Index: /issm/branches/trunk-jpl-damage/configs/config-altix64-castor.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/configs/config-altix64-castor.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/configs/config-altix64-castor.sh	(revision 12168)
@@ -1,3 +1,3 @@
 #!/bin/csh
 
-./configure --prefix=$ISSM_TIER --with-serial=no --with-metis-dir=$ISSM_TIER/externalpackages/metis/install --with-petsc-dir=$ISSM_TIER/externalpackages/petsc/install --with-mpi-include=/usr/include  --with-mpi-lib="-L/usr/lib -lmpi" --with-petsc-arch=$ISSM_ARCH --with-dakota-dir=$ISSM_TIER/externalpackages/dakota/install --with-mkl-dir=/opt/intel/mkl/9.1.023/lib/64 --with-triangle-dir=$ISSM_TIER/externalpackages/triangle/install --with-plapack-lib="-L$ISSM_TIER/externalpackages/petsc/install/$ISSM_ARCH -lPLAPACK" --with-plapack-include="-I$ISSM_TIER/externalpackages/petsc/install/externalpackages/PLAPACKR32-hg/$ISSM_ARCH/INCLUDE" --with-mumps-dir=$ISSM_TIER/externalpackages/petsc/install/$ISSM_ARCH/ --with-scalapack-dir=$ISSM_TIER/externalpackages/petsc/install/$ISSM_ARCH/ --with-blacs-dir=$ISSM_TIER/externalpackages/petsc/install/$ISSM_ARCH --with-graphics-lib=/usr/X11R6/lib/libX11.so
+./configure --prefix=$ISSM_DIR --with-serial=no --with-metis-dir=$ISSM_DIR/externalpackages/metis/install --with-petsc-dir=$ISSM_DIR/externalpackages/petsc/install --with-mpi-include=/usr/include  --with-mpi-lib="-L/usr/lib -lmpi" --with-petsc-arch=$ISSM_ARCH --with-dakota-dir=$ISSM_DIR/externalpackages/dakota/install --with-mkl-dir=/opt/intel/mkl/9.1.023/lib/64 --with-triangle-dir=$ISSM_DIR/externalpackages/triangle/install --with-plapack-lib="-L$ISSM_DIR/externalpackages/petsc/install/$ISSM_ARCH -lPLAPACK" --with-plapack-include="-I$ISSM_DIR/externalpackages/petsc/install/externalpackages/PLAPACKR32-hg/$ISSM_ARCH/INCLUDE" --with-mumps-dir=$ISSM_DIR/externalpackages/petsc/install/$ISSM_ARCH/ --with-scalapack-dir=$ISSM_DIR/externalpackages/petsc/install/$ISSM_ARCH/ --with-blacs-dir=$ISSM_DIR/externalpackages/petsc/install/$ISSM_ARCH --with-graphics-lib=/usr/X11R6/lib/libX11.so
Index: /issm/branches/trunk-jpl-damage/configs/config-arm-linux.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/configs/config-arm-linux.sh	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/configs/config-arm-linux.sh	(revision 12168)
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+pythonversion=2.7
+
+./configure \
+	--prefix=$ISSM_DIR \
+	--with-python-dir=$ISSM_DIR/externalpackages/python/install\
+	--with-python-version=$pythonversion \
+	--with-python-numpy-dir=$ISSM_DIR/externalpackages/python/install/Python.framework/Versions/$pythonversion/lib/python$pythonversion/site-packages/numpy/core/include/numpy\
+	--with-vendor=arm-linux \
+	--with-triangle-dir=$ISSM_DIR/externalpackages/triangle/install \
+	--with-gsl-dir=$ISSM_DIR/externalpackages/gsl/install
Index: /issm/branches/trunk-jpl-damage/configs/config-cosmos.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/configs/config-cosmos.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/configs/config-cosmos.sh	(revision 12168)
@@ -1,3 +1,3 @@
 #!/bin/csh
 
-./configure --prefix=$ISSM_TIER --with-serial=no --with-metis-dir=$ISSM_TIER/externalpackages/metis/install --with-petsc-dir=$ISSM_TIER/externalpackages/petsc/install --with-mpi-include=/opt/mpich/gm/intel10.1/include  --with-mpi-lib="-L/opt/mpich/gm/intel10.1/lib -lmpich -L/usr/local/gm/lib/ -lgm  -lpthread  -lrt" --with-petsc-arch=$ISSM_ARCH --with-mkl-dir=/opt/intel/mkl/10.0.5.025/lib/32/  --with-plapack-dir="-L$ISSM_TIER/externalpackages/petsc/install/$ISSM_ARCH -lPLAPACK" --with-plapack-include="-I$ISSM_TIER/externalpackages/petsc/install/externalpackages/PLAPACKR32-hg/$ISSM_ARCH/INCLUDE" --with-mumps-dir=$ISSM_TIER/externalpackages/petsc/install/$ISSM_ARCH/ --with-scalapack-dir=$ISSM_TIER/externalpackages/petsc/install/$ISSM_ARCH/ --with-blacs-dir=$ISSM_TIER/externalpackages/petsc/install/$ISSM_ARCH  --with-vendor=intel-linux --with-graphics-lib=/usr/X11R6/lib/libX11.so
+./configure --prefix=$ISSM_DIR --with-serial=no --with-metis-dir=$ISSM_DIR/externalpackages/metis/install --with-petsc-dir=$ISSM_DIR/externalpackages/petsc/install --with-mpi-include=/opt/mpich/gm/intel10.1/include  --with-mpi-lib="-L/opt/mpich/gm/intel10.1/lib -lmpich -L/usr/local/gm/lib/ -lgm  -lpthread  -lrt" --with-petsc-arch=$ISSM_ARCH --with-mkl-dir=/opt/intel/mkl/10.0.5.025/lib/32/  --with-plapack-dir="-L$ISSM_DIR/externalpackages/petsc/install/$ISSM_ARCH -lPLAPACK" --with-plapack-include="-I$ISSM_DIR/externalpackages/petsc/install/externalpackages/PLAPACKR32-hg/$ISSM_ARCH/INCLUDE" --with-mumps-dir=$ISSM_DIR/externalpackages/petsc/install/$ISSM_ARCH/ --with-scalapack-dir=$ISSM_DIR/externalpackages/petsc/install/$ISSM_ARCH/ --with-blacs-dir=$ISSM_DIR/externalpackages/petsc/install/$ISSM_ARCH  --with-vendor=intel-linux --with-graphics-lib=/usr/X11R6/lib/libX11.so
Index: /issm/branches/trunk-jpl-damage/configs/config-greenplanet.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/configs/config-greenplanet.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/configs/config-greenplanet.sh	(revision 12168)
@@ -5,19 +5,19 @@
 
 ./configure \
- --prefix=$ISSM_TIER \
- --with-serial=no \
- --with-triangle-dir=$ISSM_TIER/externalpackages/triangle/install \
- --with-metis-dir=$ISSM_TIER/externalpackages/metis/install \
- --with-petsc-dir=$ISSM_TIER/externalpackages/petsc/install \
+ --prefix=$ISSM_DIR \
+ --with-modules=no \
+ --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="/sopt/mpi/openmpi-1.5.4_psm/intel/include/" \
  --with-mpi-lib="-L/sopt/mpi/openmpi-1.5.4_psm/intel/lib/ -lmpi -lmpi_f77" \
  --with-petsc-arch=$ISSM_ARCH \
- --with-dakota-dir=$ISSM_TIER/externalpackages/dakota/install \
+ --with-dakota-dir=$ISSM_DIR/externalpackages/dakota/install \
  --with-mkl-dir=/opt/intel/mkl/10.2.4.032/ \
- --with-plapack-lib="-L$ISSM_TIER/externalpackages/petsc/install/ -lPLAPACK" \
- --with-plapack-include="-I$ISSM_TIER/externalpackages/petsc/install/externalpackages/PLAPACKR32-hg/INCLUDE" \
- --with-mumps-dir=$ISSM_TIER/externalpackages/petsc/install/ \
- --with-scalapack-dir=$ISSM_TIER/externalpackages/petsc/install/ \
- --with-blacs-dir=$ISSM_TIER/externalpackages/petsc/install/ \
+ --with-plapack-lib="-L$ISSM_DIR/externalpackages/petsc/install/ -lPLAPACK" \
+ --with-plapack-include="-I$ISSM_DIR/externalpackages/petsc/install/externalpackages/PLAPACKR32-hg/INCLUDE" \
+ --with-mumps-dir=$ISSM_DIR/externalpackages/petsc/install/ \
+ --with-scalapack-dir=$ISSM_DIR/externalpackages/petsc/install/ \
+ --with-blacs-dir=$ISSM_DIR/externalpackages/petsc/install/ \
  --with-graphics-lib=/usr/lib64/libX11.so \
  --with-cxxoptflags="-O3 -xS" \
Index: /issm/branches/trunk-jpl-damage/configs/config-linux64-astrid-ad.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/configs/config-linux64-astrid-ad.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/configs/config-linux64-astrid-ad.sh	(revision 12168)
@@ -2,22 +2,22 @@
 
 ./configure \
- --prefix=$ISSM_TIER \
+ --prefix=$ISSM_DIR \
  --with-serial=no\
- --with-metis-dir=$ISSM_TIER/externalpackages/metis/install \
- --with-petsc-dir=$ISSM_TIER/externalpackages/petsc/install \
- --with-mpi-include=$ISSM_TIER/externalpackages/mpich2/install/include  \
- --with-mpi-lib="-L$ISSM_TIER/externalpackages/mpich2/install/lib/ -lmpich" \
+ --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-blas-lapack-dir=$ISSM_TIER/externalpackages/petsc/install \
- --with-plapack-lib="-L$ISSM_TIER/externalpackages/petsc/install/ -lPLAPACK" \
- --with-plapack-include="-I$ISSM_TIER/externalpackages/petsc/install/externalpackages/PLAPACKR32-hg/INCLUDE" \
- --with-blacs-dir=$ISSM_TIER/externalpackages/petsc/install/ \
- --with-scalapack-dir=$ISSM_TIER/externalpackages/petsc/install/ \
- --with-mumps-dir=$ISSM_TIER/externalpackages/petsc/install/ \
+ --with-blas-lapack-dir=$ISSM_DIR/externalpackages/petsc/install \
+ --with-plapack-lib="-L$ISSM_DIR/externalpackages/petsc/install/ -lPLAPACK" \
+ --with-plapack-include="-I$ISSM_DIR/externalpackages/petsc/install/externalpackages/PLAPACKR32-hg/INCLUDE" \
+ --with-blacs-dir=$ISSM_DIR/externalpackages/petsc/install/ \
+ --with-scalapack-dir=$ISSM_DIR/externalpackages/petsc/install/ \
+ --with-mumps-dir=$ISSM_DIR/externalpackages/petsc/install/ \
  --with-graphics-lib=/usr/lib64/libX11.so \
  --with-cxxoptflags="-march=opteron -O2" \
  --with-fortran-lib="-L/usr/lib/gcc/x86_64-redhat-linux/4.1.1/ -lgfortran" \
- --with-rose-dir=$ISSM_TIER/externalpackages/rose/install/ \
- --with-adic2-dir=$ISSM_TIER/externalpackages/adic/install/ \
+ --with-rose-dir=$ISSM_DIR/externalpackages/rose/install/ \
+ --with-adic2-dir=$ISSM_DIR/externalpackages/adic/install/ \
  --with-numthreads=24 \
  --without-thermal \
Index: /issm/branches/trunk-jpl-damage/configs/config-linux64-astrid-mpich1.0.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/configs/config-linux64-astrid-mpich1.0.sh	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/configs/config-linux64-astrid-mpich1.0.sh	(revision 12168)
@@ -0,0 +1,31 @@
+#!/bin/sh
+
+#External packages versions:
+#petsc 3.1 or 3.2
+#mpich 1.0.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-tao-dir=$ISSM_DIR/externalpackages/tao/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 \
+ --with-plapack-lib="-L$ISSM_DIR/externalpackages/petsc/install/ -lPLAPACK" \
+ --with-plapack-include="-I$ISSM_DIR/externalpackages/petsc/install/externalpackages/PLAPACKR32-hg/INCLUDE" \
+ --with-blacs-dir=$ISSM_DIR/externalpackages/petsc/install/ \
+ --with-scalapack-dir=$ISSM_DIR/externalpackages/petsc/install/ \
+ --with-mumps-dir=$ISSM_DIR/externalpackages/petsc/install/ \
+ --with-scotch-dir="$ISSM_DIR/externalpackages/scotch/install" \
+ --with-chaco-dir="$ISSM_DIR/externalpackages/chaco/install" \
+ --with-shapelib-dir="$ISSM_DIR/externalpackages/shapelib/install" \
+ --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 \
+ --enable-debugging
Index: sm/branches/trunk-jpl-damage/configs/config-linux64-astrid-mpich1.4.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/configs/config-linux64-astrid-mpich1.4.sh	(revision 12167)
+++ 	(revision )
@@ -1,31 +1,0 @@
-#!/bin/sh
-
-#External packages versions:
-#petsc 3.1 or 3.2
-#mpich 1.4
-
-./configure \
- --prefix=$ISSM_TIER \
- --with-matlab-dir=$MATLAB_DIR \
- --with-triangle-dir=$ISSM_TIER/externalpackages/triangle/install \
- --with-metis-dir=$ISSM_TIER/externalpackages/metis/install \
- --with-petsc-dir=$ISSM_TIER/externalpackages/petsc/install \
- --with-tao-dir=$ISSM_TIER/externalpackages/tao/install \
- --with-mpi-include=$ISSM_TIER/externalpackages/mpich2/install/include  \
- --with-mpi-lib="-L$ISSM_TIER/externalpackages/mpich2/install/lib/ -lmpich -lmpl " \
- --with-petsc-arch=$ISSM_ARCH \
- --with-dakota-dir=$ISSM_TIER/externalpackages/dakota/install \
- --with-blas-lapack-dir=$ISSM_TIER/externalpackages/petsc/install \
- --with-plapack-lib="-L$ISSM_TIER/externalpackages/petsc/install/ -lPLAPACK" \
- --with-plapack-include="-I$ISSM_TIER/externalpackages/petsc/install/externalpackages/PLAPACKR32-hg/INCLUDE" \
- --with-blacs-dir=$ISSM_TIER/externalpackages/petsc/install/ \
- --with-scalapack-dir=$ISSM_TIER/externalpackages/petsc/install/ \
- --with-mumps-dir=$ISSM_TIER/externalpackages/petsc/install/ \
- --with-scotch-dir="$ISSM_TIER/externalpackages/scotch/install" \
- --with-chaco-dir="$ISSM_TIER/externalpackages/chaco/install" \
- --with-shapelib-dir="$ISSM_TIER/externalpackages/shapelib/install" \
- --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 \
- --enable-debugging
Index: /issm/branches/trunk-jpl-damage/configs/config-linux64-astrid-petsc2.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/configs/config-linux64-astrid-petsc2.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/configs/config-linux64-astrid-petsc2.sh	(revision 12168)
@@ -5,3 +5,3 @@
 #mpich 1.0.2
 
-./configure --prefix=$ISSM_TIER --with-matlab-dir=$MATLAB_DIR --with-triangle-dir=$ISSM_TIER/externalpackages/triangle/install --with-metis-dir=$ISSM_TIER/externalpackages/metis/install --with-petsc-dir=$ISSM_TIER/externalpackages/petsc/install --with-mpi-include=$ISSM_TIER/externalpackages/mpich2/install/include  --with-mpi-lib="-L$ISSM_TIER/externalpackages/mpich2/install/lib/ -lmpich" --with-petsc-arch=$ISSM_ARCH --with-dakota-dir=$ISSM_TIER/externalpackages/dakota/install --with-blas-lapack-dir=$ISSM_TIER/externalpackages/petsc/install/externalpackages/fblaslapack/$ISSM_ARCH --with-plapack-lib="-L$ISSM_TIER/externalpackages/petsc/install/externalpackages/PLAPACKR32-hg/$ISSM_ARCH -lPLAPACK" --with-plapack-include="-I$ISSM_TIER/externalpackages/petsc/install/externalpackages/PLAPACKR32-hg/$ISSM_ARCH/INCLUDE" --with-blacs-dir=$ISSM_TIER/externalpackages/petsc/install/externalpackages/blacs-dev/$ISSM_ARCH --with-scalapack-dir=$ISSM_TIER/externalpackages/petsc/install/externalpackages/SCALAPACK/$ISSM_ARCH --with-mumps-dir=$ISSM_TIER/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-scotch-dir=$ISSM_TIER/externalpackages/scotch/install --with-chaco-dir=$ISSM_TIER/externalpackages/chaco/install --enable-debugging --with-shapelib-dir=$ISSM_TIER/externalpackages/shapelib/install\
+./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-scotch-dir=$ISSM_DIR/externalpackages/scotch/install --with-chaco-dir=$ISSM_DIR/externalpackages/chaco/install --enable-debugging --with-shapelib-dir=$ISSM_DIR/externalpackages/shapelib/install\
Index: /issm/branches/trunk-jpl-damage/configs/config-linux64-astrid.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/configs/config-linux64-astrid.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/configs/config-linux64-astrid.sh	(revision 12168)
@@ -3,26 +3,26 @@
 #External packages versions:
 #petsc 3.1 or 3.2
-#mpich 1.0.2
+#mpich 1.4
 
 ./configure \
- --prefix=$ISSM_TIER \
+ --prefix=$ISSM_DIR \
  --with-matlab-dir=$MATLAB_DIR \
- --with-triangle-dir=$ISSM_TIER/externalpackages/triangle/install \
- --with-metis-dir=$ISSM_TIER/externalpackages/metis/install \
- --with-petsc-dir=$ISSM_TIER/externalpackages/petsc/install \
- --with-tao-dir=$ISSM_TIER/externalpackages/tao/install \
- --with-mpi-include=$ISSM_TIER/externalpackages/mpich2/install/include  \
- --with-mpi-lib="-L$ISSM_TIER/externalpackages/mpich2/install/lib/ -lmpich " \
+ --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-tao-dir=$ISSM_DIR/externalpackages/tao/install \
+ --with-mpi-include=$ISSM_DIR/externalpackages/mpich2/install/include  \
+ --with-mpi-lib="-L$ISSM_DIR/externalpackages/mpich2/install/lib/ -lmpich -lmpl " \
  --with-petsc-arch=$ISSM_ARCH \
- --with-dakota-dir=$ISSM_TIER/externalpackages/dakota/install \
- --with-blas-lapack-dir=$ISSM_TIER/externalpackages/petsc/install \
- --with-plapack-lib="-L$ISSM_TIER/externalpackages/petsc/install/ -lPLAPACK" \
- --with-plapack-include="-I$ISSM_TIER/externalpackages/petsc/install/externalpackages/PLAPACKR32-hg/INCLUDE" \
- --with-blacs-dir=$ISSM_TIER/externalpackages/petsc/install/ \
- --with-scalapack-dir=$ISSM_TIER/externalpackages/petsc/install/ \
- --with-mumps-dir=$ISSM_TIER/externalpackages/petsc/install/ \
- --with-scotch-dir="$ISSM_TIER/externalpackages/scotch/install" \
- --with-chaco-dir="$ISSM_TIER/externalpackages/chaco/install" \
- --with-shapelib-dir="$ISSM_TIER/externalpackages/shapelib/install" \
+ --with-dakota-dir=$ISSM_DIR/externalpackages/dakota/install \
+ --with-blas-lapack-dir=$ISSM_DIR/externalpackages/petsc/install \
+ --with-plapack-lib="-L$ISSM_DIR/externalpackages/petsc/install/ -lPLAPACK" \
+ --with-plapack-include="-I$ISSM_DIR/externalpackages/petsc/install/externalpackages/PLAPACKR32-hg/INCLUDE" \
+ --with-blacs-dir=$ISSM_DIR/externalpackages/petsc/install/ \
+ --with-scalapack-dir=$ISSM_DIR/externalpackages/petsc/install/ \
+ --with-mumps-dir=$ISSM_DIR/externalpackages/petsc/install/ \
+ --with-scotch-dir="$ISSM_DIR/externalpackages/scotch/install" \
+ --with-chaco-dir="$ISSM_DIR/externalpackages/chaco/install" \
+ --with-shapelib-dir="$ISSM_DIR/externalpackages/shapelib/install" \
  --with-fortran-lib="-L/usr/lib/gcc/x86_64-redhat-linux/4.1.1/ -lgfortran" \
  --with-graphics-lib=/usr/lib64/libX11.so \
Index: /issm/branches/trunk-jpl-damage/configs/config-linux64-murdo-ad.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/configs/config-linux64-murdo-ad.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/configs/config-linux64-murdo-ad.sh	(revision 12168)
@@ -2,23 +2,23 @@
 
 ./configure \
- --prefix=$ISSM_TIER \
+ --prefix=$ISSM_DIR \
  --with-serial=no\
- --with-metis-dir=$ISSM_TIER/externalpackages/metis/install \
- --with-petsc-dir=$ISSM_TIER/externalpackages/petsc/install \
- --with-mpi-include=$ISSM_TIER/externalpackages/mpich2/install/include  \
- --with-mpi-lib="-L$ISSM_TIER/externalpackages/mpich2/install/lib/ -lmpich" \
+ --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-blas-lapack-dir=$ISSM_TIER/externalpackages/petsc/install \
- --with-plapack-lib="-L$ISSM_TIER/externalpackages/petsc/install/ -lPLAPACK" \
- --with-plapack-include="-I$ISSM_TIER/externalpackages/petsc/install/externalpackages/PLAPACKR32-hg/INCLUDE" \
- --with-blacs-dir=$ISSM_TIER/externalpackages/petsc/install/ \
- --with-scalapack-dir=$ISSM_TIER/externalpackages/petsc/install/ \
- --with-hypre-dir=$ISSM_TIER/externalpackages/petsc/install/ \
- --with-ml-dir=$ISSM_TIER/externalpackages/petsc/install/ \
- --with-mumps-dir=$ISSM_TIER/externalpackages/petsc/install/ \
+ --with-blas-lapack-dir=$ISSM_DIR/externalpackages/petsc/install \
+ --with-plapack-lib="-L$ISSM_DIR/externalpackages/petsc/install/ -lPLAPACK" \
+ --with-plapack-include="-I$ISSM_DIR/externalpackages/petsc/install/externalpackages/PLAPACKR32-hg/INCLUDE" \
+ --with-blacs-dir=$ISSM_DIR/externalpackages/petsc/install/ \
+ --with-scalapack-dir=$ISSM_DIR/externalpackages/petsc/install/ \
+ --with-hypre-dir=$ISSM_DIR/externalpackages/petsc/install/ \
+ --with-ml-dir=$ISSM_DIR/externalpackages/petsc/install/ \
+ --with-mumps-dir=$ISSM_DIR/externalpackages/petsc/install/ \
  --with-graphics-lib=/usr/lib64/libX11.so \
  --with-cxxoptflags="-mtune=barcelona -ffast-math -O3 -msse4.2 -Wno-write-strings "\
  --with-fortran-lib="-L/usr/lib/gcc/x86_64-redhat-linux/3.4.6/ -lg2c  /usr/lib/gcc/x86_64-redhat-linux/4.1.1/libgfortran.a" \
- --with-adic2-dir=$ISSM_TIER/externalpackages/adic/install/ \
+ --with-adic2-dir=$ISSM_DIR/externalpackages/adic/install/ \
 --with-numthreads=24 \
  --without-thermal \
Index: /issm/branches/trunk-jpl-damage/configs/config-linux64-murdo-nopetsc.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/configs/config-linux64-murdo-nopetsc.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/configs/config-linux64-murdo-nopetsc.sh	(revision 12168)
@@ -2,26 +2,26 @@
 
 ./configure \
- --prefix=$ISSM_TIER \
- --with-mpi-include=$ISSM_TIER/externalpackages/mpich2/install/include  \
- --with-mpi-lib="-L$ISSM_TIER/externalpackages/mpich2/install/lib/ -lmpich" \
+ --prefix=$ISSM_DIR \
+ --with-mpi-include=$ISSM_DIR/externalpackages/mpich2/install/include  \
+ --with-mpi-lib="-L$ISSM_DIR/externalpackages/mpich2/install/lib/ -lmpich" \
  --with-matlab-dir=$MATLAB_DIR \
- --with-triangle-dir=$ISSM_TIER/externalpackages/triangle/install \
- --with-metis-dir=$ISSM_TIER/externalpackages/metis/install \
- --with-blas-lapack-dir=$ISSM_TIER/externalpackages/petsc/install/lib \
+ --with-triangle-dir=$ISSM_DIR/externalpackages/triangle/install \
+ --with-metis-dir=$ISSM_DIR/externalpackages/metis/install \
+ --with-blas-lapack-dir=$ISSM_DIR/externalpackages/petsc/install/lib \
  --with-graphics-lib=/usr/lib64/libX11.so \
- --with-scotch-dir="$ISSM_TIER/externalpackages/scotch/install" \
- --with-chaco-dir="$ISSM_TIER/externalpackages/chaco/install" \
+ --with-scotch-dir="$ISSM_DIR/externalpackages/scotch/install" \
+ --with-chaco-dir="$ISSM_DIR/externalpackages/chaco/install" \
  --with-cxxoptflags="-mtune=barcelona -ffast-math -O3 -msse4.2 -Wno-write-strings "\
  --with-numthreads=18 \
  --enable-debugging \
- --with-gsl-dir=$ISSM_TIER/externalpackages/gsl/install
+ --with-gsl-dir=$ISSM_DIR/externalpackages/gsl/install
  
  
-# --with-petsc-dir=$ISSM_TIER/externalpackages/petsc/install \
+# --with-petsc-dir=$ISSM_DIR/externalpackages/petsc/install \
 # --with-petsc-arch=$ISSM_ARCH \
-# --with-plapack-lib="-L$ISSM_TIER/externalpackages/petsc/install/ -lPLAPACK" \
-# --with-plapack-include="-I$ISSM_TIER/externalpackages/petsc/install/externalpackages/PLAPACKR32-hg/INCLUDE" \
-# --with-blacs-dir=$ISSM_TIER/externalpackages/petsc/install/ \
-# --with-scalapack-dir=$ISSM_TIER/externalpackages/petsc/install/ \
-# --with-mumps-dir=$ISSM_TIER/externalpackages/petsc/install/ \
-# --with-dakota-dir=$ISSM_TIER/externalpackages/dakota/install \
+# --with-plapack-lib="-L$ISSM_DIR/externalpackages/petsc/install/ -lPLAPACK" \
+# --with-plapack-include="-I$ISSM_DIR/externalpackages/petsc/install/externalpackages/PLAPACKR32-hg/INCLUDE" \
+# --with-blacs-dir=$ISSM_DIR/externalpackages/petsc/install/ \
+# --with-scalapack-dir=$ISSM_DIR/externalpackages/petsc/install/ \
+# --with-mumps-dir=$ISSM_DIR/externalpackages/petsc/install/ \
+# --with-dakota-dir=$ISSM_DIR/externalpackages/dakota/install \
Index: /issm/branches/trunk-jpl-damage/configs/config-linux64-murdo.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/configs/config-linux64-murdo.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/configs/config-linux64-murdo.sh	(revision 12168)
@@ -2,24 +2,24 @@
 
 ./configure \
- --prefix=$ISSM_TIER \
+ --prefix=$ISSM_DIR \
  --with-matlab-dir=$MATLAB_DIR \
- --with-triangle-dir=$ISSM_TIER/externalpackages/triangle/install \
- --with-metis-dir=$ISSM_TIER/externalpackages/metis/install \
- --with-petsc-dir=$ISSM_TIER/externalpackages/petsc/install \
- --with-mpi-include=$ISSM_TIER/externalpackages/mpich2/install/include  \
- --with-mpi-lib="-L$ISSM_TIER/externalpackages/mpich2/install/lib/ -lmpich" \
+ --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-blas-lapack-dir=$ISSM_TIER/externalpackages/petsc/install \
- --with-plapack-lib="-L$ISSM_TIER/externalpackages/petsc/install/ -lPLAPACK" \
- --with-plapack-include="-I$ISSM_TIER/externalpackages/petsc/install/externalpackages/PLAPACKR32-hg/INCLUDE" \
- --with-blacs-dir=$ISSM_TIER/externalpackages/petsc/install/ \
- --with-scalapack-dir=$ISSM_TIER/externalpackages/petsc/install/ \
- --with-mumps-dir=$ISSM_TIER/externalpackages/petsc/install/ \
- --with-scotch-dir="$ISSM_TIER/externalpackages/scotch/install" \
- --with-chaco-dir="$ISSM_TIER/externalpackages/chaco/install" \
+ --with-blas-lapack-dir=$ISSM_DIR/externalpackages/petsc/install \
+ --with-plapack-lib="-L$ISSM_DIR/externalpackages/petsc/install/ -lPLAPACK" \
+ --with-plapack-include="-I$ISSM_DIR/externalpackages/petsc/install/externalpackages/PLAPACKR32-hg/INCLUDE" \
+ --with-blacs-dir=$ISSM_DIR/externalpackages/petsc/install/ \
+ --with-scalapack-dir=$ISSM_DIR/externalpackages/petsc/install/ \
+ --with-mumps-dir=$ISSM_DIR/externalpackages/petsc/install/ \
+ --with-scotch-dir="$ISSM_DIR/externalpackages/scotch/install" \
+ --with-chaco-dir="$ISSM_DIR/externalpackages/chaco/install" \
  --with-graphics-lib=/usr/lib64/libX11.so \
  --with-cxxoptflags="-mtune=barcelona -ffast-math -O3 -msse4.2 -Wno-write-strings "\
  --with-numthreads=18 \
- --with-dakota-dir=$ISSM_TIER/externalpackages/dakota/install \
+ --with-dakota-dir=$ISSM_DIR/externalpackages/dakota/install \
  --enable-debugging
  
Index: /issm/branches/trunk-jpl-damage/configs/config-macosx32-mathieu.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/configs/config-macosx32-mathieu.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/configs/config-macosx32-mathieu.sh	(revision 12168)
@@ -10,19 +10,19 @@
 
 ./configure \
-	--prefix=$ISSM_TIER \
+	--prefix=$ISSM_DIR \
 	--with-matlab-dir=$MATLAB_DIR \
-	--with-triangle-dir=$ISSM_TIER/externalpackages/triangle/install \
-	--with-metis-dir=$ISSM_TIER/externalpackages/metis/install \
-	--with-petsc-dir=$ISSM_TIER/externalpackages/petsc/install  \
-	--with-mpi-include=$ISSM_TIER/externalpackages/mpich2/install/include  \
-	--with-mpi-lib=" $ISSM_TIER/externalpackages/mpich2/install/lib/libpmpich.a $ISSM_TIER/externalpackages/mpich2/install/lib/libmpich.a $ISSM_TIER/externalpackages/mpich2/install/lib/libmpl.a " \
+	--with-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=" $ISSM_DIR/externalpackages/mpich2/install/lib/libpmpich.a $ISSM_DIR/externalpackages/mpich2/install/lib/libmpich.a $ISSM_DIR/externalpackages/mpich2/install/lib/libmpl.a " \
 	--with-petsc-arch=$ISSM_ARCH \
-	--with-dakota-dir=$ISSM_TIER/externalpackages/dakota/install \
-	--with-blas-lapack-dir=$ISSM_TIER/externalpackages/petsc/install \
-	--with-plapack-lib="-L$ISSM_TIER/externalpackages/petsc/install/ -lPLAPACK" \
-	--with-plapack-include="-I$ISSM_TIER/externalpackages/petsc/install/include/ " \
-	--with-blacs-dir=$ISSM_TIER/externalpackages/petsc/install/ \
-	--with-scalapack-dir=$ISSM_TIER/externalpackages/petsc/install/ \
-	--with-mumps-dir=$ISSM_TIER/externalpackages/petsc/install/ \
+	--with-dakota-dir=$ISSM_DIR/externalpackages/dakota/install \
+	--with-blas-lapack-dir=$ISSM_DIR/externalpackages/petsc/install \
+	--with-plapack-lib="-L$ISSM_DIR/externalpackages/petsc/install/ -lPLAPACK" \
+	--with-plapack-include="-I$ISSM_DIR/externalpackages/petsc/install/include/ " \
+	--with-blacs-dir=$ISSM_DIR/externalpackages/petsc/install/ \
+	--with-scalapack-dir=$ISSM_DIR/externalpackages/petsc/install/ \
+	--with-mumps-dir=$ISSM_DIR/externalpackages/petsc/install/ \
 	--with-fortran-lib="/usr/local/lib/libgfortran.a" \
 	--with-math-lib="/usr/lib/libm.dylib" \
Index: /issm/branches/trunk-jpl-damage/configs/config-macosx32-ogive.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/configs/config-macosx32-ogive.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/configs/config-macosx32-ogive.sh	(revision 12168)
@@ -5,19 +5,19 @@
 
 ./configure \
-	--prefix=$ISSM_TIER \
+	--prefix=$ISSM_DIR \
 	--with-matlab-dir=$MATLAB_DIR \
-	--with-triangle-dir=$ISSM_TIER/externalpackages/triangle/install \
-	--with-metis-dir=$ISSM_TIER/externalpackages/metis/install \
-	--with-petsc-dir=$ISSM_TIER/externalpackages/petsc/install  \
-	--with-mpi-include=$ISSM_TIER/externalpackages/mpich2/install/include  \
-	--with-mpi-lib=" $ISSM_TIER/externalpackages/mpich2/install/lib/libpmpich.a $ISSM_TIER/externalpackages/mpich2/install/lib/libmpich.a $ISSM_TIER/externalpackages/mpich2/install/lib/libmpl.a " \
+	--with-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=" $ISSM_DIR/externalpackages/mpich2/install/lib/libpmpich.a $ISSM_DIR/externalpackages/mpich2/install/lib/libmpich.a $ISSM_DIR/externalpackages/mpich2/install/lib/libmpl.a " \
 	--with-petsc-arch=$ISSM_ARCH \
-	--with-dakota-dir=$ISSM_TIER/externalpackages/dakota/install \
-	--with-blas-lapack-dir=$ISSM_TIER/externalpackages/petsc/install \
-	--with-plapack-lib="-L$ISSM_TIER/externalpackages/petsc/install/ -lPLAPACK" \
-	--with-plapack-include="-I$ISSM_TIER/externalpackages/petsc/install/include/ " \
-	--with-blacs-dir=$ISSM_TIER/externalpackages/petsc/install/ \
-	--with-scalapack-dir=$ISSM_TIER/externalpackages/petsc/install/ \
-	--with-mumps-dir=$ISSM_TIER/externalpackages/petsc/install/ \
+	--with-dakota-dir=$ISSM_DIR/externalpackages/dakota/install \
+	--with-blas-lapack-dir=$ISSM_DIR/externalpackages/petsc/install \
+	--with-plapack-lib="-L$ISSM_DIR/externalpackages/petsc/install/ -lPLAPACK" \
+	--with-plapack-include="-I$ISSM_DIR/externalpackages/petsc/install/include/ " \
+	--with-blacs-dir=$ISSM_DIR/externalpackages/petsc/install/ \
+	--with-scalapack-dir=$ISSM_DIR/externalpackages/petsc/install/ \
+	--with-mumps-dir=$ISSM_DIR/externalpackages/petsc/install/ \
 	--with-fortran-lib="/usr/local/gfortran/lib/libgfortran.a" \
 	--with-math-lib="/usr/lib/libm.dylib" \
Index: /issm/branches/trunk-jpl-damage/configs/config-macosx64-larour-ad.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/configs/config-macosx64-larour-ad.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/configs/config-macosx64-larour-ad.sh	(revision 12168)
@@ -6,17 +6,17 @@
 ./configure \
 	--with-serial=no\
-	--prefix=$ISSM_TIER \
-	--with-metis-dir=$ISSM_TIER/externalpackages/metis/install \
-	--with-mpi-include=$ISSM_TIER/externalpackages/mpich2/install/include  \
-	--with-mpi-lib=" $ISSM_TIER/externalpackages/mpich2/install/lib/libpmpich.a $ISSM_TIER/externalpackages/mpich2/install/lib/libmpich.a $ISSM_TIER/externalpackages/mpich2/install/lib/libmpl.a " \
+	--prefix=$ISSM_DIR \
+	--with-metis-dir=$ISSM_DIR/externalpackages/metis/install \
+	--with-mpi-include=$ISSM_DIR/externalpackages/mpich2/install/include  \
+	--with-mpi-lib=" $ISSM_DIR/externalpackages/mpich2/install/lib/libpmpich.a $ISSM_DIR/externalpackages/mpich2/install/lib/libmpich.a $ISSM_DIR/externalpackages/mpich2/install/lib/libmpl.a " \
 	--without-blas-lapack-dir \
-	--with-chaco-dir=$ISSM_TIER/externalpackages/chaco/install \
+	--with-chaco-dir=$ISSM_DIR/externalpackages/chaco/install \
 	--with-fortran-lib="/usr/local/gfortran/lib/libgfortran.a" \
-	--with-dakota-dir=$ISSM_TIER/externalpackages/dakota/install \
+	--with-dakota-dir=$ISSM_DIR/externalpackages/dakota/install \
 	--with-math-lib="/usr/lib/libm.dylib" \
 	--with-graphics-lib="/usr/X11/lib/libX11.dylib" \
 	--with-cxxoptflags=" -fno-common -no-cpp-precomp -fexceptions -arch x86_64 -mmacosx-version-min=10.5  -O3 -DNDEBUG -w "\
-	--with-adic2-dir=$ISSM_TIER/externalpackages/adic/install/ \
-	--with-adolc-dir=$ISSM_TIER/externalpackages/adolc/install/ \
+	--with-adic2-dir=$ISSM_DIR/externalpackages/adic/install/ \
+	--with-adolc-dir=$ISSM_DIR/externalpackages/adolc/install/ \
 	--with-numthreads=8 \
 	--without-thermal \
@@ -34,10 +34,10 @@
  
 #--without-prognostic \
-#--with-petsc-dir=$ISSM_TIER/externalpackages/petsc/install  \
+#--with-petsc-dir=$ISSM_DIR/externalpackages/petsc/install  \
 #--with-petsc-arch=$ISSM_ARCH \
-#--with-blas-lapack-dir=$ISSM_TIER/externalpackages/petsc/install \
-#--with-plapack-lib="-L$ISSM_TIER/externalpackages/petsc/install/ -lPLAPACK" \
-#--with-plapack-include="-I$ISSM_TIER/externalpackages/petsc/install/include/ " \
-#--with-blacs-dir=$ISSM_TIER/externalpackages/petsc/install/ \
-#--with-scalapack-dir=$ISSM_TIER/externalpackages/petsc/install/ \
-#--with-mumps-dir=$ISSM_TIER/externalpackages/petsc/install/ \
+#--with-blas-lapack-dir=$ISSM_DIR/externalpackages/petsc/install \
+#--with-plapack-lib="-L$ISSM_DIR/externalpackages/petsc/install/ -lPLAPACK" \
+#--with-plapack-include="-I$ISSM_DIR/externalpackages/petsc/install/include/ " \
+#--with-blacs-dir=$ISSM_DIR/externalpackages/petsc/install/ \
+#--with-scalapack-dir=$ISSM_DIR/externalpackages/petsc/install/ \
+#--with-mumps-dir=$ISSM_DIR/externalpackages/petsc/install/ \
Index: /issm/branches/trunk-jpl-damage/configs/config-macosx64-larour-bothapis.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/configs/config-macosx64-larour-bothapis.sh	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/configs/config-macosx64-larour-bothapis.sh	(revision 12168)
@@ -0,0 +1,33 @@
+#!/bin/sh
+
+#petsc 3.2
+#mpich 1.4
+
+pythonversion=2.7
+
+./configure \
+	--prefix=$ISSM_DIR \
+	--with-triangle-dir=$ISSM_DIR/externalpackages/triangle/install \
+	--with-matlab-dir=$MATLAB_DIR \
+	--with-python-dir=$ISSM_DIR/externalpackages/python/install\
+	--with-python-version=$pythonversion \
+	--with-python-numpy-dir=$ISSM_DIR/externalpackages/python/install/Python.framework/Versions/$pythonversion/lib/python$pythonversion/site-packages/numpy/core/include/numpy\
+	--with-metis-dir=$ISSM_DIR/externalpackages/metis/install \
+	--with-mpi-include=$ISSM_DIR/externalpackages/mpich2/install/include  \
+	--with-mpi-lib=" $ISSM_DIR/externalpackages/mpich2/install/lib/libpmpich.a $ISSM_DIR/externalpackages/mpich2/install/lib/libmpich.a $ISSM_DIR/externalpackages/mpich2/install/lib/libmpl.a " \
+	--with-chaco-dir=$ISSM_DIR/externalpackages/chaco/install \
+	--with-fortran-lib="/usr/local/gfortran/lib/libgfortran.a" \
+	--with-math-lib="/usr/lib/libm.dylib" \
+	--with-graphics-lib="/usr/X11/lib/libX11.dylib" \
+	--with-cxxoptflags=" -fno-common -no-cpp-precomp -fexceptions -arch x86_64 -mmacosx-version-min=10.5  -O3 -DNDEBUG -w "\
+	--with-numthreads=8 \
+	--with-petsc-dir=$ISSM_DIR/externalpackages/petsc/install  \
+	--with-petsc-arch=$ISSM_ARCH \
+	--with-blas-lapack-dir=$ISSM_DIR/externalpackages/petsc/install \
+	--with-plapack-lib="-L$ISSM_DIR/externalpackages/petsc/install/ -lPLAPACK" \
+	--with-plapack-include="-I$ISSM_DIR/externalpackages/petsc/install/include/ " \
+	--with-blacs-dir=$ISSM_DIR/externalpackages/petsc/install/ \
+	--with-scalapack-dir=$ISSM_DIR/externalpackages/petsc/install/ \
+	--with-mumps-dir=$ISSM_DIR/externalpackages/petsc/install/ 
+	#--with-dakota-dir=$ISSM_DIR/externalpackages/dakota/install \
+	#--with-boost-dir=$ISSM_DIR/externalpackages/boost/install/ \
Index: /issm/branches/trunk-jpl-damage/configs/config-macosx64-larour-nopetsc.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/configs/config-macosx64-larour-nopetsc.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/configs/config-macosx64-larour-nopetsc.sh	(revision 12168)
@@ -1,28 +1,15 @@
 #!/bin/sh
 
-#petsc 3.2
-#mpich 1.4
+pythonversion=3.2
 
 ./configure \
-	--prefix=$ISSM_TIER \
-	--with-mpi-include=$ISSM_TIER/externalpackages/mpich2/install/include  \
-	--with-mpi-lib=" $ISSM_TIER/externalpackages/mpich2/install/lib/libpmpich.a $ISSM_TIER/externalpackages/mpich2/install/lib/libmpich.a $ISSM_TIER/externalpackages/mpich2/install/lib/libmpl.a " \
+	--prefix=$ISSM_DIR \
 	--with-matlab-dir=$MATLAB_DIR \
-	--with-triangle-dir=$ISSM_TIER/externalpackages/triangle/install \
-	--with-metis-dir=$ISSM_TIER/externalpackages/metis/install \
-	--with-chaco-dir=$ISSM_TIER/externalpackages/chaco/install \
-	--with-fortran-lib="/usr/local/gfortran/lib/libgfortran.a" \
+	--with-python-dir=$ISSM_DIR/externalpackages/python/install\
+	--with-python-version=$pythonversion \
+	--with-python-numpy-dir=$ISSM_DIR/externalpackages/python/install/Python.framework/Versions/$pythonversion/lib/python$pythonversion/site-packages/numpy/core/include/numpy\
+	--with-triangle-dir=$ISSM_DIR/externalpackages/triangle/install \
 	--with-math-lib="/usr/lib/libm.dylib" \
-	--with-blas-lapack-dir=$ISSM_TIER/externalpackages/petsc/install/lib \
 	--with-graphics-lib="/usr/X11/lib/libX11.dylib" \
 	--with-cxxoptflags=" -fno-common -no-cpp-precomp -fexceptions -arch x86_64 -mmacosx-version-min=10.5  -O3 -DNDEBUG -w "\
-	--with-numthreads=8 \
-	--with-gsl-dir=$ISSM_TIER/externalpackages/gsl/install
-#	--with-petsc-dir=$ISSM_TIER/externalpackages/petsc/install  \
-#	--with-petsc-arch=$ISSM_ARCH \
-#	--with-plapack-lib="-L$ISSM_TIER/externalpackages/petsc/install/ -lPLAPACK" \
-#	--with-plapack-include="-I$ISSM_TIER/externalpackages/petsc/install/include/ " \
-#	--with-blacs-dir=$ISSM_TIER/externalpackages/petsc/install/ \
-#	--with-scalapack-dir=$ISSM_TIER/externalpackages/petsc/install/ \
-#	--with-mumps-dir=$ISSM_TIER/externalpackages/petsc/install/ 
-#   --with-dakota-dir=$ISSM_TIER/externalpackages/dakota/install \
+	--with-gsl-dir=$ISSM_DIR/externalpackages/gsl/install
Index: /issm/branches/trunk-jpl-damage/configs/config-macosx64-larour-python.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/configs/config-macosx64-larour-python.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/configs/config-macosx64-larour-python.sh	(revision 12168)
@@ -5,12 +5,12 @@
 
 ./configure \
-	--prefix=$ISSM_TIER \
-	--with-triangle-dir=$ISSM_TIER/externalpackages/triangle/install \
-	--with-python-dir=$ISSM_TIER/externalpackages/python/install\
-	--with-python-numpy-dir=$ISSM_TIER/externalpackages/python/install/Python.framework/Versions/3.2/lib/python3.2/site-packages/numpy/core/include/numpy\
-	--with-metis-dir=$ISSM_TIER/externalpackages/metis/install \
-	--with-mpi-include=$ISSM_TIER/externalpackages/mpich2/install/include  \
-	--with-mpi-lib=" $ISSM_TIER/externalpackages/mpich2/install/lib/libpmpich.a $ISSM_TIER/externalpackages/mpich2/install/lib/libmpich.a $ISSM_TIER/externalpackages/mpich2/install/lib/libmpl.a " \
-	--with-chaco-dir=$ISSM_TIER/externalpackages/chaco/install \
+	--prefix=$ISSM_DIR \
+	--with-triangle-dir=$ISSM_DIR/externalpackages/triangle/install \
+	--with-python-dir=$ISSM_DIR/externalpackages/python/install\
+	--with-python-numpy-dir=$ISSM_DIR/externalpackages/python/install/Python.framework/Versions/3.2/lib/python3.2/site-packages/numpy/core/include/numpy\
+	--with-metis-dir=$ISSM_DIR/externalpackages/metis/install \
+	--with-mpi-include=$ISSM_DIR/externalpackages/mpich2/install/include  \
+	--with-mpi-lib=" $ISSM_DIR/externalpackages/mpich2/install/lib/libpmpich.a $ISSM_DIR/externalpackages/mpich2/install/lib/libmpich.a $ISSM_DIR/externalpackages/mpich2/install/lib/libmpl.a " \
+	--with-chaco-dir=$ISSM_DIR/externalpackages/chaco/install \
 	--with-fortran-lib="/usr/local/gfortran/lib/libgfortran.a" \
 	--with-math-lib="/usr/lib/libm.dylib" \
@@ -18,12 +18,12 @@
 	--with-cxxoptflags=" -fno-common -no-cpp-precomp -fexceptions -arch x86_64 -mmacosx-version-min=10.5  -O3 -DNDEBUG -w "\
 	--with-numthreads=8 \
-	--with-petsc-dir=$ISSM_TIER/externalpackages/petsc/install  \
+	--with-petsc-dir=$ISSM_DIR/externalpackages/petsc/install  \
 	--with-petsc-arch=$ISSM_ARCH \
-	--with-blas-lapack-dir=$ISSM_TIER/externalpackages/petsc/install \
-	--with-plapack-lib="-L$ISSM_TIER/externalpackages/petsc/install/ -lPLAPACK" \
-	--with-plapack-include="-I$ISSM_TIER/externalpackages/petsc/install/include/ " \
-	--with-blacs-dir=$ISSM_TIER/externalpackages/petsc/install/ \
-	--with-scalapack-dir=$ISSM_TIER/externalpackages/petsc/install/ \
-	--with-mumps-dir=$ISSM_TIER/externalpackages/petsc/install/ 
-	#--with-dakota-dir=$ISSM_TIER/externalpackages/dakota/install \
-	#--with-boost-dir=$ISSM_TIER/externalpackages/boost/install/ \
+	--with-blas-lapack-dir=$ISSM_DIR/externalpackages/petsc/install \
+	--with-plapack-lib="-L$ISSM_DIR/externalpackages/petsc/install/ -lPLAPACK" \
+	--with-plapack-include="-I$ISSM_DIR/externalpackages/petsc/install/include/ " \
+	--with-blacs-dir=$ISSM_DIR/externalpackages/petsc/install/ \
+	--with-scalapack-dir=$ISSM_DIR/externalpackages/petsc/install/ \
+	--with-mumps-dir=$ISSM_DIR/externalpackages/petsc/install/ 
+	#--with-dakota-dir=$ISSM_DIR/externalpackages/dakota/install \
+	#--with-boost-dir=$ISSM_DIR/externalpackages/boost/install/ \
Index: /issm/branches/trunk-jpl-damage/configs/config-macosx64-larour.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/configs/config-macosx64-larour.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/configs/config-macosx64-larour.sh	(revision 12168)
@@ -5,11 +5,11 @@
 
 ./configure \
-	--prefix=$ISSM_TIER \
+	--prefix=$ISSM_DIR \
 	--with-matlab-dir=$MATLAB_DIR \
-	--with-triangle-dir=$ISSM_TIER/externalpackages/triangle/install \
-	--with-metis-dir=$ISSM_TIER/externalpackages/metis/install \
-	--with-mpi-include=$ISSM_TIER/externalpackages/mpich2/install/include  \
-	--with-mpi-lib=" $ISSM_TIER/externalpackages/mpich2/install/lib/libpmpich.a $ISSM_TIER/externalpackages/mpich2/install/lib/libmpich.a $ISSM_TIER/externalpackages/mpich2/install/lib/libmpl.a " \
-	--with-chaco-dir=$ISSM_TIER/externalpackages/chaco/install \
+	--with-triangle-dir=$ISSM_DIR/externalpackages/triangle/install \
+	--with-metis-dir=$ISSM_DIR/externalpackages/metis/install \
+	--with-mpi-include=$ISSM_DIR/externalpackages/mpich2/install/include  \
+	--with-mpi-lib=" $ISSM_DIR/externalpackages/mpich2/install/lib/libpmpich.a $ISSM_DIR/externalpackages/mpich2/install/lib/libmpich.a $ISSM_DIR/externalpackages/mpich2/install/lib/libmpl.a " \
+	--with-chaco-dir=$ISSM_DIR/externalpackages/chaco/install \
 	--with-fortran-lib="/usr/local/gfortran/lib/libgfortran.a" \
 	--with-math-lib="/usr/lib/libm.dylib" \
@@ -17,11 +17,11 @@
 	--with-cxxoptflags=" -fno-common -no-cpp-precomp -fexceptions -arch x86_64 -mmacosx-version-min=10.5  -O3 -DNDEBUG -w "\
 	--with-numthreads=8 \
-	--with-petsc-dir=$ISSM_TIER/externalpackages/petsc/install  \
+	--with-petsc-dir=$ISSM_DIR/externalpackages/petsc/install  \
 	--with-petsc-arch=$ISSM_ARCH \
-	--with-blas-lapack-dir=$ISSM_TIER/externalpackages/petsc/install \
-	--with-plapack-lib="-L$ISSM_TIER/externalpackages/petsc/install/ -lPLAPACK" \
-	--with-plapack-include="-I$ISSM_TIER/externalpackages/petsc/install/include/ " \
-	--with-blacs-dir=$ISSM_TIER/externalpackages/petsc/install/ \
-	--with-scalapack-dir=$ISSM_TIER/externalpackages/petsc/install/ \
-	--with-mumps-dir=$ISSM_TIER/externalpackages/petsc/install/ 
-	#--with-dakota-dir=$ISSM_TIER/externalpackages/dakota/install \
+	--with-blas-lapack-dir=$ISSM_DIR/externalpackages/petsc/install \
+	--with-plapack-lib="-L$ISSM_DIR/externalpackages/petsc/install/ -lPLAPACK" \
+	--with-plapack-include="-I$ISSM_DIR/externalpackages/petsc/install/include/ " \
+	--with-blacs-dir=$ISSM_DIR/externalpackages/petsc/install/ \
+	--with-scalapack-dir=$ISSM_DIR/externalpackages/petsc/install/ \
+	--with-mumps-dir=$ISSM_DIR/externalpackages/petsc/install/ 
+	#--with-dakota-dir=$ISSM_DIR/externalpackages/dakota/install \
Index: /issm/branches/trunk-jpl-damage/configs/config-macosx64-mathieu.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/configs/config-macosx64-mathieu.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/configs/config-macosx64-mathieu.sh	(revision 12168)
@@ -5,19 +5,19 @@
 
 ./configure \
-	--prefix=$ISSM_TIER \
+	--prefix=$ISSM_DIR \
 	--with-matlab-dir=$MATLAB_DIR \
-	--with-triangle-dir=$ISSM_TIER/externalpackages/triangle/install \
-	--with-metis-dir=$ISSM_TIER/externalpackages/metis/install \
-	--with-petsc-dir=$ISSM_TIER/externalpackages/petsc/install  \
-	--with-mpi-include=$ISSM_TIER/externalpackages/mpich2/install/include  \
-	--with-mpi-lib=" $ISSM_TIER/externalpackages/mpich2/install/lib/libpmpich.a $ISSM_TIER/externalpackages/mpich2/install/lib/libmpich.a $ISSM_TIER/externalpackages/mpich2/install/lib/libmpl.a " \
+	--with-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=" $ISSM_DIR/externalpackages/mpich2/install/lib/libpmpich.a $ISSM_DIR/externalpackages/mpich2/install/lib/libmpich.a $ISSM_DIR/externalpackages/mpich2/install/lib/libmpl.a " \
 	--with-petsc-arch=$ISSM_ARCH \
-	--with-dakota-dir=$ISSM_TIER/externalpackages/dakota/install \
-	--with-blas-lapack-dir=$ISSM_TIER/externalpackages/petsc/install \
-	--with-plapack-lib="-L$ISSM_TIER/externalpackages/petsc/install/ -lPLAPACK" \
-	--with-plapack-include="-I$ISSM_TIER/externalpackages/petsc/install/include/ " \
-	--with-blacs-dir=$ISSM_TIER/externalpackages/petsc/install/ \
-	--with-scalapack-dir=$ISSM_TIER/externalpackages/petsc/install/ \
-	--with-mumps-dir=$ISSM_TIER/externalpackages/petsc/install/ \
+	--with-dakota-dir=$ISSM_DIR/externalpackages/dakota/install \
+	--with-blas-lapack-dir=$ISSM_DIR/externalpackages/petsc/install \
+	--with-plapack-lib="-L$ISSM_DIR/externalpackages/petsc/install/ -lPLAPACK" \
+	--with-plapack-include="-I$ISSM_DIR/externalpackages/petsc/install/include/ " \
+	--with-blacs-dir=$ISSM_DIR/externalpackages/petsc/install/ \
+	--with-scalapack-dir=$ISSM_DIR/externalpackages/petsc/install/ \
+	--with-mumps-dir=$ISSM_DIR/externalpackages/petsc/install/ \
 	--with-fortran-lib="/usr/local/lib/libgfortran.a" \
 	--with-math-lib="/usr/lib/libm.dylib" \
Index: /issm/branches/trunk-jpl-damage/configs/config-macosx64-nicole.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/configs/config-macosx64-nicole.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/configs/config-macosx64-nicole.sh	(revision 12168)
@@ -5,21 +5,21 @@
 
 ./configure \
-	--prefix=$ISSM_TIER \
+	--prefix=$ISSM_DIR \
 	--with-matlab-dir=$MATLAB_DIR \
-	--with-triangle-dir=$ISSM_TIER/externalpackages/triangle/install \
-	--with-metis-dir=$ISSM_TIER/externalpackages/metis/install \
-	--with-petsc-dir=$ISSM_TIER/externalpackages/petsc/install  \
-	--with-mpi-include=$ISSM_TIER/externalpackages/mpich2/install/include  \
-	--with-mpi-lib=" $ISSM_TIER/externalpackages/mpich2/install/lib/libpmpich.a $ISSM_TIER/externalpackages/mpich2/install/lib/libmpich.a $ISSM_TIER/externalpackages/mpich2/install/lib/libmpl.a " \
+	--with-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=" $ISSM_DIR/externalpackages/mpich2/install/lib/libpmpich.a $ISSM_DIR/externalpackages/mpich2/install/lib/libmpich.a $ISSM_DIR/externalpackages/mpich2/install/lib/libmpl.a " \
 	--with-petsc-arch=$ISSM_ARCH \
-	--with-dakota-dir=$ISSM_TIER/externalpackages/dakota/install \
-	--with-blas-lapack-dir=$ISSM_TIER/externalpackages/petsc/install \
-	--with-plapack-lib="-L$ISSM_TIER/externalpackages/petsc/install -lPLAPACK" \
-	--with-plapack-include="-I$ISSM_TIER/externalpackages/petsc/install/include/ " \
-	--with-blacs-dir=$ISSM_TIER/externalpackages/petsc/install \
-	--with-scalapack-dir=$ISSM_TIER/externalpackages/petsc/install \
-	--with-mumps-dir=$ISSM_TIER/externalpackages/petsc/install \
-	--with-scotch-dir="$ISSM_TIER/externalpackages/scotch/install" \
-	--with-chaco-dir="$ISSM_TIER/externalpackages/chaco/install" \
+	--with-dakota-dir=$ISSM_DIR/externalpackages/dakota/install \
+	--with-blas-lapack-dir=$ISSM_DIR/externalpackages/petsc/install \
+	--with-plapack-lib="-L$ISSM_DIR/externalpackages/petsc/install -lPLAPACK" \
+	--with-plapack-include="-I$ISSM_DIR/externalpackages/petsc/install/include/ " \
+	--with-blacs-dir=$ISSM_DIR/externalpackages/petsc/install \
+	--with-scalapack-dir=$ISSM_DIR/externalpackages/petsc/install \
+	--with-mumps-dir=$ISSM_DIR/externalpackages/petsc/install \
+	--with-scotch-dir="$ISSM_DIR/externalpackages/scotch/install" \
+	--with-chaco-dir="$ISSM_DIR/externalpackages/chaco/install" \
 	--with-fortran-lib="/usr/local/gfortran/lib/gcc/x86_64-apple-darwin10/4.6.2/libgfortran.a" \
 	--with-math-lib="/usr/lib/libm.dylib" \
Index: /issm/branches/trunk-jpl-damage/configs/config-macosx64-ogive.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/configs/config-macosx64-ogive.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/configs/config-macosx64-ogive.sh	(revision 12168)
@@ -9,19 +9,19 @@
 
 ./configure \
-	--prefix=$ISSM_TIER \
+	--prefix=$ISSM_DIR \
 	--with-matlab-dir=$MATLAB_DIR \
-	--with-triangle-dir=$ISSM_TIER/externalpackages/triangle/install \
-	--with-metis-dir=$ISSM_TIER/externalpackages/metis/install \
-	--with-petsc-dir=$ISSM_TIER/externalpackages/petsc/install  \
-	--with-mpi-include=$ISSM_TIER/externalpackages/mpich2/install/include  \
-	--with-mpi-lib=" $ISSM_TIER/externalpackages/mpich2/install/lib/libpmpich.a $ISSM_TIER/externalpackages/mpich2/install/lib/libmpich.a $ISSM_TIER/externalpackages/mpich2/install/lib/libmpl.a " \
+	--with-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=" $ISSM_DIR/externalpackages/mpich2/install/lib/libpmpich.a $ISSM_DIR/externalpackages/mpich2/install/lib/libmpich.a $ISSM_DIR/externalpackages/mpich2/install/lib/libmpl.a " \
 	--with-petsc-arch=$ISSM_ARCH \
-	--with-dakota-dir=$ISSM_TIER/externalpackages/dakota/install \
-	--with-blas-lapack-dir=$ISSM_TIER/externalpackages/petsc/install \
-	--with-plapack-lib="-L$ISSM_TIER/externalpackages/petsc/install/ -lPLAPACK" \
-	--with-plapack-include="-I$ISSM_TIER/externalpackages/petsc/install/include/ " \
-	--with-blacs-dir=$ISSM_TIER/externalpackages/petsc/install/ \
-	--with-scalapack-dir=$ISSM_TIER/externalpackages/petsc/install/ \
-	--with-mumps-dir=$ISSM_TIER/externalpackages/petsc/install/ \
+	--with-dakota-dir=$ISSM_DIR/externalpackages/dakota/install \
+	--with-blas-lapack-dir=$ISSM_DIR/externalpackages/petsc/install \
+	--with-plapack-lib="-L$ISSM_DIR/externalpackages/petsc/install/ -lPLAPACK" \
+	--with-plapack-include="-I$ISSM_DIR/externalpackages/petsc/install/include/ " \
+	--with-blacs-dir=$ISSM_DIR/externalpackages/petsc/install/ \
+	--with-scalapack-dir=$ISSM_DIR/externalpackages/petsc/install/ \
+	--with-mumps-dir=$ISSM_DIR/externalpackages/petsc/install/ \
 	--with-fortran-lib="/usr/local/gfortran/lib/x86_64/libgfortran.a" \
 	--with-math-lib="/usr/lib/libm.dylib" \
Index: /issm/branches/trunk-jpl-damage/configs/config-macosx64-sophie.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/configs/config-macosx64-sophie.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/configs/config-macosx64-sophie.sh	(revision 12168)
@@ -9,19 +9,19 @@
 
 ./configure \
-	--prefix=$ISSM_TIER \
+	--prefix=$ISSM_DIR \
 	--with-matlab-dir=$MATLAB_DIR \
-	--with-triangle-dir=$ISSM_TIER/externalpackages/triangle/install \
-	--with-metis-dir=$ISSM_TIER/externalpackages/metis/install \
-	--with-petsc-dir=$ISSM_TIER/externalpackages/petsc/install  \
-	--with-mpi-include=$ISSM_TIER/externalpackages/mpich2/install/include  \
-	--with-mpi-lib=" $ISSM_TIER/externalpackages/mpich2/install/lib/libpmpich.a $ISSM_TIER/externalpackages/mpich2/install/lib/libmpich.a $ISSM_TIER/externalpackages/mpich2/install/lib/libmpl.a " \
+	--with-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=" $ISSM_DIR/externalpackages/mpich2/install/lib/libpmpich.a $ISSM_DIR/externalpackages/mpich2/install/lib/libmpich.a $ISSM_DIR/externalpackages/mpich2/install/lib/libmpl.a " \
 	--with-petsc-arch=$ISSM_ARCH \
-	--with-dakota-dir=$ISSM_TIER/externalpackages/dakota/install \
-	--with-blas-lapack-dir=$ISSM_TIER/externalpackages/petsc/install \
-	--with-plapack-lib="-L$ISSM_TIER/externalpackages/petsc/install/ -lPLAPACK" \
-	--with-plapack-include="-I$ISSM_TIER/externalpackages/petsc/install/include/ " \
-	--with-blacs-dir=$ISSM_TIER/externalpackages/petsc/install/ \
-	--with-scalapack-dir=$ISSM_TIER/externalpackages/petsc/install/ \
-	--with-mumps-dir=$ISSM_TIER/externalpackages/petsc/install/ \
+	--with-dakota-dir=$ISSM_DIR/externalpackages/dakota/install \
+	--with-blas-lapack-dir=$ISSM_DIR/externalpackages/petsc/install \
+	--with-plapack-lib="-L$ISSM_DIR/externalpackages/petsc/install/ -lPLAPACK" \
+	--with-plapack-include="-I$ISSM_DIR/externalpackages/petsc/install/include/ " \
+	--with-blacs-dir=$ISSM_DIR/externalpackages/petsc/install/ \
+	--with-scalapack-dir=$ISSM_DIR/externalpackages/petsc/install/ \
+	--with-mumps-dir=$ISSM_DIR/externalpackages/petsc/install/ \
 	--with-fortran-lib="/sw/usr/local/lib/x86_64/libgfortran.a" \
 	--with-math-lib="/usr/lib/libm.dylib" \
Index: /issm/branches/trunk-jpl-damage/configs/config-pleiades-petsc2.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/configs/config-pleiades-petsc2.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/configs/config-pleiades-petsc2.sh	(revision 12168)
@@ -2,19 +2,19 @@
 
 ./configure \
- --prefix=$ISSM_TIER \
- --with-serial=no \
- --with-triangle-dir=$ISSM_TIER/externalpackages/triangle/install \
- --with-metis-dir=$ISSM_TIER/externalpackages/metis/install \
- --with-petsc-dir=$ISSM_TIER/externalpackages/petsc/install \
+ --prefix=$ISSM_DIR \
+ --with-modules=no \
+ --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=/nasa/sgi/mpt/1.25/include \
  --with-mpi-lib="-L/nasa/sgi/mpt/1.25/lib/ -lmpi -lpthread -lgfortran" \
  --with-petsc-arch=$ISSM_ARCH \
- --with-dakota-dir=$ISSM_TIER/externalpackages/dakota/install \
+ --with-dakota-dir=$ISSM_DIR/externalpackages/dakota/install \
  --with-mkl-dir=/nasa/intel/mkl/10.0.011/lib/64/ \
- --with-plapack-lib="-L$ISSM_TIER/externalpackages/petsc/install/ -lPLAPACK" \
- --with-plapack-include="-I$ISSM_TIER/externalpackages/petsc/install/externalpackages/PLAPACKR32-hg/INCLUDE" \
- --with-mumps-dir=$ISSM_TIER/externalpackages/petsc/install/ \
- --with-scalapack-dir=$ISSM_TIER/externalpackages/petsc/install/ \
- --with-blacs-dir=$ISSM_TIER/externalpackages/petsc/install/ \
+ --with-plapack-lib="-L$ISSM_DIR/externalpackages/petsc/install/ -lPLAPACK" \
+ --with-plapack-include="-I$ISSM_DIR/externalpackages/petsc/install/externalpackages/PLAPACKR32-hg/INCLUDE" \
+ --with-mumps-dir=$ISSM_DIR/externalpackages/petsc/install/ \
+ --with-scalapack-dir=$ISSM_DIR/externalpackages/petsc/install/ \
+ --with-blacs-dir=$ISSM_DIR/externalpackages/petsc/install/ \
  --with-graphics-lib=/usr/lib64/libX11.so \
  --with-cxxoptflags="-O3 -xS" \
Index: /issm/branches/trunk-jpl-damage/configs/config-pleiades.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/configs/config-pleiades.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/configs/config-pleiades.sh	(revision 12168)
@@ -2,19 +2,20 @@
 
 ./configure \
- --prefix=$ISSM_TIER \
- --with-serial=no \
- --with-triangle-dir=$ISSM_TIER/externalpackages/triangle/install \
- --with-metis-dir=$ISSM_TIER/externalpackages/metis/install \
- --with-petsc-dir=$ISSM_TIER/externalpackages/petsc/install \
+ --prefix=$ISSM_DIR \
+ --with-modules=no \
+ --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-tao-dir=$ISSM_DIR/externalpackages/tao/install \
  --with-mpi-include=/nasa/sgi/mpt/1.25/include \
  --with-mpi-lib="-L/nasa/sgi/mpt/1.25/lib/ -lmpi -lpthread -lgfortran" \
  --with-petsc-arch=$ISSM_ARCH \
- --with-dakota-dir=$ISSM_TIER/externalpackages/dakota/install \
+ --with-dakota-dir=$ISSM_DIR/externalpackages/dakota/install \
  --with-mkl-dir=/nasa/intel/mkl/10.0.011/lib/64/ \
- --with-plapack-lib="-L$ISSM_TIER/externalpackages/petsc/install/ -lPLAPACK" \
- --with-plapack-include="-I$ISSM_TIER/externalpackages/petsc/install/externalpackages/PLAPACKR32-hg/INCLUDE" \
- --with-mumps-dir=$ISSM_TIER/externalpackages/petsc/install/ \
- --with-scalapack-dir=$ISSM_TIER/externalpackages/petsc/install/ \
- --with-blacs-dir=$ISSM_TIER/externalpackages/petsc/install/ \
+ --with-plapack-lib="-L$ISSM_DIR/externalpackages/petsc/install/ -lPLAPACK" \
+ --with-plapack-include="-I$ISSM_DIR/externalpackages/petsc/install/externalpackages/PLAPACKR32-hg/INCLUDE" \
+ --with-mumps-dir=$ISSM_DIR/externalpackages/petsc/install/ \
+ --with-scalapack-dir=$ISSM_DIR/externalpackages/petsc/install/ \
+ --with-blacs-dir=$ISSM_DIR/externalpackages/petsc/install/ \
  --with-graphics-lib=/usr/lib64/libX11.so \
  --with-cxxoptflags="-O3 -xS" \
Index: /issm/branches/trunk-jpl-damage/configs/config-win32-eric.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/configs/config-win32-eric.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/configs/config-win32-eric.sh	(revision 12168)
@@ -4,3 +4,3 @@
 #get configure.sh to pick up the intel compiler 
 
-./configure --prefix=$ISSM_TIER --with-parallel=no --with-vendor=intel-win  --with-matlab-dir=$MATLAB_DIR --with-triangle-dir=$ISSM_TIER/externalpackages/triangle/install --with-metis-dir=$ISSM_TIER/externalpackages/metis/install --with-petsc-dir=$ISSM_TIER/externalpackages/petsc/install  --with-petsc-arch=$ISSM_ARCH  --with-blas-lapack-dir=$ISSM_TIER/externalpackages/petsc/install/externalpackages/f2cblaslapack/$ISSM_ARCH
+./configure --prefix=$ISSM_DIR --with-parallel=no --with-vendor=intel-win  --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-petsc-arch=$ISSM_ARCH  --with-blas-lapack-dir=$ISSM_DIR/externalpackages/petsc/install/externalpackages/f2cblaslapack/$ISSM_ARCH
Index: /issm/branches/trunk-jpl-damage/configs/config-win7-32.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/configs/config-win7-32.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/configs/config-win7-32.sh	(revision 12168)
@@ -2,15 +2,15 @@
 
 #Dos style path needed for the windows sdk 7.1 cl compiler: 
-ISSM_TIER_WIN=`cygpath -m "$ISSM_TIER"`
+ISSM_DIR_WIN=`cygpath -m "$ISSM_DIR"`
 
 #get configure.sh to pick up the win7 Visual Studio compiler 
-./configure --prefix=$ISSM_TIER \
+./configure --prefix=$ISSM_DIR \
 	--with-vendor=intel-win7-32  \
 	--with-matlab-dir=$MATLAB_DIR \
-	--with-triangle-dir="$ISSM_TIER_WIN/externalpackages/triangle/install" \
-	--with-metis-dir="$ISSM_TIER_WIN/externalpackages/metis/install" \
-	--with-petsc-dir="$ISSM_TIER_WIN/externalpackages/petsc/install" \
+	--with-triangle-dir="$ISSM_DIR_WIN/externalpackages/triangle/install" \
+	--with-metis-dir="$ISSM_DIR_WIN/externalpackages/metis/install" \
+	--with-petsc-dir="$ISSM_DIR_WIN/externalpackages/petsc/install" \
 	--with-petsc-arch=$ISSM_ARCH  \
-	--with-blas-lapack-dir=$ISSM_TIER/externalpackages/petsc/install/lib/  \
-	--with-mpi-lib="$ISSM_TIER_WIN/externalpackages/petsc/install/lib/libpetsc.lib" \
-	--with-mpi-include="$ISSM_TIER_WIN/externalpackages/petsc/install/include/mpiuni" 
+	--with-blas-lapack-dir=$ISSM_DIR/externalpackages/petsc/install/lib/  \
+	--with-mpi-lib="$ISSM_DIR_WIN/externalpackages/petsc/install/lib/libpetsc.lib" \
+	--with-mpi-include="$ISSM_DIR_WIN/externalpackages/petsc/install/include/mpiuni" 
Index: /issm/branches/trunk-jpl-damage/configs/config-win7-64.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/configs/config-win7-64.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/configs/config-win7-64.sh	(revision 12168)
@@ -2,15 +2,15 @@
 
 #Dos style path needed for the windows sdk 7.1 cl compiler: 
-ISSM_TIER_WIN=`cygpath -m "$ISSM_TIER"`
+ISSM_DIR_WIN=`cygpath -m "$ISSM_DIR"`
 
 #get configure.sh to pick up the win7 Visual Studio compiler 
-./configure --prefix=$ISSM_TIER \
+./configure --prefix=$ISSM_DIR \
 	--with-vendor=intel-win7-64  \
 	--with-matlab-dir=$MATLAB_DIR \
-	--with-triangle-dir="$ISSM_TIER_WIN/externalpackages/triangle/install" \
-	--with-metis-dir="$ISSM_TIER_WIN/externalpackages/metis/install" \
-	--with-petsc-dir="$ISSM_TIER_WIN/externalpackages/petsc/install" \
+	--with-triangle-dir="$ISSM_DIR_WIN/externalpackages/triangle/install" \
+	--with-metis-dir="$ISSM_DIR_WIN/externalpackages/metis/install" \
+	--with-petsc-dir="$ISSM_DIR_WIN/externalpackages/petsc/install" \
 	--with-petsc-arch=$ISSM_ARCH  \
-	--with-blas-lapack-dir=$ISSM_TIER/externalpackages/petsc/install/lib/  \
-	--with-mpi-lib="$ISSM_TIER_WIN/externalpackages/petsc/install/lib/libpetsc.lib" \
-	--with-mpi-include="$ISSM_TIER_WIN/externalpackages/petsc/install/include/mpiuni" 
+	--with-blas-lapack-dir=$ISSM_DIR/externalpackages/petsc/install/lib/  \
+	--with-mpi-lib="$ISSM_DIR_WIN/externalpackages/petsc/install/lib/libpetsc.lib" \
+	--with-mpi-include="$ISSM_DIR_WIN/externalpackages/petsc/install/include/mpiuni" 
Index: /issm/branches/trunk-jpl-damage/configure.ac
===================================================================
--- /issm/branches/trunk-jpl-damage/configure.ac	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/configure.ac	(revision 12168)
@@ -2,5 +2,5 @@
 
 #AUTOCONF
-AC_INIT([ISSM],[4.0],[issm@jpl.nasa.gov],[issm],[http://issm.jpl.nasa.gov]) #Initializing configure
+AC_INIT([ISSM],[4.1],[issm@jpl.nasa.gov],[issm],[http://issm.jpl.nasa.gov]) #Initializing configure
 AC_CONFIG_AUX_DIR([./aux-config])         #Put config files in aux-config
 AC_CONFIG_MACRO_DIR([m4])                 #m4 macros are located in m4
@@ -36,6 +36,10 @@
 AC_CONFIG_FILES([Makefile
 			src/Makefile
-			src/c/Makefile
-			src/mex/Makefile
+			src/c/Makefile 
+			src/py/Makefile
+			src/py/model/Makefile
+			src/modules/Makefile
+			src/modules/python/Makefile
+			src/modules/matlab/Makefile
 			src/m/Makefile
 			bin/Makefile])
Index: /issm/branches/trunk-jpl-damage/cron/configs/linux64_daily
===================================================================
--- /issm/branches/trunk-jpl-damage/cron/configs/linux64_daily	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/cron/configs/linux64_daily	(revision 12168)
@@ -6,6 +6,5 @@
 
 #ISSM main directory (full paths)
-ISSM_DIR="/path/to/issm"
-ISSM_TIER="/path/to/issm/cron/trunk-jpl"
+ISSM_DIR="/path/to/issm/cron/trunk-jpl"
 
 #ISSM Architecture
@@ -72,5 +71,5 @@
 
 #Mail delivery. If SKIPMAIL="no", the html nightly run report will be
-#sent to the adresses present in $ISSM_TIER/cron/mailinglist.
+#sent to the adresses present in $ISSM_DIR/cron/mailinglist.
 SKIPMAIL="no"
 
Index: /issm/branches/trunk-jpl-damage/cron/configs/linux64_nightly
===================================================================
--- /issm/branches/trunk-jpl-damage/cron/configs/linux64_nightly	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/cron/configs/linux64_nightly	(revision 12168)
@@ -6,6 +6,5 @@
 
 #ISSM main directory (full paths)
-ISSM_DIR="/path/to/issm"
-ISSM_TIER="/path/to/issm/cron/trunk-jpl"
+ISSM_DIR="/path/to/issm/cron/trunk-jpl"
 
 #ISSM Architecture
@@ -72,5 +71,5 @@
 
 #Mail delivery. If SKIPMAIL="no", the html nightly run report will be
-#sent to the adresses present in $ISSM_TIER/cron/mailinglist.
+#sent to the adresses present in $ISSM_DIR/cron/mailinglist.
 SKIPMAIL="no"
 
Index: /issm/branches/trunk-jpl-damage/cron/configs/macosx64_daily
===================================================================
--- /issm/branches/trunk-jpl-damage/cron/configs/macosx64_daily	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/cron/configs/macosx64_daily	(revision 12168)
@@ -6,6 +6,5 @@
 
 #ISSM main directory (full path)
-ISSM_DIR="/path/to/issm/"
-ISSM_TIER="/path/to/issm/trunk-jpl/cron/trunk-jpl"
+ISSM_DIR="/path/to/issm/trunk-jpl/cron/trunk-jpl"
 
 #ISSM Architecture
@@ -72,5 +71,5 @@
 
 #Mail delivery. If SKIPMAIL="no", the html nightly run report will be
-#sent to the adresses present in $ISSM_TIER/cron/mailinglist.
+#sent to the adresses present in $ISSM_DIR/cron/mailinglist.
 SKIPMAIL="no"
 
Index: /issm/branches/trunk-jpl-damage/cron/configs/macosx64_nightly
===================================================================
--- /issm/branches/trunk-jpl-damage/cron/configs/macosx64_nightly	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/cron/configs/macosx64_nightly	(revision 12168)
@@ -6,6 +6,5 @@
 
 #ISSM main directory (full path)
-ISSM_DIR="/path/to/issm/"
-ISSM_TIER="/path/to/issm/trunk-jpl/cron/trunk-jpl"
+ISSM_DIR="/path/to/issm/trunk-jpl/cron/trunk-jpl"
 
 #ISSM Architecture
@@ -72,5 +71,5 @@
 
 #Mail delivery. If SKIPMAIL="no", the html nightly run report will be
-#sent to the adresses present in $ISSM_TIER/cron/mailinglist.
+#sent to the adresses present in $ISSM_DIR/cron/mailinglist.
 SKIPMAIL="no"
 
Index: /issm/branches/trunk-jpl-damage/cron/configs/win732
===================================================================
--- /issm/branches/trunk-jpl-damage/cron/configs/win732	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/cron/configs/win732	(revision 12168)
@@ -6,6 +6,5 @@
 
 #ISSM main directory (full path)
-ISSM_DIR="/cygdrive/c/issm"
-ISSM_TIER="/cygdrive/c/issm/trunk-jpl/cron/trunk-jpl"
+ISSM_DIR="/cygdrive/c/issm-uci/trunk-jpl/cron/trunk-jpl"
 
 #ISSM Architecture
@@ -16,5 +15,5 @@
 
 #MATLAB path
-MATLAB_PATH="C:/MATLAB/R2011b32/"
+MATLAB_PATH="C:/MATLAB/R2012a/"
 
 #COMPILATION CONFIGURATION FILE
@@ -32,5 +31,5 @@
 # - "none"     leave ISSM as is in its directory
 #              ->skip to section 3
-ISSM_INSTALLATION="none"
+ISSM_INSTALLATION="checkout"
 
 #SVN repository
@@ -38,5 +37,5 @@
 
 #execution path used for parallel runs
-EXECUTION_PATH="/cygdrive/c/issm/ExecutionNightlyRun"
+EXECUTION_PATH="/cygdrive/c/issm-uci/ExecutionNightlyRun"
 
 #-----------------------------------#
@@ -49,6 +48,6 @@
 # - "none"    leave external packages as is
 #             ->skip to section 4
-ISSM_EXTERNALPACKAGES="none"
-EXTERNALPACKAGESDIR="/cygdrive/c/issm/trunk-jpl/externalpackages"
+ISSM_EXTERNALPACKAGES="link"
+EXTERNALPACKAGESDIR="/cygdrive/c/issm-uci/trunk-jpl/externalpackages"
 
 #List of external pakages to be installed
@@ -66,5 +65,5 @@
 # - "yes" compile ISSM
 # - "no"  do not compile ISSM
-ISSM_COMPILATION="no"
+ISSM_COMPILATION="yes"
 
 #----------------------#
@@ -73,9 +72,9 @@
 
 #Mail delivery. If SKIPMAIL="no", the html nightly run report will be
-#sent to the adresses present in $ISSM_TIER/cron/mailinglist.
-SKIPMAIL="no"
+#sent to the adresses present in $ISSM_DIR/cron/mailinglist.
+SKIPMAIL="yes"
 
 #Sender email address
-EMAIL_ADRESS="eric.larour@jpl.nasa.gov"
+EMAIL_ADRESS="eric.larour@gmail.com"
 
 #------------------------#
@@ -85,5 +84,5 @@
 #number of cpus used in ISSM installation and compilation (one is usually
 #safer as some packages are very sensitive to parallel compilation)
-NUMCPUS_INSTALL=8
+NUMCPUS_INSTALL=1
 
 #number of cpus used in the nightly runs.
@@ -95,8 +94,8 @@
 #ex: "'id',[101 102 103]"
 
-NROPTIONS="'benchmark','all'"
+NROPTIONS="'benchmark',102:2:120"
 
 #------------------------#
 # 7: Matlab#
 #------------------------#
-MATLABBIN=/cygdrive/c/MATLAB/R2011b32/bin/matlab
+MATLABBIN=/cygdrive/c/MATLAB/R2012a/bin/matlab
Index: /issm/branches/trunk-jpl-damage/cron/configs/win764
===================================================================
--- /issm/branches/trunk-jpl-damage/cron/configs/win764	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/cron/configs/win764	(revision 12168)
@@ -6,6 +6,5 @@
 
 #ISSM main directory (full path)
-ISSM_DIR="/cygdrive/c/issm"
-ISSM_TIER="/cygdrive/c/issm/trunk-jpl/cron/trunk-jpl"
+ISSM_DIR="/cygdrive/c/issm/trunk-jpl/cron/trunk-jpl"
 
 #ISSM Architecture
@@ -73,5 +72,5 @@
 
 #Mail delivery. If SKIPMAIL="no", the html nightly run report will be
-#sent to the adresses present in $ISSM_TIER/cron/mailinglist.
+#sent to the adresses present in $ISSM_DIR/cron/mailinglist.
 SKIPMAIL="no"
 
Index: /issm/branches/trunk-jpl-damage/cron/configs/winxp32
===================================================================
--- /issm/branches/trunk-jpl-damage/cron/configs/winxp32	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/cron/configs/winxp32	(revision 12168)
@@ -6,6 +6,5 @@
 
 #ISSM main directory (full path)
-ISSM_DIR="C:/home/issm/trunk-jpl"
-ISSM_TIER="C:/home/issm/trunk-jpl/cron/trunk-jpl"
+ISSM_DIR="C:/home/issm/trunk-jpl/cron/trunk-jpl"
 
 #ISSM Architecture
@@ -66,5 +65,5 @@
 
 #Mail delivery. If SKIPMAIL="no", the html nightly run report will be
-#sent to the adresses present in $ISSM_TIER/cron/mailinglist.
+#sent to the adresses present in $ISSM_DIR/cron/mailinglist.
 SKIPMAIL="no"
 
Index: /issm/branches/trunk-jpl-damage/etc/environment.csh
===================================================================
--- /issm/branches/trunk-jpl-damage/etc/environment.csh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/etc/environment.csh	(revision 12168)
@@ -1,4 +1,4 @@
-#ISSM_TIER and ISSM_ARCH should have been defined already in your shell settings file (.bashrc, .cshrc, etc ...)
-source $ISSM_TIER/etc/environment_variables.csh
+#ISSM_DIR and ISSM_ARCH should have been defined already in your shell settings file (.bashrc, .cshrc, etc ...)
+source $ISSM_DIR/etc/environment_variables.csh
 
 #Do we have any command line arguments? (such as MATLAB_DIR=otherdirthandefault), source them before exporting the variables 
@@ -10,8 +10,8 @@
 
 #CRON utilities
-setenv PATH {$PATH}:{$ISSM_TIER}/cron
+setenv PATH {$PATH}:{$ISSM_DIR}/cron
 
 #SCRIPTS utilities
-setenv PATH {$PATH}:{$ISSM_TIER}/scripts
+setenv PATH {$PATH}:{$ISSM_DIR}/scripts
 
 #MATLAB
@@ -110,9 +110,9 @@
 #AUTOCONF
 setenv AUTOCONF_DIR {$AUTOCONF_DIR}
-setenv PATH {$PATH}:{$AUTOCONF_DIR}/bin
+setenv PATH {$AUTOCONF_DIR}/bin:{$PATH}
 
 #AUTOMAKE
 setenv AUTOMAKE_DIR {$AUTOMAKE_DIR}
-setenv PATH {$PATH}:{$AUTOMAKE_DIR}/bin
+setenv PATH {$AUTOMAKE_DIR}/bin:{$PATH}
 
 #BORLAND
Index: /issm/branches/trunk-jpl-damage/etc/environment.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/etc/environment.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/etc/environment.sh	(revision 12168)
@@ -1,10 +1,10 @@
-#ISSM_TIER and ISSM_ARCH should have been defined already in your shell settings file (.bashrc, .cshrc, etc ...)
+#ISSM_DIR and ISSM_ARCH should have been defined already in your shell settings file (.bashrc, .cshrc, etc ...)
 
 #Windows compilers: 
 if [[ "$ISSM_ARCH" == "cygwin-intel" ]]; then
-	source $ISSM_TIER/externalpackages/windows/windows_environment.sh
+	source $ISSM_DIR/externalpackages/windows/windows_environment.sh
 fi
 
-source $ISSM_TIER/etc/environment_variables.sh
+source $ISSM_DIR/etc/environment_variables.sh
 
 #Do we have any command line arguments? (such as MATLAB_DIR=otherdirthandefault), source them after exporting the variables
@@ -16,8 +16,8 @@
 
 #CRON utilities
-PATH="$PATH:$ISSM_TIER/cron"
+PATH="$PATH:$ISSM_DIR/cron"
 
 #scripts
-PATH="$PATH:$ISSM_TIER/scripts"
+PATH="$PATH:$ISSM_DIR/scripts"
 
 ##MATLAB
@@ -137,5 +137,5 @@
 #export INTEL_DIR
 #PATH="$PATH:$INTEL_DIR"
-#source $ISSM_TIER/externalpackages/intel/intel.sh
+#source $ISSM_DIR/externalpackages/intel/intel.sh
 
 #SDK
@@ -242,6 +242,6 @@
 export PATH="$PATH:$ANDROID_NDK_DIR/"
 
-#ANDROID_DEV_DIR
-export ANDROID_DEV_DIR
+#ANDROID_DIR
+export ANDROID_DIR
 
 #ANDROID_SDK
@@ -259,6 +259,6 @@
 #PYTHON
 export PATH="$PYTHON_DIR/bin:$PATH"
-export PYTHONPATH="$PYTHONPATH:$ISSM_TIER/src/mex"
-export LD_LIBRARY_PATH=$ISSM_TIER/src/mex:$LD_LIBRARY_PATH
+export PYTHONPATH="$PYTHONPATH:$ISSM_DIR/src/modules/python"
+export LD_LIBRARY_PATH=$ISSM_DIR/src/modules/python:$LD_LIBRARY_PATH
 
 #MODELE
Index: /issm/branches/trunk-jpl-damage/etc/environment_variables.csh
===================================================================
--- /issm/branches/trunk-jpl-damage/etc/environment_variables.csh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/etc/environment_variables.csh	(revision 12168)
@@ -1,77 +1,77 @@
 #
 #
-#This routine can only be run if the ISSM_TIER variable has been correctly set!
+#This routine can only be run if the ISSM_DIR variable has been correctly set!
 #
 #
 
 #MATLAB
-set MATLAB_DIR={$ISSM_TIER}/externalpackages/matlab/install
+set MATLAB_DIR={$ISSM_DIR}/externalpackages/matlab/install
 
 #MPI
-set MPI_DIR={$ISSM_TIER}/externalpackages/mpich2/install
+set MPI_DIR={$ISSM_DIR}/externalpackages/mpich2/install
 
 #PETSC
-set PETSC_DIR={$ISSM_TIER}/externalpackages/petsc/install
+set PETSC_DIR={$ISSM_DIR}/externalpackages/petsc/install
 
 #SLEPC
-set SLEPC_DIR={$ISSM_TIER}/externalpackages/slepc/install
+set SLEPC_DIR={$ISSM_DIR}/externalpackages/slepc/install
 
 #Dakota
-set DAKOTA_DIR={$ISSM_TIER}/externalpackages/dakota/install
+set DAKOTA_DIR={$ISSM_DIR}/externalpackages/dakota/install
 
 #Qhull
-set QHULL_DIR={$ISSM_TIER}/externalpackages/qhull/install
+set QHULL_DIR={$ISSM_DIR}/externalpackages/qhull/install
 
 #Doxygen
-set DOXYGEN_DIR={$ISSM_TIER}/externalpackages/doxygen/install
+set DOXYGEN_DIR={$ISSM_DIR}/externalpackages/doxygen/install
 
 #MTOC
-set MTOC_DIR={$ISSM_TIER}/externalpackages/mtoc/install
+set MTOC_DIR={$ISSM_DIR}/externalpackages/mtoc/install
 
 #Triangle
-set TRIANGLE_DIR={$ISSM_TIER}/externalpackages/triangle/install
+set TRIANGLE_DIR={$ISSM_DIR}/externalpackages/triangle/install
 
 #METIS
-set METIS_DIR={$ISSM_TIER}/externalpackages/metis/install
+set METIS_DIR={$ISSM_DIR}/externalpackages/metis/install
 
 #BLAS
-set BLAS_DIR={$ISSM_TIER}/externalpackages/petsc/install/externalexternalpackages/fblaslapack
+set BLAS_DIR={$ISSM_DIR}/externalpackages/petsc/install/externalexternalpackages/fblaslapack
 
 #LAPACK
-set LAPACK_DIR={$ISSM_TIER}/externalpackages/petsc/install/externalexternalpackages/fblaslapack/$ISSM_ARCH
+set LAPACK_DIR={$ISSM_DIR}/externalpackages/petsc/install/externalexternalpackages/fblaslapack/$ISSM_ARCH
 
 #SCALAPACK
-set SCALAPACK_DIR={$ISSM_TIER}/externalpackages/petsc/install/externalexternalpackages/SCALAPACK/$ISSM_ARCH
+set SCALAPACK_DIR={$ISSM_DIR}/externalpackages/petsc/install/externalexternalpackages/SCALAPACK/$ISSM_ARCH
 
 #PLAPACK
-set PLAPACK_DIR={$ISSM_TIER}/externalpackages/petsc/install/externalexternalpackages/PLAPACKR32
+set PLAPACK_DIR={$ISSM_DIR}/externalpackages/petsc/install/externalexternalpackages/PLAPACKR32
 
 #BLACS
-set BLACS_DIR={$ISSM_TIER}/externalpackages/petsc/install/externalexternalpackages/blacs-dev/$ISSM_ARCH
+set BLACS_DIR={$ISSM_DIR}/externalpackages/petsc/install/externalexternalpackages/blacs-dev/$ISSM_ARCH
 
 #sowing
-set SOWING_DIR={$ISSM_TIER}/externalpackages/sowing/install
+set SOWING_DIR={$ISSM_DIR}/externalpackages/sowing/install
 
 #YAMS
-set YAMS_DIR={$ISSM_TIER}/externalpackages/yams/install
+set YAMS_DIR={$ISSM_DIR}/externalpackages/yams/install
 
 #TEX2IM
-set TEX2IM_DIR={$ISSM_TIER}/externalpackages/tex2im/install
+set TEX2IM_DIR={$ISSM_DIR}/externalpackages/tex2im/install
 
 #Chaco
-set CHACO_DIR={$ISSM_TIER}/externalpackages/chaco/install
+set CHACO_DIR={$ISSM_DIR}/externalpackages/chaco/install
 
 #MeshPart
-set MESHPART_DIR={$ISSM_TIER}/externalpackages/meshpart/install
+set MESHPART_DIR={$ISSM_DIR}/externalpackages/meshpart/install
 
 #SCOTCH
-set SCOTCH_DIR={$ISSM_TIER}/externalpackages/scotch/install
+set SCOTCH_DIR={$ISSM_DIR}/externalpackages/scotch/install
 
 #Development packages
 #automake
-set AUTOMAKE_DIR={$ISSM_TIER}/externalpackages/automake/install
+set AUTOMAKE_DIR={$ISSM_DIR}/externalpackages/automake/install
 
 #autoconf
-set AUTOCONF_DIR={$ISSM_TIER}/externalpackages/autoconf/install
+set AUTOCONF_DIR={$ISSM_DIR}/externalpackages/autoconf/install
 
 #borland
@@ -79,6 +79,6 @@
 
 #ssh
-set SSH_DIR={$ISSM_TIER}/externalpackages/ssh
+set SSH_DIR={$ISSM_DIR}/externalpackages/ssh
 
 #valgrind
-set VALGRIND_DIR={$ISSM_TIER}/externalpackages/valgrind/install/bin
+set VALGRIND_DIR={$ISSM_DIR}/externalpackages/valgrind/install/bin
Index: /issm/branches/trunk-jpl-damage/etc/environment_variables.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/etc/environment_variables.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/etc/environment_variables.sh	(revision 12168)
@@ -1,83 +1,83 @@
 #
 #
-#This routine can only be run if the ISSM_TIER variable has been correctly set!
+#This routine can only be run if the ISSM_DIR variable has been correctly set!
 #
 #
 
 #MATLAB
-MATLAB_DIR="$ISSM_TIER/externalpackages/matlab/install"
+MATLAB_DIR="$ISSM_DIR/externalpackages/matlab/install"
 
 #MPI
-MPI_DIR="$ISSM_TIER/externalpackages/mpich2/install"
+MPI_DIR="$ISSM_DIR/externalpackages/mpich2/install"
 
 #PETSC
-PETSC_DIR="$ISSM_TIER/externalpackages/petsc/install"
+PETSC_DIR="$ISSM_DIR/externalpackages/petsc/install"
 
 #SLEPC
-SLEPC_DIR="$ISSM_TIER/externalpackages/slepc/install"
+SLEPC_DIR="$ISSM_DIR/externalpackages/slepc/install"
 
 #Dakota
-DAKOTA_DIR="$ISSM_TIER/externalpackages/dakota/install"
+DAKOTA_DIR="$ISSM_DIR/externalpackages/dakota/install"
 
 #Qhull
-QHULL_DIR="$ISSM_TIER/externalpackages/qhull/install"
+QHULL_DIR="$ISSM_DIR/externalpackages/qhull/install"
 
 #Doxygen
-DOXYGEN_DIR="$ISSM_TIER/externalpackages/doxygen/install"
+DOXYGEN_DIR="$ISSM_DIR/externalpackages/doxygen/install"
 
 #MTOC
-MTOC_DIR="$ISSM_TIER/externalpackages/mtoc/install"
+MTOC_DIR="$ISSM_DIR/externalpackages/mtoc/install"
 
 #Triangle
-TRIANGLE_DIR="$ISSM_TIER/externalpackages/triangle/install"
+TRIANGLE_DIR="$ISSM_DIR/externalpackages/triangle/install"
 
 #METIS
-METIS_DIR="$ISSM_TIER/externalpackages/metis/install"
+METIS_DIR="$ISSM_DIR/externalpackages/metis/install"
 
 #BLAS
-BLAS_DIR="$ISSM_TIER/externalpackages/petsc/install/externalpackages/fblaslapack"
+BLAS_DIR="$ISSM_DIR/externalpackages/petsc/install/externalpackages/fblaslapack"
 
 #LAPACK
-LAPACK_DIR="$ISSM_TIER/externalpackages/petsc/install/externalpackages/fblaslapack/$ISSM_ARCH"
+LAPACK_DIR="$ISSM_DIR/externalpackages/petsc/install/externalpackages/fblaslapack/$ISSM_ARCH"
 
 #SCALAPACK
-SCALAPACK_DIR="$ISSM_TIER/externalpackages/petsc/install/externalpackages/SCALAPACK/$ISSM_ARCH"
+SCALAPACK_DIR="$ISSM_DIR/externalpackages/petsc/install/externalpackages/SCALAPACK/$ISSM_ARCH"
 
 #PLAPACK
-PLAPACK_DIR="$ISSM_TIER/externalpackages/petsc/install/externalpackages/PLAPACKR32"
+PLAPACK_DIR="$ISSM_DIR/externalpackages/petsc/install/externalpackages/PLAPACKR32"
 
 #BLACS
-BLACS_DIR="$ISSM_TIER/externalpackages/petsc/install/externalpackages/blacs-dev/$ISSM_ARCH"
+BLACS_DIR="$ISSM_DIR/externalpackages/petsc/install/externalpackages/blacs-dev/$ISSM_ARCH"
 
 #sowing
-SOWING_DIR="$ISSM_TIER/externalpackages/sowing/install"
+SOWING_DIR="$ISSM_DIR/externalpackages/sowing/install"
 
 #BLACS
-BLACS_DIR="$ISSM_TIER/externalpackages/petsc/install/externalpackages/blacs-dev/$ISSM_ARCH"
+BLACS_DIR="$ISSM_DIR/externalpackages/petsc/install/externalpackages/blacs-dev/$ISSM_ARCH"
 
 #YAMS
-YAMS_DIR="$ISSM_TIER/externalpackages/yams/install"
+YAMS_DIR="$ISSM_DIR/externalpackages/yams/install"
 
 #BAMG
-BAMG_DIR="$ISSM_TIER/externalpackages/bamg/install"
+BAMG_DIR="$ISSM_DIR/externalpackages/bamg/install"
 
 #Chaco
-CHACO_DIR="$ISSM_TIER/externalpackages/chaco/install"
+CHACO_DIR="$ISSM_DIR/externalpackages/chaco/install"
 
 #MeshPart
-MESHPART_DIR="$ISSM_TIER/externalpackages/meshpart/install"
+MESHPART_DIR="$ISSM_DIR/externalpackages/meshpart/install"
 
 #SCOTCH
-SCOTCH_DIR="$ISSM_TIER/externalpackages/scotch/install"
+SCOTCH_DIR="$ISSM_DIR/externalpackages/scotch/install"
 
 #Development packages
 #automake
-AUTOMAKE_DIR="$ISSM_TIER/externalpackages/automake/install"
+AUTOMAKE_DIR="$ISSM_DIR/externalpackages/automake/install"
 
 #libtool
-LIBTOOL_DIR="$ISSM_TIER/externalpackages/libtool/install"
+LIBTOOL_DIR="$ISSM_DIR/externalpackages/libtool/install"
 
 #autoconf
-AUTOCONF_DIR="$ISSM_TIER/externalpackages/autoconf/install"
+AUTOCONF_DIR="$ISSM_DIR/externalpackages/autoconf/install"
 
 #borland
@@ -88,5 +88,5 @@
 
 #TEX2IM			 
-TEX2IM_DIR="$ISSM_TIER/externalpackages/tex2im/install" 
+TEX2IM_DIR="$ISSM_DIR/externalpackages/tex2im/install" 
 
 #sdk
@@ -94,40 +94,40 @@
 
 #ssh 
-SSH_DIR="$ISSM_TIER/externalpackages/ssh"
+SSH_DIR="$ISSM_DIR/externalpackages/ssh"
 
 #valgrind
-VALGRIND_DIR="$ISSM_TIER/externalpackages/valgrind/install/bin"
+VALGRIND_DIR="$ISSM_DIR/externalpackages/valgrind/install/bin"
 
 #graphviz
-GRAPHVIZ_DIR="$ISSM_TIER/externalpackages/graphviz/install/bin"
+GRAPHVIZ_DIR="$ISSM_DIR/externalpackages/graphviz/install/bin"
 
 #cppcheck
-CPPCHECK_DIR="$ISSM_TIER/externalpackages/cppcheck/install"
+CPPCHECK_DIR="$ISSM_DIR/externalpackages/cppcheck/install"
 
 #gdal
-GDAL_DIR="$ISSM_TIER/externalpackages/gdal/install"
+GDAL_DIR="$ISSM_DIR/externalpackages/gdal/install"
 
 #mercurial
-MERCURIAL_DIR="$ISSM_TIER/externalpackages/mercurial/install"
+MERCURIAL_DIR="$ISSM_DIR/externalpackages/mercurial/install"
 
 #boost
-BOOST_DIR="$ISSM_TIER/externalpackages/boost/install"
-BOOSTROOT="$ISSM_TIER/externalpackages/boost/install"
+BOOST_DIR="$ISSM_DIR/externalpackages/boost/install"
+BOOSTROOT="$ISSM_DIR/externalpackages/boost/install"
 
 #OpenAnalysis
-OPENANALYSISROOT="$ISSM_TIER/externalpackages/openanalysis/install"
+OPENANALYSISROOT="$ISSM_DIR/externalpackages/openanalysis/install"
 
 #xerces
-XERCESROOT="$ISSM_TIER/externalpackages/xerces/install"
-XERCESCROOT="$ISSM_TIER/externalpackages/xerces/src"
+XERCESROOT="$ISSM_DIR/externalpackages/xerces/install"
+XERCESCROOT="$ISSM_DIR/externalpackages/xerces/src"
 
 #xaifBooster
-XAIFBOOSTERROOT="$ISSM_TIER/externalpackages/xaifbooster/"
-XAIF_DIR="$ISSM_TIER/externalpackages/xaifbooster/xaifBooster"
-XAIFBOOSTER_HOME="$ISSM_TIER/externalpackages/xaifbooster/xaifBooster"
+XAIFBOOSTERROOT="$ISSM_DIR/externalpackages/xaifbooster/"
+XAIF_DIR="$ISSM_DIR/externalpackages/xaifbooster/xaifBooster"
+XAIFBOOSTER_HOME="$ISSM_DIR/externalpackages/xaifbooster/xaifBooster"
 PLATFORM=x86-Linux
 
 #angel
-ANGELROOT="$ISSM_TIER/externalpackages/angel/angel"
+ANGELROOT="$ISSM_DIR/externalpackages/angel/angel"
 
 #java
@@ -135,63 +135,63 @@
 
 #bbftp
-BBFTP_DIR="$ISSM_TIER/externalpackages/bbftp/install"
+BBFTP_DIR="$ISSM_DIR/externalpackages/bbftp/install"
 
 #adic2
-ADIC_DIR="$ISSM_TIER/externalpackages/adic/install"
+ADIC_DIR="$ISSM_DIR/externalpackages/adic/install"
 
 #colpack
-COLPACK_DIR="$ISSM_TIER/externalpackages/colpack/install"
+COLPACK_DIR="$ISSM_DIR/externalpackages/colpack/install"
 
 #eclipse
-ECLIPSE_DIR="$ISSM_TIER/externalpackages/eclipse/install"
+ECLIPSE_DIR="$ISSM_DIR/externalpackages/eclipse/install"
 
 #flaim
-FLAIM_DIR="$ISSM_TIER/externalpackages/flaim/install"
+FLAIM_DIR="$ISSM_DIR/externalpackages/flaim/install"
 
 #appscan
-APPSCAN_DIR="$ISSM_TIER/externalpackages/appscan"
+APPSCAN_DIR="$ISSM_DIR/externalpackages/appscan"
 
 #cppcheck
-CPPCHECK_DIR="$ISSM_TIER/externalpackages/cppcheck/install"
+CPPCHECK_DIR="$ISSM_DIR/externalpackages/cppcheck/install"
 
 #rats
-RATS_DIR="$ISSM_TIER/externalpackages/rats/install"
+RATS_DIR="$ISSM_DIR/externalpackages/rats/install"
 
 #dyson
-DYSON_DIR="$ISSM_TIER/externalpackages/dyson/"
+DYSON_DIR="$ISSM_DIR/externalpackages/dyson/"
 
 #cmake
-CMAKE_DIR="$ISSM_TIER/externalpackages/cmake/install"
+CMAKE_DIR="$ISSM_DIR/externalpackages/cmake/install"
 
 #shapelib
-SHAPELIB_DIR="$ISSM_TIER/externalpackages/shapelib/install"
+SHAPELIB_DIR="$ISSM_DIR/externalpackages/shapelib/install"
 
 #cccl
-CCCL_DIR="$ISSM_TIER/externalpackages/cccl/install"
+CCCL_DIR="$ISSM_DIR/externalpackages/cccl/install"
 
 #packagemaker
-PACKAGEMAKER_DIR="$ISSM_TIER/externalpackages/packagemaker/install"
+PACKAGEMAKER_DIR="$ISSM_DIR/externalpackages/packagemaker/install"
+
+#android-dev-dir
+ANDROID_DIR="$ISSM_DIR/externalpackages/android"
 
 #android-ndk
-ANDROID_NDK_DIR="$ISSM_TIER/externalpackages/android-ndk/install"
-
-#android-dev-dir
-ANDROID_DEV_DIR="$ISSM_TIER/externalpackages/android-dev-dir"
+ANDROID_NDK_DIR="$ANDROID_DIR/android-ndk/install"
 
 #android-sdk
-ANDROID_SDK_DIR="$ISSM_TIER/externalpackages/android-sdk/install-sdk"
+ANDROID_SDK_DIR="$ANDROID_DIR/android-sdk/install-sdk"
 
 #android-ant
-ANDROID_ANT_DIR="$ISSM_TIER/externalpackages/android-sdk/install-ant"
+ANDROID_ANT_DIR="$ANDROID_DIR/android-sdk/install-ant"
 
 #gsl
-GSL_DIR="$ISSM_TIER/externalpackages/gsl/install"
+GSL_DIR="$ISSM_DIR/externalpackages/gsl/install"
 
 #gnu make
-GMAKE_DIR="$ISSM_TIER/externalpackages/gmake/install"
+GMAKE_DIR="$ISSM_DIR/externalpackages/gmake/install"
 
 #PYTHON
-PYTHON_DIR="$ISSM_TIER/externalpackages/python/install"
+PYTHON_DIR="$ISSM_DIR/externalpackages/python/install"
 
 #MODELE
-MODELE_DIR="$ISSM_TIER/externalpackages/modelE"
+MODELE_DIR="$ISSM_DIR/externalpackages/modelE"
Index: /issm/branches/trunk-jpl-damage/externalpackages/adic/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/adic/install.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/externalpackages/adic/install.sh	(revision 12168)
@@ -19,11 +19,11 @@
 cd build
 ../source/configure \
-	--with-rose=$ISSM_TIER/externalpackages/rose/install \
-	--with-openanalysis=$ISSM_TIER/externalpackages/openanalysis/openanalysis/x86_64-Linux \
-	--with-boost=$ISSM_TIER/externalpackages/boost/install \
-	--with-xerces=$ISSM_TIER/externalpackages/xerces/src \
-	--with-xaifbooster=$ISSM_TIER/externalpackages/xaifbooster/xaifBooster \
-	--with-colpack=$ISSM_TIER/externalpackages/colpack/install\
-	--prefix=$ISSM_TIER/externalpackages/adic/install 
+	--with-rose=$ISSM_DIR/externalpackages/rose/install \
+	--with-openanalysis=$ISSM_DIR/externalpackages/openanalysis/openanalysis/x86_64-Linux \
+	--with-boost=$ISSM_DIR/externalpackages/boost/install \
+	--with-xerces=$ISSM_DIR/externalpackages/xerces/src \
+	--with-xaifbooster=$ISSM_DIR/externalpackages/xaifbooster/xaifBooster \
+	--with-colpack=$ISSM_DIR/externalpackages/colpack/install\
+	--prefix=$ISSM_DIR/externalpackages/adic/install 
 if [ -z $1 ]; then
 	make
Index: /issm/branches/trunk-jpl-damage/externalpackages/adolc/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/adolc/install.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/externalpackages/adolc/install.sh	(revision 12168)
@@ -20,5 +20,5 @@
 
 ./configure \
-	--prefix=$ISSM_TIER/externalpackages/adolc/install \
+	--prefix=$ISSM_DIR/externalpackages/adolc/install \
 	--enable-sparse \
 	--enable-docexa \
Index: /issm/branches/trunk-jpl-damage/externalpackages/autoconf/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/autoconf/install.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/externalpackages/autoconf/install.sh	(revision 12168)
@@ -15,5 +15,5 @@
 #Compile autoconf
 cd src 
-./configure --prefix="$ISSM_TIER/externalpackages/autoconf/install" 
+./configure --prefix="$ISSM_DIR/externalpackages/autoconf/install" 
 make  
 make install
Index: /issm/branches/trunk-jpl-damage/externalpackages/automake/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/automake/install.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/externalpackages/automake/install.sh	(revision 12168)
@@ -13,5 +13,5 @@
 #Compile automake
 cd src 
-./configure --prefix="$ISSM_TIER/externalpackages/automake/install" 
+./configure --prefix="$ISSM_DIR/externalpackages/automake/install" 
 make  
 make install
Index: /issm/branches/trunk-jpl-damage/externalpackages/bbftp/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/bbftp/install.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/externalpackages/bbftp/install.sh	(revision 12168)
@@ -19,5 +19,5 @@
 #Configure and compile
 cd bbftpc
-./configure --prefix=$ISSM_TIER/externalpackages/bbftp/install
+./configure --prefix=$ISSM_DIR/externalpackages/bbftp/install
 make
 make install
Index: /issm/branches/trunk-jpl-damage/externalpackages/boost/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/boost/install.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/externalpackages/boost/install.sh	(revision 12168)
@@ -22,7 +22,7 @@
 cd src 
 ./bootstrap.sh \
-	--prefix="$ISSM_TIER/externalpackages/boost/install" \
+	--prefix="$ISSM_DIR/externalpackages/boost/install" \
 	--with-python=python3.2 \
-	--with-python-root="$ISSM_TIER/externalpackages/python/install" 
+	--with-python-root="$ISSM_DIR/externalpackages/python/install" 
 
 #Compile boost
Index: /issm/branches/trunk-jpl-damage/externalpackages/bsdtar/install-win7.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/bsdtar/install-win7.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/externalpackages/bsdtar/install-win7.sh	(revision 12168)
@@ -13,5 +13,5 @@
 
 cd src 
-./configure --prefix="$ISSM_TIER/externalpackages/bsdtar/install" 
+./configure --prefix="$ISSM_DIR/externalpackages/bsdtar/install" 
 make
 make install
Index: /issm/branches/trunk-jpl-damage/externalpackages/cccl/install-win7.orig.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/cccl/install-win7.orig.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/externalpackages/cccl/install-win7.orig.sh	(revision 12168)
@@ -15,5 +15,5 @@
 
 #Compile
-./configure --prefix="$ISSM_TIER/externalpackages/cccl/install"
+./configure --prefix="$ISSM_DIR/externalpackages/cccl/install"
 
 make
Index: /issm/branches/trunk-jpl-damage/externalpackages/cmake/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/cmake/install.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/externalpackages/cmake/install.sh	(revision 12168)
@@ -14,5 +14,5 @@
 #Compile cmake
 cd install 
-./bootstrap --prefix=$ISSM_TIER/externalpackages/cmake/install
+./bootstrap --prefix=$ISSM_DIR/externalpackages/cmake/install
 if [ -z $1 ]; then
 	make
Index: /issm/branches/trunk-jpl-damage/externalpackages/cppcheck/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/cppcheck/install.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/externalpackages/cppcheck/install.sh	(revision 12168)
@@ -17,4 +17,4 @@
 	make -j $1
 fi  
-make install PREFIX=$ISSM_TIER/externalpackages/cppcheck/install
+make install PREFIX=$ISSM_DIR/externalpackages/cppcheck/install
 cd ..
Index: /issm/branches/trunk-jpl-damage/externalpackages/dakota/install-altix64-cosmos.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/dakota/install-altix64-cosmos.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/externalpackages/dakota/install-altix64-cosmos.sh	(revision 12168)
@@ -29,5 +29,5 @@
 cd src
 ./configure \ 
-	--prefix="$ISSM_TIER/externalpackages/dakota/install" \
+	--prefix="$ISSM_DIR/externalpackages/dakota/install" \
 	--without-graphics  \
 	--with-pic \
Index: /issm/branches/trunk-jpl-damage/externalpackages/dakota/install-linux64-astrid.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/dakota/install-linux64-astrid.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/externalpackages/dakota/install-linux64-astrid.sh	(revision 12168)
@@ -29,5 +29,5 @@
 cd src
 ./configure \
-	--prefix="$ISSM_TIER/externalpackages/dakota/install" \
+	--prefix="$ISSM_DIR/externalpackages/dakota/install" \
 	--without-graphics  \
 	--with-pic \
Index: /issm/branches/trunk-jpl-damage/externalpackages/dakota/install-linux64-murdo.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/dakota/install-linux64-murdo.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/externalpackages/dakota/install-linux64-murdo.sh	(revision 12168)
@@ -29,5 +29,5 @@
 cd src
 ./configure \
-	--prefix="$ISSM_TIER/externalpackages/dakota/install" \
+	--prefix="$ISSM_DIR/externalpackages/dakota/install" \
 	--without-graphics  \
 	--with-pic \
Index: /issm/branches/trunk-jpl-damage/externalpackages/dakota/install-macosx64.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/dakota/install-macosx64.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/externalpackages/dakota/install-macosx64.sh	(revision 12168)
@@ -29,10 +29,10 @@
 cd src
 ./configure \
-   --prefix="$ISSM_TIER/externalpackages/dakota/install" \
+   --prefix="$ISSM_DIR/externalpackages/dakota/install" \
    --without-graphics  \
    --with-pic \
    --disable-mpi \
-   --with-blas="-L$ISSM_TIER/externalpackages/petsc/install/lib -lfblas " \
-   --with-lapack="-L$ISSM_TIER/externalpackages/petsc/install/lib -lflapack -lPLAPACK "
+   --with-blas="-L$ISSM_DIR/externalpackages/petsc/install/lib -lfblas " \
+   --with-lapack="-L$ISSM_DIR/externalpackages/petsc/install/lib -lflapack -lPLAPACK "
 cd ..
 
Index: /issm/branches/trunk-jpl-damage/externalpackages/dakota/install-pleiades.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/dakota/install-pleiades.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/externalpackages/dakota/install-pleiades.sh	(revision 12168)
@@ -29,5 +29,5 @@
 cd src
 ./configure \ 
-	--prefix="$ISSM_TIER/externalpackages/dakota/install" \
+	--prefix="$ISSM_DIR/externalpackages/dakota/install" \
 	--without-graphics  \
 	--with-pic \
Index: /issm/branches/trunk-jpl-damage/externalpackages/distribute/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/distribute/install.sh	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/externalpackages/distribute/install.sh	(revision 12168)
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+curl -O http://python-distribute.org/distribute_setup.py
+python distribute_setup.py
Index: /issm/branches/trunk-jpl-damage/externalpackages/doxygen/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/doxygen/install.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/externalpackages/doxygen/install.sh	(revision 12168)
@@ -8,5 +8,5 @@
 
 #Configure doxygen
-cd install && ./configure --prefix "$ISSM_TIER/externalpackages/doxygen/install"
+cd install && ./configure --prefix "$ISSM_DIR/externalpackages/doxygen/install"
 if [ -z $1 ]; then
 	make
Index: /issm/branches/trunk-jpl-damage/externalpackages/freetype/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/freetype/install.sh	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/externalpackages/freetype/install.sh	(revision 12168)
@@ -0,0 +1,26 @@
+#!/bin/bash
+
+#Some cleanup
+rm -rf src
+rm -rf install
+rm -rf freetype-2.4.9
+mkdir src install
+
+#Untar 
+tar -zxvf  freetype-2.4.9.tar.gz
+
+#Move freetype into src directory
+mv freetype-2.4.9/* src
+rm -rf freetype-2.4.9
+
+#Configure freetype
+cd src
+sudo ./configure 
+
+#Compile and install freetype
+if [ -z $1 ]; then
+	sudo make
+else
+	sudo make -j $1
+fi
+sudo make install
Index: /issm/branches/trunk-jpl-damage/externalpackages/gdal/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/gdal/install.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/externalpackages/gdal/install.sh	(revision 12168)
@@ -17,5 +17,5 @@
 cd src
 ./configure \
-	--prefix="$ISSM_TIER/externalpackages/gdal/install" \
+	--prefix="$ISSM_DIR/externalpackages/gdal/install" \
 	--without-python \
 	--with-netcdf=no \
Index: /issm/branches/trunk-jpl-damage/externalpackages/gmake/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/gmake/install.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/externalpackages/gmake/install.sh	(revision 12168)
@@ -16,5 +16,5 @@
 
 #Configure and compile: 
-./configure --prefix=$ISSM_TIER/externalpackages/gmake/install
+./configure --prefix=$ISSM_DIR/externalpackages/gmake/install
 
 if [ -z $1 ]; then
Index: /issm/branches/trunk-jpl-damage/externalpackages/graphviz/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/graphviz/install.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/externalpackages/graphviz/install.sh	(revision 12168)
@@ -14,5 +14,5 @@
 #Configure dakota
 cd src
-./configure --prefix="$ISSM_TIER/externalpackages/graphviz/install"
+./configure --prefix="$ISSM_DIR/externalpackages/graphviz/install"
 cd ..
 
Index: /issm/branches/trunk-jpl-damage/externalpackages/gsl/install-android-4.0.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/gsl/install-android-4.0.sh	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/externalpackages/gsl/install-android-4.0.sh	(revision 12168)
@@ -0,0 +1,35 @@
+#!/bin/bash
+
+#Some cleanup
+rm -rf src install gsl-1.15
+mkdir src install
+
+#Untar 
+tar -zxvf  gsl-1.15.tar.gz
+
+#Move gsl into src directory
+mv gsl-1.15/* src
+rm -rf gsl-1.15
+
+#Configure gsl
+cd src
+
+./configure \
+    CC=$ANDROID_DIR/arm-linux-android-4.0/bin/arm-linux-androideabi-gcc\
+    LD=$ANDROID_DIR/arm-linux-android-4.0/bin/arm-linux-androideabi-ld\
+    AR=$ANDROID_DIR/arm-linux-android-4.0/bin/arm-linux-androideabi-ar\
+    RANLIB=$ANDROID_DIR/arm-linux-android-4.0/bin/arm-linux-androideabi-ranlib\
+    NM=$ANDROID_DIR/arm-linux-android-4.0/bin/arm-linux-androideabi-nm\
+    OBJ_EXT=o\
+    LIB_EXT=a\
+    --host="arm-linux"\
+	--prefix="$ISSM_DIR/externalpackages/gsl/install" 
+
+#Compile gsl
+if [ -z $1 ]; then
+	make
+else
+	make -j $1
+fi
+
+make install
Index: /issm/branches/trunk-jpl-damage/externalpackages/gsl/install-linux64-murdo.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/gsl/install-linux64-murdo.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/externalpackages/gsl/install-linux64-murdo.sh	(revision 12168)
@@ -16,5 +16,5 @@
 
 ./configure \
-	--prefix="$ISSM_TIER/externalpackages/gsl/install" 
+	--prefix="$ISSM_DIR/externalpackages/gsl/install" 
 
 #Compile gsl
Index: /issm/branches/trunk-jpl-damage/externalpackages/gsl/install-macosx64.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/gsl/install-macosx64.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/externalpackages/gsl/install-macosx64.sh	(revision 12168)
@@ -18,5 +18,5 @@
 
 ./configure \
-	--prefix="$ISSM_TIER/externalpackages/gsl/install" 
+	--prefix="$ISSM_DIR/externalpackages/gsl/install" 
 
 #Compile gsl
Index: /issm/branches/trunk-jpl-damage/externalpackages/ipython/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/ipython/install.sh	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/externalpackages/ipython/install.sh	(revision 12168)
@@ -0,0 +1,19 @@
+#!/bin/bash
+
+#Some cleanup
+rm -rf src
+rm -rf install
+rm -rf ipython-0.12
+mkdir src install
+
+#Untar 
+tar -zxvf  ipython-0.12.tar.gz
+
+#Move ipython into src directory
+mv ipython-0.12/* src
+rm -rf ipython-0.12
+
+#install  ipython
+cd src
+python setup.py build
+python setup.py install
Index: /issm/branches/trunk-jpl-damage/externalpackages/latex2rtf/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/latex2rtf/install.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/externalpackages/latex2rtf/install.sh	(revision 12168)
@@ -10,4 +10,4 @@
 #Compile
 cd install
-export PREFIX="$ISSM_TIER/externalpackages/latex2rtf/install/"
+export PREFIX="$ISSM_DIR/externalpackages/latex2rtf/install/"
 make
Index: /issm/branches/trunk-jpl-damage/externalpackages/libermate/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/libermate/install.sh	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/externalpackages/libermate/install.sh	(revision 12168)
@@ -0,0 +1,13 @@
+#!/bin/bash
+
+#Some cleanup
+rm -rf install
+rm -rf libermate-0.4
+mkdir install
+
+#Untar 
+tar -zxvf  libermate-0.4.tgz
+
+#Move libermate into install directory
+mv libermate-0.4/* install
+rm -rf libermate-0.4
Index: /issm/branches/trunk-jpl-damage/externalpackages/libpng/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/libpng/install.sh	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/externalpackages/libpng/install.sh	(revision 12168)
@@ -0,0 +1,26 @@
+#!/bin/bash
+
+#Some cleanup
+rm -rf src
+rm -rf install
+rm -rf libpng-1.5.10
+mkdir src install
+
+#Untar 
+tar -zxvf  libpng-1.5.10.tar.gz
+
+#Move libpng into src directory
+mv libpng-1.5.10/* src
+rm -rf libpng-1.5.10
+
+#Configure libpng
+cd src
+sudo ./configure 
+
+#Compile and install libpng
+if [ -z $1 ]; then
+	sudo make
+else
+	sudo make -j $1
+fi
+sudo make install
Index: /issm/branches/trunk-jpl-damage/externalpackages/libtool/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/libtool/install.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/externalpackages/libtool/install.sh	(revision 12168)
@@ -13,5 +13,5 @@
 #Compile libtool
 cd src 
-./configure --prefix="$ISSM_TIER/externalpackages/libtool/install" 
+./configure --prefix="$ISSM_DIR/externalpackages/libtool/install" 
 make  
 make install
Index: /issm/branches/trunk-jpl-damage/externalpackages/matlab/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/matlab/install.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/externalpackages/matlab/install.sh	(revision 12168)
@@ -5,9 +5,8 @@
 
 #Select or create a new simlink
-#ln -s /usr/local/pkgs/matlab-7.6/ install
+ln -s /usr/local/pkgs/matlab-7.6/ install
 #ln -s /usr/local/matlab704/ install
 #ln -s /usr/local/matlab711/ install
 ln -s /usr/local/matlab712/ install
-#ln -s /usr/local/pkgs/matlab-7.6/ install
 
 # Macintosh (OSX) simlink 
@@ -16,3 +15,3 @@
 #ln -s /Applications/MATLAB_R2010a.app/ install
 #ln -s /Applications/MATLAB_R2012a.app/ install
-ln -s /Applications/MATLAB*.app/ install
+#ln -s /Applications/MATLAB*.app/ install
Index: /issm/branches/trunk-jpl-damage/externalpackages/matplotlib/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/matplotlib/install.sh	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/externalpackages/matplotlib/install.sh	(revision 12168)
@@ -0,0 +1,7 @@
+#/bin/bash
+
+git clone https://github.com/matplotlib/matplotlib
+mv matplotlib src
+cd src
+python setup.py build
+python setup.py install
Index: /issm/branches/trunk-jpl-damage/externalpackages/metis/install-5.0.1-linux64.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/metis/install-5.0.1-linux64.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/externalpackages/metis/install-5.0.1-linux64.sh	(revision 12168)
@@ -17,4 +17,4 @@
 
 #Compile metis
-make config prefix="$ISSM_TIER/externalpackages/metis/install"
+make config prefix="$ISSM_DIR/externalpackages/metis/install"
 make install
Index: /issm/branches/trunk-jpl-damage/externalpackages/mpich2/install-1.0.2-altix64.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/mpich2/install-1.0.2-altix64.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/externalpackages/mpich2/install-1.0.2-altix64.sh	(revision 12168)
@@ -18,5 +18,5 @@
 export FFLAGS="$FFLAGS -fPIC"
 ./configure \
-	--prefix="$ISSM_TIER/externalpackages/mpich2/install" \
+	--prefix="$ISSM_DIR/externalpackages/mpich2/install" \
 	--enable-sharedlibs=gcc \
 	--enable-f91=gfortran 
Index: /issm/branches/trunk-jpl-damage/externalpackages/mpich2/install-1.0.2-linux64.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/mpich2/install-1.0.2-linux64.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/externalpackages/mpich2/install-1.0.2-linux64.sh	(revision 12168)
@@ -18,5 +18,5 @@
 export FFLAGS="$FFLAGS -fPIC"
 ./configure \
-	--prefix="$ISSM_TIER/externalpackages/mpich2/install" \
+	--prefix="$ISSM_DIR/externalpackages/mpich2/install" \
 	--enable-sharedlibs=gcc \
 	--enable-f91=gfortran 
Index: /issm/branches/trunk-jpl-damage/externalpackages/mpich2/install-1.0.2-macosx32.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/mpich2/install-1.0.2-macosx32.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/externalpackages/mpich2/install-1.0.2-macosx32.sh	(revision 12168)
@@ -17,5 +17,5 @@
 export CFLAGS=" -m32"
 ./configure \
-	--prefix="$ISSM_TIER/externalpackages/mpich2/install" \
+	--prefix="$ISSM_DIR/externalpackages/mpich2/install" \
 	--enable-f91=gfortran \
 	--enable-sharedlibs=osx-gcc
Index: /issm/branches/trunk-jpl-damage/externalpackages/mpich2/install-1.0.2-win32.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/mpich2/install-1.0.2-win32.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/externalpackages/mpich2/install-1.0.2-win32.sh	(revision 12168)
@@ -17,5 +17,5 @@
 export CFLAGS="$CFLAGS -fPIC"
 export FFLAGS="$FFLAGS -fPIC"
-./configure --prefix="$ISSM_TIER/externalpackages/mpich2/install" 
+./configure --prefix="$ISSM_DIR/externalpackages/mpich2/install" 
 
 #Apply Patch to examples
Index: /issm/branches/trunk-jpl-damage/externalpackages/mpich2/install-1.4-linux64.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/mpich2/install-1.4-linux64.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/externalpackages/mpich2/install-1.4-linux64.sh	(revision 12168)
@@ -17,5 +17,5 @@
 export FFLAGS="$FFLAGS -fPIC"
 ./configure \
-	--prefix="$ISSM_TIER/externalpackages/mpich2/install" \
+	--prefix="$ISSM_DIR/externalpackages/mpich2/install" \
 	--enable-shared \
 	--enable-sharedlibs=gcc \
Index: /issm/branches/trunk-jpl-damage/externalpackages/mpich2/install-1.4-macosx32.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/mpich2/install-1.4-macosx32.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/externalpackages/mpich2/install-1.4-macosx32.sh	(revision 12168)
@@ -19,5 +19,5 @@
 export CPPFLAGS=" -arch i386"
 ./configure \
-	--prefix="$ISSM_TIER/externalpackages/mpich2/install" \
+	--prefix="$ISSM_DIR/externalpackages/mpich2/install" \
 	--enable-f91=gfortran \
 	--enable-sharedlibs=osx-gcc \
Index: /issm/branches/trunk-jpl-damage/externalpackages/mpich2/install-1.4-macosx64.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/mpich2/install-1.4-macosx64.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/externalpackages/mpich2/install-1.4-macosx64.sh	(revision 12168)
@@ -19,5 +19,5 @@
 export CXXFLAGS=" -arch x86_64"
 ./configure \
-	--prefix="$ISSM_TIER/externalpackages/mpich2/install" \
+	--prefix="$ISSM_DIR/externalpackages/mpich2/install" \
 	--enable-f91 \
 	--enable-sharedlibs=osx-gcc \
Index: /issm/branches/trunk-jpl-damage/externalpackages/ncview/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/ncview/install.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/externalpackages/ncview/install.sh	(revision 12168)
@@ -15,9 +15,9 @@
 cd install
 ./configure \
-	--prefix "$ISSM_TIER/externalpackages/ncview/install" \
+	--prefix "$ISSM_DIR/externalpackages/ncview/install" \
 	--x-libraries=/usr/X11/lib/ \
 	--x-includes=/usr/X11/include/ \
-	--with-netcdf_incdir="$ISSM_TIER/externalpackages/netcdf/install/include/" \
-	--with-netcdf_libdir="$ISSM_TIER/externalpackages/netcdf/install/lib/"
+	--with-netcdf_incdir="$ISSM_DIR/externalpackages/netcdf/install/include/" \
+	--with-netcdf_libdir="$ISSM_DIR/externalpackages/netcdf/install/lib/"
 
 make
Index: /issm/branches/trunk-jpl-damage/externalpackages/netcdf/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/netcdf/install.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/externalpackages/netcdf/install.sh	(revision 12168)
@@ -15,5 +15,5 @@
 #Configure and compile
 cd install
-./configure  --prefix="$ISSM_TIER/externalpackages/netcdf/install" 
+./configure  --prefix="$ISSM_DIR/externalpackages/netcdf/install" 
 if [ -z $1 ]; then
 	make
Index: /issm/branches/trunk-jpl-damage/externalpackages/nose/install-macosx64sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/nose/install-macosx64sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/externalpackages/nose/install-macosx64sh	(revision 12168)
@@ -1,10 +1,27 @@
 #/bin/bash
-#Install Python3 nose module
+#Install Python nose module
 
-rm -rf py3k
+pythonversion=2
+	
+rm -rf src 
 
-svn checkout http://python-nose.googlecode.com/svn/branches/py3k
-cd py3k
+if [[ $pythonversion == "3" ]];then
 
-python3.2 ./setup.py build
-python3.2 ./setup.py install
+	svn checkout http://python-nose.googlecode.com/svn/branches/py3k
+	mv py3k src
+
+	cd src
+	python ./setup.py build
+	python ./setup.py install
+fi
+
+if [[ $pythonversion == "2" ]];then
+
+	tar -zxvf  nose-1.1.2.tar.gz
+	mv nose-1.1.2 src
+	rm -rf nose-1.1.2
+
+	cd src
+	python ./setup.py build
+	python ./setup.py install
+fi
Index: /issm/branches/trunk-jpl-damage/externalpackages/pcre/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/pcre/install.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/externalpackages/pcre/install.sh	(revision 12168)
@@ -13,5 +13,5 @@
 #Configure doxygen
 cd install 
-./configure --prefix "$ISSM_TIER/externalpackages/python/install"
+./configure --prefix "$ISSM_DIR/externalpackages/python/install"
 make
 make install
Index: /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-2.3.2-altix64-castor.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-2.3.2-altix64-castor.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-2.3.2-altix64-castor.sh	(revision 12168)
@@ -17,5 +17,5 @@
 	cd install
 	./config/configure.py \
-		--prefix="$ISSM_TIER/externalpackages/petsc/install" \
+		--prefix="$ISSM_DIR/externalpackages/petsc/install" \
 		--with-batch=1  \
 		--ISSM_ARCH=$ISSM_ARCH \
@@ -41,5 +41,5 @@
 	cd install
 	./config/configure.py  \
-		--prefix="$ISSM_TIER/externalpackages/petsc/install" \
+		--prefix="$ISSM_DIR/externalpackages/petsc/install" \
 		--with-batch=1  \
 		--ISSM_ARCH=$ISSM_ARCH \
Index: /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-2.3.2-cosmos.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-2.3.2-cosmos.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-2.3.2-cosmos.sh	(revision 12168)
@@ -12,5 +12,5 @@
 #configure
 cd install
-PETSC_DIR=$ISSM_TIER/externalpackages/petsc/install
+PETSC_DIR=$ISSM_DIR/externalpackages/petsc/install
 ./config/configure.py  \
 	--prefix=$PETSC_DIR \
Index: /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-2.3.2-linux64-astrid.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-2.3.2-linux64-astrid.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-2.3.2-linux64-astrid.sh	(revision 12168)
@@ -13,8 +13,8 @@
 cd install
 ./config/configure.py  \
-	--prefix="$ISSM_TIER/externalpackages/petsc/install" \
-	--with-mpi-dir=$ISSM_TIER/externalpackages/mpich2/install \
+	--prefix="$ISSM_DIR/externalpackages/petsc/install" \
+	--with-mpi-dir=$ISSM_DIR/externalpackages/mpich2/install \
 	--PETSC_ARCH=linux-gnu-amd64 \
-	--PETSC_DIR="$ISSM_TIER/externalpackages/petsc/install" \
+	--PETSC_DIR="$ISSM_DIR/externalpackages/petsc/install" \
 	--with-fc=gfortran \
 	--with-debugging=1 \
@@ -25,5 +25,5 @@
 	--download-blas=yes \
 	--download-f-blas-lapack=yes \
-	--FFLAGS=-I$ISSM_TIER/externalpackages/mpich2/install/include \
+	--FFLAGS=-I$ISSM_DIR/externalpackages/mpich2/install/include \
 	--download-plapack=yes \
 	--COPTFLAGS="-march=opteron -O2" \
Index: /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-2.3.2-macosx32-eric.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-2.3.2-macosx32-eric.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-2.3.2-macosx32-eric.sh	(revision 12168)
@@ -17,8 +17,8 @@
 	cd install
 	./config/configure.py  \
-		--prefix="$ISSM_TIER/externalpackages/petsc/install" \
-		--with-mpi-dir=$ISSM_TIER/externalpackages/mpich2/install \
+		--prefix="$ISSM_DIR/externalpackages/petsc/install" \
+		--with-mpi-dir=$ISSM_DIR/externalpackages/mpich2/install \
 		--PETSC_ARCH=macosx-gnu \
-		--PETSC_DIR="$ISSM_TIER/externalpackages/petsc/install" \
+		--PETSC_DIR="$ISSM_DIR/externalpackages/petsc/install" \
 		--with-fc=/usr/local/bin/gfortran \
 		--with-debugging=0 \
@@ -29,5 +29,5 @@
 		--download-blas=yes \
 		--download-f-blas-lapack=yes \
-		--FFLAGS="-I$ISSM_TIER/externalpackages/mpich2/install/include -L$ISSM_TIER/externalpackages/mpich2/install/lib -L/usr/local/bin -lmpich -lpmpich -lgfortran  -fPIC -arch i386" \
+		--FFLAGS="-I$ISSM_DIR/externalpackages/mpich2/install/include -L$ISSM_DIR/externalpackages/mpich2/install/lib -L/usr/local/bin -lmpich -lpmpich -lgfortran  -fPIC -arch i386" \
 		--download-plapack=yes \
 		--CXXFLAGS=" -fPIC -arch i386" \
@@ -43,17 +43,17 @@
 	cd install
 	./config/configure.py  \
-		--prefix="$ISSM_TIER/externalpackages/petsc/install" \
-		--with-mpi-dir=$ISSM_TIER/externalpackages/mpich2/install \
+		--prefix="$ISSM_DIR/externalpackages/petsc/install" \
+		--with-mpi-dir=$ISSM_DIR/externalpackages/mpich2/install \
 		--PETSC_ARCH=macosx-gnu \
-		--PETSC_DIR="$ISSM_TIER/externalpackages/petsc/install" \
+		--PETSC_DIR="$ISSM_DIR/externalpackages/petsc/install" \
 		--with-fc=/usr/local/bin/gfortran \
 		--with-debugging=0 \
 		--with-shared=0 \
-		--with-mumps-dir=$ISSM_TIER/externalpackages/petsc/install/externalpackages/MUMPS_4.6.3  \
+		--with-mumps-dir=$ISSM_DIR/externalpackages/petsc/install/externalpackages/MUMPS_4.6.3  \
 		--download-scalapack=yes \
 		--download-blacs=yes \
 		--download-blas=yes \
 		--download-f-blas-lapack=yes \
-		--FFLAGS="-I$ISSM_TIER/externalpackages/mpich2/install/include -L$ISSM_TIER/externalpackages/mpich2/install/lib -L/usr/local/bin -lmpich -lpmpich -lgfortran  -fPIC -arch i386" \
+		--FFLAGS="-I$ISSM_DIR/externalpackages/mpich2/install/include -L$ISSM_DIR/externalpackages/mpich2/install/lib -L/usr/local/bin -lmpich -lpmpich -lgfortran  -fPIC -arch i386" \
 		--download-plapack=yes \
 		--CXXFLAGS=" -fPIC -arch i386" \
Index: /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-2.3.2-macosx32-ogive.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-2.3.2-macosx32-ogive.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-2.3.2-macosx32-ogive.sh	(revision 12168)
@@ -12,8 +12,8 @@
 #configure
 cd install
-./config/configure.py  --prefix="$ISSM_TIER/externalpackages/petsc/install" \
-	--with-mpi-dir=$ISSM_TIER/externalpackages/mpich2/install \
+./config/configure.py  --prefix="$ISSM_DIR/externalpackages/petsc/install" \
+	--with-mpi-dir=$ISSM_DIR/externalpackages/mpich2/install \
 	--PETSC_ARCH=macosx-gnu \
-	--PETSC_DIR="$ISSM_TIER/externalpackages/petsc/install" \
+	--PETSC_DIR="$ISSM_DIR/externalpackages/petsc/install" \
 	--with-fc=/usr/local/bin/gfortran \
 	--with-debugging=0 \
@@ -24,5 +24,5 @@
 	--download-blas=yes \
 	--download-f-blas-lapack=yes \
-	--FFLAGS="-I$ISSM_TIER/externalpackages/mpich2/install/include -L$ISSM_TIER/externalpackages/mpich2/install/lib -L/usr/local/bin -lmpich -lpmpich -lgfortran" \
+	--FFLAGS="-I$ISSM_DIR/externalpackages/mpich2/install/include -L$ISSM_DIR/externalpackages/mpich2/install/lib -L/usr/local/bin -lmpich -lpmpich -lgfortran" \
 	--download-plapack=yes
 
Index: /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-2.3.2-macosx64.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-2.3.2-macosx64.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-2.3.2-macosx64.sh	(revision 12168)
@@ -13,8 +13,8 @@
 cd src
 ./config/configure.py \
-  --prefix="$ISSM_TIER/externalpackages/petsc/install" \
-  --PETSC_DIR="$ISSM_TIER/externalpackages/petsc/src" \
+  --prefix="$ISSM_DIR/externalpackages/petsc/install" \
+  --PETSC_DIR="$ISSM_DIR/externalpackages/petsc/src" \
   --PETSC_ARCH=macosx-gnu \
-  --with-mpi-dir="$ISSM_TIER/externalpackages/mpich2/install" \
+  --with-mpi-dir="$ISSM_DIR/externalpackages/mpich2/install" \
   --with-debugging=0 \
   --with-shared-libraries=0 \
Index: /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-2.3.2-pleiades.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-2.3.2-pleiades.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-2.3.2-pleiades.sh	(revision 12168)
@@ -17,5 +17,5 @@
 	cd install
 	./config/configure.py  \
-		--prefix="$ISSM_TIER/externalpackages/petsc/install" \
+		--prefix="$ISSM_DIR/externalpackages/petsc/install" \
 		--with-batch=1  \
 		--PETSC_ARCH=$ISSM_ARCH \
@@ -44,5 +44,5 @@
 	cd install
 	./config/configure.py  \
-		--prefix="$ISSM_TIER/externalpackages/petsc/install" \
+		--prefix="$ISSM_DIR/externalpackages/petsc/install" \
 		--with-batch=1  \
 		--PETSC_ARCH=$ISSM_ARCH \
Index: /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-2.3.2-win32-eric.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-2.3.2-win32-eric.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-2.3.2-win32-eric.sh	(revision 12168)
@@ -14,7 +14,7 @@
 ./config/configure.py  \
 	--with-parallel-no \
-	--prefix="$ISSM_TIER/externalpackages/petsc/install" \
+	--prefix="$ISSM_DIR/externalpackages/petsc/install" \
 	--PETSC_ARCH=cygwin-intel \
-	--PETSC_DIR="$ISSM_TIER/externalpackages/petsc/install" \
+	--PETSC_DIR="$ISSM_DIR/externalpackages/petsc/install" \
 	--with-debugging=0 \
 	--with-mpi=0 \
Index: /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-2.3.2-win7.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-2.3.2-win7.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-2.3.2-win7.sh	(revision 12168)
@@ -14,7 +14,7 @@
 ./config/configure.py  \
 	--with-parallel-no \
-	--prefix="$ISSM_TIER/externalpackages/petsc/install" \
+	--prefix="$ISSM_DIR/externalpackages/petsc/install" \
 	--PETSC_ARCH=cygwin-intel \
-	--PETSC_DIR="$ISSM_TIER/externalpackages/petsc/install" \
+	--PETSC_DIR="$ISSM_DIR/externalpackages/petsc/install" \
 	--with-debugging=0 \
 	--with-mpi=0 \
Index: /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-3.1-altix64-castor.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-3.1-altix64-castor.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-3.1-altix64-castor.sh	(revision 12168)
@@ -17,6 +17,6 @@
 	cd src
 	./config/configure.py \
-	  --prefix="$ISSM_TIER/externalpackages/petsc/install" \
-	  --PETSC_DIR="$ISSM_TIER/externalpackages/petsc/src" \
+	  --prefix="$ISSM_DIR/externalpackages/petsc/install" \
+	  --PETSC_DIR="$ISSM_DIR/externalpackages/petsc/src" \
 	  --ISSM_ARCH=$ISSM_ARCH \
 	  --with-debugging=no \
@@ -41,6 +41,6 @@
 	cd src
 	./config/configure.py \
-		--prefix="$ISSM_TIER/externalpackages/petsc/install" \
-		--PETSC_DIR="$ISSM_TIER/externalpackages/petsc/src" \
+		--prefix="$ISSM_DIR/externalpackages/petsc/install" \
+		--PETSC_DIR="$ISSM_DIR/externalpackages/petsc/src" \
 		--with-batch=1  \
 		--ISSM_ARCH=$ISSM_ARCH \
Index: /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-3.1-cosmos.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-3.1-cosmos.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-3.1-cosmos.sh	(revision 12168)
@@ -13,6 +13,6 @@
 cd src
 ./config/configure.py \
-	--prefix="$ISSM_TIER/externalpackages/petsc/install" \
-	--PETSC_DIR="$ISSM_TIER/externalpackages/petsc/src" \
+	--prefix="$ISSM_DIR/externalpackages/petsc/install" \
+	--PETSC_DIR="$ISSM_DIR/externalpackages/petsc/src" \
 	--with-batch=1  \
 	--ISSM_ARCH=$ISSM_ARCH \
Index: /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-3.1-linux64-astrid.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-3.1-linux64-astrid.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-3.1-linux64-astrid.sh	(revision 12168)
@@ -13,8 +13,8 @@
 cd src
 ./config/configure.py \
- --prefix="$ISSM_TIER/externalpackages/petsc/install" \
- --with-mpi-dir=$ISSM_TIER/externalpackages/mpich2/install \
+ --prefix="$ISSM_DIR/externalpackages/petsc/install" \
+ --with-mpi-dir=$ISSM_DIR/externalpackages/mpich2/install \
  --PETSC_ARCH=linux-gnu-amd64 \
- --PETSC_DIR="$ISSM_TIER/externalpackages/petsc/src" \
+ --PETSC_DIR="$ISSM_DIR/externalpackages/petsc/src" \
  --with-debugging=0 \
  --with-shared=0 \
@@ -25,5 +25,5 @@
  --download-f-blas-lapack=yes \
  --download-parmetis=yes \
- --FFLAGS=-I$ISSM_TIER/externalpackages/mpich2/install/include \
+ --FFLAGS=-I$ISSM_DIR/externalpackages/mpich2/install/include \
  --download-plapack=yes \
  --COPTFLAGS="-march=opteron -O2" \
Index: /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-3.1-macosx32-mathieu.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-3.1-macosx32-mathieu.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-3.1-macosx32-mathieu.sh	(revision 12168)
@@ -13,8 +13,8 @@
 cd src
 ./config/configure.py  \
- --prefix="$ISSM_TIER/externalpackages/petsc/install" \
- --PETSC_DIR="$ISSM_TIER/externalpackages/petsc/src" \
+ --prefix="$ISSM_DIR/externalpackages/petsc/install" \
+ --PETSC_DIR="$ISSM_DIR/externalpackages/petsc/src" \
  --PETSC_ARCH=macosx-gnu \
- --with-mpi-dir=$ISSM_TIER/externalpackages/mpich2/install \
+ --with-mpi-dir=$ISSM_DIR/externalpackages/mpich2/install \
  --with-debugging=0 \
  --with-shared=0 \
@@ -25,5 +25,5 @@
  --download-f-blas-lapack=yes \
  --download-plapack=yes \
- --FFLAGS="-I$ISSM_TIER/externalpackages/mpich2/install/include -arch i386" \
+ --FFLAGS="-I$ISSM_DIR/externalpackages/mpich2/install/include -arch i386" \
  --COPTFLAGS="-march=opteron -O2 -arch i386" \
  --FOPTFLAGS="-march=opteron -O2 -arch i386" \
Index: /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-3.1-macosx32-ogive.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-3.1-macosx32-ogive.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-3.1-macosx32-ogive.sh	(revision 12168)
@@ -13,7 +13,7 @@
 cd src
 ./config/configure.py \
-	--prefix="$ISSM_TIER/externalpackages/petsc/install" \
-	--PETSC_DIR="$ISSM_TIER/externalpackages/petsc/src" \
-	--with-mpi-dir=$ISSM_TIER/externalpackages/mpich2/install \
+	--prefix="$ISSM_DIR/externalpackages/petsc/install" \
+	--PETSC_DIR="$ISSM_DIR/externalpackages/petsc/src" \
+	--with-mpi-dir=$ISSM_DIR/externalpackages/mpich2/install \
 	--PETSC_ARCH=macosx-gnu \
 	--with-fc=/usr/local/bin/gfortran \
@@ -30,5 +30,5 @@
 	--FOPTFLAGS="-march=opteron -O2 " \
 	--CXXOPTFLAGS="-march=opteron -O2 " \
-	--FFLAGS="-I$ISSM_TIER/externalpackages/mpich2/install/include -L$ISSM_TIER/externalpackages/mpich2/install/lib -L/usr/local/bin -lmpich -lpmpich -lgfortran " 
+	--FFLAGS="-I$ISSM_DIR/externalpackages/mpich2/install/include -L$ISSM_DIR/externalpackages/mpich2/install/lib -L/usr/local/bin -lmpich -lpmpich -lgfortran " 
 
 #Compile petsc and install it
Index: /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-3.1-pleiades.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-3.1-pleiades.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-3.1-pleiades.sh	(revision 12168)
@@ -17,8 +17,8 @@
 	cd src
 	./config/configure.py \
-		--prefix="$ISSM_TIER/externalpackages/petsc/install" \
+		--prefix="$ISSM_DIR/externalpackages/petsc/install" \
 		--with-batch=1  \
 		--PETSC_ARCH="$ISSM_ARCH" \
-		--PETSC_DIR="$ISSM_TIER/externalpackages/petsc/src" \
+		--PETSC_DIR="$ISSM_DIR/externalpackages/petsc/src" \
 		--with-debugging=no \
 		--with-shared=0 \
@@ -44,8 +44,8 @@
 	cd src
 	./config/configure.py \
-	 --prefix="$ISSM_TIER/externalpackages/petsc/install" \
+	 --prefix="$ISSM_DIR/externalpackages/petsc/install" \
 	 --with-batch=1  \
 	 --PETSC_ARCH="$ISSM_ARCH" \
-	 --PETSC_DIR="$ISSM_TIER/externalpackages/petsc/src" \
+	 --PETSC_DIR="$ISSM_DIR/externalpackages/petsc/src" \
 	 --with-debugging=no \
 	 --with-shared=0 \
@@ -57,5 +57,5 @@
 	 --download-scalapack=yes \
 	 --download-blacs=yes  \
-	 --with-plapack-dir=$ISSM_TIER/externalpackages/petsc/src/$ISSM_ARCH \
+	 --with-plapack-dir=$ISSM_DIR/externalpackages/petsc/src/$ISSM_ARCH \
 	 --download-parmetis=yes \
 	 --FFLAGS=-I/usr/include \
Index: /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-3.1-win7.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-3.1-win7.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-3.1-win7.sh	(revision 12168)
@@ -14,7 +14,7 @@
 ./config/configure.py  \
 	--with-parallel-no \
-	--prefix="$ISSM_TIER/externalpackages/petsc/install" \
+	--prefix="$ISSM_DIR/externalpackages/petsc/install" \
 	--PETSC_ARCH=cygwin-intel \
-	--PETSC_DIR="$ISSM_TIER/externalpackages/petsc/src" \
+	--PETSC_DIR="$ISSM_DIR/externalpackages/petsc/src" \
 	--with-debugging=0 \
 	--with-mpi=0 \
@@ -26,8 +26,8 @@
 
 #./config/configure.py  \
-# --prefix="$ISSM_TIER/externalpackages/petsc/install" \
-# --PETSC_DIR="$ISSM_TIER/externalpackages/petsc/src" \
+# --prefix="$ISSM_DIR/externalpackages/petsc/install" \
+# --PETSC_DIR="$ISSM_DIR/externalpackages/petsc/src" \
 # --PETSC_ARCH=macosx-gnu \
-# --with-mpi-dir=$ISSM_TIER/externalpackages/mpich2/install \
+# --with-mpi-dir=$ISSM_DIR/externalpackages/mpich2/install \
 # --with-debugging=0 \
 # --with-shared=0 \
@@ -38,5 +38,5 @@
 # --download-f-blas-lapack=yes \
 # --download-plapack=yes \
-# --FFLAGS="-I$ISSM_TIER/externalpackages/mpich2/install/include -arch i386" \
+# --FFLAGS="-I$ISSM_DIR/externalpackages/mpich2/install/include -arch i386" \
 # --COPTFLAGS="-march=opteron -O2 -arch i386" \
 # --FOPTFLAGS="-march=opteron -O2 -arch i386" \
Index: /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-3.2-greenplanet.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-3.2-greenplanet.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-3.2-greenplanet.sh	(revision 12168)
@@ -13,6 +13,6 @@
 cd src
 ./config/configure.py \
-	--prefix="$ISSM_TIER/externalpackages/petsc/install" \
-	--PETSC_DIR="$ISSM_TIER/externalpackages/petsc/src" \
+	--prefix="$ISSM_DIR/externalpackages/petsc/install" \
+	--PETSC_DIR="$ISSM_DIR/externalpackages/petsc/src" \
 	--PETSC_ARCH="$ISSM_ARCH" \
 	--with-batch=1 \
Index: /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-3.2-linux64.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-3.2-linux64.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-3.2-linux64.sh	(revision 12168)
@@ -13,9 +13,9 @@
 cd src
 ./config/configure.py \
-	--prefix="$ISSM_TIER/externalpackages/petsc/install" \
-	--with-mpi-dir=$ISSM_TIER/externalpackages/mpich2/install \
+	--prefix="$ISSM_DIR/externalpackages/petsc/install" \
+	--with-mpi-dir=$ISSM_DIR/externalpackages/mpich2/install \
 	--with-clanguage=C++ \
 	--PETSC_ARCH=linux-gnu-amd64 \
-	--PETSC_DIR="$ISSM_TIER/externalpackages/petsc/src" \
+	--PETSC_DIR="$ISSM_DIR/externalpackages/petsc/src" \
 	--with-debugging=0 \
 	--with-shared-libraries=0 \
Index: /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-3.2-macosx64.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-3.2-macosx64.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-3.2-macosx64.sh	(revision 12168)
@@ -13,8 +13,8 @@
 cd src
 ./config/configure.py \
-  --prefix="$ISSM_TIER/externalpackages/petsc/install" \
-  --PETSC_DIR="$ISSM_TIER/externalpackages/petsc/src" \
+  --prefix="$ISSM_DIR/externalpackages/petsc/install" \
+  --PETSC_DIR="$ISSM_DIR/externalpackages/petsc/src" \
   --PETSC_ARCH=macosx-gnu \
-  --with-mpi-dir="$ISSM_TIER/externalpackages/mpich2/install" \
+  --with-mpi-dir="$ISSM_DIR/externalpackages/mpich2/install" \
   --with-debugging=0 \
   --with-shared-libraries=0 \
Index: /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-3.2-pleiades.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-3.2-pleiades.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-3.2-pleiades.sh	(revision 12168)
@@ -17,8 +17,8 @@
 	cd src
 	./config/configure.py \
-		--prefix="$ISSM_TIER/externalpackages/petsc/install" \
+		--prefix="$ISSM_DIR/externalpackages/petsc/install" \
 		--with-batch=1  \
 		--PETSC_ARCH="$ISSM_ARCH" \
-		--PETSC_DIR="$ISSM_TIER/externalpackages/petsc/src" \
+		--PETSC_DIR="$ISSM_DIR/externalpackages/petsc/src" \
 		--with-debugging=0 \
 		--with-shared-libraries=0 \
@@ -44,8 +44,8 @@
 	cd src
 	./config/configure.py \
-	 --prefix="$ISSM_TIER/externalpackages/petsc/install" \
+	 --prefix="$ISSM_DIR/externalpackages/petsc/install" \
 	 --with-batch=1  \
 	 --PETSC_ARCH="$ISSM_ARCH" \
-	 --PETSC_DIR="$ISSM_TIER/externalpackages/petsc/src" \
+	 --PETSC_DIR="$ISSM_DIR/externalpackages/petsc/src" \
 	 --with-debugging=0 \
 	 --with-shared-libraries=0 \
@@ -57,5 +57,5 @@
 	 --download-scalapack=yes \
 	 --download-blacs=yes  \
-	 --with-plapack-dir=$ISSM_TIER/externalpackages/petsc/src/$ISSM_ARCH \
+	 --with-plapack-dir=$ISSM_DIR/externalpackages/petsc/src/$ISSM_ARCH \
 	 --download-parmetis=yes \
 	 --FFLAGS=-I/usr/include \
Index: /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-dev-linux64.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-dev-linux64.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-dev-linux64.sh	(revision 12168)
@@ -6,4 +6,5 @@
 	# Adapted from petsc 3.2. 
 	# Used Mercurial to get code
+	rm -rf src
 	hg clone http://petsc.cs.iit.edu/petsc/petsc-dev src
 	cd src
@@ -25,11 +26,12 @@
 
 if [ $STEP -eq 2 ]; then
+	rm -rf install
 	cd src
 	./config/configure.py \
-	--prefix="$ISSM_TIER/externalpackages/petsc/install" \
-	--with-mpi-dir="$ISSM_TIER/externalpackages/mpich2/install" \
+	--prefix="$ISSM_DIR/externalpackages/petsc/install" \
+	--with-mpi-dir="$ISSM_DIR/externalpackages/mpich2/install" \
 	--with-clanguage=C++ \
 	--PETSC_ARCH=linux-gnu-amd64 \
-	--PETSC_DIR="$ISSM_TIER/externalpackages/petsc/src" \
+	--PETSC_DIR="$ISSM_DIR/externalpackages/petsc/src" \
 	--with-debugging=0 \
 	--with-shared-libraries=0 \
@@ -42,4 +44,5 @@
 	--download-plapack=yes \
 	--download-parmetis=yes \
+	--download-spai=yes \
 	--with-pic=1
 
Index: /issm/branches/trunk-jpl-damage/externalpackages/pyclips/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/pyclips/install.sh	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/externalpackages/pyclips/install.sh	(revision 12168)
@@ -0,0 +1,18 @@
+#!/bin/bash
+
+#Some cleanup
+rm -rf install
+rm -rf pyclips-1.0.7.348
+mkdir install
+
+#Untar 
+tar -zxvf  pyclips-1.0.7.348.tar.gz
+
+#Move pyclips into install directory
+mv pyclips/* install
+rm -rf pyclips
+
+#install
+cd install
+python setup.py build
+sudo python setup.py install
Index: /issm/branches/trunk-jpl-damage/externalpackages/python/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/python/install.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/externalpackages/python/install.sh	(revision 12168)
@@ -20,5 +20,5 @@
 #Configure doxygen
 cd src 
-./configure --prefix="$ISSM_TIER/externalpackages/python/install" --enable-framework="$ISSM_TIER/externalpackages/python/install"
+./configure --prefix="$ISSM_DIR/externalpackages/python/install" --enable-framework="$ISSM_DIR/externalpackages/python/install"
 if [ -z $1 ]; then
 	make
Index: /issm/branches/trunk-jpl-damage/externalpackages/qhull/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/qhull/install.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/externalpackages/qhull/install.sh	(revision 12168)
@@ -15,5 +15,5 @@
 #Configure qhull
 cd src
-./configure --prefix="$ISSM_TIER/externalpackages/qhull/install"
+./configure --prefix="$ISSM_DIR/externalpackages/qhull/install"
 make
 make install
Index: /issm/branches/trunk-jpl-damage/externalpackages/rats/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/rats/install.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/externalpackages/rats/install.sh	(revision 12168)
@@ -12,5 +12,5 @@
 #compile
 cd src
-./configure --prefix=$ISSM_TIER/externalpackages/rats/install
+./configure --prefix=$ISSM_DIR/externalpackages/rats/install
 make
 make install
Index: /issm/branches/trunk-jpl-damage/externalpackages/readline/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/readline/install.sh	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/externalpackages/readline/install.sh	(revision 12168)
@@ -0,0 +1,17 @@
+#!/bin/bash
+
+#Some cleanup
+rm -rf src
+rm -rf readline-6.2.2
+mkdir src 
+
+#Untar 
+tar -zxvf  readline-6.2.2.tar.gz
+
+#Move readline into src directory
+mv readline-6.2.2/* src
+rm -rf readline-6.2.2
+
+$install
+cd src
+python setup.py install
Index: /issm/branches/trunk-jpl-damage/externalpackages/rose/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/rose/install.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/externalpackages/rose/install.sh	(revision 12168)
@@ -15,7 +15,7 @@
 cd build
 ../source/configure \
-	--prefix=$ISSM_TIER/externalpackages/rose/install \
-	--with-boost=$ISSM_TIER/externalpackages/boost/install\
-	--srcdir=$ISSM_TIER/externalpackages/rose/source
+	--prefix=$ISSM_DIR/externalpackages/rose/install \
+	--with-boost=$ISSM_DIR/externalpackages/boost/install\
+	--srcdir=$ISSM_DIR/externalpackages/rose/source
 
 if [ -z $1 ]; then
Index: /issm/branches/trunk-jpl-damage/externalpackages/scipy/install-macosx64.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/scipy/install-macosx64.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/externalpackages/scipy/install-macosx64.sh	(revision 12168)
@@ -19,6 +19,6 @@
 	#install numpy
 	cd numpy
-	python3.2 setup.py build
-	python3.2 setup.py install
+	python setup.py build
+	python setup.py install
 
 	
@@ -30,6 +30,6 @@
 	#install scipy
 	cd scipy
-	python3.2 setup.py build
-	python3.2 setup.py install
+	python setup.py build
+	python setup.py install
 
 elif [[ $install == "3" ]];then 
Index: /issm/branches/trunk-jpl-damage/externalpackages/swig/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/swig/install.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/externalpackages/swig/install.sh	(revision 12168)
@@ -13,14 +13,14 @@
 #Copy pcre prototype in include directory
 cd install 
-#cp $ISSM_TIER/externalpackages/pcre/install/pcre.h  ./Source/Include/
-#cp $ISSM_TIER/externalpackages/pcre/install/.libs/*  ./Source/Include/
-export CFLAGS="$CFLAGS -I$ISSM_TIER/externalpackages/pcre/install"
-export LDFLAGS="-L$ISSM_TIER/externalpackages/pcre/install/.libs/"
+#cp $ISSM_DIR/externalpackages/pcre/install/pcre.h  ./Source/Include/
+#cp $ISSM_DIR/externalpackages/pcre/install/.libs/*  ./Source/Include/
+export CFLAGS="$CFLAGS -I$ISSM_DIR/externalpackages/pcre/install"
+export LDFLAGS="-L$ISSM_DIR/externalpackages/pcre/install/.libs/"
 export LIBS="-lpcre"
 #Configure doxygen
 ./configure \
- --prefix="$ISSM_TIER/externalpackages/python/install" \
- --with-pcre-prefix="$ISSM_TIER/externalpackages/pcre/install" \
- --with-pcre-exec-prefix="$ISSM_TIER/externalpackages/pcre/install"
+ --prefix="$ISSM_DIR/externalpackages/python/install" \
+ --with-pcre-prefix="$ISSM_DIR/externalpackages/pcre/install" \
+ --with-pcre-exec-prefix="$ISSM_DIR/externalpackages/pcre/install"
 make 
 make install
Index: /issm/branches/trunk-jpl-damage/externalpackages/tao/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/tao/install.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/externalpackages/tao/install.sh	(revision 12168)
@@ -14,5 +14,5 @@
 rm -rf tao-2.0-p3
 cd install
-export TAO_DIR="$ISSM_TIER/externalpackages/tao/install/"
+export TAO_DIR="$ISSM_DIR/externalpackages/tao/install/"
 
 #petsc needs to be compiled with --with-clanguage=C++
Index: sm/branches/trunk-jpl-damage/externalpackages/triangle/README
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/triangle/README	(revision 12167)
+++ 	(revision )
@@ -1,2 +1,0 @@
-Go pick up the correct configure.make  file in the config directory (according to your platform), 
-copy it to the top triangle directory, and run install.sh
Index: /issm/branches/trunk-jpl-damage/externalpackages/triangle/configs/android/android-4.0/configure.make
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/triangle/configs/android/android-4.0/configure.make	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/externalpackages/triangle/configs/android/android-4.0/configure.make	(revision 12168)
@@ -11,8 +11,8 @@
 
 ANDROID_BIN=$(ISSM_TIER)/src/android/tmp/android-14-toolchain/bin
-CC=$(ANDROID_DEV_DIR)/tmp/android-linux-4.0/bin/arm-linux-androideabi-gcc
-AR=$(ANDROID_DEV_DIR)/tmp/android-linux-4.0/bin/arm-linux-androideabi-ar
-RANLIB=$(ANDROID_DEV_DIR)/tmp/android-linux-4.0/bin/arm-linux-androideabi-ranlib
-CSWITCHES = $(CFLAGS)  -I/usr/X11R6/include -L/usr/X11R6/lib -I$(MATLAB_DIR)/extern/include -fPIC -I$(MATLAB_DIR)/include
+CC=$(ANDROID_DIR)/arm-linux-android-4.0/bin/arm-linux-androideabi-gcc
+AR=$(ANDROID_DIR)/arm-linux-android-4.0/bin/arm-linux-androideabi-ar
+RANLIB=$(ANDROID_DIR)/arm-linux-android-4.0/bin/arm-linux-androideabi-ranlib
+CSWITCHES = $(CFLAGS)
 TRILIBDEFS = -DTRILIBRARY
 OBJ_EXT=o
Index: /issm/branches/trunk-jpl-damage/externalpackages/triangle/triangle.c.patch.python
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/triangle/triangle.c.patch.python	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/externalpackages/triangle/triangle.c.patch.python	(revision 12168)
@@ -5,6 +5,6 @@
 >  * double precision activation in exactinit(); The rest is not changed. 
 >  * We also created the ice_makefile to compile Triangle into a library. */
-> #include <mat.h>
-> #include <matrix.h>
+> /* #include <mat.h>
+> #include <matrix.h> */
 > #define ANSI_DECLARATORS
 > #define NO_TIMER
Index: /issm/branches/trunk-jpl-damage/externalpackages/valgrind/install-altix64.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/valgrind/install-altix64.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/externalpackages/valgrind/install-altix64.sh	(revision 12168)
@@ -14,5 +14,5 @@
 #configure
 cd install
-./configure --prefix="$ISSM_TIER/externalpackages/valgrind/install"
+./configure --prefix="$ISSM_DIR/externalpackages/valgrind/install"
 
 #Compile valgrind
Index: /issm/branches/trunk-jpl-damage/externalpackages/valgrind/install-linux64.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/valgrind/install-linux64.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/externalpackages/valgrind/install-linux64.sh	(revision 12168)
@@ -14,5 +14,5 @@
 #configure
 cd install
-./configure  --prefix="$ISSM_TIER/externalpackages/valgrind/install"
+./configure  --prefix="$ISSM_DIR/externalpackages/valgrind/install"
 
 #Compile valgrind
Index: /issm/branches/trunk-jpl-damage/externalpackages/valgrind/install-macosx32.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/valgrind/install-macosx32.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/externalpackages/valgrind/install-macosx32.sh	(revision 12168)
@@ -14,5 +14,5 @@
 #configure
 cd install
-./configure  --prefix="$ISSM_TIER/externalpackages/valgrind/install" --enable-only32bit
+./configure  --prefix="$ISSM_DIR/externalpackages/valgrind/install" --enable-only32bit
 
 #Compile valgrind
Index: /issm/branches/trunk-jpl-damage/externalpackages/valgrind/install-macosx64.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/valgrind/install-macosx64.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/externalpackages/valgrind/install-macosx64.sh	(revision 12168)
@@ -14,5 +14,5 @@
 #configure
 cd install
-./configure  --prefix="$ISSM_TIER/externalpackages/valgrind/install" --enable-only64bit
+./configure  --prefix="$ISSM_DIR/externalpackages/valgrind/install" --enable-only64bit
 
 #Compile valgrind
Index: /issm/branches/trunk-jpl-damage/externalpackages/valgrind/install-win32.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/valgrind/install-win32.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/externalpackages/valgrind/install-win32.sh	(revision 12168)
@@ -14,5 +14,5 @@
 #configure
 cd install
-./configure  --prefix="$ISSM_TIER/externalpackages/valgrind/install"
+./configure  --prefix="$ISSM_DIR/externalpackages/valgrind/install"
 
 #Compile valgrind
Index: /issm/branches/trunk-jpl-damage/externalpackages/vim/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/vim/install.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/externalpackages/vim/install.sh	(revision 12168)
@@ -19,5 +19,5 @@
 cd src/src 
 ./configure \
-	--prefix "$ISSM_TIER/externalpackages/vim/install" \
+	--prefix "$ISSM_DIR/externalpackages/vim/install" \
 	--with-gcc "/usr/bin/gcc"
 
Index: /issm/branches/trunk-jpl-damage/externalpackages/windows/configs/sdk7.1.win7-64.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/windows/configs/sdk7.1.win7-64.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/externalpackages/windows/configs/sdk7.1.win7-64.sh	(revision 12168)
@@ -15,5 +15,5 @@
 declare -x LOCALAPPDATA="C:\\Users\\schlegel\\AppData\\Local"
 declare -x MANPATH="/usr/local/man:/usr/share/man:/usr/man:"
-declare -x PATH="/usr/local/bin:/usr/bin:/usr/include:/cygdrive/c/cygwin/usr/bin:/cygdrive/c/cygwin/usr/include:/cygdrive/c/Windows/Microsoft.NET/Framework64/v4.0.30319:/cygdrive/c/Windows/Microsoft.NET/Framework/v4.0.30319:/cygdrive/c/Windows/Microsoft.NET/Framework64/v3.5:/cygdrive/c/Windows/Microsoft.NET/Framework/v3.5:/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 10.0/Common7/IDE:/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 10.0/Common7/Tools:/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 10.0/VC/Bin/amd64:/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 10.0/VC/Bin/VCPackages:/cygdrive/c/Program Files/Microsoft SDKs/Windows/v7.1/Bin/NETFX 4.0 Tools/x64:/cygdrive/c/Program Files/Microsoft SDKs/Windows/v7.1/Bin/x64:/cygdrive/c/Program Files/Microsoft SDKs/Windows/v7.1/Bin:/cygdrive/c/Windows/system32:/cygdrive/c/Windows:/cygdrive/c/Windows/System32/Wbem:/cygdrive/c/Windows/System32/WindowsPowerShell/v1.0:/cygdrive/c/Program Files/Microsoft Windows Performance Toolkit:/cygdrive/c/MATLAB/R2011b/runtime/win64:/cygdrive/b/MATLAB/R2011b/bin:/cygdrive/c/MATLAB/R2011b/extern/include:/cygdrive/c/MATLAB/R2011a/runtime/win64:/cygdrive/c/MATLAB/R2011a/bin:/cygdrive/c/MATLAB/R2011a/extern/include"
+declare -x PATH="/usr/local/bin:/usr/bin:/usr/include:/cygdrive/c/cygwin/usr/bin:/cygdrive/c/cygwin/usr/include:/cygdrive/c/Windows/Microsoft.NET/Framework64/v4.0.30319:/cygdrive/c/Windows/Microsoft.NET/Framework/v4.0.30319:/cygdrive/c/Windows/Microsoft.NET/Framework64/v3.5:/cygdrive/c/Windows/Microsoft.NET/Framework/v3.5:/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 10.0/Common7/IDE:/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 10.0/Common7/Tools:/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 10.0/VC/Bin/amd64:/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 10.0/VC/Bin/VCPackages:/cygdrive/c/Program Files/Microsoft SDKs/Windows/v7.1/Bin/NETFX 4.0 Tools/x64:/cygdrive/c/Program Files/Microsoft SDKs/Windows/v7.1/Bin/x64:/cygdrive/c/Program Files/Microsoft SDKs/Windows/v7.1/Bin:/cygdrive/c/Windows/system32:/cygdrive/c/Windows:/cygdrive/c/Windows/System32/Wbem:/cygdrive/c/Windows/System32/WindowsPowerShell/v1.0:/cygdrive/c/Program Files/Microsoft Windows Performance Toolkit:/cygdrive/c/MATLAB/R2012a/runtime/win64:/cygdrive/c/MATLAB/R2012a/bin:/cygdrive/c/MATLAB/R2012a/extern/include:/cygdrive/c/MATLAB/R2011a/runtime/win64:/cygdrive/c/MATLAB/R2011a/bin:/cygdrive/c/MATLAB/R2011a/extern/include"
 declare -x PATHEXT=".COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC"
 declare -x PROCESSOR_ARCHITECTURE="x86"
Index: /issm/branches/trunk-jpl-damage/m4/issm_options.m4
===================================================================
--- /issm/branches/trunk-jpl-damage/m4/issm_options.m4	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/m4/issm_options.m4	(revision 12168)
@@ -13,31 +13,15 @@
 	fi
 	dnl }}}
-	dnl Serial build {{{
-	AC_ARG_WITH([serial],
-		AS_HELP_STRING([--with-serial = value],[serial compilation. ]),
-		[SERIAL_VALUE=$withval],[SERIAL_VALUE="yes"])
-	AC_MSG_CHECKING(for serial compilation)
-	AM_CONDITIONAL([NOSERIAL], [test $SERIAL_VALUE = no])
-	AM_CONDITIONAL([SERIAL], [test $SERIAL_VALUE = yes])
-	AC_MSG_RESULT($SERIAL_VALUE) 
-	dnl }}}
-	dnl Parallel build {{{
-	AC_ARG_WITH([parallel],
-		AS_HELP_STRING([--with-parallel = value], [parallel compilation. ]),
-		[PARALLEL_VALUE=$withval],[PARALLEL_VALUE="yes"])
-	AC_MSG_CHECKING(for parallel compilation)
-	AM_CONDITIONAL([NOPARALLEL], [test $PARALLEL_VALUE = no])
-	AM_CONDITIONAL([PARALLEL], [test $PARALLEL_VALUE = yes])
-	AC_MSG_RESULT($PARALLEL_VALUE) 
+	dnl Modules build {{{
+	AC_ARG_WITH([modules],
+		AS_HELP_STRING([--with-modules = value],[modules compilation. ]),
+		[MODULES_VALUE=$withval],[MODULES_VALUE="yes"])
+	AC_MSG_CHECKING(for modules compilation)
+	AM_CONDITIONAL([MODULES], [test $MODULES_VALUE = yes])
+	AC_MSG_RESULT($MODULES_VALUE) 
+	dnl }}}
+	dnl Extensions{{{
 	ISSMEXT=".exe"
 	AC_SUBST([ISSMEXT])
-	dnl }}}
-	dnl Serial or Parallel check {{{
-	dnl Check that at least serial or parallel builds have been requested!
-	if test "$SERIAL_VALUE" != "yes" ; then
-		if test "$PARALLEL_VALUE" != "yes"; then
-			AC_MSG_ERROR([cannot request --with-serial=no and --with-parallel=no at the same time!])
-		fi
-	fi
 	dnl }}}
 
@@ -81,4 +65,8 @@
 			export CXXFLAGS=" -O3 -xS -D_INTEL_LINUX_ "
 			export CFLAGS=" -O3 -xS -D_INTEL_LINUX_ "
+		elif test $VENDOR = arm-linux; then
+			export CC=$ANDROID_DIR/arm-linux-android-4.0/bin/arm-linux-androideabi-cc
+			export CXX=$ANDROID_DIR/arm-linux-android-4.0/bin/arm-linux-androideabi-cc
+
 		else
 		AC_MSG_ERROR([unknow compiler vendor!])
@@ -92,8 +80,8 @@
 	dnl 1. See if matlab has been provided
 	AC_ARG_WITH([matlab-dir],
-		AS_HELP_STRING([--with-matlab-dir = DIR], [matlab root directory. necessary for serial build.]),
+		AS_HELP_STRING([--with-matlab-dir=DIR], [matlab root directory. necessary for serial build.]),
 		[MATLAB_ROOT=$withval],[MATLAB_ROOT=""]) 
 
-	AC_MSG_CHECKING([wether Matlab is enabled])
+	AC_MSG_CHECKING([whether matlab is enabled])
 	if test -d "$MATLAB_ROOT"; then
 		HAVE_MATLAB=yes
@@ -109,5 +97,5 @@
 	dnl 2. if matlab is provided, get version number
 	if test x$HAVE_MATLAB = xyes; then
-		AC_MSG_CHECKING([for Matlab version])
+		AC_MSG_CHECKING([for matlab version])
 		MATLAB_VERSION=""
 
@@ -172,5 +160,5 @@
 
 		dnl 3. Get Matlab libraries
-		AC_MSG_CHECKING(for Matlab headers and libraries in $MATLAB_ROOT)
+		AC_MSG_CHECKING(for matlab headers and libraries in $MATLAB_ROOT)
 		MATLABINCL=-I"$MATLAB_ROOT/extern/include";
 		
@@ -191,9 +179,9 @@
 			*darwin*)
 				dnl mex -v gives all the flags for compilation of mex files
-				dnl if matlab version is 7.10 or more, we must use mexmaci64 (64 bits)
+				dnl if matlab version is 7.9 or more, we must use mexmaci64 (64 bits)
 				MEXLINK="-O -Wl,-flat_namespace -undefined suppress -arch i386 -bundle -Wl,-exported_symbols_list,$MATLAB_ROOT/extern/lib/maci/mexFunction.map"
 				MEXLIB=" -L$MATLAB_ROOT/bin/maci/ -lmx -lmex -lmat -lstdc++ -largeArrayDims"
 				if test $MATLAB_MAJOR -ge 7; then 
-					 if test $MATLAB_MINOR -ge 10; then 
+					 if test $MATLAB_MINOR -ge 9; then 
 						  MEXLINK="-O -Wl,-flat_namespace -undefined suppress -bundle -Wl,-exported_symbols_list,$MATLAB_ROOT/extern/lib/maci64/mexFunction.map"
 							 MEXLIB=" -L$MATLAB_ROOT/bin/maci64/ -lmx -lmex -lmat -lstdc++"
@@ -217,6 +205,6 @@
 		AC_SUBST([MATLABINCL])
 		AC_SUBST([MEX])
-		WRAPPEREXT=$MEXEXT
-		AC_SUBST([WRAPPEREXT])
+		MATLABWRAPPEREXT=$MEXEXT
+		AC_SUBST([MATLABWRAPPEREXT])
 		AC_SUBST([MEXLIB]) 
 		AC_SUBST([MEXLINK])
@@ -225,7 +213,7 @@
 	dnl triangle {{{
 	AC_ARG_WITH([triangle-dir],
-			  AS_HELP_STRING([--with-triangle-dir = DIR], [triangle root directory. necessary for serial build]),
+			  AS_HELP_STRING([--with-triangle-dir=DIR], [triangle root directory. necessary for serial build]),
 			 [TRIANGLE_ROOT=$withval],[TRIANGLE_ROOT=""]) 
-	AC_MSG_CHECKING(for Triangle headers and libraries)
+	AC_MSG_CHECKING(for triangle headers and libraries)
 
 	if test -d "$TRIANGLE_ROOT"; then
@@ -266,7 +254,7 @@
 	dnl dakota{{{
 	AC_ARG_WITH([dakota-dir],
-	  AS_HELP_STRING([--with-dakota-dir = DIR], [dakota root directory. necessary for serial build]),
+	  AS_HELP_STRING([--with-dakota-dir=DIR], [dakota root directory. necessary for serial build]),
 	  [DAKOTA_ROOT=$withval],[DAKOTA_ROOT=""]) 
-	AC_MSG_CHECKING(for Dakota)
+	AC_MSG_CHECKING(for dakota)
 	
 	if test -d "$DAKOTA_ROOT"; then
@@ -299,7 +287,7 @@
 	dnl boost{{{
 	AC_ARG_WITH([boost-dir],
-	  AS_HELP_STRING([--with-boost-dir = DIR], [boost root directory.]),
+	  AS_HELP_STRING([--with-boost-dir=DIR], [boost root directory.]),
 	  [BOOST_ROOT=$withval],[BOOST_ROOT=""]) 
-	AC_MSG_CHECKING(for Boost)
+	AC_MSG_CHECKING(for boost)
 	
 	if test -d "$BOOST_ROOT"; then
@@ -318,9 +306,29 @@
 	AC_MSG_RESULT($HAVE_BOOST)
 	dnl }}}
+	dnl python-version{{{
+	AC_ARG_WITH([python-version],
+	  AS_HELP_STRING([--with-python-version = PYTHONVERSION],[python version.]),
+	  [PYTHONVERSION=$withval],[PYTHONVERSION=""])
+	AC_MSG_CHECKING(for python version)
+
+	HAVE_PYTHON3="no"
+
+	dnl recover major: 
+	PYTHON_MAJOR=${PYTHONVERSION%.*}
+
+	if test x$PYTHON_MAJOR = x3; then
+		dnl are we running python 3?
+		HAVE_PYTHON3="yes"
+	fi
+	AC_DEFINE_UNQUOTED([_PYTHON_MAJOR_],$PYTHON_MAJOR,[python version major])
+
+	AM_CONDITIONAL([PYTHON3], [test x$HAVE_PYTHON3 = xyes])
+	AC_MSG_RESULT($PYTHON_MAJOR)
+	dnl }}}
 	dnl python{{{
 	AC_ARG_WITH([python-dir],
-	  AS_HELP_STRING([--with-python-dir = DIR], [python root directory.]),
+	  AS_HELP_STRING([--with-python-dir=DIR], [python root directory.]),
 	  [PYTHON_ROOT=$withval],[PYTHON_ROOT=""]) 
-	AC_MSG_CHECKING(for Python)
+	AC_MSG_CHECKING(for python)
 	
 	if test -d "$PYTHON_ROOT"; then
@@ -328,5 +336,5 @@
 		HAVE_PYTHON=yes
 		PYTHONINCL=-I$PYTHON_ROOT/include
-		PYTHONLIB="-L$PYTHON_ROOT/lib -lpython3.2"
+		PYTHONLIB="-L$PYTHON_ROOT/lib -lpython$PYTHONVERSION"
 		PYTHONEXT=.so
 		PYTHONLINK="-dynamiclib"
@@ -335,6 +343,6 @@
 		AC_SUBST([PYTHONINCL])
 		AC_SUBST([PYTHONLIB])
-		WRAPPEREXT=$PYTHONEXT
-		AC_SUBST([WRAPPEREXT])
+		PYTHONWRAPPEREXT=$PYTHONEXT
+		AC_SUBST([PYTHONWRAPPEREXT])
 		AC_SUBST([PYTHONLINK])
 	else
@@ -346,7 +354,7 @@
 	dnl python-numpy{{{
 	AC_ARG_WITH([python-numpy-dir],
-	  AS_HELP_STRING([--with-python-numpy-dir = DIR], [python-numpy root directory.]),
+	  AS_HELP_STRING([--with-python-numpy-dir=DIR], [python-numpy root directory.]),
 	  [PYTHON_NUMPY_ROOT=$withval],[PYTHON_NUMPY_ROOT=""]) 
-	AC_MSG_CHECKING(for Python-Numpy)
+	AC_MSG_CHECKING(for python-numpy)
 	
 	if test -d "$PYTHON_NUMPY_ROOT"; then
@@ -364,7 +372,7 @@
 	dnl chaco{{{
 	AC_ARG_WITH([chaco-dir],
-	  AS_HELP_STRING([--with-chaco-dir = DIR], [chaco root directory.]),
+	  AS_HELP_STRING([--with-chaco-dir=DIR], [chaco root directory.]),
 	  [CHACO_ROOT=$withval],[CHACO_ROOT=""]) 
-	AC_MSG_CHECKING(for Chaco)
+	AC_MSG_CHECKING(for chaco)
 	
 	if test -d "$CHACO_ROOT"; then
@@ -386,7 +394,7 @@
 	dnl scotch{{{
 	AC_ARG_WITH([scotch-dir],
-	  AS_HELP_STRING([--with-scotch-dir = DIR], [scotch root directory.]),
+	  AS_HELP_STRING([--with-scotch-dir=DIR], [scotch root directory.]),
 	  [SCOTCH_ROOT=$withval],[SCOTCH_ROOT=""]) 
-	AC_MSG_CHECKING(for Scotch)
+	AC_MSG_CHECKING(for scotch)
 	
 	if test -d "$SCOTCH_ROOT"; then
@@ -408,7 +416,7 @@
 	dnl adolc{{{
 	AC_ARG_WITH([adolc-dir],
-		AS_HELP_STRING([--with-adolc-dir = DIR], [adolc root directory.]),
+		AS_HELP_STRING([--with-adolc-dir=DIR], [adolc root directory.]),
 		[ADOLC_ROOT=$withval],[ADOLC_ROOT="no"]) 
-	AC_MSG_CHECKING(for ADOLC)
+	AC_MSG_CHECKING(for adolc)
 
 	if test "x$ADOLC_ROOT" = "xno"; then
@@ -436,7 +444,7 @@
 	dnl adic2{{{
 	AC_ARG_WITH([adic2-dir],
-	  AS_HELP_STRING([--with-adic2-dir = DIR], [adic2 root directory.]),
+	  AS_HELP_STRING([--with-adic2-dir=DIR], [adic2 root directory.]),
 	  [ADIC2_ROOT=$withval],[ADIC2_ROOT="no"]) 
-	AC_MSG_CHECKING(for ADIC2)
+	AC_MSG_CHECKING(for adic2)
 
 	if test "x$ADIC2_ROOT" = "xno"; then
@@ -464,7 +472,7 @@
 	dnl gsl{{{
 	AC_ARG_WITH([gsl-dir],
-	  AS_HELP_STRING([--with-gsl-dir = DIR], [gsl root directory.]),
+	  AS_HELP_STRING([--with-gsl-dir=DIR], [gsl root directory.]),
 	  [GSL_ROOT=$withval],[GSL_ROOT=""]) 
-	AC_MSG_CHECKING(for Gsl)
+	AC_MSG_CHECKING(for gsl)
 	
 	if test -d "$GSL_ROOT"; then
@@ -487,7 +495,7 @@
 	dnl rose{{{
 	AC_ARG_WITH([rose-dir],
-	  AS_HELP_STRING([--with-rose-dir = DIR], [rose root directory.]),
+	  AS_HELP_STRING([--with-rose-dir=DIR], [rose root directory.]),
 	  [ROSE_ROOT=$withval],[ROSE_ROOT=""]) 
-	AC_MSG_CHECKING(for Rose)
+	AC_MSG_CHECKING(for rose)
 	
 	if test -d "$ROSE_ROOT"; then
@@ -510,10 +518,10 @@
 	dnl metis{{{
 	AC_ARG_WITH([metis-dir],
-	  AS_HELP_STRING([--with-metis-dir = DIR],[metis root directory. necessary for serial build]),
+	  AS_HELP_STRING([--with-metis-dir=DIR],[metis root directory. necessary for serial build]),
 	  [METIS_ROOT=$withval],[METIS_ROOT=""])
 
 	if test -d "$METIS_ROOT"; then
 
-		AC_MSG_CHECKING(for Metis headers and libraries in $METIS_ROOT)
+		AC_MSG_CHECKING(for metis headers and libraries in $METIS_ROOT)
 
 		dnl first figure out version of metis: does the VERSION file exist?
@@ -568,10 +576,5 @@
 		HAVE_METIS=no
 	fi
-
-	if test $HAVE_METIS = no; then
-		AC_MSG_ERROR([--with-metis-dir  missing. Metis is needed to run ISSM]);
-	else
-		AC_MSG_RESULT($HAVE_METIS)
-	fi
+	AM_CONDITIONAL([METIS], [test x$HAVE_METIS = xyes])
 	dnl }}}
 	dnl mpi{{{
@@ -582,5 +585,5 @@
 	
 	AC_ARG_WITH([mpi-include],
-	  AS_HELP_STRING([--with-mpi-include = DIR],[mpi include directory, necessary for parallel build]),
+	  AS_HELP_STRING([--with-mpi-include=DIR],[mpi include directory, necessary for parallel build]),
 	  [MPI_INCLUDE=$withval],[MPI_INCLUDE=""])
 	
@@ -591,4 +594,5 @@
 			HAVE_MPI=no
 		else
+			HAVE_MPI=yes
 			MPIINCL=-I"$MPI_INCLUDE/"
 			AC_DEFINE([_HAVE_MPI_],[1],[with Mpi in ISSM src])
@@ -598,13 +602,14 @@
 		fi
 	fi
-	AC_MSG_RESULT(done)
+	AM_CONDITIONAL([MPI], [test x$HAVE_MPI = xyes])
+	AC_MSG_RESULT($HAVE_MPI)
 	dnl }}}
 	dnl petsc{{{
 	AC_ARG_WITH([petsc-dir],
-	  AS_HELP_STRING([--with-petsc-dir = DIR],[PETSc root directory, necessary for parallel build]),
+	  AS_HELP_STRING([--with-petsc-dir=DIR],[PETSc root directory, necessary for parallel build]),
 	  [PETSC_ROOT=$withval],[PETSC_ROOT=""])
 		
 	if test -d "$PETSC_ROOT"; then
-		AC_MSG_CHECKING(for PETSc version)
+		AC_MSG_CHECKING(for petsc version)
 		PETSC_MAJOR=`cat $PETSC_ROOT/include/petscversion.h | grep "#define PETSC_VERSION_MAJOR" | sed 's/#define PETSC_VERSION_MAJOR//' | sed 's/ //g'`
 		PETSC_MINOR=`cat $PETSC_ROOT/include/petscversion.h | grep "#define PETSC_VERSION_MINOR" | sed 's/#define PETSC_VERSION_MINOR//' | sed 's/ //g'`
@@ -614,5 +619,5 @@
 
 		PETSC_VERSION_DATE_HG=`cat $PETSC_ROOT/include/petscversion.h | grep "#define PETSC_VERSION_DATE_HG" | sed 's/#define PETSC_VERSION_DATE_HG//' | sed 's/ //g' | sed -e 's/\"//g' `
-		AC_MSG_CHECKING(wether PETSc is the development version)
+		AC_MSG_CHECKING(whether petsc is the development version)
 		if test x$PETSC_VERSION_DATE_HG = xunknown; then
 			AC_DEFINE([_HAVE_PETSCDEV_],[1],[with PETSc-dev])
@@ -624,8 +629,8 @@
 	
 	AC_ARG_WITH([petsc-arch],
-	  AS_HELP_STRING([--with-petsc-arch = DIR],[PETSc arch , necessary for parallel build]),
+	  AS_HELP_STRING([--with-petsc-arch=DIR],[PETSc arch , necessary for parallel build]),
 	  [PETSC_ARCH=$withval],[PETSC_ARCH=""])
 
-	AC_MSG_CHECKING(for PETSc headers and libraries in $PETSC_ROOT for architecture $PETSC_ARCH)
+	AC_MSG_CHECKING(for petsc headers and libraries in $PETSC_ROOT for architecture $PETSC_ARCH)
 	
 	if test -d "$PETSC_ROOT"; then
@@ -671,7 +676,7 @@
 	dnl tao{{{
 	AC_ARG_WITH([tao-dir],
-		AS_HELP_STRING([--with-tao-dir = DIR], [tao root directory.]),
+		AS_HELP_STRING([--with-tao-dir=DIR], [tao root directory.]),
 		[TAO_ROOT=$withval],[TAO_ROOT=""]) 
-	AC_MSG_CHECKING(for Tao)
+	AC_MSG_CHECKING(for tao)
 
 	if test -d "$TAO_ROOT"; then
@@ -689,33 +694,10 @@
 	AC_MSG_RESULT($HAVE_TAO)
 	dnl }}}
-	dnl mpiuni{{{
-	dnl when running in serial mode, MPI must be ignored, and set to internal petsc mpiuni: 
-	if test "$PARALLEL_VALUE" = "no" ; then
-		HAVE_MPI=yes
-		MPIINCL=-I"$PETSC_ROOT/include/mpiuni"
-
-		case "${host_os}" in
-			*cygwin*)
-			dnl MPILIB="-link -LIBPATH:\"$PETSC_ROOT/$PETSC_ARCH/lib\" -LIBPATH:\"$PETSC_ROOT/lib\" -LIBPATH:\"$PETSC_ROOT/lib/$PETSC_ARCH\" libmpiuni.lib"
-			;;
-			*linux*)
-			MPILIB="-L$PETSC_ROOT/$PETSC_ARCH/lib -L$PETSC_ROOT/lib -L$PETSC_ROOT/lib/$PETSC_ARCH -lmpiuni"
-			;;
-			*darwin*)
-			MPILIB="-L$PETSC_ROOT/$PETSC_ARCH/lib -L$PETSC_ROOT/lib -L$PETSC_ROOT/lib/$PETSC_ARCH -lmpiuni"
-			;;
-		esac
-								  
-		AC_DEFINE([_HAVE_MPI_],[1],[with Mpi in ISSM src])
-		AC_SUBST([MPIINCL])
-		AC_SUBST([MPILIB])
-	fi
-	dnl }}}
 	dnl slepc{{{
 	AC_ARG_WITH([slepc-dir],
-	  AS_HELP_STRING([--with-slepc-dir = DIR],[slepc root directory]),
+	  AS_HELP_STRING([--with-slepc-dir=DIR],[slepc root directory]),
 	  [SLEPC_ROOT=$withval],[SLEPC_ROOT=""])
 			  
-	AC_MSG_CHECKING(for Slepc headers and libraries in $SLEPC_ROOT)
+	AC_MSG_CHECKING(for slepc headers and libraries in $SLEPC_ROOT)
 	if test -d "$SLEPC_ROOT"; then
 		HAVE_SLEPC=yes
@@ -733,8 +715,8 @@
 	dnl shapelib{{{
 	AC_ARG_WITH([shapelib-dir],
-	  AS_HELP_STRING([--with-shapelib-dir = DIR], [shapelib root directory]),
+	  AS_HELP_STRING([--with-shapelib-dir=DIR], [shapelib root directory]),
 	  [SHAPELIB_ROOT=$withval],[SHAPELIB_ROOT=""])
 			  
-	AC_MSG_CHECKING(for Shapelib headers and libraries in $SHAPELIB_ROOT)
+	AC_MSG_CHECKING(for shapelib headers and libraries in $SHAPELIB_ROOT)
 	if test -d "$SHAPELIB_ROOT"; then
 
@@ -754,8 +736,8 @@
 	dnl scalapack{{{
 	AC_ARG_WITH([scalapack-dir],
-	  AS_HELP_STRING([--with-scalapack-dir = DIR],[scalapack root directory]),
+	  AS_HELP_STRING([--with-scalapack-dir=DIR],[scalapack root directory]),
 	  [SCALAPACK_ROOT=$withval],[SCALAPACK_ROOT=""])
 			  
-	AC_MSG_CHECKING(for Scalapack headers and libraries in $SCALAPACK_ROOT)
+	AC_MSG_CHECKING(for scalapack headers and libraries in $SCALAPACK_ROOT)
 	if test -d "$SCALAPACK_ROOT"; then
 
@@ -773,8 +755,8 @@
 	dnl blas{{{
 	AC_ARG_WITH([blas-lapack-dir],
-	  AS_HELP_STRING([--with-blas-lapack-dir = DIR],[blas-lapack root directory]),
+	  AS_HELP_STRING([--with-blas-lapack-dir=DIR],[blas-lapack root directory]),
 	  [BLASLAPACK_ROOT=$withval],[BLASLAPACK_ROOT=""])
 			  
-	AC_MSG_CHECKING(for Blas and Lapack headers and libraries in $BLASLAPACK_ROOT)
+	AC_MSG_CHECKING(for blas and lapack headers and libraries in $BLASLAPACK_ROOT)
 	if test -d "$BLASLAPACK_ROOT"; then
 
@@ -806,5 +788,5 @@
 	dnl mkl{{{
 	AC_ARG_WITH([mkl-dir],
-	  AS_HELP_STRING([--with-mkl-dir = DIR],[mkl root directory]),
+	  AS_HELP_STRING([--with-mkl-dir=DIR],[mkl root directory]),
 	  [MKL_ROOT=$withval],[MKL_ROOT=""])
 			  
@@ -825,8 +807,9 @@
 	dnl }}}
 	dnl plapack{{{
+	AC_MSG_CHECKING(for plapack)
+	
 	AC_ARG_WITH([plapack-lib],
 	  AS_HELP_STRING([--with-plapack-lib = lib],[plapack library]),
 	  [PLAPACK_LIB=$withval],[PLAPACK_LIB=""])
-	AC_MSG_CHECKING(for Plapack libraries)
 	
 	AC_ARG_WITH([plapack-include],
@@ -834,5 +817,4 @@
 							 [plapack include ]),
 			  [PLAPACK_INCLUDE=$withval],[PLAPACK_INCLUDE=""])
-	AC_MSG_CHECKING(for Plapack headers)
 	  
 	if test -n "$PLAPACK_LIB"; then
@@ -857,8 +839,8 @@
 	dnl mumps{{{
 	AC_ARG_WITH([mumps-dir],
-	  AS_HELP_STRING([--with-mumps-dir = DIR],[mumps root directory]),
+	  AS_HELP_STRING([--with-mumps-dir=DIR],[mumps root directory]),
 	  [MUMPS_ROOT=$withval],[MUMPS_ROOT=""])
 			  
-	AC_MSG_CHECKING(for Mumps headers and libraries in $MUMPS_ROOT)
+	AC_MSG_CHECKING(for mumps headers and libraries in $MUMPS_ROOT)
 	if test -d "$MUMPS_ROOT"; then
 
@@ -882,8 +864,8 @@
 	dnl blacs{{{
 	AC_ARG_WITH([blacs-dir],
-		AS_HELP_STRING([--with-blacs-dir = DIR],[blacs root directory]),
+		AS_HELP_STRING([--with-blacs-dir=DIR],[blacs root directory]),
 			  [BLACS_ROOT=$withval],[BLACS_ROOT=""])
 			  
-	AC_MSG_CHECKING(for Blacs headers and libraries in $BLACS_ROOT)
+	AC_MSG_CHECKING(for blacs headers and libraries in $BLACS_ROOT)
 	if test -d "$BLACS_ROOT"; then
 
@@ -903,8 +885,8 @@
 	dnl hypre{{{
 	AC_ARG_WITH([hypre-dir],
-	  AS_HELP_STRING([--with-hypre-dir = DIR],[hypre root directory]),
+	  AS_HELP_STRING([--with-hypre-dir=DIR],[hypre root directory]),
 			  [HYPRE_ROOT=$withval],[HYPRE_ROOT=""])
 			  
-	AC_MSG_CHECKING(for Hypre headers and libraries in $HYPRE_ROOT)
+	AC_MSG_CHECKING(for hypre headers and libraries in $HYPRE_ROOT)
 	if test -d "$HYPRE_ROOT"; then
 
@@ -924,8 +906,8 @@
 	dnl ml{{{
 	AC_ARG_WITH([ml-dir],
-	  AS_HELP_STRING([--with-ml-dir = DIR],[ml root directory]),
+	  AS_HELP_STRING([--with-ml-dir=DIR],[ml root directory]),
 			  [ML_ROOT=$withval],[ML_ROOT=""])
 			  
-	AC_MSG_CHECKING(for Ml headers and libraries in $ML_ROOT)
+	AC_MSG_CHECKING(for ml headers and libraries in $ML_ROOT)
 	if test -d "$ML_ROOT"; then
 
@@ -1229,5 +1211,5 @@
 	AC_MSG_CHECKING(consistency between all libraries)
 	
-	dnl check that if petsc is requested in parallel, mpi should be specified
+	dnl check that if petsc is requested , mpi should be specified
 	if test "$HAVE_PETSC" = "yes" ; then
 		if test "$HAVE_MPI" = "NO";  then
@@ -1236,15 +1218,22 @@
 	fi
 
-	dnl check that we have either python or matlab support if we only compile serially
-	if test "$PARALLEL_VALUE" = "no"  && test "$HAVE_MATLAB" = "no" && test "$HAVE_PYTHON" = "no"; then
-		AC_MSG_ERROR([need at least python or matlab support to compile only in serial mode!]);
-	fi
-
-	dnl check that we don't have with-matlab and with-python at the same time
-	if test "$HAVE_PYTHON" = "yes" ; then
-		if test "$HAVE_MATLAB" = "yes";  then
-			AC_MSG_ERROR([cannot create matlab and python wrappers simultaneously! Please choose one or the other.]);
-		fi
-	fi
+	dnl check that we have either python or matlab support if we compile the modules
+	if test "$MODULES_VALUE" = "yes"  && test "$HAVE_MATLAB" = "no" && test "$HAVE_PYTHON" = "no"; then
+		AC_MSG_ERROR([need at least python or matlab support to compile modules (or use --with-modules=no)]);
+	fi
+
+	dnl check that we have python version if python compile is specified
+	if test "$HAVE_PYTHON" = "yes"  && test "$PYTHONVERSION" = "" ; then
+	AC_MSG_ERROR([need python-version if python compile is required!]);
+	fi
+
+	dnl check that if we have MPI, we have metis
+	if test "$HAVE_METIS" = "yes"  && test "$HAVE_MPI" = "no" ; then
+	AC_MSG_ERROR([need mpi if using the metis partitioner!]);
+	fi
+
+
+
+
 
 	AC_MSG_RESULT(done)
@@ -1257,5 +1246,5 @@
 	  AS_HELP_STRING([--with-cxxoptflags = CXXOPTFLAGS], [optimization using CXX flags, ex: --with-cxxoptflags=-march=opteron -O3]),
 	  [CXXOPTFLAGS=$withval],[CXXOPTFLAGS="-g -O2"]) 
-	AC_MSG_CHECKING(for C++ optimization flags)
+	AC_MSG_CHECKING(for c++ optimization flags)
 	AC_SUBST([CXXOPTFLAGS])
 	AC_MSG_RESULT(done)
Index: /issm/branches/trunk-jpl-damage/scripts/GenerateReferences.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/scripts/GenerateReferences.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/scripts/GenerateReferences.sh	(revision 12168)
@@ -16,5 +16,5 @@
 \begin{document}
 \nocite{$CITE}
-\bibliography{$ISSM_DIR/publications/bibtex/references}
+\bibliography{$JPL_SVN/publications/bibtex/references}
 \end{document}
 END
@@ -29,5 +29,5 @@
 mv references.bak2 references.bbl
 echo "Converting to rtf"
-$ISSM_TIER/externalpackages/latex2rtf/install/latex2rtf -P $ISSM_TIER/externalpackages/latex2rtf/install/cfg/ references
+$ISSM_DIR/externalpackages/latex2rtf/install/latex2rtf -P $ISSM_DIR/externalpackages/latex2rtf/install/cfg/ references
 
 #Remove all but rtf file
Index: /issm/branches/trunk-jpl-damage/scripts/archive.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/scripts/archive.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/scripts/archive.sh	(revision 12168)
@@ -10,5 +10,5 @@
 
 #Cleanup code 
-cd $ISSM_TIER
+cd $ISSM_DIR
 make clean
 make distclean
@@ -18,5 +18,5 @@
 
 #Create tar file, with today's date in the title;
-cd $ISSM_TIER/..
+cd $ISSM_DIR/..
 today=`today_date`
-tar zcvf issm-3.0-$today.tar.gz  `basename $ISSM_TIER`
+tar zcvf issm-3.0-$today.tar.gz  `basename $ISSM_DIR`
Index: /issm/branches/trunk-jpl-damage/scripts/automakererun.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/scripts/automakererun.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/scripts/automakererun.sh	(revision 12168)
@@ -4,8 +4,8 @@
 
 
- ACLOCAL="$ISSM_TIER/externalpackages/automake/install/bin/aclocal"
-AUTOCONF="$ISSM_TIER/externalpackages/autoconf/install/bin/autoconf"
-AUTOHEAD="$ISSM_TIER/externalpackages/autoconf/install/bin/autoheader"
-AUTOMAKE="$ISSM_TIER/externalpackages/automake/install/bin/automake"
+ ACLOCAL="$ISSM_DIR/externalpackages/automake/install/bin/aclocal"
+AUTOCONF="$ISSM_DIR/externalpackages/autoconf/install/bin/autoconf"
+AUTOHEAD="$ISSM_DIR/externalpackages/autoconf/install/bin/autoheader"
+AUTOMAKE="$ISSM_DIR/externalpackages/automake/install/bin/automake"
 
 echo "removing config.cach"
Index: /issm/branches/trunk-jpl-damage/scripts/cloc2html.py
===================================================================
--- /issm/branches/trunk-jpl-damage/scripts/cloc2html.py	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/scripts/cloc2html.py	(revision 12168)
@@ -4,6 +4,6 @@
 import sys, re, os
 
-ISSM_TIER=os.getenv('ISSM_TIER');
-if(not ISSM_TIER): raise NameError('ISSM_TIER undefined')
+ISSM_DIR=os.getenv('ISSM_DIR');
+if(not ISSM_DIR): raise NameError('ISSM_DIR undefined')
 
 infile  = open('temp','r')
Index: /issm/branches/trunk-jpl-damage/scripts/convertmatlabclasses.py
===================================================================
--- /issm/branches/trunk-jpl-damage/scripts/convertmatlabclasses.py	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/scripts/convertmatlabclasses.py	(revision 12168)
@@ -4,8 +4,8 @@
 
 #get names of all directories to process
-ISSM_TIER=os.getenv('ISSM_TIER');
-if(not ISSM_TIER): raise NameError('ISSM_TIER undefined')
-newclassesdir = ISSM_TIER + '/src/m/classes/'
-oldclassesdir = ISSM_TIER + '/src/m/oldclasses/'
+ISSM_DIR=os.getenv('ISSM_DIR');
+if(not ISSM_DIR): raise NameError('ISSM_DIR undefined')
+newclassesdir = ISSM_DIR + '/src/m/classes/'
+oldclassesdir = ISSM_DIR + '/src/m/oldclasses/'
 
 #make new directory
Index: /issm/branches/trunk-jpl-damage/scripts/dailyrun.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/scripts/dailyrun.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/scripts/dailyrun.sh	(revision 12168)
@@ -54,15 +54,15 @@
 #Prepare run
 #Windows hack for startup.m {{{1
-#windows environments: ISSM_TIER_WIN variable not correctly picked up when using 
-#the cron job. just get startup to take the ISSM_TIER variable as the pwd:
+#windows environments: ISSM_DIR_WIN variable not correctly picked up when using 
+#the cron job. just get startup to take the ISSM_DIR variable as the pwd:
 if [ "$OS" = "winxp32" ]
 then
-	cat startup.m | sed 's/clear status/clear status; ISSM_TIER=pwd;/g' > startup.m.bak
+	cat startup.m | sed 's/clear status/clear status; ISSM_DIR=pwd;/g' > startup.m.bak
 	mv startup.m.bak startup.m
 fi
 #}}}
 #create softlink to startup {{{1
-cd $ISSM_TIER/test/NightlyRun/
-ln -s $ISSM_TIER/startup.m .
+cd $ISSM_DIR/test/NightlyRun/
+ln -s $ISSM_DIR/startup.m .
 #}}}
 #Create dailylog directory and info.log {{{1
@@ -70,7 +70,7 @@
 INSTALL_TIME=$(timer)
 ELAPSED_INSTALL=$(timer $START_TIME)
-rm -rf $ISSM_TIER/dailylog
-mkdir  $ISSM_TIER/dailylog
-cat << END > $ISSM_TIER/dailylog/info.log
+rm -rf $ISSM_DIR/dailylog
+mkdir  $ISSM_DIR/dailylog
+cat << END > $ISSM_DIR/dailylog/info.log
 today:     $(echo $TODAY)
 user:      $(echo $USER)
@@ -95,8 +95,8 @@
 do
 	#Launch matlab and the daily run script
-	cat > $ISSM_TIER/dailylog/matlab_run$i.m << EOF
+	cat > $ISSM_DIR/dailylog/matlab_run$i.m << EOF
 	warning off %necessary to avoid a info.log of several Go for parallel runs
 	try,
-	cd $ISSM_TIER/test/NightlyRun
+	cd $ISSM_DIR/test/NightlyRun
 	startup;
 	$(if [ "$NROPTIONS" = ""  ]
@@ -111,5 +111,5 @@
 		directory=strsplit(pwd,'/');
 		message=getReport(me)
-		fid=fopen([ISSM_TIER '/dailylog/matlaberror.log'], 'at');
+		fid=fopen([ISSM_DIR '/dailylog/matlaberror.log'], 'at');
 		fprintf(fid,'\nMatlab error occured in: %s\n\n',directory{end});
 		fprintf(fid,'%s',message);
@@ -121,5 +121,5 @@
 
 	#Start run from dailylog directory
-	cd $ISSM_TIER/dailylog/
+	cd $ISSM_DIR/dailylog/
 
 	#Start test
@@ -132,5 +132,5 @@
 #}}}
 #concatenate all reports {{{1
-cd $ISSM_TIER/dailylog/
+cd $ISSM_DIR/dailylog/
 mv matlab_log1.log  matlab_log.log
 for (( i=2;i<=$NUMCPUS_RUN;i++ ))
@@ -149,5 +149,5 @@
 ELAPSED_RUN=$(timer $INSTALL_TIME)
 ELAPSED_TOTAL=$(timer $START_TIME)
-cat << END >>  $ISSM_TIER/dailylog/info.log
+cat << END >>  $ISSM_DIR/dailylog/info.log
 elapsed_run:   $(echo $ELAPSED_RUN)
 elapsed_total: $(echo $ELAPSED_TOTAL)
@@ -158,7 +158,7 @@
 #Send Report
 #Build html report {{{1
-cd $ISSM_TIER/dailylog/
+cd $ISSM_DIR/dailylog/
 sh ../scripts/report.sh
-ln -s $ISSM_TIER/dailylog/report.html $INIT_PATH
-echo "html report located in $ISSM_TIER/dailylog/report.html and $INIT_PATH/report.html"
+ln -s $ISSM_DIR/dailylog/report.html $INIT_PATH
+echo "html report located in $ISSM_DIR/dailylog/report.html and $INIT_PATH/report.html"
 #}}}
Index: /issm/branches/trunk-jpl-damage/scripts/getloc.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/scripts/getloc.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/scripts/getloc.sh	(revision 12168)
@@ -1,12 +1,12 @@
 #!/bin/bash
 #get number of lines of code
-cloc-1.55.pl $ISSM_TIER/src $ISSM_TIER/m4 --exclude-dir=.svn --exclude-ext=exp --exclude-lang=make --out=temp
+cloc-1.55.pl $ISSM_DIR/src $ISSM_DIR/m4 --exclude-dir=.svn --exclude-ext=exp --exclude-lang=make --out=temp
 cat temp
 ./cloc2html.py
 rm temp
 
-cat $ISSM_TIER/src/dox/issm.dox | sed '/<table/,//d' > input1
-cat $ISSM_TIER/src/dox/issm.dox | sed '1,/<\/table>/d' > input2
-cat input1 temp.html input2 > $ISSM_TIER/src/dox/issm.dox
+cat $ISSM_DIR/src/dox/issm.dox | sed '/<table/,//d' > input1
+cat $ISSM_DIR/src/dox/issm.dox | sed '1,/<\/table>/d' > input2
+cat input1 temp.html input2 > $ISSM_DIR/src/dox/issm.dox
 rm input1 input2 temp.html
 
@@ -19,10 +19,10 @@
 #OLDER MANUAL VESION
 #get Matlab number of lines
-cd $ISSM_TIER/src/m
+cd $ISSM_DIR/src/m
 M_LOC=$(find . -name "*.m" -exec wc -l '{}' \; | awk '{ sum += $1 } END { print sum}');
 echo "Matlab code: $M_LOC"
 
 #get C/CPP number of lines
-cd $ISSM_TIER/src
+cd $ISSM_DIR/src
 CPP_LOC=$(find . -name "*.cpp" -exec wc -l '{}' \; | awk '{ sum += $1 } END { print sum}');
 echo "C++    code: $CPP_LOC"
Index: /issm/branches/trunk-jpl-damage/scripts/issmconfiguration.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/scripts/issmconfiguration.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/scripts/issmconfiguration.sh	(revision 12168)
@@ -7,6 +7,6 @@
 presendir=`pwd`
 
-if test -d "$ISSM_TIER/configs" ; then
-	cd $ISSM_TIER/configs
+if test -d "$ISSM_DIR/configs" ; then
+	cd $ISSM_DIR/configs
 	LIST=`ls`
 	
@@ -40,5 +40,5 @@
 	echo ""
 
-	cd $ISSM_TIER 
+	cd $ISSM_DIR 
 	source ./scripts/automakererun.sh 
 	source configs/$configurename
@@ -56,3 +56,3 @@
 
 
-#alias aut='a=`pwd` && cd $ISSM_TIER && ./scripts/automakererun.sh && ./configs/config-macosx64-larour-nopetsc.sh'
+#alias aut='a=`pwd` && cd $ISSM_DIR && ./scripts/automakererun.sh && ./configs/config-macosx64-larour-nopetsc.sh'
Index: /issm/branches/trunk-jpl-damage/scripts/mail
===================================================================
--- /issm/branches/trunk-jpl-damage/scripts/mail	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/scripts/mail	(revision 12168)
@@ -0,0 +1,158 @@
+#!/bin/sh
+
+# This is a shell script to emulate the standard mail(1) aka mailx(1)
+# aka Mail(1) tool usage for sending emails. This shell script is not
+# a client for checking or reading mail. Also, this version of mail
+# does not touch any mail boxes.
+
+# Copyright (c) 2003 by Jeremy C. Reed
+# This software is provided "as is" without any warranties. You may
+# redistribute and use this source, with or without modification,
+# as long as you include this copyright and disclaimer.
+
+# To do: some switches to consider:
+# -v  display details of delivery
+# -E  do not send empty messages
+# -c  send carbon copies to users
+# -b  send blind carbon copies
+
+# todo: test if read can read in long enough lines
+# some shells may have limit of 256 characters per read?
+ 
+SENDMAIL=sendmail  # set to path of your sendmail(8) command
+SENDMAIL_ARGS="-t -i" # -i is so dot doesn't terminate message
+                      # -t is to get recipients from headers
+
+unset subject
+unset to_addr
+dontsendempty=0
+
+about ()
+{
+  echo "This is mailx.sh version 0.03. This is simple, shell script"
+  echo "to implement mailx(1) functionality for sending mail. It does"
+  echo "not provide an interface for checking or reading email messages."
+  echo
+
+  # maybe do this without forking a command
+  mailname=$( basename $0 )
+
+  if [ -n "$1" ] ; then
+    echo "$mailname: $1" 1>&2
+  fi
+
+  echo "Usage: $mailname [-s subject] to-addr ..." 1>&2
+
+  if [ -n "$1" ] ; then
+    if [ -n "$2" ] ; then 
+      exit $2
+    fi
+    exit 100
+  fi
+
+  exit 0
+}
+
+if [ $# -eq 0 ] ; then
+  about "Sorry, this is not a mail reader." 1
+fi
+
+while [ -n "$1" ] ; do
+  case "$1" in
+  -*)
+      if [ "$1" = "-s" ] ; then
+        if [ -z "$2" ] ; then
+          about "The \"-s\" option requires an argument." 4
+        fi
+        subject="$2"
+        shift
+      elif [ "$1" = "-u" -o "$1" = "-f" ] ; then
+        about "Sorry, this is not a mail reader." 2
+#      elif [ "$1" = "-E" ] ; then
+# this probably needs to have entire message saved to temp file first
+#        dontsendempty=1
+      else
+#        about "unknown option -- $1" 3
+        about "Switch \"$1\" is not implemented." 3
+      fi
+      ;;
+  *)  if [ -n "$to_addr" ] ; then
+        to_addr="${to_addr}, $1"
+      else
+        to_addr="$1"
+      fi
+      ;;
+  esac
+  shift
+done
+
+
+if [ -t 0 ] ; then   # no piped in standard input
+  if [ -z "$subject" ] ; then
+    echo -n "Subject: "
+    OLD_IFS=$IFS
+    IFS=""
+    read -r subject
+    IFS=$OLD_IFS
+  fi
+fi
+
+if [ -z "$to_addr" ] ; then
+  about "No recipients specified." 6
+#  about "You must specify recipients." 6
+fi
+
+# generate SMTP headers
+
+# mail(1) doesn't seem to set date
+#date +"Date: %a, %e %b %G %T %z"
+## maybe pipe though sed to get rid of extra space
+## before single digit day of month?
+
+{
+# if [ -n "$to_addr" ] ; then
+echo "To: ${to_addr}"
+# fi
+
+if [ -n "$subject" ] ; then
+  echo "Subject: $subject"
+fi
+
+# end of headers
+echo ""
+
+# output
+line_count=0
+OLD_IFS=$IFS
+IFS=""
+while read -r line ; do
+  # finish if manual, non-piped input is a period on a line by itself
+  if [ "$line" = "." -a -t 0 ] ; then
+      break
+  fi
+  echo "$line"
+  line_count=$(( line_count + 1 ))
+done
+
+IFS=$OLD_IFS
+
+if [ -t 0 ] ; then   # no piped in standard input
+  echo "EOT" 1>&2
+fi
+
+# later add switch to not send mail by exiting
+if [ "$line_count" -eq 0 ] ; then
+#  if [ "$dontsendempty" -eq 1 ] ; then
+# todo this, have it save to temp file and then send to sendmail as needed
+#    # No message, so just exit cleanly
+#    exit 0
+#  fi
+  if [ -z "$subject" ] ; then
+    echo "No message, no subject; hope that's ok" 1>&2
+  else
+    echo "Null message body; hope that's ok" 1>&2
+  fi
+fi
+
+} | $SENDMAIL $SENDMAIL_ARGS
+
Index: /issm/branches/trunk-jpl-damage/scripts/report.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/scripts/report.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/scripts/report.sh	(revision 12168)
@@ -49,5 +49,5 @@
 
 #create some variables
-if [ $(ls -1 $ISSM_TIER/bin | wc -l) -le 20 ];
+if [ $(ls -1 $ISSM_DIR/bin | wc -l) -le 20 ];
 then
 	IS_INSTALL=0
Index: /issm/branches/trunk-jpl-damage/scripts/run.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/scripts/run.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/scripts/run.sh	(revision 12168)
@@ -6,6 +6,6 @@
 MATLAB_VERSION="7.6" #7.2,7.4,7.6 and 7.8
 #create softlink to startup {{{1
-cd $ISSM_TIER/test/NightlyRun/
-ln -s $ISSM_TIER/startup.m .
+cd $ISSM_DIR/test/NightlyRun/
+ln -s $ISSM_DIR/startup.m .
 #}}}
 
@@ -14,8 +14,8 @@
 do
 	#Launch matlab and the daily run script
-	cat > $ISSM_TIER/dailylog/matlab_run$i.m << EOF
+	cat > $ISSM_DIR/dailylog/matlab_run$i.m << EOF
 	warning off %necessary to avoid a daily.log of several Go for parallel runs
 	try,
-		cd $ISSM_TIER/test/NightlyRun
+		cd $ISSM_DIR/test/NightlyRun
 		startup;
 		$(if [ "$NROPTIONS" = ""  ]
@@ -30,5 +30,5 @@
 		directory=strsplit(pwd,'/');
 		message=getReport(me)
-		fid=fopen([ISSM_TIER '/dailylog/matlaberror.log'], 'at');
+		fid=fopen([ISSM_DIR '/dailylog/matlaberror.log'], 'at');
 		fprintf(fid,'\nMatlab error occured in: %s\n\n',directory{end});
 		fprintf(fid,'%s',message);
@@ -39,5 +39,5 @@
 
 	#Start run from dailylog directory
-	cd $ISSM_TIER/dailylog/
+	cd $ISSM_DIR/dailylog/
 
 	#Start test
Index: /issm/branches/trunk-jpl-damage/scripts/windowsbuild.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/scripts/windowsbuild.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/scripts/windowsbuild.sh	(revision 12168)
@@ -11,5 +11,5 @@
 today=`today_date`
 
-cd $ISSM_TIER/bin
+cd $ISSM_DIR/bin
 
 #Filter out .svn files
Index: /issm/branches/trunk-jpl-damage/src/Makefile.am
===================================================================
--- /issm/branches/trunk-jpl-damage/src/Makefile.am	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/Makefile.am	(revision 12168)
@@ -1,2 +1,2 @@
-EXTRA_DIST =  perl  pro
-SUBDIRS = c mex m
+EXTRA_DIST =  perl  pro 
+SUBDIRS = c modules m  py
Index: /issm/branches/trunk-jpl-damage/src/c/Container/Constraints.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/Container/Constraints.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/Container/Constraints.cpp	(revision 12168)
@@ -48,10 +48,11 @@
 
 	/*figure out total number of constraints combining all the cpus (no clones here)*/
-	#ifdef _PARALLEL_
-	MPI_Reduce(&localconstraints,&numberofconstraints,1,MPI_INT,MPI_SUM,0,MPI_COMM_WORLD );
-	MPI_Bcast(&numberofconstraints,1,MPI_INT,0,MPI_COMM_WORLD);
+	#ifdef _HAVE_MPI_
+		MPI_Reduce(&localconstraints,&numberofconstraints,1,MPI_INT,MPI_SUM,0,MPI_COMM_WORLD );
+		MPI_Bcast(&numberofconstraints,1,MPI_INT,0,MPI_COMM_WORLD);
 	#else
-	numberofconstraints=localconstraints;
+		numberofconstraints=localconstraints;
 	#endif
+	
 
 	return numberofconstraints;
Index: /issm/branches/trunk-jpl-damage/src/c/Container/DataSet.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/Container/DataSet.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/Container/DataSet.cpp	(revision 12168)
@@ -84,329 +84,4 @@
 /*}}}*/
 
-/*I/O*/
-#ifdef _SERIAL_
-/*FUNCTION DataSet::Marshall{{{1*/
-char* DataSet::Marshall(){
-
-	vector<Object*>::iterator object;
-	int                       object_size;
-	int                       marshalled_dataset_size=0;
-	char*                     marshalled_dataset=NULL;
-	char*                     old_marshalled_dataset=NULL;
-
-	/*First get size of marshalled dataset: */
-	object_size=(int)objects.size();
-
-	marshalled_dataset_size=MarshallSize();
-	
-	/*Allocate marshalled dataset: */
-	marshalled_dataset=(char*)xmalloc(marshalled_dataset_size*sizeof(char)); 
-
-	/*Keep track of old_marshalled_dataset: */
-	old_marshalled_dataset=marshalled_dataset;
-
-	/*Store internals of dataset first: */
-	memcpy(marshalled_dataset,&object_size,sizeof(int)); marshalled_dataset+=sizeof(int);
-	memcpy(marshalled_dataset,&sorted,sizeof(int)); marshalled_dataset+=sizeof(int);
-	if(sorted){
-		if(object_size)memcpy(marshalled_dataset,sorted_ids,object_size*sizeof(int)); marshalled_dataset+=object_size*sizeof(int);
-		if(object_size)memcpy(marshalled_dataset,id_offsets,object_size*sizeof(int)); marshalled_dataset+=object_size*sizeof(int);
-	}
-
-	for ( object=objects.begin() ; object < objects.end(); object++ ){
-		(*object)->Marshall(&marshalled_dataset);
-	}
-
-	/* Ok, marshalled_dataset now points to the end of the original marshalled_dataset pointer 
-	 * before  we started the loop on objects. Get object to point right again: */
-	marshalled_dataset-=marshalled_dataset_size;
-
-	/*We should be back to old_marshalled_dataset: check and abort if that's not the case, 
-	 * because this is a nasty error: */
-	if (marshalled_dataset!=old_marshalled_dataset){
-		_error_("final marshalled dataset \"%s\" is different from initial one!",EnumToStringx(enum_type)); 
-		abort();
-	}
-
-	/*Return: */
-	return marshalled_dataset;
-}
-/*}}}*/
-/*FUNCTION DataSet::MarshallSize{{{1*/
-int DataSet::MarshallSize(){
-
-	vector<Object*>::iterator object;
-	int                      marshalled_dataset_size=0;
-
-
-	for ( object=objects.begin() ; object < objects.end(); object++ ){
-		marshalled_dataset_size+= (*object)->MarshallSize();
-	}
-
-	marshalled_dataset_size+=sizeof(int); //objects size
-	marshalled_dataset_size+=sizeof(int); //sorted size
-	if(sorted){
-		marshalled_dataset_size+=(int)objects.size()*sizeof(int); //sorted ids
-		marshalled_dataset_size+=(int)objects.size()*sizeof(int); //id offsets
-	}
-
-	return marshalled_dataset_size;
-}
-/*}}}*/
-/*FUNCTION DataSet::Demarshall{{{1*/
-DataSet* DataSetDemarshall(char* marshalled_dataset){
-
-	return DataSetDemarshallRaw(&marshalled_dataset);
-
-}
-/*}}}*/
-/*FUNCTION DataSet::DemarshallRaw{{{1*/
-DataSet* DataSetDemarshallRaw(char** pmarshalled_dataset){
-
-	int i;
-
-	DataSet* dataset=NULL;
-	int      numobjects=0;
-	int      enum_type;
-	Object*  object=NULL;
-	int      sorted;
-	int*     sorted_ids=NULL;
-	int*     id_offsets=NULL;
-	char*    marshalled_dataset=NULL;
-
-	/*recover marshalled_dataset pointer: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*initialize dataset: */
-	dataset=new DataSet();
-
-	/*Get internals first: */
-	memcpy(&numobjects,marshalled_dataset,sizeof(int)); marshalled_dataset+=sizeof(int);
-	memcpy(&sorted,marshalled_dataset,sizeof(int)); marshalled_dataset+=sizeof(int);
-	if(sorted){
-		if(numobjects){
-			sorted_ids=(int*)xmalloc(numobjects*sizeof(int));
-			id_offsets=(int*)xmalloc(numobjects*sizeof(int));
-			memcpy(sorted_ids,marshalled_dataset,numobjects*sizeof(int)); marshalled_dataset+=numobjects*sizeof(int);
-			memcpy(id_offsets,marshalled_dataset,numobjects*sizeof(int)); marshalled_dataset+=numobjects*sizeof(int);
-		}
-		dataset->SetSorting(sorted_ids,id_offsets);
-	}
-
-	for(i=0;i<numobjects;i++){
-
-		/*get enum type of object: */
-		memcpy(&enum_type,marshalled_dataset,sizeof(int)); marshalled_dataset+=sizeof(int);
-
-		switch(enum_type){
-			case NodeEnum:{
-				Node* node=NULL;
-				node=new Node();
-				node->Demarshall(&marshalled_dataset);
-				dataset->AddObject(node);}
-				break;
-			case VertexEnum:{
-				Vertex* vertex=NULL;
-				vertex=new Vertex();
-				vertex->Demarshall(&marshalled_dataset);
-				dataset->AddObject(vertex);}
-				break;
-			case DoubleParamEnum:{
-				DoubleParam* doubleparam=NULL;
-				doubleparam=new DoubleParam();
-				doubleparam->Demarshall(&marshalled_dataset);
-				dataset->AddObject(doubleparam);}
-				break;
-			case TriaEnum:{
-				Tria* tria=NULL;
-				tria=new Tria();
-				tria->Demarshall(&marshalled_dataset);
-				dataset->AddObject(tria);}
-				break;
-			case TriaP1InputEnum:{
-				TriaP1Input* triavertexinput=NULL;
-				triavertexinput=new TriaP1Input();
-				triavertexinput->Demarshall(&marshalled_dataset);
-				dataset->AddObject(triavertexinput);}
-				break;
-			#ifdef _HAVE_3D_
-			case PentaP1InputEnum:{
-				PentaP1Input* pentavertexinput=NULL;
-				pentavertexinput=new PentaP1Input();
-				pentavertexinput->Demarshall(&marshalled_dataset);
-				dataset->AddObject(pentavertexinput);}
-				break;
-			#endif
-			case TransientInputEnum:{
-				TransientInput* transientinput=NULL;
-				transientinput=new TransientInput();
-				transientinput->Demarshall(&marshalled_dataset);
-				dataset->AddObject(transientinput);}
-				break;
-			#ifdef _HAVE_CONTROL_
-			case ControlInputEnum:{
-			   ControlInput* controlinputinput=NULL;
-				controlinputinput=new ControlInput();
-				controlinputinput->Demarshall(&marshalled_dataset);
-				dataset->AddObject(controlinputinput);}
-				break;
-			#endif
-			case DatasetInputEnum:{
-				DatasetInput* datasetinputinput=NULL;
-				datasetinputinput=new DatasetInput();
-				datasetinputinput->Demarshall(&marshalled_dataset);
-				dataset->AddObject(datasetinputinput);}
-				break;
-			case TriaP1ElementResultEnum:{
-				TriaP1ElementResult* triavertexelementresult=NULL;
-				triavertexelementresult=new TriaP1ElementResult();
-				triavertexelementresult->Demarshall(&marshalled_dataset);
-				dataset->AddObject(triavertexelementresult);}
-				break;
-			 #ifdef _HAVE_3D_
-			case PentaP1ElementResultEnum:{
-				PentaP1ElementResult* pentavertexelementresult=NULL;
-				pentavertexelementresult=new PentaP1ElementResult();
-				pentavertexelementresult->Demarshall(&marshalled_dataset);
-				dataset->AddObject(pentavertexelementresult);}
-				break;
-			case PentaEnum:{
-				Penta* penta=NULL;
-				penta=new Penta();
-				penta->Demarshall(&marshalled_dataset);
-				dataset->AddObject(penta);}
-				break;
-			#endif
-			case MaticeEnum:{
-				Matice* matice=NULL;
-				matice=new Matice();
-				matice->Demarshall(&marshalled_dataset);
-				dataset->AddObject(matice);}
-				break;
-			case MatparEnum:{
-				Matpar* matpar=NULL;
-				matpar=new Matpar();
-				matpar->Demarshall(&marshalled_dataset);
-				dataset->AddObject(matpar);}
-				break;
-			case SpcStaticEnum:{
-				SpcStatic* spcstatic=NULL;
-				spcstatic=new SpcStatic();
-				spcstatic->Demarshall(&marshalled_dataset);
-				dataset->AddObject(spcstatic);}
-				break;
-			case SpcDynamicEnum:{
-				SpcDynamic* spcdynamic=NULL;
-				spcdynamic=new SpcDynamic();
-				spcdynamic->Demarshall(&marshalled_dataset);
-				dataset->AddObject(spcdynamic);}
-				break;
-			case SpcTransientEnum:{
-				SpcTransient* spctransient=NULL;
-				spctransient=new SpcTransient();
-				spctransient->Demarshall(&marshalled_dataset);
-				dataset->AddObject(spctransient);}
-				break;
-			case PengridEnum:{
-				Pengrid* pengrid=NULL;
-				pengrid=new Pengrid();
-				pengrid->Demarshall(&marshalled_dataset);
-				dataset->AddObject(pengrid);}
-				break;
-			case PenpairEnum:{
-				Penpair* penpair=NULL;
-				penpair=new Penpair();
-				penpair->Demarshall(&marshalled_dataset);
-				dataset->AddObject(penpair);}
-				break;
-			case IcefrontEnum:{
-				Icefront* icefront=NULL;
-				icefront=new Icefront();
-				icefront->Demarshall(&marshalled_dataset);
-				dataset->AddObject(icefront);}
-				break;
-			case NumericalfluxEnum:{
-				Numericalflux* numericalflux=NULL;
-				numericalflux=new Numericalflux();
-				numericalflux->Demarshall(&marshalled_dataset);
-				dataset->AddObject(numericalflux);}
-				break;
-			#ifdef _HAVE_RIFTS_
-			case RiftfrontEnum:{
-				Riftfront* riftfront=NULL;
-				riftfront=new Riftfront();
-				riftfront->Demarshall(&marshalled_dataset);
-				dataset->AddObject(riftfront);}
-				break;
-			#endif
-			case DoubleInputEnum:{
-				DoubleInput* doubleinput=NULL;
-				doubleinput=new DoubleInput();
-				doubleinput->Demarshall(&marshalled_dataset);
-				dataset->AddObject(doubleinput);}
-				break;
-			case IntInputEnum:{
-				IntInput* intinput=NULL;
-				intinput=new IntInput();
-				intinput->Demarshall(&marshalled_dataset);
-				dataset->AddObject(intinput);}
-				break;
-			case BoolInputEnum:{
-				BoolInput* boolinput=NULL;
-				boolinput=new BoolInput();
-				boolinput->Demarshall(&marshalled_dataset);
-				dataset->AddObject(boolinput);}
-				break;
-			case IntParamEnum:{
-				IntParam* intparam=NULL;
-				intparam=new IntParam();
-				intparam->Demarshall(&marshalled_dataset);
-				dataset->AddObject(intparam);}
-				break;
-			case BoolParamEnum:{
-				BoolParam* boolparam=NULL;
-				boolparam=new BoolParam();
-				boolparam->Demarshall(&marshalled_dataset);
-				dataset->AddObject(boolparam);}
-				break;
-			case StringParamEnum:{
-				StringParam* stringparam=NULL;
-				stringparam=new StringParam();
-				stringparam->Demarshall(&marshalled_dataset);
-				dataset->AddObject(stringparam);}
-				break;
-			case DoubleVecExternalResultEnum:{
-				DoubleVecExternalResult* doublevecexternalresult=NULL;
-				doublevecexternalresult=new DoubleVecExternalResult();
-				doublevecexternalresult->Demarshall(&marshalled_dataset);
-				dataset->AddObject(doublevecexternalresult);}
-				break;
-			case DoubleExternalResultEnum:{
-				DoubleExternalResult* doubleexternalresult=NULL;
-				doubleexternalresult=new DoubleExternalResult();
-				doubleexternalresult->Demarshall(&marshalled_dataset);
-				dataset->AddObject(doubleexternalresult);}
-				break;
-			#ifdef _HAVE_GROUNDINGLINE_
-			case BoolElementResultEnum:{
-				BoolElementResult* boolelementresult=NULL;
-				boolelementresult=new BoolElementResult();
-				boolelementresult->Demarshall(&marshalled_dataset);
-				dataset->AddObject(boolelementresult);}
-				break;
-			#endif
-			default:
-				_error_("could not recognize enum type: %s",EnumToStringx(enum_type));
-		}
-	}
-
-	/*Assign output pointers:*/
-	*pmarshalled_dataset=marshalled_dataset;
-	
-	return dataset;
-}
-/*}}}*/
-#endif
-
 /*Specific methods*/
 /*FUNCTION DataSet::AddObject{{{1*/
Index: /issm/branches/trunk-jpl-damage/src/c/Container/DataSet.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/Container/DataSet.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/Container/DataSet.h	(revision 12168)
@@ -49,8 +49,4 @@
 		void  Echo();
 		void  DeepEcho();
-		#ifdef _SERIAL_
-		char* Marshall();
-		int   MarshallSize();
-		#endif
 		int   AddObject(Object* object);
 		int   DeleteObject(int id);
@@ -69,11 +65,3 @@
 };
 
-/*This routine cannot be object oriented, but need for demarshalling: */
-#ifdef _SERIAL_
-DataSet* DataSetDemarshall(char* marshalled_dataset);
-DataSet* DataSetDemarshallRaw(char** pmarshalled_dataset);
 #endif
-	
-
-
-#endif
Index: /issm/branches/trunk-jpl-damage/src/c/Container/Elements.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/Container/Elements.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/Container/Elements.cpp	(revision 12168)
@@ -124,6 +124,6 @@
 	}
 
-	#ifdef _PARALLEL_
 	/*Synchronize across cluster, so as to not end up with different sizes for each patch on each cpu: */
+	#ifdef _HAVE_MPI_
 	MPI_Reduce (&numvertices,&max_numvertices,1,MPI_INT,MPI_MAX,0,MPI_COMM_WORLD );
 	MPI_Bcast(&max_numvertices,1,MPI_INT,0,MPI_COMM_WORLD);
@@ -193,7 +193,11 @@
 
 		/*Get rank of first cpu that has results*/
+		#ifdef _HAVE_MPI_
 		if(this->Size()) rank=my_rank;
 		else rank=num_procs;
 		MPI_Allreduce (&rank,&minrank,1,MPI_INT,MPI_MIN,MPI_COMM_WORLD);
+		#else
+		minrank=my_rank;
+		#endif
 
 		/*see what the first element of this partition has in stock (this is common to all partitions)*/
@@ -203,8 +207,11 @@
 			element->ListResultsInfo(&resultsenums,&resultssizes,&resultstimes,&resultssteps,&numberofresults);
 		}
+		#ifdef _HAVE_MPI_
 		MPI_Bcast(&numberofresults,1,MPI_DOUBLE,minrank,MPI_COMM_WORLD);
+		#endif
 
 		/*Get out if there is no results. Otherwise broadcast info*/
 		if(!numberofresults) return;
+		#ifdef _HAVE_MPI_
 		if(my_rank!=minrank){
 			resultsenums=(int*)xmalloc(numberofresults*sizeof(int));
@@ -217,4 +224,5 @@
 		MPI_Bcast(resultstimes,numberofresults,MPI_DOUBLE,minrank,MPI_COMM_WORLD);
 		MPI_Bcast(resultssteps,numberofresults,MPI_INT,minrank,MPI_COMM_WORLD);
+		#endif
 
 		/*Loop over all results and get nodal vector*/
@@ -250,7 +258,5 @@
 
 		/*Gather onto master cpu 0, if needed: */
-#ifdef _PARALLEL_
 		if(io_gather)patch->Gather();
-#endif
 
 		/*create result object and add to results dataset:*/
@@ -276,9 +282,9 @@
 	int numberofelements;
 
-	#ifdef _PARALLEL_
 	local_nelem=this->Size();
+	#ifdef _HAVE_MPI_
 	MPI_Allreduce ( (void*)&local_nelem,(void*)&numberofelements,1,MPI_INT,MPI_SUM,MPI_COMM_WORLD);
 	#else
-	numberofelements=this->Size();
+	numberofelements=local_nelem;
 	#endif
 
Index: /issm/branches/trunk-jpl-damage/src/c/Container/Loads.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/Container/Loads.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/Container/Loads.cpp	(revision 12168)
@@ -63,5 +63,5 @@
 
 	/*figure out total number of loads combining all the cpus (no clones here)*/
-	#ifdef _PARALLEL_
+	#ifdef _HAVE_MPI_
 	MPI_Reduce(&localloads,&numberofloads,1,MPI_INT,MPI_SUM,0,MPI_COMM_WORLD );
 	MPI_Bcast(&numberofloads,1,MPI_INT,0,MPI_COMM_WORLD);
@@ -69,4 +69,5 @@
 	numberofloads=localloads;
 	#endif
+
 
 	return numberofloads;
Index: /issm/branches/trunk-jpl-damage/src/c/Container/Nodes.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/Container/Nodes.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/Container/Nodes.cpp	(revision 12168)
@@ -83,8 +83,12 @@
 	 * 0. This means the dofs between all the cpus are not unique. We now offset the dofs of eache
 	 * cpus by the total last dofs of the previus cpu, starting from 0.
-	 * First: bet number of dofs for each cpu*/
+	 * First: get number of dofs for each cpu*/
 	alldofcount=(int*)xmalloc(num_procs*sizeof(int));
+	#ifdef _HAVE_MPI_
 	MPI_Gather(&dofcount,1,MPI_INT,alldofcount,1,MPI_INT,0,MPI_COMM_WORLD);
 	MPI_Bcast(alldofcount,num_procs,MPI_INT,0,MPI_COMM_WORLD);
+	#else
+	alldofcount[0]=dofcount;
+	#endif
 
 	/* Every cpu should start its own dof count at the end of the dofcount from cpu-1*/
@@ -119,5 +123,10 @@
 		}
 	}
-	MPI_Allreduce ( (void*)truedofs,(void*)alltruedofs,numnodes*maxdofspernode,MPI_INT,MPI_MAX,MPI_COMM_WORLD);
+
+	#ifdef _HAVE_MPI_
+	MPI_Allreduce((void*)truedofs,(void*)alltruedofs,numnodes*maxdofspernode,MPI_INT,MPI_MAX,MPI_COMM_WORLD);
+	#else
+	for(i=0;i<numnodes*maxdofspernode;i++)alltruedofs[i]=truedofs[i];
+	#endif
 
 	/* Now every cpu knows the true dofs of everyone else that is not a clone*/
@@ -145,5 +154,4 @@
 	int  numnodes;
 
-
 	/*Figure out number of nodes for this analysis: */
 	numnodes=this->NumberOfNodes(analysis_type);
@@ -162,5 +170,9 @@
 	 * dealt with by another cpu. We take the minimum because we are going to manage dof assignment in increasing 
 	 * order of cpu rank. This is also why we initialized this array to num_procs.*/
+	#ifdef _HAVE_MPI_
 	MPI_Allreduce ( (void*)ranks,(void*)minranks,numnodes,MPI_INT,MPI_MIN,MPI_COMM_WORLD);
+	#else
+	for(i=0;i<numnodes;i++)minranks[i]=ranks[i];
+	#endif
 
 	/*Now go through all objects, and use minranks to flag which objects are cloned: */
@@ -204,9 +216,9 @@
 	}
 
-#ifdef _PARALLEL_
 	/*Grab max of all cpus: */
+	#ifdef _HAVE_MPI_
 	MPI_Allreduce ( (void*)&max,(void*)&allmax,1,MPI_INT,MPI_MAX,MPI_COMM_WORLD);
 	max=allmax;
-#endif
+	#endif
 
 	return max;
@@ -239,5 +251,9 @@
 
 	/*Gather from all cpus: */
+	#ifdef _HAVE_MPI_
 	MPI_Allreduce ( (void*)&numdofs,(void*)&allnumdofs,1,MPI_INT,MPI_SUM,MPI_COMM_WORLD);
+	#else
+	allnumdofs=numdofs;
+	#endif
 	return allnumdofs;
 }
@@ -262,5 +278,9 @@
 
 	/*Gather from all cpus: */
+	#ifdef _HAVE_MPI_
 	MPI_Allreduce ( (void*)&numnodes,(void*)&allnumnodes,1,MPI_INT,MPI_SUM,MPI_COMM_WORLD);
+	#else
+	allnumnodes=numnodes;
+	#endif
 
 	return allnumnodes;
@@ -288,9 +308,9 @@
 	}
 
-	#ifdef _PARALLEL_
-		MPI_Reduce (&max_sid,&node_max_sid,1,MPI_INT,MPI_MAX,0,MPI_COMM_WORLD );
-		MPI_Bcast(&node_max_sid,1,MPI_INT,0,MPI_COMM_WORLD);
-		max_sid=node_max_sid;
-	#endif 
+	#ifdef _HAVE_MPI_
+	MPI_Reduce (&max_sid,&node_max_sid,1,MPI_INT,MPI_MAX,0,MPI_COMM_WORLD );
+	MPI_Bcast(&node_max_sid,1,MPI_INT,0,MPI_COMM_WORLD);
+	max_sid=node_max_sid;
+	#endif
 
 	if(max_sid==1){
Index: /issm/branches/trunk-jpl-damage/src/c/Container/Options.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/Container/Options.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/Container/Options.cpp	(revision 12168)
@@ -20,7 +20,5 @@
 #include "../shared/shared.h"
 #include "../EnumDefinitions/EnumDefinitions.h"
-#if _SERIAL_
 #include "../io/io.h"
-#endif
 /*}}}*/
 
@@ -31,30 +29,4 @@
 }
 /*}}}*/
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-/*FUNCTION Options::Options(int istart, int nrhs, const mxArray* prhs[]){{{1*/
-Options::Options(int istart, int nrhs, const mxArray* prhs[]){
-
-	int            i;
-	char          *name    = NULL;
-	Option *option = NULL;
-
-	/*loop over each name and value*/
-	for (i=istart; i<nrhs; i=i+2){
-		if (!mxIsClass(prhs[i],"char")) _error_("Argument %d must be name of option.",i+1);
-
-		FetchData(&name,prhs[i]);
-		if (i+1 == nrhs) _error_("Argument %d must exist and be value of option \"%s\".",i+2,name);
-
-		//_printf_(true,"  Processing option \"%s\" of class \"%s\".\n",name,mxGetClassName(prhs[i+1]));
-		option=(Option*)OptionParse(name,&prhs[i+1]);
-		this->AddOption(option);
-		option=NULL;
-	}
-
-	/*echo the dataset  */
-	//if (this->Size()) for(i=0;i<this->Size();i++) ((Option*)this->GetObjectByOffset(i))->Echo();
-}
-/*}}}*/
-#endif
 /*FUNCTION Options::~Options(){{{1*/
 Options::~Options(){
Index: /issm/branches/trunk-jpl-damage/src/c/Container/Options.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/Container/Options.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/Container/Options.h	(revision 12168)
@@ -15,7 +15,4 @@
 		/*constructors, destructors*/
 		Options();
-		#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-		Options(int istart, int nrhs, const mxArray* prhs[]);
-		#endif
 		~Options();
 
Index: /issm/branches/trunk-jpl-damage/src/c/Container/Results.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/Container/Results.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/Container/Results.cpp	(revision 12168)
@@ -65,88 +65,4 @@
 /*}}}*/
 /*FUNCTION Results::Write{{{1*/
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-void Results::Write(mxArray** pdataref){
-
-	int i,j;
-	int count;
-
-	/*output: */
-	mxArray* dataref=NULL;
-	mxArray* processeddataref=NULL;
-	mwSize nfields;
-	mwSize maxfields;
-	mwSize nsteps;
-	mwSize step;
-	const char **fnames      = NULL;
-	int         *enums       = NULL;
-	int          baseenum;
-	mwSize       onebyone[2] = {1,1};
-	mwSize       ndim        = 2;
-
-	/*How many time steps do we have? : */
-	nsteps=0;
-	for(i=0;i<this->Size();i++){
-		ExternalResult* result=(ExternalResult*)this->GetObjectByOffset(i);
-		step=result->GetStep();
-		if(step>nsteps)nsteps=step;
-	}
-	onebyone[0]=nsteps;
-
-	/*How many field names do we have. First, figure out how many result types we have: */
-	maxfields=(mwSize)this->Size();
-	enums=(int*)xmalloc(maxfields*sizeof(int));
-	for(i=0;i<maxfields;i++){
-		ExternalResult* result=(ExternalResult*)this->GetObjectByOffset(i);
-		enums[i]=result->InstanceEnum();
-	}
-	/*Now, make result types unique: */
-	for(i=0;i<maxfields;i++){
-		if(enums[i]>=0){//if <0, it means this enum was found to replicate another one previously
-			baseenum=enums[i]; 		
-			/*is the baseenum repeated later on?:*/
-			for(j=i+1;j<maxfields;j++){
-				if (enums[j]==baseenum)enums[j]=-1;
-			}
-		}
-		else continue;
-	}
-
-	/*Now, go through enums, and whatever is not null is a non repeated field name: */
-	nfields=0;
-	for(i=0;i<maxfields;i++)if(enums[i]>0)nfields++;
-
-	/*Add 2 fields for time and step: */
-	nfields=nfields+2;
-	
-	/*Fill the names of the structure field: */
-	fnames=(const char**)xmalloc(nfields*sizeof(char*));
-	count=0;
-	for(i=0;i<maxfields;i++){
-		if (enums[i]>0){
-			fnames[count]=EnumToStringx(enums[i]);
-			count++;
-		}
-	}
-	/*don't forget the extra fields "time" and "step":*/
-	fnames[nfields-2]="time";
-	fnames[nfields-1]="step";
-
-	/*Initialize structure: */
-	dataref=mxCreateStructArray( ndim,onebyone,nfields,fnames);
-
-	/*Fill each field: */
-	for(i=0;i<this->Size();i++){ //do not include the last one used for time
-		ExternalResult* result=(ExternalResult*)this->GetObjectByOffset(i);
-		result->SetMatlabField(dataref);
-	}
-
-	/*Now, process the patch in the dataref structure, by calling MatlabProcessPatch.m 
-	 *on the current dataref structure: */
-	mexCallMATLAB(1,&processeddataref,1,&dataref, "MatlabProcessPatch");
-
-	/*Assign output pointers:*/
-	*pdataref=processeddataref;
-}
-#else 
 void Results::Write(Parameters* parameters){
 	
@@ -167,4 +83,3 @@
 
 }
-#endif
 /*}}}*/
Index: /issm/branches/trunk-jpl-damage/src/c/Container/Results.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/Container/Results.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/Container/Results.h	(revision 12168)
@@ -26,9 +26,5 @@
 		/*numerics: {{{1*/
 		Results* SpawnTriaResults(int* indices);
-		#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-		void Write(mxArray** pdataref);
-		#else 
 		void Write(Parameters* parameters);
-		#endif
 		/*}}}*/
 };
Index: /issm/branches/trunk-jpl-damage/src/c/Container/Vertices.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/Container/Vertices.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/Container/Vertices.cpp	(revision 12168)
@@ -61,6 +61,10 @@
 	 * First: bet number of dofs for each cpu*/
 	alldofcount=(int*)xmalloc(num_procs*sizeof(int));
+	#ifdef _HAVE_MPI_
 	MPI_Gather(&dofcount,1,MPI_INT,alldofcount,1,MPI_INT,0,MPI_COMM_WORLD);
 	MPI_Bcast(alldofcount,num_procs,MPI_INT,0,MPI_COMM_WORLD);
+	#else
+	alldofcount[0]=dofcount;
+	#endif
 
 	/* Every cpu should start its own dof count at the end of the dofcount from cpu-1*/
@@ -85,5 +89,9 @@
 		vertex->ShowTrueDofs(truedofs);
 	}
+	#ifdef _HAVE_MPI_
 	MPI_Allreduce((void*)truedofs,(void*)alltruedofs,numberofobjects*numberofdofsperobject,MPI_INT,MPI_MAX,MPI_COMM_WORLD);
+	#else
+	for(i=0;i<numberofobjects*numberofdofsperobject;i++)alltruedofs[i]=truedofs[i];
+	#endif
 
 	/* Now every cpu knows the true dofs of everyone else that is not a clone*/
@@ -121,5 +129,9 @@
 	 * dealt with by another cpu. We take the minimum because we are going to manage dof assignment in increasing 
 	 * order of cpu rank. This is also why we initialized this array to num_procs.*/
+	#ifdef _HAVE_MPI_
 	MPI_Allreduce ( (void*)ranks,(void*)minranks,numberofobjects,MPI_INT,MPI_MIN,MPI_COMM_WORLD);
+	#else
+	for(i=0;i<numberofobjects;i++)minranks[i]=ranks[i];
+	#endif
 
 	/*Now go through all objects, and use minranks to flag which objects are cloned: */
@@ -149,5 +161,5 @@
 	}
 
-	#ifdef _PARALLEL_
+	#ifdef _HAVE_MPI_
 	MPI_Reduce (&max_sid,&vertex_max_sid,1,MPI_INT,MPI_MAX,0,MPI_COMM_WORLD );
 	MPI_Bcast(&vertex_max_sid,1,MPI_INT,0,MPI_COMM_WORLD);
Index: /issm/branches/trunk-jpl-damage/src/c/EnumDefinitions/Synchronize.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/EnumDefinitions/Synchronize.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/EnumDefinitions/Synchronize.sh	(revision 12168)
@@ -6,7 +6,7 @@
 
 #Removed existing files
-rm $ISSM_TIER/src/m/enum/*.m
-rm $ISSM_TIER/src/c/modules/EnumToStringx/EnumToStringx.cpp
-rm $ISSM_TIER/src/c/modules/StringToEnumx/StringToEnumx.cpp
+rm $ISSM_DIR/src/m/enum/*.m
+rm $ISSM_DIR/src/c/modules/EnumToStringx/EnumToStringx.cpp
+rm $ISSM_DIR/src/c/modules/StringToEnumx/StringToEnumx.cpp
 
 #Get number of enums
@@ -15,5 +15,5 @@
 #Build EnumToStringx.cpp {{{1
 #Header
-cat <<END >  $ISSM_TIER/src/c/modules/EnumToStringx/EnumToStringx.cpp
+cat <<END >  $ISSM_DIR/src/c/modules/EnumToStringx/EnumToStringx.cpp
 /*
 * \file EnumToStringx.cpp:
@@ -35,7 +35,7 @@
 END
 #core
-cat temp |  awk '{print "\t\t" "case " $2" : return \"" substr($2,1,length($2)-4) "\";"}' >> $ISSM_TIER/src/c/modules/EnumToStringx/EnumToStringx.cpp
+cat temp |  awk '{print "\t\t" "case " $2" : return \"" substr($2,1,length($2)-4) "\";"}' >> $ISSM_DIR/src/c/modules/EnumToStringx/EnumToStringx.cpp
 #Footer
-cat <<END >> $ISSM_TIER/src/c/modules/EnumToStringx/EnumToStringx.cpp
+cat <<END >> $ISSM_DIR/src/c/modules/EnumToStringx/EnumToStringx.cpp
 		default : return "unknown";
 
@@ -57,5 +57,5 @@
 #Build StringToEnumx.cpp {{{1
 #Header
-cat <<END > $ISSM_TIER/src/c/modules/StringToEnumx/StringToEnumx.cpp
+cat <<END > $ISSM_DIR/src/c/modules/StringToEnumx/StringToEnumx.cpp
 /*
 * \file StringToEnumx.cpp:
@@ -81,9 +81,9 @@
 i2=120;
 for (( i=1 ; i<=100 ; i++ )); do
-	echo "   if(stage==$i){" >> $ISSM_TIER//src/c/modules/StringToEnumx/StringToEnumx.cpp
+	echo "   if(stage==$i){" >> $ISSM_DIR//src/c/modules/StringToEnumx/StringToEnumx.cpp
 	awk -v i1=$i1 -v i2=$i2 '{if(NR>=i1 && NR<=i2) print $0 }' temp |
-	awk '{print "\t" ((NR==1)?"      if":"      else if") " (strcmp(name,\"" substr($2,1,length($2)-4) "\")==0) return " $2 ";"}' >> $ISSM_TIER//src/c/modules/StringToEnumx/StringToEnumx.cpp
-	echo "         else stage=$(($i+1));" >> $ISSM_TIER//src/c/modules/StringToEnumx/StringToEnumx.cpp
-	echo "   }" >> $ISSM_TIER//src/c/modules/StringToEnumx/StringToEnumx.cpp
+	awk '{print "\t" ((NR==1)?"      if":"      else if") " (strcmp(name,\"" substr($2,1,length($2)-4) "\")==0) return " $2 ";"}' >> $ISSM_DIR//src/c/modules/StringToEnumx/StringToEnumx.cpp
+	echo "         else stage=$(($i+1));" >> $ISSM_DIR//src/c/modules/StringToEnumx/StringToEnumx.cpp
+	echo "   }" >> $ISSM_DIR//src/c/modules/StringToEnumx/StringToEnumx.cpp
 	
 	if [ $i2 -ge $NUMENUMS ]; then break; fi
@@ -93,5 +93,5 @@
 
 #footer
-cat <<END >> $ISSM_TIER/src/c/modules/StringToEnumx/StringToEnumx.cpp
+cat <<END >> $ISSM_DIR/src/c/modules/StringToEnumx/StringToEnumx.cpp
 	/*If we reach this point, the string provided has not been found*/
    _error_("Enum %s not found",name);
@@ -127,5 +127,5 @@
 	#}}}
 	#Add case to matlabenum file{{{
-	cat <<END > $ISSM_TIER"/src/m/enum/"$(echo $NAMEENUM".m")
+	cat <<END > $ISSM_DIR"/src/m/enum/"$(echo $NAMEENUM".m")
 function macro=$(echo $NAMEENUM)()
 %$(echo $NAMEENUM | awk {'print toupper($1)'}) - Enum of $(echo $NAME)
Index: /issm/branches/trunk-jpl-damage/src/c/Makefile.am
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/Makefile.am	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/Makefile.am	(revision 12168)
@@ -4,17 +4,10 @@
 
 #Library declaration {{{1
-#Compile serial library, and then try and compile parallel library
-if NOSERIAL
-if NOPARALLEL
-lib_LIBRARIES = 
-else
-lib_LIBRARIES = libpISSM.a libOverload.a
-endif
-else
-if NOPARALLEL
-lib_LIBRARIES = libISSM.a libOverload.a
-else
-lib_LIBRARIES = libISSM.a libpISSM.a libOverload.a
-endif
+lib_LIBRARIES = libISSMCore.a libISSMModules.a libISSMOverload.a
+if PYTHON
+lib_LIBRARIES += libISSMPython.a 
+endif
+if MATLAB
+lib_LIBRARIES += libISSMMatlab.a 
 endif
 #}}}
@@ -22,5 +15,7 @@
 #sources
 #Core sources{{{1
-core_sources = ./include/macros.h\
+core_sources = ./issm.h\
+					./issm-binding.h\
+					./include/macros.h\
 					./include/typedefs.h\
 					./include/types.h\
@@ -211,10 +206,4 @@
 					./shared/Wrapper/ModuleBoot.cpp\
 					./shared/Wrapper/ModuleEnd.cpp\
-					./toolkits/mpi/mpiincludes.h\
-					./toolkits/mpi/patches/mpipatches.h\
-					./toolkits/mpi/patches/DetermineLocalSize.cpp\
-					./toolkits/mpi/patches/MPI_Upperrow.cpp\
-					./toolkits/mpi/patches/MPI_Lowerrow.cpp\
-					./toolkits/mpi/patches/MPI_Boundariesfromrange.cpp\
 					./toolkits/metis/metisincludes.h\
 					./toolkits/issm/issmtoolkit.h\
@@ -223,6 +212,4 @@
 					./toolkits/issm/SeqMat.h\
 					./toolkits/issm/SeqMat.cpp\
-					./toolkits/metis/patches/metispatches.h\
-					./toolkits/metis/patches/METIS_PartMeshNodalPatch.cpp\
 					./toolkits/triangle/triangleincludes.h\
 					./toolkitsenums.h\
@@ -362,14 +349,14 @@
 					  ./modules/AverageOntoPartitionx/AverageOntoPartitionx.cpp\
 					  ./modules/ModelProcessorx/Dakota/CreateParametersDakota.cpp\
-					  ./modules/AverageOntoPartitionx/AverageOntoPartitionx.h
-dakota_psources= ./modules/Dakotax/SpawnCoreParallel.cpp
+					  ./modules/AverageOntoPartitionx/AverageOntoPartitionx.h\
+					  ./modules/Dakotax/SpawnCoreParallel.cpp
 #}}}
 #Transient sources  {{{1
-transient_sources  = ./modules/ModelProcessorx/Transient/UpdateElementsTransient.cpp
-transient_psources = ./solutions/transient_core.cpp
+transient_sources  = ./modules/ModelProcessorx/Transient/UpdateElementsTransient.cpp \
+					 ./solutions/transient_core.cpp
 #}}}
 #Steadystate sources  {{{1
-steadystate_psources = ./solutions/steadystate_core.cpp\
-					        ./solutions/steadystateconvergence.cpp
+steadystate_sources = ./solutions/steadystate_core.cpp\
+					  ./solutions/steadystateconvergence.cpp
 #}}}
 #Prognostic sources  {{{1
@@ -377,6 +364,6 @@
 					      ./modules/ModelProcessorx/Prognostic/CreateNodesPrognostic.cpp\
 					      ./modules/ModelProcessorx/Prognostic/CreateConstraintsPrognostic.cpp\
-					      ./modules/ModelProcessorx/Prognostic/CreateLoadsPrognostic.cpp
-prognostic_psources = ./solutions/prognostic_core.cpp
+					      ./modules/ModelProcessorx/Prognostic/CreateLoadsPrognostic.cpp\
+						  ./solutions/prognostic_core.cpp
 #}}}
 #Thermal sources  {{{1
@@ -395,9 +382,8 @@
 					   ./modules/ConstraintsStatex/ThermalConstraintsState.cpp\
 					   ./modules/ConstraintsStatex/ThermalIsPresent.cpp\
-					   ./modules/ResetConstraintsx/ThermalConstraintsReset.cpp
-
-thermal_psources = ./solutions/thermal_core.cpp\
-					    ./solutions/enthalpy_core.cpp\
-					    ./solvers/solver_thermal_nonlinear.cpp
+					   ./modules/ResetConstraintsx/ThermalConstraintsReset.cpp \
+					   ./solutions/thermal_core.cpp\
+					   ./solutions/enthalpy_core.cpp\
+					   ./solvers/solver_thermal_nonlinear.cpp
 #}}}
 #Control sources  {{{1
@@ -443,8 +429,6 @@
 					  ./objects/Inputs/ControlInput.cpp\
 					  ./shared/Numerics/BrentSearch.cpp\
-					  ./shared/Numerics/OptimalSearch.cpp\
-					  ./shared/Numerics/OptFunc.cpp
-
-control_psources=./solutions/control_core.cpp\
+					  ./shared/Numerics/OptimalSearch.cpp \
+					  ./solutions/control_core.cpp\
 					  ./solutions/controltao_core.cpp\
 					  ./solutions/controlrestart.cpp\
@@ -462,8 +446,7 @@
 					      ./modules/ModelProcessorx/Hydrology/CreateNodesHydrology.cpp\
 					      ./modules/ModelProcessorx/Hydrology/CreateConstraintsHydrology.cpp\
-					      ./modules/ModelProcessorx/Hydrology/CreateLoadsHydrology.cpp
-					  
-hydrology_psources  = ./solutions/hydrology_core.cpp\
-					       ./solutions/hydrology_core_step.cpp 
+					      ./modules/ModelProcessorx/Hydrology/CreateLoadsHydrology.cpp \
+						  ./solutions/hydrology_core.cpp\
+						  ./solutions/hydrology_core_step.cpp 
 #}}}
 #Diagnostic sources  {{{1
@@ -480,11 +463,11 @@
 					      ./modules/ModelProcessorx/DiagnosticHutter/CreateConstraintsDiagnosticHutter.cpp \
 					      ./modules/ModelProcessorx/DiagnosticHutter/CreateLoadsDiagnosticHutter.cpp \
-							./shared/Elements/CoordinateSystemTransform.cpp\
-							./shared/Elements/TransformLoadVectorCoord.cpp \
-							./shared/Elements/TransformStiffnessMatrixCoord.cpp \
-							./shared/Elements/TransformInvStiffnessMatrixCoord.cpp \
-							./shared/Elements/TransformSolutionCoord.cpp
-diagnostic_psources =./solutions/diagnostic_core.cpp\
-					      ./solvers/solver_stokescoupling_nonlinear.cpp
+						  ./shared/Elements/CoordinateSystemTransform.cpp\
+						  ./shared/Elements/TransformLoadVectorCoord.cpp \
+						  ./shared/Elements/TransformStiffnessMatrixCoord.cpp \
+						  ./shared/Elements/TransformInvStiffnessMatrixCoord.cpp \
+						  ./shared/Elements/TransformSolutionCoord.cpp\
+						  ./solutions/diagnostic_core.cpp\
+						  ./solvers/solver_stokescoupling_nonlinear.cpp
 #}}}
 #Balanced sources  {{{1
@@ -492,6 +475,6 @@
 					    ./modules/ModelProcessorx/Balancethickness/CreateNodesBalancethickness.cpp\
 					    ./modules/ModelProcessorx/Balancethickness/CreateConstraintsBalancethickness.cpp\
-					    ./modules/ModelProcessorx/Balancethickness/CreateLoadsBalancethickness.cpp
-balanced_psources = ./solutions/balancethickness_core.cpp
+						./modules/ModelProcessorx/Balancethickness/CreateLoadsBalancethickness.cpp\
+						./solutions/balancethickness_core.cpp
 #}}}
 #Responses sources  {{{1
@@ -533,6 +516,6 @@
 					  ./modules/ModelProcessorx/SurfaceSlope/CreateNodesSurfaceSlope.cpp \
 					  ./modules/ModelProcessorx/SurfaceSlope/CreateConstraintsSurfaceSlope.cpp\
-					  ./modules/ModelProcessorx/SurfaceSlope/CreateLoadsSurfaceSlope.cpp
-slope_psources = ./solutions/surfaceslope_core.cpp\
+					  ./modules/ModelProcessorx/SurfaceSlope/CreateLoadsSurfaceSlope.cpp\
+					  ./solutions/surfaceslope_core.cpp\
 					  ./solutions/bedslope_core.cpp
 #}}}
@@ -694,23 +677,4 @@
 			     ./objects/KML/KMLFileReadUtils.h
 #}}}
-#Matlab sources  {{{1
-matlab_sources= ./toolkits/matlab/matlabincludes.h\
-				    ./toolkits/matlab/MatlabNArrayToNArray.cpp\
-				    ./toolkits/double/MatlabVectorToDoubleVector.cpp\
-				    ./toolkits/double/double.h\
-				    ./toolkits/double/MatlabMatrixToDoubleMatrix.cpp\
-				    ./io/Matlab/matlabio.h\
-				    ./io/Matlab/CheckNumMatlabArguments.cpp\
-				    ./io/Matlab/mxGetAssignedField.cpp\
-				    ./io/Matlab/WriteMatlabData.cpp\
-				    ./io/Matlab/FetchMatlabData.cpp\
-				    ./io/Matlab/OptionParse.cpp
-#}}}
-#Python sources  {{{1
-python_sources=     ./io/Python/pythonio.h\
-				    ./io/Python/WritePythonData.cpp\
-				    ./io/Python/CheckNumPythonArguments.cpp\
-				    ./io/Python/FetchPythonData.cpp
-#}}}
 #Petsc sources  {{{1
 petsc_sources= ./toolkits/petsc\
@@ -718,8 +682,4 @@
 					./toolkits/petsc/patches/SolverEnum.h\
 					./toolkits/petsc/patches/petscpatches.h\
-					./toolkits/petsc/patches/MatlabMatrixToPetscMatrix.cpp\
-					./toolkits/petsc/patches/MatlabVectorToPetscVector.cpp\
-					./toolkits/petsc/patches/PetscMatrixToMatlabMatrix.cpp\
-					./toolkits/petsc/patches/PetscVectorToMatlabVector.cpp\
 					./toolkits/petsc/patches/VecTranspose.cpp\
 					./toolkits/petsc/patches/VecToMPISerial.cpp\
@@ -732,4 +692,6 @@
 					./toolkits/petsc/patches/SerialToVec.cpp\
 					./toolkits/petsc/patches/VecFree.cpp\
+					./toolkits/petsc/patches/PetscMatrixToDoubleMatrix.cpp\
+					./toolkits/petsc/patches/PetscVectorToDoubleVector.cpp\
 					./toolkits/petsc/patches/VecDuplicatePatch.cpp\
 					./toolkits/petsc/patches/KSPFree.cpp\
@@ -754,6 +716,48 @@
 
 #}}}
-#Serialsources  {{{1
-serial_sources= ./objects/Options/Option.cpp\
+#Mpi sources  {{{1
+mpi_sources= ./toolkits/mpi/mpiincludes.h\
+				./toolkits/mpi/patches/mpipatches.h\
+				./toolkits/mpi/patches/DetermineLocalSize.cpp\
+				./toolkits/mpi/patches/MPI_Upperrow.cpp\
+				./toolkits/mpi/patches/MPI_Lowerrow.cpp\
+				./toolkits/mpi/patches/MPI_Boundariesfromrange.cpp
+#}}}
+#Metis sources  {{{1
+metis_sources= ./toolkits/metis/patches/metispatches.h\
+					./toolkits/metis/patches/METIS_PartMeshNodalPatch.cpp
+#}}}
+#Python sources  {{{1
+python_sources=     ./python/io/pythonio.h\
+					./python/python-binding.h\
+				    ./python/io/WritePythonData.cpp\
+				    ./python/io/CheckNumPythonArguments.cpp\
+				    ./python/io/FetchPythonData.cpp
+
+#}}}
+#Matlab sources  {{{1
+matlab_sources= ./toolkits/matlab/matlabincludes.h\
+				    ./matlab/matlab-binding.h\
+				    ./matlab/io/matlabio.h\
+				    ./matlab/io/MatlabNArrayToNArray.cpp\
+				    ./matlab/io/CheckNumMatlabArguments.cpp\
+				    ./matlab/io/mxGetAssignedField.cpp\
+				    ./matlab/io/WriteMatlabData.cpp\
+				    ./matlab/io/FetchMatlabData.cpp\
+				    ./matlab/io/OptionParse.cpp\
+				    ./matlab/io/MatlabMatrixToMatrix.cpp\
+				    ./matlab/io/MatlabVectorToVector.cpp\
+					 ./matlab/io/MatlabVectorToDoubleVector.cpp\
+					 ./matlab/io/MatlabMatrixToDoubleMatrix.cpp\
+					 ./matlab/io/MatlabMatrixToSeqMat.cpp\
+					 ./matlab/io/MatlabVectorToSeqVec.cpp
+#}}}
+#Matlab and Petsc sources  {{{1
+matlabpetsc_sources= ./matlab/io/MatlabMatrixToPetscMatrix.cpp\
+					 ./matlab/io/MatlabVectorToPetscVector.cpp
+	
+#}}}
+#Modules sources{{{1
+module_sources= ./objects/Options/Option.cpp\
 			./objects/Options/Option.h\
 			./objects/Options/OptionDouble.cpp\
@@ -769,4 +773,6 @@
 			./objects/Options/OptionUtilities.cpp\
 			./objects/Options/OptionUtilities.h\
+			./shared/Alloc/alloc_module.h\
+			./shared/Alloc/alloc_module.cpp\
 			./shared/Threads/issm_threads.h\
 			./shared/Threads/LaunchThread.cpp\
@@ -790,5 +796,4 @@
 			./modules/Chacox/chaco_seconds.cpp\
 			./modules/Chacox/user_params.cpp\
-			./modules/Dakotax/SpawnCoreSerial.cpp\
 			./modules/TriaSearchx/TriaSearchx.h\
 			./modules/TriaSearchx/TriaSearchx.cpp\
@@ -815,4 +820,6 @@
 			./modules/HoleFillerx/HoleFillerx.cpp\
 			./modules/HoleFillerx/HoleFillerx.h\
+			./modules/Krigingx/Krigingx.cpp\
+			./modules/Krigingx/Krigingx.h\
 			./modules/AverageFilterx/AverageFilterx.cpp\
 			./modules/AverageFilterx/AverageFilterx.h\
@@ -841,67 +848,55 @@
 #}}}
 
+#{{{1 Conditional build-up of sources
 #ISSM sources are a combination of core sources and sources related to specific capabilities (which can 
 #be activated by autotools conditionals 
-#{{{1
+
 
 #First the core
 issm_sources  =  $(core_sources)
-issm_psources =  
 
 #Now the optional source
 if DAKOTA
 issm_sources  +=  $(dakota_sources)
-issm_psources +=  $(dakota_psources)
 endif
 
 if PETSC
 issm_sources  +=  $(petsc_sources)
-issm_psources +=  $(petsc_psources)
 endif
 
 if GSL
 issm_sources  +=  $(gsl_sources)
-issm_psources +=  $(gsl_psources)
-endif
-
+endif
 
 if TRANSIENT
 issm_sources  +=  $(transient_sources)
-issm_psources +=  $(transient_psources)
 endif
 
 if STEADYSTATE
 issm_sources  +=  $(steadystate_sources)
-issm_psources +=  $(steadystate_psources)
 endif
 
 if PROGNOSTIC
 issm_sources  +=  $(prognostic_sources)
-issm_psources +=  $(prognostic_psources)
 endif
 
 if THERMAL
 issm_sources  +=  $(thermal_sources)
-issm_psources +=  $(thermal_psources)
 endif
 
 if CONTROL
 issm_sources  +=  $(control_sources)
-issm_psources +=  $(control_psources)
 endif
 
 if HYDROLOGY
 issm_sources  +=  $(hydrology_sources)
-issm_psources +=  $(hydrology_psources)
 endif
 
 if DIAGNOSTIC
 issm_sources  +=  $(diagnostic_sources)
-issm_psources +=  $(diagnostic_psources)
 endif
 
 if BALANCED
 issm_sources  +=  $(balanced_sources)
-issm_psources +=  $(balanced_psources)
 endif
 
@@ -912,5 +907,4 @@
 if SLOPE
 issm_sources  +=  $(slope_sources)
-issm_psources +=  $(slope_psources)
 endif
 
@@ -926,47 +920,54 @@
 issm_sources +=  $(threed_sources)
 endif
-#}}}
-
-#ISSM serial library {{{1
-if SERIAL
-libISSM_a_SOURCES  = $(issm_sources)
-libISSM_a_SOURCES += $(serial_sources)
-libISSM_a_SOURCES += $(bamg_sources)
-libISSM_a_SOURCES += $(kml_sources)
-libISSM_a_CXXFLAGS = -fPIC -D_SERIAL_ -D_GNU_SOURCE -fno-omit-frame-pointer -pthread -D_CPP_  $(CXXFLAGS) $(CXXOPTFLAGS) 
-#libISSM_a_CXXFLAGS = -D_SERIAL_ -DTRILIBRARY -DANSI_DECLARATORS -DNO_TIMER   $(CXXFLAGS) $(CXXOPTFLAGS) 
+
+if MPI
+issm_sources +=  $(mpi_sources)
+endif
+
+if METIS
+issm_sources +=  $(metis_sources)
+endif
+
+if PETSC
+if MATLAB
+issm_sources +=  $(matlabpetsc_sources)
+endif
+endif
+
+
+#}}}
+#Library flags and sources {{{1
+ALLCXXFLAGS= -fPIC -D_GNU_SOURCE -fno-omit-frame-pointer -pthread -D_CPP_  $(CXXFLAGS) $(CXXOPTFLAGS) 
+
+libISSMCore_a_SOURCES  = $(issm_sources)
+libISSMCore_a_CXXFLAGS = $(ALLCXXFLAGS)
+
+if MODULES
+libISSMModules_a_SOURCES = $(module_sources)
+libISSMModules_a_SOURCES += $(bamg_sources)
+libISSMModules_a_SOURCES += $(kml_sources)
+libISSMModules_a_CXXFLAGS = $(ALLCXXFLAGS)
 
 if PYTHON
-libISSM_a_CXXFLAGS+=  -DNPY_NO_DEPRECATED_API 
-libISSM_a_SOURCES += $(python_sources)
+libISSMPython_a_SOURCES = $(python_sources)
+libISSMPython_a_CXXFLAGS= $(ALLCXXFLAGS)
 endif
 
 if MATLAB
-libISSM_a_SOURCES += $(matlab_sources)
-endif
-
-endif
-#}}}
-#ISSM parallel library {{{1
-if PARALLEL
-libpISSM_a_SOURCES  = $(issm_sources)
-libpISSM_a_SOURCES += $(issm_psources)
-libpISSM_a_CXXFLAGS = -fPIC -D_PARALLEL_   -D_C_ $(CXXFLAGS) $(CXXOPTFLAGS) 
+libISSMMatlab_a_SOURCES = $(matlab_sources)
+libISSMMatlab_a_CXXFLAGS= $(ALLCXXFLAGS)
+endif
 endif
 #}}}
 #Overload library, to overload any non-standard symbols. {{{1
-libOverload_a_SOURCES = ./shared/String/stricmp.c
-libOverload_a_CFLAGS  = -fPIC -D_PARALLEL_   -D_C_ $(COPTFLAGS) $(CFLAGS)
+libISSMOverload_a_SOURCES = ./shared/String/stricmp.c
+libISSMOverload_a_CFLAGS  = -fPIC -D_C_ $(COPTFLAGS) $(CFLAGS)
 #}}}
 
 #Executable {{{1
-if NOPARALLEL
-bin_PROGRAMS = 
-else 
 bin_PROGRAMS = issm 
-endif
 
 #Standard libraries
-LDADD = ./libpISSM.a ./libOverload.a
+LDADD = ./libISSMCore.a ./libISSMOverload.a
 
 #External packages
@@ -974,22 +975,21 @@
 
 issm_SOURCES = solutions/issm.cpp
-issm_CXXFLAGS= -fPIC -D_PARALLEL_ $(CXXFLAGS) $(CXXOPTFLAGS) $(COPTFLAGS) 
+issm_CXXFLAGS= -fPIC $(CXXFLAGS) $(CXXOPTFLAGS) $(COPTFLAGS) 
 #}}}
 #Automatic differentiation: append this fold to the end of the src/c/Makefile.am to get this Makefile.am {{{
 if ADIC2 
-lib_LIBRARIES += libAD.a libpISSMRose.a
+lib_LIBRARIES += libAD.a libISSMRose.a
 
 #ADIC2 library, for automatic differentiation 
 #libAD_a_SOURCES = ./mini1.ad.c
 libAD_a_SOURCES = 
-libAD_a_CFLAGS = -fPIC -D_PARALLEL_   -D_C_ $(COPTFLAGS)
-
+libAD_a_CFLAGS = -fPIC -D_C_ $(COPTFLAGS)
 
 
 #test rose preprocessing 
 %.r2cpp.cpp : %.cpp
-	testTranslator -rose:o $@ -rose:skipfinalCompileStep -DHAVE_CONFIG_H -D_PARALLEL_ -D_C_ -I. -I../.. $(INCLUDES) $<
-libpISSMRose_a_SOURCES = $(libpISSM_a_SOURCES:.cpp=.r2cpp.cpp)
-libpISSMRose_a_CXXFLAGS= -fPIC -D_PARALLEL_ -D_C_ $(CXXOPTFLAGS)
+	testTranslator -rose:o $@ -rose:skipfinalCompileStep -DHAVE_CONFIG_H -D_C_ -I. -I../.. $(INCLUDES) $<
+libISSMRose_a_SOURCES = $(libISSMCore_a_SOURCES:.cpp=.r2cpp.cpp)
+libISSMRose_a_CXXFLAGS= -fPIC -D_C_ $(CXXOPTFLAGS)
 
 
@@ -1003,7 +1003,7 @@
 #Executable
 bin_PROGRAMS +=  issmRose.exe
-issmRose_exe_LDADD = ./libpISSMRose.a $(LDADD)
+issmRose_exe_LDADD = ./libISSMRose.a $(LDADD)
 issmRose_exe_SOURCES = solutions/issm.cpp
-issmRose_exe_CXXFLAGS= -fPIC -D_PARALLEL_  $(CXXOPTFLAGS) $(COPTFLAGS) 
+issmRose_exe_CXXFLAGS= -fPIC $(CXXOPTFLAGS) $(COPTFLAGS) 
 LDADD +=  $(ADIC2LIB) 
 
Index: /issm/branches/trunk-jpl-damage/src/c/include/macros.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/include/macros.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/include/macros.h	(revision 12168)
@@ -40,39 +40,14 @@
 #endif
 /*}}}*/
-
-/* MODULEBOOT/MODULEEND {{{1*/
+/* ISSMBOOT/ISSMEND {{{1*/
 
 /*The following macros hide the error exception handling in a matlab module. Just put 
- * MODULEBOOT(); and MODULEEND(); at the beginning and end of a module, and c++ exceptions 
+ * ISSMBOOT(); and ISSMEND(); at the beginning and end of a module, and c++ exceptions 
  * will be trapped. Really nifty!*/
 
-#ifdef _SERIAL_
-#ifdef _HAVE_MATLAB_ //{{{2
-#define MODULEBOOT(); ModuleBoot(); \
+#define ISSMBOOT(); \
 	try{
 
-#define MODULEEND(); ModuleEnd(); }\
-	catch(ErrorException &exception){\
-		exception.Report(); \
-		mexErrMsgTxt(""); \
-	}\
-	catch (exception& e) {\
-		_printf_(true,"Standard exception: %s\n",e.what());\
-		mexErrMsgTxt(" ");\
-	}
-#endif //}}}
-#ifdef _HAVE_PYTHON_ //{{{2
-#define MODULEBOOT(); ModuleBoot();  \
-	PyObject* output = PyTuple_New(NLHS); if (!output) return NULL;
-
-#define MODULEEND();  ModuleEnd(); \
-						 return output;
-#endif //}}}
-#else 
-//{{{2
-#define MODULEBOOT(); \
-	try{
-
-#define MODULEEND(); }\
+#define ISSMEND(); }\
 	catch(ErrorException &exception){\
 		exception.Report(); \
@@ -82,50 +57,9 @@
 		_printf_(true,"Standard exception: %s\n",e.what());\
 		return 1;\
+	}\
+	catch(...){\
+		_printf_(true,"An unexpected error occurred");\
 	}
-//}}}
-#endif
 /*}}}*/
-/* WRAPPER {{{1*/
-#ifdef _HAVE_MATLAB_
-#define WRAPPER(modulename,...) void mexFunction(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]) 
-#endif
-#ifdef _HAVE_PYTHON_
-#define WRAPPER(modulename,...)  \
-\
-static PyObject* modulename(PyObject* self,PyObject* args);\
-static PyMethodDef modulename##_funcs[] = {\
-	{#modulename, (PyCFunction)modulename, METH_VARARGS, ""},\
-	{NULL,NULL,0,NULL}\
-};\
-\
-static struct PyModuleDef modulename##module= {\
-	PyModuleDef_HEAD_INIT,\
-	#modulename,   /* name of module */\
-	NULL, /* module documentation, may be NULL */\
-	-1,       /* size of per-interpreter state of the module,\
-				 or -1 if the module keeps state in global variables. */\
-	modulename##_funcs\
-};\
-\
-PyMODINIT_FUNC PyInit_##modulename(void){\
-\
-	import_array();\
-	return PyModule_Create(&modulename##module);\
-}\
-\
-static PyObject* modulename(PyObject* self,PyObject* args)
 
 #endif
-
-/*}}}*/
-/* CHECKARGUMENTS {{{1*/
-#ifdef _HAVE_MATLAB_
-#define CHECKARGUMENTS(NLHS,NRHS,functionpointer) CheckNumMatlabArguments(nlhs,NLHS,nrhs,NRHS,__FUNCT__,functionpointer)
-#endif
-#ifdef _HAVE_PYTHON_
-#define CHECKARGUMENTS(NLHS,NRHS,functionpointer) CheckNumPythonArguments(args, NRHS,functionpointer)
-#endif
-/*}}}*/
-
-
-#endif
Index: /issm/branches/trunk-jpl-damage/src/c/include/types.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/include/types.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/include/types.h	(revision 12168)
@@ -16,12 +16,4 @@
 
 /*Define abstract type for I/O: */
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-#include <mex.h>
-typedef const mxArray* ConstDataHandle;  //serially, we are reading data from a matlab array.
-typedef mxArray* DataHandle;  
-#else 
-typedef FILE* ConstDataHandle; //in parallel, we are reading data from a file.
-typedef FILE* DataHandle; 
-#endif
 enum param_type { STRING, INTEGER, STRINGARRAY, DOUBLE, DOUBLEVEC, DOUBLEMAT, PETSCVEC, PETSCMAT };
 
Index: /issm/branches/trunk-jpl-damage/src/c/io/PrintfFunction.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/io/PrintfFunction.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/io/PrintfFunction.cpp	(revision 12168)
@@ -8,8 +8,4 @@
 #include "../shared/shared.h"
 #include "../include/include.h"
-
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-#include "mex.h"
-#endif
 
 int PrintfFunction(const char* format,...){
@@ -53,9 +49,5 @@
 
 	/*Ok, if we are running in parallel, get node 0 to print*/
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-	mexPrintf(buffer);
-#else
 	if(my_rank==0)printf(buffer);
-#endif
 
 	/*Clean up and return*/
Index: /issm/branches/trunk-jpl-damage/src/c/io/io.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/io/io.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/io/io.h	(revision 12168)
@@ -15,12 +15,4 @@
 #include "./Disk/diskio.h"
 
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-#include "./Matlab/matlabio.h"
-#endif
-
-#if defined(_HAVE_PYTHON_) && defined(_SERIAL_)
-#include "./Python/pythonio.h"
-#endif
-
 /*printf: */
 int PrintfFunction(const char* format,...);
Index: /issm/branches/trunk-jpl-damage/src/c/issm-binding.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/issm-binding.h	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/c/issm-binding.h	(revision 12168)
@@ -0,0 +1,18 @@
+#ifndef _ISSM_BINDING_H_
+#define _ISSM_BINDING_H_
+
+#ifdef HAVE_CONFIG_H
+	#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+#ifdef  _HAVE_MATLAB_MODULES_
+#include "./matlab/matlab-binding.h"
+#endif
+
+#ifdef  _HAVE_PYTHON_MODULES_
+#include "./python/python-binding.h"
+#endif
+
+#endif
Index: /issm/branches/trunk-jpl-damage/src/c/matlab/include/matlab_macros.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/matlab/include/matlab_macros.h	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/c/matlab/include/matlab_macros.h	(revision 12168)
@@ -0,0 +1,47 @@
+/* \file matlab macros.h
+ * \brief: macros used for the matlab bindings
+ */
+
+/*Header {{{1*/
+#ifndef _MATLAB_MACROS_H_
+#define _MATLAB_MACROS_H_
+
+#ifdef HAVE_CONFIG_H
+	#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+/*}}}*/
+
+#ifdef _HAVE_MATLAB_
+/* MODULEBOOT/MODULEEND {{{1*/
+
+/*The following macros hide the error exception handling in a matlab module. Just put 
+ * MODULEBOOT(); and MODULEEND(); at the beginning and end of a module, and c++ exceptions 
+ * will be trapped. Really nifty!*/
+//exception.Report(); 
+
+#define MODULEBOOT(); ModuleBoot(); \
+	try{
+
+#define MODULEEND(); ModuleEnd(); }\
+	catch(ErrorException &exception){\
+		mexErrMsgTxt("ISSM Error"); \
+	}\
+	catch (exception &e){\
+		mexErrMsgTxt(exprintf("Standard exception: %s\n",e.what()));\
+	}\
+	catch(...){\
+		mexErrMsgTxt("An unexpected error occurred");\
+	}
+//}}}
+/* WRAPPER {{{1*/
+#define WRAPPER(modulename,...) void mexFunction(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]) 
+
+/*}}}*/
+/* CHECKARGUMENTS {{{1*/
+#define CHECKARGUMENTS(NLHS,NRHS,functionpointer) CheckNumMatlabArguments(nlhs,NLHS,nrhs,NRHS,__FUNCT__,functionpointer)
+/*}}}*/
+#endif
+
+#endif
Index: /issm/branches/trunk-jpl-damage/src/c/matlab/io/CheckNumMatlabArguments.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/matlab/io/CheckNumMatlabArguments.cpp	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/c/matlab/io/CheckNumMatlabArguments.cpp	(revision 12168)
@@ -0,0 +1,31 @@
+/*!\file CheckNumMatlabArguments.cpp:
+ * \brief: check number of arguments and report an usage error message.
+ */
+
+#ifdef HAVE_CONFIG_H
+	#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+
+#include "../../shared/Exceptions/exceptions.h"
+#include "../../include/include.h"
+#include "mex.h"
+
+int CheckNumMatlabArguments(int nlhs,int NLHS, int nrhs,int NRHS, const char* __FUNCT__, void (*function)( void )){
+	
+	/*checks on arguments on the matlab side: */
+	if (nrhs==0 && nlhs==0) {
+		/*unless NLHS=0 and NRHS=0, we are just asking for documentation: */
+		if (NRHS==0 && NLHS==0)return 1;
+		/* special case: */
+		function();
+		_error_("usage: see above");
+	}
+	else if (nlhs!=NLHS || nrhs!=NRHS ) {
+		function(); 
+		_error_("usage error.");
+	}
+	return 1;
+}
Index: /issm/branches/trunk-jpl-damage/src/c/matlab/io/FetchMatlabData.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/matlab/io/FetchMatlabData.cpp	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/c/matlab/io/FetchMatlabData.cpp	(revision 12168)
@@ -0,0 +1,638 @@
+/*\file FetchData.cpp:
+ * \brief: general I/O interface to fetch data in matlab
+ */
+
+#ifdef HAVE_CONFIG_H
+	#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+#include <mex.h>
+#include "../../shared/shared.h"
+#include "../../include/include.h"
+#include "./matlabio.h"
+
+/*Primitive data types*/
+/*FUNCTION FetchData(double** pmatrix,int* pM,int *pN,const mxArray* dataref){{{1*/
+void FetchData(double** pmatrix,int* pM,int *pN,const mxArray* dataref){
+
+	double*  outmatrix=NULL;
+	int      outmatrix_rows,outmatrix_cols;
+
+	if(mxIsEmpty(dataref) ){
+		/*Nothing to pick up. Just initialize matrix pointer to NULL: */
+		outmatrix_rows=0;
+		outmatrix_cols=0;
+		outmatrix=NULL;
+	}
+	else if(mxIsClass(dataref,"double") || mxIsClass(dataref,"single")){
+		/*Check dataref is not pointing to NaN: */
+		if ( mxIsNaN(*(mxGetPr(dataref))) && (mxGetM(dataref)==1) && (mxGetN(dataref)==1) ){
+			outmatrix_rows=0;
+			outmatrix_cols=0;
+			outmatrix=NULL;
+		}
+		else{
+			/*Convert matlab matrix to double* matrix: */
+			MatlabMatrixToDoubleMatrix(&outmatrix,&outmatrix_rows,&outmatrix_cols,dataref);
+		}
+	}
+	else{
+		/*This is an error: we don't have the correct input!: */
+		_error_("Input parameter of class %s not supported yet",mxGetClassName(dataref));
+	}
+			
+	/*Assign output pointers:*/
+	*pmatrix=outmatrix;
+	if (pM)*pM=outmatrix_rows;
+	if (pN)*pN=outmatrix_cols;
+
+}
+/*}}}*/
+/*FUNCTION FetchData(double** pmatrix,int* pnumel,int* pndims,int** psize,const mxArray* dataref){{{1*/
+void FetchData(double** pmatrix,int* pnumel,int* pndims,int** psize,const mxArray* dataref){
+
+	double*  outmatrix=NULL;
+	int      outmatrix_numel,outmatrix_ndims;
+	int*     outmatrix_size=NULL;
+
+	if(mxIsEmpty(dataref) ){
+		/*Nothing to pick up. Just initialize matrix pointer to NULL: */
+		outmatrix_numel=0;
+		outmatrix_ndims=0;
+		outmatrix_size =NULL;
+		outmatrix=NULL;
+	}
+	else if (mxIsClass(dataref,"double") ){
+
+		/*Check dataref is not pointing to NaN: */
+		if ( mxIsNaN(*(mxGetPr(dataref))) && (mxGetNumberOfElements(dataref)==1) ){
+			outmatrix_numel=0;
+			outmatrix_ndims=0;
+			outmatrix_size =NULL;
+			outmatrix=NULL;
+		}
+		else{
+
+			/*Convert matlab n-dim array to double* matrix: */
+			MatlabNArrayToNArray(&outmatrix,&outmatrix_numel,&outmatrix_ndims,&outmatrix_size,dataref);
+		}
+	}
+	else{
+		/*This is an error: we don't have the correct input!: */
+		_error_("Input parameter of class %s not supported yet",mxGetClassName(dataref));
+	}
+			
+	/*Assign output pointers:*/
+	*pmatrix=outmatrix;
+	if (pnumel)*pnumel=outmatrix_numel;
+	if (pndims)*pndims=outmatrix_ndims;
+	if (psize )*psize =outmatrix_size;
+	else xfree((void**)&outmatrix_size);
+
+}
+/*}}}*/
+/*FUNCTION FetchData(int** pmatrix,int* pM,int *pN,const mxArray* dataref){{{1*/
+void FetchData(int** pmatrix,int* pM,int *pN,const mxArray* dataref){
+
+	int     i,outmatrix_rows,outmatrix_cols;
+	double *doublematrix=NULL;
+	int    *outmatrix=NULL;
+
+	if(mxIsEmpty(dataref) ){
+		/*Nothing to pick up. Just initialize matrix pointer to NULL: */
+		outmatrix_rows=0;
+		outmatrix_cols=0;
+		outmatrix=NULL;
+	}
+	else if (mxIsClass(dataref,"double") ){
+
+		/*Check dataref is not pointing to NaN: */
+		if ( mxIsNaN(*(mxGetPr(dataref))) && (mxGetM(dataref)==1) && (mxGetN(dataref)==1) ){
+			outmatrix_rows=0;
+			outmatrix_cols=0;
+			outmatrix=NULL;
+		}
+		else{
+
+			/*Convert matlab matrix to double* matrix: */
+			MatlabMatrixToDoubleMatrix(&doublematrix,&outmatrix_rows,&outmatrix_cols,dataref);
+
+			/*Convert double matrix into integer matrix: */
+			outmatrix=(int*)xmalloc(outmatrix_rows*outmatrix_cols*sizeof(int));
+			for(i=0;i<outmatrix_rows*outmatrix_cols;i++)outmatrix[i]=(int)doublematrix[i];
+		}
+	}
+	else{
+		/*This is an error: we don't have the correct input!: */
+		_error_("Input parameter of class %s not supported yet",mxGetClassName(dataref));
+	}
+
+	/*Assign output pointers:*/
+	*pmatrix=outmatrix;
+	if (pM)*pM=outmatrix_rows;
+	if (pN)*pN=outmatrix_cols;
+}
+/*}}}*/
+/*FUNCTION FetchData(bool** pmatrix,int* pM,int *pN,const mxArray* dataref){{{1*/
+void FetchData(bool** pmatrix,int* pM,int *pN,const mxArray* dataref){
+
+	int     i,outmatrix_rows,outmatrix_cols;
+	double *doublematrix=NULL;
+	bool   *outmatrix=NULL;
+
+	if(mxIsEmpty(dataref) ){
+		/*Nothing to pick up. Just initialize matrix pointer to NULL: */
+		outmatrix_rows=0;
+		outmatrix_cols=0;
+		outmatrix=NULL;
+	}
+	else if (mxIsClass(dataref,"double") ){
+
+		/*Check dataref is not pointing to NaN: */
+		if ( mxIsNaN(*(mxGetPr(dataref))) && (mxGetM(dataref)==1) && (mxGetN(dataref)==1) ){
+			outmatrix_rows=0;
+			outmatrix_cols=0;
+			outmatrix=NULL;
+		}
+		else{
+
+			/*Convert matlab matrix to double* matrix: */
+			MatlabMatrixToDoubleMatrix(&doublematrix,&outmatrix_rows,&outmatrix_cols,dataref);
+
+			/*Convert double matrix into integer matrix: */
+			outmatrix=(bool*)xmalloc(outmatrix_rows*outmatrix_cols*sizeof(bool));
+			for(i=0;i<outmatrix_rows;i++)outmatrix[i]=(bool)doublematrix[i];
+		}
+	}
+	else{
+		/*This is an error: we don't have the correct input!: */
+		_error_("Input parameter of class %s not supported yet",mxGetClassName(dataref));
+	}
+
+	/*Assign output pointers:*/
+	*pmatrix=outmatrix;
+	if (pM)*pM=outmatrix_rows;
+	if (pN)*pN=outmatrix_cols;
+}
+/*}}}*/
+/*FUNCTION FetchData(bool** pmatrix,int* pnumel,int* pndims,int** psize,const mxArray* dataref){{{1*/
+void FetchData(bool** pmatrix,int* pnumel,int* pndims,int** psize,const mxArray* dataref){
+
+	int      i;
+	int      outmatrix_numel,outmatrix_ndims;
+	int*     outmatrix_size=NULL;
+	double*  doublematrix=NULL;
+	bool*    outmatrix=NULL;
+
+	if(mxIsEmpty(dataref) ){
+		/*Nothing to pick up. Just initialize matrix pointer to NULL: */
+		outmatrix_numel=0;
+		outmatrix_ndims=0;
+		outmatrix_size =NULL;
+		outmatrix=NULL;
+	}
+	else if (mxIsClass(dataref,"logical") ){
+
+		/*Check dataref is not pointing to NaN: */
+		if ( mxIsNaN(*((bool*)mxGetData(dataref))) && (mxGetNumberOfElements(dataref)==1) ){
+			outmatrix_numel=0;
+			outmatrix_ndims=0;
+			outmatrix_size =NULL;
+			outmatrix=NULL;
+		}
+		else{
+
+			/*Convert matlab n-dim array to bool* matrix: */
+			MatlabNArrayToNArray(&outmatrix,&outmatrix_numel,&outmatrix_ndims,&outmatrix_size,dataref);
+		}
+	}
+	else if (mxIsClass(dataref,"double") ){
+
+		/*Check dataref is not pointing to NaN: */
+		if ( mxIsNaN(*(mxGetPr(dataref))) && (mxGetNumberOfElements(dataref)==1) ){
+			outmatrix_numel=0;
+			outmatrix_ndims=0;
+			outmatrix_size =NULL;
+			outmatrix=NULL;
+		}
+		else{
+
+			/*Convert matlab n-dim array to double* matrix: */
+			MatlabNArrayToNArray(&doublematrix,&outmatrix_numel,&outmatrix_ndims,&outmatrix_size,dataref);
+
+			/*Convert double matrix into bool matrix: */
+			outmatrix=(bool*)xmalloc(outmatrix_numel*sizeof(bool));
+			for(i=0;i<outmatrix_numel;i++)outmatrix[i]=(bool)doublematrix[i];
+			xfree((void**)&doublematrix);
+		}
+	}
+	else{
+		/*This is an error: we don't have the correct input!: */
+		_error_("Input parameter of class %s not supported yet",mxGetClassName(dataref));
+	}
+			
+	/*Assign output pointers:*/
+	*pmatrix=outmatrix;
+	if (pnumel)*pnumel=outmatrix_numel;
+	if (pndims)*pndims=outmatrix_ndims;
+	if (psize )*psize =outmatrix_size;
+	else xfree((void**)&outmatrix_size);
+
+}
+/*}}}*/
+/*FUNCTION FetchData(double** pvector,int* pM,const mxArray* dataref){{{1*/
+void FetchData(double** pvector,int* pM,const mxArray* dataref){
+
+	double* outvector=NULL;
+	int outvector_rows;
+
+	if(mxIsEmpty(dataref)){
+		/*Nothing to pick up. Just initialize matrix pointer to NULL: */
+		outvector_rows=0;
+		outvector=NULL;
+	}
+	else if (mxIsClass(dataref,"double") ){
+
+		/*Convert matlab vector to double*  vector: */
+		MatlabVectorToDoubleVector(&outvector,&outvector_rows,dataref);
+
+	}
+	else{
+		/*This is an error: we don't have the correct input!: */
+		_error_("Input parameter of class %s not supported yet",mxGetClassName(dataref));
+	}
+
+	/*Assign output pointers:*/
+	*pvector=outvector;
+	if (pM)*pM=outvector_rows;
+}
+/*}}}*/
+/*FUNCTION FetchData(int** pvector,int* pM,const mxArray* dataref){{{1*/
+void FetchData(int** pvector,int* pM,const mxArray* dataref){
+
+	int    i;
+	double *doublevector   = NULL;
+	int    *outvector      = NULL;
+	int     outvector_rows;
+
+	if(mxIsEmpty(dataref)){
+		/*Nothing to pick up. Just initialize matrix pointer to NULL: */
+		outvector_rows=0;
+		outvector=NULL;
+	}
+	else if (mxIsClass(dataref,"double") ){
+
+		/*Convert matlab vector to double*  vector: */
+		MatlabVectorToDoubleVector(&doublevector,&outvector_rows,dataref);
+
+		/*Convert double vector into integer vector: */
+		outvector=(int*)xmalloc(outvector_rows*sizeof(int));
+		for(i=0;i<outvector_rows;i++)outvector[i]=(int)doublevector[i];
+	}
+	else{
+		/*This is an error: we don't have the correct input!: */
+		_error_("Input parameter of class %s not supported yet",mxGetClassName(dataref));
+	}
+
+	/*Assign output pointers:*/
+	*pvector=outvector;
+	if (pM)*pM=outvector_rows;
+}
+/*}}}*/
+/*FUNCTION FetchData(bool** pvector,int* pM,const mxArray* dataref){{{1*/
+void FetchData(bool** pvector,int* pM,const mxArray* dataref){
+
+	int    i;
+	double *doublevector   = NULL;
+	bool   *outvector      = NULL;
+	int     outvector_rows;
+
+	if(mxIsEmpty(dataref)){
+		/*Nothing to pick up. Just initialize matrix pointer to NULL: */
+		outvector_rows=0;
+		outvector=NULL;
+	}
+	else if (mxIsClass(dataref,"double") ){
+
+		/*Convert matlab vector to double*  vector: */
+		MatlabVectorToDoubleVector(&doublevector,&outvector_rows,dataref);
+
+		/*Convert double vector into integer vector: */
+		outvector=(bool*)xmalloc(outvector_rows*sizeof(bool));
+		for(i=0;i<outvector_rows;i++)outvector[i]=(bool)doublevector[i];
+	}
+	else{
+		/*This is an error: we don't have the correct input!: */
+		_error_("Input parameter of class %s not supported yet",mxGetClassName(dataref));
+	}
+
+	/*Assign output pointers:*/
+	*pvector=outvector;
+	if (pM)*pM=outvector_rows;
+}
+/*}}}*/
+/*FUNCTION FetchData(float** pvector,int* pM,const mxArray* dataref){{{1*/
+void FetchData(float** pvector,int* pM,const mxArray* dataref){
+
+	int    i;
+	double *doublevector   = NULL;
+	float  *outvector      = NULL;
+	int     outvector_rows;
+
+	if(mxIsEmpty(dataref)){
+		/*Nothing to pick up. Just initialize matrix pointer to NULL: */
+		outvector_rows=0;
+		outvector=NULL;
+	}
+	else if (mxIsClass(dataref,"double") ){
+
+		/*Convert matlab vector to double*  vector: */
+		MatlabVectorToDoubleVector(&doublevector,&outvector_rows,dataref);
+
+		/*Convert double vector into float vector: */
+		outvector=(float*)xmalloc(outvector_rows*sizeof(float));
+		for(i=0;i<outvector_rows;i++)outvector[i]=(float)doublevector[i];
+	}
+	else{
+		/*This is an error: we don't have the correct input!: */
+		_error_("Input parameter of class %s not supported yet",mxGetClassName(dataref));
+	}
+
+	/*Assign output pointers:*/
+	*pvector=outvector;
+	if (pM)*pM=outvector_rows;
+}
+/*}}}*/
+/*FUNCTION FetchData(char** pstring,const mxArray* dataref){{{1*/
+void FetchData(char** pstring,const mxArray* dataref){
+
+	char* outstring=NULL;
+
+
+	/*Ok, the string should be coming directly from the matlab workspace: */
+	if (!mxIsClass(dataref,"char")){
+		_error_("input data_type is not a string!");
+	}
+	else{
+		/*Recover the string:*/
+		int stringlen;
+		
+		stringlen = mxGetM(dataref)*mxGetN(dataref)+1;
+		outstring = (char*)xmalloc(sizeof(mxChar)*stringlen);
+		mxGetString(dataref,outstring,stringlen);
+	}
+
+	/*Assign output pointers:*/
+	*pstring=outstring;
+}
+/*FUNCTION FetchData(char** pmatrix,int* pnumel,int* pndims,int** psize,const mxArray* dataref){{{1*/
+void FetchData(char** pmatrix,int* pnumel,int* pndims,int** psize,const mxArray* dataref){
+
+	int      outmatrix_numel,outmatrix_ndims;
+	int*     outmatrix_size=NULL;
+	char*    outmatrix=NULL;
+
+	if(mxIsEmpty(dataref) ){
+		/*Nothing to pick up. Just initialize matrix pointer to NULL: */
+		outmatrix_numel=0;
+		outmatrix_ndims=0;
+		outmatrix_size =NULL;
+		outmatrix=NULL;
+	}
+	else if (mxIsClass(dataref,"char") ){
+
+		/*Check dataref is not pointing to NaN: */
+		if ( mxIsNaN(*(mxGetPr(dataref))) && (mxGetNumberOfElements(dataref)==1) ){
+			outmatrix_numel=0;
+			outmatrix_ndims=0;
+			outmatrix_size =NULL;
+			outmatrix=NULL;
+		}
+		else{
+
+			/*Convert matlab n-dim array to char* matrix: */
+			MatlabNArrayToNArray(&outmatrix,&outmatrix_numel,&outmatrix_ndims,&outmatrix_size,dataref);
+		}
+	}
+	else{
+		/*This is an error: we don't have the correct input!: */
+		_error_("Input parameter of class %s not supported yet",mxGetClassName(dataref));
+	}
+			
+	/*Assign output pointers:*/
+	*pmatrix=outmatrix;
+	if (pnumel)*pnumel=outmatrix_numel;
+	if (pndims)*pndims=outmatrix_ndims;
+	if (psize )*psize =outmatrix_size;
+	else xfree((void**)&outmatrix_size);
+
+}
+/*}}}*/
+/*FUNCTION FetchData(double* pscalar,const mxArray* dataref){{{1*/
+void FetchData(double* pscalar,const mxArray* dataref){
+
+	double scalar;
+
+	if (!mxIsClass(dataref,"double")){
+		_error_("input data_type is not a double!");
+	}
+	else{
+		/*Recover the double: */
+		scalar=mxGetScalar(dataref);
+	}
+
+	/*Assign output pointers:*/
+	*pscalar=scalar;
+}
+/*}}}*/
+/*FUNCTION FetchData(int* pinteger,const mxArray* dataref){{{1*/
+void FetchData(int* pinteger,const mxArray* dataref){
+
+	int integer;
+
+	if (!mxIsClass(dataref,"double")){
+		_error_("input data_type is not a scalar!");
+	}
+	else{
+		/*Recover the double: */
+		integer=(int)mxGetScalar(dataref);
+	}
+
+	/*Assign output pointers:*/
+	*pinteger=integer;
+}
+/*}}}*/
+/*FUNCTION FetchData(bool* pboolean,const mxArray* dataref){{{1*/
+void FetchData(bool* pboolean,const mxArray* dataref){
+
+	bool* mxbool_ptr=NULL;
+
+	if (mxIsClass(dataref,"logical")){
+		if(mxGetM(dataref)!=1) _error_("input data is not of size 1x1");
+		if(mxGetN(dataref)!=1) _error_("input data is not of size 1x1");
+		mxbool_ptr=mxGetLogicals(dataref);
+	}
+	else{
+		_error_("input data_type is not a bool!");
+	}
+
+	*pboolean=*mxbool_ptr;
+}
+/*}}}*/
+
+/*ISSM objects*/
+/*FUNCTION FetchData(Matrix** pmatrix,const mxArray* dataref){{{1*/
+void FetchData(Matrix** pmatrix,const mxArray* dataref){
+
+	Matrix* outmatrix=NULL;
+	int dummy=0;
+
+	if (mxIsClass(dataref,"double") ){
+
+		/*Convert matlab matrix to matrix: */
+		outmatrix=MatlabMatrixToMatrix(dataref);
+
+	}
+	else{
+		/*This is an error: we don't have the correct input!: */
+		_error_("Input parameter of class %s not supported yet",mxGetClassName(dataref));
+	}
+
+	/*Assign output pointers:*/
+	*pmatrix=outmatrix;
+}
+/*}}}*/
+/*FUNCTION FetchData(Vector** pvector,const mxArray* dataref){{{1*/
+void FetchData(Vector** pvector,const mxArray* dataref){
+
+	Vector* vector=NULL;
+	int dummy;
+
+	if(mxIsEmpty(dataref)){
+		/*Nothing to pick up. Just initialize matrix pointer to NULL: */
+		vector=new Vector(0);
+	}
+	else if (mxIsClass(dataref,"double") ){
+
+		/*Convert matlab vector to petsc vector: */
+		vector=MatlabVectorToVector(dataref);
+	}
+	else{
+		/*This is an error: we don't have the correct input!: */
+		_error_("Input parameter of class %s not supported yet",mxGetClassName(dataref));
+	}
+
+	/*Assign output pointers:*/
+	*pvector=vector;
+}
+/*}}}*/
+/*FUNCTION FetchData(BamgGeom** pbamggeom,const mxArray* dataref){{{1*/
+void FetchData(BamgGeom** pbamggeom,const mxArray* dataref){
+
+	/*Initialize output*/
+	BamgGeom* bamggeom=new BamgGeom();
+
+	/*Fetch all fields*/
+	FetchData(&bamggeom->Vertices,&bamggeom->VerticesSize[0],&bamggeom->VerticesSize[1],mxGetAssignedField(dataref,0,"Vertices"));
+	FetchData(&bamggeom->Edges, &bamggeom->EdgesSize[0], &bamggeom->EdgesSize[1], mxGetAssignedField(dataref,0,"Edges"));
+	FetchData(&bamggeom->Corners, &bamggeom->CornersSize[0], &bamggeom->CornersSize[1], mxGetAssignedField(dataref,0,"Corners"));
+	FetchData(&bamggeom->RequiredVertices,&bamggeom->RequiredVerticesSize[0],&bamggeom->RequiredVerticesSize[1],mxGetAssignedField(dataref,0,"RequiredVertices"));
+	FetchData(&bamggeom->RequiredEdges, &bamggeom->RequiredEdgesSize[0], &bamggeom->RequiredEdgesSize[1], mxGetAssignedField(dataref,0,"RequiredEdges"));
+	FetchData(&bamggeom->CrackedEdges,&bamggeom->CrackedEdgesSize[0],&bamggeom->CrackedEdgesSize[1],mxGetAssignedField(dataref,0,"CrackedEdges"));
+	FetchData(&bamggeom->SubDomains,&bamggeom->SubDomainsSize[0],&bamggeom->SubDomainsSize[1],mxGetAssignedField(dataref,0,"SubDomains"));
+
+	/*Assign output pointers:*/
+	*pbamggeom=bamggeom;
+}
+/*}}}*/
+/*FUNCTION FetchData(BamgMesh** pbamgmesh,const mxArray* dataref){{{1*/
+void FetchData(BamgMesh** pbamgmesh,const mxArray* dataref){
+
+	/*Initialize output*/
+	BamgMesh* bamgmesh=new BamgMesh();
+
+	/*Fetch all fields*/
+	FetchData(&bamgmesh->Vertices,&bamgmesh->VerticesSize[0],&bamgmesh->VerticesSize[1],mxGetAssignedField(dataref,0,"Vertices"));
+	FetchData(&bamgmesh->Edges, &bamgmesh->EdgesSize[0], &bamgmesh->EdgesSize[1], mxGetAssignedField(dataref,0,"Edges"));
+	FetchData(&bamgmesh->Triangles, &bamgmesh->TrianglesSize[0], &bamgmesh->TrianglesSize[1], mxGetAssignedField(dataref,0,"Triangles"));
+	FetchData(&bamgmesh->CrackedEdges,&bamgmesh->CrackedEdgesSize[0],&bamgmesh->CrackedEdgesSize[1],mxGetAssignedField(dataref,0,"CrackedEdges"));
+	FetchData(&bamgmesh->VerticesOnGeomEdge,&bamgmesh->VerticesOnGeomEdgeSize[0],&bamgmesh->VerticesOnGeomEdgeSize[1],mxGetAssignedField(dataref,0,"VerticesOnGeomEdge"));
+	FetchData(&bamgmesh->VerticesOnGeomVertex,&bamgmesh->VerticesOnGeomVertexSize[0],&bamgmesh->VerticesOnGeomVertexSize[1],mxGetAssignedField(dataref,0,"VerticesOnGeomVertex"));
+	FetchData(&bamgmesh->EdgesOnGeomEdge, &bamgmesh->EdgesOnGeomEdgeSize[0], &bamgmesh->EdgesOnGeomEdgeSize[1], mxGetAssignedField(dataref,0,"EdgesOnGeomEdge"));
+	FetchData(&bamgmesh->IssmSegments,&bamgmesh->IssmSegmentsSize[0],&bamgmesh->IssmSegmentsSize[1],mxGetAssignedField(dataref,0,"IssmSegments"));
+
+	/*Assign output pointers:*/
+	*pbamgmesh=bamgmesh;
+}
+/*}}}*/
+/*FUNCTION FetchData(BamgOpts** pbamgopts,const mxArray* dataref){{{1*/
+void FetchData(BamgOpts** pbamgopts,const mxArray* dataref){
+
+	/*Initialize output*/
+	BamgOpts* bamgopts=new BamgOpts();
+
+	/*Fetch all fields*/
+	FetchData(&bamgopts->anisomax,mxGetField(dataref,0,"anisomax"));
+	FetchData(&bamgopts->cutoff,mxGetField(dataref,0,"cutoff"));
+	FetchData(&bamgopts->coeff,mxGetField(dataref,0,"coeff"));
+	FetchData(&bamgopts->errg,mxGetField(dataref,0,"errg"));
+	FetchData(&bamgopts->gradation,mxGetField(dataref,0,"gradation"));
+	FetchData(&bamgopts->Hessiantype,mxGetField(dataref,0,"Hessiantype"));
+	FetchData(&bamgopts->MaxCornerAngle,mxGetField(dataref,0,"MaxCornerAngle"));
+	FetchData(&bamgopts->maxnbv,mxGetField(dataref,0,"maxnbv"));
+	FetchData(&bamgopts->maxsubdiv,mxGetField(dataref,0,"maxsubdiv"));
+	FetchData(&bamgopts->Metrictype,mxGetField(dataref,0,"Metrictype"));
+	FetchData(&bamgopts->nbjacobi,mxGetField(dataref,0,"nbjacobi"));
+	FetchData(&bamgopts->nbsmooth,mxGetField(dataref,0,"nbsmooth"));
+	FetchData(&bamgopts->omega,mxGetField(dataref,0,"omega"));
+	FetchData(&bamgopts->power,mxGetField(dataref,0,"power"));
+	FetchData(&bamgopts->verbose,mxGetField(dataref,0,"verbose"));
+
+	FetchData(&bamgopts->Crack,mxGetField(dataref,0,"Crack"));
+	FetchData(&bamgopts->geometricalmetric,mxGetField(dataref,0,"geometricalmetric"));
+	FetchData(&bamgopts->KeepVertices,mxGetField(dataref,0,"KeepVertices"));
+	FetchData(&bamgopts->splitcorners,mxGetField(dataref,0,"splitcorners"));
+
+	FetchData(&bamgopts->hmin,mxGetField(dataref,0,"hmin"));
+	FetchData(&bamgopts->hmax,mxGetField(dataref,0,"hmax"));
+	FetchData(&bamgopts->hminVertices,&bamgopts->hminVerticesSize[0],&bamgopts->hminVerticesSize[1],mxGetField(dataref,0,"hminVertices"));
+	FetchData(&bamgopts->hmaxVertices,&bamgopts->hmaxVerticesSize[0],&bamgopts->hmaxVerticesSize[1],mxGetField(dataref,0,"hmaxVertices"));
+	FetchData(&bamgopts->hVertices,&bamgopts->hVerticesSize[0],&bamgopts->hVerticesSize[1],mxGetField(dataref,0,"hVertices"));
+	FetchData(&bamgopts->metric,&bamgopts->metricSize[0],&bamgopts->metricSize[1],mxGetField(dataref,0,"metric"));
+	FetchData(&bamgopts->field,&bamgopts->fieldSize[0],&bamgopts->fieldSize[1],mxGetField(dataref,0,"field"));
+	FetchData(&bamgopts->err,&bamgopts->errSize[0],&bamgopts->errSize[1],mxGetField(dataref,0,"err"));
+
+	/*Additional checks*/
+	bamgopts->Check();
+
+	/*Assign output pointers:*/
+	*pbamgopts=bamgopts;
+}
+/*}}}*/
+/*FUNCTION FetchData(Options** poptions,const mxArray* dataref){{{1*/
+void FetchData(Options** poptions,int istart, int nrhs,const mxArray** pdataref){
+
+	char   *name   = NULL;
+	Option *option = NULL;
+
+	/*Initialize output*/
+	Options* options=new Options();
+
+	/*Fetch all options*/
+	for (int i=istart; i<nrhs; i=i+2){
+		if (!mxIsClass(pdataref[i],"char")) _error_("Argument %d must be name of option",i+1);
+
+		FetchData(&name,pdataref[i]);
+		if(i+1 == nrhs) _error_("Argument %d must exist and be value of option \"%s\".",i+2,name);
+
+		option=(Option*)OptionParse(name,&pdataref[i+1]);
+		options->AddOption(option);
+		option=NULL;
+	}
+
+	/*Assign output pointers:*/
+	*poptions=options;
+}
+/*}}}*/
Index: /issm/branches/trunk-jpl-damage/src/c/matlab/io/MatlabMatrixToDoubleMatrix.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/matlab/io/MatlabMatrixToDoubleMatrix.cpp	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/c/matlab/io/MatlabMatrixToDoubleMatrix.cpp	(revision 12168)
@@ -0,0 +1,101 @@
+/* \file MatlabMatrixToDoubleMatrix.cpp
+ * \brief: convert a sparse or dense matlab matrix to a double* pointer
+ */
+
+
+#ifdef HAVE_CONFIG_H
+	#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+
+/*Matlab includes: */
+#include "mex.h"
+
+#include "../../shared/shared.h"
+
+int MatlabMatrixToDoubleMatrix(double** pmatrix,int* pmatrix_rows,int* pmatrix_cols,const mxArray* mxmatrix){
+
+	int     i,j,count,rows,cols;
+	double *pmxdoublematrix = NULL;
+	float  *pmxsinglematrix = NULL;
+
+	/*output: */
+	double* matrix=NULL;
+
+	/*matlab indices: */
+	mwIndex*    ir=NULL;
+	mwIndex*    jc=NULL;
+
+	/*Ok, first check if we are dealing with a sparse or full matrix: */
+	if (mxIsSparse(mxmatrix)){
+
+		/*Dealing with sparse matrix: recover size first: */
+		pmxdoublematrix=(double*)mxGetPr(mxmatrix);
+		rows=mxGetM(mxmatrix);
+		cols=mxGetN(mxmatrix);
+		
+		if(rows*cols){
+			matrix=(double*)xcalloc(rows*cols,sizeof(double));
+
+			/*Now, get ir,jc and pr: */
+			ir=mxGetIr(mxmatrix);
+			jc=mxGetJc(mxmatrix);
+
+			/*Now, start inserting data into double* matrix: */
+			count=0;
+			for(i=0;i<cols;i++){
+				for(j=0;j<(jc[i+1]-jc[i]);j++){
+					matrix[rows*ir[count]+i]=pmxdoublematrix[count];
+					count++;
+				}
+			}
+		}
+
+	}
+	else if(mxIsClass(mxmatrix,"double")){
+		/*Dealing with dense matrix: recover pointer and size: */
+		pmxdoublematrix=(double*)mxGetPr(mxmatrix);
+		rows=mxGetM(mxmatrix);
+		cols=mxGetN(mxmatrix);
+		
+		/*Create serial matrix: */
+		if(rows*cols){
+			matrix=(double*)xcalloc(rows*cols,sizeof(double));
+
+			for(i=0;i<rows;i++){
+				for(j=0;j<cols;j++){
+					matrix[cols*i+j]=(double)pmxdoublematrix[rows*j+i];
+				}
+			}
+		}
+	}
+	else if(mxIsClass(mxmatrix,"single")){
+		/*Dealing with dense matrix: recover pointer and size: */
+		pmxsinglematrix=(float*)mxGetPr(mxmatrix);
+		rows=mxGetM(mxmatrix);
+		cols=mxGetN(mxmatrix);
+
+		/*Create serial matrix: */
+		if(rows*cols){
+			matrix=(double*)xcalloc(rows*cols,sizeof(double));
+
+			for(i=0;i<rows;i++){
+				for(j=0;j<cols;j++){
+					matrix[cols*i+j]=(double)pmxsinglematrix[rows*j+i];
+				}
+			}
+		}
+	}
+	else{
+		_error_("Matlab matrix type Not implemented yet");
+	}
+
+	/*Assign output pointer: */
+	*pmatrix=matrix;
+	*pmatrix_rows=rows;
+	*pmatrix_cols=cols;
+
+	return 1;
+}
Index: /issm/branches/trunk-jpl-damage/src/c/matlab/io/MatlabMatrixToMatrix.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/matlab/io/MatlabMatrixToMatrix.cpp	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/c/matlab/io/MatlabMatrixToMatrix.cpp	(revision 12168)
@@ -0,0 +1,39 @@
+/*!\file MatlabMatrixToMatrix.cpp
+ */
+
+/*Headers:*/
+/*{{{1*/
+#ifdef HAVE_CONFIG_H
+	#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+#include <mex.h>
+#include <stdio.h>
+#include <string.h>
+#include "./matlabio.h"
+#include "../../objects/objects.h"
+#include "../../shared/shared.h"
+#include "../../Container/Container.h"
+#include "../../include/include.h"
+#include "../../toolkits/toolkits.h"
+	
+/*}}}*/
+
+Matrix* MatlabMatrixToMatrix(const mxArray* mxmatrix){
+
+	int dummy;
+	Matrix* matrix=NULL;
+
+	/*allocate matrix object: */
+	matrix=new Matrix();
+
+	#ifdef _HAVE_PETSC_
+	MatlabMatrixToPetscMatrix(&matrix->matrix,NULL,NULL,mxmatrix);
+	#else
+	matrix->matrix=MatlabMatrixToSeqMat(mxmatrix);
+	#endif
+	
+	return matrix;
+}
Index: /issm/branches/trunk-jpl-damage/src/c/matlab/io/MatlabMatrixToPetscMatrix.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/matlab/io/MatlabMatrixToPetscMatrix.cpp	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/c/matlab/io/MatlabMatrixToPetscMatrix.cpp	(revision 12168)
@@ -0,0 +1,120 @@
+/* \file MatlabMatrixToPetscMatrix.cpp
+ * \brief: convert a sparse or dense matlab matrix to a serial Petsc matrix:
+ */
+
+
+#ifdef HAVE_CONFIG_H
+	#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+
+/*Petsc includes: */
+#include "petscmat.h"
+#include "petscvec.h"
+#include "petscksp.h"
+
+/*Matlab includes: */
+#include "mex.h"
+
+#include "../../shared/shared.h"
+
+int MatlabMatrixToPetscMatrix(Mat* pmatrix,int* pmatrix_rows,int* pmatrix_cols,const mxArray* mxmatrix){
+
+	int rows, cols;
+	double* mxmatrix_ptr=NULL;
+	double* tmatrix=NULL;
+	int ierr;
+	int i,j;
+
+	/*output: */
+	Mat matrix=NULL;
+
+	/*matlab indices: */
+	mwIndex*    ir=NULL;
+	mwIndex*    jc=NULL;
+	double* pr=NULL;
+	int     count;
+	int     nnz;
+	int     nz;
+
+	/*petsc indices: */
+	int* idxm=NULL;
+	int* idxn=NULL;
+	
+	/*Ok, first check if we are dealing with a sparse or full matrix: */
+	if (mxIsSparse(mxmatrix)){
+
+		/*Dealing with sparse matrix: recover size first: */
+		mxmatrix_ptr=(double*)mxGetPr(mxmatrix);
+		rows=mxGetM(mxmatrix);
+		cols=mxGetN(mxmatrix);
+		nnz=mxGetNzmax(mxmatrix);
+		if(rows){
+			nz=(int)((double)nnz/(double)rows);
+		}
+		else{
+			nz=0;
+		}
+
+		ierr=MatCreateSeqAIJ(PETSC_COMM_SELF,rows,cols,nz,PETSC_NULL,&matrix);CHKERRQ(ierr);
+
+		/*Now, get ir,jc and pr: */
+		pr=mxGetPr(mxmatrix);
+		ir=mxGetIr(mxmatrix);
+		jc=mxGetJc(mxmatrix);
+
+		/*Now, start inserting data into sparse matrix: */
+		count=0;
+		for(i=0;i<cols;i++){
+			for(j=0;j<(jc[i+1]-jc[i]);j++){
+				MatSetValue(matrix,ir[count],i,pr[count],INSERT_VALUES);
+				count++;
+			}
+		}
+
+	}
+	else{
+
+		/*Dealing with dense matrix: recover pointer and size: */
+		mxmatrix_ptr=(double*)mxGetPr(mxmatrix);
+		rows=mxGetM(mxmatrix);
+		cols=mxGetN(mxmatrix);
+
+		/*transpose, as Petsc now does not allows MAT_COLUMN_ORIENTED matrices in MatSetValues: */
+		tmatrix=(double*)xmalloc(rows*cols*sizeof(double));
+		for(i=0;i<cols;i++){
+			for(j=0;j<rows;j++){
+				*(tmatrix+rows*i+j)=*(mxmatrix_ptr+cols*j+i);
+			}
+		}
+
+		/*Create serial matrix: */
+		ierr=MatCreateSeqDense(PETSC_COMM_SELF,rows,cols,NULL,&matrix);CHKERRQ(ierr);
+
+		/*Insert mxmatrix_ptr values into petsc matrix: */
+		idxm=(int*)xmalloc(rows*sizeof(int));
+		idxn=(int*)xmalloc(cols*sizeof(int));
+
+		for(i=0;i<rows;i++)idxm[i]=i;
+		for(i=0;i<cols;i++)idxn[i]=i;
+
+		ierr=MatSetValues(matrix,rows,idxm,cols,idxn,tmatrix,INSERT_VALUES); CHKERRQ(ierr);
+
+		xfree((void**)&tmatrix);
+
+	}
+
+	/*Assemble matrix: */
+	MatAssemblyBegin(matrix,MAT_FINAL_ASSEMBLY); 
+	MatAssemblyEnd(matrix,MAT_FINAL_ASSEMBLY);
+
+
+	/*Assign output pointer: */
+	*pmatrix=matrix;
+	if(pmatrix_rows) *pmatrix_rows=rows;
+	if(pmatrix_cols) *pmatrix_cols=cols;
+
+	return 1;
+}
Index: /issm/branches/trunk-jpl-damage/src/c/matlab/io/MatlabMatrixToSeqMat.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/matlab/io/MatlabMatrixToSeqMat.cpp	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/c/matlab/io/MatlabMatrixToSeqMat.cpp	(revision 12168)
@@ -0,0 +1,29 @@
+/*!\file MatlabMatrixToSeqMat.cpp
+ */
+
+/*Headers:*/
+/*{{{1*/
+#ifdef HAVE_CONFIG_H
+	#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+#include <mex.h>
+#include <stdio.h>
+#include <string.h>
+#include "../../toolkits/toolkits.h"
+#include "../../shared/shared.h"
+#include "./matlabio.h"
+
+/*}}}*/
+
+SeqMat* MatlabMatrixToSeqMat(const mxArray* dataref){
+
+	SeqMat* output=NULL;
+
+	output=new SeqMat();
+	MatlabMatrixToDoubleMatrix(&output->matrix,&output->M,&output->N,dataref);
+	return output;
+
+}
Index: /issm/branches/trunk-jpl-damage/src/c/matlab/io/MatlabNArrayToNArray.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/matlab/io/MatlabNArrayToNArray.cpp	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/c/matlab/io/MatlabNArrayToNArray.cpp	(revision 12168)
@@ -0,0 +1,272 @@
+/* \file MatlabNArrayToNArray.cpp
+ * \brief: convert a sparse or dense matlab n-dimensional array to cpp n-dimensional array
+ */
+
+
+#ifdef HAVE_CONFIG_H
+	#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+#include "../../shared/shared.h"
+#include "../../include/include.h"
+
+#include <mex.h>
+
+/*FUNCTION MatlabNArrayToNArray(double** pmatrix,int* pmatrix_numel,int* pmatrix_ndims,int** pmatrix_size,const mxArray* mxmatrix){{{1*/
+int MatlabNArrayToNArray(double** pmatrix,int* pmatrix_numel,int* pmatrix_ndims,int** pmatrix_size,const mxArray* mxmatrix){
+
+	int  i,j,rows,cols;
+	int  numel,ndims;
+	int *size,*dims;
+	double* mxmatrix_ptr=NULL;
+	const mwSize* ipt=NULL;
+
+	/*output: */
+	double* matrix=NULL;
+
+	/*matlab indices: */
+	mwIndex*    ir=NULL;
+	mwIndex*    jc=NULL;
+	double* pr=NULL;
+	int     count;
+	int     nnz;
+	int     nz;
+
+	/*get Matlab matrix information: */
+	numel=mxGetNumberOfElements(mxmatrix);
+	ndims=mxGetNumberOfDimensions(mxmatrix);
+	ipt  =mxGetDimensions(mxmatrix);
+	size =(int *) xcalloc(ndims,sizeof(int));
+	for (i=0; i<ndims; i++) size[i]=(int)ipt[i];
+
+	/*Ok, first check if we are dealing with a sparse or full matrix: */
+	if (mxIsSparse(mxmatrix)){
+
+		/*Dealing with sparse matrix: recover size first: */
+		rows=mxGetM(mxmatrix);
+		cols=mxGetN(mxmatrix);
+		nnz=mxGetNzmax(mxmatrix);
+		nz=(int)((double)nnz/(double)rows);
+
+		matrix=(double*)xcalloc(rows*cols,sizeof(double));
+
+		/*Now, get ir,jc and pr: */
+		ir=mxGetIr(mxmatrix);
+		jc=mxGetJc(mxmatrix);
+		pr=mxGetPr(mxmatrix);
+
+		/*Now, start inserting data into double* matrix: */
+		count=0;
+		for(i=0;i<cols;i++){
+			for(j=0;j<(jc[i+1]-jc[i]);j++){
+				*(matrix+rows*ir[count]+i)=pr[count];
+				count++;
+			}
+		}
+
+	}
+	else{
+
+		/*Dealing with dense matrix: recover pointer and size: */
+		mxmatrix_ptr=(double*)mxGetPr(mxmatrix);
+		
+		/*Create serial matrix: */
+		matrix=(double*)xcalloc(numel,sizeof(double));
+
+		dims=(int *) xcalloc(ndims,sizeof(int));
+		for(i=0;i<numel;i++){
+			ColumnWiseDimsFromIndex(dims,i,size,ndims);
+			j=IndexFromRowWiseDims(dims,size,ndims);
+			*(matrix+j)=*(mxmatrix_ptr+i);
+		}
+		xfree((void**)&dims);
+		
+	}
+
+	/*Assign output pointer: */
+	*pmatrix=matrix;
+	*pmatrix_numel=numel;
+	*pmatrix_ndims=ndims;
+	*pmatrix_size=size;
+
+	return 1;
+}
+/*}}}*/
+/*FUNCTION MatlabNArrayToNArray(bool** pmatrix,int* pmatrix_numel,int* pmatrix_ndims,int** pmatrix_size,const mxArray* mxmatrix){{{1*/
+int MatlabNArrayToNArray(bool** pmatrix,int* pmatrix_numel,int* pmatrix_ndims,int** pmatrix_size,const mxArray* mxmatrix){
+
+	int  i,j,rows,cols;
+	int  numel,ndims;
+	int *size,*dims;
+	bool* mxmatrix_ptr=NULL;
+	const mwSize* ipt=NULL;
+
+	/*output: */
+	bool* matrix=NULL;
+
+	/*matlab indices: */
+	mwIndex*    ir=NULL;
+	mwIndex*    jc=NULL;
+	bool*   pm=NULL;
+	int     count;
+	int     nnz;
+	int     nz;
+
+	/*get Matlab matrix information: */
+	numel=mxGetNumberOfElements(mxmatrix);
+	ndims=mxGetNumberOfDimensions(mxmatrix);
+	ipt  =mxGetDimensions(mxmatrix);
+	size =(int *) xcalloc(ndims,sizeof(int));
+	for (i=0; i<ndims; i++) size[i]=(int)ipt[i];
+
+	/*Ok, first check if we are dealing with a sparse or full matrix: */
+	if (mxIsSparse(mxmatrix)){
+
+		/*Dealing with sparse matrix: recover size first: */
+		rows=mxGetM(mxmatrix);
+		cols=mxGetN(mxmatrix);
+		nnz=mxGetNzmax(mxmatrix);
+		nz=(int)((double)nnz/(double)rows);
+
+		matrix=(bool*)xcalloc(rows*cols,sizeof(bool));
+
+		/*Now, get ir,jc and pm: */
+		ir=mxGetIr(mxmatrix);
+		jc=mxGetJc(mxmatrix);
+		pm=(bool*)mxGetData(mxmatrix);
+
+		/*Now, start inserting data into bool* matrix: */
+		count=0;
+		for(i=0;i<cols;i++){
+			for(j=0;j<(jc[i+1]-jc[i]);j++){
+				*(matrix+rows*ir[count]+i)=pm[count];
+				count++;
+			}
+		}
+
+	}
+	else{
+
+		/*Dealing with dense matrix: recover pointer and size: */
+		mxmatrix_ptr=(bool*)mxGetData(mxmatrix);
+		
+		/*Create serial matrix: */
+		matrix=(bool*)xcalloc(numel,sizeof(bool));
+
+		dims=(int *) xcalloc(ndims,sizeof(int));
+		for(i=0;i<numel;i++){
+			ColumnWiseDimsFromIndex(dims,i,size,ndims);
+			j=IndexFromRowWiseDims(dims,size,ndims);
+			*(matrix+j)=(bool)*(mxmatrix_ptr+i);
+		}
+		xfree((void**)&dims);
+		
+	}
+
+	/*Assign output pointer: */
+	*pmatrix=matrix;
+	*pmatrix_numel=numel;
+	*pmatrix_ndims=ndims;
+	*pmatrix_size=size;
+
+	return 1;
+}
+/*}}}*/
+/*FUNCTION MatlabNArrayToNArray(char** pmatrix,int* pmatrix_numel,int* pmatrix_ndims,int** pmatrix_size,const mxArray* mxmatrix){{{1*/
+int MatlabNArrayToNArray(char** pmatrix,int* pmatrix_numel,int* pmatrix_ndims,int** pmatrix_size,const mxArray* mxmatrix){
+
+	int  i,j,rows,cols;
+	int  numel,ndims;
+	int *size,*dims;
+	mxChar* mxmatrix_ptr=NULL;
+	const mwSize* ipt=NULL;
+
+	/*output: */
+	char* matrix=NULL;
+
+	/*matlab indices: */
+	mwIndex*    ir=NULL;
+	mwIndex*    jc=NULL;
+	char*   pm=NULL;
+	int     count;
+	int     nnz;
+	int     nz;
+
+	/*get Matlab matrix information: */
+	numel=mxGetNumberOfElements(mxmatrix);
+	ndims=mxGetNumberOfDimensions(mxmatrix);
+	ipt  =mxGetDimensions(mxmatrix);
+	size =(int *) xcalloc(ndims,sizeof(int));
+	for (i=0; i<ndims; i++) size[i]=(int)ipt[i];
+
+	/*Ok, first check if we are dealing with a sparse or full matrix: */
+	if (mxIsSparse(mxmatrix)){
+
+		/*Dealing with sparse matrix: recover size first: */
+		rows=mxGetM(mxmatrix);
+		cols=mxGetN(mxmatrix);
+		nnz=mxGetNzmax(mxmatrix);
+		nz=(int)((double)nnz/(double)rows);
+
+		matrix=(char*)xcalloc(rows*cols,sizeof(double));
+
+		/*Now, get ir,jc and pm: */
+		ir=mxGetIr(mxmatrix);
+		jc=mxGetJc(mxmatrix);
+		pm=(char*)mxGetData(mxmatrix);
+
+		/*Now, start inserting data into char* matrix: */
+		count=0;
+		for(i=0;i<cols;i++){
+			for(j=0;j<(jc[i+1]-jc[i]);j++){
+				*(matrix+rows*ir[count]+i)=(char)pm[count];
+				count++;
+			}
+		}
+
+	}
+	else{
+
+		/*Dealing with dense matrix: recover pointer and size: */
+		mxmatrix_ptr=mxGetChars(mxmatrix);
+		
+		/*Create serial matrix: */
+		matrix=(char*)xcalloc(numel+1,sizeof(mxChar));
+
+		/*looping code adapted from Matlab example explore.c: */
+		int elements_per_page = size[0] * size[1];
+		/* total_number_of_pages = size[2] x size[3] x ... x size[N-1] */
+		int total_number_of_pages = 1;
+		for (i=2; i<ndims; i++) {
+			total_number_of_pages *= size[i];
+		}
+
+		i=0;
+		for (int page=0; page < total_number_of_pages; page++) {
+			int row;
+			/* On each page, walk through each row. */
+			for (row=0; row<size[0]; row++)  {
+				int column;
+				j = (page * elements_per_page) + row;
+
+				/* Walk along each column in the current row. */
+				for (column=0; column<size[1]; column++) {
+					*(matrix+i++)=(char)*(mxmatrix_ptr+j);
+					j += size[0];
+				}
+			}
+		}
+
+	}
+
+	/*Assign output pointer: */
+	*pmatrix=matrix;
+	*pmatrix_numel=numel;
+	*pmatrix_ndims=ndims;
+	*pmatrix_size=size;
+
+	return 1;
+}
+/*}}}*/
Index: /issm/branches/trunk-jpl-damage/src/c/matlab/io/MatlabVectorToDoubleVector.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/matlab/io/MatlabVectorToDoubleVector.cpp	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/c/matlab/io/MatlabVectorToDoubleVector.cpp	(revision 12168)
@@ -0,0 +1,96 @@
+/* \file MatlabVectorToDoubleVector.cpp
+ * \brief: convert a sparse or dense matlab vector to a serial vector:
+ */
+
+
+#ifdef HAVE_CONFIG_H
+	#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+
+#include <string.h>
+
+/*Matlab includes: */
+#include "mex.h"
+
+#include "../../shared/shared.h"
+
+int MatlabVectorToDoubleVector(double** pvector,int* pvector_rows,const mxArray* mxvector){
+
+	int rows,cols;
+	double* mxvector_ptr=NULL;
+	int ierr;
+	int i,j;
+
+	/*output: */
+	double* vector=NULL;
+
+	/*matlab indices: */
+	mwIndex*    ir=NULL;
+	mwIndex*    jc=NULL;
+	double* pr=NULL;
+	int     count;
+	int     nnz;
+	int     nz;
+
+	/*Ok, first check if we are dealing with a sparse or full vector: */
+	if (mxIsSparse(mxvector)){
+
+		/*Dealing with sparse vector: recover size first: */
+		mxvector_ptr=(double*)mxGetPr(mxvector);
+		rows=mxGetM(mxvector);
+		cols=mxGetN(mxvector);
+		nnz=mxGetNzmax(mxvector);
+		
+		/*Check that input is actualy a vector*/
+		if (cols!=1) _error_("input vector of size %ix%i should have only one column",rows,cols);
+
+		nz=(int)((double)nnz/(double)rows);
+
+		if(rows){
+			vector=(double*)xcalloc(rows,sizeof(double));
+
+			/*Now, get ir,jc and pr: */
+			pr=mxGetPr(mxvector);
+			ir=mxGetIr(mxvector);
+			jc=mxGetJc(mxvector);
+
+			/*Now, start inserting data into sparse vector: */
+			count=0;
+			for(i=0;i<cols;i++){
+				for(j=0;j<(jc[i+1]-jc[i]);j++){
+					vector[ir[count]]=pr[count];
+					count++;
+				}
+			}
+		}
+
+	}
+	else{
+
+		/*Dealing with dense vector: recover pointer and size: */
+		mxvector_ptr=(double*)mxGetPr(mxvector);
+		rows=mxGetM(mxvector);
+		cols=mxGetN(mxvector);
+
+		/*Check that input is actualy a vector*/
+		if (cols!=1) _error_("input vector of size %ix%i should have only one column",rows,cols);
+
+		/*allocate and memcpy*/
+		if(rows){
+			vector=(double*)xmalloc(rows*sizeof(double));
+			memcpy(vector,mxvector_ptr,rows*sizeof(double));
+		}
+		else{
+			vector=NULL;
+		}
+	}
+
+	/*Assign output pointer: */
+	*pvector=vector;
+	*pvector_rows=rows;
+
+	return 1;
+}
Index: /issm/branches/trunk-jpl-damage/src/c/matlab/io/MatlabVectorToPetscVector.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/matlab/io/MatlabVectorToPetscVector.cpp	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/c/matlab/io/MatlabVectorToPetscVector.cpp	(revision 12168)
@@ -0,0 +1,98 @@
+/* \file MatlabVectorToPetscVector.cpp
+ * \brief: convert a sparse or dense matlab vector to a serial Petsc vector:
+ */
+
+
+#ifdef HAVE_CONFIG_H
+	#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+/*Petsc includes: */
+#include "petscmat.h"
+#include "petscvec.h"
+#include "petscksp.h"
+
+/*Matlab includes: */
+#include "mex.h"
+
+#include "../../shared/shared.h"
+
+int MatlabVectorToPetscVector(Vec* pvector,int* pvector_rows,const mxArray* mxvector){
+
+	int rows, cols;
+	double* mxvector_ptr=NULL;
+	int ierr;
+	int i,j;
+
+	/*output: */
+	Vec vector=NULL;
+
+	/*matlab indices: */
+	mwIndex*    ir=NULL;
+	mwIndex*    jc=NULL;
+	double* pr=NULL;
+	int     count;
+	int     nnz;
+	int     nz;
+
+	/*petsc indices: */
+	int* idxm=NULL;
+	
+	/*Ok, first check if we are dealing with a sparse or full vector: */
+	if (mxIsSparse(mxvector)){
+
+		/*Dealing with sparse vector: recover size first: */
+		mxvector_ptr=(double*)mxGetPr(mxvector);
+		rows=mxGetM(mxvector);
+		cols=mxGetN(mxvector);
+		nnz=mxGetNzmax(mxvector);
+		nz=(int)((double)nnz/(double)rows);
+
+		ierr=VecCreateSeq(PETSC_COMM_SELF,rows,&vector);CHKERRQ(ierr);
+
+		/*Now, get ir,jc and pr: */
+		pr=mxGetPr(mxvector);
+		ir=mxGetIr(mxvector);
+		jc=mxGetJc(mxvector);
+
+		/*Now, start inserting data into sparse vector: */
+		count=0;
+		for(i=0;i<cols;i++){
+			for(j=0;j<(jc[i+1]-jc[i]);j++){
+				VecSetValue(vector,ir[count],pr[count],INSERT_VALUES);
+				count++;
+			}
+		}
+
+	}
+	else{
+
+		/*Dealing with dense vector: recover pointer and size: */
+		mxvector_ptr=(double*)mxGetPr(mxvector);
+		rows=mxGetM(mxvector);
+		cols=mxGetN(mxvector);
+
+		/*Create serial vector: */
+		ierr=VecCreateSeq(PETSC_COMM_SELF,rows,&vector);CHKERRQ(ierr);
+
+		/*Insert mxvector_ptr values into petsc vector: */
+		idxm=(int*)xmalloc(rows*sizeof(int));
+
+		for(i=0;i<rows;i++)idxm[i]=i;
+
+		ierr=VecSetValues(vector,rows,idxm,mxvector_ptr,INSERT_VALUES);CHKERRQ(ierr);
+
+	}
+
+	/*Assemble vector: */
+	VecAssemblyBegin(vector);
+	VecAssemblyEnd(vector);
+
+	/*Assign output pointer: */
+	*pvector=vector;
+	*pvector_rows=rows;
+
+	return 1;
+}
Index: /issm/branches/trunk-jpl-damage/src/c/matlab/io/MatlabVectorToSeqVec.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/matlab/io/MatlabVectorToSeqVec.cpp	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/c/matlab/io/MatlabVectorToSeqVec.cpp	(revision 12168)
@@ -0,0 +1,29 @@
+/*!\file MatlabVectorToSeqVec.cpp
+ */
+
+/*Headers:*/
+/*{{{1*/
+#ifdef HAVE_CONFIG_H
+	#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+#include <mex.h>
+#include <stdio.h>
+#include <string.h>
+#include "../../toolkits/toolkits.h"
+#include "../../shared/shared.h"
+#include "./matlabio.h"
+
+/*}}}*/
+
+SeqVec* MatlabVectorToSeqVec(const mxArray* dataref){
+
+	SeqVec* output=NULL;
+
+	output=new SeqVec();
+	MatlabVectorToDoubleVector(&output->vector,&output->M,dataref);
+	return output;
+
+}
Index: /issm/branches/trunk-jpl-damage/src/c/matlab/io/MatlabVectorToVector.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/matlab/io/MatlabVectorToVector.cpp	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/c/matlab/io/MatlabVectorToVector.cpp	(revision 12168)
@@ -0,0 +1,39 @@
+/*!\file MatlabVectorToVector.cpp
+ */
+
+/*Headers:*/
+/*{{{1*/
+#ifdef HAVE_CONFIG_H
+	#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+#include <mex.h>
+#include <stdio.h>
+#include <string.h>
+#include "./matlabio.h"
+#include "../../objects/objects.h"
+#include "../../shared/shared.h"
+#include "../../Container/Container.h"
+#include "../../include/include.h"
+#include "../../toolkits/toolkits.h"
+	
+/*}}}*/
+
+Vector* MatlabVectorToVector(const mxArray* mxvector){
+
+	int dummy;
+	Vector* vector=NULL;
+
+	/*allocate vector object: */
+	vector=new Vector();
+
+	#ifdef _HAVE_PETSC_
+	MatlabVectorToPetscVector(&vector->vector,&dummy,mxvector);
+	#else
+	vector->vector=MatlabVectorToSeqVec(mxvector);
+	#endif
+	
+	return vector;
+}
Index: /issm/branches/trunk-jpl-damage/src/c/matlab/io/OptionParse.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/matlab/io/OptionParse.cpp	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/c/matlab/io/OptionParse.cpp	(revision 12168)
@@ -0,0 +1,191 @@
+/*\file OptionParse.c
+ *\brief: functions to parse the mex options.
+ */
+#ifdef HAVE_CONFIG_H
+    #include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+#include "../../shared/shared.h"
+#include "../../io/io.h"
+#include "../../include/include.h"
+#include "./matlabio.h"
+
+#include <mex.h>
+
+/*FUNCTION OptionDoubleParse {{{1*/
+OptionDouble* OptionDoubleParse( char* name, const mxArray* prhs[]){
+
+	OptionDouble *odouble = NULL;
+
+	/*check and parse the name  */
+	odouble=new OptionDouble;
+	odouble->name =(char *) xmalloc((strlen(name)+1)*sizeof(char));
+	memcpy(odouble->name,name,(strlen(name)+1)*sizeof(char));
+
+	/*check and parse the value  */
+	if (!mxIsClass(prhs[0],"double")){
+		_error_("Value of option \"%s\" must be class \"%s\", not class \"%s\".",odouble->name,"double",odouble->name,mxGetClassName(prhs[0]));
+	}
+
+	FetchData(&odouble->values,&odouble->numel,&odouble->ndims,&odouble->size,prhs[0]);
+
+	return(odouble);
+}/*}}}*/
+/*FUNCTION OptionLogicalParse {{{1*/
+OptionLogical* OptionLogicalParse( char* name, const mxArray* prhs[]){
+
+	OptionLogical *ological = NULL;
+
+	/*check and parse the name  */
+	ological=new OptionLogical;
+	ological->name =(char *) xmalloc((strlen(name)+1)*sizeof(char));
+	memcpy(ological->name,name,(strlen(name)+1)*sizeof(char));
+
+	/*check and parse the value  */
+	if (!mxIsClass(prhs[0],"logical")){
+		_error_("Value of option \"%s\" must be class \"%s\", not class \"%s\".",ological->name,"logical",ological->name,mxGetClassName(prhs[0]));
+	}
+
+	FetchData(&ological->values,&ological->numel,&ological->ndims,&ological->size,prhs[0]);
+
+	return(ological);
+}/*}}}*/
+/*FUNCTION OptionCharParse {{{1*/
+OptionChar* OptionCharParse( char* name, const mxArray* prhs[]){
+
+	OptionChar  *ochar = NULL;
+
+	/*check and parse the name  */
+	ochar=new OptionChar;
+	ochar->name =(char *) xmalloc((strlen(name)+1)*sizeof(char));
+	memcpy(ochar->name,name,(strlen(name)+1)*sizeof(char));
+
+	/*check and parse the value  */
+	if (!mxIsClass(prhs[0],"char")){
+		_error_("Value of option \"%s\" must be class \"%s\", not class \"%s\".",ochar->name,"char",ochar->name,mxGetClassName(prhs[0]));
+	}
+
+	FetchData(&ochar->values,&ochar->numel,&ochar->ndims,&ochar->size,prhs[0]);
+
+	return(ochar);
+}/*}}}*/
+/*FUNCTION OptionStructParse {{{1*/
+OptionStruct* OptionStructParse( char* name, const mxArray* prhs[]){
+
+	int            i;
+	char           namei[161];
+	OptionStruct  *ostruct    = NULL;
+	Option        *option     = NULL;
+	const mwSize  *ipt        = NULL;
+	const mxArray *structi;
+	mwIndex        sindex;
+
+	/*check and parse the name  */
+	ostruct=new OptionStruct;
+	ostruct->name =(char*)xmalloc((strlen(name)+1)*sizeof(char));
+	memcpy(ostruct->name,name,(strlen(name)+1)*sizeof(char));
+
+	/*check and parse the value  */
+	if (!mxIsClass(prhs[0],"struct")){
+		_error_("Value of option \"%s\" must be class \"%s\", not class \"%s\".",ostruct->name,"struct",ostruct->name,mxGetClassName(prhs[0]));
+	}
+
+	ostruct->numel=mxGetNumberOfElements(prhs[0]);
+	ostruct->ndims=mxGetNumberOfDimensions(prhs[0]);
+	ipt           =mxGetDimensions(prhs[0]);
+	ostruct->size =(int *) xmalloc(ostruct->ndims*sizeof(int));
+	for (i=0; i<ostruct->ndims; i++) ostruct->size[i]=(int)ipt[i];
+	if (ostruct->numel) ostruct->values=(Options**) xmalloc(ostruct->numel*sizeof(Options *));
+
+	/*loop through and process each element of the struct array  */
+	for (sindex=0; sindex<ostruct->numel; sindex++) {
+		ostruct->values[sindex]=new Options;
+
+		/*loop through and process each field for the element  */
+		for (i=0; i<mxGetNumberOfFields(prhs[0]); i++) {
+			sprintf(namei,"%s.%s",name,mxGetFieldNameByNumber(prhs[0],i));
+			structi=mxGetFieldByNumber(prhs[0],sindex,i);
+
+			option=(Option*)OptionParse(namei,&structi);
+			ostruct->values[sindex]->AddObject((Object*)option);
+			option=NULL;
+		}
+	}
+
+	return(ostruct);
+}/*}}}*/
+/*FUNCTION OptionCellParse {{{1*/
+OptionCell* OptionCellParse( char* name, const mxArray* prhs[]){
+
+	int            i;
+	int           *dims;
+	char           namei[161];
+	char           cstr[81];
+	OptionCell    *ocell      = NULL;
+	Option        *option     = NULL;
+	const mwSize  *ipt        = NULL;
+	const mxArray *celli;
+	mwIndex        cindex;
+
+	/*check and parse the name  */
+	ocell=new OptionCell;
+	ocell->name =(char *) xmalloc((strlen(name)+1)*sizeof(char));
+	memcpy(ocell->name,name,(strlen(name)+1)*sizeof(char));
+
+	/*check and parse the value  */
+	if (!mxIsClass(prhs[0],"cell")){
+		_error_("Value of option \"%s\" must be class \"%s\", not class \"%s\".",ocell->name,"cell",ocell->name,mxGetClassName(prhs[0]));
+	}
+
+	ocell->numel=mxGetNumberOfElements(prhs[0]);
+	ocell->ndims=mxGetNumberOfDimensions(prhs[0]);
+	ipt         =mxGetDimensions(prhs[0]);
+	ocell->size =(int *) xmalloc(ocell->ndims*sizeof(int));
+	for (i=0; i<ocell->ndims; i++) ocell->size[i]=(int)ipt[i];
+	ocell->values=new Options;
+
+	/*loop through and process each element of the cell array  */
+	dims=(int *) xmalloc(ocell->ndims*sizeof(int));
+	for (cindex=0; cindex<ocell->numel; cindex++) {
+		ColumnWiseDimsFromIndex(dims,(int)cindex,ocell->size,ocell->ndims);
+		StringFromDims(cstr,dims,ocell->ndims);
+		#ifdef _INTEL_WIN_
+			_snprintf(namei,161,"%s%s",name,cstr);
+		#else
+			snprintf(namei,161,"%s%s",name,cstr);
+		#endif
+		celli=mxGetCell(prhs[0],cindex);
+
+		option=(Option*)OptionParse(namei,&celli);
+		ocell->values->AddObject((Object*)option);
+		option=NULL;
+	}
+	xfree((void**)&dims);
+
+	return(ocell);
+}/*}}}*/
+/*FUNCTION OptionParse{{{1*/
+Option* OptionParse(char* name, const mxArray* prhs[]){
+
+	Option *option = NULL;
+	mxArray       *lhs[1];
+
+	/*parse the value according to the matlab data type  */
+	if     (mxIsClass(prhs[0],"double"))  option=(Option*)OptionDoubleParse(name,prhs);
+	else if(mxIsClass(prhs[0],"logical")) option=(Option*)OptionLogicalParse(name,prhs);
+	else if(mxIsClass(prhs[0],"char"))    option=(Option*)OptionCharParse(name,prhs);
+	else if(mxIsClass(prhs[0],"struct"))  option=(Option*)OptionStructParse(name,prhs);
+	else if(mxIsClass(prhs[0],"cell"))    option=(Option*)OptionCellParse(name,prhs);
+	else {
+		_printf_(true,"  Converting value of option \"%s\" from unrecognized class \"%s\" to class \"%s\".\n",name,mxGetClassName(prhs[0]),"struct");
+		if (!mexCallMATLAB(1,lhs,1,(mxArray**)prhs,"struct")) {
+			option=(Option*)OptionStructParse(name,(const mxArray**)lhs);
+			mxDestroyArray(lhs[0]);
+		}
+		else _error_("Second argument value of option \"%s\" is of unrecognized class \"%s\".",name,mxGetClassName(prhs[0]));
+	}
+
+	return(option);
+}/*}}}*/
Index: /issm/branches/trunk-jpl-damage/src/c/matlab/io/PrintfFunction.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/matlab/io/PrintfFunction.cpp	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/c/matlab/io/PrintfFunction.cpp	(revision 12168)
@@ -0,0 +1,58 @@
+/*\file PrintfFunction.c
+ *\brief: this function is used by the _printf_ macro, to take into account the 
+ *fact we may be running on a cluster. 
+ */
+
+#include <stdarg.h>
+#include <stdio.h>
+#include "../../shared/shared.h"
+#include "../../include/include.h"
+
+#include "mex.h"
+
+int PrintfFunction(char* format,...){
+	/*http://linux.die.net/man/3/vsnprintf*/
+
+	/*string to be printed: */
+	char *buffer = NULL;
+	int   n,size = 100;
+	int         string_size;
+	extern int  my_rank;
+	extern int  num_procs;
+                                                                                                                                                                                                     
+	//variable list of arguments
+	va_list args;
+
+	while(true){
+
+		/*allocate buffer for given string size*/
+		buffer=(char*)xmalloc(size*sizeof(char));
+
+		/* Try to print in the allocated space. */
+		va_start(args, format);
+#ifndef WIN32
+		n=vsnprintf(buffer,size,format,args);
+#else
+		n=vsnprintf(buffer,size,format,args);
+#endif
+		va_end(args);
+
+		/* If that worked, return the string. */
+		if(n>-1 && n<size) break;
+
+		/* Else try again with more space. */
+		if(n>-1)   /* glibc 2.1 */
+		 size=n+1; /* precisely what is needed */
+		else       /* glibc 2.0 */
+		 size*=2;  /* twice the old size */
+
+		xfree((void**)&buffer);
+	}
+
+	/*Ok, if we are running in parallel, get node 0 to print*/
+	if(my_rank==0)printf(buffer);
+
+	/*Clean up and return*/
+	xfree((void**)&buffer);
+	return 1;
+}
Index: /issm/branches/trunk-jpl-damage/src/c/matlab/io/WriteMatlabData.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/matlab/io/WriteMatlabData.cpp	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/c/matlab/io/WriteMatlabData.cpp	(revision 12168)
@@ -0,0 +1,310 @@
+/* \file WriteData.c:
+ * \brief: general interface for writing data
+ */
+
+#ifdef HAVE_CONFIG_H
+	#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+#include "../../include/include.h"
+#include "../../shared/shared.h"
+#include "./matlabio.h"
+
+#include <mex.h>
+
+
+/*Primitive data types*/
+/*FUNCTION WriteData(mxArray** pdataref,double* matrix, int M,int N){{{1*/
+void WriteData(mxArray** pdataref,double* matrix, int M,int N){
+
+	mxArray *dataref  = NULL;
+	double  *tmatrix  = NULL;
+		
+	if(matrix){
+		/*create the matlab matrixwith Matlab's memory manager */   
+		tmatrix=(double*)mxMalloc(M*N*sizeof(double));
+		for(int i=0;i<M;i++){
+			for(int j=0;j<N;j++){
+				tmatrix[j*M+i]=matrix[i*N+j];
+			}
+		}
+		dataref = mxCreateDoubleMatrix(0,0,mxREAL);
+		mxSetM(dataref,(mwSize)M);
+		mxSetN(dataref,(mwSize)N);
+		mxSetPr(dataref,(double*)tmatrix);
+	}
+	else{
+		dataref = mxCreateDoubleMatrix(0,0,mxREAL);
+	}
+	*pdataref=dataref;
+}
+/*}}}*/
+/*FUNCTION WriteData(mxArray** pdataref,int* matrix, int M,int N){{{1*/
+void WriteData(mxArray** pdataref,int* matrix, int M,int N){
+
+	mxArray* dataref = NULL;
+	double*  tmatrix = NULL;
+
+	if(matrix){
+		/*convert to double matrix using Matlab's memory manager*/
+		double* tmatrix=(double*)mxMalloc(M*N*sizeof(double));
+		for(int i=0;i<M;i++){
+			for(int j=0;j<N;j++){
+				tmatrix[j*M+i]=(double)matrix[i*N+j];
+			}
+		}
+		dataref = mxCreateDoubleMatrix(0,0,mxREAL);
+		mxSetM(dataref,(mwSize)M);
+		mxSetN(dataref,(mwSize)N);
+		mxSetPr(dataref,(double*)tmatrix);
+	}
+	else{
+		dataref = mxCreateDoubleMatrix(0,0,mxREAL);
+	}
+	*pdataref=dataref;
+}
+/*}}}*/
+/*FUNCTION WriteData(mxArray** pdataref,double* vector, int M){{{1*/
+void WriteData(mxArray** pdataref,double* vector, int M){
+	
+	mxArray* dataref       = NULL;
+	double*  vector_matlab = NULL;
+
+	if(vector){
+
+		/*create the matlab vector with Matlab's memory manager */
+		vector_matlab=(double*)mxMalloc(M*sizeof(double));
+		for(int i=0;i<M;i++) vector_matlab[i]=vector[i];
+		dataref = mxCreateDoubleMatrix(0,0,mxREAL);
+		mxSetM(dataref,(mwSize)M);
+		mxSetN(dataref,(mwSize)1);
+		mxSetPr(dataref,vector_matlab);
+	}
+	else{
+		dataref = mxCreateDoubleMatrix(0,0,mxREAL);
+	}
+
+	*pdataref=dataref;
+}
+/*}}}*/
+/*FUNCTION WriteData(mxArray** pdataref,double scalar){{{1*/
+void WriteData(mxArray** pdataref,double scalar){
+
+	*pdataref=mxCreateDoubleScalar(scalar);
+}
+/*}}}*/
+/*FUNCTION WriteData(mxArray** pdataref,int integer){{{1*/
+void WriteData(mxArray** pdataref,int integer){
+
+		*pdataref=mxCreateDoubleScalar((double)integer);
+
+}
+/*}}}*/
+/*FUNCTION WriteData(mxArray** pdataref,int boolean){{{1*/
+void WriteData(mxArray** pdataref,bool boolean){
+
+	*pdataref=mxCreateDoubleScalar((double)boolean);
+
+}
+/*}}}*/
+/*FUNCTION WriteData(mxArray** pdataref,char* string){{{1*/
+void WriteData(mxArray** pdataref,char* string){
+
+		*pdataref=mxCreateString(string);
+}
+/*}}}*/
+
+/*ISSM objects*/
+/*FUNCTION WriteData(mxArray** pdataref,BamgGeom* bamggeom){{{1*/
+void WriteData(mxArray** pdataref,BamgGeom* bamggeom){
+
+	/*Intermediary*/
+	int         i;
+	mxArray    *dataref           = NULL;
+	const int   numfields         = 7;
+	const char *fnames[numfields];
+	mwSize      ndim              = 2;
+	mwSize      dimensions[2]     = {1,1};
+
+	/*Initialize field names*/
+	i=0;
+	fnames[i++] = "Vertices";
+	fnames[i++] = "Edges";
+	fnames[i++] = "TangentAtEdges";
+	fnames[i++] = "RequiredVertices";
+	fnames[i++] = "RequiredEdges";
+	fnames[i++] = "CrackedEdges";
+	fnames[i++] = "SubDomains";
+	_assert_(i==numfields);
+
+	/*Initialize Matlab structure*/
+	dataref=mxCreateStructArray(ndim,dimensions,numfields,fnames);
+
+	/*set each matlab each field*/
+	i=0;
+	i++; SetStructureField(dataref,"Vertices",        bamggeom->VerticesSize[0],        bamggeom->VerticesSize[1],        bamggeom->Vertices);
+	i++; SetStructureField(dataref,"Edges",           bamggeom->EdgesSize[0],           bamggeom->EdgesSize[1],           bamggeom->Edges);
+	i++; SetStructureField(dataref,"TangentAtEdges",  bamggeom->TangentAtEdgesSize[0],  bamggeom->TangentAtEdgesSize[1],  bamggeom->TangentAtEdges);
+	i++; SetStructureField(dataref,"RequiredVertices",bamggeom->RequiredVerticesSize[0],bamggeom->RequiredVerticesSize[1],bamggeom->RequiredVertices);
+	i++; SetStructureField(dataref,"RequiredEdges",   bamggeom->RequiredEdgesSize[0],   bamggeom->RequiredEdgesSize[1],   bamggeom->RequiredEdges);
+	i++; SetStructureField(dataref,"CrackedEdges",    bamggeom->CrackedEdgesSize[0],    bamggeom->CrackedEdgesSize[1],    bamggeom->CrackedEdges);
+	i++; SetStructureField(dataref,"SubDomains",      bamggeom->SubDomainsSize[0],      bamggeom->SubDomainsSize[1],      bamggeom->SubDomains);
+	_assert_(i==numfields);
+
+	/*Assign output*/
+	*pdataref=dataref;
+}
+/*}}}*/
+/*FUNCTION WriteData(mxArray** pdataref,BamgMesh* bamgmesh){{{1*/
+void WriteData(mxArray** pdataref,BamgMesh* bamgmesh){
+
+	/*Intermediary*/
+	int         i;
+	mxArray    *dataref           = NULL;
+	const int   numfields         = 16;
+	const char *fnames[numfields];
+	mwSize      ndim              = 2;
+	mwSize      dimensions[2]     = {1,1};
+
+	/*Initialize field names*/
+	i=0;
+	fnames[i++] = "Triangles";
+	fnames[i++] = "Vertices";
+	fnames[i++] = "Edges";
+	fnames[i++] = "IssmSegments";
+	fnames[i++] = "IssmEdges";
+	fnames[i++] = "Quadrilaterals";
+	fnames[i++] = "VerticesOnGeomVertex";
+	fnames[i++] = "VerticesOnGeomEdge";
+	fnames[i++] = "EdgesOnGeomEdge";
+	fnames[i++] = "SubDomains";
+	fnames[i++] = "SubDomainsFromGeom";
+	fnames[i++] = "ElementConnectivity";
+	fnames[i++] = "NodalConnectivity";
+	fnames[i++] = "NodalElementConnectivity";
+	fnames[i++] = "CrackedVertices";
+	fnames[i++] = "CrackedEdges";
+	_assert_(i==numfields);
+
+	/*Initialize Matlab structure*/
+	dataref=mxCreateStructArray(ndim,dimensions,numfields,fnames);
+
+	/*set each matlab each field*/
+	i=0;
+	i++; SetStructureField(dataref,"Triangles", bamgmesh->TrianglesSize[0],bamgmesh->TrianglesSize[1], bamgmesh->Triangles);
+	i++; SetStructureField(dataref,"Vertices",bamgmesh->VerticesSize[0], bamgmesh->VerticesSize[1],bamgmesh->Vertices);
+	i++; SetStructureField(dataref,"Edges", bamgmesh->EdgesSize[0],bamgmesh->EdgesSize[1], bamgmesh->Edges);
+	i++; SetStructureField(dataref,"IssmSegments",bamgmesh->IssmSegmentsSize[0], bamgmesh->IssmSegmentsSize[1],bamgmesh->IssmSegments);
+	i++; SetStructureField(dataref,"IssmEdges", bamgmesh->IssmEdgesSize[0],bamgmesh->IssmEdgesSize[1], bamgmesh->IssmEdges);
+	i++; SetStructureField(dataref,"Quadrilaterals",bamgmesh->QuadrilateralsSize[0], bamgmesh->QuadrilateralsSize[1],bamgmesh->Quadrilaterals);
+	i++; SetStructureField(dataref,"VerticesOnGeomVertex",bamgmesh->VerticesOnGeomVertexSize[0],bamgmesh->VerticesOnGeomVertexSize[1], bamgmesh->VerticesOnGeomVertex);
+	i++; SetStructureField(dataref,"VerticesOnGeomEdge",bamgmesh->VerticesOnGeomEdgeSize[0],bamgmesh->VerticesOnGeomEdgeSize[1], bamgmesh->VerticesOnGeomEdge);
+	i++; SetStructureField(dataref,"EdgesOnGeomEdge", bamgmesh->EdgesOnGeomEdgeSize[0], bamgmesh->EdgesOnGeomEdgeSize[1],bamgmesh->EdgesOnGeomEdge);
+	i++; SetStructureField(dataref,"SubDomains",bamgmesh->SubDomainsSize[0], bamgmesh->SubDomainsSize[1],bamgmesh->SubDomains);
+	i++; SetStructureField(dataref,"SubDomainsFromGeom", bamgmesh->SubDomainsFromGeomSize[0], bamgmesh->SubDomainsFromGeomSize[1],bamgmesh->SubDomainsFromGeom);
+	i++; SetStructureField(dataref,"ElementConnectivity",bamgmesh->ElementConnectivitySize[0],bamgmesh->ElementConnectivitySize[1], bamgmesh->ElementConnectivity);
+	i++; SetStructureField(dataref,"NodalConnectivity",bamgmesh->NodalConnectivitySize[0],bamgmesh->NodalConnectivitySize[1], bamgmesh->NodalConnectivity);
+	i++; SetStructureField(dataref,"NodalElementConnectivity", bamgmesh->NodalElementConnectivitySize[0], bamgmesh->NodalElementConnectivitySize[1],bamgmesh->NodalElementConnectivity);
+	i++; SetStructureField(dataref,"CrackedVertices", bamgmesh->CrackedVerticesSize[0],bamgmesh->CrackedVerticesSize[1], bamgmesh->CrackedVertices);
+	i++; SetStructureField(dataref,"CrackedEdges",bamgmesh->CrackedEdgesSize[0], bamgmesh->CrackedEdgesSize[1],bamgmesh->CrackedEdges);
+	_assert_(i==numfields);
+
+	/*Assign output*/
+	*pdataref=dataref;
+}
+/*}}}*/
+/*FUNCTION WriteData(mxArray** pdataref,Matrix* matrix){{{1*/
+void WriteData(mxArray** pdataref,Matrix* matrix){
+		
+	int      i,j;
+	int      rows,cols;
+	mxArray *dataref     = NULL;
+	double  *matrix_ptr  = NULL;
+	double  *tmatrix_ptr = NULL;
+	
+	if(matrix){
+		
+		#ifdef _HAVE_PETSC_
+		PetscMatrixToDoubleMatrix(&matrix_ptr,&rows,&cols,matrix->matrix);
+		#else
+		matrix_ptr=matrix->matrix->ToSerial();
+		matrix->matrix->GetSize(&rows,&cols);
+		#endif
+
+		/*Now transpose the matrix and allocate with Matlab's memory manager: */
+		tmatrix_ptr=(double*)mxMalloc(rows*cols*sizeof(double));
+		for(i=0;i<rows;i++){
+			for(j=0;j<cols;j++){
+				tmatrix_ptr[j*rows+i]=matrix_ptr[i*cols+j];
+			}
+		}
+		
+		/*create matlab matrix: */
+		dataref=mxCreateDoubleMatrix(0,0,mxREAL);
+		mxSetM(dataref,rows); 
+		mxSetN(dataref,cols);
+		mxSetPr(dataref,tmatrix_ptr);
+
+		/*Free ressources:*/
+		xfree((void**)&matrix_ptr);
+
+	}
+	else{
+		dataref = mxCreateDoubleMatrix(0,0,mxREAL);
+	}
+
+	*pdataref=dataref;
+}
+/*}}}*/
+/*FUNCTION WriteData(mxArray** pdataref,Vector* vector){{{1*/
+void WriteData(mxArray** pdataref,Vector* vector){
+	
+	mxArray* dataref=NULL;
+	double*  vector_ptr=NULL;
+	double*  vector_matlab=NULL;
+	int      rows;
+	
+	if(vector){
+		/*call toolkit routine: */
+		#ifdef _HAVE_PETSC_
+		PetscVectorToDoubleVector(&vector_ptr,&rows,vector->vector);
+		#else
+		vector_ptr=vector->vector->ToMPISerial();
+		vector->vector->GetSize(&rows);
+		#endif
+		
+		/*now create the matlab vector with Matlab's memory manager */
+		vector_matlab=(double*)mxMalloc(rows*sizeof(double));
+		for(int i=0;i<rows;i++) vector_matlab[i]=vector_ptr[i];
+
+		dataref = mxCreateDoubleMatrix(0,0,mxREAL);                         
+		mxSetM(dataref,rows);
+		mxSetN(dataref,1);                                                                                          
+		mxSetPr(dataref,vector_matlab);           
+	}
+	else{
+		dataref = mxCreateDoubleMatrix(0,0,mxREAL);
+	}
+
+	/*Clean-up and return*/
+	xfree((void**)&vector_ptr);
+	*pdataref=dataref;
+}
+/*}}}*/
+
+/*Toolkit*/
+/*FUNCTION SetStructureField{{{1*/
+void SetStructureField(mxArray* dataref,const char* fieldname,int M,int N,double* fieldpointer){
+
+	mxArray* field = NULL;
+
+
+	/*Convert field*/
+	WriteData(&field,fieldpointer,M,N);
+
+	/*Assign to structure*/
+	mxSetField(dataref,0,fieldname,field);
+}
+/*}}}*/
Index: /issm/branches/trunk-jpl-damage/src/c/matlab/io/matlabio.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/matlab/io/matlabio.h	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/c/matlab/io/matlabio.h	(revision 12168)
@@ -0,0 +1,86 @@
+/*\file matlabio.h
+ *\brief: I/O for ISSM in matlab mode
+ */
+
+#ifndef _MATLAB_IO_H_
+#define _MATLAB_IO_H_
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif 
+
+#include "../../objects/objects.h"
+#include "../../Container/Container.h"
+#include "../../include/include.h"
+
+#include <mex.h>
+
+void WriteData(mxArray** pdataref,Matrix* matrix);
+void WriteData(mxArray** pdataref,double* matrix, int M,int N);
+void WriteData(mxArray** pdataref,int*    matrix, int M,int N);
+void WriteData(mxArray** pdataref,Vector* vector);
+void WriteData(mxArray** pdataref,double* vector, int M);
+void WriteData(mxArray** pdataref,int integer);
+void WriteData(mxArray** pdataref,bool boolean);
+void WriteData(mxArray** pdataref,double scalar);
+void WriteData(mxArray** pdataref,char* string);
+void WriteData(mxArray** pdataref,BamgGeom* bamggeom);
+void WriteData(mxArray** pdataref,BamgMesh* bamgmesh);
+
+void FetchData(double** pmatrix,int* pM,int *pN,const mxArray* dataref);
+void FetchData(double** pmatrix,int* pnumel,int* pndims,int** psize,const mxArray* dataref);
+void FetchData(int** pmatrix,int* pM,int *pN,const mxArray* dataref);
+void FetchData(bool** pmatrix,int* pM,int *pN,const mxArray* dataref);
+void FetchData(bool** pmatrix,int* pnumel,int* pndims,int** psize,const mxArray* dataref);
+void FetchData(Matrix** pmatrix,const mxArray* dataref);
+void FetchData(int** pvector,int* pM,const mxArray* dataref);
+void FetchData(float** pvector,int* pM,const mxArray* dataref);
+void FetchData(double** pvector,int* pM,const mxArray* dataref);
+void FetchData(bool** pvector,int* pM,const mxArray* dataref);
+void FetchData(Vector** pvector,const mxArray* dataref);
+void FetchData(char** pstring,const mxArray* dataref);
+void FetchData(char** pmatrix,int* pnumel,int* pndims,int** psize,const mxArray* dataref);
+void FetchData(double* pscalar,const mxArray* dataref);
+void FetchData(int* pinteger,const mxArray* dataref);
+void FetchData(bool* pbool,const mxArray* dataref);
+void FetchData(BamgGeom** bamggeom,const mxArray* dataref);
+void FetchData(BamgMesh** bamgmesh,const mxArray* dataref);
+void FetchData(BamgOpts** bamgopts,const mxArray* dataref);
+void FetchData(Options** poptions,int istart, int nrhs,const mxArray** pdataref);
+
+Option* OptionParse(char* name, const mxArray* prhs[]);
+OptionDouble*   OptionDoubleParse( char* name, const mxArray* prhs[]);
+OptionLogical*  OptionLogicalParse( char* name, const mxArray* prhs[]);
+OptionChar*     OptionCharParse( char* name, const mxArray* prhs[]);
+OptionStruct*   OptionStructParse( char* name, const mxArray* prhs[]);
+OptionCell*     OptionCellParse( char* name, const mxArray* prhs[]);
+
+mxArray* mxGetAssignedField(const mxArray* pmxa_array,int number, const char* field);
+void SetStructureField(mxArray* dataref,const char* fieldname,int fieldrows,int fieldcols,double* fieldpointer);
+int CheckNumMatlabArguments(int nlhs,int NLHS, int nrhs,int NRHS, const char* THISFUNCTION, void (*function)( void ));
+
+/*Matlab to Matrix routines: */
+Matrix* MatlabMatrixToMatrix(const mxArray* mxmatrix);
+Vector* MatlabVectorToVector(const mxArray* mxvector);
+
+/*Matlab to double* routines: */
+int MatlabVectorToDoubleVector(double** pvector,int* pvector_rows,const mxArray* mxvector);
+int MatlabMatrixToDoubleMatrix(double** pmatrix,int* pmatrix_rows,int* pmatrix_cols,const mxArray* mxmatrix);
+int MatlabNArrayToNArray(double** pmatrix,int* pmatrix_numel,int* pmatrix_ndims,int** pmatrix_size,const mxArray* mxmatrix);
+int MatlabNArrayToNArray(bool** pmatrix,int* pmatrix_numel,int* pmatrix_ndims,int** pmatrix_size,const mxArray* mxmatrix);
+int MatlabNArrayToNArray(char** pmatrix,int* pmatrix_numel,int* pmatrix_ndims,int** pmatrix_size,const mxArray* mxmatrix);
+
+/*Matlab to SeqMat routines: */
+SeqMat* MatlabMatrixToSeqMat(const mxArray* dataref);
+SeqVec* MatlabVectorToSeqVec(const mxArray* dataref);
+
+/*Matlab to Petsc routines: */
+#ifdef _HAVE_PETSC_
+int MatlabMatrixToPetscMatrix(Mat* matrix,int* prows,int* pcols, const mxArray* mxmatrix);
+int MatlabVectorToPetscVector(Vec* pvector,int* pvector_rows,const mxArray* mxvector);
+#endif
+
+
+#endif	/* _IO_H_ */
Index: /issm/branches/trunk-jpl-damage/src/c/matlab/io/mxGetAssignedField.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/matlab/io/mxGetAssignedField.cpp	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/c/matlab/io/mxGetAssignedField.cpp	(revision 12168)
@@ -0,0 +1,45 @@
+/*!\file: mxGetAssignedField.c: 
+ * \brief: abstract interface on parallel side for i/o, so it ressembles the serial i/o.
+ *
+ * In serial mode, this routine takes care of returning the field coming 
+ * from the model. If largesize is 1, we are running out of core models in 
+ * matlab, and we need to call the subsref private method from the model object
+ * in order to correctly load the data from disk.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#else
+#error "Cannot compile without HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+#include "mex.h"
+
+mxArray* mxGetAssignedField(const mxArray* pmxa_array,int number,const char* field){
+
+	//output
+	mxArray* mxfield=NULL;
+	
+	//input
+	mxArray    *inputs[2];
+	mxArray    *pindex      = NULL;
+	const char *fnames[2];
+	mwSize      ndim        = 2;
+	mwSize      onebyone[2] = {1,1};
+
+	//We want to call the subsasgn method, and get the returned array.This ensures that if we are running 
+	//large sized problems, the data is truly loaded from disk by the model subsasgn class method.
+	inputs[0]=(mxArray*)pmxa_array; //this is the model
+
+	//create index structure used in the assignment (index.type='.' and index.subs='x' for field x for ex)
+	fnames[0] = "type";
+	fnames[1] = "subs";
+	pindex=mxCreateStructArray( ndim,onebyone,2,fnames);
+	mxSetField( pindex, 0, "type",mxCreateString("."));
+	mxSetField( pindex, 0, "subs",mxCreateString(field));
+	inputs[1]=pindex;
+
+	mexCallMATLAB( 1, &mxfield, 2, (mxArray**)inputs, "subsref");
+
+	return mxfield;
+}
Index: /issm/branches/trunk-jpl-damage/src/c/matlab/matlab-binding.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/matlab/matlab-binding.h	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/c/matlab/matlab-binding.h	(revision 12168)
@@ -0,0 +1,7 @@
+#ifndef _MATLAB_BINDING_H_
+#define _MATLAB_BINDING_H_
+
+#include "./io/matlabio.h"
+#include "./include/matlab_macros.h"
+
+#endif
Index: /issm/branches/trunk-jpl-damage/src/c/modules/ConstraintsStatex/RiftConstraintsState.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/ConstraintsStatex/RiftConstraintsState.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/ConstraintsStatex/RiftConstraintsState.cpp	(revision 12168)
@@ -32,5 +32,5 @@
 	}
 
-	#ifdef _PARALLEL_
+	#ifdef _HAVE_MPI_
 	MPI_Reduce (&found,&mpi_found,1,MPI_INT,MPI_SUM,0,MPI_COMM_WORLD );
 	MPI_Bcast(&mpi_found,1,MPI_INT,0,MPI_COMM_WORLD);                
@@ -95,5 +95,5 @@
 	}
 
-	#ifdef _PARALLEL_
+	#ifdef _HAVE_MPI_
 	MPI_Reduce (&num_unstable_constraints,&sum_num_unstable_constraints,1,MPI_INT,MPI_SUM,0,MPI_COMM_WORLD );
 	MPI_Bcast(&sum_num_unstable_constraints,1,MPI_INT,0,MPI_COMM_WORLD);                
@@ -135,5 +135,5 @@
 	
 	/*Is there just one found? that would mean we have frozen! : */
-	#ifdef _PARALLEL_
+	#ifdef _HAVE_MPI_
 	MPI_Reduce (&found,&mpi_found,1,MPI_INT,MPI_MAX,0,MPI_COMM_WORLD );
 	MPI_Bcast(&mpi_found,1,MPI_INT,0,MPI_COMM_WORLD);                
@@ -195,5 +195,5 @@
 	}
 
-	#ifdef _PARALLEL_
+	#ifdef _HAVE_MPI_
 	MPI_Reduce (&found,&mpi_found,1,MPI_INT,MPI_SUM,0,MPI_COMM_WORLD );
 	MPI_Bcast(&mpi_found,1,MPI_INT,0,MPI_COMM_WORLD);                
@@ -228,5 +228,5 @@
 	}
 
-	#ifdef _PARALLEL_
+	#ifdef _HAVE_MPI_
 	MPI_Reduce (&found,&mpi_found,1,MPI_INT,MPI_SUM,0,MPI_COMM_WORLD );
 	MPI_Bcast(&mpi_found,1,MPI_INT,0,MPI_COMM_WORLD);                
@@ -289,5 +289,5 @@
 	}
 
-	#ifdef _PARALLEL_
+	#ifdef _HAVE_MPI_
 	MPI_Reduce (&num_unstable_constraints,&sum_num_unstable_constraints,1,MPI_INT,MPI_SUM,0,MPI_COMM_WORLD );
 	MPI_Bcast(&sum_num_unstable_constraints,1,MPI_INT,0,MPI_COMM_WORLD);                
@@ -329,5 +329,5 @@
 	}
 
-	#ifdef _PARALLEL_
+	#ifdef _HAVE_MPI_
 	MPI_Reduce (&max_penetration,&mpi_max_penetration,1,MPI_DOUBLE,MPI_MAX,0,MPI_COMM_WORLD );
 	MPI_Bcast(&mpi_max_penetration,1,MPI_DOUBLE,0,MPI_COMM_WORLD);                
@@ -368,5 +368,5 @@
 	}
 
-	#ifdef _PARALLEL_
+	#ifdef _HAVE_MPI_
 	MPI_Reduce (&num_unstable_constraints,&sum_num_unstable_constraints,1,MPI_INT,MPI_SUM,0,MPI_COMM_WORLD );
 	MPI_Bcast(&sum_num_unstable_constraints,1,MPI_INT,0,MPI_COMM_WORLD);                
Index: /issm/branches/trunk-jpl-damage/src/c/modules/ConstraintsStatex/ThermalConstraintsState.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/ConstraintsStatex/ThermalConstraintsState.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/ConstraintsStatex/ThermalConstraintsState.cpp	(revision 12168)
@@ -36,5 +36,5 @@
 	}
 
-	#ifdef _PARALLEL_
+	#ifdef _HAVE_MPI_
 	MPI_Reduce (&num_unstable_constraints,&sum_num_unstable_constraints,1,MPI_INT,MPI_SUM,0,MPI_COMM_WORLD );
 	MPI_Bcast(&sum_num_unstable_constraints,1,MPI_INT,0,MPI_COMM_WORLD);                
Index: /issm/branches/trunk-jpl-damage/src/c/modules/ConstraintsStatex/ThermalIsPresent.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/ConstraintsStatex/ThermalIsPresent.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/ConstraintsStatex/ThermalIsPresent.cpp	(revision 12168)
@@ -28,5 +28,5 @@
 	}
 	
-	#ifdef _PARALLEL_
+	#ifdef _HAVE_MPI_
 	MPI_Reduce (&found,&mpi_found,1,MPI_INT,MPI_SUM,0,MPI_COMM_WORLD );
 	MPI_Bcast(&mpi_found,1,MPI_INT,0,MPI_COMM_WORLD);                
Index: /issm/branches/trunk-jpl-damage/src/c/modules/ContourToMeshx/ContourToMeshx.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/ContourToMeshx/ContourToMeshx.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/ContourToMeshx/ContourToMeshx.cpp	(revision 12168)
@@ -11,5 +11,5 @@
 #include "./ContourToMeshx.h"
 
-int ContourToMeshx( Vector** pin_nod,Vector** pin_elem, double* index, double* x, double* y,Contour** contours,int numcontours,char* interptype,int nel,int nods, int edgevalue) {
+int ContourToMeshx( Vector** pin_nod,Vector** pin_elem, double* index, double* x, double* y,DataSet* contours,char* interptype,int nel,int nods, int edgevalue) {
 
 	int noerr=1;
@@ -37,5 +37,4 @@
 
 	/*initialize thread parameters: */
-	gate.numcontours=numcontours;
 	gate.contours=contours;
 	gate.nods=nods;
Index: /issm/branches/trunk-jpl-damage/src/c/modules/ContourToMeshx/ContourToMeshx.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/ContourToMeshx/ContourToMeshx.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/ContourToMeshx/ContourToMeshx.h	(revision 12168)
@@ -13,6 +13,5 @@
 typedef struct{
 
-	int numcontours;
-	Contour** contours;
+	DataSet* contours;
 	int nods;
 	int edgevalue;
@@ -25,5 +24,5 @@
 
 /* local prototypes: */
-int ContourToMeshx( Vector** pin_nods,Vector** pin_elem, double* index, double* x, double* y,Contour** contours,int numcontours,char* interptype,int nel,int nods, int edgevalue);
+int ContourToMeshx( Vector** pin_nods,Vector** pin_elem, double* index, double* x, double* y,DataSet* contours,char* interptype,int nel,int nods, int edgevalue);
 
 void* ContourToMeshxt(void* vContourToMeshxThreadStruct);
Index: /issm/branches/trunk-jpl-damage/src/c/modules/ContourToMeshx/ContourToMeshxt.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/ContourToMeshx/ContourToMeshxt.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/ContourToMeshx/ContourToMeshxt.cpp	(revision 12168)
@@ -26,13 +26,7 @@
 
 	/*Contour:*/
-	Contour* contouri=NULL;
-	int      numnodes;
-	double*  xc=NULL;
-	double*  yc=NULL;
-
+	DataSet* contours=NULL;
 
 	/*parameters: */
-	int numcontours;
-	Contour** contours=NULL;
 	int nods;
 	int edgevalue;
@@ -49,5 +43,4 @@
 
 	/*recover parameters :*/
-	numcontours=gate->numcontours;
 	contours=gate->contours;
 	nods=gate->nods;
@@ -61,10 +54,7 @@
 
 	/*Loop through all contours: */
-	for (i=0;i<numcontours;i++){
-		contouri=*(contours+i);
-		numnodes=contouri->nods;
-		xc=contouri->x;
-		yc=contouri->y;
-		IsInPoly(in_nod,xc,yc,numnodes,x,y,i0,i1,edgevalue);
+	for (i=0;i<contours->Size();i++){
+		Contour* contour=(Contour*)contours->GetObjectByOffset(i);
+		IsInPoly(in_nod,contour->x,contour->y,contour->nods,x,y,i0,i1,edgevalue);
 	}
 
Index: /issm/branches/trunk-jpl-damage/src/c/modules/ContourToNodesx/ContourToNodesx.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/ContourToNodesx/ContourToNodesx.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/ContourToNodesx/ContourToNodesx.cpp	(revision 12168)
@@ -38,2 +38,36 @@
 	return 1;
 }
+
+int ContourToNodesx( Vector** pflags,double* x, double* y, int nods, DataSet* contours, int edgevalue){
+
+	int i;
+	int m,n;
+
+	/*Contour:*/
+	Contour* contouri=NULL;
+	int      numnodes;
+	double*  xc=NULL;
+	double*  yc=NULL;
+	double   value;
+
+	/*output: */
+	Vector* flags=NULL;
+
+	flags=new Vector(nods);
+
+	/*Loop through all contours: */
+	if(contours){
+		for (i=0;i<contours->Size();i++){
+			Contour* contour=(Contour*)contours->GetObjectByOffset(i);
+			IsInPoly(flags,contour->x,contour->y,contour->nods,x,y,0,nods,edgevalue);
+		}
+	}
+
+	/*Assemble vector: */
+	flags->Assemble();
+
+	/*Assign output pointers: */
+	*pflags=flags;
+	
+	return 1;
+}
Index: /issm/branches/trunk-jpl-damage/src/c/modules/ContourToNodesx/ContourToNodesx.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/ContourToNodesx/ContourToNodesx.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/ContourToNodesx/ContourToNodesx.h	(revision 12168)
@@ -12,4 +12,5 @@
 /* local prototypes: */
 int ContourToNodesx( Vector** pflags,double* x, double* y, int nods, Contour** contours,int numcontours,int edgevalue);
+int ContourToNodesx( Vector** pflags,double* x, double* y, int nods, DataSet* contours, int edgevalue);
 
 #endif /* _CONTOURTONODESX_H */
Index: /issm/branches/trunk-jpl-damage/src/c/modules/Dakotax/Dakotax.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/Dakotax/Dakotax.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/Dakotax/Dakotax.cpp	(revision 12168)
@@ -51,9 +51,5 @@
 #endif
 
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-void Dakotax(mxArray* femmodel){ 
-#else
 void Dakotax(FemModel* femmodel){ 
-#endif
 
 
@@ -69,9 +65,5 @@
 
 	/*Retrieve parameters: */
-	#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-	FetchData((Parameters**)&parameters,mxGetField((mxArray*)femmodel,0,"parameters"));
-	#else
 	parameters=femmodel->parameters;
-	#endif
 
 	/*Recover dakota_input_file, dakota_output_file and dakota_error_file, in the parameters dataset in parallel */
@@ -80,15 +72,9 @@
 	parameters->FindParam(&dakota_error_file,QmuErrNameEnum);
 
-	#ifdef _PARALLEL_
 	if(my_rank==0){
-	#endif
 	
 		// Instantiate/initialize the parallel library and problem description
 		// database objects.
-		#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-			Dakota::ParallelLibrary parallel_lib; //use Dakota's standard library mode constructor
-		#else
-			Dakota::ParallelLibrary parallel_lib("serial"); //use our own ISSM Dakota library mode constructor, which only fires up Dakota on CPU 0. 
-		#endif
+		Dakota::ParallelLibrary parallel_lib("serial"); //use our own ISSM Dakota library mode constructor, which only fires up Dakota on CPU 0. 
 		Dakota::ProblemDescDB problem_db(parallel_lib); 
 
@@ -123,10 +109,7 @@
 		selected_strategy.run_strategy();
 		
-		#ifdef _PARALLEL_
 		//Warn other cpus that we are done running the dakota iterator, by setting the counter to -1:
 		SpawnCore(NULL,0, NULL,NULL,0,femmodel,-1);
-		#endif
 
-	#ifdef _PARALLEL_
 	}
 	else{
@@ -136,5 +119,4 @@
 		}
 	}
-	#endif //#ifdef _PARALLEL_
 
 	/*Free ressources:*/
@@ -143,8 +125,4 @@
 	xfree((void**)&dakota_output_file);
 
-	#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-	delete parameters;
-	#endif
-
 	#endif //#ifdef _HAVE_DAKOTA_
 }
Index: /issm/branches/trunk-jpl-damage/src/c/modules/Dakotax/Dakotax.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/Dakotax/Dakotax.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/Dakotax/Dakotax.h	(revision 12168)
@@ -10,14 +10,9 @@
 
 /* local prototypes: */
-int SpawnCore(double* responses, int numresponses, double* variables, char** variables_descriptors,int numvariables, void* femmodel,int counter);
+int  SpawnCore(double* responses, int numresponses, double* variables, char** variables_descriptors,int numvariables, void* femmodel,int counter);
 int  DescriptorIndex(char* root, int* pindex,char* descriptor);
 
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-void Dakotax(mxArray* femmodel);
-void SpawnCoreSerial(double* responses, int numresponses, double* variables, char** variables_descriptors,int numvariables, mxArray* femmodel,int counter);
-#else
 void Dakotax(FemModel* femmodel);
 void SpawnCoreParallel(double* responses, int numresponses, double* variables, char** variables_descriptors,int numvariables, FemModel* femmodel,int counter);
-#endif
 void DakotaResponses(double* responses,char** responses_descriptors,int numresponses,FemModel* femmodel);
 void DakotaMPI_Bcast(double** pvariables, char*** pvariables_descriptors,int* pnumvariables, int* pnumresponses);
Index: /issm/branches/trunk-jpl-damage/src/c/modules/Dakotax/SpawnCore.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/Dakotax/SpawnCore.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/Dakotax/SpawnCore.cpp	(revision 12168)
@@ -21,12 +21,9 @@
 	/*Branch into a serial SpawnCore and a parallel SpawnCore: */
 
-	#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-		SpawnCoreSerial(responses, numresponses, variables, variables_descriptors,numvariables, (mxArray*)femmodel, counter);
-	#else
-		/*Call SpawnCoreParallel unless counter=-1 on cpu0, in which case, bail out and return 0: */
-		MPI_Bcast(&counter,1,MPI_INT,0,MPI_COMM_WORLD); 
-		if(counter==-1)return 0;
-		SpawnCoreParallel(responses, numresponses, variables, variables_descriptors,numvariables, (FemModel*)femmodel,counter);
-	#endif
+	/*Call SpawnCoreParallel unless counter=-1 on cpu0, in which case, bail out and return 0: */
+	MPI_Bcast(&counter,1,MPI_INT,0,MPI_COMM_WORLD); 
+	if(counter==-1)return 0;
+
+	SpawnCoreParallel(responses, numresponses, variables, variables_descriptors,numvariables, (FemModel*)femmodel,counter);
 	return 1;
 }
Index: sm/branches/trunk-jpl-damage/src/c/modules/Dakotax/SpawnCoreSerial.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/Dakotax/SpawnCoreSerial.cpp	(revision 12167)
+++ 	(revision )
@@ -1,71 +1,0 @@
-/*!\file:  SpawnCoreSerial.cpp
- * \brief: run core ISSM solution using Dakota inputs. Call the Serial core solution, using mexCallMATLAB
- * \sa SpawnCore.cpp SpawnCoreParallel.cpp
- *
- */ 
-
-#ifdef HAVE_CONFIG_H
-	#include <config.h>
-#else
-#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
-#endif
-
-#include "../../objects/objects.h"
-#include "../../io/io.h"
-#include "../../EnumDefinitions/EnumDefinitions.h"
-#include "../../shared/shared.h"
-#include "./Dakotax.h"
-#include "../../include/include.h"
-
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-void SpawnCoreSerial(double* responses, int numresponses, double* variables, char** variables_descriptors,int numvariables, mxArray* femmodel, int counter){
-
-	int i;
-
-	//inputs to matlab routine
-	mxArray* mxvariables=NULL;
-	double*  variables_copy=NULL;
-	mxArray* mxvariabledescriptors=NULL;
-	mxArray* mxcounter=NULL;
-	mwSize   dims[2]={0};
-
-	//mexCallMATLAB arrays
-	mxArray* array[4];
-
-	//output from SpawnCore in matlab routine.
-	mxArray* mxresponses=NULL;
-
-	/*Create variables and variable descriptors mxArrays that we will feed to the core solution for update of the inputs: */
-	mxvariables=mxCreateDoubleMatrix(numvariables,1,mxREAL);
-	variables_copy=(double*)xmalloc(numvariables*sizeof(double));
-	memcpy(variables_copy,variables,numvariables*sizeof(double));
-	mxSetPr(mxvariables,variables_copy);
-
-	dims[0]=numvariables;
-	dims[1]=1;
-	mxvariabledescriptors=mxCreateCellArray(2,dims);
-	for(i=0;i<numvariables;i++){
-		mxSetCell(mxvariabledescriptors,i,mxCreateString(variables_descriptors[i]));
-	}
-
-	mxcounter=mxCreateDoubleScalar((double)counter);
-
-	//call SpwanCore matlab routine.
-	array[0]=femmodel;
-	array[1]=mxvariables;
-	array[2]=mxvariabledescriptors;
-	array[3]=mxcounter;
-
-	mexCallMATLAB(1,&mxresponses,4,array,"SpawnCore");
-
-	/*copy responses back to dakota: */
-	memcpy(responses,mxGetPr(mxresponses),numresponses*sizeof(double));
-
-	//destroy constructed arrays: 
-	mxDestroyArray(mxvariables);
-	mxDestroyArray(mxvariabledescriptors);
-	mxDestroyArray(mxresponses);
-	mxDestroyArray(mxcounter);
-
-}
-#endif
Index: /issm/branches/trunk-jpl-damage/src/c/modules/DragCoefficientAbsGradientx/DragCoefficientAbsGradientx.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/DragCoefficientAbsGradientx/DragCoefficientAbsGradientx.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/DragCoefficientAbsGradientx/DragCoefficientAbsGradientx.cpp	(revision 12168)
@@ -27,7 +27,9 @@
 
 	/*Sum all J from all cpus of the cluster:*/
+	#ifdef _HAVE_MPI_
 	MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0,MPI_COMM_WORLD );
 	MPI_Bcast(&J_sum,1,MPI_DOUBLE,0,MPI_COMM_WORLD);
 	J=J_sum;
+	#endif
 
 	/*Assign output pointers: */
Index: /issm/branches/trunk-jpl-damage/src/c/modules/ElementResponsex/ElementResponsex.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/ElementResponsex/ElementResponsex.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/ElementResponsex/ElementResponsex.cpp	(revision 12168)
@@ -37,6 +37,8 @@
 
 	/*Broadcast whether we found the element: */
+	#ifdef _HAVE_MPI_
 	MPI_Allreduce ( &found,&sumfound,1,MPI_INT,MPI_SUM,MPI_COMM_WORLD);
 	if(!sumfound)_error_("%s%i%s","could not find material with id",index," to compute ElementResponse");
+	#endif
 
 	/*Ok, we found the element, compute responseocity: */
@@ -46,6 +48,8 @@
 
 	/*Broadcast and plug into response: */
+	#ifdef _HAVE_MPI_
 	MPI_Allreduce ( &cpu_found,&cpu_found,1,MPI_INT,MPI_MAX,MPI_COMM_WORLD);
 	MPI_Bcast(&response,1,MPI_DOUBLE,cpu_found,MPI_COMM_WORLD); 
+	#endif
 
 	*presponse=response;
Index: /issm/branches/trunk-jpl-damage/src/c/modules/Exp2Kmlx/Exp2Kmlx.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/Exp2Kmlx/Exp2Kmlx.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/Exp2Kmlx/Exp2Kmlx.cpp	(revision 12168)
@@ -61,5 +61,5 @@
 /*  read exp file  */
 
-	if (!DomainOutlineRead(&nprof,&pnvert,&pprofx,&pprofy,&closed,filexp,true))
+	if (!DomainOutlineRead(&nprof,&pnvert,&pprofx,&pprofy,&closed,filexp))
 		_error_("Error reading exp file.");
 	_printf_(true,"Exp2Kmlx -- Reading %d exp profiles from file \"%s\".\n",nprof,filexp);
Index: /issm/branches/trunk-jpl-damage/src/c/modules/GroundinglineMigrationx/GroundinglineMigrationx.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/GroundinglineMigrationx/GroundinglineMigrationx.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/GroundinglineMigrationx/GroundinglineMigrationx.cpp	(revision 12168)
@@ -156,6 +156,10 @@
 		vec_nodes_on_floatingice->Assemble();
 		
+		#ifdef _HAVE_MPI_
 		MPI_Allreduce(&local_nflipped,&nflipped,1,MPI_INT,MPI_SUM,MPI_COMM_WORLD);
 		_printf_(VerboseConvergence(),"   Additional number of vertices allowed to unground: %i\n",nflipped);
+		#else
+		nflipped=local_nflipped;
+		#endif
 
 		/*Avoid leaks: */
Index: /issm/branches/trunk-jpl-damage/src/c/modules/IceVolumex/IceVolumex.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/IceVolumex/IceVolumex.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/IceVolumex/IceVolumex.cpp	(revision 12168)
@@ -19,6 +19,10 @@
 		local_ice_volume+=element->IceVolume();
 	}
+	#ifdef _HAVE_MPI_
 	MPI_Reduce(&local_ice_volume,&total_ice_volume,1,MPI_DOUBLE,MPI_SUM,0,MPI_COMM_WORLD );
 	MPI_Bcast(&total_ice_volume,1,MPI_DOUBLE,0,MPI_COMM_WORLD);
+	#else
+	total_ice_volume=local_ice_volume;
+	#endif
 
 	/*Assign output pointers: */
Index: /issm/branches/trunk-jpl-damage/src/c/modules/InputConvergencex/InputConvergencex.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/InputConvergencex/InputConvergencex.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/InputConvergencex/InputConvergencex.cpp	(revision 12168)
@@ -30,5 +30,5 @@
 
 	/*In parallel, we need to gather the converged status: */
-	#ifdef _PARALLEL_
+	#ifdef _HAVE_MPI_
 	MPI_Allreduce ( (void*)&num_notconverged,(void*)&total_notconverged,1,MPI_INT,MPI_SUM,MPI_COMM_WORLD);
 	num_notconverged=total_notconverged;
Index: /issm/branches/trunk-jpl-damage/src/c/modules/InterpFromMeshToMesh2dx/InterpFromMeshToMesh2dx.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/InterpFromMeshToMesh2dx/InterpFromMeshToMesh2dx.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/InterpFromMeshToMesh2dx/InterpFromMeshToMesh2dx.cpp	(revision 12168)
@@ -14,5 +14,5 @@
 
 int InterpFromMeshToMesh2dx(double** pdata_interp,double* index_data,double* x_data,double* y_data,int nods_data,int nels_data,
-			double* data,int data_rows,int data_cols,double* x_interp,double* y_interp,int nods_interp,double* default_values,int num_default_values, Contour** contours, int numcontours){
+			double* data,int data_rows,int data_cols,double* x_interp,double* y_interp,int nods_interp,double* default_values,int num_default_values, DataSet* contours){
 	
 	/*Output*/
@@ -36,5 +36,4 @@
 	bool   skip_bamg=false;
 
-
 	/*Checks*/
 	if (data_cols<=0){
@@ -50,5 +49,5 @@
 	/*If default values supplied, figure out which nodes are inside the contour, including the border of the contour: */
 	if(num_default_values){
-		ContourToNodesx( &vec_incontour,x_interp,y_interp,nods_interp,contours,numcontours,1);
+		ContourToNodesx( &vec_incontour,x_interp,y_interp,nods_interp,contours,1);
 		incontour=vec_incontour->ToMPISerial();
 	}
Index: /issm/branches/trunk-jpl-damage/src/c/modules/InterpFromMeshToMesh2dx/InterpFromMeshToMesh2dx.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/InterpFromMeshToMesh2dx/InterpFromMeshToMesh2dx.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/InterpFromMeshToMesh2dx/InterpFromMeshToMesh2dx.h	(revision 12168)
@@ -10,5 +10,5 @@
 /* local prototypes: */
 int InterpFromMeshToMesh2dx(double** pdata_interp,double* index_data,double* x_data,double* y_data,int nods_data,int nels_data,
-			double* data,int data_rows,int data_cols,double* x_interp,double* y_interp,int nods_interp,double* default_values,int num_default_values,Contour** contours, int numcontours );
+			double* data,int data_rows,int data_cols,double* x_interp,double* y_interp,int nods_interp,double* default_values,int num_default_values,DataSet* contours);
 
 #endif
Index: /issm/branches/trunk-jpl-damage/src/c/modules/Krigingx/Krigingx.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/Krigingx/Krigingx.cpp	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/Krigingx/Krigingx.cpp	(revision 12168)
@@ -0,0 +1,22 @@
+/*!\file:  Kriging.cpp
+ * \brief  "c" core code for Kriging
+ */ 
+
+#include "./Krigingx.h"
+#include "../../shared/shared.h"
+#include "../../include/include.h"
+#include "../../toolkits/toolkits.h"
+#include "../../objects/objects.h"
+#include "../modules.h"
+
+int Krigingx(double** ppredictions,double* x, double* y, double* observations, int n_obs,double* x_interp,double* y_interp,int n_interp){
+
+	/*output*/
+	double *predictions = NULL;
+
+	/*Allocate output*/
+	predictions=(double*)xmalloc(n_interp*sizeof(double));
+
+	/*Assign output pointer*/
+	*ppredictions=predictions;
+}
Index: /issm/branches/trunk-jpl-damage/src/c/modules/Krigingx/Krigingx.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/Krigingx/Krigingx.h	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/Krigingx/Krigingx.h	(revision 12168)
@@ -0,0 +1,15 @@
+/*!\file Kriging.h
+ * \brief: header file for Kriging
+ */
+
+#ifndef _KRIGINGX_H
+#define _KRIGINGX_H
+
+#include "../../objects/objects.h"
+#include "../../toolkits/toolkits.h"
+
+
+int Krigingx(double** ppredictions,double* x, double* y, double* observations, int n_obs,double* x_interp,double* y_interp,int n_interp);
+
+#endif /* _KRIGINGX_H */
+
Index: /issm/branches/trunk-jpl-damage/src/c/modules/MassFluxx/MassFluxx.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/MassFluxx/MassFluxx.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/MassFluxx/MassFluxx.cpp	(revision 12168)
@@ -59,5 +59,5 @@
 	}
 
-	#ifdef _PARALLEL_
+	#ifdef _HAVE_MPI_
 	MPI_Allreduce ( (void*)&mass_flux,(void*)&all_mass_flux,1,MPI_DOUBLE,MPI_SUM,MPI_COMM_WORLD);
 	mass_flux=all_mass_flux;
Index: /issm/branches/trunk-jpl-damage/src/c/modules/MaxAbsVxx/MaxAbsVxx.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/MaxAbsVxx/MaxAbsVxx.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/MaxAbsVxx/MaxAbsVxx.cpp	(revision 12168)
@@ -31,6 +31,6 @@
 	}
 
-	#ifdef _PARALLEL_
 	/*Figure out maximum across the cluster: */
+	#ifdef _HAVE_MPI_
 	MPI_Reduce (&maxabsvx,&node_maxabsvx,1,MPI_DOUBLE,MPI_MAX,0,MPI_COMM_WORLD );
 	MPI_Bcast(&node_maxabsvx,1,MPI_DOUBLE,0,MPI_COMM_WORLD);   
Index: /issm/branches/trunk-jpl-damage/src/c/modules/MaxAbsVyx/MaxAbsVyx.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/MaxAbsVyx/MaxAbsVyx.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/MaxAbsVyx/MaxAbsVyx.cpp	(revision 12168)
@@ -32,6 +32,6 @@
 	}
 
-	#ifdef _PARALLEL_
 	/*Figure out maximum across the cluster: */
+	#ifdef _HAVE_MPI_
 	MPI_Reduce (&maxabsvy,&node_maxabsvy,1,MPI_DOUBLE,MPI_MAX,0,MPI_COMM_WORLD );
 	MPI_Bcast(&node_maxabsvy,1,MPI_DOUBLE,0,MPI_COMM_WORLD);   
Index: /issm/branches/trunk-jpl-damage/src/c/modules/MaxAbsVzx/MaxAbsVzx.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/MaxAbsVzx/MaxAbsVzx.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/MaxAbsVzx/MaxAbsVzx.cpp	(revision 12168)
@@ -31,6 +31,6 @@
 	}
 
-	#ifdef _PARALLEL_
 	/*Figure out minimum across the cluster: */
+	#ifdef _HAVE_MPI_
 	MPI_Reduce (&maxabsvz,&node_maxabsvz,1,MPI_DOUBLE,MPI_MAX,0,MPI_COMM_WORLD );
 	MPI_Bcast(&node_maxabsvz,1,MPI_DOUBLE,0,MPI_COMM_WORLD);   
Index: /issm/branches/trunk-jpl-damage/src/c/modules/MaxVelx/MaxVelx.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/MaxVelx/MaxVelx.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/MaxVelx/MaxVelx.cpp	(revision 12168)
@@ -32,6 +32,6 @@
 	}
 
-	#ifdef _PARALLEL_
 	/*Figure out maximum across the cluster: */
+	#ifdef _HAVE_MPI_
 	MPI_Reduce (&maxvel,&node_maxvel,1,MPI_DOUBLE,MPI_MAX,0,MPI_COMM_WORLD );
 	MPI_Bcast(&node_maxvel,1,MPI_DOUBLE,0,MPI_COMM_WORLD);   
Index: /issm/branches/trunk-jpl-damage/src/c/modules/MaxVxx/MaxVxx.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/MaxVxx/MaxVxx.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/MaxVxx/MaxVxx.cpp	(revision 12168)
@@ -31,6 +31,6 @@
 	}
 
-	#ifdef _PARALLEL_
 	/*Figure out minimum across the cluster: */
+	#ifdef _HAVE_MPI_
 	MPI_Reduce (&maxvx,&node_maxvx,1,MPI_DOUBLE,MPI_MAX,0,MPI_COMM_WORLD );
 	MPI_Bcast(&node_maxvx,1,MPI_DOUBLE,0,MPI_COMM_WORLD);   
Index: /issm/branches/trunk-jpl-damage/src/c/modules/MaxVyx/MaxVyx.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/MaxVyx/MaxVyx.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/MaxVyx/MaxVyx.cpp	(revision 12168)
@@ -31,6 +31,6 @@
 	}
 
-	#ifdef _PARALLEL_
 	/*Figure out minimum across the cluster: */
+	#ifdef _HAVE_MPI_
 	MPI_Reduce (&maxvy,&node_maxvy,1,MPI_DOUBLE,MPI_MAX,0,MPI_COMM_WORLD );
 	MPI_Bcast(&node_maxvy,1,MPI_DOUBLE,0,MPI_COMM_WORLD);   
Index: /issm/branches/trunk-jpl-damage/src/c/modules/MaxVzx/MaxVzx.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/MaxVzx/MaxVzx.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/MaxVzx/MaxVzx.cpp	(revision 12168)
@@ -32,6 +32,6 @@
 	}
 
-	#ifdef _PARALLEL_
 	/*Figure out minimum across the cluster: */
+	#ifdef _HAVE_MPI_
 	MPI_Reduce (&maxvz,&node_maxvz,1,MPI_DOUBLE,MPI_MAX,0,MPI_COMM_WORLD );
 	MPI_Bcast(&node_maxvz,1,MPI_DOUBLE,0,MPI_COMM_WORLD);   
Index: /issm/branches/trunk-jpl-damage/src/c/modules/MeshPartitionx/MeshPartitionx.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/MeshPartitionx/MeshPartitionx.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/MeshPartitionx/MeshPartitionx.cpp	(revision 12168)
@@ -42,5 +42,7 @@
 		/*Partition using Metis:*/
 		if (num_procs>1){
+			#ifdef _HAVE_METIS_
 			METIS_PartMeshNodalPatch(&numberofelements,&numberofnodes, index, &etype, &numflag, &num_procs, &edgecut, epart, npart);
+			#endif
 		}
 		else if (num_procs==1){
@@ -67,5 +69,7 @@
 		/*Partition using Metis:*/
 		if (num_procs>1){
+			#ifdef _HAVE_METIS_
 			METIS_PartMeshNodalPatch(&numberofelements2d,&numberofnodes2d, index2d, &etype2d, &numflag, &num_procs, &edgecut, epart2d, npart2d);
+			#endif
 		}
 		else if (num_procs==1){
Index: /issm/branches/trunk-jpl-damage/src/c/modules/MeshProfileIntersectionx/SegmentIntersect.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/MeshProfileIntersectionx/SegmentIntersect.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/MeshProfileIntersectionx/SegmentIntersect.cpp	(revision 12168)
@@ -6,5 +6,5 @@
 int SegmentIntersect(double* palpha, double* pbeta, double* x1, double* y1, double* x2, double* y2){
 
-	/*See ISSM_TIER/src/m/utils/Geometry/SegIntersect.m for matlab routine from which we take this routine: */
+	/*See ISSM_DIR/src/m/utils/Geometry/SegIntersect.m for matlab routine from which we take this routine: */
 
 	/*output: */
Index: /issm/branches/trunk-jpl-damage/src/c/modules/MinVelx/MinVelx.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/MinVelx/MinVelx.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/MinVelx/MinVelx.cpp	(revision 12168)
@@ -32,6 +32,6 @@
 	}
 
-	#ifdef _PARALLEL_
 	/*Figure out minimum across the cluster: */
+	#ifdef _HAVE_MPI_
 	MPI_Reduce (&minvel,&node_minvel,1,MPI_DOUBLE,MPI_MIN,0,MPI_COMM_WORLD );
 	MPI_Bcast(&node_minvel,1,MPI_DOUBLE,0,MPI_COMM_WORLD);   
Index: /issm/branches/trunk-jpl-damage/src/c/modules/MinVxx/MinVxx.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/MinVxx/MinVxx.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/MinVxx/MinVxx.cpp	(revision 12168)
@@ -31,6 +31,6 @@
 	}
 
-	#ifdef _PARALLEL_
 	/*Figure out minimum across the cluster: */
+	#ifdef _HAVE_MPI_
 	MPI_Reduce (&minvx,&node_minvx,1,MPI_DOUBLE,MPI_MIN,0,MPI_COMM_WORLD );
 	MPI_Bcast(&node_minvx,1,MPI_DOUBLE,0,MPI_COMM_WORLD);   
Index: /issm/branches/trunk-jpl-damage/src/c/modules/MinVyx/MinVyx.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/MinVyx/MinVyx.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/MinVyx/MinVyx.cpp	(revision 12168)
@@ -31,6 +31,6 @@
 	}
 
-	#ifdef _PARALLEL_
 	/*Figure out minimum across the cluster: */
+	#ifdef _HAVE_MPI_
 	MPI_Reduce (&minvy,&node_minvy,1,MPI_DOUBLE,MPI_MIN,0,MPI_COMM_WORLD );
 	MPI_Bcast(&node_minvy,1,MPI_DOUBLE,0,MPI_COMM_WORLD);   
Index: /issm/branches/trunk-jpl-damage/src/c/modules/MinVzx/MinVzx.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/MinVzx/MinVzx.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/MinVzx/MinVzx.cpp	(revision 12168)
@@ -31,6 +31,6 @@
 	}
 
-	#ifdef _PARALLEL_
 	/*Figure out minimum across the cluster: */
+	#ifdef _HAVE_MPI_
 	MPI_Reduce (&minvz,&node_minvz,1,MPI_DOUBLE,MPI_MIN,0,MPI_COMM_WORLD );
 	MPI_Bcast(&node_minvz,1,MPI_DOUBLE,0,MPI_COMM_WORLD);   
Index: /issm/branches/trunk-jpl-damage/src/c/modules/ModelProcessorx/ElementsAndVerticesPartitioning.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/ModelProcessorx/ElementsAndVerticesPartitioning.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/ModelProcessorx/ElementsAndVerticesPartitioning.cpp	(revision 12168)
@@ -63,5 +63,4 @@
 	else elements_width=6; //penta elements
 
-	#ifdef _PARALLEL_
 	/*Determine parallel partitioning of elements: we use Metis for now. First load the data, then partition*/
 	if(dim==2){
@@ -79,9 +78,4 @@
 	xfree((void**)&elements);
 	xfree((void**)&elements2d);
-
-	#else
-	/*In serial mode, epart is full of 0: all elements belong to cpu 0: */
-	epart=(int*)xcalloc(numberofelements,sizeof(int));
-	#endif
 
 	/*Deal with rifts, they have to be included into one partition only, not several: */
Index: /issm/branches/trunk-jpl-damage/src/c/modules/NodalValuex/NodalValuex.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/NodalValuex/NodalValuex.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/NodalValuex/NodalValuex.cpp	(revision 12168)
@@ -36,10 +36,16 @@
 
 	/*Broadcast whether we found the element: */
+	#ifdef _HAVE_MPI_
 	MPI_Allreduce ( &found,&sumfound,1,MPI_INT,MPI_SUM,MPI_COMM_WORLD);
 	if(!sumfound)_error_("%s%i%s%s","could not find element with vertex with id",index," to compute nodal value ",EnumToStringx(natureofdataenum));
+	#endif
 
 	/*Broadcast and plug into response: */
+	#ifdef _HAVE_MPI_
 	MPI_Allreduce ( &cpu_found,&cpu_found,1,MPI_INT,MPI_MAX,MPI_COMM_WORLD);
 	MPI_Bcast(&value,1,MPI_DOUBLE,cpu_found,MPI_COMM_WORLD); 
+	#else
+	value=cpu_found;
+	#endif
 
 	*pnodalvalue=value;
Index: /issm/branches/trunk-jpl-damage/src/c/modules/OutputResultsx/OutputResultsx.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/OutputResultsx/OutputResultsx.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/OutputResultsx/OutputResultsx.cpp	(revision 12168)
@@ -16,9 +16,5 @@
 #include "../../objects/objects.h"
 		
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-void OutputResultsx(mxArray** pdataref, Elements* elements, Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,Results* results){
-#else 
 void OutputResultsx(                    Elements* elements, Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,Results* results){
-#endif
 
 	extern int  my_rank;
@@ -31,11 +27,4 @@
 	bool        dakota_analysis         = false;
 	
-	#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-	const char **fnames      = NULL;
-	mwSize       onebyone[2] = {0,0};
-	mwSize       ndim        = 2;
-	int          nfields=0;
-	#endif
-
 	/*retrieve parameters: */
 	parameters->FindParam(&dakota_analysis,QmuIsdakotaEnum);
@@ -43,7 +32,4 @@
 	if(dakota_analysis){
 		//no need to output anything, Dakota analysis has different outputs
-		#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-		*pdataref=mxCreateStructArray( ndim,onebyone,nfields,fnames);
-		#endif
 		return; 
 	}
@@ -56,5 +42,4 @@
 	/*Results do not include the type of solution being run	. In parallel, we output results to a filename, 
 	 *therefore, we need to include the solutiontype into the filename: */
-	#ifdef _PARALLEL_
 	if(my_rank==0){
 		parameters->FindParam(&solutiontype,SolutionTypeEnum);
@@ -88,26 +73,19 @@
 		parameters->SetParam(fid,OutputFilePointerEnum);
 	}
-	#endif
 
-	/*Write results to disk (in parallel), or to memory (in serial mode): */
-	#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-		results->Write(pdataref);
-	#else
-		results->Write(parameters);
-	#endif
+	/*Write results to disk: */
+	results->Write(parameters);
 
 	/*Delete and reinitialize results, in parallel: */
-	#ifdef _PARALLEL_
-		results->clear();
+	results->clear();
 
-		/*Close output file? :*/
-		/*WARNING: issm.cpp is taking care of it for now (quick fix)
-		if((step==1) && (time==0)){
-			if(io_gather){
-				if(my_rank==0) pfclose(fid,outputfilename);
-			}
-			else pfclose(fid,cpu_outputfilename);
-		}
-		*/
-	#endif
+	/*Close output file? :*/
+	/*WARNING: issm.cpp is taking care of it for now (quick fix)
+	  if((step==1) && (time==0)){
+	  if(io_gather){
+	  if(my_rank==0) pfclose(fid,outputfilename);
+	  }
+	  else pfclose(fid,cpu_outputfilename);
+	  }
+	*/
 }
Index: /issm/branches/trunk-jpl-damage/src/c/modules/OutputResultsx/OutputResultsx.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/OutputResultsx/OutputResultsx.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/OutputResultsx/OutputResultsx.h	(revision 12168)
@@ -14,10 +14,5 @@
 #include "../../Container/Container.h"
 
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-#include <mex.h>
-void OutputResultsx(mxArray** pdataref, Elements* elements, Nodes* nodes, Vertices* vertices, Loads* loads,  Materials* materials, Parameters* parameters, Results* results);
-#else
 void OutputResultsx(Elements* elements, Nodes* nodes, Vertices* vertices, Loads* loads,  Materials* materials, Parameters* parameters, Results* results);
-#endif
 
 #endif  /* _OUTPUTRESULTS_H */
Index: /issm/branches/trunk-jpl-damage/src/c/modules/ParsePetscOptionsx/ParsePetscOptionsx.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/ParsePetscOptionsx/ParsePetscOptionsx.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/ParsePetscOptionsx/ParsePetscOptionsx.cpp	(revision 12168)
@@ -92,6 +92,6 @@
 	}
 
-	#ifdef _PARALLEL_
 	/*Ok, broadcast to other cpus: */
+ 	#ifdef _HAVE_MPI_
 	MPI_Bcast(&numanalyses,1,MPI_INT,0,MPI_COMM_WORLD);
 	if(my_rank!=0){
@@ -100,4 +100,5 @@
 	}
 	MPI_Bcast(analyses,numanalyses,MPI_DOUBLE,0,MPI_COMM_WORLD);
+	#endif
 	for(i=0;i<numanalyses;i++){
 		char* string=strings[i];
@@ -106,10 +107,11 @@
 		}
 		if(my_rank==0)stringlength=(strlen(string)+1)*sizeof(char);
+		#ifdef _HAVE_MPI_
 		MPI_Bcast(&stringlength,1,MPI_INT,0,MPI_COMM_WORLD);
 		if(my_rank!=0)string=(char*)xmalloc(stringlength);
 		MPI_Bcast(string,stringlength,MPI_CHAR,0,MPI_COMM_WORLD);
 		if(my_rank!=0)strings[i]=string;
+		#endif
 	}
-	#endif
 
 	/*Ok, out of strings and analyses and numanalyses, create parameters, and plug them into parameters container: */
Index: /issm/branches/trunk-jpl-damage/src/c/modules/PositiveDegreeDayx/PositiveDegreeDayx.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/PositiveDegreeDayx/PositiveDegreeDayx.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/PositiveDegreeDayx/PositiveDegreeDayx.cpp	(revision 12168)
@@ -11,11 +11,100 @@
 
 void PositiveDegreeDayx(Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads,Materials* materials, Parameters* parameters){
-	
-	Element* element = NULL;
 
-	for(int i=0;i<elements->Size();i++){
-		element=(Element*)elements->GetObjectByOffset(i);
-		element->PositiveDegreeDay();
-	}
+// void PositiveDegreeDayx(hd,vTempsea,vPrec,agd,Tsurf,ni){
+//    note "v" prefix means 12 monthly means, ie time dimension
+//    INPUT parameters: ni: working size of arrays
+//    INPUT: surface elevation (m): hd(NA)
+//    monthly mean surface sealevel temperature (degrees C): vTempsea(NA
+//    ,NTIME) 
+//    monthly mean precip rate (m/yr water equivalent): vPrec(NA,NTIME)
+//    OUTPUT: mass-balance (m/yr ice): agd(NA)
+//    mean annual surface temperature (degrees C): Tsurf(NA)
 
+  int    i, it, jj, itm;
+  double DT = 0.02, sigfac, snormfac;
+  double signorm = 5.5;      // signorm : sigma of the temperature distribution for a normal day 
+  double siglim;       // sigma limit for the integration which is equal to 2.5 sigmanorm
+  double signormc;     // sigma of the temperature distribution for cloudy day
+  double siglimc=0, siglim0, siglim0c;
+  double tstep, tsint, tint, tstepc;
+  int    NPDMAX = 1504, NPDCMAX = 1454;
+  //double pdds[NPDMAX]={0}; 
+  //double pds[NPDCMAX]={0};
+  double pddt, pd ; // pd : snow/precip fraction, precipitation falling as snow
+  double PDup, PDCUT = 2.0;    // PDcut: rain/snow cutoff temperature (C)
+  double tstar; // monthly mean surface temp
+  
+  double* pdds=NULL; 
+  double* pds=NULL; 
+  Element* element = NULL;
+  
+  pdds=(double*)xmalloc(NPDMAX*sizeof(double)+1); 
+  pds=(double*)xmalloc(NPDCMAX*sizeof(double)+1); 
+  
+  
+  // PDD constant
+  siglim = 2.5*signorm; 
+  
+  // initialize PDD (creation of a lookup table)
+  tstep = 0.1;
+  tsint = tstep*0.5;
+  sigfac = -1.0/(2.0*pow(signorm,2));
+  snormfac = 1.0/(signorm*sqrt(2.0*acos(-1.0)));
+  siglim = 2.5*signorm;
+  itm = (int)(2*siglim/DT + 1.5);
+  
+  if (itm >= NPDMAX){
+    printf("increase NPDMAX in massBalance.cpp\n");
+    exit (1);
+      }
+  for (it = 0; it < itm; it++){  
+    //    tstar = REAL(it)*DT-siglim;
+    tstar = it*DT-siglim;
+    tint = tsint;
+    pddt = 0;
+    for ( jj = 0; jj < 600; jj++){
+      if (tint > (tstar+siglim)){break;}
+      pddt = pddt + tint*exp(sigfac*(pow((tint-tstar),2)))*tstep;
+      tint = tint+tstep;
+    }
+    pdds[it] = pddt*snormfac;
+  }
+  pdds[itm+1] = siglim + DT;
+  
+  //*********compute PD(T) : snow/precip fraction. precipitation falling as snow
+  tstepc = 0.1;
+  tsint = PDCUT-tstepc*0.5;
+  signormc = signorm - 0.5;
+  sigfac = -1.0/(2.0*pow(signormc,2));
+  snormfac = 1.0/(signormc*sqrt(2.0*acos(-1.0)));
+  siglimc = 2.5*signormc ;
+  itm = (int)((PDCUT+2.*siglimc)/DT + 1.5);
+  if (itm >= NPDCMAX){
+    printf("'increase NPDCMAX in p35com'\n");
+    exit (1);
+      }
+  for (it = 0; it < itm; it++ ){
+    tstar = it*DT-siglimc;
+    //    tstar = REAL(it)*DT-siglimc;
+    tint = tsint;          // start against upper bound
+    pd = 0;
+    for (jj = 0; jj < 600; jj++){
+      if (tint<(tstar-siglimc)) {break;}
+      pd = pd + exp(sigfac*(pow((tint-tstar),2)))*tstepc;
+      tint = tint-tstepc;
+    }
+    pds[it] = pd*snormfac;  // gaussian integral lookup table for snow fraction
+  }
+  pds[itm+1] = 0;
+  //     *******END initialize PDD
+  
+  for(i=0;i<elements->Size();i++){
+    element=(Element*)elements->GetObjectByOffset(i);
+    element->PositiveDegreeDay(pdds,pds,signorm);
+  }
+  /*free ressouces: */
+  xfree((void**)&pdds);
+  xfree((void**)&pds);
+  
 }
Index: /issm/branches/trunk-jpl-damage/src/c/modules/RheologyBbarAbsGradientx/RheologyBbarAbsGradientx.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/RheologyBbarAbsGradientx/RheologyBbarAbsGradientx.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/RheologyBbarAbsGradientx/RheologyBbarAbsGradientx.cpp	(revision 12168)
@@ -27,7 +27,9 @@
 
 	/*Sum all J from all cpus of the cluster:*/
+	#ifdef _HAVE_MPI_
 	MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0,MPI_COMM_WORLD );
 	MPI_Bcast(&J_sum,1,MPI_DOUBLE,0,MPI_COMM_WORLD);
 	J=J_sum;
+	#endif
 
 	/*Assign output pointers: */
Index: /issm/branches/trunk-jpl-damage/src/c/modules/Solverx/Solverx.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/Solverx/Solverx.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/Solverx/Solverx.cpp	(revision 12168)
@@ -34,8 +34,4 @@
 
 		/*In serial mode, the Petsc Options database has not been initialized properly: */
-		#ifdef _SERIAL_
-		parameters->FindParam(&analysis_type,AnalysisTypeEnum);
-		PetscOptionsFromAnalysis(parameters,analysis_type);
-		#endif
 
 		SolverxPetsc(&uf_vector,Kff->matrix,pf->vector,uf0_vector,df_vector,parameters);
Index: /issm/branches/trunk-jpl-damage/src/c/modules/Solverx/SolverxPetsc.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/Solverx/SolverxPetsc.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/Solverx/SolverxPetsc.cpp	(revision 12168)
@@ -43,5 +43,4 @@
 	#endif
 
-
 	/*Display message*/
 	_printf_(VerboseModule(),"   Solving\n");
@@ -52,5 +51,5 @@
 	#endif
 
-	/*First, check that f-set is not NULL, i.e. model is fully constrained: {{{*/
+	/*First, check that f-set is not NULL, i.e. model is fully constrained:*/ 
 	_assert_(Kff);
 	MatGetSize(Kff,&global_m,&global_n); _assert_(global_m==global_m);
@@ -58,6 +57,6 @@
 		*puf=NULL; return;
 	}
-	/*}}}*/
-	/*Initial guess logic here: {{{1*/
+
+	/*Initial guess */
 	/*Now, check that we are not giving an initial guess to the solver, if we are running a direct solver: */
 	#if _PETSC_MAJOR_ >= 3 
@@ -74,54 +73,23 @@
 		MatGetLocalSize(Kff,&local_m,&local_n);uf=NewVec(local_n,fromlocalsize);
 	}
-	/*}}}*/
-	/*Process petsc options to see if we are using special types of external solvers: {{{1*/
+
+	/*Process petsc options to see if we are using special types of external solvers*/
 	PetscOptionsDetermineSolverType(&solver_type);
 
-	/*In serial mode, the matrices have been loaded as MPIAIJ or AIJ matrices. 
-	 We need to convert them if we are going to run the solvers successfully: */
-	#ifdef _SERIAL_
-	#if _PETSC_MAJOR_ == 2 
-	if (solver_type==MUMPSPACKAGE_LU){
-		/*Convert Kff to MATTAIJMUMPS: */
-		MatConvert(Kff,MATAIJMUMPS,MAT_REUSE_MATRIX,&Kff);
+	/*Check the solver is available*/
+	if(solver_type==MUMPSPACKAGE_LU || solver_type==MUMPSPACKAGE_CHOL){
+		#if _PETSC_MAJOR_ >=3
+			#ifndef _HAVE_MUMPS_
+			_error_("requested MUMPS solver, which was not compiled into ISSM!\n");
+			#endif
+		#endif
 	}
-	if (solver_type==MUMPSPACKAGE_CHOL){
-		/*Convert Kff to MATTSBAIJMUMPS: */
-		MatConvert(Kff,MATSBAIJMUMPS,MAT_REUSE_MATRIX,&Kff);
-	}
-	if (solver_type==SPOOLESPACKAGE_LU){
-		/*Convert Kff to MATTSBAIJMUMPS: */
-		MatConvert(Kff,MATAIJSPOOLES,MAT_REUSE_MATRIX,&Kff);
-	}
-	if (solver_type==SPOOLESPACKAGE_CHOL){
-		/*Convert Kff to MATTSBAIJMUMPS: */
-		MatConvert(Kff,MATSBAIJSPOOLES,MAT_REUSE_MATRIX,&Kff);
-	}
-	if (solver_type==SUPERLUDISTPACKAGE){
-		/*Convert Kff to MATTSBAIJMUMPS: */
-		MatConvert(Kff,MATSUPERLU_DIST,MAT_REUSE_MATRIX,&Kff);
-	}
-	if (solver_type==StokesSolverEnum){
-		_error_("Petsc 2 does not support multi-physics solvers");
-	}
-	#endif
-	#endif
-	/*}}}*/
-	/*Check the solver is available: {{{1*/
-	if(solver_type==MUMPSPACKAGE_LU || solver_type==MUMPSPACKAGE_CHOL){
-	#if _PETSC_MAJOR_ >=3
-		#ifndef _HAVE_MUMPS_
-		_error_("requested MUMPS solver, which was not compiled into ISSM!\n");
-		#endif
 
-	#endif
-	}
-	/*}}}*/
-	/*Prepare solver:{{{1*/
+	/*Prepare solver*/
 	KSPCreate(MPI_COMM_WORLD,&ksp);
 	KSPSetOperators(ksp,Kff,Kff,DIFFERENT_NONZERO_PATTERN);
 	KSPSetFromOptions(ksp);
 
-	#if defined(_SERIAL_) && _PETSC_MAJOR_==3
+	#if _PETSC_MAJOR_==3
 	/*Specific solver?: */
 	KSPGetPC(ksp,&pc);
@@ -133,7 +101,5 @@
 		#endif
 	}
-	#endif
 
-	#if defined(_PARALLEL_) && _PETSC_MAJOR_==3
 	/*Stokes: */
 	if (solver_type==StokesSolverEnum){
@@ -155,16 +121,15 @@
 	#endif
 
-	/*}}}*/
-	/*If there is an initial guess for the solution, use it, except if we are using the MUMPS direct solver, where any initial guess will crash Petsc: {{{1*/
+	/*If there is an initial guess for the solution, use it
+	 * except if we are using the MUMPS direct solver
+	 * where any initial guess will crash Petsc*/
 	if (uf0){
-		if( (solver_type!=MUMPSPACKAGE_LU) && (solver_type!=MUMPSPACKAGE_CHOL) && (solver_type!=SPOOLESPACKAGE_LU) && (solver_type!=SPOOLESPACKAGE_CHOL) && (solver_type!=SUPERLUDISTPACKAGE)){
+		if((solver_type!=MUMPSPACKAGE_LU) && (solver_type!=MUMPSPACKAGE_CHOL) && (solver_type!=SPOOLESPACKAGE_LU) && (solver_type!=SPOOLESPACKAGE_CHOL) && (solver_type!=SUPERLUDISTPACKAGE)){
 			KSPSetInitialGuessNonzero(ksp,PETSC_TRUE);
 		}
 	}
-	/*}}}*/
-	
-	if(VerboseSolver())KSPView(ksp,PETSC_VIEWER_STDOUT_WORLD);
 
 	/*Solve: */
+	if(VerboseSolver())KSPView(ksp,PETSC_VIEWER_STDOUT_WORLD);
 	KSPSolve(ksp,pf,uf);
 	
Index: /issm/branches/trunk-jpl-damage/src/c/modules/SurfaceAbsVelMisfitx/SurfaceAbsVelMisfitx.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/SurfaceAbsVelMisfitx/SurfaceAbsVelMisfitx.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/SurfaceAbsVelMisfitx/SurfaceAbsVelMisfitx.cpp	(revision 12168)
@@ -27,7 +27,9 @@
 
 	/*Sum all J from all cpus of the cluster:*/
+	#ifdef _HAVE_MPI_
 	MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0,MPI_COMM_WORLD );
 	MPI_Bcast(&J_sum,1,MPI_DOUBLE,0,MPI_COMM_WORLD);
 	J=J_sum;
+	#endif
 
 	/*Assign output pointers: */
Index: /issm/branches/trunk-jpl-damage/src/c/modules/SurfaceAreax/SurfaceAreax.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/SurfaceAreax/SurfaceAreax.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/SurfaceAreax/SurfaceAreax.cpp	(revision 12168)
@@ -28,7 +28,9 @@
 
 	/*Sum all J from all cpus of the cluster:*/
-	MPI_Reduce (&S,&S_sum,1,MPI_DOUBLE,MPI_SUM,0,MPI_COMM_WORLD );
+	#ifdef _HAVE_MPI_
+ 	MPI_Reduce (&S,&S_sum,1,MPI_DOUBLE,MPI_SUM,0,MPI_COMM_WORLD );
 	MPI_Bcast(&S_sum,1,MPI_DOUBLE,0,MPI_COMM_WORLD); 
 	S=S_sum;
+	#endif
 
 	/*add surface area to element inputs:*/
Index: /issm/branches/trunk-jpl-damage/src/c/modules/SurfaceAverageVelMisfitx/SurfaceAverageVelMisfitx.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/SurfaceAverageVelMisfitx/SurfaceAverageVelMisfitx.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/SurfaceAverageVelMisfitx/SurfaceAverageVelMisfitx.cpp	(revision 12168)
@@ -31,7 +31,9 @@
 
 	/*Sum all J from all cpus of the cluster:*/
+	#ifdef _HAVE_MPI_
 	MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0,MPI_COMM_WORLD );
 	MPI_Bcast(&J_sum,1,MPI_DOUBLE,0,MPI_COMM_WORLD);
 	J=J_sum;
+	#endif
 
 	/*Assign output pointers: */
Index: /issm/branches/trunk-jpl-damage/src/c/modules/SurfaceLogVelMisfitx/SurfaceLogVelMisfitx.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/SurfaceLogVelMisfitx/SurfaceLogVelMisfitx.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/SurfaceLogVelMisfitx/SurfaceLogVelMisfitx.cpp	(revision 12168)
@@ -27,7 +27,9 @@
 
 	/*Sum all J from all cpus of the cluster:*/
+	#ifdef _HAVE_MPI_
 	MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0,MPI_COMM_WORLD );
 	MPI_Bcast(&J_sum,1,MPI_DOUBLE,0,MPI_COMM_WORLD);
 	J=J_sum;
+	#endif
 
 	/*Assign output pointers: */
Index: /issm/branches/trunk-jpl-damage/src/c/modules/SurfaceLogVxVyMisfitx/SurfaceLogVxVyMisfitx.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/SurfaceLogVxVyMisfitx/SurfaceLogVxVyMisfitx.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/SurfaceLogVxVyMisfitx/SurfaceLogVxVyMisfitx.cpp	(revision 12168)
@@ -27,7 +27,9 @@
 
 	/*Sum all J from all cpus of the cluster:*/
+	#ifdef _HAVE_MPI_
 	MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0,MPI_COMM_WORLD );
 	MPI_Bcast(&J_sum,1,MPI_DOUBLE,0,MPI_COMM_WORLD);
 	J=J_sum;
+	#endif
 
 	/*Assign output pointers: */
Index: /issm/branches/trunk-jpl-damage/src/c/modules/SurfaceRelVelMisfitx/SurfaceRelVelMisfitx.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/SurfaceRelVelMisfitx/SurfaceRelVelMisfitx.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/SurfaceRelVelMisfitx/SurfaceRelVelMisfitx.cpp	(revision 12168)
@@ -27,7 +27,9 @@
 
 	/*Sum all J from all cpus of the cluster:*/
+	#ifdef _HAVE_MPI_
 	MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0,MPI_COMM_WORLD );
 	MPI_Bcast(&J_sum,1,MPI_DOUBLE,0,MPI_COMM_WORLD);
 	J=J_sum;
+	#endif
 
 	/*Assign output pointers: */
Index: /issm/branches/trunk-jpl-damage/src/c/modules/ThicknessAbsGradientx/ThicknessAbsGradientx.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/ThicknessAbsGradientx/ThicknessAbsGradientx.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/ThicknessAbsGradientx/ThicknessAbsGradientx.cpp	(revision 12168)
@@ -27,7 +27,9 @@
 
 	/*Sum all J from all cpus of the cluster:*/
+	#ifdef _HAVE_MPI_
 	MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0,MPI_COMM_WORLD );
 	MPI_Bcast(&J_sum,1,MPI_DOUBLE,0,MPI_COMM_WORLD);
 	J=J_sum;
+	#endif
 
 	/*Assign output pointers: */
Index: /issm/branches/trunk-jpl-damage/src/c/modules/ThicknessAbsMisfitx/ThicknessAbsMisfitx.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/ThicknessAbsMisfitx/ThicknessAbsMisfitx.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/ThicknessAbsMisfitx/ThicknessAbsMisfitx.cpp	(revision 12168)
@@ -27,7 +27,9 @@
 
 	/*Sum all J from all cpus of the cluster:*/
+	#ifdef _HAVE_MPI_
 	MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0,MPI_COMM_WORLD );
 	MPI_Bcast(&J_sum,1,MPI_DOUBLE,0,MPI_COMM_WORLD);
 	J=J_sum;
+	#endif
 
 	/*Assign output pointers: */
Index: /issm/branches/trunk-jpl-damage/src/c/modules/TimeAdaptx/TimeAdaptx.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/TimeAdaptx/TimeAdaptx.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/TimeAdaptx/TimeAdaptx.cpp	(revision 12168)
@@ -31,6 +31,6 @@
 	}
 
-	#ifdef _PARALLEL_
 	/*Figure out minimum across the cluster: */
+	#ifdef _HAVE_MPI_
 	MPI_Reduce (&min_dt,&node_min_dt,1,MPI_DOUBLE,MPI_MIN,0,MPI_COMM_WORLD );
 	MPI_Bcast(&node_min_dt,1,MPI_DOUBLE,0,MPI_COMM_WORLD);
Index: /issm/branches/trunk-jpl-damage/src/c/modules/TriMeshx/TriMeshx.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/TriMeshx/TriMeshx.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/TriMeshx/TriMeshx.cpp	(revision 12168)
@@ -10,8 +10,15 @@
 #include "../../toolkits/toolkits.h"
 #include "../../EnumDefinitions/EnumDefinitions.h"
+/*ANSI_DECLARATORS needed to call triangle library: */
+#ifndef ANSI_DECLARATORS
+#define ANSI_DECLARATORS
+#include "triangle.h"
+#undef ANSI_DECLARATORS
+#else
+#include "triangle.h"
+#endif
 /*}}}*/
 
-
-void TriMeshx(Matrix** pindex,Vector** px,Vector** py,Matrix** psegments,Vector** psegmentmarkerlist,DataSet* domain,double area,bool order){
+void TriMeshx(Matrix** pindex,Vector** px,Vector** py,Matrix** psegments,Vector** psegmentmarkerlist,DataSet* domain,DataSet* rifts,double area){
 
 	/*indexing: */
@@ -28,5 +35,5 @@
 
 	/*intermediary: */
-	int      counter,backcounter;
+	int      counter,counter2,backcounter;
 	Contour* contour=NULL;
 
@@ -39,6 +46,11 @@
 	for (i=0;i<domain->Size();i++){
 		contour=(Contour*)domain->GetObjectByOffset(i);
+		in.numberofpoints+=contour->nods-1;
+	}
+	for (i=0;i<rifts->Size();i++){
+		contour=(Contour*)rifts->GetObjectByOffset(i);
 		in.numberofpoints+=contour->nods;
 	}
+
 	/*number of point attributes: */
 	in.numberofpointattributes=1;
@@ -50,4 +62,12 @@
 	for (i=0;i<domain->Size();i++){
 		contour=(Contour*)domain->GetObjectByOffset(i);
+		for (j=0;j<contour->nods-1;j++){
+			in.pointlist[2*counter+0]=contour->x[j];
+			in.pointlist[2*counter+1]=contour->y[j];
+			counter++;
+		}
+	}
+	for (i=0;i<rifts->Size();i++){
+		contour=(Contour*)rifts->GetObjectByOffset(i);
 		for (j=0;j<contour->nods;j++){
 			in.pointlist[2*counter+0]=contour->x[j];
@@ -58,5 +78,5 @@
 	
 	/*fill in the point attribute list: */
-	in.pointattributelist = (REAL *) xmalloc(in.numberofpoints * in.numberofpointattributes * sizeof(REAL));
+	in.pointattributelist = (REAL*)xmalloc(in.numberofpoints*in.numberofpointattributes*sizeof(REAL));
 	for (i=0;i<in.numberofpoints;i++) in.pointattributelist[i] = 0.0;
 	
@@ -65,10 +85,14 @@
 	for(i=0;i<in.numberofpoints;i++) in.pointmarkerlist[i] = 0;
 
-
 	/*Build segments. First figure out number of segments: holes and closed outlines have as many segments as vertices: */
 	in.numberofsegments=0;
 	for (i=0;i<domain->Size();i++){
 		contour=(Contour*)domain->GetObjectByOffset(i);
-		in.numberofsegments+=contour->nods;
+		in.numberofsegments+=contour->nods-1;
+	}
+	for(i=0;i<rifts->Size();i++){
+		contour=(Contour*)rifts->GetObjectByOffset(i);
+		/*for rifts, we have one less segment as we have vertices*/
+		in.numberofsegments+=contour->nods-1;
 	}
 	
@@ -79,5 +103,5 @@
 	for (i=0;i<domain->Size();i++){
 		contour=(Contour*)domain->GetObjectByOffset(i);
-		for (j=0;j<contour->nods-1;j++){
+		for (j=0;j<contour->nods-2;j++){
 			in.segmentlist[2*counter+0]=counter;
 			in.segmentlist[2*counter+1]=counter+1;
@@ -92,5 +116,16 @@
 		 backcounter=counter;
 	}
-
+	counter2=counter;
+	for (i=0;i<rifts->Size();i++){
+		contour=(Contour*)rifts->GetObjectByOffset(i);
+		for (j=0;j<(contour->nods-1);j++){
+			in.segmentlist[2*counter2+0]=counter;
+			in.segmentlist[2*counter2+1]=counter+1;
+			in.segmentmarkerlist[counter2]=2+i;
+			counter2++;
+			counter++;
+		}
+		counter++;
+	}
 	
 	/*Build regions: */
@@ -103,20 +138,19 @@
 		for (i=0;i<domain->Size()-1;i++){
 			contour=(Contour*)domain->GetObjectByOffset(i+1);
-			GridInsideHole(&in.holelist[2*i+0],&in.holelist[2*i+1],contour->nods,contour->x,contour->y);
+			GridInsideHole(&in.holelist[2*i+0],&in.holelist[2*i+1],contour->nods-1,contour->x,contour->y);
 		}
 	}
 
 	/* Make necessary initializations so that Triangle can return a triangulation in `out': */
-
-	out.pointlist = (REAL *) NULL;            
-	out.pointattributelist = (REAL *) NULL;
-	out.pointmarkerlist = (int *) NULL; 
-	out.trianglelist = (int *) NULL;          
-	out.triangleattributelist = (REAL *) NULL;
-	out.neighborlist = (int *) NULL;         
-	out.segmentlist = (int *) NULL;
-	out.segmentmarkerlist = (int *) NULL;
-	out.edgelist = (int *) NULL;             
-	out.edgemarkerlist = (int *) NULL;   
+	out.pointlist             = (REAL*)NULL;
+	out.pointattributelist    = (REAL*)NULL;
+	out.pointmarkerlist       = (int *)NULL;
+	out.trianglelist          = (int *)NULL;
+	out.triangleattributelist = (REAL*)NULL;
+	out.neighborlist          = (int *)NULL;
+	out.segmentlist           = (int *)NULL;
+	out.segmentmarkerlist     = (int *)NULL;
+	out.edgelist              = (int *)NULL;
+	out.edgemarkerlist        = (int *)NULL;
 
 	/* Triangulate the points:.  Switches are chosen to read and write a  */
@@ -125,12 +159,7 @@
 	/*   produce an edge list (e), a Voronoi diagram (v), and a triangle */
 	/*   neighbor list (n).                                              */
-
 	sprintf(options,"%s%lf","pQzDq30ia",area); /*replace V by Q to quiet down the logging*/
-
-  
 	triangulate(options, &in, &out, NULL);
-
 	/*report(&out, 0, 1, 1, 1, 1, 0);*/
-
 
 	/*Allocate index, x and y: */
@@ -141,15 +170,14 @@
 	segmentmarkerlist=(double*)xmalloc(out.numberofsegments*sizeof(double));
 
-	for (i = 0; i < out.numberoftriangles; i++) {
+	for (i = 0; i< out.numberoftriangles; i++) {
 		for (j = 0; j < out.numberofcorners; j++) {
-			*(index+3*i+j)=(double)out.trianglelist[i * out.numberofcorners + j]+1;
-		}
-	}
-	for (i = 0; i < out.numberofpoints; i++) {
-		x[i]=out.pointlist[i * 2 + 0];
-		y[i]=out.pointlist[i * 2 + 1];
-	}
-	
-	for (i = 0; i < out.numberofsegments; i++) {
+			index[3*i+j]=(double)out.trianglelist[i*out.numberofcorners+j]+1;
+		}
+	}
+	for (i = 0; i< out.numberofpoints; i++){
+		x[i]=out.pointlist[i*2+0];
+		y[i]=out.pointlist[i*2+1];
+	}
+	for (i = 0; i<out.numberofsegments;i++){
 		segments[3*i+0]=(double)out.segmentlist[i*2+0]+1;
 		segments[3*i+1]=(double)out.segmentlist[i*2+1]+1;
@@ -157,14 +185,9 @@
 	}
 
-
-
 	/*Associate elements with segments: */
 	AssociateSegmentToElement(&segments,out.numberofsegments,index,out.numberoftriangles);
 
 	/*Order segments so that their normals point outside the domain: */
-	if(order){
-		OrderSegments(&segments,out.numberofsegments, index,out.numberoftriangles);
-	}
-
+	OrderSegments(&segments,out.numberofsegments, index,out.numberoftriangles);
 
 	/*Output : */
@@ -179,4 +202,3 @@
 	*py=new Vector(y,out.numberofpoints);
 	*psegmentmarkerlist=new Vector(segmentmarkerlist,out.numberofsegments);
-
 }
Index: /issm/branches/trunk-jpl-damage/src/c/modules/TriMeshx/TriMeshx.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/TriMeshx/TriMeshx.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/TriMeshx/TriMeshx.h	(revision 12168)
@@ -6,22 +6,10 @@
 #define _TRIMESHX_H_
 
-
-
-/*ANSI_DECLARATORS needed to call triangle library: */
-#ifndef ANSI_DECLARATORS
-#define ANSI_DECLARATORS
-#include "triangle.h"
-#undef ANSI_DECLARATORS
-#else
-#include "triangle.h"
-#endif
-
 #include "string.h"
-
 #include "../../Container/Container.h"
 #include "../../objects/objects.h"
 
 /* local prototypes: */
-void TriMeshx(Matrix** pindex,Vector** px,Vector** py,Matrix** psegments,Vector** psegmentmarkerlist,DataSet* domain,double area,bool order);
+void TriMeshx(Matrix** pindex,Vector** px,Vector** py,Matrix** psegments,Vector** psegmentmarkerlist,DataSet* domain,DataSet* rifts,double area);
 
 #endif  /* _TRIMESHX_H */
Index: /issm/branches/trunk-jpl-damage/src/c/modules/modules.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/modules.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/modules.h	(revision 12168)
@@ -62,4 +62,5 @@
 #include "./Exp2Kmlx/Exp2Kmlx.h"
 #include "./Kml2Expx/Kml2Expx.h"
+#include "./Krigingx/Krigingx.h"
 #include "./Shp2Kmlx/Shp2Kmlx.h"
 #include "./MassFluxx/MassFluxx.h"
@@ -111,7 +112,5 @@
 #include "./TimeAdaptx/TimeAdaptx.h"
 #include "./TriaSearchx/TriaSearchx.h"
-#ifdef _SERIAL_
 #include "./TriMeshx/TriMeshx.h"
-#endif
 #include "./ThicknessAbsMisfitx/ThicknessAbsMisfitx.h"
 #include "./ThicknessAbsGradientx/ThicknessAbsGradientx.h"
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Bamg/BamgGeom.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Bamg/BamgGeom.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Bamg/BamgGeom.cpp	(revision 12168)
@@ -19,20 +19,4 @@
 }
 /*}}}*/
-/*FUNCTION BamgGeom::BamgGeom(mxArray* matlab_struct){{{1*/
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-BamgGeom::BamgGeom(mxArray* matlab_struct){
-
-	FetchData(&this->Vertices,        &this->VerticesSize[0],        &this->VerticesSize[1],        mxGetAssignedField(matlab_struct,0,"Vertices"));
-	FetchData(&this->Edges,           &this->EdgesSize[0],           &this->EdgesSize[1],           mxGetAssignedField(matlab_struct,0,"Edges"));
-	this->TangentAtEdgesSize[0]=0,    this->TangentAtEdgesSize[1]=0;    this->TangentAtEdges=NULL;
-	FetchData(&this->Corners,         &this->CornersSize[0],         &this->CornersSize[1],         mxGetAssignedField(matlab_struct,0,"Corners"));
-	FetchData(&this->RequiredVertices,&this->RequiredVerticesSize[0],&this->RequiredVerticesSize[1],mxGetAssignedField(matlab_struct,0,"RequiredVertices"));
-	FetchData(&this->RequiredEdges,   &this->RequiredEdgesSize[0],   &this->RequiredEdgesSize[1],   mxGetAssignedField(matlab_struct,0,"RequiredEdges"));
-	FetchData(&this->CrackedEdges,    &this->CrackedEdgesSize[0],    &this->CrackedEdgesSize[1],    mxGetAssignedField(matlab_struct,0,"CrackedEdges"));
-	FetchData(&this->SubDomains,      &this->SubDomainsSize[0],      &this->SubDomainsSize[1],      mxGetAssignedField(matlab_struct,0,"SubDomains"));
-
-}
-#endif
-/*}}}*/
 /*FUNCTION BamgGeom::~BamgGeom(){{{1*/
 BamgGeom::~BamgGeom(){
@@ -49,77 +33,2 @@
 }
 /*}}}*/
-
-/*Methods*/
-/*FUNCTION BamgGeom::SetMatlabStructureFields{{{1*/
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-void BamgGeom::SetMatlabStructureFields(mxArray** matlab_struct){
-
-	/*Intermediary*/
-	int         i;
-	mxArray*    output=NULL;
-	const int         numfields=7;
-	const char* fnames[numfields];
-	mwSize      ndim=2;
-	mwSize      dimensions[2]={1,1};
-
-	/*Initialize field names*/
-	i=0;
-	fnames[i++] = "Vertices";
-	fnames[i++] = "Edges";
-	fnames[i++] = "TangentAtEdges";
-	fnames[i++] = "RequiredVertices";
-	fnames[i++] = "RequiredEdges";
-	fnames[i++] = "CrackedEdges";
-	fnames[i++] = "SubDomains";
-	_assert_(i==numfields);
-
-	/*Initialize Matlab structure*/
-	output=mxCreateStructArray(ndim,dimensions,numfields,fnames);
-
-	/*set each matlab each field*/
-	i=0;
-	i++; SetMatlabStructureField(output,"Vertices",        this->VerticesSize[0],        this->VerticesSize[1],        this->Vertices);
-	i++; SetMatlabStructureField(output,"Edges",           this->EdgesSize[0],           this->EdgesSize[1],           this->Edges);
-	i++; SetMatlabStructureField(output,"TangentAtEdges",  this->TangentAtEdgesSize[0],  this->TangentAtEdgesSize[1],  this->TangentAtEdges);
-	i++; SetMatlabStructureField(output,"RequiredVertices",this->RequiredVerticesSize[0],this->RequiredVerticesSize[1],this->RequiredVertices);
-	i++; SetMatlabStructureField(output,"RequiredEdges",   this->RequiredEdgesSize[0],   this->RequiredEdgesSize[1],   this->RequiredEdges);
-	i++; SetMatlabStructureField(output,"CrackedEdges",    this->CrackedEdgesSize[0],    this->CrackedEdgesSize[1],    this->CrackedEdges);
-	i++; SetMatlabStructureField(output,"SubDomains",      this->SubDomainsSize[0],      this->SubDomainsSize[1],      this->SubDomains);
-	_assert_(i==numfields);
-
-	/*Assign output*/
-	*matlab_struct=output;
-
-}
-#endif
-/*}}}*/
-/*FUNCTION BamgGeom::SetMatlabStructureField{{{1*/
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-void BamgGeom::SetMatlabStructureField(mxArray* matlab_struct,const char* fieldname,int fieldrows,int fieldcols,double* fieldpointer){
-
-	/*Intermediary*/
-	int         i1,i2;
-	mxArray*    pfield=NULL;
-	mxArray*    pfield2=NULL;
-
-	/*Copy field*/
-	double*  fieldcopy=NULL;
-	if (fieldrows*fieldcols){
-		fieldcopy=(double*)xmalloc(fieldrows*fieldcols*sizeof(double));
-		for(i1=0;i1<fieldrows;i1++){
-			for(i2=0;i2<fieldcols;i2++){
-				fieldcopy[fieldcols*i1+i2]=fieldpointer[fieldcols*i1+i2];
-			}
-		}
-	}
-
-	/*Set matlab field*/
-	pfield=mxCreateDoubleMatrix(0,0,mxREAL);
-	mxSetM(pfield,fieldcols);
-	mxSetN(pfield,fieldrows);
-	mxSetPr(pfield,fieldcopy);
-	mexCallMATLAB(1,&pfield2,1,&pfield,"transpose");//transpose
-	mxSetField(matlab_struct,0,fieldname,pfield2);
-}
-#endif
-/*}}}*/
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Bamg/BamgGeom.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Bamg/BamgGeom.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Bamg/BamgGeom.h	(revision 12168)
@@ -4,8 +4,4 @@
 #ifndef _BAMGGEOM_H_
 #define _BAMGGEOM_H_
-
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-#include <mex.h>
-#endif
 
 class BamgGeom{
@@ -30,13 +26,5 @@
 
 		BamgGeom();
-		#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-		BamgGeom(mxArray* matlab_struct);
-		#endif
 		~BamgGeom();
-
-		#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-		void SetMatlabStructureFields(mxArray** matlab_struct);
-		void SetMatlabStructureField(mxArray* matlab_struct,const char* fieldname,int fieldrows,int fieldcols,double* fieldpointer);
-		#endif
 };
 
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Bamg/BamgMesh.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Bamg/BamgMesh.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Bamg/BamgMesh.cpp	(revision 12168)
@@ -18,7 +18,7 @@
 	this->CrackedEdgesSize[0]=0,              this->CrackedEdgesSize[1]=0;             this->CrackedEdges=NULL;
 
-	this->VerticesOnGeomVertexSize[0]=0, this->VerticesOnGeomVertexSize[1]=0;this->VerticesOnGeomVertex=NULL;
-	this->VerticesOnGeomEdgeSize[0]=0,   this->VerticesOnGeomEdgeSize[1]=0;  this->VerticesOnGeomEdge=NULL;
-	this->EdgesOnGeomEdgeSize[0]=0,      this->EdgesOnGeomEdgeSize[1]=0;     this->EdgesOnGeomEdge=NULL;
+	this->VerticesOnGeomVertexSize[0]=0,      this->VerticesOnGeomVertexSize[1]=0;     this->VerticesOnGeomVertex=NULL;
+	this->VerticesOnGeomEdgeSize[0]=0,        this->VerticesOnGeomEdgeSize[1]=0;       this->VerticesOnGeomEdge=NULL;
+	this->EdgesOnGeomEdgeSize[0]=0,           this->EdgesOnGeomEdgeSize[1]=0;          this->EdgesOnGeomEdge=NULL;
 
 	this->IssmEdgesSize[0]=0,                 this->IssmEdgesSize[1]=0;                this->IssmEdges=NULL;
@@ -28,37 +28,5 @@
 	this->NodalConnectivitySize[0]=0,         this->NodalConnectivitySize[1]=0;        this->NodalConnectivity=NULL;
 	this->NodalElementConnectivitySize[0]=0,  this->NodalElementConnectivitySize[1]=0; this->NodalElementConnectivity=NULL;
-
-
 }
-/*}}}*/
-/*FUNCTION BamgMesh::BamgMesh(mxArray* matlab_struct){{{1*/
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-BamgMesh::BamgMesh(mxArray* matlab_struct){
-
-	int lines,cols;
-
-	FetchData(&this->Vertices,            &this->VerticesSize[0],            &this->VerticesSize[1],            mxGetAssignedField(matlab_struct,0,"Vertices"));
-	FetchData(&this->Edges,               &this->EdgesSize[0],               &this->EdgesSize[1],               mxGetAssignedField(matlab_struct,0,"Edges"));
-	FetchData(&this->Triangles,           &this->TrianglesSize[0],           &this->TrianglesSize[1],           mxGetAssignedField(matlab_struct,0,"Triangles"));
-	this->QuadrilateralsSize[0]=0,        this->QuadrilateralsSize[1]=0;     this->Quadrilaterals=NULL;
-
-	this->SubDomainsSize[0]=0,            this->SubDomainsSize[1]=0;         this->SubDomains=NULL;
-	this->SubDomainsFromGeomSize[0]=0,    this->SubDomainsFromGeomSize[1]=0; this->SubDomainsFromGeom=NULL;
-	this->CrackedVerticesSize[0]=0,       this->CrackedVerticesSize[1]=0;    this->CrackedVertices=NULL;
-	FetchData(&this->CrackedEdges,        &this->CrackedEdgesSize[0],        &this->CrackedEdgesSize[1],        mxGetAssignedField(matlab_struct,0,"CrackedEdges"));
-
-	FetchData(&this->VerticesOnGeomEdge,  &this->VerticesOnGeomEdgeSize[0],  &this->VerticesOnGeomEdgeSize[1],  mxGetAssignedField(matlab_struct,0,"VerticesOnGeomEdge"));
-	FetchData(&this->VerticesOnGeomVertex,&this->VerticesOnGeomVertexSize[0],&this->VerticesOnGeomVertexSize[1],mxGetAssignedField(matlab_struct,0,"VerticesOnGeomVertex"));
-	FetchData(&this->EdgesOnGeomEdge,     &this->EdgesOnGeomEdgeSize[0],     &this->EdgesOnGeomEdgeSize[1],     mxGetAssignedField(matlab_struct,0,"EdgesOnGeomEdge"));
-
-	this->IssmEdgesSize[0]=0,             this->IssmEdgesSize[1]=0;          this->IssmEdges=NULL;
-	FetchData(&this->IssmSegments,        &this->IssmSegmentsSize[0],        &this->IssmSegmentsSize[1],        mxGetAssignedField(matlab_struct,0,"IssmSegments"));
-
-	this->ElementConnectivitySize[0]=0,      this->ElementConnectivitySize[1]=0;      this->ElementConnectivity=NULL;
-	this->NodalConnectivitySize[0]=0,        this->NodalConnectivitySize[1]=0;        this->NodalConnectivity=NULL;
-	this->NodalElementConnectivitySize[0]=0, this->NodalElementConnectivitySize[1]=0; this->NodalElementConnectivity=NULL;
-
-}
-#endif
 /*}}}*/
 /*FUNCTION BamgMesh::~BamgMesh(){{{1*/
@@ -89,95 +57,2 @@
 }
 /*}}}*/
-
-/*Methods*/
-/*FUNCTION BamgMesh::SetMatlabStructureFields{{{1*/
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-void BamgMesh::SetMatlabStructureFields(mxArray** matlab_struct){
-
-	/*Intermediary*/
-	int         i;
-	mxArray*    output=NULL;
-	const int         numfields=16;
-	const char* fnames[numfields];
-	mwSize      ndim=2;
-	mwSize      dimensions[2]={1,1};
-
-	/*Initialize field names*/
-	i=0;
-	fnames[i++] = "Triangles";
-	fnames[i++] = "Vertices";
-	fnames[i++] = "Edges";
-	fnames[i++] = "IssmSegments";
-	fnames[i++] = "IssmEdges";
-	fnames[i++] = "Quadrilaterals";
-	fnames[i++] = "VerticesOnGeomVertex";
-	fnames[i++] = "VerticesOnGeomEdge";
-	fnames[i++] = "EdgesOnGeomEdge";
-	fnames[i++] = "SubDomains";
-	fnames[i++] = "SubDomainsFromGeom";
-	fnames[i++] = "ElementConnectivity";
-	fnames[i++] = "NodalConnectivity";
-	fnames[i++] = "NodalElementConnectivity";
-	fnames[i++] = "CrackedVertices";
-	fnames[i++] = "CrackedEdges";
-	_assert_(i==numfields);
-
-	/*Initialize Matlab structure*/
-	output=mxCreateStructArray(ndim,dimensions,numfields,fnames);
-
-	/*set each matlab each field*/
-	i=0;
-	i++; SetMatlabStructureField(output,"Triangles",                this->TrianglesSize[0],                this->TrianglesSize[1],                 this->Triangles);
-	i++; SetMatlabStructureField(output,"Vertices",                 this->VerticesSize[0],                 this->VerticesSize[1],                  this->Vertices);
-	i++; SetMatlabStructureField(output,"Edges",                    this->EdgesSize[0],                    this->EdgesSize[1],                     this->Edges);
-	i++; SetMatlabStructureField(output,"IssmSegments",             this->IssmSegmentsSize[0],             this->IssmSegmentsSize[1],              this->IssmSegments);
-	i++; SetMatlabStructureField(output,"IssmEdges",                this->IssmEdgesSize[0],                this->IssmEdgesSize[1],                 this->IssmEdges);
-	i++; SetMatlabStructureField(output,"Quadrilaterals",           this->QuadrilateralsSize[0],           this->QuadrilateralsSize[1],            this->Quadrilaterals);
-	i++; SetMatlabStructureField(output,"VerticesOnGeomVertex",this->VerticesOnGeomVertexSize[0],this->VerticesOnGeomVertexSize[1], this->VerticesOnGeomVertex);
-	i++; SetMatlabStructureField(output,"VerticesOnGeomEdge",  this->VerticesOnGeomEdgeSize[0],  this->VerticesOnGeomEdgeSize[1],   this->VerticesOnGeomEdge);
-	i++; SetMatlabStructureField(output,"EdgesOnGeomEdge",     this->EdgesOnGeomEdgeSize[0],     this->EdgesOnGeomEdgeSize[1],      this->EdgesOnGeomEdge);
-	i++; SetMatlabStructureField(output,"SubDomains",               this->SubDomainsSize[0],               this->SubDomainsSize[1],                this->SubDomains);
-	i++; SetMatlabStructureField(output,"SubDomainsFromGeom",       this->SubDomainsFromGeomSize[0],       this->SubDomainsFromGeomSize[1],        this->SubDomainsFromGeom);
-	i++; SetMatlabStructureField(output,"ElementConnectivity",      this->ElementConnectivitySize[0],      this->ElementConnectivitySize[1],       this->ElementConnectivity);
-	i++; SetMatlabStructureField(output,"NodalConnectivity",        this->NodalConnectivitySize[0],        this->NodalConnectivitySize[1],         this->NodalConnectivity);
-	i++; SetMatlabStructureField(output,"NodalElementConnectivity", this->NodalElementConnectivitySize[0], this->NodalElementConnectivitySize[1],  this->NodalElementConnectivity);
-	i++; SetMatlabStructureField(output,"CrackedVertices",          this->CrackedVerticesSize[0],          this->CrackedVerticesSize[1],           this->CrackedVertices);
-	i++; SetMatlabStructureField(output,"CrackedEdges",             this->CrackedEdgesSize[0],             this->CrackedEdgesSize[1],              this->CrackedEdges);
-	_assert_(i==numfields);
-
-	/*Assign output*/
-	*matlab_struct=output;
-
-}
-#endif
-/*}}}*/
-/*FUNCTION BamgMesh::SetMatlabStructureField{{{1*/
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-void BamgMesh::SetMatlabStructureField(mxArray* matlab_struct,const char* fieldname,int fieldrows,int fieldcols,double* fieldpointer){
-
-	/*Intermediary*/
-	int         i1,i2;
-	mxArray*    pfield=NULL;
-	mxArray*    pfield2=NULL;
-
-	/*Copy field*/
-	double*  fieldcopy=NULL;
-	if (fieldrows*fieldcols){
-		fieldcopy=(double*)xmalloc(fieldrows*fieldcols*sizeof(double));
-		for(i1=0;i1<fieldrows;i1++){
-			for(i2=0;i2<fieldcols;i2++){
-				fieldcopy[fieldcols*i1+i2]=fieldpointer[fieldcols*i1+i2];
-			}
-		}
-	}
-
-	/*Set matlab field*/
-	pfield=mxCreateDoubleMatrix(0,0,mxREAL);
-	mxSetM(pfield,fieldcols);
-	mxSetN(pfield,fieldrows);
-	mxSetPr(pfield,fieldcopy);
-	mexCallMATLAB(1,&pfield2,1,&pfield,"transpose");//transpose
-	mxSetField(matlab_struct,0,fieldname,pfield2);
-}
-#endif
-/*}}}*/
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Bamg/BamgMesh.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Bamg/BamgMesh.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Bamg/BamgMesh.h	(revision 12168)
@@ -4,8 +4,4 @@
 #ifndef _BAMGMESH_H_
 #define _BAMGMESH_H_
-
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-#include <mex.h>
-#endif
 
 class BamgMesh{
@@ -51,14 +47,5 @@
 
 		BamgMesh();
-		#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-		BamgMesh(mxArray* matlab_struct);
-		#endif
 		~BamgMesh();
-
-		#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-		void SetMatlabStructureFields(mxArray** matlab_struct);
-		void SetMatlabStructureField(mxArray* matlab_struct,const char* fieldname,int fieldrows,int fieldcols,double* fieldpointer);
-		#endif
-
 };
 
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Bamg/BamgOpts.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Bamg/BamgOpts.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Bamg/BamgOpts.cpp	(revision 12168)
@@ -40,44 +40,4 @@
 
 }
-/*}}}*/
-/*FUNCTION BamgOpts::BamgOpts(mxArray* matlab_struct){{{1*/
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-BamgOpts::BamgOpts(mxArray* matlab_struct){
-
-	FetchData(&this->anisomax,mxGetField(matlab_struct,0,"anisomax"));
-	FetchData(&this->cutoff,mxGetField(matlab_struct,0,"cutoff"));
-	FetchData(&this->coeff,mxGetField(matlab_struct,0,"coeff"));
-	FetchData(&this->errg,mxGetField(matlab_struct,0,"errg"));
-	FetchData(&this->gradation,mxGetField(matlab_struct,0,"gradation"));
-	FetchData(&this->Hessiantype,mxGetField(matlab_struct,0,"Hessiantype"));
-	FetchData(&this->MaxCornerAngle,mxGetField(matlab_struct,0,"MaxCornerAngle"));
-	FetchData(&this->maxnbv,mxGetField(matlab_struct,0,"maxnbv"));
-	FetchData(&this->maxsubdiv,mxGetField(matlab_struct,0,"maxsubdiv"));
-	FetchData(&this->Metrictype,mxGetField(matlab_struct,0,"Metrictype"));
-	FetchData(&this->nbjacobi,mxGetField(matlab_struct,0,"nbjacobi"));
-	FetchData(&this->nbsmooth,mxGetField(matlab_struct,0,"nbsmooth"));
-	FetchData(&this->omega,mxGetField(matlab_struct,0,"omega"));
-	FetchData(&this->power,mxGetField(matlab_struct,0,"power"));
-	FetchData(&this->verbose,mxGetField(matlab_struct,0,"verbose"));
-
-	FetchData(&this->Crack,mxGetField(matlab_struct,0,"Crack"));
-	FetchData(&this->geometricalmetric,mxGetField(matlab_struct,0,"geometricalmetric"));
-	FetchData(&this->KeepVertices,mxGetField(matlab_struct,0,"KeepVertices"));
-	FetchData(&this->splitcorners,mxGetField(matlab_struct,0,"splitcorners"));
-
-	FetchData(&this->hmin,mxGetField(matlab_struct,0,"hmin"));
-	FetchData(&this->hmax,mxGetField(matlab_struct,0,"hmax"));
-	FetchData(&this->hminVertices,&this->hminVerticesSize[0],&this->hminVerticesSize[1],mxGetField(matlab_struct,0,"hminVertices"));
-	FetchData(&this->hmaxVertices,&this->hmaxVerticesSize[0],&this->hmaxVerticesSize[1],mxGetField(matlab_struct,0,"hmaxVertices"));
-	FetchData(&this->hVertices,&this->hVerticesSize[0],&this->hVerticesSize[1],mxGetField(matlab_struct,0,"hVertices"));
-	FetchData(&this->metric,&this->metricSize[0],&this->metricSize[1],mxGetField(matlab_struct,0,"metric"));
-	FetchData(&this->field,&this->fieldSize[0],&this->fieldSize[1],mxGetField(matlab_struct,0,"field"));
-	FetchData(&this->err,&this->errSize[0],&this->errSize[1],mxGetField(matlab_struct,0,"err"));
-
-	/*Additional checks*/
-	this->Check();
-
-}
-#endif
 /*}}}*/
 /*FUNCTION BamgOpts::~BamgOpts() {{{1*/
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Bamg/BamgOpts.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Bamg/BamgOpts.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Bamg/BamgOpts.h	(revision 12168)
@@ -5,8 +5,4 @@
 #ifndef _BAMGOPTS_H_
 #define _BAMGOPTS_H_
-
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-#include <mex.h>
-#endif
 
 class BamgOpts{
@@ -54,7 +50,4 @@
 
 		BamgOpts();
-		#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-		BamgOpts(mxArray* matlab_struct);
-		#endif
 		~BamgOpts();
 
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Bamg/Metric.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Bamg/Metric.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Bamg/Metric.h	(revision 12168)
@@ -5,4 +5,5 @@
 #include "../../shared/Bamg/shared.h"
 #include "R2.h"
+#include <math.h>
 
 namespace bamg {
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Bamg/QuadTree.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Bamg/QuadTree.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Bamg/QuadTree.h	(revision 12168)
@@ -33,9 +33,4 @@
 					int   Id(){_error_("not implemented yet");};
 					int   MyRank(){_error_("not implemented yet");};
-					#ifdef _SERIAL_
-					void  Marshall(char** pmarshalled_dataset){_error_("not implemented yet");};
-					int   MarshallSize(){_error_("not implemented yet");};
-					void  Demarshall(char** pmarshalled_dataset){_error_("not implemented yet");};
-					#endif
 					int   ObjectEnum(){_error_("not implemented yet");};
 					Object* copy(){_error_("not implemented yet");};
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Constraints/SpcDynamic.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Constraints/SpcDynamic.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Constraints/SpcDynamic.cpp	(revision 12168)
@@ -72,68 +72,4 @@
 }
 /*}}}1*/
-#ifdef _SERIAL_
-/*FUNCTION SpcDynamic::Marshall {{{1*/
-void  SpcDynamic::Marshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   enum_type=0;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*get enum type of SpcDynamic: */
-	enum_type=SpcDynamicEnum;
-	
-	/*marshall enum: */
-	memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-	
-	/*marshall SpcDynamic data: */
-	memcpy(marshalled_dataset,&sid,sizeof(sid));marshalled_dataset+=sizeof(sid);
-	memcpy(marshalled_dataset,&nodeid,sizeof(nodeid));marshalled_dataset+=sizeof(nodeid);
-	memcpy(marshalled_dataset,&dof,sizeof(dof));marshalled_dataset+=sizeof(dof);
-	memcpy(marshalled_dataset,&value,sizeof(value));marshalled_dataset+=sizeof(value);
-	memcpy(marshalled_dataset,&isset,sizeof(isset));marshalled_dataset+=sizeof(isset);
-	memcpy(marshalled_dataset,&analysis_type,sizeof(analysis_type));marshalled_dataset+=sizeof(analysis_type);
-
-	*pmarshalled_dataset=marshalled_dataset;
-	return;
-}
-/*}}}1*/
-/*FUNCTION SpcDynamic::MarshallSize {{{1*/
-int   SpcDynamic::MarshallSize(){
-
-	return sizeof(sid)
-		+sizeof(nodeid)
-		+sizeof(dof)
-		+sizeof(value)
-		+sizeof(isset)
-		+sizeof(analysis_type)
-		+sizeof(int); //sizeof(int) for enum type
-}
-/*}}}1*/
-/*FUNCTION SpcDynamic::Demarshall {{{1*/
-void  SpcDynamic::Demarshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*this time, no need to get enum type, the pointer directly points to the beginning of the 
-	 *object data (thanks to DataSet::Demarshall):*/
-
-	memcpy(&sid,marshalled_dataset,sizeof(sid));marshalled_dataset+=sizeof(sid);
-	memcpy(&nodeid,marshalled_dataset,sizeof(nodeid));marshalled_dataset+=sizeof(nodeid);
-	memcpy(&dof,marshalled_dataset,sizeof(dof));marshalled_dataset+=sizeof(dof);
-	memcpy(&value,marshalled_dataset,sizeof(value));marshalled_dataset+=sizeof(value);
-	memcpy(&isset,marshalled_dataset,sizeof(isset));marshalled_dataset+=sizeof(isset);
-	memcpy(&analysis_type,marshalled_dataset,sizeof(analysis_type));marshalled_dataset+=sizeof(analysis_type);
-
-	/*return: */
-	*pmarshalled_dataset=marshalled_dataset;
-	return;
-}
-/*}}}1*/
-#endif
 /*FUNCTION SpcDynamic::ObjectEnum{{{1*/
 int SpcDynamic::ObjectEnum(void){
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Constraints/SpcDynamic.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Constraints/SpcDynamic.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Constraints/SpcDynamic.h	(revision 12168)
@@ -34,9 +34,4 @@
 		int   Id(); 
 		int   MyRank();
-		#ifdef _SERIAL_
-		void  Marshall(char** pmarshalled_dataset);
-		int   MarshallSize();
-		void  Demarshall(char** pmarshalled_dataset);
-		#endif
 		int   ObjectEnum();
 		Object* copy();
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Constraints/SpcStatic.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Constraints/SpcStatic.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Constraints/SpcStatic.cpp	(revision 12168)
@@ -75,65 +75,4 @@
 }
 /*}}}1*/
-#ifdef _SERIAL_
-/*FUNCTION SpcStatic::Marshall {{{1*/
-void  SpcStatic::Marshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   enum_type=0;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*get enum type of SpcStatic: */
-	enum_type=SpcStaticEnum;
-	
-	/*marshall enum: */
-	memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-	
-	/*marshall SpcStatic data: */
-	memcpy(marshalled_dataset,&sid,sizeof(sid));marshalled_dataset+=sizeof(sid);
-	memcpy(marshalled_dataset,&nodeid,sizeof(nodeid));marshalled_dataset+=sizeof(nodeid);
-	memcpy(marshalled_dataset,&dof,sizeof(dof));marshalled_dataset+=sizeof(dof);
-	memcpy(marshalled_dataset,&value,sizeof(value));marshalled_dataset+=sizeof(value);
-	memcpy(marshalled_dataset,&analysis_type,sizeof(analysis_type));marshalled_dataset+=sizeof(analysis_type);
-
-	*pmarshalled_dataset=marshalled_dataset;
-	return;
-}
-/*}}}1*/
-/*FUNCTION SpcStatic::MarshallSize {{{1*/
-int   SpcStatic::MarshallSize(){
-
-	return sizeof(sid)
-		+sizeof(nodeid)
-		+sizeof(dof)
-		+sizeof(value)
-		+sizeof(analysis_type)
-		+sizeof(int); //sizeof(int) for enum type
-}
-/*}}}1*/
-/*FUNCTION SpcStatic::Demarshall {{{1*/
-void  SpcStatic::Demarshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*this time, no need to get enum type, the pointer directly points to the beginning of the 
-	 *object data (thanks to DataSet::Demarshall):*/
-
-	memcpy(&sid,marshalled_dataset,sizeof(sid));marshalled_dataset+=sizeof(sid);
-	memcpy(&nodeid,marshalled_dataset,sizeof(nodeid));marshalled_dataset+=sizeof(nodeid);
-	memcpy(&dof,marshalled_dataset,sizeof(dof));marshalled_dataset+=sizeof(dof);
-	memcpy(&value,marshalled_dataset,sizeof(value));marshalled_dataset+=sizeof(value);
-	memcpy(&analysis_type,marshalled_dataset,sizeof(analysis_type));marshalled_dataset+=sizeof(analysis_type);
-
-	/*return: */
-	*pmarshalled_dataset=marshalled_dataset;
-	return;
-}
-/*}}}1*/
-#endif
 /*FUNCTION SpcStatic::ObjectEnum{{{1*/
 int SpcStatic::ObjectEnum(void){
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Constraints/SpcStatic.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Constraints/SpcStatic.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Constraints/SpcStatic.h	(revision 12168)
@@ -33,9 +33,4 @@
 		int   Id(); 
 		int   MyRank();
-		#ifdef _SERIAL_
-		void  Marshall(char** pmarshalled_dataset);
-		int   MarshallSize();
-		void  Demarshall(char** pmarshalled_dataset);
-		#endif
 		int   ObjectEnum();
 		Object* copy();
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Constraints/SpcTransient.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Constraints/SpcTransient.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Constraints/SpcTransient.cpp	(revision 12168)
@@ -87,76 +87,4 @@
 }
 /*}}}1*/
-#ifdef _SERIAL_
-/*FUNCTION SpcTransient::Marshall {{{1*/
-void  SpcTransient::Marshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   enum_type=0;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*get enum type of SpcTransient: */
-	enum_type=SpcTransientEnum;
-	
-	/*marshall enum: */
-	memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-	
-	/*marshall SpcTransient data: */
-	memcpy(marshalled_dataset,&sid,sizeof(sid));marshalled_dataset+=sizeof(sid);
-	memcpy(marshalled_dataset,&nodeid,sizeof(nodeid));marshalled_dataset+=sizeof(nodeid);
-	memcpy(marshalled_dataset,&dof,sizeof(dof));marshalled_dataset+=sizeof(dof);
-	memcpy(marshalled_dataset,&nsteps,sizeof(nsteps));marshalled_dataset+=sizeof(nsteps);
-	memcpy(marshalled_dataset,&analysis_type,sizeof(analysis_type));marshalled_dataset+=sizeof(analysis_type);
-	if(nsteps){
-		memcpy(marshalled_dataset,values,nsteps*sizeof(double));marshalled_dataset+=nsteps*sizeof(double);
-		memcpy(marshalled_dataset,times,nsteps*sizeof(double));marshalled_dataset+=nsteps*sizeof(double);
-	}
-
-	*pmarshalled_dataset=marshalled_dataset;
-	return;
-}
-/*}}}1*/
-/*FUNCTION SpcTransient::MarshallSize {{{1*/
-int   SpcTransient::MarshallSize(){
-
-	return sizeof(sid)
-		+sizeof(nodeid)
-		+sizeof(dof)
-		+sizeof(nsteps)
-		+nsteps*2*sizeof(double)
-		+sizeof(analysis_type)
-		+sizeof(int); //sizeof(int) for enum type
-}
-/*}}}1*/
-/*FUNCTION SpcTransient::Demarshall {{{1*/
-void  SpcTransient::Demarshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*this time, no need to get enum type, the pointer directly points to the beginning of the 
-	 *object data (thanks to DataSet::Demarshall):*/
-
-	memcpy(&sid,marshalled_dataset,sizeof(sid));marshalled_dataset+=sizeof(sid);
-	memcpy(&nodeid,marshalled_dataset,sizeof(nodeid));marshalled_dataset+=sizeof(nodeid);
-	memcpy(&dof,marshalled_dataset,sizeof(dof));marshalled_dataset+=sizeof(dof);
-	memcpy(&nsteps,marshalled_dataset,sizeof(nsteps));marshalled_dataset+=sizeof(nsteps);
-	memcpy(&analysis_type,marshalled_dataset,sizeof(analysis_type));marshalled_dataset+=sizeof(analysis_type);
-	if(nsteps){
-		values=(double*)xmalloc(nsteps*sizeof(double));
-		times=(double*)xmalloc(nsteps*sizeof(double));
-		memcpy(values,marshalled_dataset,nsteps*sizeof(double));marshalled_dataset+=nsteps*sizeof(double);
-		memcpy(times,marshalled_dataset,nsteps*sizeof(double));marshalled_dataset+=nsteps*sizeof(double);
-	}
-
-	/*return: */
-	*pmarshalled_dataset=marshalled_dataset;
-	return;
-}
-/*}}}1*/
-#endif
 /*FUNCTION SpcTransient::ObjectEnum{{{1*/
 int SpcTransient::ObjectEnum(void){
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Constraints/SpcTransient.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Constraints/SpcTransient.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Constraints/SpcTransient.h	(revision 12168)
@@ -35,9 +35,4 @@
 		int   Id(); 
 		int   MyRank();
-		#ifdef _SERIAL_
-		void  Marshall(char** pmarshalled_dataset);
-		int   MarshallSize();
-		void  Demarshall(char** pmarshalled_dataset);
-		#endif
 		int   ObjectEnum();
 		Object* copy();
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Contour.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Contour.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Contour.cpp	(revision 12168)
@@ -79,71 +79,4 @@
 }
 /*}}}*/
-#ifdef _SERIAL_
-/*FUNCTION Contour::Marshall{{{1*/
-void  Contour::Marshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   enum_type=0;
-	char* marshalled_inputs=NULL;
-	int   marshalled_inputssize;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*get enum type of Contour: */
-	enum_type=ContourEnum;
-	
-	/*marshall enum: */
-	memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-	
-	/*marshall Contour data: */
-	memcpy(marshalled_dataset,&id,sizeof(id));marshalled_dataset+=sizeof(id);
-	memcpy(marshalled_dataset,&nods,sizeof(nods));marshalled_dataset+=sizeof(nods);
-	memcpy(marshalled_dataset,&closed,sizeof(closed));marshalled_dataset+=sizeof(closed);
-	memcpy(marshalled_dataset,x,nods*sizeof(double));marshalled_dataset+=nods*sizeof(double);
-	memcpy(marshalled_dataset,y,nods*sizeof(double));marshalled_dataset+=nods*sizeof(double);
-
-	*pmarshalled_dataset=marshalled_dataset;
-	return;
-}
-/*}}}*/
-/*FUNCTION Contour::MarshallSize{{{1*/
-int   Contour::MarshallSize(){
-
-	return sizeof(id)+
-		sizeof(nods)+
-		sizeof(closed)+
-		2*nods*sizeof(double)+
-		sizeof(int); //sizeof(int) for enum type
-}
-/*}}}*/
-/*FUNCTION Contour::Demarshall{{{1*/
-void  Contour::Demarshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*this time, no need to get enum type, the pointer directly points to the beginning of the 
-	 *object data (thanks to DataSet::Demarshall):*/
-
-	memcpy(&id,marshalled_dataset,sizeof(id));marshalled_dataset+=sizeof(id);
-	memcpy(&nods,marshalled_dataset,sizeof(nods));marshalled_dataset+=sizeof(nods);
-	memcpy(&closed,marshalled_dataset,sizeof(closed));marshalled_dataset+=sizeof(closed);
-
-	if(nods){
-		this->x=(double*)xmalloc(nods*sizeof(double));
-		this->y=(double*)xmalloc(nods*sizeof(double));
-		memcpy(x,marshalled_dataset,nods*sizeof(double));marshalled_dataset+=nods*sizeof(double);
-		memcpy(y,marshalled_dataset,nods*sizeof(double));marshalled_dataset+=nods*sizeof(double);
-	}
-
-	/*return: */
-	*pmarshalled_dataset=marshalled_dataset;
-	return;
-}
-/*}}}*/
-#endif
 /*FUNCTION Contour::ObjectEnum{{{1*/
 int Contour::ObjectEnum(void){
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Contour.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Contour.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Contour.h	(revision 12168)
@@ -34,9 +34,4 @@
 		int   Id(void);
 		int   MyRank(void);
-		#ifdef _SERIAL_
-		void  Marshall(char** pmarshalled_dataset);
-		int   MarshallSize(void);
-		void  Demarshall(char** pmarshalled_dataset);
-		#endif
 		int   ObjectEnum(void);
 		Object* copy(void);
Index: /issm/branches/trunk-jpl-damage/src/c/objects/DofIndexing.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/DofIndexing.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/DofIndexing.cpp	(revision 12168)
@@ -208,128 +208,3 @@
 }		
 /*}}}*/
-#ifdef _SERIAL_
-/*FUNCTION DofIndexing::Marshall{{{1*/
-void  DofIndexing::Marshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   enum_type=0;
-	bool  flagdoftype; //to indicate if there are some doftype or if NULL
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*preliminary: */
-	if(this->doftype)flagdoftype=true;
-	else             flagdoftype=false;
-
-	/*get enum type of DofIndexing: */
-	enum_type=DofIndexingEnum;
-	
-	/*marshall enum: */
-	memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-	
-	/*marshall DofIndexing data: */
-	memcpy(marshalled_dataset,&gsize,sizeof(gsize));marshalled_dataset+=sizeof(gsize);
-	memcpy(marshalled_dataset,&fsize,sizeof(fsize));marshalled_dataset+=sizeof(fsize);
-	memcpy(marshalled_dataset,&ssize,sizeof(ssize));marshalled_dataset+=sizeof(ssize);
-	memcpy(marshalled_dataset,&flagdoftype,sizeof(flagdoftype));marshalled_dataset+=sizeof(flagdoftype);
-	memcpy(marshalled_dataset,&clone,sizeof(clone));marshalled_dataset+=sizeof(clone);
-	
-	if(this->gsize>0){
-		memcpy(marshalled_dataset,f_set,gsize*sizeof(bool));marshalled_dataset+=gsize*sizeof(bool);
-		memcpy(marshalled_dataset,s_set,gsize*sizeof(bool));marshalled_dataset+=gsize*sizeof(bool);
-		memcpy(marshalled_dataset,svalues,gsize*sizeof(double)); marshalled_dataset+=gsize*sizeof(double);
-		if(flagdoftype){ memcpy(marshalled_dataset,doftype,gsize*sizeof(int)); marshalled_dataset+=gsize*sizeof(int); }
-		memcpy(marshalled_dataset,gdoflist,gsize*sizeof(int)); marshalled_dataset+=gsize*sizeof(int);
-	}
-	if(this->fsize>0 && this->fsize!=UNDEF){ memcpy(marshalled_dataset,fdoflist,fsize*sizeof(int)); marshalled_dataset+=fsize*sizeof(int);}
-	if(this->ssize>0 && this->ssize!=UNDEF){ memcpy(marshalled_dataset,sdoflist,ssize*sizeof(int)); marshalled_dataset+=ssize*sizeof(int);}
-
-	*pmarshalled_dataset=marshalled_dataset;
-	return;
-}
-/*}}}*/
-/*FUNCTION DofIndexing::MarshallSize{{{1*/
-int   DofIndexing::MarshallSize(){
-
-	int size=0;
-
-	size+=4*sizeof(int)+sizeof(bool);
-	if(this->gsize>0){
-		size+= 2*this->gsize*sizeof(bool)+
-			   this->gsize*sizeof(double)+
-			   this->gsize*sizeof(int);
-		if(this->doftype)size+=this->gsize*sizeof(int);
-	}
-	if(this->fsize>0 && this->fsize!=UNDEF)size+=this->fsize*sizeof(int);
-	if(this->ssize>0 && this->ssize!=UNDEF)size+=this->ssize*sizeof(int);
-
-	size+=sizeof(int); //sizeof(int) for enum type
-
-	return size;
-}
-/*}}}*/
-/*FUNCTION DofIndexing::Demarshall{{{1*/
-void  DofIndexing::Demarshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   enum_type;
-	bool  flagdoftype;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*get enum type of object since DofIndexing is not directly called by DataSet: */
-	memcpy(&enum_type,marshalled_dataset,sizeof(int)); marshalled_dataset+=sizeof(int);
-
-	/*easy part: */
-	memcpy(&gsize,marshalled_dataset,sizeof(gsize));marshalled_dataset+=sizeof(gsize);
-	memcpy(&fsize,marshalled_dataset,sizeof(fsize));marshalled_dataset+=sizeof(fsize);
-	memcpy(&ssize,marshalled_dataset,sizeof(ssize));marshalled_dataset+=sizeof(ssize);
-	memcpy(&flagdoftype,marshalled_dataset,sizeof(flagdoftype));marshalled_dataset+=sizeof(flagdoftype);
-	memcpy(&clone,marshalled_dataset,sizeof(clone));marshalled_dataset+=sizeof(clone);
-	
-	/*Allocate: */
-	if(this->gsize>0){
-		this->f_set=(bool*)xmalloc(this->gsize*sizeof(bool));
-		this->s_set=(bool*)xmalloc(this->gsize*sizeof(bool));
-		this->svalues=(double*)xmalloc(this->gsize*sizeof(double));
-		if(flagdoftype)this->doftype=(int*)xmalloc(this->gsize*sizeof(int));
-		else           this->doftype=NULL;
-		this->gdoflist=(int*)xmalloc(this->gsize*sizeof(int));
-	}
-	else{
-		this->f_set=NULL;
-		this->s_set=NULL;
-		this->svalues=NULL;
-		this->doftype=NULL;
-		this->gdoflist=NULL;
-	}
-	if(this->fsize>0)
-	 this->fdoflist=(int*)xmalloc(this->fsize*sizeof(int));
-	else
-	 this->fdoflist=NULL;
-	if(this->ssize>0)
-	 this->sdoflist=(int*)xmalloc(this->ssize*sizeof(int));
-	else
-	 this->sdoflist=NULL;
-
-	/*Copy arrays: */
-	if(this->gsize>0){
-		memcpy(f_set,marshalled_dataset,gsize*sizeof(bool));marshalled_dataset+=gsize*sizeof(bool);
-		memcpy(s_set,marshalled_dataset,gsize*sizeof(bool));marshalled_dataset+=gsize*sizeof(bool);
-		memcpy(svalues,marshalled_dataset,gsize*sizeof(double));marshalled_dataset+=gsize*sizeof(double);
-		if(flagdoftype){memcpy(doftype,marshalled_dataset,gsize*sizeof(int));marshalled_dataset+=gsize*sizeof(int); }
-		memcpy(gdoflist,marshalled_dataset,gsize*sizeof(int));marshalled_dataset+=gsize*sizeof(int);
-	}
-	
-	if(this->fsize>0 && this->fsize!=UNDEF){ memcpy(this->fdoflist,marshalled_dataset,this->fsize*sizeof(int));marshalled_dataset+=this->fsize*sizeof(int); }
-	if(this->ssize>0 && this->ssize!=UNDEF){ memcpy(this->sdoflist,marshalled_dataset,this->ssize*sizeof(int));marshalled_dataset+=this->ssize*sizeof(int); }
-
-	/*return: */
-	*pmarshalled_dataset=marshalled_dataset;
-	return;
-}
-/*}}}*/
-#endif
-
+
Index: /issm/branches/trunk-jpl-damage/src/c/objects/DofIndexing.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/DofIndexing.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/DofIndexing.h	(revision 12168)
@@ -43,9 +43,4 @@
 		void  Echo(void); 
 		void  DeepEcho(void); 
-		#ifdef _SERIAL_
-		void  Marshall(char** pmarshalled_dataset);
-		int   MarshallSize();
-		void  Demarshall(char** pmarshalled_dataset);
-		#endif
 		void  copy(DofIndexing* properties);
 		/*}}}*/
Index: /issm/branches/trunk-jpl-damage/src/c/objects/ElementResults/BoolElementResult.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/ElementResults/BoolElementResult.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/ElementResults/BoolElementResult.cpp	(revision 12168)
@@ -64,61 +64,4 @@
 }
 /*}}}*/
-#ifdef _SERIAL_
-/*FUNCTION BoolElementResult::Marshall{{{1*/
-void  BoolElementResult::Marshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   enum_value=0;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*get enum value of BoolElementResult: */
-	enum_value=BoolElementResultEnum;
-	
-	/*marshall enum: */
-	memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);
-	
-	/*marshall BoolElementResult data: */
-	memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-	memcpy(marshalled_dataset,&value,sizeof(value));marshalled_dataset+=sizeof(value);
-	memcpy(marshalled_dataset,&time,sizeof(time));marshalled_dataset+=sizeof(time);
-	memcpy(marshalled_dataset,&step,sizeof(step));marshalled_dataset+=sizeof(step);
-
-	*pmarshalled_dataset=marshalled_dataset;
-}
-/*}}}*/
-/*FUNCTION BoolElementResult::Demarshall{{{1*/
-void  BoolElementResult::Demarshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   i;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*this time, no need to get enum type, the pointer directly points to the beginning of the 
-	 *object data (thanks to DataSet::Demarshall):*/
-	memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-	memcpy(&value,marshalled_dataset,sizeof(value));marshalled_dataset+=sizeof(value);
-	memcpy(&time,marshalled_dataset,sizeof(time));marshalled_dataset+=sizeof(time);
-	memcpy(&step,marshalled_dataset,sizeof(step));marshalled_dataset+=sizeof(step);
-
-	/*return: */
-	*pmarshalled_dataset=marshalled_dataset;
-	return;
-}
-/*}}}*/
-/*FUNCTION BoolElementResult::MarshallSize{{{1*/
-int   BoolElementResult::MarshallSize(){
-	
-	return sizeof(value)+
-		+sizeof(enum_type)
-		+sizeof(time)
-		+sizeof(step)
-		+sizeof(int); //sizeof(int) for enum value
-}
-/*}}}*/
-#endif
 /*FUNCTION BoolElementResult::ObjectEnum{{{1*/
 int BoolElementResult::ObjectEnum(void){
Index: /issm/branches/trunk-jpl-damage/src/c/objects/ElementResults/BoolElementResult.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/ElementResults/BoolElementResult.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/ElementResults/BoolElementResult.h	(revision 12168)
@@ -35,9 +35,4 @@
 		int   Id(); 
 		int   MyRank();
-		#ifdef _SERIAL_
-		void  Marshall(char** pmarshalled_dataset);
-		int   MarshallSize();
-		void  Demarshall(char** pmarshalled_dataset);
-		#endif
 		int   ObjectEnum();
 		Object* copy();
Index: /issm/branches/trunk-jpl-damage/src/c/objects/ElementResults/DoubleElementResult.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/ElementResults/DoubleElementResult.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/ElementResults/DoubleElementResult.cpp	(revision 12168)
@@ -64,61 +64,4 @@
 }
 /*}}}*/
-#ifdef _SERIAL_
-/*FUNCTION DoubleElementResult::Marshall{{{1*/
-void  DoubleElementResult::Marshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   enum_value=0;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*get enum value of DoubleElementResult: */
-	enum_value=DoubleElementResultEnum;
-	
-	/*marshall enum: */
-	memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);
-	
-	/*marshall DoubleElementResult data: */
-	memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-	memcpy(marshalled_dataset,&value,sizeof(value));marshalled_dataset+=sizeof(value);
-	memcpy(marshalled_dataset,&time,sizeof(time));marshalled_dataset+=sizeof(time);
-	memcpy(marshalled_dataset,&step,sizeof(step));marshalled_dataset+=sizeof(step);
-
-	*pmarshalled_dataset=marshalled_dataset;
-}
-/*}}}*/
-/*FUNCTION DoubleElementResult::Demarshall{{{1*/
-void  DoubleElementResult::Demarshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   i;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*this time, no need to get enum type, the pointer directly points to the beginning of the 
-	 *object data (thanks to DataSet::Demarshall):*/
-	memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-	memcpy(&value,marshalled_dataset,sizeof(value));marshalled_dataset+=sizeof(value);
-	memcpy(&step,marshalled_dataset,sizeof(step));marshalled_dataset+=sizeof(step);
-	memcpy(&time,marshalled_dataset,sizeof(time));marshalled_dataset+=sizeof(time);
-
-	/*return: */
-	*pmarshalled_dataset=marshalled_dataset;
-	return;
-}
-/*}}}*/
-/*FUNCTION DoubleElementResult::MarshallSize{{{1*/
-int   DoubleElementResult::MarshallSize(){
-	
-	return sizeof(value)+
-		+sizeof(enum_type)
-		+sizeof(time)
-		+sizeof(step)
-		+sizeof(int); //sizeof(int) for enum value
-}
-/*}}}*/
-#endif
 /*FUNCTION DoubleElementResult::ObjectEnum{{{1*/
 int DoubleElementResult::ObjectEnum(void){
Index: /issm/branches/trunk-jpl-damage/src/c/objects/ElementResults/DoubleElementResult.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/ElementResults/DoubleElementResult.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/ElementResults/DoubleElementResult.h	(revision 12168)
@@ -35,9 +35,4 @@
 		int   Id(); 
 		int   MyRank();
-		#ifdef _SERIAL_
-		void  Marshall(char** pmarshalled_dataset);
-		int   MarshallSize();
-		void  Demarshall(char** pmarshalled_dataset);
-		#endif
 		int   ObjectEnum();
 		Object* copy();
Index: /issm/branches/trunk-jpl-damage/src/c/objects/ElementResults/PentaP1ElementResult.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/ElementResults/PentaP1ElementResult.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/ElementResults/PentaP1ElementResult.cpp	(revision 12168)
@@ -67,61 +67,4 @@
 }
 /*}}}*/
-#ifdef _SERIAL_
-/*FUNCTION PentaP1ElementResult::Marshall{{{1*/
-void  PentaP1ElementResult::Marshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   enum_value=0;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*get enum value of PentaP1ElementResult: */
-	enum_value=PentaP1ElementResultEnum;
-	
-	/*marshall enum: */
-	memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);
-	
-	/*marshall PentaP1ElementResult data: */
-	memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-	memcpy(marshalled_dataset,&values,sizeof(values));marshalled_dataset+=sizeof(values);
-	memcpy(marshalled_dataset,&time,sizeof(time));marshalled_dataset+=sizeof(time);
-	memcpy(marshalled_dataset,&step,sizeof(step));marshalled_dataset+=sizeof(step);
-
-	*pmarshalled_dataset=marshalled_dataset;
-}
-/*}}}*/
-/*FUNCTION PentaP1ElementResult::MarshallSize{{{1*/
-int   PentaP1ElementResult::MarshallSize(){
-	
-	return sizeof(values)+
-		+sizeof(enum_type)
-		+sizeof(time)
-		+sizeof(step)
-		+sizeof(int); //sizeof(int) for enum value
-}
-/*}}}*/
-/*FUNCTION PentaP1ElementResult::Demarshall{{{1*/
-void  PentaP1ElementResult::Demarshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   i;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*this time, no need to get enum type, the pointer directly points to the beginning of the 
-	 *object data (thanks to DataSet::Demarshall):*/
-	memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-	memcpy(&values,marshalled_dataset,sizeof(values));marshalled_dataset+=sizeof(values);
-	memcpy(&time,marshalled_dataset,sizeof(time));marshalled_dataset+=sizeof(time);
-	memcpy(&step,marshalled_dataset,sizeof(step));marshalled_dataset+=sizeof(step);
-
-	/*return: */
-	*pmarshalled_dataset=marshalled_dataset;
-	return;
-}
-/*}}}*/
-#endif
 /*FUNCTION PentaP1ElementResult::ObjectEnum{{{1*/
 int PentaP1ElementResult::ObjectEnum(void){
Index: /issm/branches/trunk-jpl-damage/src/c/objects/ElementResults/PentaP1ElementResult.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/ElementResults/PentaP1ElementResult.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/ElementResults/PentaP1ElementResult.h	(revision 12168)
@@ -34,9 +34,4 @@
 		int   Id(); 
 		int   MyRank();
-		#ifdef _SERIAL_
-		void  Marshall(char** pmarshalled_dataset);
-		int   MarshallSize();
-		void  Demarshall(char** pmarshalled_dataset);
-		#endif
 		int   ObjectEnum();
 		Object* copy();
Index: /issm/branches/trunk-jpl-damage/src/c/objects/ElementResults/TriaP1ElementResult.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/ElementResults/TriaP1ElementResult.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/ElementResults/TriaP1ElementResult.cpp	(revision 12168)
@@ -66,62 +66,4 @@
 }
 /*}}}*/
-#ifdef _SERIAL_
-/*FUNCTION TriaP1ElementResult::Marshall{{{1*/
-void  TriaP1ElementResult::Marshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   enum_value=0;
-
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*get enum value of TriaP1ElementResult: */
-	enum_value=TriaP1ElementResultEnum;
-	
-	/*marshall enum: */
-	memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);
-	
-	/*marshall TriaP1ElementResult data: */
-	memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-	memcpy(marshalled_dataset,&values,sizeof(values));marshalled_dataset+=sizeof(values);
-	memcpy(marshalled_dataset,&time,sizeof(time));marshalled_dataset+=sizeof(time);
-	memcpy(marshalled_dataset,&step,sizeof(step));marshalled_dataset+=sizeof(step);
-
-	*pmarshalled_dataset=marshalled_dataset;
-}
-/*}}}*/
-/*FUNCTION TriaP1ElementResult::MarshallSize{{{1*/
-int   TriaP1ElementResult::MarshallSize(){
-	
-	return sizeof(values)
-		+sizeof(enum_type)
-		+sizeof(time)
-		+sizeof(step)
-		+sizeof(int); //sizeof(int) for enum value
-}
-/*}}}*/
-/*FUNCTION TriaP1ElementResult::Demarshall{{{1*/
-void  TriaP1ElementResult::Demarshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   i;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*this time, no need to get enum type, the pointer directly points to the beginning of the 
-	 *object data (thanks to DataSet::Demarshall):*/
-	memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-	memcpy(&values,marshalled_dataset,sizeof(values));marshalled_dataset+=sizeof(values);
-	memcpy(&time,marshalled_dataset,sizeof(time));marshalled_dataset+=sizeof(time);
-	memcpy(&step,marshalled_dataset,sizeof(step));marshalled_dataset+=sizeof(step);
-
-	/*return: */
-	*pmarshalled_dataset=marshalled_dataset;
-	return;
-}
-/*}}}*/
-#endif
 /*FUNCTION TriaP1ElementResult::ObjectEnum{{{1*/
 int TriaP1ElementResult::ObjectEnum(void){
Index: /issm/branches/trunk-jpl-damage/src/c/objects/ElementResults/TriaP1ElementResult.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/ElementResults/TriaP1ElementResult.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/ElementResults/TriaP1ElementResult.h	(revision 12168)
@@ -33,9 +33,4 @@
 		int   Id(); 
 		int   MyRank();
-		#ifdef _SERIAL_
-		void  Marshall(char** pmarshalled_dataset);
-		int   MarshallSize();
-		void  Demarshall(char** pmarshalled_dataset);
-		#endif
 		int   ObjectEnum();
 		Object* copy();
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Elements/Element.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Elements/Element.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Elements/Element.h	(revision 12168)
@@ -71,5 +71,5 @@
 		virtual void   MigrateGroundingLine(double* old_floating_ice,double* sheet_ungrounding)=0;
 		virtual void   PotentialSheetUngrounding(Vector* potential_sheet_ungrounding)=0;
-		virtual void   PositiveDegreeDay(void)=0;
+		virtual void   PositiveDegreeDay(double* pdds,double* pds,double signorm)=0;
 		virtual int    UpdatePotentialSheetUngrounding(double* potential_sheet_ungrounding,Vector* vec_nodes_on_iceshelf,double* nodes_on_iceshelf)=0;
 		virtual void   ResetCoordinateSystem()=0;
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Elements/Penta.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Elements/Penta.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Elements/Penta.cpp	(revision 12168)
@@ -142,161 +142,4 @@
 }
 /*}}}*/
-
-/*Marshall*/
-#ifdef _SERIAL_
-/*FUNCTION Penta::Marshall {{{1*/
-void  Penta::Marshall(char** pmarshalled_dataset){
-
-	int   i;
-	char* marshalled_dataset=NULL;
-	int   enum_type=0;
-	char* marshalled_inputs=NULL;
-	int   marshalled_inputs_size;
-	char* marshalled_results=NULL;
-	int   marshalled_results_size;
-	int   flaghook; //to indicate if hook is NULL or exists
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*get enum type of Penta: */
-	enum_type=PentaEnum;
-
-	/*marshall enum: */
-	memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-
-	/*marshall Penta data: */
-	memcpy(marshalled_dataset,&id,sizeof(id));marshalled_dataset+=sizeof(id);
-	memcpy(marshalled_dataset,&sid,sizeof(sid));marshalled_dataset+=sizeof(sid);
-	memcpy(marshalled_dataset,&numanalyses,sizeof(numanalyses));marshalled_dataset+=sizeof(numanalyses);
-
-	/*Mershall Ref: */
-	for(i=0;i<numanalyses;i++){
-		memcpy(marshalled_dataset,&element_type_list[i],sizeof(element_type_list[i]));marshalled_dataset+=sizeof(element_type_list[i]);
-	}
-
-	/*Marshall hooks: */
-	for(i=0;i<numanalyses;i++){
-		if(hnodes[i]){
-			/*Set flag to 1 as there is a hook */
-			flaghook=1;
-			memcpy(marshalled_dataset,&flaghook,sizeof(flaghook));marshalled_dataset+=sizeof(flaghook);
-			hnodes[i]->Marshall(&marshalled_dataset);
-		}
-		else{
-			/*Set flag to 0 and do not marshall flag as there is no Hook */
-			flaghook=0;
-			memcpy(marshalled_dataset,&flaghook,sizeof(flaghook));marshalled_dataset+=sizeof(flaghook);
-		}
-	}
-	hmatice->Marshall(&marshalled_dataset);
-	hmatpar->Marshall(&marshalled_dataset);
-	hneighbors->Marshall(&marshalled_dataset);
-
-	/*Marshall inputs and results: */
-	marshalled_inputs_size=inputs->MarshallSize();
-	marshalled_inputs=inputs->Marshall();
-	memcpy(marshalled_dataset,marshalled_inputs,marshalled_inputs_size*sizeof(char));
-	marshalled_dataset+=marshalled_inputs_size;
-
-	marshalled_results_size=results->MarshallSize();
-	marshalled_results=results->Marshall();
-	memcpy(marshalled_dataset,marshalled_results,marshalled_results_size*sizeof(char));
-	marshalled_dataset+=marshalled_results_size;
-
-	/*parameters: don't do anything about it. parameters are marshalled somewhere else!*/
-
-	xfree((void**)&marshalled_inputs);
-	xfree((void**)&marshalled_results);
-
-	/*marshall horizontal neighbors: */
-	memcpy(marshalled_dataset,horizontalneighborsids,3*sizeof(int));marshalled_dataset+=3*sizeof(int);
-
-	*pmarshalled_dataset=marshalled_dataset;
-	return;
-}
-/*}}}*/
-/*FUNCTION Penta::MarshallSize {{{1*/
-int   Penta::MarshallSize(){
-
-	int i;
-	int hnodes_size=0;;
-
-	for(i=0;i<numanalyses;i++){
-		hnodes_size+=sizeof(int); //Flag 0 or 1
-		if (hnodes[i]) hnodes_size+=hnodes[i]->MarshallSize();
-	}
-
-	return sizeof(id)
-		+sizeof(sid)
-		+hnodes_size
-		+sizeof(numanalyses)
-		+numanalyses*sizeof(int) //element_type_lists
-		+hmatice->MarshallSize()
-		+hmatpar->MarshallSize()
-		+hneighbors->MarshallSize()
-		+inputs->MarshallSize()
-		+results->MarshallSize()
-		+3*sizeof(int)
-		+sizeof(int); //sizeof(int) for enum type
-}
-/*}}}*/
-/*FUNCTION Penta::Demarshall {{{1*/
-void  Penta::Demarshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   i;
-	int flaghook;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*this time, no need to get enum type, the pointer directly points to the beginning of the 
-	 *object data (thanks to DataSet::Demarshall):*/
-	memcpy(&id,marshalled_dataset,sizeof(id));marshalled_dataset+=sizeof(id);
-	memcpy(&sid,marshalled_dataset,sizeof(sid));marshalled_dataset+=sizeof(sid);
-	memcpy(&numanalyses,marshalled_dataset,sizeof(numanalyses));marshalled_dataset+=sizeof(numanalyses);
-
-	/*demarshall Ref: */
-	this->element_type_list=(int*)xmalloc(this->numanalyses*sizeof(int));
-	for(i=0;i<numanalyses;i++){ memcpy(&element_type_list[i],marshalled_dataset,sizeof(int));marshalled_dataset+=sizeof(int);}
-
-	/*allocate dynamic memory: */
-	this->hnodes=new Hook*[this->numanalyses];
-	/*demarshall hooks: */
-	for(i=0;i<numanalyses;i++){
-		memcpy(&flaghook,marshalled_dataset,sizeof(flaghook));marshalled_dataset+=sizeof(flaghook);
-		if(flaghook){ // there is a hook so demarshall it
-			hnodes[i]=new Hook();
-			hnodes[i]->Demarshall(&marshalled_dataset);
-		}
-		else hnodes[i]=NULL; //There is no hook so it is NULL
-	}
-	hmatice=new Hook(); hmatice->Demarshall(&marshalled_dataset);
-	hmatpar=new Hook(); hmatpar->Demarshall(&marshalled_dataset);
-	hneighbors=new Hook(); hneighbors->Demarshall(&marshalled_dataset);
-
-	/*pointers are garbage, until configuration is carried out: */
-	nodes=NULL;
-	matice=NULL;
-	matpar=NULL;
-	verticalneighbors=NULL;
-
-	/*demarshall inputs and results: */
-	inputs=(Inputs*)DataSetDemarshallRaw(&marshalled_dataset); 
-	results=(Results*)DataSetDemarshallRaw(&marshalled_dataset); 
-
-	/*parameters: may not exist even yet, so let Configure handle it: */
-	this->parameters=NULL;
-
-	/*neighbors: */
-	memcpy(&this->horizontalneighborsids,marshalled_dataset,3*sizeof(int));marshalled_dataset+=3*sizeof(int);
-
-	/*return: */
-	*pmarshalled_dataset=marshalled_dataset;
-	return;
-}
-/*}}}*/
-#endif
 
 /*Other*/
@@ -2421,7 +2264,225 @@
 /*}}}*/
 /*FUNCTION Penta::PositiveDegreeDay{{{1*/
-void  Penta::PositiveDegreeDay(){
-
-	_error_("Not implemented yet");
+void  Penta::PositiveDegreeDay(double* pdds,double* pds,double signorm){
+
+
+   int    i,iqj,imonth;
+   double agd[NUMVERTICES];  // surface and basal
+   double saccu[NUMVERTICES] = {0};     // yearly surface accumulation
+   double smelt[NUMVERTICES] = {0};     // yearly melt
+   double precrunoff[NUMVERTICES];      // yearly runoff
+   double prect; // total precipitation during 1 year taking into account des. ef.
+   double water; //water=rain + snowmelt 
+   double runoff; //meltwater only, does not include rain 
+   double sconv; //rhow_rain/rhoi / 12 months
+
+   double  rho_water,rho_ice,density;
+   double lapser=6.5/1000, sealev=0;    // lapse rate. degrees per meter.
+   double desfac = 0.5;                 //desert elevation factor
+   double s0p[NUMVERTICES]={0};         //should be set to elevation from precip source
+   double s0t[NUMVERTICES]={0};         //should be set to elevation from temperature source
+   double st;             // elevation between altitude of the temp record and current altitude
+   double sp;             // elevation between altitude of the prec record and current altitude
+
+
+   // PDD and PD constants and variables
+   double siglim;          // sigma limit for the integration which is equal to 2.5 sigmanorm
+   double siglimc=0, siglim0, siglim0c;
+   double PDup, pddsig, PDCUT = 2.0; // PDcut: rain/snow cutoff temperature (C)
+   double DT = 0.02;
+   double pddt, pd; // pd: snow/precip fraction, precipitation falling as snow
+   
+   double q, qmpt; // q is desert/elev. fact, hnpfac is huybrect fact, and pd is normal dist.
+   double qm[NUMVERTICES] = {0};        // snow part of the precipitation 
+   double qmt[NUMVERTICES] = {0};       // precipitation without desertification effect adjustment
+   double qmp[NUMVERTICES] = {0};       // desertification taken into account
+   double pdd[NUMVERTICES] = {0};     
+   double frzndd[NUMVERTICES] = {0};  
+
+   double tstar;                        // monthly mean surface temp
+   double Tsum[NUMVERTICES]= {0};       // average summer (JJA) temperature
+   double Tsurf[NUMVERTICES] = {0};     // average annual temperature    
+   
+   double h[NUMVERTICES],s[NUMVERTICES],ttmp[NUMVERTICES],prectmp[NUMVERTICES]; // ,b[NUMVERTICES]
+   double t[NUMVERTICES][12],prec[NUMVERTICES][12];
+   double deltm=1/12;
+   int    ismon[12]={12,1,2,3,4,5,6,7,8,9,10,11};
+
+   double snwm;  // snow that could have been melted in a year.
+   double snwmf; //  ablation factor for snow per positive degree day.
+   double smf;   //  ablation factor for ice per pdd (Braithwaite 1995 from tarasov 2002).
+
+   double dfrz=1.5, CovrLm=2009./3.35e+5, dCovrLm=dfrz*CovrLm; //m*J kg^-1 C^-1 /(J kg^-1)=m/C yr
+   double supice,supcap,diffndd;
+   double fsupT=0.5,  fsupndd=0.5;  // Tsurf mode factors for supice
+   double pddtj[NUMVERTICES], hmx2;
+
+   /*Recover info at the vertices: */
+   GetInputListOnVertices(&h[0],ThicknessEnum);
+   GetInputListOnVertices(&s[0],SurfaceEnum);
+   GetInputListOnVertices(&ttmp[0],ThermalSpctemperatureEnum);
+   GetInputListOnVertices(&prectmp[0],SurfaceforcingsPrecipitationEnum);
+
+   for(i=0;i<NUMVERTICES;i++) ttmp[i]=ttmp[i]-273.15; // convertion from Kelvin to celcius
+
+   for(i=0;i<NUMVERTICES;i++)
+     for(imonth=0;imonth<12;imonth++){
+       t[i][imonth]=ttmp[i];
+       prec[i][imonth]=prectmp[i];
+   }
+
+   /*Get material parameters :*/
+   rho_ice=matpar->GetRhoIce();
+   rho_water=matpar->GetRhoWater();
+   density=rho_ice/rho_water;
+   
+   sconv=(rho_water/rho_ice)/12.; //rhow_rain/rhoi / 12 months
+     
+     /*PDD constant*/
+   siglim = 2.5*signorm; 
+   siglim0 =  siglim/DT + 0.5;
+   siglim0c =  siglimc/DT + 0.5;
+   PDup = siglimc+PDCUT;
+   
+   // seasonal loop
+   for (iqj = 0; iqj < 12; iqj++){
+     imonth =  ismon[iqj];
+     for (i = 0; i < NUMVERTICES; i++){
+       st=(s[i]-s0t[i])/1000;
+       tstar = t[i][imonth] - lapser *max(st,sealev);
+       Tsurf[i] = tstar*deltm+Tsurf[i];        
+       
+       /*********compute PD ****************/
+       if (tstar < PDup){
+	 pd = 1;
+	 if (tstar >= -siglimc){ pd = pds[int(tstar/DT + siglim0c)];}}
+       else { 
+	 pd = 0;}
+       
+       /******exp des/elev precip reduction*******/
+       sp=(s[i]-s0p[i])/1000; // deselev effect is wrt chng in topo
+       if (sp>0.0){q = exp(-desfac*sp);}
+       else {q = 1.0;}
+       
+       qmt[i]= qmt[i] + prec[i][imonth]*sconv;  //*sconv to convert in m of ice equivalent 
+       qmpt= q*prec[i][imonth]*sconv;           
+       qmp[i]= qmp[i] + qmpt;
+       qm[i]= qm[i] + qmpt*pd;
+       
+       /*********compute PDD************/
+       // ndd(month)=-(tstar-pdd(month)) since ndd+pdd gives expectation of
+       // gaussian=T_m, so ndd=-(Tsurf-pdd)
+       if (iqj>6 &&  iqj<10){ Tsum[i]=Tsum[i]+tstar;} 
+       if (tstar >= siglim) {pdd[i] = pdd[i] + tstar*deltm;}
+       else if (tstar> -siglim){
+	 pddsig=pdds[int(tstar/DT + siglim0)];
+	 pdd[i] = pdd[i] + pddsig*deltm;
+	 frzndd[i] = frzndd[i] - (tstar-pddsig)*deltm;}
+       else{frzndd[i] = frzndd[i] - tstar*deltm; }
+     }
+   } // end of seasonal loop 
+   
+   //******************************************************************
+   for(i=0;i<NUMVERTICES;i++){
+     saccu[i] = qm[i];
+     prect = qmp[i];     // total precipitation during 1 year taking into account des. ef.
+     Tsum[i]=Tsum[i]/3;
+     
+     /***** determine PDD factors *****/
+     if(Tsum[i]< -1.) {
+       snwmf=2.65*0.001;   //  ablation factor for snow per positive degree day.*0.001 to go from mm to m/ppd
+       smf=17.22*0.001;    //  ablation factor for ice per pdd (Braithwaite 1995 from tarasov 2002)
+     }
+     else if(Tsum[i]< 10){
+       snwmf = (0.15*Tsum[i] + 2.8)*0.001;
+       smf = (0.0067*pow((10.-Tsum[i]),3) + 8.3)*0.001;
+     }
+     else{
+       snwmf=4.3*0.001;
+       smf=8.3*0.001;
+     }
+     snwmf=0.95*snwmf;
+     smf=0.95*smf;
+     
+     /*****  compute PDD ablation and refreezing *****/
+     pddt = pdd[i] *365;
+     snwm = snwmf*pddt;       // snow that could have been melted in a year
+     hmx2 = min(h[i],dfrz);   // refreeze active layer max depth: dfrz
+     
+     if(snwm < saccu[i]) {
+       water=prect-saccu[i] + snwm; //water=rain + snowmelt
+       //     l 2.2= capillary factor
+       //     Should refreezing be controlled by frzndd or by mean annual Tsurf?
+       //     dCovrLm concept is of warming of active layer (thickness =d@=1-
+       //     >2m)
+       //     problem with water seepage into ice: should be sealed after
+       //     refreezing
+       //     so everything needs to be predicated on 1 year scale, except for
+       //     thermal
+       //     conductivity through ice
+       //     also, need to account that melt season has low accum, so what's
+       //     going to
+       //     hold the meltwater around for refreezing? And melt-time will have
+       //     low seasonal frzndd
+       
+       //      Superimposed ice :  Pfeffer et al. 1991, Tarasov 2002
+       
+       supice= min(hmx2*CovrLm*frzndd[i]+2.2*(saccu[i]-snwm), water); // superimposed ice
+       supcap=min(2.2*(saccu[i]-snwm),water);
+       runoff=snwm - supice;  //meltwater only, does not include rain
+     }
+     else {  //all snow melted
+       supice= min(hmx2*CovrLm*frzndd[i], prect );
+       runoff= saccu[i] + smf*(pddt-saccu[i]/snwmf) - supice;
+       supcap=0;
+     }
+     //     pdd melting doesn't cool Tsurf, so ndd refreeze shouldn't warm it
+     //     except pdd melt heat source is atmosphere, while refreeze is
+     //     ground/ice stored interim
+     //     assume pdd=ndd, then melt should equal refreeze and Tsurf should=0
+     //     assume ndd=2*pdd, then all supice is refrozen, but Tsurf should be
+     //     <0
+     //     assume ndd>pdd, little melt => little supice 
+     //     bottom line: compare for Tsurf<0 : supice and no supice case,
+     //     expect Tsurf difference
+     //     except some of cooling flux comes from atmosphere//
+     //     1 dm supice should not raise Tsurf by 1/dCovrLm = 16.675C
+     //     does supice make sense when H< 0.1m? then d=thermoactive ice layer ////
+     //     < 0.1 
+     
+     //     make more sense to just use residual pdd-ndd except that pdd
+     //     residual not clear yet
+     //     frzndd should not be used up by refreezing in snow, so stick in
+     //     supcap.
+     diffndd=0;
+     if (frzndd[i]>0) {
+       diffndd=fsupndd*min((supice-supcap)/dCovrLm ,frzndd[i]);
+       frzndd[i]=frzndd[i]-diffndd;
+     }
+     if(runoff<0){
+       saccu[i]= saccu[i] -runoff;
+       smelt[i] = 0;
+       precrunoff[i]=prect-saccu[i];
+       //here assume pdd residual is 0, => 
+       Tsurf[i]= max(Tsurf[i],-frzndd[i]);
+     }
+     else {
+       smelt[i] = runoff;
+       precrunoff[i]=prect-max(0.,supice)-saccu[i];}
+     //here really need pdd balance, try 0.5 fudge factor?
+     //at least runoff>0 => it's fairly warm, so Tsurf is !<<0,
+     //yet from site plots, can be ice free with Tsurf=-5.5C
+     if(Tsurf[i]<0) {
+       Tsurf[i]= min(Tsurf[i]+fsupT*diffndd , 0.);}
+     
+     agd[i] = -smelt[i]+saccu[i];
+     pddtj[i]=pddt;
+     
+     /*Update inputs*/    
+     this->inputs->AddInput(new PentaP1Input(SurfaceforcingsMassBalanceEnum,&agd[0])); ////////verifier le nom
+     // this->inputs->AddInput(new TriaVertexInput(ThermalSpcTemperatureEnum,&Tsurf[0]));
+     this->inputs->AddInput(new PentaP1Input(ThermalSpctemperatureEnum,&Tsurf[0]));
+     
+   }       //end of the for loop over the vertices
 }
 /*}}}*/
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Elements/Penta.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Elements/Penta.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Elements/Penta.h	(revision 12168)
@@ -55,9 +55,4 @@
 		int		  ObjectEnum();
 		int		  Id(); 
-		#ifdef _SERIAL_
-		void	  Marshall(char** pmarshalled_dataset);
-		int		  MarshallSize();
-		void	  Demarshall(char** pmarshalled_dataset);
-		#endif
 		int		  MyRank();
 		/*}}}*/
@@ -112,5 +107,5 @@
 		void   PatchFill(int* pcount, Patch* patch);
 		void   PatchSize(int* pnumrows, int* pnumvertices,int* pnumnodes);
-		void   PositiveDegreeDay(void);
+		void   PositiveDegreeDay(double* pdds,double* pds,double signorm);
 		void   ProcessResultsUnits(void);
 		void   ResetCoordinateSystem(void);
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Elements/Tria.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Elements/Tria.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Elements/Tria.cpp	(revision 12168)
@@ -122,158 +122,4 @@
 }
 /*}}}*/
-
-/*Marshall*/
-#ifdef _SERIAL_
-/*FUNCTION Tria::Marshall {{{1*/
-void  Tria::Marshall(char** pmarshalled_dataset){
-
-	int   i;
-	char* marshalled_dataset=NULL;
-	int   enum_type=0;
-	char* marshalled_inputs=NULL;
-	int   marshalled_inputs_size;
-	char* marshalled_results=NULL;
-	int   marshalled_results_size;
-	int   flaghook; //to indicate if hook is NULL or exists
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*get enum type of Tria: */
-	enum_type=TriaEnum;
-
-	/*marshall enum: */
-	memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-
-	/*marshall Tria data: */
-	memcpy(marshalled_dataset,&id,sizeof(id));marshalled_dataset+=sizeof(id);
-	memcpy(marshalled_dataset,&sid,sizeof(sid));marshalled_dataset+=sizeof(sid);
-	memcpy(marshalled_dataset,&numanalyses,sizeof(numanalyses));marshalled_dataset+=sizeof(numanalyses);
-
-	/*Mershall Ref: */
-	for(i=0;i<numanalyses;i++){
-		memcpy(marshalled_dataset,&element_type_list[i],sizeof(element_type_list[i]));marshalled_dataset+=sizeof(element_type_list[i]);
-	}
-
-	/*Marshall hooks: */
-	for(i=0;i<numanalyses;i++){
-		if(hnodes[i]){
-			/*Set flag to 1 as there is a hook */
-			flaghook=1;
-			memcpy(marshalled_dataset,&flaghook,sizeof(flaghook));marshalled_dataset+=sizeof(flaghook);
-			hnodes[i]->Marshall(&marshalled_dataset);
-		}
-		else{
-			/*Set flag to 0 and do not marshall flag as there is no Hook */
-			flaghook=0;
-			memcpy(marshalled_dataset,&flaghook,sizeof(flaghook));marshalled_dataset+=sizeof(flaghook);
-		}
-	}
-	hmatice->Marshall(&marshalled_dataset);
-	hmatpar->Marshall(&marshalled_dataset);
-
-	/*Marshall inputs: */
-	marshalled_inputs_size=inputs->MarshallSize();
-	marshalled_inputs=inputs->Marshall();
-	memcpy(marshalled_dataset,marshalled_inputs,marshalled_inputs_size*sizeof(char));
-	marshalled_dataset+=marshalled_inputs_size;
-
-	/*Marshall results: */
-	marshalled_results_size=results->MarshallSize();
-	marshalled_results=results->Marshall();
-	memcpy(marshalled_dataset,marshalled_results,marshalled_results_size*sizeof(char));
-	marshalled_dataset+=marshalled_results_size;
-
-	/*parameters: don't do anything about it. parameters are marshalled somewhere else!*/
-
-	xfree((void**)&marshalled_inputs);
-	xfree((void**)&marshalled_results);
-
-	/*marshall horizontal neighbors: */
-	memcpy(marshalled_dataset,horizontalneighborsids,3*sizeof(int));marshalled_dataset+=3*sizeof(int);
-
-	*pmarshalled_dataset=marshalled_dataset;
-	return;
-}
-/*}}}*/
-/*FUNCTION Tria::MarshallSize {{{1*/
-int   Tria::MarshallSize(){
-
-	int i;
-	int hnodes_size=0;;
-
-	for(i=0;i<numanalyses;i++){
-		hnodes_size+=sizeof(int); //Flag 0 or 1
-		if (hnodes[i]) hnodes_size+=hnodes[i]->MarshallSize();
-	}
-
-	return sizeof(id)
-	  +sizeof(sid)
-	  +hnodes_size
-	  +sizeof(numanalyses)
-	  +numanalyses*sizeof(int) //element_type_lists
-	  +hmatice->MarshallSize()
-	  +hmatpar->MarshallSize()
-	  +inputs->MarshallSize()
-	  +results->MarshallSize()
-	  +3*sizeof(int)
-	  +sizeof(int); //sizeof(int) for enum type
-}
-/*}}}*/
-/*FUNCTION Tria::Demarshall {{{1*/
-void  Tria::Demarshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int i;
-	int flaghook;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*this time, no need to get enum type, the pointer directly points to the beginning of the 
-	 *object data (thanks to DataSet::Demarshall):*/
-	memcpy(&id,marshalled_dataset,sizeof(id));marshalled_dataset+=sizeof(id);
-	memcpy(&sid,marshalled_dataset,sizeof(sid));marshalled_dataset+=sizeof(sid);
-	memcpy(&numanalyses,marshalled_dataset,sizeof(numanalyses));marshalled_dataset+=sizeof(numanalyses);
-
-	/*demarshall Ref: */
-	this->element_type_list=(int*)xmalloc(this->numanalyses*sizeof(int));
-	for(i=0;i<numanalyses;i++){ memcpy(&element_type_list[i],marshalled_dataset,sizeof(int));marshalled_dataset+=sizeof(int);}
-
-	/*allocate dynamic memory: */
-	this->hnodes=new Hook*[this->numanalyses];
-	/*demarshall hooks: */
-	for(i=0;i<numanalyses;i++){
-		memcpy(&flaghook,marshalled_dataset,sizeof(flaghook));marshalled_dataset+=sizeof(flaghook);
-		if(flaghook){ // there is a hook so demarshall it
-			hnodes[i]=new Hook();
-			hnodes[i]->Demarshall(&marshalled_dataset);
-		}
-		else hnodes[i]=NULL; //There is no hook so it is NULL
-	}
-	hmatice=new Hook(); hmatice->Demarshall(&marshalled_dataset);
-	hmatpar=new Hook(); hmatpar->Demarshall(&marshalled_dataset);
-
-	/*pointers are garbabe, until configuration is carried out: */
-	nodes=NULL;
-	matice=NULL;
-	matpar=NULL;
-	
-	/*demarshall inputs: */
-	inputs=(Inputs*)DataSetDemarshallRaw(&marshalled_dataset); 
-	results=(Results*)DataSetDemarshallRaw(&marshalled_dataset); 
-
-	/*parameters: may not exist even yet, so let Configure handle it: */
-	this->parameters=NULL;
-
-	/*neighbors: */
-	memcpy(&this->horizontalneighborsids,marshalled_dataset,3*sizeof(int));marshalled_dataset+=3*sizeof(int);
-
-	/*return: */
-	*pmarshalled_dataset=marshalled_dataset;
-	return;
-}
-/*}}}*/
-#endif
 
 /*Other*/
@@ -2241,7 +2087,224 @@
 /*}}}*/
 /*FUNCTION Tria::PositiveDegreeDay{{{1*/
-void  Tria::PositiveDegreeDay(){
-
-	_error_("Not implemented yet");
+void  Tria::PositiveDegreeDay(double* pdds,double* pds,double signorm){
+
+   int    i,iqj,imonth;
+   double agd[NUMVERTICES];  // surface and basal
+   double saccu[NUMVERTICES] = {0};     // yearly surface accumulation
+   double smelt[NUMVERTICES] = {0};     // yearly melt
+   double precrunoff[NUMVERTICES];      // yearly runoff
+   double prect; // total precipitation during 1 year taking into account des. ef.
+   double water; //water=rain + snowmelt 
+   double runoff; //meltwater only, does not include rain 
+   double sconv; //rhow_rain/rhoi / 12 months
+
+   double  rho_water,rho_ice,density;
+   double lapser=6.5/1000, sealev=0;    // lapse rate. degrees per meter.
+   double desfac = 0.5;                 //desert elevation factor
+   double s0p[NUMVERTICES]={0};         //should be set to elevation from precip source
+   double s0t[NUMVERTICES]={0};         //should be set to elevation from temperature source
+   double st;             // elevation between altitude of the temp record and current altitude
+   double sp;             // elevation between altitude of the prec record and current altitude
+
+
+   // PDD and PD constants and variables
+   double siglim;          // sigma limit for the integration which is equal to 2.5 sigmanorm
+   double siglimc=0, siglim0, siglim0c;
+   double PDup, pddsig, PDCUT = 2.0; // PDcut: rain/snow cutoff temperature (C)
+   double DT = 0.02;
+   double pddt, pd; // pd: snow/precip fraction, precipitation falling as snow
+   
+   double q, qmpt; // q is desert/elev. fact, hnpfac is huybrect fact, and pd is normal dist.
+   double qm[NUMVERTICES] = {0};        // snow part of the precipitation 
+   double qmt[NUMVERTICES] = {0};       // precipitation without desertification effect adjustment
+   double qmp[NUMVERTICES] = {0};       // desertification taken into account
+   double pdd[NUMVERTICES] = {0};     
+   double frzndd[NUMVERTICES] = {0};  
+
+   double tstar;                        // monthly mean surface temp
+   double Tsum[NUMVERTICES]= {0};       // average summer (JJA) temperature
+   double Tsurf[NUMVERTICES] = {0};     // average annual temperature    
+   
+   double h[NUMVERTICES],s[NUMVERTICES],ttmp[NUMVERTICES],prectmp[NUMVERTICES]; // ,b[NUMVERTICES]
+   double t[NUMVERTICES][12],prec[NUMVERTICES][12];
+   double deltm=1/12;
+   int    ismon[12]={12,1,2,3,4,5,6,7,8,9,10,11};
+
+   double snwm;  // snow that could have been melted in a year.
+   double snwmf; //  ablation factor for snow per positive degree day.
+   double smf;   //  ablation factor for ice per pdd (Braithwaite 1995 from tarasov 2002).
+
+   double dfrz=1.5, CovrLm=2009./3.35e+5, dCovrLm=dfrz*CovrLm; //m*J kg^-1 C^-1 /(J kg^-1)=m/C yr
+   double supice,supcap,diffndd;
+   double fsupT=0.5,  fsupndd=0.5;  // Tsurf mode factors for supice
+   double pddtj[NUMVERTICES], hmx2;
+
+   /*Recover info at the vertices: */
+   GetInputListOnVertices(&h[0],ThicknessEnum);
+   GetInputListOnVertices(&s[0],SurfaceEnum);
+   GetInputListOnVertices(&ttmp[0],ThermalSpctemperatureEnum);
+   GetInputListOnVertices(&prectmp[0],SurfaceforcingsPrecipitationEnum);
+
+   for(i=0;i<NUMVERTICES;i++) ttmp[i]=ttmp[i]-273.15; // convertion from Kelvin to celcius
+
+   for(i=0;i<NUMVERTICES;i++)
+     for(imonth=0;imonth<12;imonth++){
+       t[i][imonth]=ttmp[i];
+       prec[i][imonth]=prectmp[i];
+   }
+
+   /*Get material parameters :*/
+   rho_ice=matpar->GetRhoIce();
+   rho_water=matpar->GetRhoWater();
+   density=rho_ice/rho_water;
+   
+   sconv=(rho_water/rho_ice)/12.; //rhow_rain/rhoi / 12 months
+     
+     /*PDD constant*/
+   siglim = 2.5*signorm; 
+   siglim0 =  siglim/DT + 0.5;
+   siglim0c =  siglimc/DT + 0.5;
+   PDup = siglimc+PDCUT;
+   
+   // seasonal loop
+   for (iqj = 0; iqj < 12; iqj++){
+     imonth =  ismon[iqj];
+     for (i = 0; i < NUMVERTICES; i++){
+       st=(s[i]-s0t[i])/1000;
+       tstar = t[i][imonth] - lapser *max(st,sealev);
+       Tsurf[i] = tstar*deltm+Tsurf[i];        
+       
+       /*********compute PD ****************/
+       if (tstar < PDup){
+	 pd = 1;
+	 if (tstar >= -siglimc){ pd = pds[int(tstar/DT + siglim0c)];}}
+       else { 
+	 pd = 0;}
+       
+       /******exp des/elev precip reduction*******/
+       sp=(s[i]-s0p[i])/1000; // deselev effect is wrt chng in topo
+       if (sp>0.0){q = exp(-desfac*sp);}
+       else {q = 1.0;}
+       
+       qmt[i]= qmt[i] + prec[i][imonth]*sconv;  //*sconv to convert in m of ice equivalent 
+       qmpt= q*prec[i][imonth]*sconv;           
+       qmp[i]= qmp[i] + qmpt;
+       qm[i]= qm[i] + qmpt*pd;
+       
+       /*********compute PDD************/
+       // ndd(month)=-(tstar-pdd(month)) since ndd+pdd gives expectation of
+       // gaussian=T_m, so ndd=-(Tsurf-pdd)
+       if (iqj>6 &&  iqj<10){ Tsum[i]=Tsum[i]+tstar;} 
+       if (tstar >= siglim) {pdd[i] = pdd[i] + tstar*deltm;}
+       else if (tstar> -siglim){
+	 pddsig=pdds[int(tstar/DT + siglim0)];
+	 pdd[i] = pdd[i] + pddsig*deltm;
+	 frzndd[i] = frzndd[i] - (tstar-pddsig)*deltm;}
+       else{frzndd[i] = frzndd[i] - tstar*deltm; }
+     }
+   } // end of seasonal loop 
+   
+   //******************************************************************
+   for(i=0;i<NUMVERTICES;i++){
+     saccu[i] = qm[i];
+     prect = qmp[i];     // total precipitation during 1 year taking into account des. ef.
+     Tsum[i]=Tsum[i]/3;
+     
+     /***** determine PDD factors *****/
+     if(Tsum[i]< -1.) {
+       snwmf=2.65*0.001;   //  ablation factor for snow per positive degree day.*0.001 to go from mm to m/ppd
+       smf=17.22*0.001;    //  ablation factor for ice per pdd (Braithwaite 1995 from tarasov 2002)
+     }
+     else if(Tsum[i]< 10){
+       snwmf = (0.15*Tsum[i] + 2.8)*0.001;
+       smf = (0.0067*pow((10.-Tsum[i]),3) + 8.3)*0.001;
+     }
+     else{
+       snwmf=4.3*0.001;
+       smf=8.3*0.001;
+     }
+     snwmf=0.95*snwmf;
+     smf=0.95*smf;
+     
+     /*****  compute PDD ablation and refreezing *****/
+     pddt = pdd[i] *365;
+     snwm = snwmf*pddt;       // snow that could have been melted in a year
+     hmx2 = min(h[i],dfrz);   // refreeze active layer max depth: dfrz
+     
+     if(snwm < saccu[i]) {
+       water=prect-saccu[i] + snwm; //water=rain + snowmelt
+       //     l 2.2= capillary factor
+       //     Should refreezing be controlled by frzndd or by mean annual Tsurf?
+       //     dCovrLm concept is of warming of active layer (thickness =d@=1-
+       //     >2m)
+       //     problem with water seepage into ice: should be sealed after
+       //     refreezing
+       //     so everything needs to be predicated on 1 year scale, except for
+       //     thermal
+       //     conductivity through ice
+       //     also, need to account that melt season has low accum, so what's
+       //     going to
+       //     hold the meltwater around for refreezing? And melt-time will have
+       //     low seasonal frzndd
+       
+       //      Superimposed ice :  Pfeffer et al. 1991, Tarasov 2002
+       
+       supice= min(hmx2*CovrLm*frzndd[i]+2.2*(saccu[i]-snwm), water); // superimposed ice
+       supcap=min(2.2*(saccu[i]-snwm),water);
+       runoff=snwm - supice;  //meltwater only, does not include rain
+     }
+     else {  //all snow melted
+       supice= min(hmx2*CovrLm*frzndd[i], prect );
+       runoff= saccu[i] + smf*(pddt-saccu[i]/snwmf) - supice;
+       supcap=0;
+     }
+     //     pdd melting doesn't cool Tsurf, so ndd refreeze shouldn't warm it
+     //     except pdd melt heat source is atmosphere, while refreeze is
+     //     ground/ice stored interim
+     //     assume pdd=ndd, then melt should equal refreeze and Tsurf should=0
+     //     assume ndd=2*pdd, then all supice is refrozen, but Tsurf should be
+     //     <0
+     //     assume ndd>pdd, little melt => little supice 
+     //     bottom line: compare for Tsurf<0 : supice and no supice case,
+     //     expect Tsurf difference
+     //     except some of cooling flux comes from atmosphere//
+     //     1 dm supice should not raise Tsurf by 1/dCovrLm = 16.675C
+     //     does supice make sense when H< 0.1m? then d=thermoactive ice layer ////
+     //     < 0.1 
+     
+     //     make more sense to just use residual pdd-ndd except that pdd
+     //     residual not clear yet
+     //     frzndd should not be used up by refreezing in snow, so stick in
+     //     supcap.
+     diffndd=0;
+     if (frzndd[i]>0) {
+       diffndd=fsupndd*min((supice-supcap)/dCovrLm ,frzndd[i]);
+       frzndd[i]=frzndd[i]-diffndd;
+     }
+     if(runoff<0){
+       saccu[i]= saccu[i] -runoff;
+       smelt[i] = 0;
+       precrunoff[i]=prect-saccu[i];
+       //here assume pdd residual is 0, => 
+       Tsurf[i]= max(Tsurf[i],-frzndd[i]);
+     }
+     else {
+       smelt[i] = runoff;
+       precrunoff[i]=prect-max(0.,supice)-saccu[i];}
+     //here really need pdd balance, try 0.5 fudge factor?
+     //at least runoff>0 => it's fairly warm, so Tsurf is !<<0,
+     //yet from site plots, can be ice free with Tsurf=-5.5C
+     if(Tsurf[i]<0) {
+       Tsurf[i]= min(Tsurf[i]+fsupT*diffndd , 0.);}
+     
+     agd[i] = -smelt[i]+saccu[i];
+     pddtj[i]=pddt;
+     
+     /*Update inputs*/    
+     this->inputs->AddInput(new TriaP1Input(SurfaceforcingsMassBalanceEnum,&agd[0])); ////////verifier le nom
+     // this->inputs->AddInput(new TriaVertexInput(ThermalSpcTemperatureEnum,&Tsurf[0]));
+     this->inputs->AddInput(new TriaP1Input(ThermalSpctemperatureEnum,&Tsurf[0]));
+     
+   }       //end of the for loop over the vertices
 }
 /*}}}*/
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Elements/Tria.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Elements/Tria.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Elements/Tria.h	(revision 12168)
@@ -51,9 +51,4 @@
 		int   Id(); 
 		int   MyRank();
-		#ifdef _SERIAL_
-		void  Marshall(char** pmarshalled_dataset);
-		int   MarshallSize();
-		void  Demarshall(char** pmarshalled_dataset);
-		#endif
 		int   ObjectEnum();
 		Object* copy();
@@ -108,5 +103,5 @@
 		int    NodalValue(double* pvalue, int index, int natureofdataenum,bool process_units);
 		void   PotentialSheetUngrounding(Vector* potential_sheet_ungrounding);
-		void   PositiveDegreeDay(void);
+		void   PositiveDegreeDay(double* pdds,double* pds,double signorm);
 		void   RequestedOutput(int output_enum,int step,double time);
 		void   ListResultsInfo(int** results_enums,int** results_size,double** results_times,int** results_steps,int* num_results);
Index: /issm/branches/trunk-jpl-damage/src/c/objects/ExternalResults/BoolExternalResult.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/ExternalResults/BoolExternalResult.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/ExternalResults/BoolExternalResult.cpp	(revision 12168)
@@ -68,64 +68,4 @@
 }
 /*}}}*/
-#ifdef _SERIAL_
-/*FUNCTION BoolExternalResult::Marshall{{{1*/
-void  BoolExternalResult::Marshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   enum_value=0;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*get enum value of BoolExternalResult: */
-	enum_value=BoolExternalResultEnum;
-	
-	/*marshall enum: */
-	memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);
-	
-	/*marshall BoolExternalResult data: */
-	memcpy(marshalled_dataset,&id,sizeof(id));marshalled_dataset+=sizeof(id);
-	memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-	memcpy(marshalled_dataset,&value,sizeof(value));marshalled_dataset+=sizeof(value);
-	memcpy(marshalled_dataset,&step,sizeof(step));marshalled_dataset+=sizeof(step);
-	memcpy(marshalled_dataset,&time,sizeof(time));marshalled_dataset+=sizeof(time);
-
-	*pmarshalled_dataset=marshalled_dataset;
-}
-/*}}}*/
-/*FUNCTION BoolExternalResult::MarshallSize{{{1*/
-int   BoolExternalResult::MarshallSize(){
-	
-	return sizeof(value)+
-		+sizeof(id)
-		+sizeof(enum_type)
-		+sizeof(step)
-		+sizeof(time)
-		+sizeof(int); //sizeof(int) for enum value
-}
-/*}}}*/
-/*FUNCTION BoolExternalResult::Demarshall{{{1*/
-void  BoolExternalResult::Demarshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   i;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*this time, no need to get enum type, the pointer directly points to the beginning of the 
-	 *object data (thanks to DataSet::Demarshall):*/
-	memcpy(&id,marshalled_dataset,sizeof(id));marshalled_dataset+=sizeof(id);
-	memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-	memcpy(&value,marshalled_dataset,sizeof(value));marshalled_dataset+=sizeof(value);
-	memcpy(&step,marshalled_dataset,sizeof(step));marshalled_dataset+=sizeof(step);
-	memcpy(&time,marshalled_dataset,sizeof(time));marshalled_dataset+=sizeof(time);
-
-	/*return: */
-	*pmarshalled_dataset=marshalled_dataset;
-	return;
-}
-/*}}}*/
-#endif
 /*FUNCTION BoolExternalResult::ObjectEnum{{{1*/
 int BoolExternalResult::ObjectEnum(void){
@@ -185,17 +125,4 @@
 }
 /*}}}*/
-/*FUNCTION BoolExternalResult::SetMatlabField{{{1*/
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-void BoolExternalResult::SetMatlabField(mxArray* dataref){
-
-	char* name=NULL;
-	this->GetResultName(&name);
-	
-	mxSetField( dataref, this->step-1, name,mxCreateDoubleScalar((double)value));
-	mxSetField( dataref, this->step-1, "time",mxCreateDoubleScalar((double)this->time)); 
-	mxSetField( dataref, this->step-1, "step",mxCreateDoubleScalar((double)this->step)); 
-}
-#endif
-/*}}}*/
 /*FUNCTION BoolExternalResult::GetStep{{{1*/
 int BoolExternalResult::GetStep(void){
Index: /issm/branches/trunk-jpl-damage/src/c/objects/ExternalResults/BoolExternalResult.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/ExternalResults/BoolExternalResult.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/ExternalResults/BoolExternalResult.h	(revision 12168)
@@ -15,9 +15,4 @@
 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
 #endif
-
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-#include <mex.h>
-#endif
-
 
 #include "./ExternalResult.h"
@@ -47,9 +42,4 @@
 		int   Id(); 
 		int   MyRank();
-		#ifdef _SERIAL_
-		void  Marshall(char** pmarshalled_dataset);
-		int   MarshallSize();
-		void  Demarshall(char** pmarshalled_dataset);
-		#endif
 		int   ObjectEnum();
 		Object* copy();
@@ -59,9 +49,6 @@
 		void  WriteData(FILE* fid,bool io_gather);
 		void  GetResultName(char**);
-	    #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-		void  SetMatlabField(mxArray* dataref);
-		#endif
 		int   GetStep(void);
 		/*}}}*/
 };
-#endif  /* _BOOLEXTERNALRESULT_H */
+#endif
Index: /issm/branches/trunk-jpl-damage/src/c/objects/ExternalResults/DoubleExternalResult.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/ExternalResults/DoubleExternalResult.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/ExternalResults/DoubleExternalResult.cpp	(revision 12168)
@@ -68,64 +68,4 @@
 }
 /*}}}*/
-#ifdef _SERIAL_
-/*FUNCTION DoubleExternalResult::Marshall{{{1*/
-void  DoubleExternalResult::Marshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   enum_value=0;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*get enum value of DoubleExternalResult: */
-	enum_value=DoubleExternalResultEnum;
-	
-	/*marshall enum: */
-	memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);
-	
-	/*marshall DoubleExternalResult data: */
-	memcpy(marshalled_dataset,&id,sizeof(id));marshalled_dataset+=sizeof(id);
-	memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-	memcpy(marshalled_dataset,&value,sizeof(value));marshalled_dataset+=sizeof(value);
-	memcpy(marshalled_dataset,&step,sizeof(step));marshalled_dataset+=sizeof(step);
-	memcpy(marshalled_dataset,&time,sizeof(time));marshalled_dataset+=sizeof(time);
-
-	*pmarshalled_dataset=marshalled_dataset;
-}
-/*}}}*/
-/*FUNCTION DoubleExternalResult::MarshallSize{{{1*/
-int   DoubleExternalResult::MarshallSize(){
-	
-	return sizeof(value)+
-		+sizeof(id)
-		+sizeof(enum_type)
-		+sizeof(step)
-		+sizeof(time)
-		+sizeof(int); //sizeof(int) for enum value
-}
-/*}}}*/
-/*FUNCTION DoubleExternalResult::Demarshall{{{1*/
-void  DoubleExternalResult::Demarshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   i;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*this time, no need to get enum type, the pointer directly points to the beginning of the 
-	 *object data (thanks to DataSet::Demarshall):*/
-	memcpy(&id,marshalled_dataset,sizeof(id));marshalled_dataset+=sizeof(id);
-	memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-	memcpy(&value,marshalled_dataset,sizeof(value));marshalled_dataset+=sizeof(value);
-	memcpy(&step,marshalled_dataset,sizeof(step));marshalled_dataset+=sizeof(step);
-	memcpy(&time,marshalled_dataset,sizeof(time));marshalled_dataset+=sizeof(time);
-
-	/*return: */
-	*pmarshalled_dataset=marshalled_dataset;
-	return;
-}
-/*}}}*/
-#endif
 /*FUNCTION DoubleExternalResult::ObjectEnum{{{1*/
 int DoubleExternalResult::ObjectEnum(void){
@@ -181,17 +121,4 @@
 }
 /*}}}*/
-/*FUNCTION DoubleExternalResult::SetMatlabField{{{1*/
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-void DoubleExternalResult::SetMatlabField(mxArray* dataref){
-
-	char* name=NULL;
-	this->GetResultName(&name);
-	mxSetField( dataref,this->step-1, name,mxCreateDoubleScalar(value));
-	mxSetField( dataref, this->step-1, "time",mxCreateDoubleScalar((double)this->time)); 
-	mxSetField( dataref, this->step-1, "step",mxCreateDoubleScalar((double)this->step)); 
-
-}
-#endif
-/*}}}*/
 /*FUNCTION DoubleExternalResult::GetStep{{{1*/
 int DoubleExternalResult::GetStep(void){
Index: /issm/branches/trunk-jpl-damage/src/c/objects/ExternalResults/DoubleExternalResult.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/ExternalResults/DoubleExternalResult.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/ExternalResults/DoubleExternalResult.h	(revision 12168)
@@ -14,8 +14,4 @@
 #else
 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
-#endif
-
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-#include <mex.h>
 #endif
 
@@ -48,9 +44,4 @@
 		int   Id(); 
 		int   MyRank();
-		#ifdef _SERIAL_
-		void  Marshall(char** pmarshalled_dataset);
-		int   MarshallSize();
-		void  Demarshall(char** pmarshalled_dataset);
-		#endif
 		int   ObjectEnum();
 		Object* copy();
@@ -60,7 +51,4 @@
 		void  WriteData(FILE* fid,bool io_gather);
 		void  GetResultName(char**);
-		#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-		void  SetMatlabField(mxArray* dataref);
-		#endif
 		int   GetStep(void);
 		/*}}}*/
Index: /issm/branches/trunk-jpl-damage/src/c/objects/ExternalResults/DoubleMatExternalResult.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/ExternalResults/DoubleMatExternalResult.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/ExternalResults/DoubleMatExternalResult.cpp	(revision 12168)
@@ -96,73 +96,4 @@
 }
 /*}}}*/
-#ifdef _SERIAL_
-/*FUNCTION DoubleMatExternalResult::Marshall{{{1*/
-void  DoubleMatExternalResult::Marshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   enum_value=0;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*get enum value of DoubleMatExternalResult: */
-	enum_value=DoubleMatExternalResultEnum;
-	
-	/*marshall enum: */
-	memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);
-	
-	/*marshall DoubleMatExternalResult data: */
-	memcpy(marshalled_dataset,&id,sizeof(id));marshalled_dataset+=sizeof(id);
-	memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-	memcpy(marshalled_dataset,&M,sizeof(M));marshalled_dataset+=sizeof(M);
-	memcpy(marshalled_dataset,&N,sizeof(N));marshalled_dataset+=sizeof(N);
-	memcpy(marshalled_dataset,values,M*sizeof(double));marshalled_dataset+=M*sizeof(double);
-	memcpy(marshalled_dataset,&step,sizeof(step));marshalled_dataset+=sizeof(step);
-	memcpy(marshalled_dataset,&time,sizeof(time));marshalled_dataset+=sizeof(time);
-
-	*pmarshalled_dataset=marshalled_dataset;
-}
-/*}}}*/
-/*FUNCTION DoubleMatExternalResult::MarshallSize{{{1*/
-int   DoubleMatExternalResult::MarshallSize(){
-	
-	return sizeof(M)
-		+sizeof(N)
-		+M*N*sizeof(double)
-		+sizeof(id)
-		+sizeof(enum_type)
-		+sizeof(step)
-		+sizeof(time)
-		+sizeof(int); //sizeof(int) for enum value
-}
-/*}}}*/
-/*FUNCTION DoubleMatExternalResult::Demarshall{{{1*/
-void  DoubleMatExternalResult::Demarshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   i;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*this time, no need to get enum type, the pointer directly points to the beginning of the 
-	 *object data (thanks to DataSet::Demarshall):*/
-	memcpy(&id,marshalled_dataset,sizeof(id));marshalled_dataset+=sizeof(id);
-	memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-	
-	/*data: */
-	memcpy(&M,marshalled_dataset,sizeof(M));marshalled_dataset+=sizeof(M);
-	memcpy(&N,marshalled_dataset,sizeof(N));marshalled_dataset+=sizeof(N);
-	values=(double*)xmalloc(M*N*sizeof(double));
-	memcpy(values,marshalled_dataset,M*N*sizeof(double));marshalled_dataset+=M*N*sizeof(double);
-	memcpy(&step,marshalled_dataset,sizeof(step));marshalled_dataset+=sizeof(step);
-	memcpy(&time,marshalled_dataset,sizeof(time));marshalled_dataset+=sizeof(time);
-
-	/*return: */
-	*pmarshalled_dataset=marshalled_dataset;
-	return;
-}
-/*}}}*/
-#endif
 /*FUNCTION DoubleMatExternalResult::ObjectEnum{{{1*/
 int DoubleMatExternalResult::ObjectEnum(void){
@@ -222,37 +153,4 @@
 }
 /*}}}*/
-/*FUNCTION DoubleMatExternalResult::SetMatlabField{{{1*/
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-void DoubleMatExternalResult::SetMatlabField(mxArray* dataref){
-
-	mxArray* pfield=NULL;
-	mxArray* pfield2=NULL;
-	char* name=NULL;
-	double* doublemat=NULL;
-
-	/*Make a copy of the value, to be used by matlab: */
-	doublemat=(double*)xmalloc(M*N*sizeof(double));
-	memcpy(doublemat,values,M*N*sizeof(double));
-
-	/*recover name: */
-	this->GetResultName(&name);
-				
-	/*create matlab matrix: */
-	pfield=mxCreateDoubleMatrix(0,0,mxREAL);
-	mxSetM(pfield,N);
-	mxSetN(pfield,M);
-	mxSetPr(pfield,doublemat);
-	
-	/*transpose the matrix, from c to matlab format */
-	mexCallMATLAB(1,&pfield2, 1, &pfield, "transpose");
-
-	/*set tranpose matrix inside the dataref structure: */
-	mxSetField( dataref, this->step-1, name,pfield2);
-	mxSetField( dataref, this->step-1, "time",mxCreateDoubleScalar((double)this->time));
-	mxSetField( dataref, this->step-1, "step",mxCreateDoubleScalar((double)this->step));
-
-}
-#endif
-/*}}}*/
 /*FUNCTION DoubleMatExternalResult::GetStep{{{1*/
 int DoubleMatExternalResult::GetStep(void){
Index: /issm/branches/trunk-jpl-damage/src/c/objects/ExternalResults/DoubleMatExternalResult.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/ExternalResults/DoubleMatExternalResult.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/ExternalResults/DoubleMatExternalResult.h	(revision 12168)
@@ -14,9 +14,4 @@
 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
 #endif
-
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-#include <mex.h>
-#endif
-
 
 #include "./ExternalResult.h"
@@ -49,9 +44,4 @@
 		int   Id(); 
 		int   MyRank();
-		#ifdef _SERIAL_
-		void  Marshall(char** pmarshalled_dataset);
-		int   MarshallSize();
-		void  Demarshall(char** pmarshalled_dataset);
-		#endif
 		int   ObjectEnum();
 		Object* copy();
@@ -61,7 +51,4 @@
 		void  WriteData(FILE* fid,bool io_gather);
 		void  GetResultName(char**);
-		#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-		void  SetMatlabField(mxArray* dataref);
-		#endif
 		int   GetStep(void);
 		/*}}}*/
Index: /issm/branches/trunk-jpl-damage/src/c/objects/ExternalResults/DoubleVecExternalResult.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/ExternalResults/DoubleVecExternalResult.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/ExternalResults/DoubleVecExternalResult.cpp	(revision 12168)
@@ -87,70 +87,4 @@
 }
 /*}}}*/
-#ifdef _SERIAL_
-/*FUNCTION DoubleVecExternalResult::Marshall{{{1*/
-void  DoubleVecExternalResult::Marshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   enum_value=0;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*get enum value of DoubleVecExternalResult: */
-	enum_value=DoubleVecExternalResultEnum;
-	
-	/*marshall enum: */
-	memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);
-	
-	/*marshall DoubleVecExternalResult data: */
-	memcpy(marshalled_dataset,&id,sizeof(id));marshalled_dataset+=sizeof(id);
-	memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-	memcpy(marshalled_dataset,&M,sizeof(M));marshalled_dataset+=sizeof(M);
-	memcpy(marshalled_dataset,values,M*sizeof(double));marshalled_dataset+=M*sizeof(double);
-	memcpy(marshalled_dataset,&step,sizeof(step));marshalled_dataset+=sizeof(step);
-	memcpy(marshalled_dataset,&time,sizeof(time));marshalled_dataset+=sizeof(time);
-
-	*pmarshalled_dataset=marshalled_dataset;
-}
-/*}}}*/
-/*FUNCTION DoubleVecExternalResult::MarshallSize{{{1*/
-int   DoubleVecExternalResult::MarshallSize(){
-	
-	return sizeof(M)
-		+M*sizeof(double)
-		+sizeof(id)
-		+sizeof(enum_type)
-		+sizeof(step)
-		+sizeof(time)
-		+sizeof(int); //sizeof(int) for enum value
-}
-/*}}}*/
-/*FUNCTION DoubleVecExternalResult::Demarshall{{{1*/
-void  DoubleVecExternalResult::Demarshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   i;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*this time, no need to get enum type, the pointer directly points to the beginning of the 
-	 *object data (thanks to DataSet::Demarshall):*/
-	memcpy(&id,marshalled_dataset,sizeof(id));marshalled_dataset+=sizeof(id);
-	memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-	
-	/*data: */
-	memcpy(&M,marshalled_dataset,sizeof(M));marshalled_dataset+=sizeof(M);
-	values=(double*)xmalloc(M*sizeof(double));
-	memcpy(values,marshalled_dataset,M*sizeof(double));marshalled_dataset+=M*sizeof(double);
-	memcpy(&step,marshalled_dataset,sizeof(step));marshalled_dataset+=sizeof(step);
-	memcpy(&time,marshalled_dataset,sizeof(time));marshalled_dataset+=sizeof(time);
-
-	/*return: */
-	*pmarshalled_dataset=marshalled_dataset;
-	return;
-}
-/*}}}*/
-#endif
 /*FUNCTION DoubleVecExternalResult::ObjectEnum{{{1*/
 int DoubleVecExternalResult::ObjectEnum(void){
@@ -206,32 +140,4 @@
 }
 /*}}}*/
-/*FUNCTION DoubleVecExternalResult::SetMatlabField{{{1*/
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-void DoubleVecExternalResult::SetMatlabField(mxArray* dataref){
-
-	mxArray *pfield    = NULL;
-	double  *doublemat = NULL;
-	char    *name      = NULL;
-	double  *doublevec = NULL;
-
-	/*Make a copy of the value, to be used by matlab: */
-	doublevec=(double*)xmalloc(M*sizeof(double));
-	memcpy(doublevec,values,M*sizeof(double));
-
-	/*recover name: */
-	this->GetResultName(&name);
-				
-	/*create matlab matrix: */
-	pfield=mxCreateDoubleMatrix(0,0,mxREAL);
-	mxSetM(pfield,M);
-	mxSetN(pfield,1);
-	mxSetPr(pfield,doublevec);
-
-	mxSetField( dataref, this->step-1, name,pfield);
-	mxSetField( dataref, this->step-1, "time",mxCreateDoubleScalar((double)this->time)); 
-	mxSetField( dataref, this->step-1, "step",mxCreateDoubleScalar((double)this->step)); 
-}
-#endif
-/*}}}*/
 /*FUNCTION DoubleVecExternalResult::GetStep{{{1*/
 int DoubleVecExternalResult::GetStep(void){
Index: /issm/branches/trunk-jpl-damage/src/c/objects/ExternalResults/DoubleVecExternalResult.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/ExternalResults/DoubleVecExternalResult.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/ExternalResults/DoubleVecExternalResult.h	(revision 12168)
@@ -14,9 +14,4 @@
 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
 #endif
-
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-#include <mex.h>
-#endif
-
 
 #include "./ExternalResult.h"
@@ -48,9 +43,4 @@
 		int   Id(); 
 		int   MyRank();
-		#ifdef _SERIAL_
-		void  Marshall(char** pmarshalled_dataset);
-		int   MarshallSize();
-		void  Demarshall(char** pmarshalled_dataset);
-		#endif
 		int   ObjectEnum();
 		Object* copy();
@@ -60,7 +50,4 @@
 		void  WriteData(FILE* fid,bool io_gather);
 		void  GetResultName(char**);
-		#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-		void  SetMatlabField(mxArray* dataref);
-		#endif
 		int   GetStep(void);
 		/*}}}*/
Index: /issm/branches/trunk-jpl-damage/src/c/objects/ExternalResults/ExternalResult.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/ExternalResults/ExternalResult.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/ExternalResults/ExternalResult.h	(revision 12168)
@@ -16,8 +16,4 @@
 #endif
 
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-#include <mex.h>
-#endif
-
 #include "../Object.h"
 #include "../Node.h"
@@ -33,7 +29,4 @@
 		virtual void  WriteData(FILE* fid,bool io_gather)=0;
 		virtual void  GetResultName(char**)=0;
-		#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-		virtual void  SetMatlabField(mxArray* dataref)=0;
-		#endif
 		virtual int   GetStep(void)=0;
 		/*}}}*/
Index: /issm/branches/trunk-jpl-damage/src/c/objects/ExternalResults/IntExternalResult.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/ExternalResults/IntExternalResult.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/ExternalResults/IntExternalResult.cpp	(revision 12168)
@@ -68,64 +68,4 @@
 }
 /*}}}*/
-#ifdef _SERIAL_
-/*FUNCTION IntExternalResult::Marshall{{{1*/
-void  IntExternalResult::Marshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   enum_value=0;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*get enum value of IntExternalResult: */
-	enum_value=IntExternalResultEnum;
-	
-	/*marshall enum: */
-	memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);
-	
-	/*marshall IntExternalResult data: */
-	memcpy(marshalled_dataset,&id,sizeof(id));marshalled_dataset+=sizeof(id);
-	memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-	memcpy(marshalled_dataset,&value,sizeof(value));marshalled_dataset+=sizeof(value);
-	memcpy(marshalled_dataset,&step,sizeof(step));marshalled_dataset+=sizeof(step);
-	memcpy(marshalled_dataset,&time,sizeof(time));marshalled_dataset+=sizeof(time);
-
-	*pmarshalled_dataset=marshalled_dataset;
-}
-/*}}}*/
-/*FUNCTION IntExternalResult::MarshallSize{{{1*/
-int   IntExternalResult::MarshallSize(){
-	
-	return sizeof(value)+
-		+sizeof(id)
-		+sizeof(enum_type)
-		+sizeof(step)
-		+sizeof(time)
-		+sizeof(int); //sizeof(int) for enum value
-}
-/*}}}*/
-/*FUNCTION IntExternalResult::Demarshall{{{1*/
-void  IntExternalResult::Demarshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   i;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*this time, no need to get enum type, the pointer directly points to the beginning of the 
-	 *object data (thanks to DataSet::Demarshall):*/
-	memcpy(&id,marshalled_dataset,sizeof(id));marshalled_dataset+=sizeof(id);
-	memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-	memcpy(&value,marshalled_dataset,sizeof(value));marshalled_dataset+=sizeof(value);
-	memcpy(&step,marshalled_dataset,sizeof(step));marshalled_dataset+=sizeof(step);
-	memcpy(&time,marshalled_dataset,sizeof(time));marshalled_dataset+=sizeof(time);
-
-	/*return: */
-	*pmarshalled_dataset=marshalled_dataset;
-	return;
-}
-/*}}}*/
-#endif
 /*FUNCTION IntExternalResult::ObjectEnum{{{1*/
 int IntExternalResult::ObjectEnum(void){
@@ -185,18 +125,4 @@
 }
 /*}}}*/
-/*FUNCTION IntExternalResult::SetMatlabField{{{1*/
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-void IntExternalResult::SetMatlabField(mxArray* dataref){
-
-	char* name=NULL;
-	this->GetResultName(&name);
-
-	mxSetField( dataref, this->step-1, name,mxCreateDoubleScalar(value));
-	mxSetField( dataref, this->step-1, "time",mxCreateDoubleScalar((double)this->time)); 
-	mxSetField( dataref, this->step-1, "step",mxCreateDoubleScalar((double)this->step)); 
-
-}
-#endif
-/*}}}*/
 /*FUNCTION IntExternalResult::GetStep{{{1*/
 int IntExternalResult::GetStep(void){
Index: /issm/branches/trunk-jpl-damage/src/c/objects/ExternalResults/IntExternalResult.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/ExternalResults/IntExternalResult.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/ExternalResults/IntExternalResult.h	(revision 12168)
@@ -14,8 +14,4 @@
 #else
 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
-#endif
-
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-#include <mex.h>
 #endif
 
@@ -46,9 +42,4 @@
 		int   Id(); 
 		int   MyRank();
-		#ifdef _SERIAL_
-		void  Marshall(char** pmarshalled_dataset);
-		int   MarshallSize();
-		void  Demarshall(char** pmarshalled_dataset);
-		#endif
 		int   ObjectEnum();
 		Object* copy();
@@ -58,7 +49,4 @@
 		void  WriteData(FILE* fid,bool io_gather);
 		void  GetResultName(char**);
-		#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-		void  SetMatlabField(mxArray* dataref);
-		#endif
 		int   GetStep(void);
 		/*}}}*/
Index: /issm/branches/trunk-jpl-damage/src/c/objects/ExternalResults/PetscVecExternalResult.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/ExternalResults/PetscVecExternalResult.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/ExternalResults/PetscVecExternalResult.cpp	(revision 12168)
@@ -80,108 +80,4 @@
 }
 /*}}}*/
-#ifdef _SERIAL_
-/*FUNCTION PetscVecExternalResult::Marshall{{{1*/
-void  PetscVecExternalResult::Marshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   enum_value=0;
-	int   M;
-	double* serial_value=NULL;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*get enum value of PetscVecExternalResult: */
-	enum_value=PetscVecExternalResultEnum;
-	
-	/*marshall enum: */
-	memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);
-	
-	/*marshall PetscVecExternalResult data: */
-	memcpy(marshalled_dataset,&id,sizeof(id));marshalled_dataset+=sizeof(id);
-	memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-	memcpy(marshalled_dataset,&step,sizeof(step));marshalled_dataset+=sizeof(step);
-	memcpy(marshalled_dataset,&time,sizeof(time));marshalled_dataset+=sizeof(time);
-	
-	if(value){
-		VecGetSize(value,&M);
-		VecToMPISerial(&serial_value,value);
-		memcpy(marshalled_dataset,&M,sizeof(M));marshalled_dataset+=sizeof(M);
-		memcpy(marshalled_dataset,serial_value,M*sizeof(double));marshalled_dataset+=(M*sizeof(double));
-	}
-	else{
-		M=0;
-		memcpy(marshalled_dataset,&M,sizeof(M));marshalled_dataset+=sizeof(M);
-	}
-	/*Free ressources:*/
-	xfree((void**)&serial_value);
-
-	/*return:*/
-	*pmarshalled_dataset=marshalled_dataset;
-}
-/*}}}*/
-/*FUNCTION PetscVecExternalResult::MarshallSize{{{1*/
-int   PetscVecExternalResult::MarshallSize(){
-
-	int M=0;
-	if(value)VecGetSize(value,&M);
-
-	return sizeof(M)+M*sizeof(double)
-		+sizeof(id)
-		+sizeof(enum_type)
-		+sizeof(step)
-		+sizeof(time)
-		+sizeof(int); //sizeof(int) for enum value
-}
-/*}}}*/
-/*FUNCTION PetscVecExternalResult::Demarshall{{{1*/
-void  PetscVecExternalResult::Demarshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   i;
-	int   M;
-	double* serial_vec=NULL;
-	int*    idxm=NULL;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*this time, no need to get enum type, the pointer directly points to the beginning of the 
-	 *object data (thanks to DataSet::Demarshall):*/
-	memcpy(&id,marshalled_dataset,sizeof(id));marshalled_dataset+=sizeof(id);
-	memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-	
-	/*data: */
-	memcpy(&step,marshalled_dataset,sizeof(step));marshalled_dataset+=sizeof(step);
-	memcpy(&time,marshalled_dataset,sizeof(time));marshalled_dataset+=sizeof(time);
-	
-	memcpy(&M,marshalled_dataset,sizeof(M));marshalled_dataset+=sizeof(M);
-	if(M){
-		serial_vec=(double*)xmalloc(M*sizeof(double));
-		memcpy(serial_vec,marshalled_dataset,M*sizeof(double));marshalled_dataset+=(M*sizeof(double));
-
-		value=NewVec(M);
-		idxm=(int*)xmalloc(M*sizeof(int));
-		for(i=0;i<M;i++)idxm[i]=i;
-		VecSetValues(value,M,idxm,serial_vec,INSERT_VALUES);
-
-		VecAssemblyBegin(value);
-		VecAssemblyEnd(value);
-
-		
-	}
-	else{
-		value=NULL;
-	}
-
-	/*Free ressources:*/
-	xfree((void**)&serial_vec);
-	xfree((void**)&idxm);
-
-	/*return: */
-	*pmarshalled_dataset=marshalled_dataset;
-}
-/*}}}*/
-#endif
 /*FUNCTION PetscVecExternalResult::ObjectEnum{{{1*/
 int PetscVecExternalResult::ObjectEnum(void){
@@ -244,29 +140,4 @@
 }
 /*}}}*/
-/*FUNCTION PetscVecExternalResult::SetMatlabField{{{1*/
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-void  PetscVecExternalResult::SetMatlabField(mxArray* dataref){
-
-	mxArray* pfield=NULL;
-	char* name=NULL;
-	double* doublevec=NULL;
-	int M;
-	
-	VecToMPISerial(&doublevec,value);
-	VecGetSize(value,&M);
-	this->GetResultName(&name);
-	
-	pfield=mxCreateDoubleMatrix(0,0,mxREAL);
-	mxSetM(pfield,M);
-	mxSetN(pfield,1);
-	mxSetPr(pfield,doublevec);
-	
-	mxSetField( dataref, this->step-1, name, pfield);
-	mxSetField( dataref, this->step-1, "time",mxCreateDoubleScalar((double)this->time)); 
-	mxSetField( dataref, this->step-1, "step",mxCreateDoubleScalar((double)this->step)); 
-
-}
-#endif
-/*}}}*/
 /*FUNCTION PetscVecExternalResult::GetStep{{{1*/
 int PetscVecExternalResult::GetStep(void){
Index: /issm/branches/trunk-jpl-damage/src/c/objects/ExternalResults/PetscVecExternalResult.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/ExternalResults/PetscVecExternalResult.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/ExternalResults/PetscVecExternalResult.h	(revision 12168)
@@ -15,9 +15,4 @@
 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
 #endif
-
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-#include <mex.h>
-#endif
-
 
 #include "./ExternalResult.h"
@@ -48,9 +43,4 @@
 		int   Id(); 
 		int   MyRank();
-		#ifdef _SERIAL_
-		void  Marshall(char** pmarshalled_dataset);
-		int   MarshallSize();
-		void  Demarshall(char** pmarshalled_dataset);
-		#endif
 		int   ObjectEnum();
 		Object* copy();
@@ -60,7 +50,4 @@
 		void  WriteData(FILE* fid,bool io_gather);
 		void  GetResultName(char**);
-		#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-		void  SetMatlabField(mxArray* dataref);
-		#endif
 		int   GetStep(void);
 		/*}}}*/
Index: /issm/branches/trunk-jpl-damage/src/c/objects/ExternalResults/StringExternalResult.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/ExternalResults/StringExternalResult.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/ExternalResults/StringExternalResult.cpp	(revision 12168)
@@ -71,77 +71,4 @@
 }
 /*}}}*/
-#ifdef _SERIAL_
-/*FUNCTION StringExternalResult::Marshall{{{1*/
-void  StringExternalResult::Marshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   enum_value=0;
-	int   stringsize;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*get enum value of StringExternalResult: */
-	enum_value=StringExternalResultEnum;
-	
-	/*marshall enum: */
-	memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);
-
-	/*marshall data: */
-	memcpy(marshalled_dataset,&id,sizeof(id));marshalled_dataset+=sizeof(id);
-	memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-	stringsize=strlen(this->value)+1;
-	
-	memcpy(marshalled_dataset,&stringsize,sizeof(stringsize));marshalled_dataset+=sizeof(stringsize);
-	memcpy(marshalled_dataset,this->value,stringsize*sizeof(char));marshalled_dataset+=stringsize*sizeof(char);
-	memcpy(marshalled_dataset,&step,sizeof(step));marshalled_dataset+=sizeof(step);
-	memcpy(marshalled_dataset,&time,sizeof(time));marshalled_dataset+=sizeof(time);
-
-	*pmarshalled_dataset=marshalled_dataset;
-}
-/*}}}*/
-/*FUNCTION StringExternalResult::MarshallSize{{{1*/
-int   StringExternalResult::MarshallSize(){
-
-	int stringsize;
-	stringsize=strlen(this->value)+1;
-	
-	return sizeof(int)+
-		+stringsize*sizeof(char)
-		+sizeof(id)
-		+sizeof(enum_type)
-		+sizeof(step)
-		+sizeof(time)
-		+sizeof(int); //sizeof(int) for enum value
-}
-/*}}}*/
-/*FUNCTION StringExternalResult::Demarshall{{{1*/
-void  StringExternalResult::Demarshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   i;
-	int   stringsize;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*this time, no need to get enum type, the pointer directly points to the beginning of the 
-	 *object data (thanks to DataSet::Demarshall):*/
-	memcpy(&id,marshalled_dataset,sizeof(id));marshalled_dataset+=sizeof(id);
-	memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-
-	memcpy(&stringsize,marshalled_dataset,sizeof(int));marshalled_dataset+=sizeof(int);
-	
-	this->value=(char*)xmalloc(stringsize*sizeof(char));
-	memcpy(value,marshalled_dataset,stringsize*sizeof(char));marshalled_dataset+=stringsize*sizeof(char);
-	memcpy(&step,marshalled_dataset,sizeof(step));marshalled_dataset+=sizeof(step);
-	memcpy(&time,marshalled_dataset,sizeof(time));marshalled_dataset+=sizeof(time);
-
-	/*return: */
-	*pmarshalled_dataset=marshalled_dataset;
-	return;
-}
-/*}}}*/
-#endif
 /*FUNCTION StringExternalResult::ObjectEnum{{{1*/
 int StringExternalResult::ObjectEnum(void){
@@ -197,19 +124,4 @@
 }
 /*}}}*/
-/*FUNCTION StringExternalResult::SetMatlabField{{{1*/
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-void  StringExternalResult::SetMatlabField(mxArray* dataref){
-	
-	char* name=NULL;
-
-	this->GetResultName(&name);
-
-	mxSetField( dataref, this->step-1, name, mxCreateString(value));
-	mxSetField( dataref, this->step-1, "time",mxCreateDoubleScalar((double)this->time)); 
-	mxSetField( dataref, this->step-1, "step",mxCreateDoubleScalar((double)this->step)); 
-
-}
-#endif
-/*}}}*/
 /*FUNCTION StringExternalResult::GetStep{{{1*/
 int StringExternalResult::GetStep(void){
Index: /issm/branches/trunk-jpl-damage/src/c/objects/ExternalResults/StringExternalResult.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/ExternalResults/StringExternalResult.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/ExternalResults/StringExternalResult.h	(revision 12168)
@@ -15,9 +15,4 @@
 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
 #endif
-
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-#include <mex.h>
-#endif
-
 
 #include "./ExternalResult.h"
@@ -48,9 +43,4 @@
 		int   Id(); 
 		int   MyRank();
-		#ifdef _SERIAL_
-		void  Marshall(char** pmarshalled_dataset);
-		int   MarshallSize();
-		void  Demarshall(char** pmarshalled_dataset);
-		#endif
 		int   ObjectEnum();
 		Object* copy();
@@ -60,7 +50,4 @@
 		void  WriteData(FILE* fid,bool io_gather);
 		void  GetResultName(char**);
-		#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-		void  SetMatlabField(mxArray* dataref);
-		#endif
 		int   GetStep(void);
 		/*}}}*/
Index: /issm/branches/trunk-jpl-damage/src/c/objects/FemModel.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/FemModel.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/FemModel.cpp	(revision 12168)
@@ -22,5 +22,4 @@
 /*FUNCTION FemModel::constructor {{{1*/
 FemModel::FemModel(char* inputfilename, char* outputfilename, const int in_solution_type,const int* analyses,const int nummodels){
-#ifdef _PARALLEL_
 
 	/*intermediary*/
@@ -75,6 +74,4 @@
 	/*Add output file name to parameters: */
 	this->parameters->AddObject(new StringParam(OutputfilenameEnum,outputfilename));
-
-#endif
 
 }
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Hook.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Hook.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Hook.cpp	(revision 12168)
@@ -118,91 +118,4 @@
 }
 /*}}}*/
-#ifdef _SERIAL_
-/*FUNCTION Hook::Marshall{{{1*/
-void Hook::Marshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   enum_type=0;
-	int   i;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*get enum type of Hook: */
-	enum_type=HookEnum;
-	
-	/*marshall enum: */
-	memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-	
-	/*marshall Hook data: */
-	memcpy(marshalled_dataset,&num,sizeof(num));marshalled_dataset+=sizeof(num);
-	for(i=0;i<num;i++){
-		memcpy(marshalled_dataset,&this->ids[i],sizeof(int));marshalled_dataset+=sizeof(int);
-		memcpy(marshalled_dataset,&this->offsets[i],sizeof(int));marshalled_dataset+=sizeof(int);
-	}
-
-	*pmarshalled_dataset=marshalled_dataset;
-	return;
-}
-/*}}}*/
-/*FUNCTION Hook::MarshallSize{{{1*/
-int Hook::MarshallSize(){
-
-	return 
-		sizeof(num)+
-		num*sizeof(int)+
-		num*sizeof(int)+
-		sizeof(int); //sizeof(int) for enum type
-}
-/*}}}*/
-/*FUNCTION Hook::Demarshall{{{1*/
-void Hook::Demarshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   i;
-	int   enum_type;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*get enum type of object since Hook is not directly called by DataSet: */
-	memcpy(&enum_type,marshalled_dataset,sizeof(int)); marshalled_dataset+=sizeof(int);
-
-	memcpy(&num,marshalled_dataset,sizeof(num));marshalled_dataset+=sizeof(num);
-	
-	/*allocate: */
-	if (num<0){
-		_error_("cannot demarshall Hook as num<=0");
-	}
-	else if (num==0){
-		this->ids=NULL;
-		this->offsets=NULL;
-		this->objects=NULL;
-	}
-	else{
-
-		this->ids=(int*)xmalloc(num*sizeof(int));
-		this->offsets=(int*)xmalloc(num*sizeof(int));
-
-		/*demarshall allocated ids and offsets: */
-		_assert_(num<1000);
-		for (i=0;i<num;i++){
-			memcpy(&this->ids[i],marshalled_dataset,sizeof(int));marshalled_dataset+=sizeof(int);
-			memcpy(&this->offsets[i],marshalled_dataset,sizeof(int));marshalled_dataset+=sizeof(int);
-		}
-
-		/*nullify object pointers */
-		this->objects=(Object**)xmalloc(num*sizeof(Object*));
-		for (i=0;i<num;i++){
-			this->objects[i]=NULL;
-		}
-	}
-
-	/*return: */
-	*pmarshalled_dataset=marshalled_dataset;
-	return;
-}
-/*}}}*/
-#endif
 /*FUNCTION Hook::copy {{{1*/
 Object* Hook::copy(void){
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Hook.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Hook.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Hook.h	(revision 12168)
@@ -34,9 +34,4 @@
 		void       Echo(void);
 		void       DeepEcho(void);
-		#ifdef _SERIAL_
-		void       Marshall(char** pmarshalled_dataset);
-		int        MarshallSize();
-		void       Demarshall(char** pmarshalled_dataset);
-		#endif
 		Object*    copy(void);
 		/*}}}*/
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/BoolInput.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/BoolInput.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/BoolInput.cpp	(revision 12168)
@@ -59,55 +59,4 @@
 }
 /*}}}*/
-#ifdef _SERIAL_
-/*FUNCTION BoolInput::Marshall{{{1*/
-void  BoolInput::Marshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   enum_value=0;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*get enum value of BoolInput: */
-	enum_value=BoolInputEnum;
-	
-	/*marshall enum: */
-	memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);
-	
-	/*marshall BoolInput data: */
-	memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-	memcpy(marshalled_dataset,&value,sizeof(value));marshalled_dataset+=sizeof(value);
-
-	*pmarshalled_dataset=marshalled_dataset;
-}
-/*}}}*/
-/*FUNCTION BoolInput::MarshallSize{{{1*/
-int   BoolInput::MarshallSize(){
-	
-	return sizeof(value)+
-		+sizeof(enum_type)+
-		+sizeof(int); //sizeof(int) for enum value
-}
-/*}}}*/
-/*FUNCTION BoolInput::Demarshall{{{1*/
-void  BoolInput::Demarshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   i;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*this time, no need to get enum type, the pointer directly points to the beginning of the 
-	 *object data (thanks to DataSet::Demarshall):*/
-	memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-	memcpy(&value,marshalled_dataset,sizeof(value));marshalled_dataset+=sizeof(value);
-
-	/*return: */
-	*pmarshalled_dataset=marshalled_dataset;
-	return;
-}
-/*}}}*/
-#endif
 /*FUNCTION BoolInput::ObjectEnum{{{1*/
 int BoolInput::ObjectEnum(void){
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/BoolInput.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/BoolInput.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/BoolInput.h	(revision 12168)
@@ -31,9 +31,4 @@
 		int   Id(); 
 		int   MyRank();
-		#ifdef _SERIAL_
-		void  Marshall(char** pmarshalled_dataset);
-		int   MarshallSize();
-		void  Demarshall(char** pmarshalled_dataset);
-		#endif
 		int   ObjectEnum();
 		Object* copy();
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/ControlInput.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/ControlInput.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/ControlInput.h	(revision 12168)
@@ -36,9 +36,4 @@
 		int   Id(); 
 		int   MyRank();
-		#ifdef _SERIAL_
-		void  Marshall(char** pmarshalled_dataset);
-		int   MarshallSize();
-		void  Demarshall(char** pmarshalled_dataset);
-		#endif
 		int   ObjectEnum();
 		Object* copy();
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/DatasetInput.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/DatasetInput.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/DatasetInput.cpp	(revision 12168)
@@ -61,68 +61,4 @@
 }
 /*}}}*/
-#ifdef _SERIAL_
-/*FUNCTION DatasetInput::Marshall{{{1*/
-void  DatasetInput::Marshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	char* marshalled_inputs=NULL;
-	int   marshalled_inputs_size;
-	int   enum_value=0;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*get enum value of DatasetInput: */
-	enum_value=DatasetInputEnum;
-	
-	/*marshall enum: */
-	memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);
-	
-	/*marshall enum_type: */
-	memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-
-	/*marshal inputs*/
-	marshalled_inputs_size=inputs->MarshallSize();
-	marshalled_inputs=inputs->Marshall();
-	memcpy(marshalled_dataset,marshalled_inputs,marshalled_inputs_size*sizeof(char));
-	marshalled_dataset+=marshalled_inputs_size;
-
-	/*clean up and assign output pointer*/
-	xfree((void**)&marshalled_inputs);
-	*pmarshalled_dataset=marshalled_dataset;
-}
-/*}}}*/
-/*FUNCTION DatasetInput::MarshallSize{{{1*/
-int   DatasetInput::MarshallSize(){
-	
-	int size=0;
-
-	size=sizeof(enum_type)+
-	  +inputs->MarshallSize()
-	  +sizeof(int); //sizeof(int) for enum value
-
-	return size;
-}
-/*}}}*/
-/*FUNCTION DatasetInput::Demarshall{{{1*/
-void  DatasetInput::Demarshall(char** pmarshalled_dataset){
-	char* marshalled_dataset=NULL;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*this time, no need to get enum type, the pointer directly points to the beginning of the 
-	 *object data (thanks to DataSet::Demarshall):*/
-	memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-
-	/*Demarshal values*/
-	inputs=(Inputs*)DataSetDemarshallRaw(&marshalled_dataset); 
-
-	/*return: */
-	*pmarshalled_dataset=marshalled_dataset;
-	return;
-}
-/*}}}*/
-#endif
 /*FUNCTION DatasetInput::ObjectEnum{{{1*/
 int DatasetInput::ObjectEnum(void){
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/DatasetInput.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/DatasetInput.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/DatasetInput.h	(revision 12168)
@@ -31,9 +31,4 @@
 		int   Id();
 		int   MyRank();
-		#ifdef _SERIAL_
-		void  Marshall(char** pmarshalled_dataset);
-		int   MarshallSize();
-		void  Demarshall(char** pmarshalled_dataset);
-		#endif
 		int   ObjectEnum();
 		Object* copy();
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/DoubleInput.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/DoubleInput.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/DoubleInput.cpp	(revision 12168)
@@ -59,55 +59,4 @@
 }
 /*}}}*/
-#ifdef _SERIAL_
-/*FUNCTION DoubleInput::Marshall{{{1*/
-void  DoubleInput::Marshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   enum_value=0;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*get enum value of DoubleInput: */
-	enum_value=DoubleInputEnum;
-	
-	/*marshall enum: */
-	memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);
-	
-	/*marshall DoubleInput data: */
-	memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-	memcpy(marshalled_dataset,&value,sizeof(value));marshalled_dataset+=sizeof(value);
-
-	*pmarshalled_dataset=marshalled_dataset;
-}
-/*}}}*/
-/*FUNCTION DoubleInput::MarshallSize{{{1*/
-int   DoubleInput::MarshallSize(){
-	
-	return sizeof(value)+
-		+sizeof(enum_type)+
-		+sizeof(int); //sizeof(int) for enum value
-}
-/*}}}*/
-/*FUNCTION DoubleInput::Demarshall{{{1*/
-void  DoubleInput::Demarshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   i;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*this time, no need to get enum type, the pointer directly points to the beginning of the 
-	 *object data (thanks to DataSet::Demarshall):*/
-	memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-	memcpy(&value,marshalled_dataset,sizeof(value));marshalled_dataset+=sizeof(value);
-
-	/*return: */
-	*pmarshalled_dataset=marshalled_dataset;
-	return;
-}
-/*}}}*/
-#endif
 /*FUNCTION DoubleInput::ObjectEnum{{{1*/
 int DoubleInput::ObjectEnum(void){
@@ -159,9 +108,5 @@
 /*FUNCTION DoubleInput::GetInputValue(bool* pvalue) {{{1*/
 void DoubleInput::GetInputValue(bool* pvalue){
-#ifdef _SERIAL_
-	*pvalue=(bool)value;
-#else
 	_error_("Double input of enum %s cannot return a boolean",EnumToStringx(enum_type));
-#endif
 
 }
@@ -169,9 +114,5 @@
 /*FUNCTION DoubleInput::GetInputValue(int* pvalue){{{1*/
 void DoubleInput::GetInputValue(int* pvalue){
-#ifdef _SERIAL_
-	*pvalue=(int)value;
-#else
 	_error_("Double input of enum %i (%s) cannot return an integer",enum_type,EnumToStringx(enum_type));
-#endif
 
 }
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/DoubleInput.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/DoubleInput.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/DoubleInput.h	(revision 12168)
@@ -30,9 +30,4 @@
 		int   Id(); 
 		int   MyRank();
-		#ifdef _SERIAL_
-		void  Marshall(char** pmarshalled_dataset);
-		int   MarshallSize();
-		void  Demarshall(char** pmarshalled_dataset);
-		#endif
 		int   ObjectEnum();
 		Object* copy();
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/IntInput.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/IntInput.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/IntInput.cpp	(revision 12168)
@@ -54,55 +54,4 @@
 }
 /*}}}*/
-#ifdef _SERIAL_
-/*FUNCTION IntInput::Marshall{{{1*/
-void  IntInput::Marshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   enum_value=0;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*get enum value of IntInput: */
-	enum_value=IntInputEnum;
-	
-	/*marshall enum: */
-	memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);
-	
-	/*marshall IntInput data: */
-	memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-	memcpy(marshalled_dataset,&value,sizeof(value));marshalled_dataset+=sizeof(value);
-
-	*pmarshalled_dataset=marshalled_dataset;
-}
-/*}}}*/
-/*FUNCTION IntInput::MarshallSize{{{1*/
-int   IntInput::MarshallSize(){
-	
-	return sizeof(value)+
-		+sizeof(enum_type)+
-		+sizeof(int); //sizeof(int) for enum value
-}
-/*}}}*/
-/*FUNCTION IntInput::Demarshall{{{1*/
-void  IntInput::Demarshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   i;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*this time, no need to get enum type, the pointer directly points to the beginning of the 
-	 *object data (thanks to DataSet::Demarshall):*/
-	memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-	memcpy(&value,marshalled_dataset,sizeof(value));marshalled_dataset+=sizeof(value);
-
-	/*return: */
-	*pmarshalled_dataset=marshalled_dataset;
-	return;
-}
-/*}}}*/
-#endif
 /*FUNCTION IntInput::ObjectEnum{{{1*/
 int IntInput::ObjectEnum(void){
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/IntInput.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/IntInput.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/IntInput.h	(revision 12168)
@@ -31,9 +31,4 @@
 		int   Id(); 
 		int   MyRank();
-		#ifdef _SERIAL_
-		void  Marshall(char** pmarshalled_dataset);
-		int   MarshallSize();
-		void  Demarshall(char** pmarshalled_dataset);
-		#endif
 		int   ObjectEnum();
 		Object* copy();
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/PentaP1Input.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/PentaP1Input.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/PentaP1Input.cpp	(revision 12168)
@@ -70,55 +70,4 @@
 }
 /*}}}*/
-#ifdef _SERIAL_
-/*FUNCTION PentaP1Input::Marshall{{{1*/
-void  PentaP1Input::Marshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   enum_value=0;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*get enum value of PentaP1Input: */
-	enum_value=PentaP1InputEnum;
-	
-	/*marshall enum: */
-	memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);
-	
-	/*marshall PentaP1Input data: */
-	memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-	memcpy(marshalled_dataset,&values,sizeof(values));marshalled_dataset+=sizeof(values);
-
-	*pmarshalled_dataset=marshalled_dataset;
-}
-/*}}}*/
-/*FUNCTION PentaP1Input::MarshallSize{{{1*/
-int   PentaP1Input::MarshallSize(){
-	
-	return sizeof(values)+
-		+sizeof(enum_type)+
-		+sizeof(int); //sizeof(int) for enum value
-}
-/*}}}*/
-/*FUNCTION PentaP1Input::Demarshall{{{1*/
-void  PentaP1Input::Demarshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   i;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*this time, no need to get enum type, the pointer directly points to the beginning of the 
-	 *object data (thanks to DataSet::Demarshall):*/
-	memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-	memcpy(&values,marshalled_dataset,sizeof(values));marshalled_dataset+=sizeof(values);
-
-	/*return: */
-	*pmarshalled_dataset=marshalled_dataset;
-	return;
-}
-/*}}}*/
-#endif
 /*FUNCTION PentaP1Input::ObjectEnum{{{1*/
 int PentaP1Input::ObjectEnum(void){
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/PentaP1Input.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/PentaP1Input.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/PentaP1Input.h	(revision 12168)
@@ -31,9 +31,4 @@
 		int   Id(); 
 		int   MyRank();
-		#ifdef _SERIAL_
-		void  Marshall(char** pmarshalled_dataset);
-		int   MarshallSize();
-		void  Demarshall(char** pmarshalled_dataset);
-		#endif
 		int   ObjectEnum();
 		Object* copy();
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/TransientInput.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/TransientInput.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/TransientInput.cpp	(revision 12168)
@@ -114,77 +114,4 @@
 }
 /*}}}*/
-#ifdef _SERIAL_
-/*FUNCTION TransientInput::Marshall{{{1*/
-void  TransientInput::Marshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	char* marshalled_inputs=NULL;
-	int   marshalled_inputs_size;
-	int   enum_value=0;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*get enum value of TransientInput: */
-	enum_value=TransientInputEnum;
-	
-	/*marshall enum: */
-	memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);
-
-	/*marshall TransientInput data: */
-	memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-	memcpy(marshalled_dataset,&numtimesteps,sizeof(numtimesteps));marshalled_dataset+=sizeof(numtimesteps);
-	memcpy(marshalled_dataset,timesteps,numtimesteps*sizeof(double));marshalled_dataset+=numtimesteps*sizeof(double);
-
-	/*marshal inputs*/
-	marshalled_inputs_size=inputs->MarshallSize();
-	marshalled_inputs=inputs->Marshall();
-	memcpy(marshalled_dataset,marshalled_inputs,marshalled_inputs_size*sizeof(char));
-	marshalled_dataset+=marshalled_inputs_size;
-
-	/*clean up and assign output pointer*/
-	xfree((void**)&marshalled_inputs);
-	*pmarshalled_dataset=marshalled_dataset;
-
-}
-/*}}}*
-/*FUNCTION TransientInput::MarshallSize{{{1*/
-int   TransientInput::MarshallSize(){
-
-	return 
-		+sizeof(enum_type)+
-		+sizeof(numtimesteps)+
-		+inputs->MarshallSize()
-		+numtimesteps*sizeof(double)+
-		+sizeof(int); //sizeof(int) for enum value
-}
-/*}}}*/
-/*FUNCTION TransientInput::Demarshall{{{1*/
-void  TransientInput::Demarshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*this time, no need to get enum type, the pointer directly points to the beginning of the 
-	 *object data (thanks to DataSet::Demarshall):*/
-	memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-	memcpy(&numtimesteps,marshalled_dataset,sizeof(numtimesteps));marshalled_dataset+=sizeof(numtimesteps);
-
-	/*allocate: */
-	timesteps=(double*)xmalloc(numtimesteps*sizeof(double));
-	memcpy(timesteps,marshalled_dataset,numtimesteps*sizeof(double));marshalled_dataset+=numtimesteps*sizeof(double);
-
-	/*Demarshal values*/
-	inputs=(Inputs*)DataSetDemarshallRaw(&marshalled_dataset);
-
-	/*return: */
-	*pmarshalled_dataset=marshalled_dataset;
-	return;
-
-}
-/*}}}*/
-#endif
 /*FUNCTION TransientInput::ObjectEnum{{{1*/
 int TransientInput::ObjectEnum(void){
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/TransientInput.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/TransientInput.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/TransientInput.h	(revision 12168)
@@ -34,9 +34,4 @@
 		int   Id();
 		int   MyRank();
-		#ifdef _SERIAL_
-		void  Marshall(char** pmarshalled_dataset);
-		int   MarshallSize();
-		void  Demarshall(char** pmarshalled_dataset);
-		#endif
 		int   ObjectEnum();
 		Object* copy();
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/TriaP1Input.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/TriaP1Input.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/TriaP1Input.cpp	(revision 12168)
@@ -70,55 +70,4 @@
 }
 /*}}}*/
-#ifdef _SERIAL_
-/*FUNCTION TriaP1Input::Marshall{{{1*/
-void  TriaP1Input::Marshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   enum_value=0;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*get enum value of TriaP1Input: */
-	enum_value=TriaP1InputEnum;
-	
-	/*marshall enum: */
-	memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);
-	
-	/*marshall TriaP1Input data: */
-	memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-	memcpy(marshalled_dataset,&values,sizeof(values));marshalled_dataset+=sizeof(values);
-
-	*pmarshalled_dataset=marshalled_dataset;
-}
-/*}}}*/
-/*FUNCTION TriaP1Input::MarshallSize{{{1*/
-int   TriaP1Input::MarshallSize(){
-	
-	return sizeof(values)+
-		+sizeof(enum_type)+
-		+sizeof(int); //sizeof(int) for enum value
-}
-/*}}}*/
-/*FUNCTION TriaP1Input::Demarshall{{{1*/
-void  TriaP1Input::Demarshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   i;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*this time, no need to get enum type, the pointer directly points to the beginning of the 
-	 *object data (thanks to DataSet::Demarshall):*/
-	memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-	memcpy(&values,marshalled_dataset,sizeof(values));marshalled_dataset+=sizeof(values);
-
-	/*return: */
-	*pmarshalled_dataset=marshalled_dataset;
-	return;
-}
-/*}}}*/
-#endif
 /*FUNCTION TriaP1Input::ObjectEnum{{{1*/
 int TriaP1Input::ObjectEnum(void){
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/TriaP1Input.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/TriaP1Input.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/TriaP1Input.h	(revision 12168)
@@ -31,9 +31,4 @@
 		int   Id(); 
 		int   MyRank();
-		#ifdef _SERIAL_
-		void  Marshall(char** pmarshalled_dataset);
-		int   MarshallSize();
-		void  Demarshall(char** pmarshalled_dataset);
-		#endif
 		int   ObjectEnum();
 		Object* copy();
Index: /issm/branches/trunk-jpl-damage/src/c/objects/IoModel.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/IoModel.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/IoModel.cpp	(revision 12168)
@@ -198,5 +198,7 @@
 				/*Ok, we have reached the end of the file. break: */
 				record_code=0; //0 means bailout
+				#ifdef _HAVE_MPI_
 				MPI_Bcast(&record_code,1,MPI_INT,0,MPI_COMM_WORLD);  /*tell others cpus we are bailing: */
+				#endif
 				break;
 			}
@@ -207,4 +209,5 @@
 				fread(&record_code,sizeof(int),1,this->fid);
 					
+				#ifdef _HAVE_MPI_
 				/*Tell other cpus what we are doing: */
 				MPI_Bcast(&record_code,1,MPI_INT,0,MPI_COMM_WORLD);  /*tell other cpus what we are going to do: */
@@ -213,11 +216,13 @@
 				MPI_Bcast(&record_enum,1,MPI_INT,0,MPI_COMM_WORLD);  
 				MPI_Bcast(&record_length,1,MPI_INT,0,MPI_COMM_WORLD);  
+				#endif
 				
-
 				switch(record_code){
 					case 1: 
 						/*Read the boolean and broadcast it to other cpus:*/
 						if(fread(&booleanint,sizeof(int),1,this->fid)!=1) _error_(" could not read boolean ");
+						#ifdef _HAVE_MPI_
 						MPI_Bcast(&booleanint,1,MPI_INT,0,MPI_COMM_WORLD); 
+						#endif
 
 						/*create BoolParam: */
@@ -228,5 +233,7 @@
 						/*Read the integer and broadcast it to other cpus:*/
 						if(fread(&integer,sizeof(int),1,this->fid)!=1) _error_(" could not read integer ");
+						#ifdef _HAVE_MPI_
 						MPI_Bcast(&integer,1,MPI_INT,0,MPI_COMM_WORLD); 
+						#endif
 
 						/*create IntParam: */
@@ -237,5 +244,7 @@
 						/*Read the scalar and broadcast it to other cpus:*/
 						if(fread(&scalar,sizeof(double),1,this->fid)!=1) _error_(" could not read scalar ");
+						#ifdef _HAVE_MPI_
 						MPI_Bcast(&scalar,1,MPI_DOUBLE,0,MPI_COMM_WORLD); 
+						#endif
 
 						/*create DoubleParam: */
@@ -246,5 +255,7 @@
 						/*We have to read a string from disk. First read the dimensions of the string, then the string: */
 						if(fread(&string_size,sizeof(int),1,this->fid)!=1) _error_(" could not read length of string ");
+						#ifdef _HAVE_MPI_
 						MPI_Bcast(&string_size,1,MPI_INT,0,MPI_COMM_WORLD); 
+						#endif
 
 						if(string_size){
@@ -254,5 +265,7 @@
 							/*Read string, then broadcast: */
 							if(fread(string,string_size*sizeof(char),1,this->fid)!=1)_error_("  could not read string ");
+							#ifdef _HAVE_MPI_
 							MPI_Bcast(string,string_size,MPI_CHAR,0,MPI_COMM_WORLD); 
+							#endif
 						}
 						else{
@@ -308,4 +321,5 @@
 		}
 	} //}}}
+	#ifdef _HAVE_MPI_
 	else{ //cpu ~0 {{{2
 		for(;;){ //wait on cpu 0
@@ -377,4 +391,5 @@
 		}
 	} //}}}
+	#endif
 }
 /*}}}*/
@@ -399,5 +414,7 @@
 		if(fread(&booleanint,sizeof(int),1,fid)!=1) _error_(" could not read boolean ");
 	}
+	#ifdef _HAVE_MPI_
 	MPI_Bcast(&booleanint,1,MPI_INT,0,MPI_COMM_WORLD); 
+	#endif
 
 	/*cast to bool: */
@@ -428,5 +445,7 @@
 	}
 
+	#ifdef _HAVE_MPI_
 	MPI_Bcast(&integer,1,MPI_INT,0,MPI_COMM_WORLD); 
+	#endif
 
 	/*Assign output pointers: */
@@ -456,5 +475,7 @@
 		if(fread(&scalar,sizeof(double),1,fid)!=1)_error_(" could not read scalar ");
 	}
+	#ifdef _HAVE_MPI_
 	MPI_Bcast(&scalar,1,MPI_DOUBLE,0,MPI_COMM_WORLD); 
+	#endif
 
 	/*Assign output pointers: */
@@ -487,5 +508,7 @@
 	}
 
+	#ifdef _HAVE_MPI_
 	MPI_Bcast(&string_size,1,MPI_INT,0,MPI_COMM_WORLD); 
+	#endif
 
 	/*Now allocate string: */
@@ -498,5 +521,7 @@
 			if(fread(string,string_size*sizeof(char),1,fid)!=1)_error_("  could not read string ");
 		}
+		#ifdef _HAVE_MPI_
 		MPI_Bcast(string,string_size,MPI_CHAR,0,MPI_COMM_WORLD); 
+		#endif
 	}
 	else{
@@ -538,10 +563,14 @@
 	}
 
+	#ifdef _HAVE_MPI_
 	MPI_Bcast(&M,1,MPI_INT,0,MPI_COMM_WORLD); 
+	#endif
 
 	if(my_rank==0){  
 		if(fread(&N,sizeof(int),1,fid)!=1) _error_("could not read number of columns for matrix ");
 	}
-	MPI_Bcast(&N,1,MPI_INT,0,MPI_COMM_WORLD); 
+	#ifdef _HAVE_MPI_
+	MPI_Bcast(&N,1,MPI_INT,0,MPI_COMM_WORLD);
+	#endif
 
 	/*Now allocate matrix: */
@@ -554,5 +583,7 @@
 		}
 		
+		#ifdef _HAVE_MPI_
 		MPI_Bcast(matrix,M*N,MPI_DOUBLE,0,MPI_COMM_WORLD); 
+		#endif
 	}
 
@@ -602,10 +633,14 @@
 		if(fread(&M,sizeof(int),1,fid)!=1) _error_("could not read number of rows for matrix ");
 	}
+	#ifdef _HAVE_MPI_
 	MPI_Bcast(&M,1,MPI_INT,0,MPI_COMM_WORLD); 
+	#endif
 
 	if(my_rank==0){  
 		if(fread(&N,sizeof(int),1,fid)!=1) _error_("could not read number of columns for matrix ");
 	}
+	#ifdef _HAVE_MPI_
 	MPI_Bcast(&N,1,MPI_INT,0,MPI_COMM_WORLD); 
+	#endif
 
 	/*Now allocate matrix: */
@@ -617,5 +652,7 @@
 			if(fread(matrix,M*N*sizeof(double),1,fid)!=1) _error_("could not read matrix ");
 		}
+		#ifdef _HAVE_MPI_
 		MPI_Bcast(matrix,M*N,MPI_DOUBLE,0,MPI_COMM_WORLD); 
+		#endif
 	}
 
@@ -652,5 +689,7 @@
 		if(fread(&numstrings,sizeof(int),1,fid)!=1) _error_(" could not read length of string array");
 	}
+	#ifdef _HAVE_MPI_
 	MPI_Bcast(&numstrings,1,MPI_INT,0,MPI_COMM_WORLD); 
+	#endif
 
 	/*Now allocate string array: */
@@ -665,5 +704,7 @@
 				if(fread(&string_size,sizeof(int),1,fid)!=1) _error_(" could not read length of string ");
 			}
+			#ifdef _HAVE_MPI_
 			MPI_Bcast(&string_size,1,MPI_INT,0,MPI_COMM_WORLD); 
+			#endif
 			if(string_size){
 				string=(char*)xmalloc((string_size+1)*sizeof(char));
@@ -674,5 +715,7 @@
 					if(fread(string,string_size*sizeof(char),1,fid)!=1)_error_("  could not read string ");
 				}
+				#ifdef _HAVE_MPI_
 				MPI_Bcast(string,string_size,MPI_CHAR,0,MPI_COMM_WORLD); 
+				#endif
 			}
 			else{
@@ -717,5 +760,7 @@
 		if(fread(&numrecords,sizeof(int),1,fid)!=1) _error_("could not read number of records in matrix array ");
 	}
+	#ifdef _HAVE_MPI_
 	MPI_Bcast(&numrecords,1,MPI_INT,0,MPI_COMM_WORLD); 
+	#endif
 
 	if(numrecords){
@@ -738,10 +783,14 @@
 				if(fread(&M,sizeof(int),1,fid)!=1) _error_("%s%i%s","could not read number of rows in ",i,"th matrix of matrix array");
 			}
+			#ifdef _HAVE_MPI_
 			MPI_Bcast(&M,1,MPI_INT,0,MPI_COMM_WORLD); 
+			#endif
 
 			if(my_rank==0){  
 				if(fread(&N,sizeof(int),1,fid)!=1) _error_("%s%i%s","could not read number of columns in ",i,"th matrix of matrix array");
 			}
+			#ifdef _HAVE_MPI_
 			MPI_Bcast(&N,1,MPI_INT,0,MPI_COMM_WORLD); 
+			#endif
 
 			/*Now allocate matrix: */
@@ -754,5 +803,7 @@
 				}
 
+				#ifdef _HAVE_MPI_
 				MPI_Bcast(matrix,M*N,MPI_DOUBLE,0,MPI_COMM_WORLD); 
+				#endif
 			}
 
@@ -1047,11 +1098,15 @@
 		}
 	}
+	#ifdef _HAVE_MPI_
 	MPI_Bcast(&found,1,MPI_INT,0,MPI_COMM_WORLD); 
 	if(!found)_error_("%s %s ","could not find data with name",EnumToStringx(data_enum));
+	#endif
 
 	/*Broadcast code and vector type: */
+	#ifdef _HAVE_MPI_
 	MPI_Bcast(&record_code,1,MPI_INT,0,MPI_COMM_WORLD); 
 	MPI_Bcast(&vector_type,1,MPI_INT,0,MPI_COMM_WORLD); 
 	if(record_code==5) MPI_Bcast(&vector_type,1,MPI_INT,0,MPI_COMM_WORLD); 
+	#endif
 
 	/*Assign output pointers:*/
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Loads/Icefront.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Loads/Icefront.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Loads/Icefront.cpp	(revision 12168)
@@ -163,92 +163,4 @@
 }
 /*}}}*/
-#ifdef _SERIAL_
-/*FUNCTION Icefront::Marshall {{{1*/
-void  Icefront::Marshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   enum_type=0;
-	char* marshalled_inputs=NULL;
-	int   marshalled_inputs_size;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*get enum type of Icefront: */
-	enum_type=IcefrontEnum;
-
-	/*marshall enum: */
-	memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-
-	/*marshall Icefront data: */
-	memcpy(marshalled_dataset,&id,sizeof(id));marshalled_dataset+=sizeof(id);
-	memcpy(marshalled_dataset,&analysis_type,sizeof(analysis_type));marshalled_dataset+=sizeof(analysis_type);
-
-	/*Marshall hooks: */
-	hnodes->Marshall(&marshalled_dataset);
-	helement->Marshall(&marshalled_dataset);
-	hmatpar->Marshall(&marshalled_dataset);
-
-	/*Marshall inputs: */
-	marshalled_inputs_size=inputs->MarshallSize();
-	marshalled_inputs=inputs->Marshall();
-	memcpy(marshalled_dataset,marshalled_inputs,marshalled_inputs_size*sizeof(char));
-	marshalled_dataset+=marshalled_inputs_size;
-
-	/*parameters: don't do anything about it. parameters are marshalled somewhere else!*/
-
-	xfree((void**)&marshalled_inputs);
-
-	*pmarshalled_dataset=marshalled_dataset;
-}
-/*}}}*/
-/*FUNCTION Icefront::MarshallSize {{{1*/
-int   Icefront::MarshallSize(){
-	
-	return sizeof(id)
-		+sizeof(analysis_type)
-		+hnodes->MarshallSize()
-		+helement->MarshallSize()
-		+hmatpar->MarshallSize()
-		+inputs->MarshallSize()
-		+sizeof(int); //sizeof(int) for enum type
-}
-/*}}}*/
-/*FUNCTION Icefront::Demarshall {{{1*/
-void  Icefront::Demarshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   i;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*this time, no need to get enum type, the pointer directly points to the beginning of the 
-	 *object data (thanks to DataSet::Demarshall):*/
-	memcpy(&id,marshalled_dataset,sizeof(id));marshalled_dataset+=sizeof(id);
-	memcpy(&analysis_type,marshalled_dataset,sizeof(analysis_type));marshalled_dataset+=sizeof(analysis_type);
-
-	/*demarshall hooks: */
-	hnodes=new Hook(); hnodes->Demarshall(&marshalled_dataset);
-	helement=new Hook(); helement->Demarshall(&marshalled_dataset);
-	hmatpar=new Hook(); hmatpar->Demarshall(&marshalled_dataset);
-	
-	/*pointers are garbabe, until configuration is carried out: */
-	nodes=NULL;
-	element=NULL;
-	matpar=NULL;
-
-	/*demarshall inputs: */
-	inputs=(Inputs*)DataSetDemarshallRaw(&marshalled_dataset); 
-
-	/*parameters: may not exist even yet, so let Configure handle it: */
-	this->parameters=NULL;
-
-	/*return: */
-	*pmarshalled_dataset=marshalled_dataset;
-	return;
-}
-/*}}}*/
-#endif
 /*FUNCTION Icefront::ObjectEnum{{{1*/
 int Icefront::ObjectEnum(void){
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Loads/Icefront.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Loads/Icefront.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Loads/Icefront.h	(revision 12168)
@@ -49,9 +49,4 @@
 		int   Id(); 
 		int   MyRank();
-		#ifdef _SERIAL_
-		void  Marshall(char** pmarshalled_dataset);
-		int   MarshallSize();
-		void  Demarshall(char** pmarshalled_dataset);
-		#endif
 		int   ObjectEnum();
 		Object* copy();
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Loads/Numericalflux.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Loads/Numericalflux.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Loads/Numericalflux.cpp	(revision 12168)
@@ -189,87 +189,4 @@
 }
 /*}}}*/
-#ifdef _SERIAL_
-/*FUNCTION Numericalflux::Marshall {{{1*/
-void  Numericalflux::Marshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   enum_type=0;
-	char* marshalled_inputs=NULL;
-	int   marshalled_inputs_size;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*get enum type of Numericalflux: */
-	enum_type=NumericalfluxEnum;
-
-	/*marshall enum: */
-	memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-
-	/*marshall Numericalflux data: */
-	memcpy(marshalled_dataset,&id,sizeof(id));marshalled_dataset+=sizeof(id);
-	memcpy(marshalled_dataset,&analysis_type,sizeof(analysis_type));marshalled_dataset+=sizeof(analysis_type);
-
-	/*Marshall hooks: */
-	hnodes->Marshall(&marshalled_dataset);
-	helement->Marshall(&marshalled_dataset);
-
-	/*Marshall inputs: */
-	marshalled_inputs_size=inputs->MarshallSize();
-	marshalled_inputs=inputs->Marshall();
-	memcpy(marshalled_dataset,marshalled_inputs,marshalled_inputs_size*sizeof(char));
-	marshalled_dataset+=marshalled_inputs_size;
-
-	/*parameters: don't do anything about it. parameters are marshalled somewhere else!*/
-
-	xfree((void**)&marshalled_inputs);
-
-	*pmarshalled_dataset=marshalled_dataset;
-	return;
-}
-/*}}}*/
-/*FUNCTION Numericalflux::MarshallSize{{{1*/
-int   Numericalflux::MarshallSize(){
-
-	return sizeof(id)
-		+sizeof(analysis_type)
-		+hnodes->MarshallSize()
-		+helement->MarshallSize()
-		+inputs->MarshallSize()
-		+sizeof(int); //sizeof(int) for enum type
-}
-/*}}}*/
-/*FUNCTION Numericalflux::Demarshall {{{1*/
-void  Numericalflux::Demarshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   i;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*this time, no need to get enum type, the pointer directly points to the beginning of the 
-	 *object data (thanks to DataSet::Demarshall):*/
-	memcpy(&id,marshalled_dataset,sizeof(id));marshalled_dataset+=sizeof(id);
-	memcpy(&analysis_type,marshalled_dataset,sizeof(analysis_type));marshalled_dataset+=sizeof(analysis_type);
-
-	/*demarshall hooks: */
-	hnodes=new Hook(); hnodes->Demarshall(&marshalled_dataset);
-	helement=new Hook(); helement->Demarshall(&marshalled_dataset);
-	
-	/*demarshall inputs: */
-	inputs=(Inputs*)DataSetDemarshallRaw(&marshalled_dataset); 
-
-	/*parameters: may not exist even yet, so let Configure handle it: */
-	this->parameters=NULL;
-	this->element=NULL;
-	this->nodes=NULL;
-
-	/*return: */
-	*pmarshalled_dataset=marshalled_dataset;
-	return;
-}
-/*}}}*/
-#endif
 /*FUNCTION Numericalflux::ObjectEnum{{{1*/
 int Numericalflux::ObjectEnum(void){
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Loads/Numericalflux.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Loads/Numericalflux.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Loads/Numericalflux.h	(revision 12168)
@@ -45,9 +45,4 @@
 		int   Id(); 
 		int   MyRank();
-		#ifdef _SERIAL_
-		void  Marshall(char** pmarshalled_dataset);
-		int   MarshallSize();
-		void  Demarshall(char** pmarshalled_dataset);
-		#endif
 		int   ObjectEnum();
 		Object* copy();
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Loads/Pengrid.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Loads/Pengrid.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Loads/Pengrid.cpp	(revision 12168)
@@ -132,98 +132,4 @@
 }
 /*}}}1*/
-#ifdef _SERIAL_
-/*FUNCTION Pengrid::Marshall {{{1*/
-void  Pengrid::Marshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   enum_type=0;
-	char* marshalled_inputs=NULL;
-	int   marshalled_inputs_size;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*get enum type of Tria: */
-	enum_type=PengridEnum;
-
-	/*marshall enum: */
-	memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-
-	/*marshall Tria data: */
-	memcpy(marshalled_dataset,&id,sizeof(id));marshalled_dataset+=sizeof(id);
-	memcpy(marshalled_dataset,&analysis_type,sizeof(analysis_type));marshalled_dataset+=sizeof(analysis_type);
-	memcpy(marshalled_dataset,&active,sizeof(active));marshalled_dataset+=sizeof(active);
-	memcpy(marshalled_dataset,&zigzag_counter,sizeof(zigzag_counter));marshalled_dataset+=sizeof(zigzag_counter);
-
-	/*Marshall hooks: */
-	hnode->Marshall(&marshalled_dataset);
-	helement->Marshall(&marshalled_dataset);
-	hmatpar->Marshall(&marshalled_dataset);
-
-	/*Marshall inputs: */
-	marshalled_inputs_size=inputs->MarshallSize();
-	marshalled_inputs=inputs->Marshall();
-	memcpy(marshalled_dataset,marshalled_inputs,marshalled_inputs_size*sizeof(char));
-	marshalled_dataset+=marshalled_inputs_size;
-
-	/*parameters: don't do anything about it. parameters are marshalled somewhere else!*/
-
-	xfree((void**)&marshalled_inputs);
-
-	*pmarshalled_dataset=marshalled_dataset;
-	return;
-}
-/*}}}*/
-/*FUNCTION Pengrid::MarshallSize {{{1*/
-int   Pengrid::MarshallSize(){
-	
-	return sizeof(id)
-		+sizeof(analysis_type)
-		+sizeof(active)
-		+sizeof(zigzag_counter)
-		+hnode->MarshallSize()
-		+helement->MarshallSize()
-		+hmatpar->MarshallSize()
-		+inputs->MarshallSize()
-		+sizeof(int); //sizeof(int) for enum type
-}
-/*}}}*/
-/*FUNCTION Pengrid::Demarshall {{{1*/
-void  Pengrid::Demarshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   i;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*this time, no need to get enum type, the pointer directly points to the beginning of the 
-	 *object data (thanks to DataSet::Demarshall):*/
-
-	memcpy(&id,marshalled_dataset,sizeof(id));marshalled_dataset+=sizeof(id);
-	memcpy(&analysis_type,marshalled_dataset,sizeof(analysis_type));marshalled_dataset+=sizeof(analysis_type);
-	memcpy(&active,marshalled_dataset,sizeof(active));marshalled_dataset+=sizeof(active);
-	memcpy(&zigzag_counter,marshalled_dataset,sizeof(zigzag_counter));marshalled_dataset+=sizeof(zigzag_counter);
-
-	/*demarshall hooks: */
-	hnode=new Hook(); hnode->Demarshall(&marshalled_dataset);
-	helement=new Hook(); helement->Demarshall(&marshalled_dataset);
-	hmatpar=new Hook(); hmatpar->Demarshall(&marshalled_dataset);
-	
-	/*demarshall inputs: */
-	inputs=(Inputs*)DataSetDemarshallRaw(&marshalled_dataset); 
-
-	/*parameters: may not exist even yet, so let Configure handle it: */
-	this->parameters=NULL;
-	this->node=NULL;
-	this->element=NULL;
-	this->matpar=NULL;
-
-	/*return: */
-	*pmarshalled_dataset=marshalled_dataset;
-	return;
-}
-/*}}}*/
-#endif
 /*FUNCTION Pengrid::ObjectEnum{{{1*/
 int Pengrid::ObjectEnum(void){
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Loads/Pengrid.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Loads/Pengrid.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Loads/Pengrid.h	(revision 12168)
@@ -50,9 +50,4 @@
 		int   Id(); 
 		int   MyRank();
-		#ifdef _SERIAL_
-		void  Marshall(char** pmarshalled_dataset);
-		int   MarshallSize();
-		void  Demarshall(char** pmarshalled_dataset);
-		#endif
 		int   ObjectEnum();
 		Object* copy();
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Loads/Penpair.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Loads/Penpair.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Loads/Penpair.cpp	(revision 12168)
@@ -85,67 +85,4 @@
 }
 /*}}}1*/
-#ifdef _SERIAL_
-/*FUNCTION Penpair::Marshall {{{1*/
-void  Penpair::Marshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   enum_type=0;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*get enum type of Penpair: */
-	enum_type=PenpairEnum;
-	
-	/*marshall enum: */
-	memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-	
-	/*marshall Penpair data: */
-	memcpy(marshalled_dataset,&id,sizeof(id));marshalled_dataset+=sizeof(id);
-	memcpy(marshalled_dataset,&analysis_type,sizeof(analysis_type));marshalled_dataset+=sizeof(analysis_type);
-
-	/*Marshall hooks*/
-	hnodes->Marshall(&marshalled_dataset);
-
-	*pmarshalled_dataset=marshalled_dataset;
-	return;
-}
-/*}}}1*/
-/*FUNCTION Penpair::MarshallSize {{{1*/
-int   Penpair::MarshallSize(){
-
-	return sizeof(id)+
-		+sizeof(analysis_type)
-		+hnodes->MarshallSize()
-		+sizeof(int); //sizeof(int) for enum type
-}
-/*}}}1*/
-/*FUNCTION Penpair::Demarshall {{{1*/
-void  Penpair::Demarshall(char** pmarshalled_dataset){
-
-	int i;
-	char* marshalled_dataset=NULL;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*this time, no need to get enum type, the pointer directly points to the beginning of the 
-	 *object data (thanks to DataSet::Demarshall):*/
-	memcpy(&id,marshalled_dataset,sizeof(id));marshalled_dataset+=sizeof(id);
-	memcpy(&analysis_type,marshalled_dataset,sizeof(analysis_type));marshalled_dataset+=sizeof(analysis_type);
-
-	/*demarshall hooks: */
-	hnodes=new Hook(); hnodes->Demarshall(&marshalled_dataset);
-
-	/*pointers are garbabe, until configuration is carried out: */
-	nodes=NULL;
-	parameters=NULL;
-
-	/*return: */
-	*pmarshalled_dataset=marshalled_dataset;
-	return;
-}
-/*}}}1*/
-#endif
 /*FUNCTION Penpair::ObjectEnum{{{1*/
 int Penpair::ObjectEnum(void){
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Loads/Penpair.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Loads/Penpair.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Loads/Penpair.h	(revision 12168)
@@ -37,9 +37,4 @@
 		int   Id(); 
 		int   MyRank();
-		#ifdef _SERIAL_
-		void  Marshall(char** pmarshalled_dataset);
-		int   MarshallSize();
-		void  Demarshall(char** pmarshalled_dataset);
-		#endif
 		int   ObjectEnum();
 		Object* copy();
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Loads/Riftfront.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Loads/Riftfront.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Loads/Riftfront.cpp	(revision 12168)
@@ -192,123 +192,4 @@
 }
 /*}}}1*/
-#ifdef _SERIAL_
-/*FUNCTION Riftfront::Marshall {{{1*/
-void  Riftfront::Marshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   enum_type=0;
-	char* marshalled_inputs=NULL;
-	int   marshalled_inputs_size;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*get enum type of Riftfront: */
-	enum_type=RiftfrontEnum;
-
-	/*marshall enum: */
-	memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-
-	/*marshall Riftfront data: */
-	memcpy(marshalled_dataset,&id,sizeof(id));marshalled_dataset+=sizeof(id);
-	memcpy(marshalled_dataset,&analysis_type,sizeof(analysis_type));marshalled_dataset+=sizeof(analysis_type);
-	memcpy(marshalled_dataset,&active,sizeof(active));marshalled_dataset+=sizeof(active);
-	memcpy(marshalled_dataset,&normal,sizeof(normal));marshalled_dataset+=sizeof(normal);
-	memcpy(marshalled_dataset,&length,sizeof(length));marshalled_dataset+=sizeof(length);
-	memcpy(marshalled_dataset,&fraction,sizeof(fraction));marshalled_dataset+=sizeof(fraction);
-	memcpy(marshalled_dataset,&frozen,sizeof(frozen));marshalled_dataset+=sizeof(frozen);
-	memcpy(marshalled_dataset,&state,sizeof(state));marshalled_dataset+=sizeof(state);
-	memcpy(marshalled_dataset,&counter,sizeof(counter));marshalled_dataset+=sizeof(counter);
-	memcpy(marshalled_dataset,&prestable,sizeof(prestable));marshalled_dataset+=sizeof(prestable);
-	memcpy(marshalled_dataset,&penalty_lock,sizeof(penalty_lock));marshalled_dataset+=sizeof(penalty_lock);
-	memcpy(marshalled_dataset,&material_converged,sizeof(material_converged));marshalled_dataset+=sizeof(material_converged);
-
-	/*Marshall hooks: */
-	hnodes->Marshall(&marshalled_dataset);
-	helements->Marshall(&marshalled_dataset);
-	hmatpar->Marshall(&marshalled_dataset);
-
-	/*Marshall inputs: */
-	marshalled_inputs_size=inputs->MarshallSize();
-	marshalled_inputs=inputs->Marshall();
-	memcpy(marshalled_dataset,marshalled_inputs,marshalled_inputs_size*sizeof(char));
-	marshalled_dataset+=marshalled_inputs_size;
-
-	/*parameters: don't do anything about it. parameters are marshalled somewhere else!*/
-
-	xfree((void**)&marshalled_inputs);
-
-	*pmarshalled_dataset=marshalled_dataset;
-	return;
-}
-/*}}}*/
-/*FUNCTION Riftfront::MarshallSize {{{1*/
-int   Riftfront::MarshallSize(){
-	
-	return sizeof(id)
-		+sizeof(analysis_type)
-		+sizeof(active)
-		+sizeof(normal)
-		+sizeof(length)
-		+sizeof(fraction)
-		+sizeof(frozen)
-		+sizeof(state)
-		+sizeof(counter)
-		+sizeof(prestable)
-		+sizeof(penalty_lock)
-		+sizeof(material_converged)
-		+hnodes->MarshallSize()
-		+helements->MarshallSize()
-		+hmatpar->MarshallSize()
-		+inputs->MarshallSize()
-		+sizeof(int); //sizeof(int) for enum type
-}
-/*}}}*/
-/*FUNCTION Riftfront::Demarshall {{{1*/
-void  Riftfront::Demarshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   i;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*this time, no need to get enum type, the pointer directly points to the beginning of the 
-	 *object data (thanks to DataSet::Demarshall):*/
-
-	memcpy(&id,marshalled_dataset,sizeof(id));marshalled_dataset+=sizeof(id);
-	memcpy(&analysis_type,marshalled_dataset,sizeof(analysis_type));marshalled_dataset+=sizeof(analysis_type);
-	memcpy(&active,marshalled_dataset,sizeof(active));marshalled_dataset+=sizeof(active);
-	memcpy(&normal,marshalled_dataset,sizeof(normal));marshalled_dataset+=sizeof(normal);
-	memcpy(&length,marshalled_dataset,sizeof(length));marshalled_dataset+=sizeof(length);
-	memcpy(&fraction,marshalled_dataset,sizeof(fraction));marshalled_dataset+=sizeof(fraction);
-	memcpy(&frozen,marshalled_dataset,sizeof(frozen));marshalled_dataset+=sizeof(frozen);
-	memcpy(&state,marshalled_dataset,sizeof(state));marshalled_dataset+=sizeof(state);
-	memcpy(&counter,marshalled_dataset,sizeof(counter));marshalled_dataset+=sizeof(counter);
-	memcpy(&prestable,marshalled_dataset,sizeof(prestable));marshalled_dataset+=sizeof(prestable);
-	memcpy(&penalty_lock,marshalled_dataset,sizeof(penalty_lock));marshalled_dataset+=sizeof(penalty_lock);
-	memcpy(&material_converged,marshalled_dataset,sizeof(material_converged));marshalled_dataset+=sizeof(material_converged);
-
-	/*demarshall hooks: */
-	hnodes=new Hook();    hnodes->Demarshall(&marshalled_dataset);
-	helements=new Hook(); helements->Demarshall(&marshalled_dataset);
-	hmatpar=new Hook();   hmatpar->Demarshall(&marshalled_dataset);
-
-	/*pointers are garbabe, until configuration is carried out: */
-	nodes=NULL;
-	elements=NULL;
-	matpar=NULL;
-	
-	/*demarshall inputs: */
-	inputs=(Inputs*)DataSetDemarshallRaw(&marshalled_dataset); 
-
-	/*parameters: may not exist even yet, so let Configure handle it: */
-	this->parameters=NULL;
-
-	/*return: */
-	*pmarshalled_dataset=marshalled_dataset;
-}
-/*}}}*/
-#endif
 /*FUNCTION Riftfront::ObjectEnum{{{1*/
 int Riftfront::ObjectEnum(void){
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Loads/Riftfront.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Loads/Riftfront.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Loads/Riftfront.h	(revision 12168)
@@ -57,9 +57,4 @@
 		int   Id(); 
 		int   MyRank();
-		#ifdef _SERIAL_
-		void  Marshall(char** pmarshalled_dataset);
-		int   MarshallSize();
-		void  Demarshall(char** pmarshalled_dataset);
-		#endif
 		int   ObjectEnum();
 		Object* copy();
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Materials/Matice.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Materials/Matice.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Materials/Matice.cpp	(revision 12168)
@@ -88,74 +88,4 @@
 }
 /*}}}*/
-#ifdef _SERIAL_
-/*FUNCTION Matice::Marshall {{{1*/
-void  Matice::Marshall(char** pmarshalled_dataset){
-
-	/*Intermediaries*/
-	char* marshalled_dataset=NULL;
-	int   enum_type=0;
-	char* marshalled_inputs=NULL;
-	int   marshalled_inputs_size;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*get enum type of Matice: */
-	enum_type=MaticeEnum;
-	
-	/*marshall enum: */
-	memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-	
-	/*marshall Matice data: */
-	memcpy(marshalled_dataset,&mid,sizeof(mid));marshalled_dataset+=sizeof(mid);
-
-	/*Marshall hooks: */
-	helement->Marshall(&marshalled_dataset);
-
-	/*Marshall inputs: */
-	marshalled_inputs_size=inputs->MarshallSize();
-	marshalled_inputs=inputs->Marshall();
-	memcpy(marshalled_dataset,marshalled_inputs,marshalled_inputs_size*sizeof(char));
-	marshalled_dataset+=marshalled_inputs_size;
-
-	*pmarshalled_dataset=marshalled_dataset;
-
-	/*clean up and return*/
-	xfree((void**)&marshalled_inputs);
-}
-/*}}}*/
-/*FUNCTION Matice::MarshallSize{{{1*/
-int   Matice::MarshallSize(){
-
-	return sizeof(mid)
-	  +helement->MarshallSize()
-	  +inputs->MarshallSize()
-	  +sizeof(int); //sizeof(int) for enum type
-}
-/*}}}*/
-/*FUNCTION Matice::Demarshall {{{1*/
-void  Matice::Demarshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*this time, no need to get enum type, the pointer directly points to the beginning of the 
-	 *object data (thanks to DataSet::Demarshall):*/
-	memcpy(&mid,marshalled_dataset,sizeof(mid));marshalled_dataset+=sizeof(mid);
-
-	/*demarshall hooks: */
-	helement=new Hook(); helement->Demarshall(&marshalled_dataset);
-
-	/*demarshall inputs: */
-	inputs=(Inputs*)DataSetDemarshallRaw(&marshalled_dataset); 
-
-	/*return: */
-	*pmarshalled_dataset=marshalled_dataset;
-	return;
-}
-/*}}}*/
-#endif
 /*FUNCTION Matice::ObjectEnum{{{1*/
 int Matice::ObjectEnum(void){
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Materials/Matice.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Materials/Matice.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Materials/Matice.h	(revision 12168)
@@ -35,9 +35,4 @@
 		int   Id(); 
 		int   MyRank();
-		#ifdef _SERIAL_
-		void  Marshall(char** pmarshalled_dataset);
-		int   MarshallSize();
-		void  Demarshall(char** pmarshalled_dataset);
-		#endif
 		int   ObjectEnum();
 		Object* copy();
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Materials/Matpar.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Materials/Matpar.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Materials/Matpar.cpp	(revision 12168)
@@ -102,89 +102,4 @@
 }
 /*}}}1*/
-#ifdef _SERIAL_
-/*FUNCTION Matpar::Marshall {{{1*/
-void  Matpar::Marshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   enum_type=0;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*get enum type of Matpar: */
-	enum_type=MatparEnum;
-	
-	/*marshall enum: */
-	memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-	
-	/*marshall Matpar data: */
-	memcpy(marshalled_dataset,&mid,sizeof(mid));marshalled_dataset+=sizeof(mid);
-	memcpy(marshalled_dataset,&rho_ice,sizeof(rho_ice));marshalled_dataset+=sizeof(rho_ice);
-	memcpy(marshalled_dataset,&rho_water,sizeof(rho_water));marshalled_dataset+=sizeof(rho_water);
-	memcpy(marshalled_dataset,&mu_water,sizeof(mu_water));marshalled_dataset+=sizeof(mu_water);
-	memcpy(marshalled_dataset,&heatcapacity,sizeof(heatcapacity));marshalled_dataset+=sizeof(heatcapacity);
-	memcpy(marshalled_dataset,&thermalconductivity,sizeof(thermalconductivity));marshalled_dataset+=sizeof(thermalconductivity);
-	memcpy(marshalled_dataset,&latentheat,sizeof(latentheat));marshalled_dataset+=sizeof(latentheat);
-	memcpy(marshalled_dataset,&beta,sizeof(beta));marshalled_dataset+=sizeof(beta);
-	memcpy(marshalled_dataset,&meltingpoint,sizeof(meltingpoint));marshalled_dataset+=sizeof(meltingpoint);
-	memcpy(marshalled_dataset,&referencetemperature,sizeof(referencetemperature));marshalled_dataset+=sizeof(referencetemperature);
-	memcpy(marshalled_dataset,&mixed_layer_capacity,sizeof(mixed_layer_capacity));marshalled_dataset+=sizeof(mixed_layer_capacity);
-	memcpy(marshalled_dataset,&thermal_exchange_velocity,sizeof(thermal_exchange_velocity));marshalled_dataset+=sizeof(thermal_exchange_velocity);
-	memcpy(marshalled_dataset,&g,sizeof(g));marshalled_dataset+=sizeof(g);
-
-	*pmarshalled_dataset=marshalled_dataset;
-	return;
-}
-/*}}}1*/
-/*FUNCTION Matpar::MarshallSize {{{1*/
-int   Matpar::MarshallSize(){
-
-	return sizeof(mid)+
-		sizeof(rho_ice)+
-		sizeof(rho_water)+
-		sizeof(mu_water)+
-		sizeof(heatcapacity)+
-		sizeof(thermalconductivity)+
-		sizeof(latentheat)+
-		sizeof(beta)+
-		sizeof(meltingpoint)+
-		sizeof(referencetemperature)+
-		sizeof(mixed_layer_capacity)+
-		sizeof(thermal_exchange_velocity)+
-		sizeof(g)+
-		sizeof(int); //sizeof(int) for enum type
-}
-/*}}}1*/
-/*FUNCTION Matpar::Demarshall {{{1*/
-void  Matpar::Demarshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*this time, no need to get enum type, the pointer directly points to the beginning of the 
-	 *object data (thanks to DataSet::Demarshall):*/
-
-	memcpy(&mid,marshalled_dataset,sizeof(mid));marshalled_dataset+=sizeof(mid);
-	memcpy(&rho_ice,marshalled_dataset,sizeof(rho_ice));marshalled_dataset+=sizeof(rho_ice);
-	memcpy(&rho_water,marshalled_dataset,sizeof(rho_water));marshalled_dataset+=sizeof(rho_water);
-	memcpy(&mu_water,marshalled_dataset,sizeof(mu_water));marshalled_dataset+=sizeof(mu_water);
-	memcpy(&heatcapacity,marshalled_dataset,sizeof(heatcapacity));marshalled_dataset+=sizeof(heatcapacity);
-	memcpy(&thermalconductivity,marshalled_dataset,sizeof(thermalconductivity));marshalled_dataset+=sizeof(thermalconductivity);
-	memcpy(&latentheat,marshalled_dataset,sizeof(latentheat));marshalled_dataset+=sizeof(latentheat);
-	memcpy(&beta,marshalled_dataset,sizeof(beta));marshalled_dataset+=sizeof(beta);
-	memcpy(&meltingpoint,marshalled_dataset,sizeof(meltingpoint));marshalled_dataset+=sizeof(meltingpoint);
-	memcpy(&referencetemperature,marshalled_dataset,sizeof(referencetemperature));marshalled_dataset+=sizeof(referencetemperature);
-	memcpy(&mixed_layer_capacity,marshalled_dataset,sizeof(mixed_layer_capacity));marshalled_dataset+=sizeof(mixed_layer_capacity);
-	memcpy(&thermal_exchange_velocity,marshalled_dataset,sizeof(thermal_exchange_velocity));marshalled_dataset+=sizeof(thermal_exchange_velocity);
-	memcpy(&g,marshalled_dataset,sizeof(g));marshalled_dataset+=sizeof(g);
-
-	/*return: */
-	*pmarshalled_dataset=marshalled_dataset;
-	return;
-}
-/*}}}1*/
-#endif
 /*FUNCTION Matpar::ObjectEnum{{{1*/
 int Matpar::ObjectEnum(void){
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Materials/Matpar.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Materials/Matpar.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Materials/Matpar.h	(revision 12168)
@@ -46,9 +46,4 @@
 		int   Id(); 
 		int   MyRank();
-		#ifdef _SERIAL_
-		void  Marshall(char** pmarshalled_dataset);
-		int   MarshallSize();
-		void  Demarshall(char** pmarshalled_dataset);
-		#endif
 		int   ObjectEnum();
 		Object* copy();
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Node.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Node.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Node.cpp	(revision 12168)
@@ -193,87 +193,4 @@
 }
 /*}}}*/
-#ifdef _SERIAL_
-/*FUNCTION Node::Marshall{{{1*/
-void  Node::Marshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   enum_type=0;
-	char* marshalled_inputs=NULL;
-	int   marshalled_inputssize;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*get enum type of Node: */
-	enum_type=NodeEnum;
-	
-	/*marshall enum: */
-	memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-	
-	/*marshall Node data: */
-	memcpy(marshalled_dataset,&id,sizeof(id));marshalled_dataset+=sizeof(id);
-	memcpy(marshalled_dataset,&sid,sizeof(sid));marshalled_dataset+=sizeof(sid);
-	memcpy(marshalled_dataset,&analysis_type,sizeof(analysis_type));marshalled_dataset+=sizeof(analysis_type);
-	memcpy(marshalled_dataset,&coord_system,9*sizeof(double));marshalled_dataset+=9*sizeof(double);  
-
-	/*marshall objects: */
-	indexing.Marshall(&marshalled_dataset);
-	hvertex->Marshall(&marshalled_dataset);
-
-	/*Marshall inputs: */
-	marshalled_inputssize=inputs->MarshallSize();
-	marshalled_inputs=inputs->Marshall();
-	memcpy(marshalled_dataset,marshalled_inputs,marshalled_inputssize*sizeof(char));
-	marshalled_dataset+=marshalled_inputssize;
-
-	/*Free ressources:*/
-	xfree((void**)&marshalled_inputs);
-
-	*pmarshalled_dataset=marshalled_dataset;
-	return;
-}
-/*}}}*/
-/*FUNCTION Node::MarshallSize{{{1*/
-int   Node::MarshallSize(){
-
-	return sizeof(id)+
-		sizeof(sid)+
-		indexing.MarshallSize()+
-		hvertex->MarshallSize()+
-		inputs->MarshallSize()+
-		sizeof(analysis_type)+
-		9*sizeof(double)+
-		sizeof(int); //sizeof(int) for enum type
-}
-/*}}}*/
-/*FUNCTION Node::Demarshall{{{1*/
-void  Node::Demarshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*this time, no need to get enum type, the pointer directly points to the beginning of the 
-	 *object data (thanks to DataSet::Demarshall):*/
-
-	memcpy(&id,marshalled_dataset,sizeof(id));marshalled_dataset+=sizeof(id);
-	memcpy(&sid,marshalled_dataset,sizeof(sid));marshalled_dataset+=sizeof(sid);
-	memcpy(&analysis_type,marshalled_dataset,sizeof(analysis_type));marshalled_dataset+=sizeof(analysis_type);
-	memcpy(&coord_system,marshalled_dataset,9*sizeof(double));marshalled_dataset+=9*sizeof(double);
-	
-	/*demarshall objects: */
-	indexing.Demarshall(&marshalled_dataset);
-	hvertex=new Hook(); hvertex->Demarshall(&marshalled_dataset);
-
-	/*demarshall inputs: */
-	inputs=(Inputs*)DataSetDemarshallRaw(&marshalled_dataset); 
-
-	/*return: */
-	*pmarshalled_dataset=marshalled_dataset;
-	return;
-}
-/*}}}*/
-#endif
 /*FUNCTION Node::ObjectEnum{{{1*/
 int Node::ObjectEnum(void){
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Node.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Node.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Node.h	(revision 12168)
@@ -44,9 +44,4 @@
 		int   Id(); 
 		int   MyRank();
-		#ifdef _SERIAL_
-		void  Marshall(char** pmarshalled_dataset);
-		int   MarshallSize();
-		void  Demarshall(char** pmarshalled_dataset);
-		#endif
 		int   ObjectEnum();
 		Object* copy(){_error_("Not implemented yet (similar to Elements)");};
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Numerics/Matrix.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Numerics/Matrix.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Numerics/Matrix.cpp	(revision 12168)
@@ -140,38 +140,4 @@
 }
 /*}}}*/
-
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-/*FUNCTION Matrix::ToMatlabMatrix{{{1*/
-mxArray* Matrix::ToMatlabMatrix(void){
-
-	mxArray* dataref=NULL;
-	#ifdef _HAVE_PETSC_
-	PetscMatrixToMatlabMatrix(&dataref,this->matrix);
-	#else
-	dataref=this->matrix->ToMatlabMatrix();
-	#endif
-	return dataref;
-
-}
-/*}}}*/
-/*FUNCTION MatlabMatrixToMatrix{{{1*/
-Matrix* MatlabMatrixToMatrix(const mxArray* mxmatrix){
-
-	int dummy;
-	Matrix* matrix=NULL;
-
-	/*allocate matrix object: */
-	matrix=new Matrix();
-
-	#ifdef _HAVE_PETSC_
-	MatlabMatrixToPetscMatrix(&matrix->matrix,NULL,NULL,mxmatrix);
-	#else
-	matrix->matrix=MatlabMatrixToSeqMat(mxmatrix);
-	#endif
-	
-	return matrix;
-}
-/*}}}*/
-#endif
 /*FUNCTION Matrix::Assemble{{{1*/
 void Matrix::Assemble(void){
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Numerics/Matrix.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Numerics/Matrix.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Numerics/Matrix.h	(revision 12168)
@@ -21,7 +21,4 @@
 #endif
 
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-#include "mex.h"
-#endif
 class Vector;
 
@@ -51,7 +48,4 @@
 		/*Matrix specific routines {{{1*/
 		void Echo(void);
-		#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-		mxArray* ToMatlabMatrix(void);
-		#endif
 		void Assemble(void);
 		double Norm(NormMode norm_type);
@@ -66,8 +60,4 @@
 
 };
-/*API: */
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-Matrix* MatlabMatrixToMatrix(const mxArray* mxmatrix);
-#endif
 
 #endif //#ifndef _MATRIX_H_
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Numerics/Vector.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Numerics/Vector.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Numerics/Vector.cpp	(revision 12168)
@@ -132,38 +132,4 @@
 }
 /*}}}*/
-
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-/*FUNCTION Vector::ToMatlabVector{{{1*/
-mxArray* Vector::ToMatlabVector(void){
-
-	mxArray* dataref=NULL;
-	#ifdef _HAVE_PETSC_
-	PetscVectorToMatlabVector(&dataref,this->vector);
-	#else
-	dataref=this->vector->ToMatlabVector();
-	#endif
-	return dataref;
-
-}
-/*}}}*/
-/*FUNCTION MatlabVectorToVector{{{1*/
-Vector* MatlabVectorToVector(const mxArray* mxvector){
-
-	int dummy;
-	Vector* vector=NULL;
-
-	/*allocate vector object: */
-	vector=new Vector();
-
-	#ifdef _HAVE_PETSC_
-	MatlabVectorToPetscVector(&vector->vector,&dummy,mxvector);
-	#else
-	vector->vector=MatlabVectorToSeqVec(mxvector);
-	#endif
-	
-	return vector;
-}
-/*}}}*/
-#endif
 /*FUNCTION Vector::Assemble{{{1*/
 void Vector::Assemble(void){
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Numerics/Vector.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Numerics/Vector.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Numerics/Vector.h	(revision 12168)
@@ -21,8 +21,4 @@
 #endif
 		
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-#include "mex.h"
-#endif
-
 /*}}}*/
 
@@ -54,7 +50,4 @@
 		/*Vector specific routines {{{1*/
 		void Echo(void);
-		#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-		mxArray* ToMatlabVector(void);
-		#endif
 		void    AXPY(Vector *X, double a);
 		void    AYPX(Vector *X, double a);
@@ -77,8 +70,4 @@
 };
 
-/*API: */
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-Vector* MatlabVectorToVector(const mxArray* mxvector);
-#endif
 
 #endif //#ifndef _VECTOR_H_
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Object.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Object.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Object.h	(revision 12168)
@@ -21,9 +21,4 @@
 		virtual int   Id()=0;
 		virtual int   MyRank()=0;
-		#ifdef _SERIAL_
-		virtual void  Marshall(char** pmarshalled_dataset)=0;
-		virtual int   MarshallSize()=0;
-		virtual void  Demarshall(char** pmarshalled_dataset)=0;
-		#endif
 		virtual int   ObjectEnum()=0;
 		virtual Object* copy()=0;
Index: /issm/branches/trunk-jpl-damage/src/c/objects/OptArgs.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/OptArgs.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/OptArgs.h	(revision 12168)
@@ -6,19 +6,8 @@
 #define _OPTARGS_H_
 
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-
-#include "mex.h"
-struct OptArgs{
-	char* function_name;
-	mxArray* femmodel;
-};
-
-#else
-
 class Model;
 struct OptArgs{
 	FemModel* femmodel;
 };
-#endif
 
 #endif
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Options/Option.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Options/Option.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Options/Option.h	(revision 12168)
@@ -33,9 +33,4 @@
 		int   Id(){_error_("Not implemented yet");};
 		int   MyRank(){_error_("Not implemented yet");};
-		#ifdef _SERIAL_
-		void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet");};
-		int   MarshallSize(){_error_("Not implemented yet");};
-		void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet");};
-		#endif
 		int   ObjectEnum(){return OptionEnum;};
 		Object* copy(){_error_("Not implemented yet");};
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Options/OptionCell.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Options/OptionCell.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Options/OptionCell.h	(revision 12168)
@@ -30,9 +30,4 @@
 		int   Id(){_error_("Not implemented yet");};
 		int   MyRank(){_error_("Not implemented yet");};
-		#ifdef _SERIAL_
-		void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet");};
-		int   MarshallSize(){_error_("Not implemented yet");};
-		void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet");};
-		#endif
 		int   ObjectEnum(){return OptionCellEnum;};
 		Object* copy(){_error_("Not implemented yet");};
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Options/OptionChar.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Options/OptionChar.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Options/OptionChar.h	(revision 12168)
@@ -30,9 +30,4 @@
 		int   Id(){_error_("Not implemented yet");};
 		int   MyRank(){_error_("Not implemented yet");};
-		#ifdef _SERIAL_
-		void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet");};
-		int   MarshallSize(){_error_("Not implemented yet");};
-		void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet");};
-		#endif
 		int   ObjectEnum(){return OptionCharEnum;};
 		Object* copy(){_error_("Not implemented yet");};
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Options/OptionDouble.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Options/OptionDouble.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Options/OptionDouble.h	(revision 12168)
@@ -30,9 +30,4 @@
 		int   Id(){_error_("Not implemented yet");};
 		int   MyRank(){_error_("Not implemented yet");};
-		#ifdef _SERIAL_
-		void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet");};
-		int   MarshallSize(){_error_("Not implemented yet");};
-		void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet");};
-		#endif
 		int   ObjectEnum(){return OptionDoubleEnum;};
 		Object* copy(){_error_("Not implemented yet");};
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Options/OptionLogical.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Options/OptionLogical.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Options/OptionLogical.h	(revision 12168)
@@ -30,9 +30,4 @@
 		int   Id(){_error_("Not implemented yet");};
 		int   MyRank(){_error_("Not implemented yet");};
-		#ifdef _SERIAL_
-		void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet");};
-		int   MarshallSize(){_error_("Not implemented yet");};
-		void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet");};
-		#endif
 		int   ObjectEnum(){return OptionLogicalEnum;};
 		Object* copy(){_error_("Not implemented yet");};
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Options/OptionStruct.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Options/OptionStruct.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Options/OptionStruct.h	(revision 12168)
@@ -30,9 +30,4 @@
 		int   Id(){_error_("Not implemented yet");};
 		int   MyRank(){_error_("Not implemented yet");};
-		#ifdef _SERIAL_
-		void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet");};
-		int   MarshallSize(){_error_("Not implemented yet");};
-		void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet");};
-		#endif
 		int   ObjectEnum(){return OptionStructEnum;};
 		Object* copy(){_error_("Not implemented yet");};
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Params/BoolParam.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Params/BoolParam.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Params/BoolParam.cpp	(revision 12168)
@@ -62,55 +62,4 @@
 }
 /*}}}*/
-#ifdef _SERIAL_
-/*FUNCTION BoolParam::Marshall{{{1*/
-void  BoolParam::Marshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   enum_value=0;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*get enum value of BoolParam: */
-	enum_value=BoolParamEnum;
-	
-	/*marshall enum: */
-	memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);
-	
-	/*marshall BoolParam data: */
-	memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-	memcpy(marshalled_dataset,&value,sizeof(value));marshalled_dataset+=sizeof(value);
-
-	*pmarshalled_dataset=marshalled_dataset;
-}
-/*}}}*/
-/*FUNCTION BoolParam::MarshallSize{{{1*/
-int   BoolParam::MarshallSize(){
-	
-	return sizeof(value)+
-		+sizeof(enum_type)+
-		+sizeof(int); //sizeof(int) for enum value
-}
-/*}}}*/
-/*FUNCTION BoolParam::Demarshall{{{1*/
-void  BoolParam::Demarshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   i;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*this time, no need to get enum type, the pointer directly points to the beginning of the 
-	 *object data (thanks to DataSet::Demarshall):*/
-	memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-	memcpy(&value,marshalled_dataset,sizeof(value));marshalled_dataset+=sizeof(value);
-
-	/*return: */
-	*pmarshalled_dataset=marshalled_dataset;
-	return;
-}
-/*}}}*/
-#endif
 /*FUNCTION BoolParam::ObjectEnum{{{1*/
 int BoolParam::ObjectEnum(void){
@@ -134,13 +83,4 @@
 }
 /*}}}*/
-/*FUNCTION BoolParam::SetMatlabField{{{1*/
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-void  BoolParam::SetMatlabField(mxArray* dataref){
-	char* name=NULL;
-	this->GetParameterName(&name);
-	mxSetField( dataref, 0, name,mxCreateDoubleScalar((double)value));
-}
-#endif
-/*}}}*/
 /*FUNCTION BoolParam::UnitConversion{{{1*/
 void  BoolParam::UnitConversion(int direction_enum){
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Params/BoolParam.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Params/BoolParam.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Params/BoolParam.h	(revision 12168)
@@ -13,8 +13,4 @@
 #else
 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
-#endif
-
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-#include <mex.h>
 #endif
 
@@ -41,9 +37,4 @@
 		int   Id(); 
 		int   MyRank();
-		#ifdef _SERIAL_
-		void  Marshall(char** pmarshalled_dataset);
-		int   MarshallSize();
-		void  Demarshall(char** pmarshalled_dataset);
-		#endif
 		int   ObjectEnum();
 		Object* copy();
@@ -81,7 +72,4 @@
 		
 		void GetParameterName(char**pname);
-		#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-		void  SetMatlabField(mxArray* dataref);
-		#endif
 		/*}}}*/
 };
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Params/DoubleMatArrayParam.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Params/DoubleMatArrayParam.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Params/DoubleMatArrayParam.cpp	(revision 12168)
@@ -127,111 +127,4 @@
 }
 /*}}}*/
-#ifdef _SERIAL_
-/*FUNCTION DoubleMatArrayParam::Marshall{{{1*/
-void  DoubleMatArrayParam::Marshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   enum_value=0;
-	int   i;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*get enum value of DoubleMatArrayParam: */
-	enum_value=DoubleMatArrayParamEnum;
-	
-	/*marshall enum: */
-	memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);
-	
-	/*marshall DoubleMatArrayParam data: */
-	memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-	memcpy(marshalled_dataset,&M,sizeof(M));marshalled_dataset+=sizeof(M);
-	if(M){
-		memcpy(marshalled_dataset,mdim_array,M*sizeof(int));marshalled_dataset+=M*sizeof(int);
-		memcpy(marshalled_dataset,ndim_array,M*sizeof(int));marshalled_dataset+=M*sizeof(int);
-		for(i=0;i<M;i++){
-			double* matrix=this->array[i];
-			int     m=this->mdim_array[i];
-			int     n=this->ndim_array[i];
-			memcpy(marshalled_dataset,&m,sizeof(m));marshalled_dataset+=sizeof(m);
-			memcpy(marshalled_dataset,&n,sizeof(n));marshalled_dataset+=sizeof(n);
-			if(m*n)memcpy(marshalled_dataset,matrix,m*n*sizeof(double));marshalled_dataset+=m*n*sizeof(double);
-		}
-	}
-	
-	*pmarshalled_dataset=marshalled_dataset;
-}
-/*}}}*/
-/*FUNCTION DoubleMatArrayParam::MarshallSize{{{1*/
-int   DoubleMatArrayParam::MarshallSize(){
-
-	int size=0;
-	int i;
-
-	size+=sizeof(enum_type)+
-		sizeof(M)+
-		M*sizeof(int)+
-		M*sizeof(int);
-
-	for(i=0;i<M;i++){
-		int     m=this->mdim_array[i];
-		int     n=this->ndim_array[i];
-		size+=sizeof(m)+sizeof(n)+m*n*sizeof(double);
-	}
-	size+=sizeof(int); //sizeof(int) for enum value
-
-	return  size;
-}
-/*}}}*/
-/*FUNCTION DoubleMatArrayParam::Demarshall{{{1*/
-void  DoubleMatArrayParam::Demarshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   i;
-	double* matrix=NULL;
-	int     m,n;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*this time, no need to get enum value, the pointer directly points to the beginning of the 
-	 *object data (thanks to DataSet::Demarshall):*/
-	
-	/*data: */
-	memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-	
-	memcpy(&M,marshalled_dataset,sizeof(M));marshalled_dataset+=sizeof(M);
-	if(M){
-		this->mdim_array=(int*)xmalloc(M*sizeof(int));
-		this->ndim_array=(int*)xmalloc(M*sizeof(int));
-		memcpy(this->mdim_array,marshalled_dataset,M*sizeof(int));marshalled_dataset+=M*sizeof(int);
-		memcpy(this->ndim_array,marshalled_dataset,M*sizeof(int));marshalled_dataset+=M*sizeof(int);
-
-		this->array=(double**)xmalloc(M*sizeof(double*));
-		for(i=0;i<M;i++){
-			memcpy(&m,marshalled_dataset,sizeof(m));marshalled_dataset+=sizeof(m);
-			memcpy(&n,marshalled_dataset,sizeof(n));marshalled_dataset+=sizeof(n);
-			if(m*n){
-				matrix=(double*)xmalloc(m*n*sizeof(double));
-				memcpy(matrix,marshalled_dataset,m*n*sizeof(double));marshalled_dataset+=m*n*sizeof(double);
-			}
-			else{
-				matrix=NULL;
-			}
-			this->array[i]=matrix;
-		}
-	}
-	else{
-		this->array=NULL;
-		this->mdim_array=NULL;
-		this->ndim_array=NULL;
-	}
-
-	/*return: */
-	*pmarshalled_dataset=marshalled_dataset;
-	return;
-}
-/*}}}*/
-#endif
 /*FUNCTION DoubleMatArrayParam::ObjectEnum{{{1*/
 int DoubleMatArrayParam::ObjectEnum(void){
@@ -307,44 +200,4 @@
 	EnumToStringx(pname,this->enum_type);
 }
-/*}}}*/
-/*FUNCTION StringArrayParam::SetMatlabField{{{1*/
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-void  DoubleMatArrayParam::SetMatlabField(mxArray* dataref){
-	
-	int      i,m,n;
-	double*  matrix=NULL;
-	double*  outmatrix=NULL;
-	char*    name=NULL;
-	mwSize   dims[2]={0};
-	mxArray* pfield=NULL;
-	mxArray* pfield2=NULL;
-	mxArray* pfield3=NULL;
-	
-	this->GetParameterName(&name);
-	dims[0]=this->M;
-	dims[1]=1;
-	pfield=mxCreateCellArray(2,dims);
-
-	for(i=0;i<this->M;i++){
-		matrix=this->array[i];
-		m=this->mdim_array[i];
-		n=this->ndim_array[i];
-		outmatrix=(double*)xmalloc(m*n*sizeof(double));
-		memcpy(outmatrix,matrix,m*n*sizeof(double));
-	
-		pfield2=mxCreateDoubleMatrix(0,0,mxREAL);
-		mxSetM(pfield2,n);
-		mxSetN(pfield2,m);
-		mxSetPr(pfield2,outmatrix);
-
-		//transpose the outmatrix, written directly to matlab! from C to matlab.
-		mexCallMATLAB(1,&pfield3, 1, &pfield2, "transpose");
-	
-		mxSetCell(pfield,i,pfield3);
-	}
-	
-	mxSetField( dataref, 0, name,pfield);
-}
-#endif
 /*}}}*/
 /*FUNCTION DoubleMatArrayParam::SetValue(double** array, int M, int* mdim_array, int* ndim_array){{{1*/
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Params/DoubleMatArrayParam.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Params/DoubleMatArrayParam.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Params/DoubleMatArrayParam.h	(revision 12168)
@@ -13,8 +13,4 @@
 #else
 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
-#endif
-
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-#include <mex.h>
 #endif
 
@@ -44,9 +40,4 @@
 		int   Id(); 
 		int   MyRank();
-		#ifdef _SERIAL_
-		void  Marshall(char** pmarshalled_dataset);
-		int   MarshallSize();
-		void  Demarshall(char** pmarshalled_dataset);
-		#endif
 		int   ObjectEnum();
 		Object* copy();
@@ -84,7 +75,4 @@
 
 		void GetParameterName(char**pname);
-		#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-		void  SetMatlabField(mxArray* dataref);
-		#endif
 
 		/*}}}*/
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Params/DoubleMatParam.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Params/DoubleMatParam.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Params/DoubleMatParam.cpp	(revision 12168)
@@ -78,64 +78,4 @@
 }
 /*}}}*/
-#ifdef _SERIAL_
-/*FUNCTION DoubleMatParam::Marshall{{{1*/
-void  DoubleMatParam::Marshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   enum_value=0;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*get enum value of DoubleMatParam: */
-	enum_value=DoubleMatParamEnum;
-	
-	/*marshall enum: */
-	memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);
-	
-	/*marshall DoubleMatParam data: */
-	memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-	memcpy(marshalled_dataset,&M,sizeof(M));marshalled_dataset+=sizeof(M);
-	memcpy(marshalled_dataset,&N,sizeof(N));marshalled_dataset+=sizeof(N);
-	memcpy(marshalled_dataset,value,M*N*sizeof(double));marshalled_dataset+=M*N*sizeof(double);
-
-	*pmarshalled_dataset=marshalled_dataset;
-}
-/*}}}*/
-/*FUNCTION DoubleMatParam::MarshallSize{{{1*/
-int   DoubleMatParam::MarshallSize(){
-	
-	return sizeof(M)
-		+sizeof(N)
-		+M*N*sizeof(double)
-		+sizeof(enum_type)+
-		+sizeof(int); //sizeof(int) for enum value
-}
-/*}}}*/
-/*FUNCTION DoubleMatParam::Demarshall{{{1*/
-void  DoubleMatParam::Demarshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   i;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*this time, no need to get enum type, the pointer directly points to the beginning of the 
-	 *object data (thanks to DataSet::Demarshall):*/
-	memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-	
-	/*data: */
-	memcpy(&M,marshalled_dataset,sizeof(M));marshalled_dataset+=sizeof(M);
-	memcpy(&N,marshalled_dataset,sizeof(N));marshalled_dataset+=sizeof(N);
-	value=(double*)xmalloc(M*N*sizeof(double));
-	memcpy(value,marshalled_dataset,M*N*sizeof(double));marshalled_dataset+=M*N*sizeof(double);
-
-	/*return: */
-	*pmarshalled_dataset=marshalled_dataset;
-	return;
-}
-/*}}}*/
-#endif
 /*FUNCTION DoubleMatParam::ObjectEnum{{{1*/
 int DoubleMatParam::ObjectEnum(void){
@@ -169,18 +109,5 @@
 /*FUNCTION DoubleMatParam::GetParameterValue(int** pintarray,int* pM,int* pN){{{1*/
 void  DoubleMatParam::GetParameterValue(int** pintarray,int* pM,int* pN){
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-	int* output=NULL;
-	int  i;
-
-	output=(int*)xmalloc((int)(M*N*sizeof(int)));
-	for(i=0;i<M*N;i++) output[i]=(int)value[i];
-
-	/*Assign output pointers:*/
-	if(pM) *pM=M;
-	if(pN) *pN=N;
-	*pintarray=output;
-#else
 	_error_("DoubleMat of enum %i (%s) cannot return an array of int",enum_type,EnumToStringx(enum_type));
-#endif
 }
 /*}}}*/
@@ -189,27 +116,4 @@
 	EnumToStringx(pname,this->enum_type);
 }
-/*}}}*/
-/*FUNCTION DoubleMatParam::SetMatlabField{{{1*/
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-void  DoubleMatParam::SetMatlabField(mxArray* dataref){
-
-	mxArray* pfield=NULL;
-	mxArray* pfield2=NULL;
-	double* doublemat=NULL;
-	char* name=NULL;
-	
-	this->GetParameterName(&name);
-	this->GetParameterValue(&doublemat,NULL,NULL);
-				
-	pfield=mxCreateDoubleMatrix(0,0,mxREAL);
-	mxSetM(pfield,N);
-	mxSetN(pfield,M);
-	mxSetPr(pfield,doublemat);
-	
-	//transpose the matrix, written directly to matlab! from C to matlab.
-	mexCallMATLAB(1,&pfield2, 1, &pfield, "transpose");
-	mxSetField( dataref, 0, name,pfield2);
-}
-#endif
 /*}}}*/
 /*FUNCTION DoubleMatParam::SetValue{{{1*/
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Params/DoubleMatParam.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Params/DoubleMatParam.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Params/DoubleMatParam.h	(revision 12168)
@@ -13,8 +13,4 @@
 #else
 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
-#endif
-
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-#include <mex.h>
 #endif
 
@@ -43,9 +39,4 @@
 		int   Id(); 
 		int   MyRank();
-		#ifdef _SERIAL_
-		void  Marshall(char** pmarshalled_dataset);
-		int   MarshallSize();
-		void  Demarshall(char** pmarshalled_dataset);
-		#endif
 		int   ObjectEnum();
 		Object* copy();
@@ -84,7 +75,4 @@
 
 		void GetParameterName(char**pname);
-		#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-		void  SetMatlabField(mxArray* dataref);
-		#endif
 
 		/*}}}*/
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Params/DoubleParam.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Params/DoubleParam.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Params/DoubleParam.cpp	(revision 12168)
@@ -59,55 +59,4 @@
 }
 /*}}}*/
-#ifdef _SERIAL_
-/*FUNCTION DoubleParam::Marshall{{{1*/
-void  DoubleParam::Marshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   enum_value=0;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*get enum value of DoubleParam: */
-	enum_value=DoubleParamEnum;
-	
-	/*marshall enum: */
-	memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);
-	
-	/*marshall DoubleParam data: */
-	memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-	memcpy(marshalled_dataset,&value,sizeof(value));marshalled_dataset+=sizeof(value);
-
-	*pmarshalled_dataset=marshalled_dataset;
-}
-/*}}}*/
-/*FUNCTION DoubleParam::MarshallSize{{{1*/
-int   DoubleParam::MarshallSize(){
-	
-	return sizeof(value)+
-		+sizeof(enum_type)+
-		+sizeof(int); //sizeof(int) for enum value
-}
-/*}}}*/
-/*FUNCTION DoubleParam::Demarshall{{{1*/
-void  DoubleParam::Demarshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   i;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*this time, no need to get enum type, the pointer directly points to the beginning of the 
-	 *object data (thanks to DataSet::Demarshall):*/
-	memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-	memcpy(&value,marshalled_dataset,sizeof(value));marshalled_dataset+=sizeof(value);
-
-	/*return: */
-	*pmarshalled_dataset=marshalled_dataset;
-	return;
-}
-/*}}}*/
-#endif
 /*FUNCTION DoubleParam::ObjectEnum{{{1*/
 int DoubleParam::ObjectEnum(void){
@@ -133,99 +82,31 @@
 /*FUNCTION DoubleParam::GetParameterValue(int* pinteger){{{1*/
 void DoubleParam::GetParameterValue(int* pinteger){
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-	*pinteger=(int)value;
-#else
 	_error_("Double param of enum %i (%s) cannot return an integer",enum_type,EnumToStringx(enum_type));
-#endif
 }
 /*}}}*/
 /*FUNCTION DoubleParam::GetParameterValue(bool* pbool){{{1*/
 void DoubleParam::GetParameterValue(bool* pbool){
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-
-	/*If debugging mode, cheeck that the double is 0 or 1*/
-	_assert_(value==0 || value==1);
-	*pbool=(bool)value;
-
-#else
 	_error_("Double param of enum %i (%s) cannot return an bool",enum_type,EnumToStringx(enum_type));
-#endif
 }
 /*}}}*/
 /*FUNCTION DoubleParam::GetParameterValue(int** pintarray,int* pM){{{1*/
 void DoubleParam::GetParameterValue(int** pintarray,int* pM){
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-	int* output=NULL;
-
-	output=(int*)xmalloc(1*sizeof(int));
-	*output=(int)value;
-
-	/*Assign output pointers:*/
-	if(pM) *pM=1;
-	*pintarray=output;
-#else
 	_error_("Double param of enum %i (%s) cannot return an array of integers",enum_type,EnumToStringx(enum_type));
-#endif
 }
 /*}}}*/
 /*FUNCTION DoubleParam::GetParameterValue(int** pintarray,int* pM,int* pN){{{1*/
 void DoubleParam::GetParameterValue(int** pintarray,int* pM,int* pN){
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-	int* output=NULL;
-
-	output=(int*)xmalloc(1*sizeof(int));
-	*output=(int)value;
-
-	/*Assign output pointers:*/
-	if(pM) *pM=1;
-	if(pN) *pN=1;
-	*pintarray=output;
-#else
 	_error_("Double param of enum %i (%s) cannot return an array of integers",enum_type,EnumToStringx(enum_type));
-#endif
 }
 /*}}}*/
 /*FUNCTION DoubleParam::GetParameterValue(double** pdoublearray,int* pM){{{1*/
 void DoubleParam::GetParameterValue(double** pdoublearray,int* pM){
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-	double* output=NULL;
-
-	output=(double*)xmalloc(1*sizeof(double));
-	*output=(double)value;
-
-	/*Assign output podoubleers:*/
-	if(pM) *pM=1;
-	*pdoublearray=output;
-#else
 	_error_("Double param of enum %i (%s) cannot return an array of double",enum_type,EnumToStringx(enum_type));
-#endif
 }
 /*}}}*/
 /*FUNCTION DoubleParam::GetParameterValue(double** pdoublearray,int* pM,int* pN){{{1*/
 void DoubleParam::GetParameterValue(double** pdoublearray,int* pM,int* pN){
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-	double* output=NULL;
-
-	output=(double*)xmalloc(1*sizeof(double));
-	*output=(double)value;
-
-	/*Assign output podoubleers:*/
-	if(pM) *pM=1;
-	if(pN) *pN=1;
-	*pdoublearray=output;
-#else
 	_error_("Double param of enum %i (%s) cannot return an array of double",enum_type,EnumToStringx(enum_type));
-#endif
 }
-/*}}}*/
-/*FUNCTION DoubleParam::SetMatlabField{{{1*/
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-void  DoubleParam::SetMatlabField(mxArray* dataref){
-
-	char* name=NULL;
-	this->GetParameterName(&name);
-	mxSetField( dataref, 0, name,mxCreateDoubleScalar(value));
-}
-#endif
 /*}}}*/
 /*FUNCTION DoubleParam::UnitConversion{{{1*/
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Params/DoubleParam.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Params/DoubleParam.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Params/DoubleParam.h	(revision 12168)
@@ -13,8 +13,4 @@
 #else
 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
-#endif
-
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-#include <mex.h>
 #endif
 
@@ -42,9 +38,4 @@
 		int   Id(); 
 		int   MyRank();
-		#ifdef _SERIAL_
-		void  Marshall(char** pmarshalled_dataset);
-		int   MarshallSize();
-		void  Demarshall(char** pmarshalled_dataset);
-		#endif
 		int   ObjectEnum();
 		Object* copy();
@@ -82,7 +73,4 @@
 
 		void GetParameterName(char**pname);
-		#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-		void  SetMatlabField(mxArray* dataref);
-		#endif
 
 		/*}}}*/
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Params/DoubleTransientMatParam.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Params/DoubleTransientMatParam.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Params/DoubleTransientMatParam.h	(revision 12168)
@@ -13,8 +13,4 @@
 #else
 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
-#endif
-
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-#include <mex.h>
 #endif
 
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Params/DoubleVecParam.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Params/DoubleVecParam.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Params/DoubleVecParam.cpp	(revision 12168)
@@ -75,61 +75,4 @@
 }
 /*}}}*/
-#ifdef _SERIAL_
-/*FUNCTION DoubleVecParam::Marshall{{{1*/
-void  DoubleVecParam::Marshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   enum_value=0;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*get enum value of DoubleVecParam: */
-	enum_value=DoubleVecParamEnum;
-	
-	/*marshall enum: */
-	memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);
-	
-	/*marshall DoubleVecParam data: */
-	memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-	memcpy(marshalled_dataset,&M,sizeof(M));marshalled_dataset+=sizeof(M);
-	memcpy(marshalled_dataset,values,M*sizeof(double));marshalled_dataset+=M*sizeof(double);
-
-	*pmarshalled_dataset=marshalled_dataset;
-}
-/*}}}*/
-/*FUNCTION DoubleVecParam::MarshallSize{{{1*/
-int   DoubleVecParam::MarshallSize(){
-	
-	return sizeof(M)
-		+M*sizeof(double)
-		+sizeof(enum_type)+
-		+sizeof(int); //sizeof(int) for enum value
-}
-/*}}}*/
-/*FUNCTION DoubleVecParam::Demarshall{{{1*/
-void  DoubleVecParam::Demarshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   i;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*this time, no need to get enum type, the pointer directly points to the beginning of the 
-	 *object data (thanks to DataSet::Demarshall):*/
-	memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-	
-	/*data: */
-	memcpy(&M,marshalled_dataset,sizeof(M));marshalled_dataset+=sizeof(M);
-	values=(double*)xmalloc(M*sizeof(double));
-	memcpy(values,marshalled_dataset,M*sizeof(double));marshalled_dataset+=M*sizeof(double);
-
-	/*return: */
-	*pmarshalled_dataset=marshalled_dataset;
-	return;
-}
-/*}}}*/
-#endif
 /*FUNCTION DoubleVecParam::ObjectEnum{{{1*/
 int DoubleVecParam::ObjectEnum(void){
@@ -181,18 +124,5 @@
 /*FUNCTION DoubleVecParam::GetParameterValue(int** pintarray,int* pM){{{1*/
 void  DoubleVecParam::GetParameterValue(int** pintarray,int* pM){
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-	int* output=NULL;
-	int i;
-
-	/*Cast values into integers*/
-	output=(int*)xmalloc(M*sizeof(int));
-	for(i=0;i<M;i++) output[i]=(int)values[i];
-
-	/*Assign output pointers:*/
-	if(pM) *pM=M;
-	*pintarray=output;
-#else
 	_error_("DoubleVec param of enum %i (%s) cannot return an array of int",enum_type,EnumToStringx(enum_type));
-#endif
 }
 /*}}}*/
@@ -201,24 +131,4 @@
 	EnumToStringx(pname,this->enum_type);
 }
-/*}}}*/
-/*FUNCTION DoubleVecParam::SetMatlabField{{{1*/
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-void  DoubleVecParam::SetMatlabField(mxArray* dataref){
-
-	char* name=NULL;
-	double* doublevec=NULL;
-	mxArray* pfield=NULL;
-
-	this->GetParameterValue(&doublevec,NULL);
-	this->GetParameterName(&name);
-				
-	pfield=mxCreateDoubleMatrix(0,0,mxREAL);
-	mxSetM(pfield,M);
-	mxSetN(pfield,1);
-	mxSetPr(pfield,doublevec);
-	
-	mxSetField( dataref, 0, name, pfield);
-}
-#endif
 /*}}}*/
 /*FUNCTION DoubleVecParam::SetValue{{{1*/
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Params/DoubleVecParam.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Params/DoubleVecParam.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Params/DoubleVecParam.h	(revision 12168)
@@ -13,8 +13,4 @@
 #else
 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
-#endif
-
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-#include <mex.h>
 #endif
 
@@ -42,9 +38,4 @@
 		int   Id(); 
 		int   MyRank();
-		#ifdef _SERIAL_
-		void  Marshall(char** pmarshalled_dataset);
-		int   MarshallSize();
-		void  Demarshall(char** pmarshalled_dataset);
-		#endif
 		int   ObjectEnum();
 		Object* copy();
@@ -82,7 +73,4 @@
 		
 		void GetParameterName(char**pname);
-		#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-		void  SetMatlabField(mxArray* dataref);
-		#endif
 		/*}}}*/
 };
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Params/FileParam.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Params/FileParam.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Params/FileParam.cpp	(revision 12168)
@@ -62,22 +62,4 @@
 }
 /*}}}*/
-#ifdef _SERIAL_
-/*FUNCTION FileParam::Marshall{{{1*/
-void  FileParam::Marshall(char** pmarshalled_dataset){
-
-	_error_("FileParam is a pointer and cannot be marshalled");
-}
-/*}}}*/
-/*FUNCTION FileParam::MarshallSize{{{1*/
-int   FileParam::MarshallSize(){
-	_error_("FileParam is a pointer and cannot be marshalled");
-}
-/*}}}*/
-/*FUNCTION FileParam::Demarshall{{{1*/
-void  FileParam::Demarshall(char** pmarshalled_dataset){
-	_error_("FileParam is a pointer and cannot be marshalled");
-}
-/*}}}*/
-#endif
 /*FUNCTION FileParam::ObjectEnum{{{1*/
 int FileParam::ObjectEnum(void){
@@ -101,12 +83,4 @@
 }
 /*}}}*/
-/*FUNCTION FileParam::SetMatlabField{{{1*/
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-void  FileParam::SetMatlabField(mxArray* dataref){
-	
-	_error_("FileParam is a pointer and cannot be converted into a matlab object");
-}
-#endif
-/*}}}*/
 /*FUNCTION FileParam::UnitConversion{{{1*/
 void  FileParam::UnitConversion(int direction_enum){
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Params/FileParam.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Params/FileParam.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Params/FileParam.h	(revision 12168)
@@ -13,8 +13,4 @@
 #else
 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
-#endif
-
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-#include <mex.h>
 #endif
 
@@ -41,9 +37,4 @@
 		int   Id(); 
 		int   MyRank();
-		#ifdef _SERIAL_
-		void  Marshall(char** pmarshalled_dataset);
-		int   MarshallSize();
-		void  Demarshall(char** pmarshalled_dataset);
-		#endif
 		int   ObjectEnum();
 		Object* copy();
@@ -81,7 +72,4 @@
 
 		void GetParameterName(char**pname);
-		#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-		void  SetMatlabField(mxArray* dataref);
-		#endif
 
 		/*}}}*/
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Params/IntMatParam.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Params/IntMatParam.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Params/IntMatParam.cpp	(revision 12168)
@@ -78,64 +78,4 @@
 }
 /*}}}*/
-#ifdef _SERIAL_
-/*FUNCTION IntMatParam::Marshall{{{1*/
-void  IntMatParam::Marshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   enum_value=0;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*get enum value of IntMatParam: */
-	enum_value=IntMatParamEnum;
-	
-	/*marshall enum: */
-	memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);
-	
-	/*marshall IntMatParam data: */
-	memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-	memcpy(marshalled_dataset,&M,sizeof(M));marshalled_dataset+=sizeof(M);
-	memcpy(marshalled_dataset,&N,sizeof(N));marshalled_dataset+=sizeof(N);
-	memcpy(marshalled_dataset,value,M*N*sizeof(int));marshalled_dataset+=M*N*sizeof(int);
-
-	*pmarshalled_dataset=marshalled_dataset;
-}
-/*}}}*/
-/*FUNCTION IntMatParam::MarshallSize{{{1*/
-int   IntMatParam::MarshallSize(){
-	
-	return sizeof(M)
-		+sizeof(N)
-		+M*N*sizeof(int)
-		+sizeof(enum_type)+
-		+sizeof(int); //sizeof(int) for enum value
-}
-/*}}}*/
-/*FUNCTION IntMatParam::Demarshall{{{1*/
-void  IntMatParam::Demarshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   i;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*this time, no need to get enum type, the pointer directly points to the beginning of the 
-	 *object data (thanks to DataSet::Demarshall):*/
-	memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-	
-	/*data: */
-	memcpy(&M,marshalled_dataset,sizeof(M));marshalled_dataset+=sizeof(M);
-	memcpy(&N,marshalled_dataset,sizeof(N));marshalled_dataset+=sizeof(N);
-	value=(int*)xmalloc(M*N*sizeof(int));
-	memcpy(value,marshalled_dataset,M*N*sizeof(int));marshalled_dataset+=M*N*sizeof(int);
-
-	/*return: */
-	*pmarshalled_dataset=marshalled_dataset;
-	return;
-}
-/*}}}*/
-#endif
 /*FUNCTION IntMatParam::ObjectEnum{{{1*/
 int IntMatParam::ObjectEnum(void){
@@ -172,33 +112,4 @@
 }
 /*}}}*/
-/*FUNCTION IntMatParam::SetMatlabField{{{1*/
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-void  IntMatParam::SetMatlabField(mxArray* dataref){
-
-	char    *name        = NULL;
-	double  *doublearray = NULL;
-	int     *intarray    = NULL;
-	mxArray *pfield      = NULL;
-	mxArray *pfield2     = NULL;
-
-	this->GetParameterValue(&intarray,NULL,NULL);
-	this->GetParameterName(&name);
-
-	/*cast intarray into doublearray for Matlab*/
-	doublearray=(double*)xmalloc(M*N*sizeof(double));
-	for(int i=0;i<M*N;i++)doublearray[i]=(double)intarray[i];
-	xfree((void**)&intarray);
-
-	pfield=mxCreateDoubleMatrix(0,0,mxREAL);
-	mxSetM(pfield,M);
-	mxSetN(pfield,N);
-	mxSetPr(pfield,doublearray);
-
-	//transpose the matrix, written directly to matlab! from C to matlab.
-	mexCallMATLAB(1,&pfield2, 1, &pfield, "transpose");
-	mxSetField( dataref, 0, name,pfield2);
-}
-#endif
-/*}}}*/
 /*FUNCTION IntMatParam::SetValue{{{1*/
 void  IntMatParam::SetValue(int* intarray,int in_M,int in_N){
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Params/IntMatParam.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Params/IntMatParam.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Params/IntMatParam.h	(revision 12168)
@@ -13,8 +13,4 @@
 #else
 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
-#endif
-
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-#include <mex.h>
 #endif
 
@@ -43,9 +39,4 @@
 		int   Id(); 
 		int   MyRank();
-		#ifdef _SERIAL_
-		void  Marshall(char** pmarshalled_dataset);
-		int   MarshallSize();
-		void  Demarshall(char** pmarshalled_dataset);
-		#endif
 		int   ObjectEnum();
 		Object* copy();
@@ -83,7 +74,4 @@
 
 		void GetParameterName(char**pname);
-		#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-		void  SetMatlabField(mxArray* dataref);
-		#endif
 
 		/*}}}*/
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Params/IntParam.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Params/IntParam.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Params/IntParam.cpp	(revision 12168)
@@ -62,55 +62,4 @@
 }
 /*}}}*/
-#ifdef _SERIAL_
-/*FUNCTION IntParam::Marshall{{{1*/
-void  IntParam::Marshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   enum_value=0;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*get enum value of IntParam: */
-	enum_value=IntParamEnum;
-	
-	/*marshall enum: */
-	memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);
-	
-	/*marshall IntParam data: */
-	memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-	memcpy(marshalled_dataset,&value,sizeof(value));marshalled_dataset+=sizeof(value);
-
-	*pmarshalled_dataset=marshalled_dataset;
-}
-/*}}}*/
-/*FUNCTION IntParam::MarshallSize{{{1*/
-int   IntParam::MarshallSize(){
-	
-	return sizeof(value)+
-		+sizeof(enum_type)+
-		+sizeof(int); //sizeof(int) for enum value
-}
-/*}}}*/
-/*FUNCTION IntParam::Demarshall{{{1*/
-void  IntParam::Demarshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   i;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*this time, no need to get enum type, the pointer directly points to the beginning of the 
-	 *object data (thanks to DataSet::Demarshall):*/
-	memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-	memcpy(&value,marshalled_dataset,sizeof(value));marshalled_dataset+=sizeof(value);
-
-	/*return: */
-	*pmarshalled_dataset=marshalled_dataset;
-	return;
-}
-/*}}}*/
-#endif
 /*FUNCTION IntParam::ObjectEnum{{{1*/
 int IntParam::ObjectEnum(void){
@@ -134,14 +83,4 @@
 }
 /*}}}*/
-/*FUNCTION IntParam::SetMatlabField{{{1*/
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-void  IntParam::SetMatlabField(mxArray* dataref){
-	
-	char* name=NULL;
-	this->GetParameterName(&name);
-	mxSetField( dataref, 0, name,mxCreateDoubleScalar((double)value));
-}
-#endif
-/*}}}*/
 /*FUNCTION IntParam::UnitConversion{{{1*/
 void  IntParam::UnitConversion(int direction_enum){
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Params/IntParam.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Params/IntParam.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Params/IntParam.h	(revision 12168)
@@ -13,8 +13,4 @@
 #else
 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
-#endif
-
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-#include <mex.h>
 #endif
 
@@ -42,9 +38,4 @@
 		int   Id(); 
 		int   MyRank();
-		#ifdef _SERIAL_
-		void  Marshall(char** pmarshalled_dataset);
-		int   MarshallSize();
-		void  Demarshall(char** pmarshalled_dataset);
-		#endif
 		int   ObjectEnum();
 		Object* copy();
@@ -82,7 +73,4 @@
 
 		void GetParameterName(char**pname);
-		#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-		void  SetMatlabField(mxArray* dataref);
-		#endif
 
 		/*}}}*/
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Params/IntVecParam.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Params/IntVecParam.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Params/IntVecParam.cpp	(revision 12168)
@@ -91,63 +91,4 @@
 }
 /*}}}*/
-#ifdef _SERIAL_
-/*FUNCTION IntVecParam::Marshall{{{1*/
-void  IntVecParam::Marshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   enum_value=0;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*get enum value of IntVecParam: */
-	enum_value=IntVecParamEnum;
-	
-	/*marshall enum: */
-	memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);
-	
-	/*marshall IntVecParam data: */
-	memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-	memcpy(marshalled_dataset,&M,sizeof(M));marshalled_dataset+=sizeof(M);
-	if(M)memcpy(marshalled_dataset,values,M*sizeof(int));marshalled_dataset+=M*sizeof(int);
-
-	*pmarshalled_dataset=marshalled_dataset;
-}
-/*}}}*/
-/*FUNCTION IntVecParam::MarshallSize{{{1*/
-int   IntVecParam::MarshallSize(){
-	
-	return sizeof(M)+
-		+M*sizeof(int)
-		+sizeof(enum_type)+
-		+sizeof(int); //sizeof(int) for enum value
-}
-/*}}}*/
-/*FUNCTION IntVecParam::Demarshall{{{1*/
-void  IntVecParam::Demarshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   i;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*this time, no need to get enum type, the pointer directly points to the beginning of the 
-	 *object data (thanks to DataSet::Demarshall):*/
-	memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-	
-	/*data: */
-	memcpy(&M,marshalled_dataset,sizeof(M));marshalled_dataset+=sizeof(M);
-	if(M) {
-		values=(int*)xmalloc(M*sizeof(int));
-		memcpy(values,marshalled_dataset,M*sizeof(int));marshalled_dataset+=M*sizeof(int);
-	}
-
-	/*return: */
-	*pmarshalled_dataset=marshalled_dataset;
-	return;
-}
-/*}}}*/
-#endif
 /*FUNCTION IntVecParam::ObjectEnum{{{1*/
 int IntVecParam::ObjectEnum(void){
@@ -185,33 +126,4 @@
 }
 /*}}}*/
-/*FUNCTION IntVecParam::SetMatlabField{{{1*/
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-void  IntVecParam::SetMatlabField(mxArray* dataref){
-
-	char    *name      = NULL;
-	double  *doublevec = NULL;
-	int     *intvec    = NULL;
-	mxArray *pfield    = NULL;
-
-	this->GetParameterValue(&intvec,NULL);
-	this->GetParameterName(&name);
-
-	/*cast intvec into doublevec for Matlab*/
-	if(M){
-		doublevec=(double*)xmalloc(M*sizeof(double));
-		for(int i=0;i<M;i++)doublevec[i]=(double)intvec[i];
-	}
-	else doublevec=NULL;
-	xfree((void**)&intvec);
-				
-	pfield=mxCreateDoubleMatrix(0,0,mxREAL);
-	mxSetM(pfield,M);
-	mxSetN(pfield,1);
-	mxSetPr(pfield,doublevec);
-	
-	mxSetField(dataref, 0, name, pfield);
-}
-#endif
-/*}}}*/
 /*FUNCTION IntVecParam::SetValue{{{1*/
 void  IntVecParam::SetValue(int* intarray,int in_M){
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Params/IntVecParam.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Params/IntVecParam.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Params/IntVecParam.h	(revision 12168)
@@ -13,8 +13,4 @@
 #else
 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
-#endif
-
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-#include <mex.h>
 #endif
 
@@ -43,9 +39,4 @@
 		int   Id(); 
 		int   MyRank();
-		#ifdef _SERIAL_
-		void  Marshall(char** pmarshalled_dataset);
-		int   MarshallSize();
-		void  Demarshall(char** pmarshalled_dataset);
-		#endif
 		int   ObjectEnum();
 		Object* copy();
@@ -83,7 +74,4 @@
 		
 		void GetParameterName(char**pname);
-		#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-		void  SetMatlabField(mxArray* dataref);
-		#endif
 		/*}}}*/
 };
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Params/MatrixParam.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Params/MatrixParam.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Params/MatrixParam.cpp	(revision 12168)
@@ -70,93 +70,4 @@
 }
 /*}}}*/
-#ifdef _SERIAL_
-/*FUNCTION MatrixParam::Marshall{{{1*/
-void  MatrixParam::Marshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   enum_value=0;
-	int   M,N;
-	double* serial_mat=NULL;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*get enum value of MatrixParam: */
-	enum_value=MatrixParamEnum;
-	
-	/*marshall enum: */
-	memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);
-	
-	/*marshall MatrixParam data: */
-	memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-	if(value){
-		value->GetSize(&M,&N);
-		serial_mat=value->ToSerial();
-		memcpy(marshalled_dataset,&M,sizeof(M));marshalled_dataset+=sizeof(M);
-		memcpy(marshalled_dataset,&N,sizeof(N));marshalled_dataset+=sizeof(N);
-		memcpy(marshalled_dataset,serial_mat,M*N*sizeof(double));marshalled_dataset+=(M*N*sizeof(double));
-	}
-	else{
-		M=0;
-		N=0;
-		memcpy(marshalled_dataset,&M,sizeof(M));marshalled_dataset+=sizeof(M);
-		memcpy(marshalled_dataset,&N,sizeof(N));marshalled_dataset+=sizeof(N);
-	}
-	
-	/*Free ressources:*/
-	xfree((void**)&serial_mat);
-
-	/*return:*/
-	*pmarshalled_dataset=marshalled_dataset;
-}
-/*}}}*/
-/*FUNCTION MatrixParam::MarshallSize{{{1*/
-int   MatrixParam::MarshallSize(){
-
-	int M=0;
-	int N=0;
-	if(value)value->GetSize(&M,&N);
-			
-	return sizeof(M)+
-		sizeof(N)+
-		M*N*sizeof(double)+
-		+sizeof(enum_type)+
-		+sizeof(int); //sizeof(int) for enum value
-}
-/*}}}*/
-/*FUNCTION MatrixParam::Demarshall{{{1*/
-void  MatrixParam::Demarshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   M,N;
-	double* serial_mat=NULL;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*this time, no need to get enum type, the pointer directly points to the beginning of the 
-	 *object data (thanks to DataSet::Demarshall):*/
-	memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-	
-	/*data: */
-	memcpy(&M,marshalled_dataset,sizeof(M));marshalled_dataset+=sizeof(M);
-	memcpy(&N,marshalled_dataset,sizeof(N));marshalled_dataset+=sizeof(N);
-	if(M!=0 && N!=0){
-		serial_mat=(double*)xmalloc(M*N*sizeof(double));
-		memcpy(serial_mat,marshalled_dataset,M*N*sizeof(double));marshalled_dataset+=(M*N*sizeof(double));
-		value=new Matrix(serial_mat,M,N,.001);
-	}
-	else{
-		value=NULL;
-	}
-
-	/*Free ressources:*/
-	xfree((void**)&serial_mat);
-
-	/*return: */
-	*pmarshalled_dataset=marshalled_dataset;
-}
-/*}}}*/
-#endif
 /*FUNCTION MatrixParam::ObjectEnum{{{1*/
 int MatrixParam::ObjectEnum(void){
@@ -190,25 +101,4 @@
 }
 /*}}}*/
-/*FUNCTION MatrixParam::SetMatlabField{{{1*/
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-void  MatrixParam::SetMatlabField(mxArray* dataref){
-	
-	char* name=NULL;
-	int   M,N;
-	double* doublemat=NULL;
-	mxArray* pfield=NULL;
-
-	doublemat=value->ToSerial();
-	value->GetSize(&M,&N);
-	this->GetParameterName(&name);
-				
-	pfield=mxCreateDoubleMatrix(0,0,mxREAL);
-	mxSetM(pfield,M);
-	mxSetN(pfield,N);
-	mxSetPr(pfield,doublemat);
-	mxSetField( dataref, 0, name, pfield);
-}
-#endif
-/*}}}*/
 /*FUNCTION MatrixParam::SetValue{{{1*/
 void  MatrixParam::SetValue(Matrix* matrix){
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Params/MatrixParam.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Params/MatrixParam.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Params/MatrixParam.h	(revision 12168)
@@ -13,8 +13,4 @@
 #else
 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
-#endif
-
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-#include <mex.h>
 #endif
 
@@ -42,9 +38,4 @@
 		int   Id(); 
 		int   MyRank();
-		#ifdef _SERIAL_
-		void  Marshall(char** pmarshalled_dataset);
-		int   MarshallSize();
-		void  Demarshall(char** pmarshalled_dataset);
-		#endif
 		int   ObjectEnum();
 		Object* copy();
@@ -82,7 +73,4 @@
 
 		void GetParameterName(char**pname);
-		#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-		void  SetMatlabField(mxArray* dataref);
-		#endif
 
 		/*}}}*/
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Params/Param.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Params/Param.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Params/Param.h	(revision 12168)
@@ -14,8 +14,4 @@
 #else
 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
-#endif
-
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-#include <mex.h>
 #endif
 
@@ -60,7 +56,4 @@
 		virtual void  UnitConversion(int direction_enum)=0;
 		virtual void  GetParameterName(char**pname)=0;
-		#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-		virtual void  SetMatlabField(mxArray* dataref)=0;
-		#endif
 };
 #endif
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Params/StringArrayParam.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Params/StringArrayParam.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Params/StringArrayParam.cpp	(revision 12168)
@@ -92,96 +92,4 @@
 }
 /*}}}*/
-#ifdef _SERIAL_
-/*FUNCTION StringArrayParam::Marshall{{{1*/
-void  StringArrayParam::Marshall(char** pmarshalled_dataset){
-
-	int   i;
-	char* marshalled_dataset=NULL;
-	int   enum_value=0;
-	int   stringsize;
-	char* string=NULL;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*get enum value of StringArrayParam: */
-	enum_value=StringArrayParamEnum;
-	
-	/*marshall enum: */
-	memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);
-	
-	/*marshall data: */
-	memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-	memcpy(marshalled_dataset,&numstrings,sizeof(numstrings));marshalled_dataset+=sizeof(numstrings);
-	for(i=0;i<numstrings;i++){
-		string=this->value[i];
-		stringsize=strlen(string)+1;
-		
-		memcpy(marshalled_dataset,&stringsize,sizeof(stringsize));marshalled_dataset+=sizeof(stringsize);
-		memcpy(marshalled_dataset,string,stringsize*sizeof(char));marshalled_dataset+=stringsize*sizeof(char);
-	}
-
-	*pmarshalled_dataset=marshalled_dataset;
-}
-/*}}}*/
-/*FUNCTION StringArrayParam::MarshallSize{{{1*/
-int   StringArrayParam::MarshallSize(){
-
-	int i;
-	int marshallsize=0;
-	int stringsize;
-	char* string=NULL;
-
-	marshallsize+=sizeof(numstrings);
-
-	for(i=0;i<numstrings;i++){
-		string=this->value[i];
-		stringsize=strlen(string)+1;
-		marshallsize+=sizeof(stringsize);
-		marshallsize+=stringsize*sizeof(char);
-	}
-	
-	marshallsize+=sizeof(enum_type);
-	marshallsize+=sizeof(int); //sizeof(int) for enum value
-
-	return marshallsize;
-}
-/*}}}*/
-/*FUNCTION StringArrayParam::Demarshall{{{1*/
-void  StringArrayParam::Demarshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   i;
-	int   stringsize;
-	char* string=NULL;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*this time, no need to get enum type, the pointer directly points to the beginning of the 
-	 *object data (thanks to DataSet::Demarshall):*/
-	memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-
-	memcpy(&numstrings,marshalled_dataset,sizeof(int));marshalled_dataset+=sizeof(int);
-	if(numstrings){
-		this->value=(char**)xmalloc(numstrings*sizeof(char*));
-
-		for(i=0;i<numstrings;i++){
-			memcpy(&stringsize,marshalled_dataset,sizeof(int));marshalled_dataset+=sizeof(int);
-
-			string=(char*)xmalloc(stringsize*sizeof(char));
-			memcpy(string,marshalled_dataset,stringsize*sizeof(char));marshalled_dataset+=stringsize*sizeof(char);
-
-			this->value[i]=string;
-		}
-	}
-	else this->value=NULL;
-
-	/*return: */
-	*pmarshalled_dataset=marshalled_dataset;
-	return;
-}
-/*}}}*/
-#endif
 /*FUNCTION StringArrayParam::ObjectEnum{{{1*/
 int StringArrayParam::ObjectEnum(void){
@@ -236,26 +144,4 @@
 }
 /*}}}*/
-/*FUNCTION StringArrayParam::SetMatlabField{{{1*/
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-void  StringArrayParam::SetMatlabField(mxArray* dataref){
-	
-	int      i;
-	char*    name=NULL;
-	mwSize   dims[2]={0};
-	mxArray* pfield=NULL;
-	
-	this->GetParameterName(&name);
-
-	dims[0]=this->numstrings;
-	dims[1]=1;
-	pfield=mxCreateCellArray(2,dims);
-	for(i=0;i<this->numstrings;i++){
-		char* string=value[i];
-		mxSetCell(pfield,i,mxCreateString(string));
-	}
-	mxSetField( dataref, 0, name,pfield);
-}
-#endif
-/*}}}*/
 /*FUNCTION StringArrayParam::SetValue{{{1*/
 void  StringArrayParam::SetValue(char** stringarray,int M){
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Params/StringArrayParam.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Params/StringArrayParam.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Params/StringArrayParam.h	(revision 12168)
@@ -13,8 +13,4 @@
 #else
 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
-#endif
-
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-#include <mex.h>
 #endif
 
@@ -44,9 +40,4 @@
 		int   Id(); 
 		int   MyRank();
-		#ifdef _SERIAL_
-		void  Marshall(char** pmarshalled_dataset);
-		int   MarshallSize();
-		void  Demarshall(char** pmarshalled_dataset);
-		#endif
 		int   ObjectEnum();
 		Object* copy();
@@ -84,7 +75,4 @@
 
 		void GetParameterName(char**pname);
-		#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-		void  SetMatlabField(mxArray* dataref);
-		#endif
 		/*}}}*/
 };
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Params/StringParam.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Params/StringParam.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Params/StringParam.cpp	(revision 12168)
@@ -64,68 +64,4 @@
 }
 /*}}}*/
-#ifdef _SERIAL_
-/*FUNCTION StringParam::Marshall{{{1*/
-void  StringParam::Marshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   enum_value=0;
-	int   stringsize;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*get enum value of StringParam: */
-	enum_value=StringParamEnum;
-	
-	/*marshall enum: */
-	memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);
-
-	/*marshall data: */
-	memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-	stringsize=strlen(this->value)+1;
-	
-	memcpy(marshalled_dataset,&stringsize,sizeof(stringsize));marshalled_dataset+=sizeof(stringsize);
-	memcpy(marshalled_dataset,this->value,stringsize*sizeof(char));marshalled_dataset+=stringsize*sizeof(char);
-
-	*pmarshalled_dataset=marshalled_dataset;
-}
-/*}}}*/
-/*FUNCTION StringParam::MarshallSize{{{1*/
-int   StringParam::MarshallSize(){
-
-	int stringsize;
-	stringsize=strlen(this->value)+1;
-	
-	return sizeof(int)+
-		stringsize*sizeof(char)+
-		sizeof(enum_type)+
-		sizeof(int); //sizeof(int) for enum value
-}
-/*}}}*/
-/*FUNCTION StringParam::Demarshall{{{1*/
-void  StringParam::Demarshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   i;
-	int   stringsize;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*this time, no need to get enum type, the pointer directly points to the beginning of the 
-	 *object data (thanks to DataSet::Demarshall):*/
-	memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-
-	memcpy(&stringsize,marshalled_dataset,sizeof(int));marshalled_dataset+=sizeof(int);
-	
-	this->value=(char*)xmalloc(stringsize*sizeof(char));
-	memcpy(this->value,marshalled_dataset,stringsize*sizeof(char));marshalled_dataset+=stringsize*sizeof(char);
-
-	/*return: */
-	*pmarshalled_dataset=marshalled_dataset;
-	return;
-}
-/*}}}*/
-#endif
 /*FUNCTION StringParam::ObjectEnum{{{1*/
 int StringParam::ObjectEnum(void){
@@ -164,15 +100,4 @@
 }
 /*}}}*/
-/*FUNCTION StringParam::SetMatlabField{{{1*/
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-void  StringParam::SetMatlabField(mxArray* dataref){
-	
-	char* name=NULL;
-
-	this->GetParameterName(&name);
-	mxSetField( dataref, 0, name, mxCreateString(value));
-}
-#endif
-/*}}}*/
 /*FUNCTION StringParam::SetValue{{{1*/
 void  StringParam::SetValue(char* string){
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Params/StringParam.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Params/StringParam.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Params/StringParam.h	(revision 12168)
@@ -13,8 +13,4 @@
 #else
 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
-#endif
-
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-#include <mex.h>
 #endif
 
@@ -42,9 +38,4 @@
 		int   Id(); 
 		int   MyRank();
-		#ifdef _SERIAL_
-		void  Marshall(char** pmarshalled_dataset);
-		int   MarshallSize();
-		void  Demarshall(char** pmarshalled_dataset);
-		#endif
 		int   ObjectEnum();
 		Object* copy();
@@ -82,7 +73,4 @@
 
 		void GetParameterName(char**pname);
-		#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-		void  SetMatlabField(mxArray* dataref);
-		#endif
 
 		/*}}}*/
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Params/VectorParam.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Params/VectorParam.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Params/VectorParam.cpp	(revision 12168)
@@ -72,88 +72,4 @@
 }
 /*}}}*/
-#ifdef _SERIAL_
-/*FUNCTION VectorParam::Marshall{{{1*/
-void  VectorParam::Marshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   enum_value=0;
-	int   M;
-	double* serial_value=NULL;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*get enum value of VectorParam: */
-	enum_value=VectorParamEnum;
-	
-	/*marshall enum: */
-	memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);
-	
-	/*marshall VectorParam data: */
-	memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-	if(value){
-		value->GetSize(&M);
-		serial_value=value->ToMPISerial();
-		memcpy(marshalled_dataset,&M,sizeof(M));marshalled_dataset+=sizeof(M);
-		memcpy(marshalled_dataset,serial_value,M*sizeof(double));marshalled_dataset+=(M*sizeof(double));
-	}
-	else{
-		M=0;
-		memcpy(marshalled_dataset,&M,sizeof(M));marshalled_dataset+=sizeof(M);
-	}
-	/*Free ressources:*/
-	xfree((void**)&serial_value);
-
-	/*return:*/
-	*pmarshalled_dataset=marshalled_dataset;
-}
-/*}}}*/
-/*FUNCTION VectorParam::MarshallSize{{{1*/
-int   VectorParam::MarshallSize(){
-
-	int M=0;
-	if(value)value->GetSize(&M);
-
-	return sizeof(M)+M*sizeof(double)
-		+sizeof(enum_type)+
-		+sizeof(int); //sizeof(int) for enum value
-}
-/*}}}*/
-/*FUNCTION VectorParam::Demarshall{{{1*/
-void  VectorParam::Demarshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   i;
-	double* serial_vec=NULL;
-	int   M;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*this time, no need to get enum type, the pointer directly points to the beginning of the 
-	 *object data (thanks to DataSet::Demarshall):*/
-	memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-	
-	/*data: */
-	
-	memcpy(&M,marshalled_dataset,sizeof(M));marshalled_dataset+=sizeof(M);
-	if(M){
-		serial_vec=(double*)xmalloc(M*sizeof(double));
-		memcpy(serial_vec,marshalled_dataset,M*sizeof(double));marshalled_dataset+=(M*sizeof(double));
-
-		value=new Vector(serial_vec,M);
-	}
-	else{
-		value=NULL;
-	}
-
-	/*Free ressources:*/
-	xfree((void**)&serial_vec);
-
-	/*return: */
-	*pmarshalled_dataset=marshalled_dataset;
-}
-/*}}}*/
-#endif
 /*FUNCTION VectorParam::ObjectEnum{{{1*/
 int VectorParam::ObjectEnum(void){
@@ -188,26 +104,4 @@
 }
 /*}}}*/
-/*FUNCTION VectorParam::SetMatlabField{{{1*/
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-void  VectorParam::SetMatlabField(mxArray* dataref){
-
-	mxArray* pfield=NULL;
-	char* name=NULL;
-	double* doublevec=NULL;
-	int M;
-	
-	doublevec=value->ToMPISerial();
-	value->GetSize(&M);
-	this->GetParameterName(&name);
-	
-	pfield=mxCreateDoubleMatrix(0,0,mxREAL);
-	mxSetM(pfield,M);
-	mxSetN(pfield,1);
-	mxSetPr(pfield,doublevec);
-	
-	mxSetField( dataref, 0, name, pfield);
-}
-#endif
-/*}}}*/
 /*FUNCTION VectorParam::SetValue{{{1*/
 void  VectorParam::SetValue(Vector* vector){
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Params/VectorParam.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Params/VectorParam.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Params/VectorParam.h	(revision 12168)
@@ -13,8 +13,4 @@
 #else
 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
-#endif
-
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-#include <mex.h>
 #endif
 
@@ -42,9 +38,4 @@
 		int   Id(); 
 		int   MyRank();
-		#ifdef _SERIAL_
-		void  Marshall(char** pmarshalled_dataset);
-		int   MarshallSize();
-		void  Demarshall(char** pmarshalled_dataset);
-		#endif
 		int   ObjectEnum();
 		Object* copy();
@@ -82,7 +73,4 @@
 
 		void GetParameterName(char**pname);
-		#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-		void  SetMatlabField(mxArray* dataref);
-		#endif
 
 		/*}}}*/
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Patch.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Patch.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Patch.cpp	(revision 12168)
@@ -120,13 +120,15 @@
 	int         node_numrows;
 	double     *total_values  = NULL;
+	#ifdef _HAVE_MPI_
 	MPI_Status  status;
+	#endif
 
-	#ifdef _SERIAL_
-	return; //nothing to be done
-	#endif
-	
 	/*First, figure out total number of rows combining all the cpus: */
+	#ifdef _HAVE_MPI_
 	MPI_Reduce(&this->numrows,&total_numrows,1,MPI_INT,MPI_SUM,0,MPI_COMM_WORLD );
 	MPI_Bcast(&total_numrows,1,MPI_INT,0,MPI_COMM_WORLD);
+	#else
+	total_numrows=this->numrows;
+	#endif
 
 	/*return if patch empty*/
@@ -144,4 +146,5 @@
 
 	/*Now, ask other nodes to send their values: */
+	#ifdef _HAVE_MPI_
 	for (i=1;i<num_procs;i++){
 		if (my_rank==i){ 
@@ -155,4 +158,5 @@
 		}
 	}	
+	#endif
 
 	/*Now, node 0 has total_values, of size total_numrows*this->numcols. Update the fields in the patch, to reflect this new 
@@ -163,7 +167,9 @@
 		this->values=total_values;
 	}
+	#ifdef _HAVE_MPI_
 	else{
 		this->numrows=0;
 		xfree((void**)&this->values);
 	}
+	#endif
 }/*}}}*/
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Segment.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Segment.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Segment.cpp	(revision 12168)
@@ -71,22 +71,4 @@
 }
 /*}}}*/
-#ifdef _SERIAL_
-/*FUNCTION Segment::Marshall{{{1*/
-void  Segment::Marshall(char** pmarshalled_dataset){
-
-	_error_(" not supported yet!");
-}
-/*}}}*/
-/*FUNCTION Segment::MarshallSize{{{1*/
-int   Segment::MarshallSize(){
-	_error_(" not supported yet!");
-}
-/*}}}*/
-/*FUNCTION Segment::Demarshall{{{1*/
-void  Segment::Demarshall(char** pmarshalled_dataset){
-	_error_(" not supported yet!");
-}
-/*}}}*/
-#endif
 /*FUNCTION Segment::ObjectEnum{{{1*/
 int Segment::ObjectEnum(void){
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Segment.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Segment.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Segment.h	(revision 12168)
@@ -30,9 +30,4 @@
 		int   Id(); 
 		int   MyRank();
-		#ifdef _SERIAL_
-		void  Marshall(char** pmarshalled_dataset);
-		int   MarshallSize();
-		void  Demarshall(char** pmarshalled_dataset);
-		#endif
 		int   ObjectEnum();
 		Object* copy();
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Vertex.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Vertex.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Vertex.cpp	(revision 12168)
@@ -92,78 +92,4 @@
 }
 /*}}}*/
-#ifdef _SERIAL_
-/*FUNCTION Vertex::Marshall {{{1*/
-void  Vertex::Marshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   enum_type=0;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*get enum type of Vertex: */
-	enum_type=VertexEnum;
-
-	/*marshall enum: */
-	memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-
-	/*marshall Vertex data: */
-	memcpy(marshalled_dataset,&id,sizeof(id));marshalled_dataset+=sizeof(id);
-	memcpy(marshalled_dataset,&sid,sizeof(sid));marshalled_dataset+=sizeof(sid);
-	memcpy(marshalled_dataset,&x,sizeof(x));marshalled_dataset+=sizeof(x);
-	memcpy(marshalled_dataset,&y,sizeof(y));marshalled_dataset+=sizeof(y);
-	memcpy(marshalled_dataset,&z,sizeof(z));marshalled_dataset+=sizeof(z);
-	memcpy(marshalled_dataset,&sigma,sizeof(sigma));marshalled_dataset+=sizeof(sigma);
-	memcpy(marshalled_dataset,&connectivity,sizeof(connectivity));marshalled_dataset+=sizeof(connectivity);
-	memcpy(marshalled_dataset,&dof,sizeof(dof));marshalled_dataset+=sizeof(dof);
-	memcpy(marshalled_dataset,&clone,sizeof(clone));marshalled_dataset+=sizeof(clone);
-
-	*pmarshalled_dataset=marshalled_dataset;
-	return;
-}
-/*}}}*/
-/*FUNCTION Vertex::MarshallSize {{{1*/
-int   Vertex::MarshallSize(){
-	
-	return sizeof(id)+
-		sizeof(sid)+
-		sizeof(x)+
-		sizeof(y)+
-		sizeof(z)+
-		sizeof(sigma)+
-		sizeof(connectivity)+
-		sizeof(dof)+
-		sizeof(clone)+
-		+sizeof(int); //sizeof(int) for enum type
-}
-/*}}}*/
-/*FUNCTION Vertex::Demarshall {{{1*/
-void  Vertex::Demarshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   i;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*this time, no need to get enum type, the pointer directly points to the beginning of the 
-	 *object data (thanks to DataSet::Demarshall):*/
-
-	memcpy(&id,marshalled_dataset,sizeof(id));marshalled_dataset+=sizeof(id);
-	memcpy(&sid,marshalled_dataset,sizeof(sid));marshalled_dataset+=sizeof(sid);
-	memcpy(&x,marshalled_dataset,sizeof(x));marshalled_dataset+=sizeof(x);
-	memcpy(&y,marshalled_dataset,sizeof(y));marshalled_dataset+=sizeof(y);
-	memcpy(&z,marshalled_dataset,sizeof(z));marshalled_dataset+=sizeof(z);
-	memcpy(&sigma,marshalled_dataset,sizeof(sigma));marshalled_dataset+=sizeof(sigma);
-	memcpy(&connectivity,marshalled_dataset,sizeof(connectivity));marshalled_dataset+=sizeof(connectivity);
-	memcpy(&dof,marshalled_dataset,sizeof(dof));marshalled_dataset+=sizeof(dof);
-	memcpy(&clone,marshalled_dataset,sizeof(clone));marshalled_dataset+=sizeof(clone);
-
-	/*return: */
-	*pmarshalled_dataset=marshalled_dataset;
-	return;
-}
-/*}}}*/
-#endif
 /*FUNCTION Vertex::ObjectEnum{{{1*/
 int Vertex::ObjectEnum(void){
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Vertex.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Vertex.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Vertex.h	(revision 12168)
@@ -47,9 +47,4 @@
 		int   Id(); 
 		int   MyRank();
-		#ifdef _SERIAL_
-		void  Marshall(char** pmarshalled_dataset);
-		int   MarshallSize();
-		void  Demarshall(char** pmarshalled_dataset);
-		#endif
 		int   ObjectEnum();
 		Object* copy();
Index: /issm/branches/trunk-jpl-damage/src/c/python/include/python_macros.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/python/include/python_macros.h	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/c/python/include/python_macros.h	(revision 12168)
@@ -0,0 +1,82 @@
+/* \file python_macros.h
+ * \brief: macros used for the python bindings
+ */
+
+#ifndef _PYTHON_MACROS_H_
+#define _PYTHON_MACROS_H_
+
+/*Header {{{1*/
+
+#ifdef HAVE_CONFIG_H
+	#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+/*}}}*/
+
+#ifdef _HAVE_PYTHON_
+/* MODULEBOOT/MODULEEND {{{1*/
+
+/*The following macros hide the error exception handling in a matlab module. Just put 
+ * MODULEBOOT(); and MODULEEND(); at the beginning and end of a module, and c++ exceptions 
+ * will be trapped. Really nifty!*/
+
+#define MODULEBOOT(); ModuleBoot();  \
+	PyObject* output = PyTuple_New(NLHS); if (!output) return NULL;\
+			int nrhs = (int)PyTuple_Size(args);
+
+#define MODULEEND();  ModuleEnd(); \
+						 return output;
+//}}}
+#if _PYTHON_MAJOR_ >=3
+/* WRAPPER 3.2 {{{1*/
+#define WRAPPER(modulename,...)  \
+\
+static PyObject* modulename(PyObject* self,PyObject* args);\
+static PyMethodDef modulename##_funcs[] = {\
+	{#modulename, (PyCFunction)modulename, METH_VARARGS, ""},\
+	{NULL,NULL,0,NULL}\
+};\
+\
+static struct PyModuleDef modulename##module= {\
+	PyModuleDef_HEAD_INIT,\
+	#modulename,   /* name of module */\
+	NULL, /* module documentation, may be NULL */\
+	-1,       /* size of per-interpreter state of the module,\
+				 or -1 if the module keeps state in global variables. */\
+	modulename##_funcs\
+};\
+\
+PyMODINIT_FUNC PyInit_##modulename(void){\
+\
+	import_array();\
+	return PyModule_Create(&modulename##module);\
+}\
+\
+static PyObject* modulename(PyObject* self,PyObject* args)
+/*}}}*/
+#else
+/* WRAPPER 2.7 {{{1*/
+#define WRAPPER(modulename,...)  \
+\
+static PyObject* modulename(PyObject* self,PyObject* args);\
+static PyMethodDef modulename##_funcs[] = {\
+	{#modulename, (PyCFunction)modulename, METH_VARARGS, ""},\
+	{NULL,NULL,0,NULL}\
+};\
+\
+PyMODINIT_FUNC init##modulename(void){\
+\
+	import_array();\
+	(void) Py_InitModule(#modulename, modulename##_funcs);\
+}\
+\
+static PyObject* modulename(PyObject* self,PyObject* args)
+/*}}}*/
+#endif
+/* CHECKARGUMENTS {{{1*/
+#define CHECKARGUMENTS(NLHS,NRHS,functionpointer) CheckNumPythonArguments(args, NRHS,functionpointer)
+/*}}}*/
+#endif
+
+#endif
Index: /issm/branches/trunk-jpl-damage/src/c/python/io/CheckNumPythonArguments.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/python/io/CheckNumPythonArguments.cpp	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/c/python/io/CheckNumPythonArguments.cpp	(revision 12168)
@@ -0,0 +1,36 @@
+/*!\file CheckNumPythonArguments.cpp:
+ * \brief: check number of arguments and report an usage error message.
+ */
+
+#ifdef HAVE_CONFIG_H
+	#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+
+#define PY_ARRAY_UNIQUE_SYMBOL PythonIOSymbol
+#define NO_IMPORT
+
+#include "../../toolkits/toolkits.h"
+#include "../../shared/Exceptions/exceptions.h"
+#include "../../include/include.h"
+
+int CheckNumPythonArguments(PyObject* inputs,int NRHS, void (*function)( void )){
+
+	Py_ssize_t size=0;
+
+	/*figure out size of tuple in input: */
+	size=PyTuple_Size(inputs);
+	
+	/*check on requested size: */
+	if (size==0){
+		function();
+		_error_("usage: see above");
+	}
+	else if (size!=NRHS ) {
+		function(); 
+		_error_("usage error.");
+	}
+	return 1;
+}
Index: /issm/branches/trunk-jpl-damage/src/c/python/io/FetchPythonData.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/python/io/FetchPythonData.cpp	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/c/python/io/FetchPythonData.cpp	(revision 12168)
@@ -0,0 +1,137 @@
+/*\file FetchData.cpp:
+ * \brief: general I/O interface to fetch data in python
+ */
+
+#ifdef HAVE_CONFIG_H
+	#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+#define PY_ARRAY_UNIQUE_SYMBOL PythonIOSymbol
+#define NO_IMPORT
+
+#include "../../toolkits/toolkits.h"
+#include "../../include/include.h"
+#include "../../shared/shared.h"
+
+/*Primitive data types*/
+/*FUNCTION FetchData(double* pscalar,PyObject* py_float){{{1*/
+void FetchData(double* pscalar,PyObject* py_float){
+
+	double scalar;
+
+	/*return internal value: */
+	scalar=PyFloat_AsDouble(py_float);
+
+	/*output: */
+	*pscalar=scalar;
+}
+/*}}}*/
+/*FUNCTION FetchData(int* pinteger,PyObject* py_long){{{1*/
+void FetchData(int* pinteger, PyObject* py_long){
+
+	int integer;
+
+	/*return internal value: */
+	integer=(int)PyLong_AsLong(py_long);
+
+	/*output: */
+	*pinteger=integer;
+}
+/*}}}*/
+/*FUNCTION FetchData(bool* pboolean,PyObject* py_boolean){{{1*/
+void FetchData(bool* pboolean,PyObject* py_boolean){
+
+	bool boolean;
+	
+	/*check this is indeed a subtype of long type: */
+	if(!PyBool_Check(py_boolean))_error_("expecting a boolean in input!");
+
+	/*extract boolean: */
+	boolean=(bool)PyLong_AsLong(py_boolean);
+
+	/*simple copy: */
+	*pboolean=boolean;
+	
+}
+/*}}}*/
+/*FUNCTION FetchData(double** pmatrix,int* pM, int* pN, PyObject* py_matrix){{{1*/
+void FetchData(double** pmatrix,int* pM,int *pN,PyObject* py_matrix){
+
+	/*output: */
+	double* matrix=NULL;
+	int M,N;
+	int ndim;
+	npy_intp*  dims=NULL;
+
+	/*retrive dimensions: */
+	ndim=PyArray_NDIM((const PyArrayObject*)py_matrix);
+	if(ndim!=2)_error_("expecting an MxN matrix in input!");
+	dims=PyArray_DIMS((PyArrayObject*)py_matrix);
+	M=dims[0]; N=dims[1];
+	
+	/*retrieve internal value: */
+	matrix=(double*)PyArray_DATA((PyArrayObject*)py_matrix);
+
+	/*output: */
+	if(pM)*pM=M;
+	if(pN)*pN=N;
+	if(pmatrix)*pmatrix=matrix;
+}
+/*}}}*/
+/*FUNCTION FetchData(double** pvector,int* pM, PyObject* py_vector){{{1*/
+void FetchData(double** pvector,int* pM,PyObject* py_vector){
+
+	/*output: */
+	double* vector=NULL;
+	int M;
+	int ndim;
+	npy_intp*  dims=NULL;
+
+	/*retrive dimensions: */
+	ndim=PyArray_NDIM((const PyArrayObject*)py_vector);
+	if(ndim!=1)_error_("expecting an Mx1 vector in input!");
+	dims=PyArray_DIMS((PyArrayObject*)py_vector);
+	M=dims[0]; 
+	
+	/*retrieve internal value: */
+	vector=(double*)PyArray_DATA((PyArrayObject*)py_vector);
+
+	/*output: */
+	if(pM)*pM=M;
+	if(pvector)*pvector=vector;
+}
+/*}}}*/
+
+/*Python version dependent: */
+#if _PYTHON_MAJOR_ >= 3 
+/*FUNCTION FetchData(char** pstring,PyObject* py_unicode){{{1*/
+void FetchData(char** pstring,PyObject* py_unicode){
+
+	PyObject* py_bytes;
+	char* string=NULL;
+
+	
+	/*convert to bytes format: */
+	PyUnicode_FSConverter(py_unicode,&py_bytes);
+
+	/*convert from bytes to string: */
+	string=PyBytes_AS_STRING(py_bytes);
+	
+	*pstring=string;
+}
+/*}}}*/
+#else
+/*FUNCTION FetchData(char** pstring,PyObject* py_string){{{1*/
+void FetchData(char** pstring,PyObject* py_string){
+
+	char* string=NULL;
+
+	/*extract internal string: */
+	string=PyString_AsString(py_string);
+	
+	*pstring=string;
+}
+/*}}}*/
+#endif
Index: /issm/branches/trunk-jpl-damage/src/c/python/io/WritePythonData.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/python/io/WritePythonData.cpp	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/c/python/io/WritePythonData.cpp	(revision 12168)
@@ -0,0 +1,78 @@
+/* \file WriteData.c:
+ * \brief: general interface for writing data
+ */
+
+#ifdef HAVE_CONFIG_H
+	#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+#define PY_ARRAY_UNIQUE_SYMBOL PythonIOSymbol
+#define NO_IMPORT
+
+#include "../../toolkits/toolkits.h"
+#include "../../include/include.h"
+#include "../../modules/modules.h"
+#include "../../Container/Container.h"
+#include "../../shared/shared.h"
+#include "../../io/io.h"
+#include "../../EnumDefinitions/EnumDefinitions.h"
+
+
+/*FUNCTION WriteData(PyObject* py_tuple,int index,char* string){{{1*/
+void WriteData(PyObject* py_tuple, int index, char* string){
+	
+	PyTuple_SetItem(py_tuple, index, PyUnicode_FromString(string));
+
+}
+/*}}}*/
+/*FUNCTION WriteData(PyObject* tuple,int index,Matrix* matrix){{{1*/
+void WriteData(PyObject* tuple,int index,Matrix* matrix){
+	
+	int M,N;
+	double* buffer=NULL;
+	npy_intp dims[2]={0,0};
+	PyObject* array=NULL;
+	
+	buffer=matrix->ToSerial();
+	matrix->GetSize(&M,&N);
+	dims[0]=(npy_intp)M;
+	dims[1]=(npy_intp)N;
+	array=PyArray_SimpleNewFromData(2,dims,NPY_DOUBLE,buffer);
+	
+	PyTuple_SetItem(tuple, index, array);
+
+
+}
+/*FUNCTION WriteData(PyObject* py_tuple,int index,Vector* vector){{{1*/
+void WriteData(PyObject* tuple,int index,Vector* vector){
+	
+	int M;
+	double* buffer=NULL;
+	npy_intp dim=10;
+	PyObject* array=NULL;
+	
+	buffer=vector->ToMPISerial();
+	vector->GetSize(&M);
+	dim=(npy_intp)M;
+	array=PyArray_SimpleNewFromData(1,&dim,NPY_DOUBLE,buffer);
+	
+	PyTuple_SetItem(tuple, index, array);
+
+
+}
+/*}}}*/
+/*FUNCTION WriteData(PyObject* py_tuple,int index, double* matrix, int M, int N){{{1*/
+void WriteData(PyObject* tuple, int index, double* matrix, int M,int N){
+	
+	npy_intp dims[2]={0,0};
+	PyObject* array=NULL;
+	
+	dims[0]=(npy_intp)M;
+	dims[1]=(npy_intp)N;
+	array=PyArray_SimpleNewFromData(2,dims,NPY_DOUBLE,matrix);
+	
+	PyTuple_SetItem(tuple, index, array);
+
+}
Index: /issm/branches/trunk-jpl-damage/src/c/python/io/pythonio.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/python/io/pythonio.h	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/c/python/io/pythonio.h	(revision 12168)
@@ -0,0 +1,56 @@
+/*\file pythonio.h
+ *\brief: I/O for ISSM in python mode
+ */
+
+#ifndef _PYTHON_IO_H_
+#define _PYTHON_IO_H_
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif 
+
+
+#include "../../objects/objects.h"
+#include "../../Container/Container.h"
+#include "../../include/include.h"
+
+class DataSet;
+class Parameters;
+
+//void WriteData(PyObject* py_tuple,DataSet* dataset);
+//void WriteData(PyObject* py_tuple,int*    matrix, int M,int N);
+//void WriteData(PyObject* py_tuple,double* vector, int M);
+//void WriteData(PyObject* py_tuple,int integer);
+//void WriteData(PyObject* py_tuple,bool boolean);
+//void WriteData(PyObject* py_tuple,double scalar);
+//void WriteData(DataHandle* py_tuple,Parameters* parameters);
+void WriteData(PyObject* py_tuple, int index, double* matrix, int M,int N);
+void WriteData(PyObject* py_tuple, int index, char* string);
+void WriteData(PyObject* py_tuple, int index, Matrix* matrix);
+void WriteData(PyObject* py_tuple, int index, Vector* vector);
+
+
+//void FetchData(DataSet** pdataset,PyObject* py_ref);
+//void FetchData(double** pmatrix,int* pnumel,int* pndims,int** psize,PyObject* py_ref);
+//void FetchData(int** pmatrix,int* pM,int *pN,PyObject* py_ref);
+//void FetchData(bool** pmatrix,int* pM,int *pN,PyObject* py_ref);
+//void FetchData(bool** pmatrix,int* pnumel,int* pndims,int** psize,PyObject* py_ref);
+//void FetchData(Matrix** pmatrix,PyObject* py_ref);
+//void FetchData(int** pvector,int* pM,PyObject* py_ref);
+//void FetchData(float** pvector,int* pM,PyObject* py_ref);
+//void FetchData(bool** pvector,int* pM,PyObject* py_ref);
+//void FetchData(Vector** pvector,PyObject* py_ref);
+//void FetchData(char** pmatrix,int* pnumel,int* pndims,int** psize,PyObject* py_ref);
+//void FetchData(Parameters** pparameters, DataHandle py_ref);
+void FetchData(double** pvector,int* pM,PyObject* py_ref);
+void FetchData(double** pmatrix,int* pM,int *pN,PyObject* py_array);
+void FetchData(char** pstring,PyObject* py_unicode);
+void FetchData(double* pscalar,PyObject* py_float);
+void FetchData(int* pinteger,PyObject* py_long);
+void FetchData(bool* pbool,PyObject* py_boolean);
+
+int CheckNumPythonArguments(PyObject* inputs,int NRHS, void (*function)( void ));
+
+#endif	/* _IO_H_ */
Index: /issm/branches/trunk-jpl-damage/src/c/python/python-binding.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/python/python-binding.h	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/c/python/python-binding.h	(revision 12168)
@@ -0,0 +1,7 @@
+#ifndef _PYTHON_BINDING_H_
+#define _PYTHON_BINDING_H_
+
+#include "./io/pythonio.h"
+#include "./include/python_macros.h"
+
+#endif
Index: /issm/branches/trunk-jpl-damage/src/c/shared/Alloc/alloc.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/shared/Alloc/alloc.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/shared/Alloc/alloc.cpp	(revision 12168)
@@ -19,8 +19,4 @@
 #endif
 
-#if defined(_SERIAL_) && defined(_HAVE_MATLAB_)
-#include "mex.h"
-#endif
-
 #include <stdio.h>
 #include <stdlib.h>
@@ -37,11 +33,6 @@
 	if(!size)_error_(" attempting to 0 size allocation!");
 
-	#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-	/* Use the matlab api to do the allocation: */
-	memptr=mxMalloc(size);
-	#else
 	/* Use the c library to do the allocation: */
 	memptr=malloc(size);
-	#endif
 	if(!memptr) _error_("memory allocation failed!");
 
@@ -55,11 +46,6 @@
 	if(!size)_error_("attempting to 0 size allocation!");
 
-	#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-	/* Use the matlab api to do the allocation: */
-	memptr=mxCalloc(n,size);
-	#else
 	/* Use the c library to do the allocation: */
 	memptr=calloc(n,size);
-	#endif
 	if(!memptr) _error_("memory allocation failed!");
 
@@ -70,9 +56,5 @@
 
 	if (pv && *pv){
-		#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-			mxFree(*pv);
-		#else
-			free(*pv);
-		#endif
+		free(*pv);
 
 		*pv=NULL;
@@ -83,16 +65,8 @@
 	
 	if (pv && *pv){
-		#ifdef _PARALLEL_ 
 		/*There is no mxDelete in the Matlab API -> using delete trips up Matlab. So we 
 		 * don't actually free memory in Matlab, we let the memory manager do that. We only
 		 * free in parallel: */
 		delete *pv;
-		#else
-		/*Actually, still get rid of internal Petsc matrix. Quick fix until Matlab handles C++ 
-		 * correctly: */
-		#ifdef _HAVE_PETSC_
-			MatFree(&(*pv)->matrix);
-		#endif
-		#endif
 		*pv=NULL;
 	}
@@ -102,16 +76,8 @@
 
 	if (pv && *pv){
-		#ifdef _PARALLEL_ 
 		/*There is no mxDelete in the Matlab API -> using delete trips up Matlab. So we 
 		 * don't actually free memory in Matlab, we let the memory manager do that. We only
 		 * free in parallel: */
 		delete *pv;
-		#else
-		/*Actually, still get rid of internal Petsc vector. Quick fix until Matlab handles C++ 
-		 * correctly: */
-		#ifdef _HAVE_PETSC_
-			VecFree(&(*pv)->vector);
-		#endif
-		#endif
 		*pv=NULL;
 	}
@@ -124,10 +90,5 @@
 	
 	if(!size)_error_("attempting to realloc to zero");
-
-	#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-	value = (void*)mxRealloc(pv,size);
-	#else
 	value = (void*)realloc(pv,size);
-	#endif
 
 	if (value == NULL) {
Index: /issm/branches/trunk-jpl-damage/src/c/shared/Alloc/alloc_module.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/shared/Alloc/alloc_module.cpp	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/c/shared/Alloc/alloc_module.cpp	(revision 12168)
@@ -0,0 +1,41 @@
+/* \file alloc_module.h
+ */
+
+
+#ifdef HAVE_CONFIG_H
+	#include <config.h>
+#else
+#error "Cannot compile without HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include  "./alloc_module.h"
+#include "../Exceptions/exceptions.h"
+#include "../../include/include.h"
+#include "../../objects/objects.h"
+
+void xdelete_module(Matrix** pv){
+	
+	if (pv && *pv){
+		/*Actually, still get rid of internal Petsc matrix. Quick fix until Matlab handles C++ 
+		 * correctly: */
+		#ifdef _HAVE_PETSC_
+			MatFree(&(*pv)->matrix);
+		#endif
+		*pv=NULL;
+	}
+}
+
+void xdelete_module(Vector** pv){
+
+	if (pv && *pv){
+		/*Actually, still get rid of internal Petsc vector. Quick fix until Matlab handles C++ 
+		 * correctly: */
+		#ifdef _HAVE_PETSC_
+			VecFree(&(*pv)->vector);
+		#endif
+		*pv=NULL;
+	}
+}
Index: /issm/branches/trunk-jpl-damage/src/c/shared/Alloc/alloc_module.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/shared/Alloc/alloc_module.h	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/c/shared/Alloc/alloc_module.h	(revision 12168)
@@ -0,0 +1,11 @@
+/* \file alloc.h
+ */
+
+#ifndef _ALLOC_MODULE_H_
+#define _ALLOC_MODULE_H_
+class Matrix;
+class Vector;
+void xdelete_module(Matrix** pvptr);
+void xdelete_module(Vector** pvptr);
+
+#endif
Index: /issm/branches/trunk-jpl-damage/src/c/shared/Exceptions/Exceptions.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/shared/Exceptions/Exceptions.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/shared/Exceptions/Exceptions.cpp	(revision 12168)
@@ -11,7 +11,4 @@
 #include "../shared.h"
 #include "../../include/include.h"
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-#include "mex.h"
-#endif
 
 ErrorException::ErrorException(const string &what_arg){
@@ -32,4 +29,8 @@
 
 ErrorException::~ErrorException() throw(){
+	extern int num_procs;
+	/*We want the report only for matlab modules, otherwise we get twice the report
+	 * We assume that if num_procs==1, it is a module (FIXME)*/
+	if(num_procs==1) this->Report();
 }
 
@@ -40,4 +41,5 @@
 void ErrorException::Report(){
 	extern int my_rank;
+	extern int num_procs;
 
 	if (function_name=="" || file_line==0){ //WINDOWS
@@ -45,11 +47,12 @@
 	}
 	else{
-		#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-			mexErrMsgTxt(exprintf("\n??? Error using ==> %s at %i\n%s error message: %s\n",
-							file_name.c_str(),file_line,function_name.c_str(),what()));
-		#else
+		if(num_procs==1){
+			printf("\n??? Error using ==> %s:%i\n",file_name.c_str(),file_line);
+			printf("%s error message: %s\n\n",function_name.c_str(),what());
+		}
+		else{
 			printf("\n[%i] ??? Error using ==> %s:%i\n",my_rank,file_name.c_str(),file_line);
 			printf("[%i] %s error message: %s\n\n",my_rank,function_name.c_str(),what());
-		#endif
+		}
 	}
 	return;
Index: /issm/branches/trunk-jpl-damage/src/c/shared/Exceptions/exceptions.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/shared/Exceptions/exceptions.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/shared/Exceptions/exceptions.h	(revision 12168)
@@ -23,11 +23,8 @@
 
 	public:
-
 	ErrorException(const string &what_arg); //for windows
 	ErrorException(string what_file,string what_function,int what_line,string what_arg);//UNIX
 	~ErrorException() throw();
-
 	virtual const char *what() const throw();
-
 	void Report();
 
Index: /issm/branches/trunk-jpl-damage/src/c/shared/Exp/DomainOutlineRead.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/shared/Exp/DomainOutlineRead.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/shared/Exp/DomainOutlineRead.cpp	(revision 12168)
@@ -13,6 +13,5 @@
 #include "../../Container/DataSet.h"
 
-int DomainOutlineRead(int* pnprof,int** pprofnvertices,double*** ppprofx,double*** ppprofy,bool** pclosed,char* domainname,bool whole=true){
-
+int DomainOutlineRead(int* pnprof,int** pprofnvertices,double*** ppprofx,double*** ppprofy,bool** pclosed,char* domainname){
 	
 	/*indexing: */
@@ -102,7 +101,4 @@
 		if((x[0]==x[n-1]) && (y[0]==y[n-1])){
 			cl=true;
-			if (!whole) {
-				n=n-1;
-			}
 		}
 
@@ -126,30 +122,30 @@
 }
 
-DataSet* DomainOutlineRead(char* domainname,bool whole=true){
-
-	/*indexing: */
-	int i;
+DataSet* DomainOutlineRead(char* domainname){
 
 	/*intermediary: */
-	int nprof;
-	int* profnvertices=NULL;
-	double** pprofx=NULL;
-	double** pprofy=NULL;
-
-	Contour* contour=NULL;
+	int       nprof;
+	int      *profnvertices = NULL;
+	double  **pprofx        = NULL;
+	double  **pprofy        = NULL;
+	Contour  *contour       = NULL;
 
 	/*output: */
 	DataSet* domain=NULL;
 
-	/*get domain outline from intermediary function:*/
-	DomainOutlineRead(&nprof,&profnvertices,&pprofx, &pprofy, NULL,domainname,whole);
+	/*If domainname is an empty string, return empty dataset*/
+	if (strcmp(domainname,"")==0){
+		nprof=0;
+	}
+	else{
+		DomainOutlineRead(&nprof,&profnvertices,&pprofx, &pprofy, NULL,domainname);
+	}
 
 	/*now create dataset of contours: */
 	domain=new DataSet(0);
 
-	for(i=0;i<nprof;i++){
+	for(int i=0;i<nprof;i++){
 		domain->AddObject(new Contour(i,profnvertices[i],pprofx[i],pprofy[i],1));
 	}
-
 	return domain;
 }
Index: /issm/branches/trunk-jpl-damage/src/c/shared/Exp/DomainOutlineWrite.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/shared/Exp/DomainOutlineWrite.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/shared/Exp/DomainOutlineWrite.cpp	(revision 12168)
@@ -11,5 +11,5 @@
 #include "../Exceptions/exceptions.h"
 
-int DomainOutlineWrite(int nprof,int* profnvertices,double** pprofx,double** pprofy,bool* closed,char* domainname,bool whole=true){
+int DomainOutlineWrite(int nprof,int* profnvertices,double** pprofx,double** pprofy,bool* closed,char* domainname){
 
 	
@@ -20,11 +20,4 @@
 	/*I/O: */
 	FILE* fid=NULL;
-
-	/*input: */
-//	int nprof; //number of profiles in the domainname file
-//	int* profnvertices=NULL; //array holding the number of vertices for the nprof profiles
-//	double** pprofx=NULL; //array of profiles x coordinates
-//	double** pprofy=NULL; //array of profiles y coordinates
-//	bool* closed=NULL; //array holding closed flags for the nprof profiles
 
 	/*open domain outline file for writing: */
@@ -43,8 +36,5 @@
 		
 		/*Write number of profile vertices: */
-		if(closed[counter] && !whole)
-			fprintf(fid,"%u %s\n",profnvertices[counter]+1,"1.");
-		else
-			fprintf(fid,"%u %s\n",profnvertices[counter]  ,"1.");
+		fprintf(fid,"%u %s\n",profnvertices[counter]  ,"1.");
 	
 		/*Write next line: */
@@ -55,8 +45,4 @@
 			fprintf(fid,"%lf\t%lf\n",pprofx[counter][i],pprofy[counter][i]);
 		}
-
-		/*Now check that we are dealing with open contours: */
-		if(closed[counter] && !whole)
-			fprintf(fid,"%lf\t%lf\n",pprofx[counter][0],pprofy[counter][0]);
 
 		/*Write blank line: */
Index: /issm/branches/trunk-jpl-damage/src/c/shared/Exp/exp.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/shared/Exp/exp.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/shared/Exp/exp.h	(revision 12168)
@@ -13,9 +13,9 @@
 int IsOutsidePoly(Vector* in,double* xc,double* yc,int numvertices,double* x,double* y,int i0,int i1, int edgevalue);
 int IsInPolySerial(double* in,double* xc,double* yc,int numvertices,double* x,double* y,int nods, int edgevalue);
-int DomainOutlineWrite(int nprof,int* profnvertices,double** pprofx,double** pprofy,bool* closed,char* domainname,bool whole);
+int DomainOutlineWrite(int nprof,int* profnvertices,double** pprofx,double** pprofy,bool* closed,char* domainname);
 int pnpoly(int npol, double *xp, double *yp, double x, double y, int edgevalue);
 
-int      DomainOutlineRead(int* pnprof,int** pprofnvertices,double*** ppprofx,double*** ppprofy,bool** pclosed,char* domainname,bool whole);
-DataSet* DomainOutlineRead(char* domainname,bool whole);
+int      DomainOutlineRead(int* pnprof,int** pprofnvertices,double*** ppprofx,double*** ppprofy,bool** pclosed,char* domainname);
+DataSet* DomainOutlineRead(char* domainname);
 
 
Index: sm/branches/trunk-jpl-damage/src/c/shared/Numerics/OptFunc.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/shared/Numerics/OptFunc.cpp	(revision 12167)
+++ 	(revision )
@@ -1,41 +1,0 @@
-/*!\file:  OptFunc.cpp
- * \brief: "C" code wrapper to matlab objectivefunctionC call
- */ 
-
-#ifdef HAVE_CONFIG_H
-	#include <config.h>
-#else
-#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
-#endif
-
-#include "../../objects/objects.h"
-#include "../../shared/shared.h"
-#include "../../include/include.h"
-
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-#include "mex.h"
-double OptFunc(double scalar, OptArgs* optargs){
-	
-	/*output: */
-	double J;
-
-	mxArray*   inputs[2];
-	mxArray*   psearch_scalar=NULL;
-	mxArray*   mxJ=NULL;
-
-	psearch_scalar=mxCreateDoubleScalar(scalar);
-	inputs[0]=psearch_scalar;
-	inputs[1]=optargs->femmodel;
-
-	mexCallMATLAB(1,&mxJ,2,(mxArray**)inputs, optargs->function_name);
-
-	/*extract misfit from mxArray*/
-	J=mxGetScalar(mxJ);
-
-	return J;
-}
-#else
-double OptFunc(double scalar, OptArgs* optargs){
-	_error_(" not implemented yet");
-}
-#endif
Index: /issm/branches/trunk-jpl-damage/src/c/shared/Numerics/OptionsFromAnalysis.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/shared/Numerics/OptionsFromAnalysis.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/shared/Numerics/OptionsFromAnalysis.cpp	(revision 12168)
@@ -30,11 +30,5 @@
 	parameters->FindParam(&strings,&numanalyses,PetscOptionsStringsEnum);
 
-	#if defined(_HAVE_MATLAB_) && defined(_SERIAL_) //do not take this away, because ISSM loads analyses as a Double Param instead of a DoubleVec Param  when running with only 1 analysis
-	if(numanalyses==1){ analyses=(double*)xmalloc(1*sizeof(double)); parameters->FindParam(analyses,PetscOptionsAnalysesEnum);
-	}
-	else parameters->FindParam(&analyses,&dummy,PetscOptionsAnalysesEnum);
-	#else
 	parameters->FindParam(&analyses,&dummy,PetscOptionsAnalysesEnum);
-	#endif
 
 	if(numanalyses==0)return NULL; //we did not find petsc options, don't bother.
Index: /issm/branches/trunk-jpl-damage/src/c/shared/Numerics/Synchronize.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/shared/Numerics/Synchronize.sh	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/shared/Numerics/Synchronize.sh	(revision 12168)
@@ -2,5 +2,5 @@
 #Synchronize Verbosity
 #first remove existing files
-rm $ISSM_TIER/src/m/shared/Verb*.m
+rm $ISSM_DIR/src/m/shared/Verb*.m
 
 echo "Synchronizing Verbosity levels..."
@@ -29,7 +29,4 @@
 #include "../../include/macros.h"
 #include "../Exceptions/exceptions.h"
-#ifdef _SERIAL_
-#include <mex.h>
-#endif
 /*}}}*/
 
@@ -54,5 +51,5 @@
 
 	#Add Verbosity Matlab file{{{
-	cat <<END > $ISSM_TIER"/src/m/shared/"$(echo $FILENAME".m")
+	cat <<END > $ISSM_DIR"/src/m/shared/"$(echo $FILENAME".m")
 function bool=$(echo $FILENAME)()
 %$(echo $FILENAME | awk {'print toupper($1)'}) - Return true if $(echo $LEVELNAME | awk {'print tolower($1)'}) level is activated
@@ -140,42 +137,16 @@
 	if(level<0) _error_("vebosity level should be a positive integer (user provided %i)",level);
 
-#ifdef _SERIAL_
-
-	mxArray* output=NULL;
-	mxArray* input=NULL;
-	input=mxCreateDoubleScalar((double)level);
-
-	mexCallMATLAB(0,&output,1,&input,"SetVerbosityLevel");
-#else
-
 	verbositylevel = level;
 
-#endif
 }/*}}}*/
 /*FUNCTION GetVerbosityLevel {{{*/
 int  GetVerbosityLevel(void){
-#ifdef _SERIAL_
-
-	mxArray* output=NULL;
-	mxArray* input=NULL;
-	double   level;
-
-	mexCallMATLAB(1,&output,0,&input,"GetVerbosityLevel");
-	level=mxGetScalar(output);
-
-	verbositylevel = (int)level;
-	return verbositylevel;
-
-#else
-
 	_assert_(verbositylevel>=0);
 	return verbositylevel;
-
-#endif
 }/*}}}*/
 END
 #}}}
 #Complete verbose.m {{{1
-VERBOSEPATH="$ISSM_TIER/src/m/classes/verbose.m"
+VERBOSEPATH="$ISSM_DIR/src/m/classes/verbose.m"
 cat $VERBOSEPATH  | sed "/%BEGINFIELDS/,$ d"  > temp_begin
 cat $VERBOSEPATH  | sed "1,/%ENDFIELDS/d" > temp_end
Index: /issm/branches/trunk-jpl-damage/src/c/shared/Numerics/Verbosity.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/shared/Numerics/Verbosity.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/shared/Numerics/Verbosity.cpp	(revision 12168)
@@ -18,7 +18,4 @@
 #include "../../include/macros.h"
 #include "../Exceptions/exceptions.h"
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-#include <mex.h>
-#endif
 /*}}}*/
 
@@ -39,36 +36,12 @@
 	if(level<0) _error_("vebosity level should be a positive integer (user provided %i)",level);
 
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-
-	mxArray* output=NULL;
-	mxArray* input=NULL;
-	input=mxCreateDoubleScalar((double)level);
-
-	mexCallMATLAB(0,&output,1,&input,"SetVerbosityLevel");
-#else
-
 	verbositylevel = level;
 
-#endif
 }/*}}}*/
 /*FUNCTION GetVerbosityLevel {{{*/
 int  GetVerbosityLevel(void){
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-
-	mxArray* output=NULL;
-	mxArray* input=NULL;
-	double   level;
-
-	mexCallMATLAB(1,&output,0,&input,"GetVerbosityLevel");
-	level=mxGetScalar(output);
-
-	verbositylevel = (int)level;
-	return verbositylevel;
-
-#else
 
 	_assert_(verbositylevel>=0);
 	return verbositylevel;
 
-#endif
 }/*}}}*/
Index: /issm/branches/trunk-jpl-damage/src/c/shared/Numerics/XZvectorsToCoordinateSystem.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/shared/Numerics/XZvectorsToCoordinateSystem.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/shared/Numerics/XZvectorsToCoordinateSystem.cpp	(revision 12168)
@@ -1,6 +1,6 @@
-#include "../../io/Matlab/matlabio.h"
 #include "../Alloc/alloc.h"
 #include "../../include/include.h"
 #include "../Exceptions/exceptions.h"
+#include "./isnan.h"
 #include <math.h>
 
Index: /issm/branches/trunk-jpl-damage/src/c/shared/TriMesh/SplitMeshForRifts.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/shared/TriMesh/SplitMeshForRifts.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/shared/TriMesh/SplitMeshForRifts.cpp	(revision 12168)
@@ -47,8 +47,7 @@
 	segmentmarkerlist=*psegmentmarkerlist;
 
-
 	/*Establish list of segments that belong to a rift: */
-	RiftSegmentsFromSegments(&nriftsegs,&riftsegments,nel,index,nsegs,segments); /*riftsegments of size nriftsegsx4 (4 for first element on segment,second element, 
-																				   first node and second snode)*/
+	/*riftsegments of size nriftsegsx4 (4 for first element on segment,second element,first node and second snode)*/
+	RiftSegmentsFromSegments(&nriftsegs,&riftsegments,nel,index,nsegs,segments);
 
 	/*Go through all nodes of the rift segments, and start splitting the mesh: */
@@ -57,5 +56,5 @@
 		for (j=0;j<2;j++){
 	
-			node=*(riftsegments+4*i+j+2);
+			node=riftsegments[4*i+j+2];
 			if(flags[node-1]){
 				/*This node was already split, skip:*/
@@ -70,7 +69,11 @@
 				DetermineGridElementListOnOneSideOfRift(&NumGridElementListOnOneSideOfRift,&GridElementListOnOneSideOfRift,i,nriftsegs,riftsegments,node,index,nel);
 			
-				/*Summary: we have for node, a list of elements (GridElementListOnOneSideOfRift, of size NumGridElementListOnOneSideOfRift) that all contain node 
-				 *and that are on the same side of the rift. For all these elements, we clone node into another node, and we swap all instances of node in the triangulation 
-				 *for those elements, to the new node.*/
+				/*Summary: we have for node, a list of elements
+				 * (GridElementListOnOneSideOfRift, of size
+				 * NumGridElementListOnOneSideOfRift) that all contain node 
+				 *and that are on the same side of the rift. For all these
+				 elements, we clone node into another node, and we swap all
+				 instances of node in the triangulation *for those elements, to the
+				 new node.*/
 				
 				//augment number of nodes 
@@ -94,5 +97,5 @@
 
 	/*update segments: they got modified completely by adding new nodes.*/
-	UpdateSegments(&segments,&segmentmarkerlist, &nsegs,index,x,y,riftsegments,nriftsegs);
+	UpdateSegments(&segments,&segmentmarkerlist, &nsegs,index,x,y,riftsegments,nriftsegs,nods,nel);
 
 	/*Assign output pointers: */
Index: /issm/branches/trunk-jpl-damage/src/c/shared/TriMesh/TriMeshUtils.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/shared/TriMesh/TriMeshUtils.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/shared/TriMesh/TriMeshUtils.cpp	(revision 12168)
@@ -11,4 +11,5 @@
 
 #define RIFTPENALTYPAIRSWIDTH 8
+/*FUNCTION IsGridOnRift{{{*/
 int IsGridOnRift(int* riftsegments, int nriftsegs, int node){
 
@@ -32,7 +33,6 @@
 		return 0;
 	}
-}
-				
-
+}/*}}}*/
+/*FUNCTION GridElementsList{{{*/
 int GridElementsList(int** pGridElements, int* pNumGridElements,int node,double * index,int nel){
 
@@ -87,7 +87,6 @@
 	*pNumGridElements=NumGridElements;
 	return noerr;
-}
-
-
+}/*}}}*/
+/*FUNCTION IsNeighbor{{{*/
 int IsNeighbor(int el1,int el2,double* index){
 	/*From a triangulation held in index, figure out if elements 1 and 2 have two nodes in common: */
@@ -105,7 +104,6 @@
 		return 0;
 	}
-}
-							
-
+}/*}}}*/
+/*FUNCTION IsOnRift{{{*/
 int IsOnRift(int el,int nriftsegs,int* riftsegments){
 	/*From a list of elements segments, figure out if el belongs to it: */
@@ -117,11 +115,6 @@
 	}
 	return 0;
-}
-
-
-/******************************************************************************************************************************
-                                   RiftSegmentsFromSegments
-******************************************************************************************************************************/
-
+}/*}}}*/
+/*FUNCTION RiftSegmentsFromSegments{{{*/
 void RiftSegmentsFromSegments(int* pnriftsegs, int** priftsegments, int nel, double* index, int nsegs,double* segments){
 	
@@ -189,10 +182,6 @@
 	*priftsegments=riftsegments;
 	*pnriftsegs=nriftsegs;
-}
-
-/******************************************************************************************************************************
-                                   DetermineGridElementListOnOneSideOfRift
-******************************************************************************************************************************/
-
+}/*}}}*/
+/*FUNCTION DetermineGridElementListOnOneSideOfRift{{{*/
 int DetermineGridElementListOnOneSideOfRift(int* pNumGridElementListOnOneSideOfRift, int** pGridElementListOnOneSideOfRift, int segmentnumber, int nriftsegs, int* riftsegments, int node,double* index,int nel){
 
@@ -257,11 +246,7 @@
 	*pGridElementListOnOneSideOfRift=GridElementListOnOneSideOfRift;
 	return noerr;
-}
-
-/******************************************************************************************************************************
-                                   UpdateSegments
-******************************************************************************************************************************/
-
-int UpdateSegments(double** psegments,double** psegmentmarkerlist, int* pnsegs, double* index, double* x,double* y,int* riftsegments,int nriftsegs){
+}/*}}}*/
+/*FUNCTION UpdateSegments{{{*/
+int UpdateSegments(double** psegments,double** psegmentmarkerlist, int* pnsegs, double* index, double* x,double* y,int* riftsegments,int nriftsegs,int nods,int nel){
 
 	int noerr=1;
@@ -284,8 +269,8 @@
 	/*First, update the existing segments to the new nodes :*/
 	for (i=0;i<nriftsegs;i++){
-		el1=*(riftsegments+4*i+0);
-		el2=*(riftsegments+4*i+1);
+		el1=riftsegments[4*i+0];
+		el2=riftsegments[4*i+1];
 		for (j=0;j<nsegs;j++){
-			if (*(segments+3*j+2)==(el1+1)){
+			if (segments[3*j+2]==(el1+1)){
 				/*segment j is the same as rift segment i.Let's update segments[j][:] using  element el1 and the corresponding rift segment.
 				 *Because riftsegments does not represent a list of rift segments anymore (it got heavily modified in SplitElementsForRifts, 
@@ -293,5 +278,5 @@
 				for (k=0;k<3;k++){
 					if ((x[(int)*(index+el1*3+k)-1]==x[(int)*(segments+3*j+0)-1]) && (y[(int)*(index+el1*3+k)-1]==y[(int)*(segments+3*j+0)-1])){
-						*(segments+3*j+0)=*(index+el1*3+k);
+						*(segments+3*j+0)=*(index+el1*3+k); _assert_(segments[3*j+0]<nods+1);
 						break;
 					}
@@ -299,5 +284,5 @@
 				for (k=0;k<3;k++){
 					if ((x[(int)*(index+el1*3+k)-1]==x[(int)*(segments+3*j+1)-1])  && (y[(int)*(index+el1*3+k)-1]==y[(int)*(segments+3*j+1)-1])){
-						*(segments+3*j+1)=*(index+el1*3+k);
+						*(segments+3*j+1)=*(index+el1*3+k); _assert_(segments[3*j+1]<nods+1);
 						break;
 					}
@@ -308,5 +293,5 @@
 				for (k=0;k<3;k++){
 					if ((x[(int)*(index+el2*3+k)-1]==x[(int)*(segments+3*j+0)-1]) && (y[(int)*(index+el2*3+k)-1]==y[(int)*(segments+3*j+0)-1])){
-						*(segments+3*(nsegs+i)+0)=*(index+el2*3+k);
+						*(segments+3*(nsegs+i)+0)=*(index+el2*3+k); _assert_(segments[3*(nsegs+i)+0]<nods+1);
 						break;
 					}
@@ -314,5 +299,5 @@
 				for (k=0;k<3;k++){
 					if ((x[(int)*(index+el2*3+k)-1]==x[(int)*(segments+3*j+1)-1]) && (y[(int)*(index+el2*3+k)-1]==y[(int)*(segments+3*j+1)-1])){
-						*(segments+3*(nsegs+i)+1)=*(index+el2*3+k);
+						*(segments+3*(nsegs+i)+1)=*(index+el2*3+k); _assert_(segments[3*(nsegs+i)+1]<nods+1);
 						break;
 					}
@@ -324,5 +309,5 @@
 				for (k=0;k<3;k++){
 					if ((x[(int)*(index+el2*3+k)-1]==x[(int)*(segments+3*j+0)-1]) && (y[(int)*(index+el2*3+k)-1]==y[(int)*(segments+3*j+0)-1])){
-						*(segments+3*j+0)=*(index+el2*3+k);
+						*(segments+3*j+0)=*(index+el2*3+k); _assert_(segments[3*j+0]<nods+1);
 						break;
 					}
@@ -330,5 +315,5 @@
 				for (k=0;k<3;k++){
 					if ((x[(int)*(index+el2*3+k)-1]==x[(int)*(segments+3*j+1)-1]) && (y[(int)*(index+el2*3+k)-1]==y[(int)*(segments+3*j+1)-1])){
-						*(segments+3*j+1)=*(index+el2*3+k);
+						*(segments+3*j+1)=*(index+el2*3+k);_assert_(segments[3*j+1]<nods+1);
 						break;
 					}
@@ -339,5 +324,5 @@
 				for (k=0;k<3;k++){
 					if ((x[(int)*(index+el1*3+k)-1]==x[(int)*(segments+3*j+0)-1]) && (y[(int)*(index+el1*3+k)-1]==y[(int)*(segments+3*j+0)-1])){
-						*(segments+3*(nsegs+i)+0)=*(index+el1*3+k);
+						*(segments+3*(nsegs+i)+0)=*(index+el1*3+k);_assert_(segments[3*(nsegs+i)+0]<nods+1);
 						break;
 					}
@@ -345,5 +330,5 @@
 				for (k=0;k<3;k++){
 					if ((x[(int)*(index+el1*3+k)-1]==x[(int)*(segments+3*j+1)-1]) && (y[(int)*(index+el1*3+k)-1]==y[(int)*(segments+3*j+1)-1])){
-						*(segments+3*(nsegs+i)+1)=*(index+el1*3+k);
+						*(segments+3*(nsegs+i)+1)=*(index+el1*3+k);_assert_(segments[3*(nsegs+i)+1]<nods+1);
 						break;
 					}
@@ -360,9 +345,6 @@
 	
 	return noerr;
-}
-
-/******************************************************************************************************************************
-                                   pnpoly
-******************************************************************************************************************************/
+}/*}}}*/
+/*FUNCTION pnpoly{{{*/
 int pnpoly(int npol, double *xp, double *yp, double x, double y) {
 	int i, j, c = 0;
@@ -374,33 +356,6 @@
 	}
 	return c;
-}
-
-/******************************************************************************************************************************
-                                   IsInPoly
-******************************************************************************************************************************/
-//void IsInPoly(double* in,double* xc,double* yc,int numnodes,double* x,double* y,int nods){
-//
-//	int i;
-//	double x0,y0;
-//
-//	/*Go through all nodes of the mesh:*/
-//	for (i=0;i<nods;i++){
-//		if (in[i]){
-//			/*this node already is inside one of the contours, continue*/
-//			continue;
-//		}
-//		/*pick up node: */
-//		x0=x[i];
-//		y0=y[i];
-//		if (pnpoly(numnodes,xc,yc,x0,y0)){
-//			in[i]=1;
-//		}
-//	}
-//}
-
-/******************************************************************************************************************************
-                                   FindElement
-******************************************************************************************************************************/
-
+}/*}}}*/
+/*FUNCTION FindElement{{{*/
 int FindElement(double A,double B,double* index,int nel){
 
@@ -414,10 +369,7 @@
 	}
 	return el;
-}
-/******************************************************************************************************************************
-                                   SplitRiftSegments
-******************************************************************************************************************************/
-
-int SplitRiftSegments(double** psegments,double** psegmentmarkerlist, int* pnumsegs, int* pnumrifts,int** priftsnumsegs,double*** priftssegments,int numrifts){
+}/*}}}*/
+/*FUNCTION SplitRiftSegments{{{*/
+int SplitRiftSegments(double** psegments,double** psegmentmarkerlist, int* pnumsegs, int* pnumrifts,int** priftsnumsegs,double*** priftssegments,int numrifts,int nods,int nel){
 
 	/*Using segment markers, wring out the rift segments from the segments. Rift markers are 
@@ -461,7 +413,7 @@
 	for (i=0;i<numsegs;i++){
 		if (segmentmarkerlist[i]==1){
-			*(new_segments+3*counter+0)=*(segments+3*i+0);
-			*(new_segments+3*counter+1)=*(segments+3*i+1);
-			*(new_segments+3*counter+2)=*(segments+3*i+2);
+			new_segments[3*counter+0]=segments[3*i+0];
+			new_segments[3*counter+1]=segments[3*i+1];
+			new_segments[3*counter+2]=segments[3*i+2];
 			new_segmentmarkers[counter]=segmentmarkerlist[i];
 			counter++;
@@ -484,7 +436,7 @@
 		for (j=0;j<numsegs;j++){
 			if (segmentmarkerlist[j]==(2+i)){
-				*(riftsegment+3*counter+0)=*(segments+3*j+0);
-				*(riftsegment+3*counter+1)=*(segments+3*j+1);
-				*(riftsegment+3*counter+2)=*(segments+3*j+2);
+				riftsegment[3*counter+0]=segments[3*j+0];_assert_(riftsegment[3*counter+0]<nods+1);
+				riftsegment[3*counter+1]=segments[3*j+1];_assert_(riftsegment[3*counter+1]<nods+1);
+				riftsegment[3*counter+2]=segments[3*j+2];_assert_(riftsegment[3*counter+2]<nel+1);
 				counter++;
 			}
@@ -504,10 +456,6 @@
 	*priftsnumsegs=riftsnumsegs;
 	return noerr;
-}
-
-/******************************************************************************************************************************
-                                   PairRiftElements
-******************************************************************************************************************************/
-
+}/*}}}*/
+/*FUNCTION PairRiftElements{{{*/
 int PairRiftElements(int** priftsnumpairs, double*** priftspairs,int numrifts,int* riftsnumsegments, double** riftssegments,double* x,double* y){
 
@@ -558,15 +506,6 @@
 
 	return noerr;
-}
-
-
-/******************************************************************************************************************************
-                                   RemoveRifts
-******************************************************************************************************************************/
-
-double dabs(double x){
-	if (x<0)x=-x;
-	return x;
-}
+}/*}}}*/
+/*FUNCTION RemoveRifts{{{*/
 int RemoveRifts(double** pindex,double** px,double** py,int* pnods,double** psegments,int* pnumsegs,int numrifts1,int* rifts1numsegs,double** rifts1segments,double** rifts1pairs,int nel){
 
@@ -615,6 +554,6 @@
 		if (y[i]<ymin)ymin=y[i];
 	}
-	xmin=xmin-dabs(xmin); 
-	ymin=ymin-dabs(ymin);
+	xmin=xmin-fabs(xmin); 
+	ymin=ymin-fabs(ymin);
 
 	/*Initialize two arrays, one for nodes that are going to be merged, the other with corresponding nodes being merge into: */
@@ -751,10 +690,6 @@
 
 	return noerr;
-}
-
-/******************************************************************************************************************************
-                                   IsRiftPresent
-******************************************************************************************************************************/
-
+}/*}}}*/
+/*FUNCTION IsRiftPresent{{{*/
 int IsRiftPresent(int* priftflag,int* pnumrifts, double* segmentmarkerlist,int nsegs){
 
@@ -783,11 +718,7 @@
 
 	return noerr;
-}
-
-/******************************************************************************************************************************
-                                   OrderRifts
-******************************************************************************************************************************/
-
-int OrderRifts(double** priftstips, double** riftssegments,double** riftspairs,int numrifts,int* riftsnumsegments,double* x,double* y){
+}/*}}}*/
+/*FUNCTION OrderRifts{{{*/
+int OrderRifts(double** priftstips, double** riftssegments,double** riftspairs,int numrifts,int* riftsnumsegments,double* x,double* y,int nods,int nels){
 	
 	int noerr=1;
@@ -811,5 +742,4 @@
 	/*output: */
 	double* riftstips=NULL;
-
 
 	/*Allocate byproduct of this routine, riftstips: */
@@ -822,5 +752,4 @@
 		numsegs=riftsnumsegments[i];
 	
-			
 		/*Allocate copy of riftsegments and riftpairs, 
 		 *as well as ordering vector: */
@@ -847,5 +776,7 @@
 			}
 			/* Make sure node3 faces node1 and node4 faces node2: */
-			if ((x[node1]==x[node4]) && (y[node1]==y[node4])){
+			_assert_(node1<nods+1 && node4<nods+1);
+			_assert_(node1>0 && node4>0);
+			if ((x[node1-1]==x[node4-1]) && (y[node1-1]==y[node4-1])){
 				/*Swap node3 and node4:*/
 				temp_node=node3;
@@ -943,10 +874,6 @@
 	*priftstips=riftstips;
 	return noerr;
-}
-
-/******************************************************************************************************************************
-                                   PenaltyPairs
-******************************************************************************************************************************/
-
+}/*}}}*/
+/*FUNCTION PenaltyPairs{{{*/
 int PenaltyPairs(double*** priftspenaltypairs,int** priftsnumpenaltypairs,int numrifts,double** riftssegments,
 		int* riftsnumsegs,double** riftspairs,double* riftstips,double* x,double* y){
Index: /issm/branches/trunk-jpl-damage/src/c/shared/TriMesh/trimesh.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/shared/TriMesh/trimesh.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/shared/TriMesh/trimesh.h	(revision 12168)
@@ -6,20 +6,13 @@
 #define _SHARED_TRIMESH_H
 
-
 #include <stdio.h>
 #include <math.h>
 
-
-
 //#define REAL double //took  it out because it may conflict with stdlib.h defines. put back if necessary
-
 int AssociateSegmentToElement(double** psegments,int nseg, double* index,int nel);
 int OrderSegments(double** psegments,int nseg, double* index,int nel);
-		
 int GridInsideHole(double* px0,double* py0,int n,double* x,double* y);
 int FindElement(double A,double B,double* index,int nel);
-
 int SplitMeshForRifts(int* pnel,double** pindex,int* pnods,double** px,double** py,int* pnsegs,double** psegments,double** psegmentmarkerlist);
-
 int IsGridOnRift(int* riftsegments, int nriftsegs, int node);
 int GridElementsList(int** pGridElements, int* pNumGridElements,int node,double * index,int nel);
@@ -28,17 +21,15 @@
 void RiftSegmentsFromSegments(int* pnriftsegs, int** priftsegments, int nel, double* index, int nsegs,double* segments);
 int DetermineGridElementListOnOneSideOfRift(int* pNumGridElementListOnOneSideOfRift, int** pGridElementListOnOneSideOfRift, int segmentnumber, int nriftsegs, int* riftsegments, int node,double* index,int nel);
-int UpdateSegments(double** psegments,double** psegmentmarkerlist, int* pnsegs, double* index, double* x,double* y,int* riftsegments,int nriftsegs);
+int UpdateSegments(double** psegments,double** psegmentmarkerlist, int* pnsegs, double* index, double* x,double* y,int* riftsegments,int nriftsegs,int nods,int nel);
 int pnpoly(int npol, double *xp, double *yp, double x, double y);
 int FindElement(double A,double B,double* index,int nel);
 int RemoveRifts(double** pindex,double** px,double** py,int* pnods,double** psegments,int* pnumsegs,int numrifts1,int* rifts1numsegs,double** rifts1segments,double** rifts1pairs,int nel);
 int IsRiftPresent(int* priftflag,int* pnumrifts, double* segmentmarkerlist,int nsegs);
-int SplitRiftSegments(double** psegments,double** psegmentmarkerlist, int* pnumsegs, int* pnumrifts,int** priftsnumsegs,double*** priftssegments,int numrifts);
-int OrderRifts(double** priftstips, double** riftssegments,double** riftspairs,int numrifts,int* riftsnumsegments,double* x,double* y);
+int SplitRiftSegments(double** psegments,double** psegmentmarkerlist, int* pnumsegs, int* pnumrifts,int** priftsnumsegs,double*** priftssegments,int numrifts,int nods,int nels);
+int OrderRifts(double** priftstips, double** riftssegments,double** riftspairs,int numrifts,int* riftsnumsegments,double* x,double* y,int nods,int nels);
 int PenaltyPairs(double*** priftspenaltypairs,int** priftsnumpenaltypairs,int numrifts,double**  riftssegments,
 		int* riftsnumsegments,double** riftspairs,double* riftstips,double* x,double* y);
-
 int RemoveCornersFromRifts(double** pindex,int* pnel,double** px,double** py,int* pnods, double* segments,double* segmentmarkers,int num_seg);
 int PairRiftElements(int** priftsnumpairs, double*** priftspairs,int numrifts,int* riftsnumsegments, double** riftssegments,double* x,double* y);
 
-
 #endif  /* _SHARED_TRIMESH_H */
Index: /issm/branches/trunk-jpl-damage/src/c/shared/Wrapper/wrappershared.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/shared/Wrapper/wrappershared.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/shared/Wrapper/wrappershared.h	(revision 12168)
@@ -8,8 +8,6 @@
 #include "../../objects/objects.h"
 
-#ifdef _SERIAL_
 int ModuleBoot(void);
 int ModuleEnd(void);
-#endif
 
 #endif
Index: /issm/branches/trunk-jpl-damage/src/c/shared/shared.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/shared/shared.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/shared/shared.h	(revision 12168)
@@ -8,4 +8,5 @@
 
 #include "Alloc/alloc.h"
+#include "Alloc/alloc_module.h"
 #include "Exceptions/exceptions.h"
 #include "Exp/exp.h"
Index: /issm/branches/trunk-jpl-damage/src/c/solutions/issm.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/solutions/issm.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/solutions/issm.cpp	(revision 12168)
@@ -35,9 +35,5 @@
 	int      ierr;
 
-	MODULEBOOT();
-
-	#ifndef _PARALLEL_
-	_error_(" parallel executable was compiled without support of parallel libraries!");
-	#endif
+	ISSMBOOT();
 
 	/*Initialize environments: Petsc, MPI, etc...: */
@@ -46,12 +42,20 @@
 	if(ierr) _error_("Could not initialize Petsc");
 	#else
+	#ifdef _HAVE_MPI_
 	MPI_Init(&argc,&argv);
 	#endif
+	#endif
 
+	#ifdef _HAVE_MPI_
 	MPI_Barrier(MPI_COMM_WORLD); start=MPI_Wtime();
+	#else
+	start=(double)clock();
+	#endif
 
 	/*Size and rank: */
+	#ifdef _HAVE_MPI_
 	MPI_Comm_rank(MPI_COMM_WORLD,&my_rank);  
 	MPI_Comm_size(MPI_COMM_WORLD,&num_procs); 
+	#endif
 
 	/*First process inputs*/
@@ -66,5 +70,9 @@
 	
 	/*Create femmodel, using input file: */
+	#ifdef _HAVE_MPI_
 	MPI_Barrier(MPI_COMM_WORLD); start_init=MPI_Wtime();
+	#else
+	start_init=(double)clock();
+	#endif
 	femmodel=new FemModel(binfilename,outbinfilename,solution_type,analyses,numanalyses);
 	
@@ -86,8 +94,17 @@
 	femmodel->parameters->FindParam(&control_analysis,InversionIscontrolEnum);
 	femmodel->parameters->FindParam(&tao_analysis,InversionTaoEnum);
+	#ifdef _HAVE_MPI_
 	MPI_Barrier(MPI_COMM_WORLD); finish_init=MPI_Wtime();
+	#else
+	finish_init=(double)clock();
+	#endif
 
 	_printf_(true,"call computational core:\n");
+	#ifdef _HAVE_MPI_
 	MPI_Barrier(MPI_COMM_WORLD); start_core=MPI_Wtime( );
+	#else
+	start_core=(double)clock();
+	#endif
+	
 	if(dakota_analysis){
 		#ifdef _HAVE_DAKOTA_
@@ -110,6 +127,10 @@
 		solutioncore(femmodel);
 	}
+	#ifdef _HAVE_MPI_
 	MPI_Barrier(MPI_COMM_WORLD); finish_core=MPI_Wtime( );
-
+	#else
+	finish_core=(double)clock();
+	#endif
+	
 	_printf_(true,"write results to disk:\n");
 	OutputResultsx(femmodel->elements, femmodel->nodes, femmodel->vertices, femmodel->loads, femmodel->materials, femmodel->parameters,femmodel->results);
@@ -131,21 +152,31 @@
 
 	/*Get finish time and close*/
+	#ifdef _HAVE_MPI_
 	MPI_Barrier(MPI_COMM_WORLD); finish = MPI_Wtime( );
 	_printf_(true,"\n   %-34s %f seconds  \n","FemModel initialization elapsed time:",finish_init-start_init);
 	_printf_(true,"   %-34s %f seconds  \n","Core solution elapsed time:",finish_core-start_core);
 	_printf_(true,"\n   %s %i hrs %i min %i sec\n\n","Total elapsed time:",int((finish-start)/3600),int(int(finish-start)%3600/60),int(finish-start)%60);
+	#else
+	finish=(double)clock();
+	_printf_(true,"\n   %-34s %f seconds  \n","FemModel initialization elapsed time:",(finish_init-start_init)/CLOCKS_PER_SEC);
+	_printf_(true,"   %-34s %f seconds  \n","Core solution elapsed time:",(finish_core-start_core)/CLOCKS_PER_SEC);
+	_printf_(true,"\n   %s %i hrs %i min %i sec\n\n","Total elapsed time:",int((finish-start)/3600/CLOCKS_PER_SEC),int(int((finish-start)/CLOCKS_PER_SEC)%3600/60),(int(finish-start)/CLOCKS_PER_SEC)%60);
+	#endif
 	
+		
 	
+	#ifdef _HAVE_PETSC_
 	_printf_(true,"closing MPI and Petsc\n");
-	#ifdef _HAVE_PETSC_
 	PetscFinalize(); 
 	#else
+	#ifdef _HAVE_MPI_
+	_printf_(true,"closing MPI and Petsc\n");
 	MPI_Finalize();
+	#endif
 	#endif
 	
 	/*end module: */
-	MODULEEND();
+	ISSMEND();
 
 	return 0; //unix success return;
 }
-
Index: /issm/branches/trunk-jpl-damage/src/c/toolkits/issm/SeqMat.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/toolkits/issm/SeqMat.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/toolkits/issm/SeqMat.cpp	(revision 12168)
@@ -92,52 +92,4 @@
 }
 /*}}}*/
-
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-/*FUNCTION SeqMat::ToMatlabMatrix{{{1*/
-mxArray* SeqMat::ToMatlabMatrix(void){
-
-	/*Intermediary: */
-	double* buffer=NULL;
-	mxArray* pfield=NULL;
-	
-	/*output: */
-	mxArray* dataref=NULL;
-
-	/*copy vector into a new buffer: */
-	if(this->M*this->N){
-		buffer=(double*)xmalloc(this->M*this->N*sizeof(double));
-		memcpy(buffer,this->matrix,M*N*sizeof(double));
-
-		pfield=mxCreateDoubleMatrix(0,0,mxREAL);
-		mxSetM(pfield,this->N);
-		mxSetN(pfield,this->M);
-		mxSetPr(pfield,buffer);
-		
-		//transpose the matrix, written directly to matlab! from C to matlab.
-		mexCallMATLAB(1,&dataref, 1, &pfield, "transpose");
-	}
-	else dataref=mxCreateDoubleMatrix(0,0,mxREAL);
-
-	/*do not erase buffer!: */
-	return dataref;
-
-}
-
-
-	
-	
-/*}}}*/
-/*FUNCTION MatlabMatrixToSeqMat{{{1*/
-SeqMat* MatlabMatrixToSeqMat(const mxArray* dataref){
-
-	SeqMat* output=NULL;
-
-	output=new SeqMat();
-	MatlabMatrixToDoubleMatrix(&output->matrix,&output->M,&output->N,dataref);
-	return output;
-
-}
-/*}}}*/
-#endif
 /*FUNCTION SeqMat::Assemble{{{1*/
 void SeqMat::Assemble(void){
Index: /issm/branches/trunk-jpl-damage/src/c/toolkits/issm/SeqMat.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/toolkits/issm/SeqMat.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/toolkits/issm/SeqMat.h	(revision 12168)
@@ -15,8 +15,4 @@
 
 #include "../toolkitsenums.h"
-
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-#include "mex.h"
-#endif
 
 /*}}}*/
@@ -40,7 +36,4 @@
 		/*SeqMat specific routines {{{1*/
 		void Echo(void);
-		#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-		mxArray* ToMatlabMatrix(void);
-		#endif
 		void Assemble(void);
 		double Norm(NormMode norm_type);
@@ -56,8 +49,3 @@
 };
 		
-/*API :*/
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-SeqMat*  MatlabMatrixToSeqMat(const mxArray* dataref);
-#endif
-
 #endif //#ifndef _SEQMAT_H_
Index: /issm/branches/trunk-jpl-damage/src/c/toolkits/issm/SeqVec.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/toolkits/issm/SeqVec.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/toolkits/issm/SeqVec.cpp	(revision 12168)
@@ -66,42 +66,4 @@
 /*}}}*/
 
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-/*FUNCTION SeqVec::ToMatlabVector{{{1*/
-mxArray* SeqVec::ToMatlabVector(void){
-
-	double* buffer=NULL;
-	
-	mxArray* dataref=NULL;
-
-	/*copy vector into a new buffer: */
-	if(this->M){
-		buffer=(double*)xmalloc(this->M*sizeof(double));
-		memcpy(buffer,vector,M*sizeof(double));
-
-		dataref = mxCreateDoubleMatrix(0,0,mxREAL);
-		mxSetM(dataref,this->M);
-		mxSetN(dataref,1);
-		mxSetPr(dataref,buffer);	
-	}
-	else dataref = mxCreateDoubleMatrix(0,0,mxREAL);
-
-
-	/*do not erase buffer!: */
-	return dataref;
-
-}
-/*}}}*/
-/*FUNCTION MatlabVectorToSeqVec{{{1*/
-SeqVec* MatlabVectorToSeqVec(const mxArray* dataref){
-
-	SeqVec* output=NULL;
-
-	output=new SeqVec();
-	MatlabVectorToDoubleVector(&output->vector,&output->M,dataref);
-	return output;
-
-}
-/*}}}*/
-#endif
 /*FUNCTION SeqVec::Assemble{{{1*/
 void SeqVec::Assemble(void){
Index: /issm/branches/trunk-jpl-damage/src/c/toolkits/issm/SeqVec.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/toolkits/issm/SeqVec.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/toolkits/issm/SeqVec.h	(revision 12168)
@@ -15,8 +15,4 @@
 
 #include "../toolkitsenums.h"
-
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-#include "mex.h"
-#endif
 
 /*}}}*/
@@ -37,7 +33,4 @@
 		/*SeqVec specific routines {{{1*/
 		void Echo(void);
-		#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-		mxArray* ToMatlabVector(void);
-		#endif
 		void Assemble(void);
 		void SetValues(int ssize, int* list, double* values, InsMode mode);
@@ -59,9 +52,3 @@
 };
 
-
-/*API :*/
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-SeqVec*  MatlabVectorToSeqVec(const mxArray* dataref);
-#endif
-
 #endif //#ifndef _SEQVEC_H_
Index: /issm/branches/trunk-jpl-damage/src/c/toolkits/petsc/patches/MatInvert.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/toolkits/petsc/patches/MatInvert.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/toolkits/petsc/patches/MatInvert.cpp	(revision 12168)
@@ -55,10 +55,6 @@
 	MatAssemblyBegin(inv,MAT_FINAL_ASSEMBLY);
 	MatAssemblyEnd(inv,MAT_FINAL_ASSEMBLY);
-
-	#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-		MatConvert(inv, MATSEQAIJ,MAT_REUSE_MATRIX,&inv);
-	#else
-		MatConvert(inv, MATMPIAIJ,MAT_REUSE_MATRIX,&inv);
-	#endif
+		
+	MatConvert(inv, MATMPIAIJ,MAT_REUSE_MATRIX,&inv);
 	
 	/*Free ressources:*/
Index: sm/branches/trunk-jpl-damage/src/c/toolkits/petsc/patches/MatlabMatrixToPetscMatrix.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/toolkits/petsc/patches/MatlabMatrixToPetscMatrix.cpp	(revision 12167)
+++ 	(revision )
@@ -1,123 +1,0 @@
-/* \file MatlabMatrixToPetscMatrix.cpp
- * \brief: convert a sparse or dense matlab matrix to a serial Petsc matrix:
- */
-
-
-#ifdef HAVE_CONFIG_H
-	#include <config.h>
-#else
-#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
-#endif
-
-
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-
-/*Petsc includes: */
-#include "petscmat.h"
-#include "petscvec.h"
-#include "petscksp.h"
-
-/*Matlab includes: */
-#include "mex.h"
-
-#include "../../../shared/shared.h"
-
-int MatlabMatrixToPetscMatrix(Mat* pmatrix,int* pmatrix_rows,int* pmatrix_cols,const mxArray* mxmatrix){
-
-	int rows, cols;
-	double* mxmatrix_ptr=NULL;
-	double* tmatrix=NULL;
-	int ierr;
-	int i,j;
-
-	/*output: */
-	Mat matrix=NULL;
-
-	/*matlab indices: */
-	mwIndex*    ir=NULL;
-	mwIndex*    jc=NULL;
-	double* pr=NULL;
-	int     count;
-	int     nnz;
-	int     nz;
-
-	/*petsc indices: */
-	int* idxm=NULL;
-	int* idxn=NULL;
-	
-	/*Ok, first check if we are dealing with a sparse or full matrix: */
-	if (mxIsSparse(mxmatrix)){
-
-		/*Dealing with sparse matrix: recover size first: */
-		mxmatrix_ptr=(double*)mxGetPr(mxmatrix);
-		rows=mxGetM(mxmatrix);
-		cols=mxGetN(mxmatrix);
-		nnz=mxGetNzmax(mxmatrix);
-		if(rows){
-			nz=(int)((double)nnz/(double)rows);
-		}
-		else{
-			nz=0;
-		}
-
-		ierr=MatCreateSeqAIJ(PETSC_COMM_SELF,rows,cols,nz,PETSC_NULL,&matrix);CHKERRQ(ierr);
-
-		/*Now, get ir,jc and pr: */
-		pr=mxGetPr(mxmatrix);
-		ir=mxGetIr(mxmatrix);
-		jc=mxGetJc(mxmatrix);
-
-		/*Now, start inserting data into sparse matrix: */
-		count=0;
-		for(i=0;i<cols;i++){
-			for(j=0;j<(jc[i+1]-jc[i]);j++){
-				MatSetValue(matrix,ir[count],i,pr[count],INSERT_VALUES);
-				count++;
-			}
-		}
-
-	}
-	else{
-
-		/*Dealing with dense matrix: recover pointer and size: */
-		mxmatrix_ptr=(double*)mxGetPr(mxmatrix);
-		rows=mxGetM(mxmatrix);
-		cols=mxGetN(mxmatrix);
-
-		/*transpose, as Petsc now does not allows MAT_COLUMN_ORIENTED matrices in MatSetValues: */
-		tmatrix=(double*)xmalloc(rows*cols*sizeof(double));
-		for(i=0;i<cols;i++){
-			for(j=0;j<rows;j++){
-				*(tmatrix+rows*i+j)=*(mxmatrix_ptr+cols*j+i);
-			}
-		}
-
-		/*Create serial matrix: */
-		ierr=MatCreateSeqDense(PETSC_COMM_SELF,rows,cols,NULL,&matrix);CHKERRQ(ierr);
-
-		/*Insert mxmatrix_ptr values into petsc matrix: */
-		idxm=(int*)xmalloc(rows*sizeof(int));
-		idxn=(int*)xmalloc(cols*sizeof(int));
-
-		for(i=0;i<rows;i++)idxm[i]=i;
-		for(i=0;i<cols;i++)idxn[i]=i;
-
-		ierr=MatSetValues(matrix,rows,idxm,cols,idxn,tmatrix,INSERT_VALUES); CHKERRQ(ierr);
-
-		xfree((void**)&tmatrix);
-
-	}
-
-	/*Assemble matrix: */
-	MatAssemblyBegin(matrix,MAT_FINAL_ASSEMBLY); 
-	MatAssemblyEnd(matrix,MAT_FINAL_ASSEMBLY);
-
-
-	/*Assign output pointer: */
-	*pmatrix=matrix;
-	if(pmatrix_rows) *pmatrix_rows=rows;
-	if(pmatrix_cols) *pmatrix_cols=cols;
-
-	return 1;
-}
-#endif
Index: sm/branches/trunk-jpl-damage/src/c/toolkits/petsc/patches/MatlabVectorToPetscVector.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/toolkits/petsc/patches/MatlabVectorToPetscVector.cpp	(revision 12167)
+++ 	(revision )
@@ -1,102 +1,0 @@
-/* \file MatlabVectorToPetscVector.cpp
- * \brief: convert a sparse or dense matlab vector to a serial Petsc vector:
- */
-
-
-#ifdef HAVE_CONFIG_H
-	#include <config.h>
-#else
-#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
-#endif
-
-
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-
-/*Petsc includes: */
-#include "petscmat.h"
-#include "petscvec.h"
-#include "petscksp.h"
-
-/*Matlab includes: */
-#include "mex.h"
-
-#include "../../../shared/shared.h"
-
-int MatlabVectorToPetscVector(Vec* pvector,int* pvector_rows,const mxArray* mxvector){
-
-	int rows, cols;
-	double* mxvector_ptr=NULL;
-	int ierr;
-	int i,j;
-
-	/*output: */
-	Vec vector=NULL;
-
-	/*matlab indices: */
-	mwIndex*    ir=NULL;
-	mwIndex*    jc=NULL;
-	double* pr=NULL;
-	int     count;
-	int     nnz;
-	int     nz;
-
-	/*petsc indices: */
-	int* idxm=NULL;
-	
-	/*Ok, first check if we are dealing with a sparse or full vector: */
-	if (mxIsSparse(mxvector)){
-
-		/*Dealing with sparse vector: recover size first: */
-		mxvector_ptr=(double*)mxGetPr(mxvector);
-		rows=mxGetM(mxvector);
-		cols=mxGetN(mxvector);
-		nnz=mxGetNzmax(mxvector);
-		nz=(int)((double)nnz/(double)rows);
-
-		ierr=VecCreateSeq(PETSC_COMM_SELF,rows,&vector);CHKERRQ(ierr);
-
-		/*Now, get ir,jc and pr: */
-		pr=mxGetPr(mxvector);
-		ir=mxGetIr(mxvector);
-		jc=mxGetJc(mxvector);
-
-		/*Now, start inserting data into sparse vector: */
-		count=0;
-		for(i=0;i<cols;i++){
-			for(j=0;j<(jc[i+1]-jc[i]);j++){
-				VecSetValue(vector,ir[count],pr[count],INSERT_VALUES);
-				count++;
-			}
-		}
-
-	}
-	else{
-
-		/*Dealing with dense vector: recover pointer and size: */
-		mxvector_ptr=(double*)mxGetPr(mxvector);
-		rows=mxGetM(mxvector);
-		cols=mxGetN(mxvector);
-
-		/*Create serial vector: */
-		ierr=VecCreateSeq(PETSC_COMM_SELF,rows,&vector);CHKERRQ(ierr);
-
-		/*Insert mxvector_ptr values into petsc vector: */
-		idxm=(int*)xmalloc(rows*sizeof(int));
-
-		for(i=0;i<rows;i++)idxm[i]=i;
-
-		ierr=VecSetValues(vector,rows,idxm,mxvector_ptr,INSERT_VALUES);CHKERRQ(ierr);
-
-	}
-
-	/*Assemble vector: */
-	VecAssemblyBegin(vector);
-	VecAssemblyEnd(vector);
-
-	/*Assign output pointer: */
-	*pvector=vector;
-	*pvector_rows=rows;
-
-	return 1;
-}
-#endif
Index: /issm/branches/trunk-jpl-damage/src/c/toolkits/petsc/patches/NewMat.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/toolkits/petsc/patches/NewMat.cpp	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/toolkits/petsc/patches/NewMat.cpp	(revision 12168)
@@ -68,5 +68,10 @@
 
 	#ifdef _HAVE_PETSCDEV_
-	MatCreateAIJ(MPI_COMM_WORLD,m,n,M,N,d_nz,NULL,o_nz,NULL,&outmatrix); 
+	if(sparsity==1){
+		MatCreateDense(MPI_COMM_WORLD,m,n,M,N,NULL,&outmatrix); 
+	}
+	else{
+		MatCreateAIJ(MPI_COMM_WORLD,m,n,M,N,d_nz,NULL,o_nz,NULL,&outmatrix); 
+	}
 	#else
 	MatCreateMPIAIJ(MPI_COMM_WORLD,m,n,M,N,d_nz,NULL,o_nz,NULL,&outmatrix); 
Index: /issm/branches/trunk-jpl-damage/src/c/toolkits/petsc/patches/PetscMatrixToDoubleMatrix.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/toolkits/petsc/patches/PetscMatrixToDoubleMatrix.cpp	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/c/toolkits/petsc/patches/PetscMatrixToDoubleMatrix.cpp	(revision 12168)
@@ -0,0 +1,51 @@
+/* \file PetscMatrixToDoubleMatrix.cpp
+ * \brief: convert a sparse or dense Petsc matrix into a matlab matrix
+ */
+
+
+#ifdef HAVE_CONFIG_H
+	#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+#include <string>
+
+/*Petsc includes: */
+#include "petscmat.h"
+#include "petscvec.h"
+#include "petscksp.h"
+
+/*Petsc includes: */
+#include "../../../shared/shared.h"
+
+
+void PetscMatrixToDoubleMatrix(double** pmatrix, int* prows, int* pcols,Mat petsc_matrix){
+
+	int i,j,k;
+
+	/*output: */
+	double* matrix=NULL;
+	int     rows,cols;
+
+	/*intermediary: */
+	int*    idxm=NULL;
+	int*    idxn=NULL;
+
+	/*Some needed information: */
+	MatGetSize(petsc_matrix,&rows,&cols);
+
+	idxm=(int*)xmalloc(rows*sizeof(int));
+	idxn=(int*)xmalloc(cols*sizeof(int));
+
+	for(i=0;i<rows;i++)idxm[i]=i;
+	for(i=0;i<cols;i++)idxn[i]=i;
+
+	matrix=(double*)xmalloc(rows*cols*sizeof(double));
+	MatGetValues(petsc_matrix,rows,idxm,cols,idxn,matrix);
+
+	/*Assign output pointers: */
+	*pmatrix=matrix;
+	*prows=rows;
+	*pcols=cols;
+}
Index: sm/branches/trunk-jpl-damage/src/c/toolkits/petsc/patches/PetscMatrixToMatlabMatrix.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/toolkits/petsc/patches/PetscMatrixToMatlabMatrix.cpp	(revision 12167)
+++ 	(revision )
@@ -1,150 +1,0 @@
-/* \file PetscMatrixToMatlabMatrix.cpp
- * \brief: convert a sparse or dense Petsc matrix into a matlab matrix
- */
-
-
-#ifdef HAVE_CONFIG_H
-	#include <config.h>
-#else
-#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
-#endif
-
-
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-
-/*Petsc includes: */
-#include "petscmat.h"
-#include "petscvec.h"
-#include "petscksp.h"
-
-/*Petsc includes: */
-#include "mex.h"
-
-#include "../../../shared/shared.h"
-#include <string>
-
-
-int PetscMatrixToMatlabMatrix(mxArray** pdataref,Mat tmatrix){
-
-	int i,j,k;
-
-	/*output: */
-	mxArray* dataref=NULL;
-	int    rows,cols;
-
-	int ncols;
-	int nnz=0;
-	int nzmax=0;
-	const int* columns=NULL;
-	const double* column_values=NULL;
-	double* matrix_ptr=NULL;
-
-	/*compress row format: */
-	double* val=NULL;
-	mwIndex*    col_ind=NULL;
-	mwIndex*    row_ptr=NULL;
-
-	/*petsc type: */
-	const char* type=NULL;
-	int*    idxm=NULL;
-	int*    idxn=NULL;
-	Mat     matrix=NULL;
-
-	
-	/*First off, we need to transpose the matrix using the Petsc API. We tried using the transpose operation from 
-	 * Matlab, but this ends up creating issues with lost pointers and references: */
-	MatTranspose(tmatrix,MAT_INITIAL_MATRIX,&matrix);
-
-	/*Some needed information: */
-	MatGetType(matrix,&type);
-	MatGetSize(matrix,&rows,&cols);
-
-	if (strcmp(type,MATSEQAIJ)==0){
-		
-		/*Dealing with a sparse sequential matrix: build ir, jc and val, as though it was a row comvalessed 
-		 *format, instead of a column comvalessed format. We'll transpose later.*/
-
-		/*First get nnz: */
-		nnz=0;
-		for(i=0;i<rows;i++){
-			MatGetRow(matrix,i,&ncols,&columns,&column_values);
-			nnz+=ncols;
-			MatRestoreRow(matrix,i,&ncols,&columns,&column_values);
-		}
-
-		if(nnz){
-			nzmax=nnz;
-		}
-		else{
-			nzmax=1; //so a null matrix can be returned.
-		}
-
-		val=(double*)xcalloc(nzmax,sizeof(double));
-		col_ind=(mwIndex*)xcalloc(nzmax,sizeof(mwIndex));
-		row_ptr=(mwIndex*)xcalloc((rows+1),sizeof(mwIndex));
-
-		j=0;
-
-		for(i=0;i<rows;i++){
-
-			/*Get row from petsc matrix: */
-			MatGetRow(matrix,i,&ncols,&columns,&column_values);
-
-			/*copy values: */
-			if(ncols)memcpy( val+j, column_values,ncols*sizeof(double));
-			  
-			for(k=0;k<ncols;k++) col_ind[j+k]=(mwIndex)columns[k];
-			row_ptr[i]=(mwIndex)j;
-			
-			j+=ncols;
-			
-			/*restore petsc row, otherwise we are leaking memory: */
-			MatRestoreRow(matrix,i,&ncols,&columns,&column_values);
-		}
-		row_ptr[rows]=(mwIndex)nnz;
-
-		/*Ok, allocate arrays: */
-		dataref = mxCreateSparse((mwSize)0,(mwSize)0,(mwSize)0,mxREAL);
-	
-		/* free first to avoid mem leaks...: */
-		mxFree(mxGetData(dataref));
-		mxFree(mxGetIr(dataref));
-		mxFree(mxGetJc(dataref));
-		
-		/* ...then set data: */
-		mxSetM(dataref,(mwSize)cols);
-		mxSetN(dataref,(mwSize)rows);
-		mxSetNzmax(dataref,(mwSize)nzmax);
-		mxSetData( dataref, val);
-		mxSetIr(dataref,col_ind);
-		mxSetJc(dataref,row_ptr);
-
-	}
-	else{
-		/*Dealing with a dense sequential matrix: recover pointer to the data in the Petsc matrix*/
-
-		idxm=(int*)xmalloc(rows*sizeof(int));
-		idxn=(int*)xmalloc(cols*sizeof(int));
-
-		for(i=0;i<rows;i++)idxm[i]=i;
-		for(i=0;i<cols;i++)idxn[i]=i;
-
-		matrix_ptr=(double*)xmalloc(rows*cols*sizeof(double));
-		MatGetValues(matrix,rows,idxm,cols,idxn,matrix_ptr);
-
-		dataref = mxCreateDoubleMatrix(0,0,mxREAL);
-		mxSetM(dataref,cols);
-		mxSetN(dataref,rows);
-		mxSetPr(dataref,(double*)matrix_ptr);	
-	}
-
-	/*Free ressources:*/
-	MatFree(&matrix);
-
-	/*Assign output pointers: */
-	*pdataref=dataref;
-
-	return 1;
-}
-
-#endif  
Index: /issm/branches/trunk-jpl-damage/src/c/toolkits/petsc/patches/PetscVectorToDoubleVector.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/toolkits/petsc/patches/PetscVectorToDoubleVector.cpp	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/c/toolkits/petsc/patches/PetscVectorToDoubleVector.cpp	(revision 12168)
@@ -0,0 +1,44 @@
+/* \file PetscVectorToDoubleVector.cpp
+ */
+
+#ifdef HAVE_CONFIG_H
+	#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+#include <string>
+
+/*Petsc includes: */
+#include "petscmat.h"
+#include "petscvec.h"
+#include "petscksp.h"
+
+#include "../../../shared/shared.h"
+
+void PetscVectorToDoubleVector(double** pvector, int* prows, Vec petsc_vector){
+
+	int     i;
+	int     rows;
+	int    *idxm   = NULL;
+	double *vector = NULL;
+
+	/*Get size of vector: */
+	if(petsc_vector){
+		VecGetSize(petsc_vector,&rows);
+		if(rows){
+			idxm=(int*)xmalloc(rows*sizeof(int));
+			vector=(double*)xmalloc(rows*sizeof(double));
+			for(i=0;i<rows;i++)idxm[i]=i;
+
+			VecGetValues(petsc_vector,rows,idxm,vector);
+		}
+	}
+	else{
+		rows=0;
+	}
+
+	/*Assign output pointers: */
+	*pvector=vector;
+	*prows=rows;
+}
Index: sm/branches/trunk-jpl-damage/src/c/toolkits/petsc/patches/PetscVectorToMatlabVector.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/toolkits/petsc/patches/PetscVectorToMatlabVector.cpp	(revision 12167)
+++ 	(revision )
@@ -1,66 +1,0 @@
-/* \file PetscVectorToMatlabVector.cpp
- * \brief: convert a sparse or dense Petsc vector into a matlab vector
- */
-
-
-#ifdef HAVE_CONFIG_H
-	#include <config.h>
-#else
-#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
-#endif
-
-
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-
-/*Petsc includes: */
-#include "petscmat.h"
-#include "petscvec.h"
-#include "petscksp.h"
-
-/*Petsc includes: */
-#include "mex.h"
-
-#include "../../../shared/shared.h"
-#include <string>
-
-
-int PetscVectorToMatlabVector(mxArray** pdataref,Vec vector){
-
-	int     i;
-	int     rows;
-	int    *idxm   = NULL;
-	double *values = NULL;
-
-	/*output: */
-	mxArray* dataref=NULL;
-
-	/*Get size of vector: */
-	if(vector){
-		VecGetSize(vector,&rows);
-		if(rows){
-			idxm=(int*)xmalloc(rows*sizeof(int));
-			values=(double*)xmalloc(rows*sizeof(double));
-			for(i=0;i<rows;i++)idxm[i]=i;
-
-			VecGetValues(vector,rows,idxm,values);
-		}
-	}
-	else{
-		rows=0;
-	}
-
-	/*Using values, build a matlab vector: */
-	dataref = mxCreateDoubleMatrix(0,0,mxREAL);
-	mxSetM(dataref,rows);
-	mxSetN(dataref,1);
-	mxSetPr(dataref,(double*)values);	
-
-	/*Some logic here to make the vector sparse? Although this could slow down the code quite a bit: */
-
-	/*Assign output pointers: */
-	*pdataref=dataref;
-
-	return 1;
-}
-
-#endif  //#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
Index: /issm/branches/trunk-jpl-damage/src/c/toolkits/petsc/patches/petscpatches.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/toolkits/petsc/patches/petscpatches.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/toolkits/petsc/patches/petscpatches.h	(revision 12168)
@@ -15,12 +15,4 @@
 
 class Parameters;
-
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-#include "mex.h"
-int MatlabMatrixToPetscMatrix(Mat* matrix,int* prows,int* pcols, const mxArray* mxmatrix);
-int MatlabVectorToPetscVector(Vec* pvector,int* pvector_rows,const mxArray* mxvector);
-int PetscMatrixToMatlabMatrix(mxArray** pdataref,Mat matrix);
-int PetscVectorToMatlabVector(mxArray** pdataref,Vec vector);
-#endif
 
 Vec NewVec(int size,bool fromlocalsize=false);
@@ -51,3 +43,6 @@
 MatType ISSMToPetscMatrixType(MatrixType type);
 
+void PetscMatrixToDoubleMatrix(double** pmatrix, int* prows, int* pcols,Mat matrix);
+void PetscVectorToDoubleVector(double** pvector, int* prows, Vec vector);
+
 #endif
Index: /issm/branches/trunk-jpl-damage/src/c/toolkits/python/pythonincludes.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/toolkits/python/pythonincludes.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/toolkits/python/pythonincludes.h	(revision 12168)
@@ -7,8 +7,19 @@
 
 
+#ifdef HAVE_CONFIG_H
+	#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+#if _PYTHON_MAJOR_ == 2
+#undef NPY_NO_DEPRECATED_API
+#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
+#else
+#define NPY_NO_DEPRECATED_API 
+#endif
+
 #include "Python.h"
 #include "arrayobject.h"
-
-
 
 #ifdef _HAVE_BOOST_
Index: /issm/branches/trunk-jpl-damage/src/c/toolkits/toolkits.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/toolkits/toolkits.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/toolkits/toolkits.h	(revision 12168)
@@ -12,5 +12,5 @@
 #endif
 
-#if defined(_HAVE_PYTHON_) && defined(_SERIAL_)
+#ifdef _HAVE_PYTHON_
 #include "./python/pythonincludes.h"
 #endif
@@ -20,13 +20,13 @@
 #endif
 
-#if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
-#include "./matlab/matlabincludes.h"
+#ifdef _HAVE_MPI_
+#include "./mpi/mpiincludes.h"
 #endif
 
+#ifdef _HAVE_METIS_
+#include "./metis/metisincludes.h"
+#endif
 
-#include "./mpi/mpiincludes.h"
-#include "./metis/metisincludes.h"
 #include "./triangle/triangleincludes.h"
-#include "./double/double.h"
 #include "./toolkitsenums.h"
 #include "./issm/issmtoolkit.h"
Index: /issm/branches/trunk-jpl-damage/src/c/toolkits/triangle/triangleincludes.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/toolkits/triangle/triangleincludes.h	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/c/toolkits/triangle/triangleincludes.h	(revision 12168)
@@ -6,6 +6,4 @@
 #define _TRIANGLE_INCLUDES_H_
 
-#ifdef _SERIAL_
-
 #ifdef _C_ //only valid for iso C, not C++
 /*Triangle includes: */
@@ -13,6 +11,4 @@
 #endif //#ifdef _C_
 
-#endif //ifdef _SERIAL_
-
 
 #endif
Index: /issm/branches/trunk-jpl-damage/src/dox/issm.dox
===================================================================
--- /issm/branches/trunk-jpl-damage/src/dox/issm.dox	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/dox/issm.dox	(revision 12168)
@@ -46,20 +46,20 @@
 </th>
 <tr>
-<th  bgcolor=#FFFFFF style="text-align:left;"> C++ </th><td  bgcolor=#FFFFFF style="text-align:right;">533</td><td  bgcolor=#FFFFFF style="text-align:right;">15491</td><td  bgcolor=#FFFFFF style="text-align:right;">17275</td><td  bgcolor=#FFFFFF style="text-align:right;">58005</td><td  bgcolor=#FFFFFF style="text-align:right;">90771</td>
+<th  bgcolor=#FFFFFF style="text-align:left;"> C++ </th><td  bgcolor=#FFFFFF style="text-align:right;">499</td><td  bgcolor=#FFFFFF style="text-align:right;">14338</td><td  bgcolor=#FFFFFF style="text-align:right;">16340</td><td  bgcolor=#FFFFFF style="text-align:right;">54651</td><td  bgcolor=#FFFFFF style="text-align:right;">85329</td>
 </tr>
 <tr>
-<th  bgcolor=#C6E2FF style="text-align:left;"> MATLAB </th><td  bgcolor=#C6E2FF style="text-align:right;">977</td><td  bgcolor=#C6E2FF style="text-align:right;">7199</td><td  bgcolor=#C6E2FF style="text-align:right;">13702</td><td  bgcolor=#C6E2FF style="text-align:right;">31690</td><td  bgcolor=#C6E2FF style="text-align:right;">52591</td>
+<th  bgcolor=#C6E2FF style="text-align:left;"> MATLAB </th><td  bgcolor=#C6E2FF style="text-align:right;">919</td><td  bgcolor=#C6E2FF style="text-align:right;">6875</td><td  bgcolor=#C6E2FF style="text-align:right;">13184</td><td  bgcolor=#C6E2FF style="text-align:right;">30350</td><td  bgcolor=#C6E2FF style="text-align:right;">50409</td>
 </tr>
 <tr>
-<th  bgcolor=#FFFFFF style="text-align:left;"> C/C++  Header </th><td  bgcolor=#FFFFFF style="text-align:right;">399</td><td  bgcolor=#FFFFFF style="text-align:right;">3069</td><td  bgcolor=#FFFFFF style="text-align:right;">2727</td><td  bgcolor=#FFFFFF style="text-align:right;">10358</td><td  bgcolor=#FFFFFF style="text-align:right;">16154</td>
+<th  bgcolor=#FFFFFF style="text-align:left;"> C/C++  Header </th><td  bgcolor=#FFFFFF style="text-align:right;">366</td><td  bgcolor=#FFFFFF style="text-align:right;">2665</td><td  bgcolor=#FFFFFF style="text-align:right;">2529</td><td  bgcolor=#FFFFFF style="text-align:right;">9400</td><td  bgcolor=#FFFFFF style="text-align:right;">14594</td>
 </tr>
 <tr>
-<th  bgcolor=#C6E2FF style="text-align:left;"> m4 </th><td  bgcolor=#C6E2FF style="text-align:right;">7</td><td  bgcolor=#C6E2FF style="text-align:right;">1061</td><td  bgcolor=#C6E2FF style="text-align:right;">242</td><td  bgcolor=#C6E2FF style="text-align:right;">8941</td><td  bgcolor=#C6E2FF style="text-align:right;">10244</td>
+<th  bgcolor=#C6E2FF style="text-align:left;"> m4 </th><td  bgcolor=#C6E2FF style="text-align:right;">7</td><td  bgcolor=#C6E2FF style="text-align:right;">993</td><td  bgcolor=#C6E2FF style="text-align:right;">80</td><td  bgcolor=#C6E2FF style="text-align:right;">8237</td><td  bgcolor=#C6E2FF style="text-align:right;">9310</td>
 </tr>
 <tr>
-<th  bgcolor=#FFFFFF style="text-align:left;"> Objective  C </th><td  bgcolor=#FFFFFF style="text-align:right;">9</td><td  bgcolor=#FFFFFF style="text-align:right;">98</td><td  bgcolor=#FFFFFF style="text-align:right;">0</td><td  bgcolor=#FFFFFF style="text-align:right;">370</td><td  bgcolor=#FFFFFF style="text-align:right;">468</td>
+<th  bgcolor=#FFFFFF style="text-align:left;"> Python </th><td  bgcolor=#FFFFFF style="text-align:right;">47</td><td  bgcolor=#FFFFFF style="text-align:right;">183</td><td  bgcolor=#FFFFFF style="text-align:right;">518</td><td  bgcolor=#FFFFFF style="text-align:right;">1099</td><td  bgcolor=#FFFFFF style="text-align:right;">1800</td>
 </tr>
 <tr>
-<th  bgcolor=#C6E2FF style="text-align:left;"> Bourne  Shell </th><td  bgcolor=#C6E2FF style="text-align:right;">8</td><td  bgcolor=#C6E2FF style="text-align:right;">61</td><td  bgcolor=#C6E2FF style="text-align:right;">98</td><td  bgcolor=#C6E2FF style="text-align:right;">271</td><td  bgcolor=#C6E2FF style="text-align:right;">430</td>
+<th  bgcolor=#C6E2FF style="text-align:left;"> Objective  C </th><td  bgcolor=#C6E2FF style="text-align:right;">9</td><td  bgcolor=#C6E2FF style="text-align:right;">98</td><td  bgcolor=#C6E2FF style="text-align:right;">0</td><td  bgcolor=#C6E2FF style="text-align:right;">370</td><td  bgcolor=#C6E2FF style="text-align:right;">468</td>
 </tr>
 <tr>
@@ -67,14 +67,14 @@
 </tr>
 <tr>
-<th  bgcolor=#C6E2FF style="text-align:left;"> IDL </th><td  bgcolor=#C6E2FF style="text-align:right;">1</td><td  bgcolor=#C6E2FF style="text-align:right;">18</td><td  bgcolor=#C6E2FF style="text-align:right;">4</td><td  bgcolor=#C6E2FF style="text-align:right;">124</td><td  bgcolor=#C6E2FF style="text-align:right;">146</td>
+<th  bgcolor=#C6E2FF style="text-align:left;"> Bourne  Shell </th><td  bgcolor=#C6E2FF style="text-align:right;">5</td><td  bgcolor=#C6E2FF style="text-align:right;">46</td><td  bgcolor=#C6E2FF style="text-align:right;">71</td><td  bgcolor=#C6E2FF style="text-align:right;">226</td><td  bgcolor=#C6E2FF style="text-align:right;">343</td>
 </tr>
 <tr>
-<th  bgcolor=#FFFFFF style="text-align:left;"> C </th><td  bgcolor=#FFFFFF style="text-align:right;">2</td><td  bgcolor=#FFFFFF style="text-align:right;">3</td><td  bgcolor=#FFFFFF style="text-align:right;">3</td><td  bgcolor=#FFFFFF style="text-align:right;">24</td><td  bgcolor=#FFFFFF style="text-align:right;">30</td>
+<th  bgcolor=#FFFFFF style="text-align:left;"> IDL </th><td  bgcolor=#FFFFFF style="text-align:right;">1</td><td  bgcolor=#FFFFFF style="text-align:right;">18</td><td  bgcolor=#FFFFFF style="text-align:right;">4</td><td  bgcolor=#FFFFFF style="text-align:right;">124</td><td  bgcolor=#FFFFFF style="text-align:right;">146</td>
 </tr>
 <tr>
-<th  bgcolor=#C6E2FF style="text-align:left;"> Python </th><td  bgcolor=#C6E2FF style="text-align:right;">2</td><td  bgcolor=#C6E2FF style="text-align:right;">1</td><td  bgcolor=#C6E2FF style="text-align:right;">4</td><td  bgcolor=#C6E2FF style="text-align:right;">13</td><td  bgcolor=#C6E2FF style="text-align:right;">18</td>
+<th  bgcolor=#C6E2FF style="text-align:left;"> C </th><td  bgcolor=#C6E2FF style="text-align:right;">2</td><td  bgcolor=#C6E2FF style="text-align:right;">3</td><td  bgcolor=#C6E2FF style="text-align:right;">3</td><td  bgcolor=#C6E2FF style="text-align:right;">24</td><td  bgcolor=#C6E2FF style="text-align:right;">30</td>
 </tr>
 <tr>
-<th  bgcolor=#FFFFFF style="text-align:left;"> SUM: </th><td  bgcolor=#FFFFFF style="text-align:right;">1941</td><td  bgcolor=#FFFFFF style="text-align:right;">27022</td><td  bgcolor=#FFFFFF style="text-align:right;">34078</td><td  bgcolor=#FFFFFF style="text-align:right;">110036</td><td  bgcolor=#FFFFFF style="text-align:right;">171136</td>
+<th  bgcolor=#FFFFFF style="text-align:left;"> SUM: </th><td  bgcolor=#FFFFFF style="text-align:right;">1858</td><td  bgcolor=#FFFFFF style="text-align:right;">25240</td><td  bgcolor=#FFFFFF style="text-align:right;">32752</td><td  bgcolor=#FFFFFF style="text-align:right;">104721</td><td  bgcolor=#FFFFFF style="text-align:right;">162713</td>
 </tr>
 </table>
Index: /issm/branches/trunk-jpl-damage/src/m/Makefile.am
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/Makefile.am	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/m/Makefile.am	(revision 12168)
@@ -13,9 +13,5 @@
 				./planet/*.m \
 				./qmu/*.m \
-				./shared/*.m \
-				./solutions/*.m \
-				./solvers/*.m \
 				./utils/*.m \
-				./utils/Analysis/*.m \
 				./utils/Array/*.m \
 				./utils/BC/*.m \
Index: /issm/branches/trunk-jpl-damage/src/m/classes/autodiff.py
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/classes/autodiff.py	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/m/classes/autodiff.py	(revision 12168)
@@ -0,0 +1,28 @@
+#module imports
+from fielddisplay import fielddisplay
+
+class autodiff:
+	#properties
+	def __init__(self):
+		# {{{ Properties
+		self.isautodiff = False
+		self.forward    = True
+		self.reverse    = False
+
+		#set defaults
+		self.setdefaultparameters()
+
+		#}}}
+	def __repr__(obj):
+		# {{{ Display
+		string='   automatic differentiation parameters:'
+		string="%s\n%s"%(string,fielddisplay(obj,'isautodiff','indicates if the automatic differentiation is activated'))
+		string="%s\n%s"%(string,fielddisplay(obj,'forward','forward differentiation'))
+		string="%s\n%s"%(string,fielddisplay(obj,'reverse','backward differentiation'))
+		return string
+		#}}}
+	def setdefaultparameters(obj):
+		# {{{setdefaultparameters
+		return obj
+	#}}}
+
Index: /issm/branches/trunk-jpl-damage/src/m/classes/balancethickness.py
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/classes/balancethickness.py	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/m/classes/balancethickness.py	(revision 12168)
@@ -0,0 +1,33 @@
+#module imports
+from fielddisplay import fielddisplay
+class balancethickness:
+	#properties
+	def __init__(self):
+		# {{{ Properties
+		self.spcthickness = float('NaN')
+		self.thickening_rate           = float('NaN')
+		self.stabilization           = 0
+
+		#set defaults
+		self.setdefaultparameters()
+
+		#}}}
+	def __repr__(obj):
+		# {{{ Display
+		
+		string='   balance thickness solution parameters:' 
+		
+		string="%s\n\n%s"%(string,fielddisplay(obj,'spcthickness','thickness constraints (NaN means no constraint)'))
+		string="%s\n%s"%(string,fielddisplay(obj,'thickening_rate','ice thickening rate used in the mass conservation (dh/dt)'))
+		string="%s\n%s"%(string,fielddisplay(obj,'stabilization','0: None, 1: SU, 2: MacAyeal''s artificial diffusivity, 3:DG'))
+		return string
+		#}}}
+	def setdefaultparameters(obj):
+		# {{{setdefaultparameters
+		
+		#Type of stabilization used
+		obj.stabilization=1
+
+		return obj
+	#}}}
+
Index: /issm/branches/trunk-jpl-damage/src/m/classes/basalforcings.py
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/classes/basalforcings.py	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/m/classes/basalforcings.py	(revision 12168)
@@ -0,0 +1,29 @@
+#module imports
+from fielddisplay import fielddisplay
+
+class basalforcings:
+	#properties
+	def __init__(self):
+		# {{{ Properties
+		self.melting_rate             = float('NaN')
+		self.melting_rate_correction  = float('NaN')
+		self.geothermalflux           = float('NaN')
+
+		#set defaults
+		self.setdefaultparameters()
+
+		#}}}
+	def __repr__(obj):
+		# {{{ Display
+		string="   basal forcings parameters:"
+
+		string="%s\n\n%s"%(string,fielddisplay(obj,"melting_rate","basal melting rate (positive if melting)"))
+		string="%s\n%s"%(string,fielddisplay(obj,"melting_rate_correction","additional melting applied when the grounding line retreats"))
+		string="%s\n%s"%(string,fielddisplay(obj,"geothermalflux","geothermal heat flux [W/m^2]"))
+		return string
+		#}}}
+	def setdefaultparameters(obj):
+		# {{{setdefaultparameters
+		return obj
+	#}}}
+
Index: /issm/branches/trunk-jpl-damage/src/m/classes/clusters/generic.m
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/classes/clusters/generic.m	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/m/classes/clusters/generic.m	(revision 12168)
@@ -2,5 +2,4 @@
 %
 %   Usage:
-%      cluster=generic('name','astrid',);
 %      cluster=generic('name','astrid','np',3);
 %      cluster=generic('name',oshostname(),'np',3,'login','username');
@@ -14,9 +13,9 @@
 		 port=0;
 		 interactive=1;
-		 codepath=[issmtier() '/bin'];
-		 executionpath=[issmtier() '/execution'];
-		 valgrind=[issmtier() '/externalpackages/valgrind/install/bin/valgrind'];
-		 valgrindlib=[issmtier() '/externalpackages/valgrind/install/lib/libmpidebug.so'];
-		 valgrindsup=[issmtier() '/externalpackages/valgrind/issm.supp'];
+		 codepath=[issmdir() '/bin'];
+		 executionpath=[issmdir() '/execution'];
+		 valgrind=[issmdir() '/externalpackages/valgrind/install/bin/valgrind'];
+		 valgrindlib=[issmdir() '/externalpackages/valgrind/install/lib/libmpidebug.so'];
+		 valgrindsup=[issmdir() '/externalpackages/valgrind/issm.supp'];
 		 %}}}
 	 end
@@ -28,6 +27,5 @@
 
 			 %get name
-			 if ~exist(options,'name'), error('option ''name'' has not been provided'); end
-			 cluster.name=getfieldvalue(options,'name');
+			 cluster.name=getfieldvalue(options,'name',oshostname());
 
 			 %initialize cluster using user settings if provided
Index: /issm/branches/trunk-jpl-damage/src/m/classes/clusters/generic.py
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/classes/clusters/generic.py	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/m/classes/clusters/generic.py	(revision 12168)
@@ -0,0 +1,217 @@
+#GENERIC cluster class definition
+#
+#   Usage:
+#      cluster=generic('name','astrid',);
+#      cluster=generic('name','astrid','np',3);
+#      cluster=generic('name',oshostname(),'np',3,'login','username');
+
+
+class generic:
+	#properties
+	def __init__(self):
+		# {{{ Properties
+		self.name=''
+		self.login=''
+		self.np=1
+		self.port=0
+		self.interactive=1
+		self.codepath=issmdir() + '/bin'
+		self.executionpath=issmdir() + '/execution'
+		self.valgrind=issmdir() + '/externalpackages/valgrind/install/bin/valgrind'
+		self.valgrindlib=issmdir() + '/externalpackages/valgrind/install/lib/libmpidebug.so'
+		self.valgrindsup=issmdir() + '/externalpackages/valgrind/issm.supp'
+		#}}}
+	def __repr__(obj):
+		# {{{ Display
+		
+		string="class 'generic' object:"
+		string="%s\n\n%s"%(string,"%s%s"%('    name: ',obj.name))
+		string="%s\n%s"%(string,"%s%i"%('    np: ',obj.np))
+		string="%s\n%s"%(string,"%s%i"%('    port: ',obj.port))
+		string="%s\n%s"%(string,"%s%s"%('    codepath: ',obj.codepath))
+		string="%s\n%s"%(string,"%s%s"%('    executionpath: ',obj.executionpath))
+		string="%s\n%s"%(string,"%s%s"%('    valgrind: ',obj.valgrind))
+		string="%s\n%s"%(string,"%s%s"%('    valgrindlib: ',obj.valgrindlib))
+		string="%s\n%s"%(string,"%s%s"%('    valgrindsup: ',obj.valgrindsup))
+		return string
+		#}}}
+		
+
+#old matlab
+#		function cluster=generic(varargin) % {{{1
+#
+#			 %use provided options to change fields
+#			 options=pairoptions(varargin{:});
+#
+#			 %get name
+#			 if ~exist(options,'name'), error('option ''name'' has not been provided'); end
+#			 cluster.name=getfieldvalue(options,'name');
+#
+#			 %initialize cluster using user settings if provided
+#			 if (exist([cluster.name '_settings'])==2), eval([cluster.name '_settings']); end
+#
+#			 %OK get other fields
+#			 for i=1:size(options.list,1),
+#				 fieldname=options.list{i,1};
+#				 fieldvalue=options.list{i,2};
+#				 if ismember(fieldname,properties('generic')),
+#					 cluster.(fieldname)=fieldvalue;
+#				 else
+#					 disp(['''' fieldname ''' is not a property of cluster generic']);
+#				 end
+#			 end
+#		 end
+#		 %}}}
+#		 function checkconsistency(cluster,md,solution,analyses) % {{{1
+#			 if cluster.np<1
+#				 checkmessage(['number of processors should be at least 1']);
+#			 end
+#			 if isnan(cluster.np),
+#				 checkessage('number of processors should not be NaN!');
+#			 end
+#		 end
+#		 %}}}
+#		 function BuildQueueScript(cluster,md) % {{{1
+#		 
+#			 %retrieve parameters
+#			 modelname=md.miscellaneous.name;
+#			 solution=md.private.solution;
+#			 isvalgrind=md.debug.valgrind;
+#			 isgprof=md.debug.gprof;
+#
+#			 %open file for writing: 
+#			 if ~ispc,
+#				 fid=fopen([modelname '.queue'],'w');
+#			 else
+#				 fid=fopen([modelname '.bat'],'w');
+#			 end
+#
+#			 %write instructions for launching a job on the cluster
+#			 if ~ispc,
+#				 fprintf(fid,'#!/bin/sh\n');
+#			 else
+#				 fprintf(fid,'@echo off\n');
+#			 end
+#			 
+#			 if ~isvalgrind,
+#				 if cluster.interactive
+#					 if ~ispc,
+#						 fprintf(fid,'mpiexec -np %i %s/issm.exe %s %s %s ',cluster.np,cluster.codepath,EnumToString(solution),cluster.executionpath,modelname);
+#					 else
+#						 fprintf(fid,'"%s/issm.exe" %s "%s" %s ',cluster.codepath,EnumToString(solution),cluster.executionpath,modelname);
+#					 end
+#				 else
+#					 if ~ispc,
+#						 fprintf(fid,'mpiexec -np %i %s/issm.exe %s %s %s 2> %s.errlog >%s.outlog ',cluster.np,cluster.codepath,EnumToString(solution),cluster.executionpath,modelname,modelname,modelname);
+#					 else
+#						 fprintf(fid,'"%s/issm.exe" %s "%s" %s 2> %s.errlog >%s.outlog ',cluster.codepath,EnumToString(solution),cluster.executionpath,modelname,modelname,modelname);
+#					 end
+#				 end
+#			 else
+#				 if ~ispc,
+#					 %Add --gen-suppressions=all to get suppression lines
+#					 fprintf(fid,'LD_PRELOAD=%s \\\n',cluster.valgrindlib);
+#					 fprintf(fid,'mpiexec -np %i %s --leak-check=full --suppressions=%s %s/issm.exe %s %s %s 2> %s.errlog >%s.outlog ',...
+#					 cluster.np,cluster.valgrind,cluster.valgrindsup, cluster.codepath,EnumToString(solution),cluster.executionpath,modelname,modelname,modelname);
+#				 else
+#					 error('valgrind not supported on windows platforms');
+#				 end
+#			 end
+#
+#			 if isgprof,
+#				 if ~ispc,
+#					 fprintf(fid,'\n gprof %s/issm.exe gmon.out > %s.performance',cluster.codepath,modelname);
+#				 else
+#					 error('gprof not supported on windows platforms');
+#				 end
+#
+#			 end
+#
+#			 if ~md.settings.io_gather,
+#				 if ~ispc,
+#					 %concatenate the output files:
+#					 fprintf(fid,'\ncat %s.outbin.* > %s.outbin',modelname,modelname);
+#				 else
+#					 error('iogather not supported on windows platforms');
+#				 end
+#
+#			 end
+#			 
+#			 %close file: 
+#			 fclose(fid);
+#
+#			 %in interactive mode, create a run file, and errlog and outlog file
+#			 if cluster.interactive,
+#				 fid=fopen([modelname '.errlog'],'w'); fclose(fid);
+#				 fid=fopen([modelname '.outlog'],'w'); fclose(fid);
+#			 end
+#
+#
+#		 end
+#		 %}}}
+#		 function LaunchQueueJob(cluster,md,options)% {{{1
+#			 
+#			 if ~ispc,
+#					 %lauch command, to be executed via ssh
+#					 launchcommand=['cd ' cluster.executionpath ' && rm -rf ./' md.private.runtimename ' && mkdir ' md.private.runtimename ...
+#					 ' && cd ' md.private.runtimename ' && mv ../' md.private.runtimename '.tar.gz ./ && tar -zxf ' md.private.runtimename '.tar.gz  && source  ' md.miscellaneous.name '.queue '];
+#
+#					 if ~strcmpi(options.batch,'yes'),
+#
+#						 %compress the files into one zip.
+#						 compressstring=['tar -zcf ' md.private.runtimename '.tar.gz ' md.miscellaneous.name '.bin ' md.miscellaneous.name '.queue '  md.miscellaneous.name '.petsc '];
+#						 if md.qmu.isdakota,
+#							 compressstring=[compressstring md.miscellaneous.name '.qmu.in'];
+#					end
+#					if cluster.interactive,
+#						compressstring=[compressstring ' ' md.miscellaneous.name '.errlog ' md.miscellaneous.name '.outlog '];
+#					end
+#					system(compressstring);
+#
+#					disp('uploading input file and queueing script');
+#					issmscpout(cluster.name,cluster.executionpath,cluster.login,cluster.port,{[md.private.runtimename '.tar.gz']});
+#
+#					disp('launching solution sequence on remote cluster');
+#					issmssh(cluster.name,cluster.login,cluster.port,launchcommand);
+#				else
+#					disp('batch mode requested: not launching job interactively');
+#					disp('launch solution sequence on remote cluster by hand');
+#				end
+#			else
+#				%launch right here, do not compress or archive.
+#				system([md.miscellaneous.name '.bat']);
+#			end
+#
+#		end %}}}
+#		 function Download(cluster,md)% {{{1
+#
+#			if ~ispc,
+#				%some check
+#				if isempty(md.private.runtimename),
+#					error('supply runtime name for results to be loaded!');
+#				end
+#
+#				%Figure out the  directory where all the files are in: 
+#				directory=[cluster.executionpath '/' md.private.runtimename '/'];
+#
+#				%What packages are we picking up from remote cluster
+#				packages={[md.miscellaneous.name '.outlog'],[md.miscellaneous.name '.errlog']};
+#				if md.qmu.isdakota,
+#					packages{end+1}=[md.miscellaneous.name '.qmu.err'];
+#					packages{end+1}=[md.miscellaneous.name '.qmu.out'];
+#					if isfield(md.qmu.params,'tabular_graphics_data'),
+#						if md.qmu.params.tabular_graphics_data==true,
+#							packages{end+1}='dakota_tabular.dat'; 
+#						end
+#					end
+#				else
+#					packages{end+1}=[md.miscellaneous.name '.outbin'];
+#				end
+#
+#				%copy files from cluster to present directory
+#				issmscpin(cluster.name, cluster.login, cluster.port, directory, packages);
+#			else
+#				%do nothing!
+#			end
+#		end %}}}
+#
Index: /issm/branches/trunk-jpl-damage/src/m/classes/clusters/none.m
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/classes/clusters/none.m	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/m/classes/clusters/none.m	(revision 12168)
@@ -12,18 +12,5 @@
     methods
 		 function cluster=none(varargin) % {{{1
-			 cluster=AssignObjectFields(pairoptions(varargin{:}),cluster);
-		 end
-		 %}}}
-		 function disp(cluster) % {{{1
-			 %  display the object
-			 disp(sprintf('cluster class ''%s'' object ''%s'' = ',class(cluster),inputname(1)));
-			 disp(sprintf('    name: %s',cluster.name));
-		 end
-		 %}}}
-		 function checkconsistency(cluster,md,solution,analyses) % {{{1
-		 end
-		 %}}}
-		 function BuildQueueScript(cluster,md) % {{{1
-			 error('none.BuildQueueScript error message: serial cluster cannot build queue script');
+			 error('Cannot assign md.cluster to ''none'': ISSM is not available in serial model anymore');
 		 end
 		 %}}}
Index: /issm/branches/trunk-jpl-damage/src/m/classes/clusters/none.py
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/classes/clusters/none.py	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/m/classes/clusters/none.py	(revision 12168)
@@ -0,0 +1,24 @@
+#NONE cluster class definition
+#
+#   Usage:
+#      cluster=none();
+#      cluster=none('np',3);
+#      cluster=none('np',3,'login','username');
+
+class none:
+	#properties
+	def __init__(self):
+		# {{{ Properties
+		self.name='none'
+		#}}}
+	def __repr__(obj):
+		# {{{ Display
+		
+		string="class 'none' object:"
+		string="%s\n\n%s"%(string,"%s%s"%('    name: ',obj.name))
+		return string
+		#}}}
+	def checkconsistency(cluster,md,solution,analyses):
+		pass
+	def BuildQueueScript(cluster,md):
+			 raise RuntimeError('none.BuildQueueScript error message: serial cluster cannot build queue script')
Index: /issm/branches/trunk-jpl-damage/src/m/classes/constants.py
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/classes/constants.py	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/m/classes/constants.py	(revision 12168)
@@ -0,0 +1,41 @@
+#module imports
+from fielddisplay import fielddisplay
+
+class constants:
+	#properties
+	def __init__(self):
+		# {{{ Properties
+		self.g                    = 0
+		self.yts                  = 0
+		self.referencetemperature = 0
+		
+		#set defaults
+		self.setdefaultparameters()
+
+		#}}}
+	def __repr__(obj):
+		# {{{ Display
+		string="   constants parameters:"
+		string="%s\n\n%s"%(string,fielddisplay(obj,"g","gravitational acceleration"))
+		string="%s\n%s"%(string,fielddisplay(obj,"yts","number of seconds in a year"))
+		string="%s\n%s"%(string,fielddisplay(obj,"referencetemperature","reference temperature used in the enthalpy model"))
+
+
+		return string
+		#}}}
+		
+	def setdefaultparameters(obj):
+		# {{{setdefaultparameters
+		
+		#acceleration due to gravity (m/s^2)
+		obj.g=9.81
+
+		#converstion from year to seconds
+		obj.yts=365*24*3600
+
+		#the reference temperature for enthalpy model (cf Aschwanden)
+		obj.referencetemperature=223.15
+
+		return obj
+	#}}}
+
Index: /issm/branches/trunk-jpl-damage/src/m/classes/debug.py
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/classes/debug.py	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/m/classes/debug.py	(revision 12168)
@@ -0,0 +1,28 @@
+#module imports
+from fielddisplay import fielddisplay
+
+class debug:
+	#properties
+	def __init__(self):
+		# {{{ Properties
+		self.valgrind=False
+		self.gprof   = False
+		
+		#set defaults
+		self.setdefaultparameters()
+
+		#}}}
+	def __repr__(obj):
+		# {{{ Display
+		string="   debug parameters:"
+
+		string="%s\n\n%s"%(string,fielddisplay(obj,"valgrind","use Valgrind to debug (0 or 1)"))
+		string="%s\n%s"%(string,fielddisplay(obj,"gprof","use gnu-profiler to find out where the time is spent"))
+		return string
+		#}}}
+		
+	def setdefaultparameters(obj):
+		# {{{setdefaultparameters
+		return obj
+	#}}}
+
Index: /issm/branches/trunk-jpl-damage/src/m/classes/diagnostic.m
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/classes/diagnostic.m	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/m/classes/diagnostic.m	(revision 12168)
@@ -130,5 +130,5 @@
 			fielddisplay(obj,'spcvy','y-axis velocity constraint (NaN means no constraint)');
 			fielddisplay(obj,'spcvz','z-axis velocity constraint (NaN means no constraint)');
-			fielddisplay(obj,'icefront','segments on ice front list (last column 0-> Air, 1-> Water, 2->Ice');
+			fielddisplay(obj,'icefront','segments on ice front list (last column 0-> Air, 1-> Water, 2->Ice)');
 
 			disp(sprintf('\n      %s','Rift options:'));
Index: /issm/branches/trunk-jpl-damage/src/m/classes/diagnostic.py
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/classes/diagnostic.py	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/m/classes/diagnostic.py	(revision 12168)
@@ -0,0 +1,99 @@
+#module imports
+from fielddisplay import fielddisplay
+
+class diagnostic:
+	#properties
+	def __init__(self):
+		# {{{ Properties
+		self.spcvx                    = float('NaN')
+		self.spcvy                    = float('NaN')
+		self.spcvz                    = float('NaN')
+		self.restol                   = 0
+		self.reltol                   = 0
+		self.abstol                   = 0
+		self.isnewton                 = 0
+		self.stokesreconditioning     = 0
+		self.viscosity_overshoot      = 0
+		self.icefront                 = float('NaN')
+		self.maxiter                  = 0
+		self.shelf_dampening          = 0
+		self.vertex_pairing           = float('NaN')
+		self.penalty_factor           = float('NaN')
+		self.rift_penalty_lock        = float('NaN')
+		self.rift_penalty_threshold   = 0
+		self.referential              = float('NaN')
+		self.requested_outputs        = float('NaN')
+
+		#set defaults
+		self.setdefaultparameters()
+
+		#}}}
+	def __repr__(obj):
+		# {{{ Display
+		
+		
+		string='\n   Diagnostic solution parameters:'
+		string="%s\n\n%s"%(string,'      Convergence criteria:')
+			
+		string="%s\n%s"%(string,fielddisplay(obj,'restol','mechanical equilibrium residual convergence criterion'))
+		string="%s\n%s"%(string,fielddisplay(obj,'reltol','velocity relative convergence criterion, NaN -> not applied'))
+		string="%s\n%s"%(string,fielddisplay(obj,'abstol','velocity absolute convergence criterion, NaN -> not applied'))
+		string="%s\n%s"%(string,fielddisplay(obj,'isnewton','Apply Newton''s method instead of a Picard fixed point method'))
+		string="%s\n%s"%(string,fielddisplay(obj,'maxiter','maximum number of nonlinear iterations'))
+		string="%s\n%s"%(string,fielddisplay(obj,'viscosity_overshoot','over-shooting constant new=new+C*(new-old)'))
+
+		string="%s\n%s"%(string,'      boundary conditions:')
+
+		string="%s\n%s"%(string,fielddisplay(obj,'spcvx','x-axis velocity constraint (NaN means no constraint)'))
+		string="%s\n%s"%(string,fielddisplay(obj,'spcvy','y-axis velocity constraint (NaN means no constraint)'))
+		string="%s\n%s"%(string,fielddisplay(obj,'spcvz','z-axis velocity constraint (NaN means no constraint)'))
+		string="%s\n%s"%(string,fielddisplay(obj,'icefront','segments on ice front list (last column 0-> Air, 1-> Water, 2->Ice'))
+
+		string="%s\n%s"%(string,'      Rift options:')
+		string="%s\n%s"%(string,fielddisplay(obj,'rift_penalty_threshold','threshold for instability of mechanical constraints'))
+		string="%s\n%s"%(string,fielddisplay(obj,'rift_penalty_lock','number of iterations before rift penalties are locked'))
+
+		string="%s\n%s"%(string,'      Penalty options:')
+		string="%s\n%s"%(string,fielddisplay(obj,'penalty_factor','offset used by penalties: penalty = Kmax*10^offset'))
+		string="%s\n%s"%(string,fielddisplay(obj,'vertex_pairing','pairs of vertices that are penalized'))
+
+		string="%s\n%s"%(string,'      Other:')
+		string="%s\n%s"%(string,fielddisplay(obj,'shelf_dampening','use dampening for floating ice ? Only for Stokes model'))
+		string="%s\n%s"%(string,fielddisplay(obj,'stokesreconditioning','multiplier for incompressibility equation. Only for Stokes model'))
+		string="%s\n%s"%(string,fielddisplay(obj,'referential','local referential'))
+		string="%s\n%s"%(string,fielddisplay(obj,'requested_outputs','additional outputs requested'))
+
+		return string
+		#}}}
+		
+	def setdefaultparameters(obj):
+		# {{{setdefaultparameters
+		#maximum of non-linear iterations.
+		obj.maxiter=100
+
+		#Convergence criterion: absolute, relative and residual
+		obj.restol=10**-4;
+		obj.reltol=0.01
+		obj.abstol=10
+
+		obj.stokesreconditioning=10**13
+		obj.shelf_dampening=0
+
+		#Penalty factor applied kappa=max(stiffness matrix)*10^penalty_factor
+		obj.penalty_factor=3
+
+		#coefficient to update the viscosity between each iteration of
+		#a diagnostic according to the following formula
+		#viscosity(n)=viscosity(n)+viscosity_overshoot(viscosity(n)-viscosity(n-1))
+		obj.viscosity_overshoot=0
+
+		#Stop the iterations of rift if below a threshold
+		obj.rift_penalty_threshold=0
+
+		#in some solutions, it might be needed to stop a run when only
+		#a few constraints remain unstable. For thermal computation, this
+		#parameter is often used.
+		obj.rift_penalty_lock=10
+
+		return obj
+	#}}}
Index: /issm/branches/trunk-jpl-damage/src/m/classes/flaim.py
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/classes/flaim.py	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/m/classes/flaim.py	(revision 12168)
@@ -0,0 +1,50 @@
+#module imports
+from fielddisplay import fielddisplay
+
+class flaim:
+	#properties
+	def __init__(self):
+		# {{{ Properties
+		self.targets            = ''
+		self.tracks             = ''
+		self.flightreqs         = {}
+		self.criterion          = float('NaN')
+		self.gridsatequator     = 200000
+		self.usevalueordering   = True
+		self.split_antimeridian = True
+		self.solution           = ''
+		self.quality            = 0
+		self.path_optimize      = False
+		self.opt_ndir           = 1
+		self.opt_dist           = 25
+		self.opt_niter          = 30000
+		#}}}
+	def __repr__(obj):
+		# {{{ Displa
+		string='   FLAIM - Flight Line Adaptation using Ice sheet Modeling:'
+
+		string="%s\n\n%s"%(string,'      Input:')
+		string="%s\n%s"%(string,fielddisplay(obj,'targets'            ,'name of kml output targets file '))
+		string="%s\n%s"%(string,fielddisplay(obj,'tracks'             ,'name of kml input tracks file '))
+		string="%s\n%s"%(string,fielddisplay(obj,'flightreqs'         ,'structure of kml flight requirements (not used yet)'))
+		string="%s\n%s"%(string,fielddisplay(obj,'criterion'          ,'element or nodal criterion for flight path evaluation (metric)'))
+
+		string="%s\n\n%s"%(string,'      Arguments:')
+		string="%s\n%s"%(string,fielddisplay(obj,'gridsatequator'     ,'number of grids at equator (determines resolution)'))
+		string="%s\n%s"%(string,fielddisplay(obj,'usevalueordering'   ,'flag to consider target values for flight path evaluation'))
+		string="%s\n%s"%(string,fielddisplay(obj,'split_antimeridian' ,'flag to split polygons on the antimeridian'))
+		
+		string="%s\n\n%s"%(string,'      Optimization:')
+		string="%s\n%s"%(string,fielddisplay(obj,'path_optimize'     ,'optimize? (default false)'))
+		string="%s\n%s"%(string,fielddisplay(obj,'opt_ndir'     ,['number of directions to test when moving a point.  If this value = 1, a random direction is tested.',\
+										  'A value > 1 results in directions equally spaced from [0, 2*PI] being tested.',\
+										  'For example, 4 would result in directions [0, PI/2, PI, 3PI/2].']))
+		string="%s\n%s"%(string,fielddisplay(obj,'opt_dist'     ,'specifies the distance in km (default 25) to move a randomly selected path point on each iteration'))
+		string="%s\n%s"%(string,fielddisplay(obj,'opt_niter'     ,['number of iterations (default 30,000) to run for flightplan optimization',\
+										   'i.e. the number of times to randomly select a point and move it.']))
+
+		string="%s\n\n%s"%(string,'      Output:')
+		string="%s\n%s"%(string,fielddisplay(obj,'solution'           ,'name of kml solution file'))
+		string="%s\n%s"%(string,fielddisplay(obj,'quality'            ,'quality of kml solution'))
+		return string
+		#}}}
Index: /issm/branches/trunk-jpl-damage/src/m/classes/flowequation.py
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/classes/flowequation.py	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/m/classes/flowequation.py	(revision 12168)
@@ -0,0 +1,41 @@
+#module imports
+from fielddisplay import fielddisplay
+
+class flowequation:
+	#properties
+	def __init__(self):
+		# {{{ Properties
+		
+		self.ismacayealpattyn     = 0;
+		self.ishutter             = 0;
+		self.isstokes             = 0;
+		self.vertex_equation      = float('NaN')
+		self.element_equation     = float('NaN')
+		self.bordermacayeal       = float('NaN')
+		self.borderpattyn         = float('NaN')
+		self.borderstokes         = float('NaN')
+
+		#set defaults
+		self.setdefaultparameters()
+
+		#}}}
+	def __repr__(obj):
+		# {{{ Display
+		string='   flow equation parameters:'
+
+		string="%s\n\n%s"%(string,fielddisplay(obj,'ismacayealpattyn','is the macayeal or pattyn approximation used ?'))
+		string="%s\n%s"%(string,fielddisplay(obj,'ishutter','is the shallow ice approximation used ?'))
+		string="%s\n%s"%(string,fielddisplay(obj,'isstokes','are the Full-Stokes equations used ?'))
+		string="%s\n%s"%(string,fielddisplay(obj,'vertex_equation','flow equation for each vertex'))
+		string="%s\n%s"%(string,fielddisplay(obj,'element_equation','flow equation for each element'))
+		string="%s\n%s"%(string,fielddisplay(obj,'bordermacayeal','vertices on MacAyeal''s border (for tiling)'))
+		string="%s\n%s"%(string,fielddisplay(obj,'borderpattyn','vertices on Pattyn''s border (for tiling)'))
+		string="%s\n%s"%(string,fielddisplay(obj,'borderstokes','vertices on Stokes'' border (for tiling)'))
+		return string
+		#}}}
+		
+	def setdefaultparameters(obj):
+		# {{{setdefaultparameters
+		return obj
+	#}}}
+
Index: /issm/branches/trunk-jpl-damage/src/m/classes/friction.py
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/classes/friction.py	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/m/classes/friction.py	(revision 12168)
@@ -0,0 +1,29 @@
+#module imports
+from fielddisplay import fielddisplay
+
+class friction:
+	#properties
+	def __init__(self):
+		# {{{ Properties
+		self.coefficient = float('NaN')
+		self.p           = float('NaN')
+		self.q           = float('NaN')
+
+		#set defaults
+		self.setdefaultparameters()
+
+		#}}}
+	def __repr__(obj):
+		# {{{ Display
+		string="Sigma= drag^2 * Neff ^r * u ^s, with Neff=rho_ice*g*thickness+rho_water*g*bed, r=q/p and s=1/p"
+		string="%s\n\n%s"%(string,fielddisplay(obj,"coefficient","friction coefficient [SI]"))
+		string="%s\n%s"%(string,fielddisplay(obj,"p","p exponent"))
+		string="%s\n%s"%(string,fielddisplay(obj,"q","q exponent"))
+		return string
+		#}}}
+
+	def setdefaultparameters(obj):
+		# {{{setdefaultparameters
+		return obj
+	#}}}
+
Index: /issm/branches/trunk-jpl-damage/src/m/classes/geometry.py
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/classes/geometry.py	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/m/classes/geometry.py	(revision 12168)
@@ -0,0 +1,35 @@
+#module imports
+from fielddisplay import fielddisplay
+
+class geometry:
+	#properties
+	def __init__(self):
+		# {{{ Properties
+		self.surface           = float('NaN')
+		self.thickness         = float('NaN')
+		self.bed               = float('NaN')
+		self.bathymetry        = float('NaN')
+		self.hydrostatic_ratio = float('NaN')
+
+		#set defaults
+		self.setdefaultparameters()
+
+		#}}}
+	def __repr__(obj):
+		# {{{ Display
+
+		string="   geometry parameters:"
+
+		string="%s\n\n%s"%(string,fielddisplay(obj,'surface','surface elevation'))
+		string="%s\n%s"%(string,fielddisplay(obj,'thickness','ice thickness'))
+		string="%s\n%s"%(string,fielddisplay(obj,'bed','bed elevation'))
+		string="%s\n%s"%(string,fielddisplay(obj,'bathymetry','bathymetry elevation'))
+		string="%s\n%s"%(string,fielddisplay(obj,'hydrostatic_ratio','coefficient for ice shelves'' thickness correction: hydrostatic_ratio H_obs+ (1-hydrostatic_ratio) H_hydro'))
+		return string
+		#}}}
+		
+	def setdefaultparameters(obj):
+		# {{{setdefaultparameters
+		return obj
+	#}}}
+
Index: /issm/branches/trunk-jpl-damage/src/m/classes/groundingline.m
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/classes/groundingline.m	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/m/classes/groundingline.m	(revision 12168)
@@ -37,5 +37,5 @@
 				end
 				pos=find(md.mask.vertexongroundedice); 
-				if any(md.geometry.bed(pos)-md.geometry.bathymetry(pos)),
+				if any(abs(md.geometry.bed(pos)-md.geometry.bathymetry(pos))>10^-10),
 					checkmessage(['bathymetry not equal to bed on grounded ice !']);
 				end
Index: /issm/branches/trunk-jpl-damage/src/m/classes/groundingline.py
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/classes/groundingline.py	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/m/classes/groundingline.py	(revision 12168)
@@ -0,0 +1,34 @@
+#module imports
+from fielddisplay import fielddisplay
+
+class groundingline:
+	#properties
+	def __init__(self):
+		# {{{ Properties
+		self.migration=''
+		self.melting_rate=float('NaN')
+
+		#set defaults
+		self.setdefaultparameters()
+
+		#}}}
+	def __repr__(obj):
+		# {{{ Display
+		string='   grounding line solution parameters:'
+
+		string="%s\n\n%s"%(string,fielddisplay(obj,'migration','type of grounding line migration: ''SoftMigration'',''AgressiveMigration'' or ''None'''))
+		string="%s\n%s"%(string,fielddisplay(obj,'melting_rate','melting rate applied when previously grounded parts start floating'))
+		return string
+		#}}}	
+	def setdefaultparameters(obj):
+		# {{{setdefaultparameters
+
+		#Type of migration
+		obj.migration='None'
+
+		#basal melting rate correction: 
+		obj.melting_rate=0;
+
+		return obj
+	#}}}
+
Index: /issm/branches/trunk-jpl-damage/src/m/classes/hydrology.py
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/classes/hydrology.py	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/m/classes/hydrology.py	(revision 12168)
@@ -0,0 +1,50 @@
+#module imports
+from fielddisplay import fielddisplay
+
+class hydrology:
+	#properties
+	def __init__(self):
+		# {{{ Properties
+		self.spcwatercolumn = float('NaN')
+		self.n              = 0
+		self.CR             = 0
+		self.p              = 0
+		self.q              = 0
+		self.kn             = 0
+		self.stabilization  = 0
+
+		#set defaults
+		self.setdefaultparameters()
+
+	
+		#}}}
+	def __repr__(obj):
+		# {{{ Display
+		
+		string='   hydrology solution parameters:'
+		string="%s\n\n%s"%(string,fielddisplay(obj,'spcwatercolumn','water thickness constraints (NaN means no constraint)'))
+		string="%s\n%s"%(string,fielddisplay(obj,'n','Manning roughness coefficient'))
+		string="%s\n%s"%(string,fielddisplay(obj,'CR','tortuosity parameter'))
+		string="%s\n%s"%(string,fielddisplay(obj,'p','dimensionless exponent in Manning velocity formula'))
+		string="%s\n%s"%(string,fielddisplay(obj,'q','dimensionless exponent in Manning velocity formula'))
+		string="%s\n%s"%(string,fielddisplay(obj,'kn','parameter in effective pressure formula'))
+		string="%s\n%s"%(string,fielddisplay(obj,'stabilization','artificial diffusivity (default is 1). can be more than 1 to increase diffusivity.'))
+		return string
+		#}}}
+		
+	def setdefaultparameters(obj):
+		# {{{setdefaultparameters
+		
+		#Parameters from Johnson's 2002 thesis, section 3.5.4			 
+		obj.n=.02			
+		obj.CR=.01
+		obj.p=2
+		obj.q=1
+		obj.kn=0
+
+		#Type of stabilization to use 0:nothing 1:artificial_diffusivity
+		obj.stabilization=1
+
+		return obj
+	#}}}
+
Index: /issm/branches/trunk-jpl-damage/src/m/classes/initialization.py
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/classes/initialization.py	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/m/classes/initialization.py	(revision 12168)
@@ -0,0 +1,42 @@
+#module imports
+from fielddisplay import fielddisplay
+
+class initialization:
+	#properties
+	def __init__(self):
+		# {{{ Properties
+		
+		self.vx            = float('NaN')
+		self.vy            = float('NaN')
+		self.vz            = float('NaN')
+		self.vel           = float('NaN')
+		self.pressure      = float('NaN')
+		self.temperature   = float('NaN')
+		self.watercolumn   = float('NaN')
+		self.waterfraction = float('NaN')
+
+		#set defaults
+		self.setdefaultparameters()
+
+		#}}}
+	def __repr__(obj):
+		# {{{ Display
+		string='   initial field values:'
+
+		string="%s\n%s"%(string,fielddisplay(obj,'vx','x component of velocity'))
+		string="%s\n%s"%(string,fielddisplay(obj,'vy','y component of velocity'))
+		string="%s\n%s"%(string,fielddisplay(obj,'vz','z component of velocity'))
+		string="%s\n%s"%(string,fielddisplay(obj,'vel','velocity norm'))
+		string="%s\n%s"%(string,fielddisplay(obj,'pressure','pressure field'))
+		string="%s\n%s"%(string,fielddisplay(obj,'temperature','temperature in Kelvins'))
+		string="%s\n%s"%(string,fielddisplay(obj,'watercolumn','thickness of subglacial water'))
+		string="%s\n%s"%(string,fielddisplay(obj,'waterfraction','fraction of water in the ice'))
+
+		return string
+		#}}}
+		
+	def setdefaultparameters(obj):
+		# {{{setdefaultparameters
+		return obj
+	#}}}
+
Index: /issm/branches/trunk-jpl-damage/src/m/classes/inversion.py
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/classes/inversion.py	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/m/classes/inversion.py	(revision 12168)
@@ -0,0 +1,104 @@
+#module imports
+from fielddisplay import fielddisplay
+
+class inversion:
+	#properties
+	def __init__(self):
+		# {{{ Properties
+		self.iscontrol                   = 0
+		self.tao                         = 0
+		self.incomplete_adjoint          = 0
+		self.control_parameters          = float('NaN')
+		self.nsteps                      = 0
+		self.maxiter_per_step            = float('NaN')
+		self.cost_functions              = float('NaN')
+		self.cost_functions_coefficients = float('NaN')
+		self.gradient_scaling            = float('NaN')
+		self.cost_function_threshold     = 0
+		self.min_parameters              = float('NaN')
+		self.max_parameters              = float('NaN')
+		self.step_threshold              = float('NaN')
+		self.gradient_only               = 0
+		self.vx_obs                      = float('NaN')
+		self.vy_obs                      = float('NaN')
+		self.vz_obs                      = float('NaN')
+		self.vel_obs                     = float('NaN')
+		self.thickness_obs               = float('NaN')
+		#}}}
+	def __repr__(obj):
+		# {{{ Display
+		string='\n   Inversion parameters:'
+		string="%s\n%s"%(string,fielddisplay(obj,'iscontrol','is inversion activated?'))
+		string="%s\n%s"%(string,fielddisplay(obj,'incomplete_adjoint','do we assume linear viscosity?'))
+		string="%s\n%s"%(string,fielddisplay(obj,'control_parameters','parameter where inverse control is carried out; ex: {''FrictionCoefficient''}, or {''MaterialsRheologyBbar''}'))
+		string="%s\n%s"%(string,fielddisplay(obj,'nsteps','number of optimization searches'))
+		string="%s\n%s"%(string,fielddisplay(obj,'cost_functions','indicate the type of response for each optimization step'))
+		string="%s\n%s"%(string,fielddisplay(obj,'cost_functions_coefficients','cost_functions_coefficients applied to the misfit of each vertex and for each control_parameter'))
+		string="%s\n%s"%(string,fielddisplay(obj,'cost_function_threshold','misfit convergence criterion. Default is 1%, NaN if not applied'))
+		string="%s\n%s"%(string,fielddisplay(obj,'maxiter_per_step','maximum iterations during each optimization step'))
+		string="%s\n%s"%(string,fielddisplay(obj,'gradient_scaling','scaling factor on gradient direction during optimization, for each optimization step'))
+		string="%s\n%s"%(string,fielddisplay(obj,'step_threshold','decrease threshold for misfit, default is 30%'))
+		string="%s\n%s"%(string,fielddisplay(obj,'min_parameters','absolute minimum acceptable value of the inversed parameter on each vertex'))
+		string="%s\n%s"%(string,fielddisplay(obj,'max_parameters','absolute maximum acceptable value of the inversed parameter on each vertex'))
+		string="%s\n%s"%(string,fielddisplay(obj,'gradient_only','stop control method solution at gradient'))
+		string="%s\n%s"%(string,fielddisplay(obj,'vx_obs','observed velocity x component [m/a]'))
+		string="%s\n%s"%(string,fielddisplay(obj,'vy_obs','observed velocity y component [m/a]'))
+		string="%s\n%s"%(string,fielddisplay(obj,'vel_obs','observed velocity magnitude [m/a]'))
+		string="%s\n%s"%(string,fielddisplay(obj,'thickness_obs','observed thickness [m]'))
+		string="%s\n%s"%(string,'Available cost functions:')
+		string="%s\n%s"%(string,'   101: SurfaceAbsVelMisfit')
+		string="%s\n%s"%(string,'   102: SurfaceRelVelMisfit')
+		string="%s\n%s"%(string,'   103: SurfaceLogVelMisfit')
+		string="%s\n%s"%(string,'   104: SurfaceLogVxVyMisfit')
+		string="%s\n%s"%(string,'   105: SurfaceAverageVelMisfit')
+		string="%s\n%s"%(string,'   201: ThicknessAbsMisfit')
+		string="%s\n%s"%(string,'   501: DragCoefficientAbsGradient')
+		string="%s\n%s"%(string,'   502: RheologyBbarAbsGradient')
+		string="%s\n%s"%(string,'   503: ThicknessAbsGradient')
+		return string
+		#}}}
+
+	def setdefaultparameters(obj):
+		# {{{setdefaultparameters
+		
+		#default is incomplete adjoint for now
+		obj.incomplete_adjoint=1
+
+		#parameter to be inferred by control methods (only
+		#drag and B are supported yet)
+		obj.control_parameters=['FrictionCoefficient']
+
+		#number of steps in the control methods
+		obj.nsteps=20
+
+		#maximum number of iteration in the optimization algorithm for
+		#each step
+		obj.maxiter_per_step=20*ones(obj.nsteps)
+
+		#the inversed parameter is updated as follows:
+		#new_par=old_par + gradient_scaling(n)*C*gradient with C in [0 1];
+		#usually the gradient_scaling must be of the order of magnitude of the 
+		#inversed parameter (10^8 for B, 50 for drag) and can be decreased
+		#after the first iterations
+		obj.gradient_scaling=50*ones(obj.nsteps)
+
+		#several responses can be used:
+		obj.cost_functions=101*ones(obj.nsteps)
+
+		#step_threshold is used to speed up control method. When
+		#misfit(1)/misfit(0) < obj.step_threshold, we go directly to
+		#the next step
+		obj.step_threshold=.7*ones(obj.nsteps) #30 per cent decrement
+
+		#stop control solution at the gradient computation and return it? 
+		obj.gradient_only=0
+
+		#cost_function_threshold is a criteria to stop the control methods.
+		#if J[n]-J[n-1]/J[n] < criteria, the control run stops
+		#NaN if not applied
+		obj.cost_function_threshold=NaN #not activated 
+
+		return obj
+		#}}}
+
+
Index: /issm/branches/trunk-jpl-damage/src/m/classes/mask.py
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/classes/mask.py	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/m/classes/mask.py	(revision 12168)
@@ -0,0 +1,36 @@
+#module imports
+from fielddisplay import fielddisplay
+
+class mask:
+	#properties
+	def __init__(self):
+		# {{{ Properties
+		self.elementonfloatingice = float('NaN')
+		self.elementongroundedice = float('NaN')
+		self.elementonwater       = float('NaN')
+		self.vertexonfloatingice  = float('NaN')
+		self.vertexongroundedice  = float('NaN')
+		self.vertexonwater        = float('NaN')
+
+		#set defaults
+		self.setdefaultparameters()
+
+		#}}}
+	def __repr__(obj):
+		# {{{ Display
+
+		string="";
+		string="%s\n%s"%(string,fielddisplay(obj,"elementonfloatingice","element on floating ice flags list"))
+		string="%s\n%s"%(string,fielddisplay(obj,"vertexonfloatingice","vertex on floating ice flags list"))
+		string="%s\n%s"%(string,fielddisplay(obj,"elementongroundedice","element on grounded ice  list"))
+		string="%s\n%s"%(string,fielddisplay(obj,"vertexongroundedice","vertex on grounded ice flags list"))
+		string="%s\n%s"%(string,fielddisplay(obj,"elementonwater","element on water flags list"))
+		string="%s\n%s"%(string,fielddisplay(obj,"vertexonwater","vertex on water flags list"))
+		return string
+		#}}}
+		
+	def setdefaultparameters(obj):
+		# {{{setdefaultparameters
+		return obj
+	#}}}
+
Index: /issm/branches/trunk-jpl-damage/src/m/classes/materials.py
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/classes/materials.py	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/m/classes/materials.py	(revision 12168)
@@ -0,0 +1,80 @@
+#module imports
+from fielddisplay import fielddisplay
+
+class materials:
+	#properties
+	def __init__(self):
+		# {{{ Properties
+		self.rho_ice                    = 0;
+		self.rho_water                  = 0;
+		self.mu_water                   = 0;
+		self.heatcapacity               = 0;
+		self.latentheat                 = 0;
+		self.thermalconductivity        = 0;
+		self.meltingpoint               = 0;
+		self.beta                       = 0;
+		self.mixed_layer_capacity       = 0;
+		self.thermal_exchange_velocity  = 0;
+		self.rheology_B   = float('NaN')
+		self.rheology_n   = float('NaN')
+		self.rheology_law = "";
+
+		self.setdefaultparameters()
+		#}}}
+	def __repr__(obj):
+		# {{{ Display
+		string="   Materials:"
+
+		string="%s\n\n%s"%(string,fielddisplay(obj,"rho_ice","ice density [kg/m^3]"))
+		string="%s\n%s"%(string,fielddisplay(obj,"rho_water","water density [kg/m^3]"))
+		string="%s\n%s"%(string,fielddisplay(obj,"mu_water","water viscosity [N s/m^2]"))
+		string="%s\n%s"%(string,fielddisplay(obj,"heatcapacity","heat capacity [J/kg/K]"))
+		string="%s\n%s"%(string,fielddisplay(obj,"thermalconductivity","ice thermal conductivity [W/m/K]"))
+		string="%s\n%s"%(string,fielddisplay(obj,"meltingpoint","melting point of ice at 1atm in K"))
+		string="%s\n%s"%(string,fielddisplay(obj,"latentheat","latent heat of fusion [J/m^3]"))
+		string="%s\n%s"%(string,fielddisplay(obj,"beta","rate of change of melting point with pressure [K/Pa]"))
+		string="%s\n%s"%(string,fielddisplay(obj,"mixed_layer_capacity","mixed layer capacity [W/kg/K]"))
+		string="%s\n%s"%(string,fielddisplay(obj,"thermal_exchange_velocity","thermal exchange velocity [m/s]"))
+		string="%s\n%s"%(string,fielddisplay(obj,"rheology_B","flow law parameter [Pa/s^(1/n)]"))
+		string="%s\n%s"%(string,fielddisplay(obj,"rheology_n","Glen""s flow law exponent"))
+		string="%s\n%s"%(string,fielddisplay(obj,"rheology_law","law for the temperature dependance of the rheology: ""None"", ""Paterson"" or ""Arrhenius"""))
+
+		return string
+		#}}}
+	def setdefaultparameters(obj):
+		# {{{setdefaultparameters
+		#ice density (kg/m^3)
+		obj.rho_ice=917
+
+		#water density (kg/m^3)
+		obj.rho_water=1023
+
+		#water viscosity (N.s/m^2)
+		obj.mu_water=0.001787  
+
+		#ice heat capacity cp (J/kg/K)
+		obj.heatcapacity=2093
+
+		#ice latent heat of fusion L (J/kg)
+		obj.latentheat=3.34*10**5
+
+		#ice thermal conductivity (W/m/K)
+		obj.thermalconductivity=2.4
+
+		#the melting point of ice at 1 atmosphere of pressure in K
+		obj.meltingpoint=273.15
+
+		#rate of change of melting point with pressure (K/Pa)
+		obj.beta=9.8*10**-8
+
+		#mixed layer (ice-water interface) heat capacity (J/kg/K)
+		obj.mixed_layer_capacity=3974
+
+		#thermal exchange velocity (ice-water interface) (m/s)
+		obj.thermal_exchange_velocity=1.00*10**-4
+
+		#Rheology law: what is the temperature dependence of B with T
+		#available: none, paterson and arrhenius
+		obj.rheology_law='Paterson'
+		return obj
+		#}}}
Index: /issm/branches/trunk-jpl-damage/src/m/classes/mesh.py
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/classes/mesh.py	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/m/classes/mesh.py	(revision 12168)
@@ -0,0 +1,125 @@
+#module imports
+from fielddisplay import fielddisplay
+
+class mesh:
+	#properties
+	def __init__(self):
+		# {{{ Properties
+		self.x                           = float('NaN');
+		self.y                           = float('NaN');
+		self.z                           = float('NaN');
+		self.elements                    = float('NaN');
+		self.dimension                   = 0;
+		self.numberoflayers              = 0;
+		self.numberofelements            = 0;
+		self.numberofvertices            = 0;
+		self.numberofedges               = 0;
+		
+		self.lat                         = float('NaN');
+		self.long                        = float('NaN');
+		self.hemisphere                  = float('NaN');
+
+		self.elementonbed                = float('NaN');
+		self.elementonsurface            = float('NaN');
+		self.vertexonbed                 = float('NaN');
+		self.vertexonsurface             = float('NaN');
+		self.lowerelements               = float('NaN');
+		self.lowervertex                 = float('NaN');
+		self.upperelements               = float('NaN');
+		self.uppervertex                 = float('NaN');
+		self.vertexonboundary            = float('NaN');
+
+		self.edges                       = float('NaN');
+		self.segments                    = float('NaN');
+		self.segmentmarkers              = float('NaN');
+		self.vertexconnectivity          = float('NaN');
+		self.elementconnectivity         = float('NaN');
+		self.average_vertex_connectivity = 0;
+
+		self.x2d                         = float('NaN');
+		self.y2d                         = float('NaN');
+		self.elements2d                  = float('NaN');
+		self.numberofvertices2d          = 0;
+		self.numberofelements2d          = 0;
+
+		self.extractedvertices           = float('NaN');
+		self.extractedelements           = float('NaN');
+
+		#set defaults
+		self.setdefaultparameters()
+
+		#}}}
+	def __repr__(obj):
+		# {{{ Display
+
+		if obj.dimension==3:
+			string="\n%s"%("      Elements and vertices of the original 2d mesh:")
+			
+			string="%s\n%s"%(string,fielddisplay(obj,"numberofelements2d","number of elements"))
+			string="%s\n%s"%(string,fielddisplay(obj,"numberofvertices2d","number of vertices"))
+			string="%s\n%s"%(string,fielddisplay(obj,"elements2d","index into (x,y,z), coordinates of the vertices"))
+			string="%s\n%s"%(string,fielddisplay(obj,"x2d","vertices x coordinate"))
+			string="%s\n%s"%(string,fielddisplay(obj,"y2d","vertices y coordinate"))
+
+			string="%s\n%s" %(string,"Elements and vertices of the extruded 3d mesh:")
+		else:
+			string="\n%s"%("      Elements and vertices:")
+
+		string="%s\n%s"%(string,fielddisplay(obj,"numberofelements","number of elements"))
+		
+
+
+
+		string="%s\n%s"%(string,fielddisplay(obj,"numberofvertices","number of vertices"))
+		string="%s\n%s"%(string,fielddisplay(obj,"elements","index into (x,y,z), coordinates of the vertices"))
+		string="%s\n%s"%(string,fielddisplay(obj,"x","vertices x coordinate"))
+		string="%s\n%s"%(string,fielddisplay(obj,"y","vertices y coordinate"))
+		string="%s\n%s"%(string,fielddisplay(obj,"z","vertices z coordinate"))
+		string="%s\n%s"%(string,fielddisplay(obj,"edges","edges of the 2d mesh (vertex1 vertex2 element1 element2)"))
+		string="%s\n%s"%(string,fielddisplay(obj,"numberofedges","number of edges of the 2d mesh"))
+
+		string="%s%s"%(string,"\n      Properties:")
+		
+		string="%s\n%s"%(string,fielddisplay(obj,"dimension","mesh dimension (2d or 3d)"))
+		string="%s\n%s"%(string,fielddisplay(obj,"numberoflayers","number of extrusion layers"))
+		string="%s\n%s"%(string,fielddisplay(obj,"vertexonbed","lower vertices flags list"))
+		string="%s\n%s"%(string,fielddisplay(obj,"elementonbed","lower elements flags list"))
+		string="%s\n%s"%(string,fielddisplay(obj,"vertexonsurface","upper vertices flags list"))
+		string="%s\n%s"%(string,fielddisplay(obj,"elementonsurface","upper elements flags list"))
+		string="%s\n%s"%(string,fielddisplay(obj,"uppervertex","upper vertex list (NaN for vertex on the upper surface)"))
+		string="%s\n%s"%(string,fielddisplay(obj,"upperelements","upper element list (NaN for element on the upper layer)"))
+		string="%s\n%s"%(string,fielddisplay(obj,"lowervertex","lower vertex list (NaN for vertex on the lower surface)"))
+		string="%s\n%s"%(string,fielddisplay(obj,"lowerelements","lower element list (NaN for element on the lower layer"))
+		string="%s\n%s"%(string,fielddisplay(obj,"vertexonboundary","vertices on the boundary of the domain flag list"))
+		
+		string="%s\n%s"%(string,fielddisplay(obj,"segments","edges on domain boundary (vertex1 vertex2 element)"))
+		string="%s\n%s"%(string,fielddisplay(obj,"segmentmarkers","number associated to each segment"))
+		string="%s\n%s"%(string,fielddisplay(obj,"vertexconnectivity","list of vertices connected to vertex_i"))
+		string="%s\n%s"%(string,fielddisplay(obj,"elementconnectivity","list of vertices connected to element_i"))
+		string="%s\n%s"%(string,fielddisplay(obj,"average_vertex_connectivity","average number of vertices connected to one vertex"))
+
+		string="%s%s"%(string,"\n      Extracted model:")
+
+		string="%s\n%s"%(string,fielddisplay(obj,"extractedvertices","vertices extracted from the model"))
+		string="%s\n%s"%(string,fielddisplay(obj,"extractedelements","elements extracted from the model"))
+
+		string="%s%s"%(string,"\n      Projection:")
+		string="%s\n%s"%(string,fielddisplay(obj,"lat","vertices latitude"))
+		string="%s\n%s"%(string,fielddisplay(obj,"long","vertices longitude"))
+		string="%s\n%s"%(string,fielddisplay(obj,"hemisphere","Indicate hemisphere ""n"" or ""s"" "))
+		return string
+		#}}}
+		
+	def setdefaultparameters(obj):
+		# {{{setdefaultparameters
+		
+		#the connectivity is the avergaded number of nodes linked to a
+		#given node through an edge. This connectivity is used to initially
+		#allocate memory to the stiffness matrix. A value of 16 seems to
+		#give a good memory/time ration. This value can be checked in
+		#trunk/test/Miscellaneous/runme.m
+		obj.average_vertex_connectivity=25
+
+		return obj
+	#}}}
+
Index: /issm/branches/trunk-jpl-damage/src/m/classes/miscellaneous.py
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/classes/miscellaneous.py	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/m/classes/miscellaneous.py	(revision 12168)
@@ -0,0 +1,30 @@
+#module imports
+from fielddisplay import fielddisplay
+
+class miscellaneous:
+	#properties
+	def __init__(self):
+		# {{{ Properties
+		self.notes = ''
+		self.name  = ''
+		self.dummy = {}
+
+		#set defaults
+		self.setdefaultparameters()
+
+		#}}}
+	def __repr__(obj):
+		# {{{ Display
+		string='   miscellaneous parameters:'
+
+		string="%s\n\n%s"%(string,fielddisplay(obj,'notes','notes in a cell of strings'))
+		string="%s\n%s"%(string,fielddisplay(obj,'name','model name'))
+		string="%s\n%s"%(string,fielddisplay(obj,'dummy','empty field to store some data'))
+		return string
+		#}}}
+		
+	def setdefaultparameters(obj):
+		# {{{setdefaultparameters
+		return obj
+	#}}}
+
Index: /issm/branches/trunk-jpl-damage/src/m/classes/model.py
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/classes/model.py	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/m/classes/model.py	(revision 12168)
@@ -0,0 +1,114 @@
+#module imports {{{
+from mesh import mesh
+from mask import mask
+from geometry import geometry
+from constants import constants
+from surfaceforcings import surfaceforcings
+from basalforcings import basalforcings
+from materials import materials
+from friction import friction
+from flowequation import flowequation
+from timestepping import timestepping
+from initialization import initialization
+from rifts import rifts
+from debug import debug
+from verbose import verbose
+from settings import settings
+from solver import solver
+from none import none
+from balancethickness import balancethickness
+from diagnostic import diagnostic
+from groundingline import groundingline
+from hydrology import hydrology
+from prognostic import prognostic
+from thermal import thermal
+from steadystate import steadystate
+from transient import transient
+from autodiff import autodiff
+from flaim import flaim
+from inversion import inversion
+from qmu import qmu
+from radaroverlay import radaroverlay
+from miscellaneous import miscellaneous
+from private import private
+#}}}
+class model:
+	#properties
+	def __init__(self):
+		# {{{ Properties
+		self.mesh             = mesh()
+		self.mask             = mask()
+		self.geometry         = geometry()
+		self.constants        = constants()
+		self.surfaceforcings  = surfaceforcings()
+		self.basalforcings    = basalforcings()
+		self.materials        = materials()
+		self.friction         = friction()
+		self.flowequation     = flowequation()
+		self.timestepping     = timestepping()
+		self.initialization   = initialization()
+		self.rifts            = rifts()
+
+		self.debug            = debug()
+		self.verbose          = verbose()
+		self.settings         = settings()
+		self.solver           = solver()
+		self.cluster          = none()
+
+		self.balancethickness = balancethickness()
+		self.diagnostic       = diagnostic()
+		self.groundingline    = groundingline()
+		self.hydrology        = hydrology()
+		self.prognostic       = prognostic()
+		self.thermal          = thermal()
+		self.steadystate      = steadystate()
+		self.transient        = transient()
+
+		self.autodiff         = autodiff()
+		self.flaim            = flaim()
+		self.inversion        = inversion()
+		self.qmu              = qmu()
+
+		self.results          = [];
+		self.radaroverlay     = radaroverlay()
+		self.miscellaneous    = miscellaneous()
+		self.private          = private()
+		#}}}
+	def __repr__(obj):
+		# {{{ Display
+
+		#print "Here %s the number: %d" % ("is", 37)
+		string="%19s: %-22s -- %s" % ("mesh","[%s,%s]" % ("1x1",obj.mesh.__class__.__name__),"mesh properties")
+		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("mask","[%s,%s]" % ("1x1",obj.mask.__class__.__name__),"defines grounded and floating elements"))
+		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("geometry","[%s,%s]" % ("1x1",obj.geometry.__class__.__name__),"surface elevation, bedrock topography, ice thickness,..."))
+		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("constants","[%s,%s]" % ("1x1",obj.constants.__class__.__name__),"physical constants"))
+		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("surfaceforcings","[%s,%s]" % ("1x1",obj.surfaceforcings.__class__.__name__),"surface forcings"))
+		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("basalforcings","[%s,%s]" % ("1x1",obj.basalforcings.__class__.__name__),"bed forcings"))
+		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("materials","[%s,%s]" % ("1x1",obj.materials.__class__.__name__),"material properties"))
+		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("friction","[%s,%s]" % ("1x1",obj.friction.__class__.__name__),"basal friction/drag properties"))
+		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("flowequation","[%s,%s]" % ("1x1",obj.flowequation.__class__.__name__),"flow equations"))
+		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("timestepping","[%s,%s]" % ("1x1",obj.timestepping.__class__.__name__),"time stepping for transient models"))
+		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("initialization","[%s,%s]" % ("1x1",obj.initialization.__class__.__name__),"initial guess/state"))
+		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("rifts","[%s,%s]" % ("1x1",obj.rifts.__class__.__name__),"rifts properties'"))
+		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("debug","[%s,%s]" % ("1x1",obj.debug.__class__.__name__),"debugging tools (valgrind, gprof"))
+		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("verbose","[%s,%s]" % ("1x1",obj.verbose.__class__.__name__),"verbosity level in solve"))
+		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("settings","[%s,%s]" % ("1x1",obj.settings.__class__.__name__),"settings properties"))
+		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("solver","[%s,%s]" % ("1x1",obj.solver.__class__.__name__),"PETSc options for each solution'"))
+		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("cluster","[%s,%s]" % ("1x1",obj.cluster.__class__.__name__),"cluster parameters (number of cpus...)"))
+		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("balancethickness","[%s,%s]" % ("1x1",obj.balancethickness.__class__.__name__),"parameters for balancethickness solution"))
+		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("diagnostic","[%s,%s]" % ("1x1",obj.diagnostic.__class__.__name__),"parameters for diagnostic solution"))
+		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("groundingline","[%s,%s]" % ("1x1",obj.groundingline.__class__.__name__),"parameters for groundingline solution"))
+		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("hydrology","[%s,%s]" % ("1x1",obj.hydrology.__class__.__name__),"parameters for hydrology solution"))
+		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("prognostic","[%s,%s]" % ("1x1",obj.prognostic.__class__.__name__),"parameters for prognostic solution"))
+		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("thermal","[%s,%s]" % ("1x1",obj.thermal.__class__.__name__),"parameters for thermal solution"))
+		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("steadystate","[%s,%s]" % ("1x1",obj.steadystate.__class__.__name__),"parameters for steadystate solution"))
+		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("transient","[%s,%s]" % ("1x1",obj.transient.__class__.__name__),"parameters for transient solution"))
+		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("autodiff","[%s,%s]" % ("1x1",obj.autodiff.__class__.__name__),"automatic differentiation parameters"))
+		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("flaim","[%s,%s]" % ("1x1",obj.flaim.__class__.__name__),"flaim parameters"))
+		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("inversion","[%s,%s]" % ("1x1",obj.inversion.__class__.__name__),"parameters for inverse methods"))
+		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("qmu","[%s,%s]" % ("1x1",obj.qmu.__class__.__name__),"dakota properties"))
+		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("results","[%s,%s]" % ("1x1",obj.results.__class__.__name__),"model results'"))
+		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("radaroverlay","[%s,%s]" % ("1x1",obj.radaroverlay.__class__.__name__),"radar image for plot overlay"))
+		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("miscellaneous","[%s,%s]" % ("1x1",obj.miscellaneous.__class__.__name__),"miscellaneous fields"))
+		return string;
+		 #}}}
Index: /issm/branches/trunk-jpl-damage/src/m/classes/model/model.m
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/classes/model/model.m	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/m/classes/model/model.m	(revision 12168)
@@ -382,5 +382,5 @@
 				 md.solver           = addoptions(md.solver,DiagnosticVertAnalysisEnum,iluasmoptions);
 			 end
-			 md.cluster          = none();
+			 md.cluster          = generic();
 			 md.balancethickness = balancethickness();
 			 md.diagnostic       = diagnostic();
Index: /issm/branches/trunk-jpl-damage/src/m/classes/modellist.m
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/classes/modellist.m	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/m/classes/modellist.m	(revision 12168)
@@ -7,5 +7,5 @@
 	properties (SetAccess=public) 
 		models  = cell(0,1);
-		cluster = none();
+		cluster = generic();
 	end
 	methods
Index: /issm/branches/trunk-jpl-damage/src/m/classes/pairoptions.py
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/classes/pairoptions.py	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/m/classes/pairoptions.py	(revision 12168)
@@ -0,0 +1,38 @@
+class pairoptions:
+	#properties
+	def __init__(self,*args):
+		# {{{ Properties
+		if len(args)%2==1:
+			raise RuntimeError('pairoption error message: an even number of options is required')
+
+		#create a pairoption object
+		if len(args)==0:
+			self.list=[]
+		else:
+			self.list=[]
+			for i in range(int(round(len(args)/2))):
+				if isinstance(args[2*i],str):
+					self.list.append([args[2*i],args[2*i+1]])
+				else:
+					#option is not a string, ignore it
+					print("%s%i%s"%('buildlist info: option number ',i,' is not a string, it will be ignored'))
+					continue
+
+		#}}}
+	def __repr__(obj):
+		# {{{ Display
+		if not obj.list:
+			string='   list: empty'
+		else:
+			string="   list: (%i)"%(len(obj.list))
+			for i in range(len(obj.list)):
+				if isinstance(obj.list[i][1],str):
+					string2="     field: %-10s value: '%s'"%(obj.list[i][0],obj.list[i][1])
+				elif isinstance(obj.list[i][1],float):
+					string2="     field: %-10s value: %g"%(obj.list[i][0],obj.list[i][1])
+				elif isinstance(obj.list[i][1],int):
+					string2="     field: %-10s value: %i"%(obj.list[i][0],obj.list[i][1])
+				else:
+					string2="     field: %-10s value: (%i)"%(len(obj.list[i][1]))
+				string="%s\n%s"%(string,string2)
+		return string
Index: /issm/branches/trunk-jpl-damage/src/m/classes/private.py
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/classes/private.py	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/m/classes/private.py	(revision 12168)
@@ -0,0 +1,29 @@
+#module imports
+from fielddisplay import fielddisplay
+
+class private:
+	#properties
+	def __init__(self):
+		# {{{ Properties
+		self.runtimename = ''
+		self.bamg        = {}
+		self.solution    = '';
+
+		#set defaults
+		self.setdefaultparameters()
+
+		#}}}
+	def __repr__(obj):
+		# {{{ Display
+		string='   private parameters: do not change'
+		string="%s\n%s"%(string,fielddisplay(obj,'runtimename','name of the run launched'))
+		string="%s\n%s"%(string,fielddisplay(obj,'bamg','structure with mesh properties construced if bamg is used to mesh the domain'))
+		string="%s\n%s"%(string,fielddisplay(obj,'solution','type of solution launched'))
+		return string
+		#}}}
+		
+	def setdefaultparameters(obj):
+		# {{{setdefaultparameters
+		return obj
+	#}}}
+
Index: /issm/branches/trunk-jpl-damage/src/m/classes/prognostic.py
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/classes/prognostic.py	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/m/classes/prognostic.py	(revision 12168)
@@ -0,0 +1,47 @@
+#module imports
+from fielddisplay import fielddisplay
+
+class prognostic:
+	#properties
+	def __init__(self):
+		# {{{ Properties
+		self.spcthickness           = float('NaN')
+		self.min_thickness          = 0
+		self.hydrostatic_adjustment = 0
+		self.stabilization          = 0
+		self.vertex_pairing         = float('NaN')
+		self.penalty_factor         = 0
+
+		#set defaults
+		self.setdefaultparameters()
+
+		#}}}
+	def __repr__(obj):
+		# {{{ Display
+		string='   Prognostic solution parameters:'
+		string="%s\n\n%s"%(string,fielddisplay(obj,'spcthickness','thickness constraints (NaN means no constraint)'))
+		string="%s\n%s"%(string,fielddisplay(obj,'min_thickness','minimum ice thickness allowed'))
+		string="%s\n%s"%(string,fielddisplay(obj,'hydrostatic_adjustment','adjustment of ice shelves surface and bed elevations: ''Incremental'' or ''Absolute'' '))
+		string="%s\n%s"%(string,fielddisplay(obj,'stabilization','0->no, 1->artificial_diffusivity, 2->streamline upwinding, 3->discontinuous Galerkin'))
+
+		return string
+		#}}}
+		
+	def setdefaultparameters(obj):
+		# {{{setdefaultparameters
+		
+		#Type of stabilization to use 0:nothing 1:artificial_diffusivity 3:Discontinuous Galerkin
+		obj.stabilization=1
+
+		#Factor applied to compute the penalties kappa=max(stiffness matrix)*10^penalty_factor
+		obj.penalty_factor=3
+
+		#Minimum ice thickness that can be used
+		obj.min_thickness=1
+
+		#Hydrostatic adjustment
+		obj.hydrostatic_adjustment='Absolute'
+
+		return obj
+	#}}}
+
Index: /issm/branches/trunk-jpl-damage/src/m/classes/qmu.py
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/classes/qmu.py	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/m/classes/qmu.py	(revision 12168)
@@ -0,0 +1,39 @@
+#module imports
+from fielddisplay import fielddisplay
+
+class qmu:
+	#properties
+	def __init__(self):
+		# {{{ Properties
+		self.isdakota                    = 0
+		self.variables                   = {}
+		self.responses                   = {}
+		self.method                      = {}
+		self.params                      = {}
+		self.results                     = {}
+		self.partition                   = float('NaN')
+		self.numberofpartitions          = 0
+		self.numberofresponses           = 0
+		self.variabledescriptors         = []
+		self.responsedescriptors         = []
+		self.mass_flux_profile_directory = float('NaN')
+		self.mass_flux_profiles          = float('NaN')
+		self.mass_flux_segments          = []
+		self.adjacency                   = float('NaN')
+		self.vertex_weight               = float('NaN')
+
+		#set defaults
+		self.setdefaultparameters()
+
+		#}}}
+	def __repr__(obj):
+		# {{{ Display
+		string="   qmu parameters: not implemented yet!"
+		return string
+		#}}}
+		
+	def setdefaultparameters(obj):
+		# {{{setdefaultparameters
+		return obj
+	#}}}
+
Index: /issm/branches/trunk-jpl-damage/src/m/classes/radaroverlay.py
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/classes/radaroverlay.py	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/m/classes/radaroverlay.py	(revision 12168)
@@ -0,0 +1,29 @@
+#module imports
+from fielddisplay import fielddisplay
+
+class radaroverlay:
+	#properties
+	def __init__(self):
+		# {{{ Properties
+		self.pwr = float('NaN')
+		self.x   = float('NaN')
+		self.y   = float('NaN')
+
+		#set defaults
+		self.setdefaultparameters()
+
+		#}}}
+	def __repr__(obj):
+		# {{{ Display
+		string='   radaroverlay parameters:'
+		string="%s\n\n%s"%(string,fielddisplay(obj,'pwr','radar power image (matrix)'))
+		string="%s\n%s"%(string,fielddisplay(obj,'x','corresponding x coordinates'))
+		string="%s\n%s"%(string,fielddisplay(obj,'y','corresponding y coordinates'))
+		return string
+		#}}}
+		
+	def setdefaultparameters(obj):
+		# {{{setdefaultparameters
+		return obj
+	#}}}
+
Index: /issm/branches/trunk-jpl-damage/src/m/classes/rifts.py
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/classes/rifts.py	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/m/classes/rifts.py	(revision 12168)
@@ -0,0 +1,28 @@
+#module imports
+from fielddisplay import fielddisplay
+
+class rifts:
+	#properties
+	def __init__(self):
+		# {{{ Properties
+		self.riftstruct     = float('NaN')
+		self.riftproperties = float('NaN')
+
+		#set defaults
+		self.setdefaultparameters()
+
+		#}}}
+	def __repr__(obj):
+		# {{{ Display
+		string='   rifts parameters:'
+
+		string="%s\n\n%s"%(string,fielddisplay(obj,'riftstruct','structure containing all rift information (vertices coordinates, segments, type of melange, ...)'))
+		string="%s\n%s"%(string,fielddisplay(obj,'riftproperties',''))
+		return string
+		#}}}
+		
+	def setdefaultparameters(obj):
+		# {{{setdefaultparameters
+		return obj
+	#}}}
+
Index: /issm/branches/trunk-jpl-damage/src/m/classes/settings.py
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/classes/settings.py	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/m/classes/settings.py	(revision 12168)
@@ -0,0 +1,53 @@
+#module imports
+from fielddisplay import fielddisplay
+
+class settings:
+	#properties
+	def __init__(self):
+		# {{{ Properties
+		self.io_gather           = 0
+		self.lowmem              = 0
+		self.results_as_patches  = 0
+		self.output_frequency    = 0
+		self.waitonlock          = 0
+
+		#set defaults
+		self.setdefaultparameters()
+
+		#}}}
+	def __repr__(obj):
+		# {{{ Display
+		string="   general settings parameters:"
+
+		string="%s\n%s"%(string,fielddisplay(obj,"io_gather","I/O gathering strategy for result outputs (default 1)"))
+		string="%s\n%s"%(string,fielddisplay(obj,"lowmem","is the memory limited ? (0 or 1)"))
+		string="%s\n%s"%(string,fielddisplay(obj,"results_as_patches","provide results as patches for each element (0 or 1)"))
+		string="%s\n%s"%(string,fielddisplay(obj,"output_frequency","frequency at which results are saved in all solutions with multiple time_steps"))
+		string="%s\n%s"%(string,fielddisplay(obj,"waitonlock","maximum number of minutes to wait for batch results, or return 0"))
+		return string
+		#}}}
+		
+	def setdefaultparameters(obj):
+		# {{{setdefaultparameters
+		
+		#are we short in memory ? (0 faster but requires more memory)
+		obj.lowmem=0
+
+		#i/o:
+		obj.io_gather=1
+
+		#results frequency by default every step
+		obj.output_frequency=1
+
+		#do not use patches by default (difficult to plot)
+		obj.results_as_patches=0
+
+		#this option can be activated to load automatically the results
+		#onto the model after a parallel run by waiting for the lock file
+		#N minutes that is generated once the solution has converged
+		#0 to desactivate
+		obj.waitonlock=float('Inf')
+
+		return obj
+	#}}}
+
Index: /issm/branches/trunk-jpl-damage/src/m/classes/solver.m
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/classes/solver.m	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/m/classes/solver.m	(revision 12168)
@@ -18,5 +18,8 @@
 				 end
 			 end % }}}
-		 function obj = addoptions(obj,analysis,solveroptions) % {{{1
+		 function obj = addoptions(obj,analysis,varargin) % {{{1
+		 % Usage example:
+		 %    md.solver=addoptions(md.solver,DiagnosticHorizAnalysisEnum,stokesoptions());
+		 %    md.solver=addoptions(md.solver,DiagnosticHorizAnalysisEnum);
 
 			 %Convert analysis from enum to string
@@ -29,5 +32,5 @@
 
 			 %Add solver options to analysis
-			 obj.(analysis) = solveroptions;
+			 if nargin==3, obj.(analysis) = varargin{1}; end
 		 end
 		 %}}}
Index: /issm/branches/trunk-jpl-damage/src/m/classes/solver.py
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/classes/solver.py	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/m/classes/solver.py	(revision 12168)
@@ -0,0 +1,49 @@
+#module imports {{{
+import fielddisplay 
+import ismumps
+from  mumpsoptions import *
+from  iluasmoptions import *
+#}}}
+class solver:
+	#properties
+	def __init__(self):
+		# {{{ Properties
+		if ismumps:
+			self.options=[["NoneAnalysis",mumpsoptions()]]
+		else:
+			self.options=[["NoneAnalysis",iluasmoptions()]]
+		#}}}
+	def __repr__(obj):
+		# {{{ Display
+		
+		string2="   solver parameters:"
+		for i in range(len(obj.options)):
+			option=obj.options[i]
+			analysis=option[0]
+			ioptions=option[1]
+
+			string=""
+			for i in range(len(ioptions)):
+				option=ioptions[i]
+				if not option:
+					#do nothing
+					pass
+				elif len(option)==1:
+					#this option has only one argument
+					string="%s%s%s"%(string," -",option[0])
+				elif len(option)==2:
+					#option with value. value can be string or scalar
+					if isinstance(option[1],float):
+						string="%s%s%s%s%s"%(string," -",option[0]," ","%g"%(option[1]))
+					elif isinstance(option[1],str):
+						string="%s%s%s%s%s"%(string," -",option[0]," ",option[1])
+					elif isinstance(option[1],int):
+						string="%s%s%s%s%s"%(string," -",option[0]," ","%i"%(option[1]))
+					else:
+						raise RuntimeError("%s%s%s"%("PetscString error: option #","%i"%(i)," is not well formatted"))
+				else:
+					raise RuntimeError("%s%s%s"%("PetscString error: option #","%i"%(i)," is not well formatted"))
+
+			string2="%s\n%s"%(string2,"   %s -> '%s'"%(analysis,string))
+		return string2
+	#}}}
Index: /issm/branches/trunk-jpl-damage/src/m/classes/steadystate.py
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/classes/steadystate.py	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/m/classes/steadystate.py	(revision 12168)
@@ -0,0 +1,36 @@
+#module imports
+from fielddisplay import fielddisplay
+
+class steadystate:
+	#properties
+	def __init__(self):
+		# {{{ Properties
+		self.reltol            = 0
+		self.maxiter           = 0
+		self.requested_outputs = float('NaN')
+
+		#set defaults
+		self.setdefaultparameters()
+
+		#}}}
+	def __repr__(obj):
+		# {{{ Display
+		string='   steadystate solution parameters:'
+		string="%s\n%s"%(string,fielddisplay(obj,'reltol','relative tolerance criterion'))
+		string="%s\n%s"%(string,fielddisplay(obj,'maxiter','maximum number of iterations'))
+		string="%s\n%s"%(string,fielddisplay(obj,'requested_outputs','additional requested outputs'))
+		return string
+		#}}}
+		
+	def setdefaultparameters(obj):
+		# {{{setdefaultparameters
+		
+		#maximum of steady state iterations
+		obj.maxiter=100
+
+		#Relative tolerance for the steadystate convertgence
+		obj.reltol=0.01
+
+		return obj
+	#}}}
+
Index: /issm/branches/trunk-jpl-damage/src/m/classes/surfaceforcings.py
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/classes/surfaceforcings.py	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/m/classes/surfaceforcings.py	(revision 12168)
@@ -0,0 +1,29 @@
+#module imports
+from fielddisplay import fielddisplay
+
+class surfaceforcings:
+	#properties
+	def __init__(self):
+		# {{{ Properties
+		self.precipitation = float('NaN')
+		self.mass_balance  = float('NaN')
+
+		#set defaults
+		self.setdefaultparameters()
+
+		#}}}
+	def __repr__(obj):
+		# {{{ Display
+		string="   surface forcings parameters:"
+
+		string="%s\n\n%s"%(string,fielddisplay(obj,'precipitation','surface precipitation [m/yr water eq]'))
+		string="%s\n%s"%(string,fielddisplay(obj,'mass_balance','surface mass balance [m/yr ice eq]'))
+
+		return string
+		#}}}
+		
+	def setdefaultparameters(obj):
+		# {{{setdefaultparameters
+		return obj
+	#}}}
+
Index: /issm/branches/trunk-jpl-damage/src/m/classes/thermal.py
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/classes/thermal.py	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/m/classes/thermal.py	(revision 12168)
@@ -0,0 +1,52 @@
+#module imports
+from fielddisplay import fielddisplay
+
+class thermal:
+	#properties
+	def __init__(self):
+		# {{{ Properties
+		self.spctemperature    = float('NaN')
+		self.penalty_threshold = 0
+		self.stabilization     = 0
+		self.maxiter           = 0
+		self.penalty_lock      = 0
+		self.penalty_factor    = 0
+		self.isenthalpy        = 0
+
+		#set defaults
+		self.setdefaultparameters()
+
+		#}}}
+	def __repr__(obj):
+		# {{{ Display
+		string='   Thermal solution parameters:'
+		string="%s\n\n%s"%(string,fielddisplay(obj,'spctemperature','temperature constraints (NaN means no constraint)'))
+		string="%s\n%s"%(string,fielddisplay(obj,'stabilization','0->no, 1->artificial_diffusivity, 2->SUPG'))
+		string="%s\n%s"%(string,fielddisplay(obj,'maxiter','maximum number of non linear iterations'))
+		string="%s\n%s"%(string,fielddisplay(obj,'penalty_lock','stabilize unstable thermal constraints that keep zigzagging after n iteration (default is 0, no stabilization)'))
+		string="%s\n%s"%(string,fielddisplay(obj,'penalty_threshold','threshold to declare convergence of thermal solution (default is 0)'))
+		string="%s\n%s"%(string,fielddisplay(obj,'isenthalpy','use an enthalpy formulation to include temperate ice (default is 0)'))
+		return string
+		#}}}
+		
+	def setdefaultparameters(obj):
+		# {{{setdefaultparameters
+		
+		#Number of unstable constraints acceptable
+		obj.penalty_threshold=0
+
+		#Type of stabilization used
+		obj.stabilization=1
+
+		#Maximum number of iterations
+		obj.maxiter=100
+
+		#factor used to compute the values of the penalties: kappa=max(stiffness matrix)*10^penalty_factor
+		obj.penalty_factor=3
+
+		#Should we use cold ice (default) or enthalpy formulation
+		obj.isenthalpy=0
+
+		return obj
+	#}}}
+
Index: /issm/branches/trunk-jpl-damage/src/m/classes/timestepping.py
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/classes/timestepping.py	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/m/classes/timestepping.py	(revision 12168)
@@ -0,0 +1,41 @@
+#module imports
+from fielddisplay import fielddisplay
+
+class timestepping:
+	#properties
+	def __init__(self):
+		# {{{ Properties
+		self.time_step       = 0
+		self.final_time      = 0
+		self.time_adapt      = 0
+		self.cfl_coefficient = 0
+		
+		#set defaults
+		self.setdefaultparameters()
+
+		#}}}
+	def __repr__(obj):
+		# {{{ Display
+		string="   timestepping parameters:"
+		string="%s\n\n%s"%(string,fielddisplay(obj,"time_step","length of time steps [yrs]"))
+		string="%s\n%s"%(string,fielddisplay(obj,"final_time","final time to stop the simulation [yrs]"))
+		string="%s\n%s"%(string,fielddisplay(obj,"time_adapt","use cfl condition to define time step ? (0 or 1) "))
+		string="%s\n%s"%(string,fielddisplay(obj,"cfl_coefficient","coefficient applied to cfl condition"))
+		return string
+		#}}}
+		
+	def setdefaultparameters(obj):
+		# {{{setdefaultparameters
+		
+		#time between 2 time steps
+		obj.time_step=1/2
+
+		#final time
+		obj.final_time=10*obj.time_step
+
+		#time adaptation? 
+		obj.time_adapt=0
+		obj.cfl_coefficient=.5
+
+		return obj
+	#}}}
Index: /issm/branches/trunk-jpl-damage/src/m/classes/transient.py
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/classes/transient.py	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/m/classes/transient.py	(revision 12168)
@@ -0,0 +1,40 @@
+#module imports
+from fielddisplay import fielddisplay
+
+class transient:
+	#properties
+	def __init__(self):
+		# {{{ Properties
+		self.isprognostic      = 0
+		self.isdiagnostic      = 0
+		self.isthermal         = 0
+		self.isgroundingline   = 0
+		self.requested_outputs = float('NaN')
+
+		#set defaults
+		self.setdefaultparameters()
+
+		#}}}
+	def __repr__(obj):
+		# {{{ Display
+		string='   transient solution parameters:'
+		string="%s\n%s"%(string,fielddisplay(obj,'isprognostic','indicates if a prognostic solution is used in the transient'))
+		string="%s\n%s"%(string,fielddisplay(obj,'isthermal','indicates if a thermal solution is used in the transient'))
+		string="%s\n%s"%(string,fielddisplay(obj,'isdiagnostic','indicates if a diagnostic solution is used in the transient'))
+		string="%s\n%s"%(string,fielddisplay(obj,'isgroundingline','indicates if a groundingline migration is used in the transient'))
+		string="%s\n%s"%(string,fielddisplay(obj,'requested_outputs','list of additional outputs requested'))
+		return string
+		#}}}
+		
+	def setdefaultparameters(obj):
+		# {{{setdefaultparameters
+		
+		#full analysis: Diagnostic, Prognostic and Thermal but no groundingline migration for now
+		obj.isprognostic=1
+		obj.isdiagnostic=1
+		obj.isthermal=1
+		obj.isgroundingline=0
+
+		return obj
+	#}}}
+
Index: /issm/branches/trunk-jpl-damage/src/m/classes/verbose.py
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/classes/verbose.py	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/m/classes/verbose.py	(revision 12168)
@@ -0,0 +1,27 @@
+#module imports
+from fielddisplay import fielddisplay
+
+class verbose:
+	#properties
+	def __init__(self):
+		# {{{ Properties
+		self.mprocessor  = False
+		self.module      = False
+		self.solution    = False
+		self.solver      = False
+		self.convergence = False
+		self.control     = False
+		self.qmu         = False
+		#}}}
+	def __repr__(obj):
+		# {{{ Display
+		string="%s%s%s\n\n"%("class '",obj.__class__.__name__,"'=")
+		string="%s%s\n"%(string,"   %15s : %s"%("mprocessor",obj.mprocessor))
+		string="%s%s\n"%(string,"   %15s : %s"%("module",obj.module))
+		string="%s%s\n"%(string,"   %15s : %s"%("solution",obj.solution))
+		string="%s%s\n"%(string,"   %15s : %s"%("solver",obj.solver))
+		string="%s%s\n"%(string,"   %15s : %s"%("convergence",obj.convergence))
+		string="%s%s\n"%(string,"   %15s : %s"%("control",obj.control))
+		string="%s%s\n"%(string,"   %15s : %s"%("qmu",obj.qmu))
+		return string
+		#}}}
Index: /issm/branches/trunk-jpl-damage/src/m/kml/README.txt
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/kml/README.txt	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/m/kml/README.txt	(revision 12168)
@@ -61,5 +61,5 @@
 There are some other utilities that are used in the construction of topological tables for the kml writing.
 
-nodeconnectivity.m   - create a node connectivity table (nnodes x mxepg+1)
+kmlnodeconnectivity.m   - create a node connectivity table (nnodes x mxepg+1)
 edgeadjacency.m      - create an edge adjacency array (elems x edges)
 edgeperimeter.m      - create an edge perimeter (edgeper x 2) and element perimeter (edgeper x 1) list
Index: /issm/branches/trunk-jpl-damage/src/m/kml/kml_part_edges.m
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/kml/kml_part_edges.m	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/m/kml/kml_part_edges.m	(revision 12168)
@@ -150,5 +150,5 @@
         elemp=md.mesh.elements(irow,:);
         epartp=epart(irow,:);
-        nodeconp=nodeconnectivity(elemp,md.mesh.numberofvertices);
+        nodeconp=kmlnodeconnectivity(elemp,md.mesh.numberofvertices);
         [edgeadjp]=edgeadjacency(elemp,nodeconp);
         [edgeper,elemper,iloop]=edgeperimeter(elemp,nodeconp,edgeadjp);
Index: /issm/branches/trunk-jpl-damage/src/m/kml/kml_partitions.m
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/kml/kml_partitions.m	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/m/kml/kml_partitions.m	(revision 12168)
@@ -151,5 +151,5 @@
         elemp=md.mesh.elements(irow,:);
         epartp=epart(irow,:);
-        nodeconp=nodeconnectivity(elemp,md.mesh.numberofvertices);
+        nodeconp=kmlnodeconnectivity(elemp,md.mesh.numberofvertices);
         [edgeadjp]=edgeadjacency(elemp,nodeconp);
         [edgeper,elemper,iloop]=edgeperimeter(elemp,nodeconp,edgeadjp);
Index: /issm/branches/trunk-jpl-damage/src/m/kml/kml_unsh_edges.m
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/kml/kml_unsh_edges.m	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/m/kml/kml_unsh_edges.m	(revision 12168)
@@ -74,5 +74,5 @@
 if (~exist('prtplt','var') || strncmpi(prtplt,'on' ,2) || strncmpi(prtplt,'y',1)) && ...
     md.qmu.numberofpartitions
-    [edgeadj]=edgeadjacency(md.mesh.elements,md.nodeconnectivity);
+    [edgeadj]=edgeadjacency(md.mesh.elements,md.kmlnodeconnectivity);
     [icol,irow]=find(edgeadj'==0);
     edgeuns=zeros(length(irow),2);
Index: /issm/branches/trunk-jpl-damage/src/m/kml/kmlnodeconnectivity.m
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/kml/kmlnodeconnectivity.m	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/m/kml/kmlnodeconnectivity.m	(revision 12168)
@@ -0,0 +1,58 @@
+%
+%  create a node connectivity table for the elements in the model.
+%
+%  [nodecon]=edgeadjacency(elem,nnodes,mxepg)
+%
+%  where the required input is:
+%    elem          (numeric, element connectivity array (elems x nodes))
+%
+%  and the required output is:
+%    nodecon       (numeric, node connectivity array (nnodes x mxepg+1))
+%
+%  the optional input is:
+%    nnodes        (numeric, number of nodes)
+%    mxepg         (numeric, max elements per node)
+%
+function [nodecon]=kmlnodeconnectivity(elem,nnodes,mxepg)
+
+if ~nargin
+    help kmlnodeconnectivity
+    return
+end
+
+if ~exist('nnodes','var') || isempty(nnodes)
+    nnodes=max(max(elem));
+end
+if ~exist('mxepg','var') || isempty(mxepg)
+    mxepg=25;
+end
+
+%%  create the node connectivity array
+
+nodecon=zeros(nnodes,mxepg+1);
+
+%  loop over the elements
+
+for i=1:size(elem,1)
+
+%  loop over the nodes for each element
+
+    for j=1:size(elem,2)
+        if elem(i,j)
+            nodecon(elem(i,j),nodecon(elem(i,j),end)+1)=i;
+            nodecon(elem(i,j),end)=nodecon(elem(i,j),end)+1;
+        end
+    end
+end
+
+%%  sort the node connectivity array
+
+%  loop over the nodes
+
+for i=1:size(nodecon,1)
+    if (nodecon(i,end) > 1)
+        nodecon(i,1:nodecon(i,end))=sort(nodecon(i,1:nodecon(i,end)));
+    end
+end
+
+end
Index: sm/branches/trunk-jpl-damage/src/m/kml/nodeconnectivity.m
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/kml/nodeconnectivity.m	(revision 12167)
+++ 	(revision )
@@ -1,58 +1,0 @@
-%
-%  create a node connectivity table for the elements in the model.
-%
-%  [nodecon]=edgeadjacency(elem,nnodes,mxepg)
-%
-%  where the required input is:
-%    elem          (numeric, element connectivity array (elems x nodes))
-%
-%  and the required output is:
-%    nodecon       (numeric, node connectivity array (nnodes x mxepg+1))
-%
-%  the optional input is:
-%    nnodes        (numeric, number of nodes)
-%    mxepg         (numeric, max elements per node)
-%
-function [nodecon]=nodeconnectivity(elem,nnodes,mxepg)
-
-if ~nargin
-    help nodeconnectivity
-    return
-end
-
-if ~exist('nnodes','var') || isempty(nnodes)
-    nnodes=max(max(elem));
-end
-if ~exist('mxepg','var') || isempty(mxepg)
-    mxepg=25;
-end
-
-%%  create the node connectivity array
-
-nodecon=zeros(nnodes,mxepg+1);
-
-%  loop over the elements
-
-for i=1:size(elem,1)
-
-%  loop over the nodes for each element
-
-    for j=1:size(elem,2)
-        if elem(i,j)
-            nodecon(elem(i,j),nodecon(elem(i,j),end)+1)=i;
-            nodecon(elem(i,j),end)=nodecon(elem(i,j),end)+1;
-        end
-    end
-end
-
-%%  sort the node connectivity array
-
-%  loop over the nodes
-
-for i=1:size(nodecon,1)
-    if (nodecon(i,end) > 1)
-        nodecon(i,1:nodecon(i,end))=sort(nodecon(i,1:nodecon(i,end)));
-    end
-end
-
-end
Index: /issm/branches/trunk-jpl-damage/src/m/model/AnalysisConfiguration.m
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/model/AnalysisConfiguration.m	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/m/model/AnalysisConfiguration.m	(revision 12168)
@@ -0,0 +1,58 @@
+function [analyses,numanalyses]=AnalysisConfiguration(solutiontype),
+%ANALYSISCONFIGURATION - return type of analyses, number of analyses 
+%
+%   Usage:
+%      [analyses, numanalyses]=AnalysisConfiguration(solutiontype);
+
+
+
+switch solutiontype,
+
+	case DiagnosticSolutionEnum,
+		numanalyses=5;
+		analyses=[DiagnosticHorizAnalysisEnum;DiagnosticVertAnalysisEnum;DiagnosticHutterAnalysisEnum;SurfaceSlopeAnalysisEnum;BedSlopeAnalysisEnum];
+
+	case SteadystateSolutionEnum,
+		numanalyses=7; 
+		analyses=[DiagnosticHorizAnalysisEnum;DiagnosticVertAnalysisEnum;DiagnosticHutterAnalysisEnum;SurfaceSlopeAnalysisEnum;BedSlopeAnalysisEnum;ThermalAnalysisEnum;MeltingAnalysisEnum];
+
+	case ThermalSolutionEnum,
+		numanalyses=2; 
+		analyses=[ThermalAnalysisEnum;MeltingAnalysisEnum];
+
+	case EnthalpySolutionEnum,
+		numanalyses=1; 
+		analyses=[EnthalpyAnalysisEnum];
+
+	case PrognosticSolutionEnum,
+		numanalyses=1; 
+		analyses=[PrognosticAnalysisEnum];
+
+	case BalancethicknessSolutionEnum,
+		numanalyses=1; 
+		analyses=[BalancethicknessAnalysisEnum];
+
+	case SurfaceSlopeSolutionEnum,
+		numanalyses=1; 
+		analyses=[SurfaceSlopeAnalysisEnum];
+
+	case BedSlopeSolutionEnum,
+		numanalyses=1; 
+		analyses=[BedSlopeAnalysisEnum];
+
+	case TransientSolutionEnum,
+		numanalyses=9; 
+		analyses=[DiagnosticHorizAnalysisEnum;DiagnosticVertAnalysisEnum;DiagnosticHutterAnalysisEnum;SurfaceSlopeAnalysisEnum;BedSlopeAnalysisEnum;ThermalAnalysisEnum;MeltingAnalysisEnum;EnthalpyAnalysisEnum;PrognosticAnalysisEnum];
+
+	case FlaimSolutionEnum,
+		numanalyses=1; 
+		analyses=[FlaimAnalysisEnum];
+
+	case HydrologySolutionEnum,
+		numanalyses=3; 
+		analyses=[BedSlopeAnalysisEnum;SurfaceSlopeAnalysisEnum;HydrologyAnalysisEnum];
+
+	otherwise
+		error('%s%s%s',' solution type: ',EnumToString(solutiontype),' not supported yet!');
+
+end
Index: /issm/branches/trunk-jpl-damage/src/m/model/MatlabProcessPatch.m
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/model/MatlabProcessPatch.m	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/m/model/MatlabProcessPatch.m	(revision 12168)
@@ -0,0 +1,65 @@
+function structure=MatlabProcessPatch(structure);
+%PROCESSPATCH - create a structure from a patch
+%
+%   Usage:
+%      Result=ProcessPatch(Result);
+
+%return if there is no fiel Patch
+if (~isfield(structure,'Patch')),
+	return;
+end
+
+%loop over steps
+for i=1:length(structure),
+
+	%Get Patch for current step
+	Patch=structure(i).Patch;
+	numvertices=structure(i).PatchVertices;
+
+	%check that Patch is not empty
+	if length(Patch)==0 continue; end
+
+	%Get number of fields;
+	fields=unique(Patch(:,1));
+	steps=unique(Patch(:,2));
+
+	%parse steps
+	for j=1:length(steps),
+
+		posstep=find(Patch(:,2)==steps(j));
+
+		%Take all the lines of the Patch for this timestep
+		temporarypatch=Patch(posstep,:);
+		time=temporarypatch(1,3);
+		step=temporarypatch(1,2);
+
+		%parse fields
+		for i=1:length(fields),
+
+			%get name
+			fieldname=EnumToString(fields(i));
+
+			%get line positions
+			pos=find(temporarypatch(:,1)==fields(i));
+
+			%Fill Result structure
+			structure(step).steps=step;
+			structure(step).time=time;
+			structure(step).(fieldname).element=temporarypatch(pos,4);
+			structure(step).(fieldname).interpolation=temporarypatch(pos,5);
+			structure(step).(fieldname).index=temporarypatch(pos,6:5+numvertices);
+			if structure(step).(fieldname).interpolation==P1Enum,
+				structure(step).(fieldname).value=temporarypatch(pos,6+numvertices:end);
+			end
+			if structure(step).(fieldname).interpolation==P0Enum,
+				structure(step).(fieldname).value=temporarypatch(pos,6+numvertices);
+			end
+
+		end
+	end
+end
+
+%remove fields
+structure=rmfield(structure,'Patch');
+structure=rmfield(structure,'PatchVertices');
+structure=rmfield(structure,'PatchNodes');
Index: /issm/branches/trunk-jpl-damage/src/m/model/addnote.py
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/model/addnote.py	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/m/model/addnote.py	(revision 12168)
@@ -0,0 +1,29 @@
+def addnote(md, string):
+
+    # Local Variables: md, string, i, notes, miscellaneous, newnotes
+    # Function calls: ischar, nargout, cell, nargin, length, addnote, error
+    #ADDNOTE - add a note to the existing model notes field
+    #
+    #   Usage:
+    #      md=addnote(md,string);
+    #
+    #   Example:
+    #      md=addnote(md,'Pine Island, Geometry of 2007');
+    
+	if not isinstance(string,basetring):
+        print 'addnote error message: second input argument should be a string'
+		return []
+    
+    notes = md.miscellaneous.notes
+    
+	if isinstance(notes,basestring):
+		newnotes=[notes,string]
+    else:
+		newnotes=[];
+		for i in range(len(notes)):
+			newnotes=newnotes+notes[i]
+            
+        newnotes=newnotes+nodes;
+        
+    md.miscellaneous.notes = newnotes
+    return md
Index: /issm/branches/trunk-jpl-damage/src/m/model/collapse.m
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/model/collapse.m	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/m/model/collapse.m	(revision 12168)
@@ -30,6 +30,6 @@
 if ~isnan(md.inversion.vel_obs), md.inversion.vel_obs=project2d(md,md.inversion.vel_obs,md.mesh.numberoflayers); end;
 if ~isnan(md.inversion.cost_functions_coefficients), md.inversion.cost_functions_coefficients=project2d(md,md.inversion.cost_functions_coefficients,md.mesh.numberoflayers); end;
-if ~isnan(md.inversion.min_parameters), md.inversion.min_parameters=project2d(md,md.inversion.min_parameters,md.mesh.numberoflayers); end;
-if ~isnan(md.inversion.max_parameters), md.inversion.max_parameters=project2d(md,md.inversion.max_parameters,md.mesh.numberoflayers); end;
+if numel(md.inversion.min_parameters)>1, md.inversion.min_parameters=project2d(md,md.inversion.min_parameters,md.mesh.numberoflayers); end;
+if numel(md.inversion.max_parameters)>1, md.inversion.max_parameters=project2d(md,md.inversion.max_parameters,md.mesh.numberoflayers); end;
 if ~isnan(md.surfaceforcings.mass_balance),
 	md.surfaceforcings.mass_balance=project2d(md,md.surfaceforcings.mass_balance,md.mesh.numberoflayers); 
@@ -102,6 +102,6 @@
 
 %lat long
-md.mesh.lat=project2d(md,md.mesh.lat,1);
-md.mesh.long=project2d(md,md.mesh.long,1);
+if numel(md.mesh.lat)>1,  md.mesh.lat=project2d(md,md.mesh.lat,1); end
+if numel(md.mesh.long)>1, md.mesh.long=project2d(md,md.mesh.long,1); end
 
 %Initialize with the 2d mesh
Index: sm/branches/trunk-jpl-damage/src/m/model/mesh/meshnodensity.m
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/model/mesh/meshnodensity.m	(revision 12167)
+++ 	(revision )
@@ -1,71 +1,0 @@
-function md=meshnodensity(md,domainname,varargin)
-%MESH - create model mesh
-%
-%   This routine creates a model mesh using TriMeshNoDensity and a domain outline
-%   where md is a @model object, domainname is the name of an Argus domain outline file, 
-%   Riftname is an optional argument (Argus domain outline) describing rifts.
-%   The  difference with mesh.m is that the resolution of the mesh follows that of the domain 
-%   outline and the riftoutline
-%
-%   Usage:
-%      md=meshnodensity(md,domainname)
-%   or md=meshnodensity(md,domainname,riftname);
-%
-%   Examples:
-%      md=meshnodensity(md,'DomainOutline.exp');
-%      md=meshnodensity(md,'DomainOutline.exp','Rifts.exp');
-
-if (nargin==2),
-	riftname='';
-end
-if (nargin==3),
-	riftname=varargin{1};
-end
-
-%Mesh using TriMeshNoDensity
-if strcmp(riftname,''),
-	[md.mesh.elements,md.mesh.x,md.mesh.y,md.mesh.segments,md.mesh.segmentmarkers]=TriMeshNoDensity(domainname);
-else
-	[elements,x,y,segments,segmentmarkers]=TriMeshNoDensity(domainname,riftname);
-
-	%check that all the created nodes belong to at least one element
-	orphan=find(~ismember([1:length(x)],sort(unique(elements(:)))));
-	for i=1:length(orphan),
-		%get rid of the orphan node i
-		%update x and y
-		x=[x(1:orphan(i)-(i-1)-1); x(orphan(i)-(i-1)+1:end)];
-		y=[y(1:orphan(i)-(i-1)-1); y(orphan(i)-(i-1)+1:end)];
-		%update elements
-		pos=find(elements>orphan(i)-(i-1));
-		elements(pos)=elements(pos)-1;
-		%update segments
-		pos1=find(segments(:,1)>orphan(i)-(i-1));
-		pos2=find(segments(:,2)>orphan(i)-(i-1));
-		segments(pos1,1)=segments(pos1,1)-1;
-		segments(pos2,2)=segments(pos2,2)-1;
-	end
-
-	%plug into md
-	md.mesh.x=x;
-	md.mesh.y=y;
-	md.mesh.elements=elements;
-	md.mesh.segments=segments;
-	md.mesh.segmentmarkers=segmentmarkers;
-end
-
-%Fill in rest of fields:
-md.mesh.numberofelements=length(md.mesh.elements);
-md.mesh.numberofvertices=length(md.mesh.x);
-md.mesh.z=zeros(md.mesh.numberofvertices,1);
-md.mesh.vertexonboundary=zeros(md.mesh.numberofvertices,1); md.mesh.vertexonboundary(md.mesh.segments(:,1:2))=1;
-md.mesh.vertexonbed=ones(md.mesh.numberofvertices,1);
-md.mesh.vertexonsurface=ones(md.mesh.numberofvertices,1);
-md.mesh.elementonbed=ones(md.mesh.numberofelements,1);
-md.mesh.elementonsurface=ones(md.mesh.numberofelements,1);
-
-%Now, build the connectivity tables for this mesh.
-md.mesh.vertexconnectivity=NodeConnectivity(md.mesh.elements,md.mesh.numberofvertices);
-md.mesh.elementconnectivity=ElementConnectivity(md.mesh.elements,md.mesh.vertexconnectivity);
-
-%type of model
-md.mesh.dimension=2;
Index: sm/branches/trunk-jpl-damage/src/m/model/mesh/meshrefine.m
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/model/mesh/meshrefine.m	(revision 12167)
+++ 	(revision )
@@ -1,40 +1,0 @@
-function md=meshrefine(md,areas)
-%MESHREFINE:  refined the mesh from a model, according to an area metric.
-%
-%   Usage:
-%      md=meshrefine(md,metric)
-
-%some checks on list of arguments
-if ((nargin~=2) | (nargout~=1)),
-	meshrefineusage();
-	error('meshrefine error message');
-end
-if ( (isempty(areas)) |  (length(areas)~=md.mesh.numberofelements) | (length(find(isnan(areas))))),
-	meshrefineusage();
-	error('meshrefine error message');
-end
-
-%Refine using TriMeshRefine
-[md.mesh.elements,md.mesh.x,md.mesh.y,md.mesh.segments,md.mesh.segmentmarkers]=TriMeshRefine(md.mesh.elements,md.mesh.x,md.mesh.y,md.mesh.segments,md.mesh.segmentmarkers,areas,'yes');
-
-%Fill in rest of fields:
-md.mesh.numberofelements=length(md.mesh.elements);
-md.mesh.numberofvertices=length(md.mesh.x);
-md.mesh.z=zeros(md.mesh.numberofvertices,1);
-md.mesh.vertexonboundary=zeros(md.mesh.numberofvertices,1); md.mesh.vertexonboundary(md.mesh.segments(:,1:2))=1;
-md.mesh.vertexonbed=ones(md.mesh.numberofvertices,1);
-md.mesh.vertexonsurface=ones(md.mesh.numberofvertices,1);
-md.mesh.elementonbed=ones(md.mesh.numberofelements,1);
-md.mesh.elementonsurface=ones(md.mesh.numberofelements,1);
-
-%Now, build the connectivity tables for this mesh.
-md.mesh.vertexconnectivity=NodeConnectivity(md.mesh.elements,md.mesh.numberofvertices);
-md.mesh.elementconnectivity=ElementConnectivity(md.mesh.elements,md.mesh.vertexconnectivity);
-
-%type of model
-md.mesh.dimension=2;
-end
-
-function meshrefineusage(),
-disp('usage: md=meshrefine(md,areas)');
-end
Index: /issm/branches/trunk-jpl-damage/src/m/model/mesh/triangle.m
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/model/mesh/triangle.m	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/m/model/mesh/triangle.m	(revision 12168)
@@ -38,33 +38,30 @@
 
 %Mesh using TriMesh
-if strcmp(riftname,''),
-	[md.mesh.elements,md.mesh.x,md.mesh.y,md.mesh.segments,md.mesh.segmentmarkers]=TriMesh(domainname,area,true);
-else
-	[elements,x,y,segments,segmentmarkers]=TriMeshRifts(domainname,riftname,area,'yes');
+[elements,x,y,segments,segmentmarkers]=TriMesh(domainname,riftname,area);
 
-	%check that all the created nodes belong to at least one element
-	orphan=find(~ismember([1:length(x)],sort(unique(elements(:)))));
-	for i=1:length(orphan),
-		%get rid of the orphan node i
-		%update x and y
-		x=[x(1:orphan(i)-(i-1)-1); x(orphan(i)-(i-1)+1:end)];
-		y=[y(1:orphan(i)-(i-1)-1); y(orphan(i)-(i-1)+1:end)];
-		%update elements
-		pos=find(elements>orphan(i)-(i-1));
-		elements(pos)=elements(pos)-1;
-		%update segments
-		pos1=find(segments(:,1)>orphan(i)-(i-1));
-		pos2=find(segments(:,2)>orphan(i)-(i-1));
-		segments(pos1,1)=segments(pos1,1)-1;
-		segments(pos2,2)=segments(pos2,2)-1;
-	end
+%check that all the created nodes belong to at least one element
+orphan=find(~ismember([1:length(x)],sort(unique(elements(:)))));
+for i=1:length(orphan),
+	disp('WARNING: removing orphans');
+	%get rid of the orphan node i
+	%update x and y
+	x=[x(1:orphan(i)-(i-1)-1); x(orphan(i)-(i-1)+1:end)];
+	y=[y(1:orphan(i)-(i-1)-1); y(orphan(i)-(i-1)+1:end)];
+	%update elements
+	pos=find(elements>orphan(i)-(i-1));
+	elements(pos)=elements(pos)-1;
+	%update segments
+	pos1=find(segments(:,1)>orphan(i)-(i-1));
+	pos2=find(segments(:,2)>orphan(i)-(i-1));
+	segments(pos1,1)=segments(pos1,1)-1;
+	segments(pos2,2)=segments(pos2,2)-1;
+end
 
-	%plug into md
-	md.mesh.x=x;
-	md.mesh.y=y;
-	md.mesh.elements=elements;
-	md.mesh.segments=segments;
-	md.mesh.segmentmarkers=segmentmarkers;
-end
+%plug into md
+md.mesh.x=x;
+md.mesh.y=y;
+md.mesh.elements=elements;
+md.mesh.segments=segments;
+md.mesh.segmentmarkers=segmentmarkers;
 
 %Fill in rest of fields:
Index: /issm/branches/trunk-jpl-damage/src/m/model/mesh/triangle.py
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/model/mesh/triangle.py	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/m/model/mesh/triangle.py	(revision 12168)
@@ -0,0 +1,56 @@
+from numpy import *
+import TriMesh as tm
+import NodeConnectivity as nc
+import ElementConnectivity as ec
+
+def triangle(md, domainname, resolution,riftname=''):
+	#TRIANGLE - create model mesh using the triangle package
+	#
+	#   This routine creates a model mesh using TriMesh and a domain outline, to within a certain resolution
+	#   where md is a @model object, domainname is the name of an Argus domain outline file, 
+	#   and resolution is a characteristic length for the mesh (same unit as the domain outline
+	#   unit). Riftname is an optional argument (Argus domain outline) describing rifts.
+	#
+	#   Usage:
+	#      md=triangle(md,domainname,resolution)
+	#   or md=triangle(md,domainname, resolution, riftname)
+	#
+	#   Examples:
+	#      md=triangle(md,'DomainOutline.exp',1000);
+	#      md=triangle(md,'DomainOutline.exp',1000,'Rifts.exp');
+
+
+	#Figure out a characteristic area. Resolution is a node oriented concept (ex a 1000m  resolution node would 
+	#be made of 1000*1000 area squares). 
+
+	#Check that mesh was not already run, and warn user: 
+	if md.mesh.numberofelements != 0.:
+		choice = input('This model already has a mesh. Are you sure you want to go ahead? (y/n)')
+		if choice != 'y':
+			print 'no meshing done ... exiting'
+			return []
+		
+	area = resolution**2.
+
+	#Mesh using TriMesh
+	[md.mesh.elements,md.mesh.x,md.mesh.y,md.mesh.segments,md.mesh.segmentmarkers]=tm.TriMesh(domainname,riftname,area)
+
+
+	#Fill in rest of fields:
+	md.mesh.numberofelements = len(md.mesh.elements)
+	md.mesh.numberofvertices = len(md.mesh.x)
+	md.mesh.z = zeros(md.mesh.numberofvertices)
+	md.mesh.vertexonboundary = zeros(md.mesh.numberofvertices)
+	md.mesh.vertexonboundary[md.mesh.segments[:,0:2].astype(int)-1] = 1.
+	md.mesh.vertexonbed = ones(md.mesh.numberofvertices)
+	md.mesh.vertexonsurface = ones(md.mesh.numberofvertices)
+	md.mesh.elementonbed = ones(md.mesh.numberofelements)
+	md.mesh.elementonsurface = ones(md.mesh.numberofelements)
+
+	#Now, build the connectivity tables for this mesh.
+	[md.mesh.vertexconnectivity]= nc.NodeConnectivity(md.mesh.elements, md.mesh.numberofvertices)
+	[md.mesh.elementconnectivity] = ec.ElementConnectivity(md.mesh.elements, md.mesh.vertexconnectivity)
+	
+	#type of model
+	md.mesh.dimension = 2.
+	return md
Index: /issm/branches/trunk-jpl-damage/src/m/model/modis.m
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/model/modis.m	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/m/model/modis.m	(revision 12168)
@@ -14,9 +14,9 @@
 
 %Get path  to gdal binaries
-path_gdal=[issmtier() '/externalpackages/gdal/install/bin/'];
+path_gdal=[issmdir() '/externalpackages/gdal/install/bin/'];
 
 %Was gdal compiled? 
 if ~exist([path_gdal 'gdal_translate']),
-	error(['modis error message: GDAL library needs to be compiled to use this routine. Compile GDAL in ' issmtier() '/externalpackages/gdal to use this routine.']);
+	error(['modis error message: GDAL library needs to be compiled to use this routine. Compile GDAL in ' issmdir() '/externalpackages/gdal to use this routine.']);
 end
 
Index: /issm/branches/trunk-jpl-damage/src/m/model/parameterization/parameterize.py
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/model/parameterization/parameterize.py	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/m/model/parameterization/parameterize.py	(revision 12168)
@@ -0,0 +1,27 @@
+import os
+def  parameterize(md,parametername):
+	#PARAMETERIZE - parameterize a model
+	#
+	#   from a parameter matlab file, start filling in all the model fields that were not 
+	#   filled in by the mesh.py and setmask.py model methods.
+	#   Warning: the parameter file must be able to be run in Python
+	#
+	#   Usage:
+	#      md=parameterize(md,parametername)
+	#
+	#   Example:
+	#      md=parameterize(md,'Square.par');
+
+	#some checks
+	if not os.path.isfile(parametername):
+		print 'parameterize error message: file '+parametername+' not found.'
+		return []
+
+	#Try and run parameter file.
+	execfile(parametername)
+	
+	#ame and notes
+	if len(md.miscellaneous.name)==0:
+		md.miscellaneous.name=os.path.basename(parametername)
+	
+	md=addnote(md,'Model created by using parameter file: '+parametername+' on: '+str(datetime.datetime.now()))
Index: /issm/branches/trunk-jpl-damage/src/m/model/petscversion.m
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/model/petscversion.m	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/m/model/petscversion.m	(revision 12168)
@@ -8,5 +8,5 @@
 PETSC_VERSION=3;
 
-configfile=[issmtier() '/config.h'];
+configfile=[issmdir() '/config.h'];
 if ~exist(configfile,'file'),
 	error(['File ' configfile ' not found. ISSM has not been configured yet!']);
Index: /issm/branches/trunk-jpl-damage/src/m/model/plot/applyoptions.m
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/model/plot/applyoptions.m	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/m/model/plot/applyoptions.m	(revision 12168)
@@ -229,4 +229,7 @@
 		warning on MATLAB:log:logOfZero;
 		set(c,'YTickLabel',labels);
+	end 
+ 	if exist(options,'cbYLim'); 
+		set(c,'YLim',getfieldvalue(options,'cbYLim'));
 	end
 	if exist(options,'colorbartitle'),
Index: /issm/branches/trunk-jpl-damage/src/m/model/plot/northarrow.m
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/model/plot/northarrow.m	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/m/model/plot/northarrow.m	(revision 12168)
@@ -72,5 +72,5 @@
 
 %Text North
-xN=max([A(1) D(1) E(1) F(1) G(1)])+ratio/3*lengtharrow;
+xN=max([A(1) D(1) E(1) F(1) G(1)])+ratio/3*abs(lengtharrow);
 yN=mean([A(2) F(2) H(2)]);
 text(xN,yN,'North','FontSize',fontsize,'FontWeight','b');
Index: /issm/branches/trunk-jpl-damage/src/m/model/plot/plot_gridded.m
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/model/plot/plot_gridded.m	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/m/model/plot/plot_gridded.m	(revision 12168)
@@ -40,4 +40,5 @@
 	data_max=max(data_grid(:));
 end
+options=changefieldvalue(options,'cbYLim',[data_min data_max]);
 if whitepos==1,
 	white  =data_max + (data_max-data_min)/55;
Index: /issm/branches/trunk-jpl-damage/src/m/model/plot/plot_overlay.m
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/model/plot/plot_overlay.m	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/m/model/plot/plot_overlay.m	(revision 12168)
@@ -96,5 +96,5 @@
 	%h_data(find(data_grid>data_mean))=1;
 	h_data=1*ones(size(data_grid));
-	h_data(find(data_grid>data_mean))=0.7;
+	h_data(find(data_grid<data_mean))=0.7;
 	%saturation (S)
 	s_data=max(min(abs(data_grid-data_mean)/(data_max-data_mean) ,1),0);
Index: /issm/branches/trunk-jpl-damage/src/m/model/plot/plot_section.m
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/model/plot/plot_section.m	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/m/model/plot/plot_section.m	(revision 12168)
@@ -36,5 +36,5 @@
 
 %read contours: 
-profiles=expread(getfieldvalue(options,'sectionvalue'),1);
+profiles=expread(getfieldvalue(options,'sectionvalue'));
 numprofiles=length(profiles);
 
Index: /issm/branches/trunk-jpl-damage/src/m/model/setmask.py
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/model/setmask.py	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/m/model/setmask.py	(revision 12168)
@@ -0,0 +1,55 @@
+from numpy import *
+import FlagElements as fe
+
+def setmask(md, floatingicename, groundedicename):
+	#SETMASK - establish boundaries between grounded and floating ice.
+	#
+	#   By default, ice is considered grounded. The contour floatingicename defines nodes 
+	#   for which ice is floating. The contour groundedicename defines nodes inside an floatingice, 
+	#   that are grounded (ie: ice rises, islands, etc ...)
+	#   All input files are in the Argus format (extension .exp).
+	#
+	#   Usage:
+	#      md=setmask(md,floatingicename,groundedicename)
+	#
+	#   Examples:
+	#      md=setmask(md,'all','');
+	#      md=setmask(md,'Iceshelves.exp','Islands.exp');
+
+	#%Get assigned fields
+	x = md.mesh.x
+	y = md.mesh.y
+	elements = md.mesh.elements
+
+	#Assign elementonfloatingice, elementongroundedice, vertexongroundedice and vertexonfloatingice. Only change at your own peril! This is synchronized heavily with the GroundingLineMigration module. {{{1
+	elementonfloatingice = fe.FlagElements(md, floatingicename)
+	elementongroundedice = fe.FlagElements(md, groundedicename) 
+
+	#Because groundedice nodes and elements can be included into an floatingice, we need to update. Remember, all the previous 
+	#arrays come from domain outlines that can intersect one another: 
+
+	elementonfloatingice = logical_and(elementonfloatingice,~elementongroundedice)
+	elementongroundedice = ~elementonfloatingice
+
+	#the order here is important. we choose vertexongroundedice as default on the grounding line.
+	vertexonfloatingice = zeros(md.mesh.numberofvertices,'bool')
+	vertexongroundedice = zeros(md.mesh.numberofvertices,'bool')
+
+	pos=argwhere(elementongroundedice==1)
+	pos=md.mesh.elements[pos,:]-1
+	if pos.size:
+		vertexongroundedice[pos]=True
+
+	pos=argwhere(~vertexongroundedice)
+	if pos.size:
+		vertexonfloatingice[pos]=True;
+	#%}}}
+
+	#Return: 
+	md.mask.elementonfloatingice = double(elementonfloatingice)
+	md.mask.vertexonfloatingice = double(vertexonfloatingice)
+	md.mask.elementongroundedice = double(elementongroundedice)
+	md.mask.vertexongroundedice = double(vertexongroundedice)
+	md.mask.vertexonwater = zeros(md.mesh.numberofvertices)
+	md.mask.elementonwater = zeros(md.mesh.numberofelements)
+	return md
Index: /issm/branches/trunk-jpl-damage/src/m/utils/BC/SetIceShelfBC.py
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/utils/BC/SetIceShelfBC.py	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/m/utils/BC/SetIceShelfBC.py	(revision 12168)
@@ -0,0 +1,93 @@
+def SetIceShelfBC(md,icefrontfile='')
+	#SETICESHELFBC - Create the boundary conditions for diagnostic and thermal models for a  Ice Shelf with Ice Front
+	#
+	#   Neumann BC are used on the ice front (an ANRGUS contour around the ice front
+	#   must be given in input)
+	#   Dirichlet BC are used elsewhere for diagnostic
+	#
+	#   Usage:
+	#      md=SetIceShelfBC(md,varargin)
+	#
+	#   Example:
+	#      md=SetIceShelfBC(md);
+	#      md=SetIceShelfBC(md,'Front.exp');
+	#
+	#   See also: SETICESHEETBC, SETMARINEICESHEETBC
+
+	#node on Dirichlet (boundary and ~icefront)
+	if not icefrontfile:
+		nodeonicefront=zeros(md.mesh.numberofvertices)
+	else:
+		if not os.path.isfile(icefrontfile):
+			print 'SetIceShelfBC error message: ice front file '+icefrontfile+ ' not found'
+			return []
+		nodeinsideicefront=ContourToMesh(md.mesh.elements,md.mesh.x,md.mesh.y,icefrontfile,'node',2);
+		nodeonicefront=double(md.mesh.vertexonboundary & nodeinsideicefront);
+	
+	pos=find(md.mesh.vertexonboundary & ~nodeonicefront);
+	md.diagnostic.spcvx=NaN*ones(md.mesh.numberofvertices,1);
+	md.diagnostic.spcvy=NaN*ones(md.mesh.numberofvertices,1);
+	md.diagnostic.spcvz=NaN*ones(md.mesh.numberofvertices,1);
+	md.diagnostic.spcvx(pos)=0;
+	md.diagnostic.spcvy(pos)=0;
+	md.diagnostic.spcvz(pos)=0;
+	md.diagnostic.referential=NaN*ones(md.mesh.numberofvertices,6);
+
+	#Dirichlet Values
+	if (length(md.inversion.vx_obs)==md.mesh.numberofvertices & length(md.inversion.vy_obs)==md.mesh.numberofvertices)
+		disp('      boundary conditions for diagnostic model: spc set as observed velocities');
+		md.diagnostic.spcvx(pos)=md.inversion.vx_obs(pos);
+		md.diagnostic.spcvy(pos)=md.inversion.vy_obs(pos);
+	else
+		disp('      boundary conditions for diagnostic model: spc set as zero');
+	end
+
+	#segment on Ice Front
+	#segment on Neumann (Ice Front)
+	pos=find(nodeonicefront(md.mesh.segments(:,1)) | nodeonicefront(md.mesh.segments(:,2)));
+	if (md.mesh.dimension==2)
+		pressureload=md.mesh.segments(pos,:);
+	elseif md.mesh.dimension==3
+		pressureload_layer1=[md.mesh.segments(pos,1:2)  md.mesh.segments(pos,2)+md.mesh.numberofvertices2d  md.mesh.segments(pos,1)+md.mesh.numberofvertices2d  md.mesh.segments(pos,3)];
+		pressureload=[];
+		for i=1:md.mesh.numberoflayers-1,
+			pressureload=[pressureload ;pressureload_layer1(:,1:4)+(i-1)*md.mesh.numberofvertices2d pressureload_layer1(:,5)+(i-1)*md.mesh.numberofelements2d ];
+		end
+	end
+
+	#Add water or air enum depending on the element
+	pressureload=[pressureload 1*md.mask.elementonfloatingice(pressureload(:,end))];
+
+	#plug onto model
+	md.diagnostic.icefront=pressureload;
+
+	#Create zeros basalforcings and surfaceforcings
+	if isnan(md.surfaceforcings.precipitation),
+		md.surfaceforcings.precipitation=zeros(md.mesh.numberofvertices,1);
+		disp('      no surfaceforcings.precipitation specified: values set as zero');
+	end
+	if isnan(md.surfaceforcings.mass_balance),
+		md.surfaceforcings.mass_balance=zeros(md.mesh.numberofvertices,1);
+		disp('      no surfaceforcings.mass_balance specified: values set as zero');
+	end
+	if isnan(md.basalforcings.melting_rate),
+		md.basalforcings.melting_rate=zeros(md.mesh.numberofvertices,1);
+		disp('      no basalforcings.melting_rate specified: values set as zero');
+	end
+	if isnan(md.balancethickness.thickening_rate),
+		md.balancethickness.thickening_rate=zeros(md.mesh.numberofvertices,1);
+		disp('      no balancethickness.thickening_rate specified: values set as zero');
+	end
+
+	md.prognostic.spcthickness=NaN*ones(md.mesh.numberofvertices,1);
+	md.balancethickness.spcthickness=NaN*ones(md.mesh.numberofvertices,1);
+
+	if (length(md.initialization.temperature)==md.mesh.numberofvertices),
+		md.thermal.spctemperature=NaN*ones(md.mesh.numberofvertices,1);
+		pos=find(md.mesh.vertexonsurface); md.thermal.spctemperature(pos)=md.initialization.temperature(pos); #impose observed temperature on surface
+		if (length(md.basalforcings.geothermalflux)~=md.mesh.numberofvertices),
+			md.basalforcings.geothermalflux=zeros(md.mesh.numberofvertices,1);
+		end
+	else
+		disp('      no thermal boundary conditions created: no observed temperature found');
+	end
Index: /issm/branches/trunk-jpl-damage/src/m/utils/DataProcessing/TracksToMatrix.m
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/utils/DataProcessing/TracksToMatrix.m	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/m/utils/DataProcessing/TracksToMatrix.m	(revision 12168)
@@ -26,5 +26,5 @@
 
 %Add path to dace
-addpath([issmtier() '/externalpackages/dace/install'])
+addpath([issmdir() '/externalpackages/dace/install'])
 
 %First create the x_m and y_m fot the matrix
@@ -82,3 +82,3 @@
 
 %remove DACE path
-rmpath([issmtier() '/externalpackages/dace/install']);
+rmpath([issmdir() '/externalpackages/dace/install']);
Index: /issm/branches/trunk-jpl-damage/src/m/utils/Exp/expdisp.m
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/utils/Exp/expdisp.m	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/m/utils/Exp/expdisp.m	(revision 12168)
@@ -41,5 +41,5 @@
 end
 
-domain=expread(domainoutline,1);
+domain=expread(domainoutline);
 
 figure(figurenumber),hold on
Index: /issm/branches/trunk-jpl-damage/src/m/utils/Exp/exptool.m
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/utils/Exp/exptool.m	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/m/utils/Exp/exptool.m	(revision 12168)
@@ -71,5 +71,5 @@
 		else
 			%read file
-			B=expread(filename,1);
+			B=expread(filename);
 			%go through all profiles of B
 			for i=1:size(B,2)
Index: /issm/branches/trunk-jpl-damage/src/m/utils/Geometry/FlagElements.py
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/utils/Geometry/FlagElements.py	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/m/utils/Geometry/FlagElements.py	(revision 12168)
@@ -0,0 +1,54 @@
+from numpy import * 
+def FlagElements(md,region):
+#FLAGELEMENTS - flag the elements in an region
+#
+#   The region can be given with an exp file, a list of elements.
+#
+#   Usage: 
+#      flag=FlagElements(md,region);
+#
+#   Example:
+#      flag=FlagElements(md,'all');
+#      flag=FlagElements(md,'');
+#      flag=FlagElements(md,'Domain.exp');
+#      flag=FlagElements(md,'~Domain.exp');
+#      flag=FlagElements(md,md.mask.elementongroundedice);
+
+	if isinstance(region,basestring):
+		if not(region):
+			flag=zeros(md.mesh.numberofelements,'bool')
+			invert=0;
+		elif region=='all':
+			flag=ones(md.mesh.numberofelements,'bool')
+			invert=0;
+		else:
+			#make sure that we actually don't want the elements outside the domain outline!
+			if region[0]=='~':
+				region=region[1:]
+				invert=1;
+			else:
+				invert=0;
+			
+			#does the region domain outline exist or do we have to look for xlim,ylim in basinzoom?
+			if not os.path.isfile(region):
+				[xlim,ylim]=basinzoom('basin',region);
+				flag_nodes=double(md.mesh.x<xlim(2) & md.mesh.x>xlim(1) &  md.mesh.y<ylim(2) & md.mesh.y>ylim(1));
+				flag=prod(flag_nodes(md.mesh.elements),2);
+			else:
+				#ok, flag elements
+				flag=ContourToMesh(md.mesh.elements[:,0:3],md.mesh.x,md.mesh.y,region,'element',1);
+		
+		if invert:
+			flag=~flag;
+	
+	elif isinstance(region,nparray):
+		if len(region)!=md.mesh.numberofelements:
+			print FlagElements.__doc__
+			print 'Flaglist for region must be of same size as number of elements in model'
+			return []
+		flag=region;
+	else:
+		print 'Invalid region option'
+		return []
+
+	return flag;
Index: sm/branches/trunk-jpl-damage/src/m/utils/ImageProcessing/gradient_perso.m
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/utils/ImageProcessing/gradient_perso.m	(revision 12167)
+++ 	(revision )
@@ -1,91 +1,0 @@
-function [ax,ay ]=gradient_perso(a,dx,dy,n);
-%GRADIENT_PERSO - gradient computation
-%
-%   INPUT a,dx,dy,n where a is the scalar value, dx and dy the spacing of one pixel
-%   in a and n is the width wanted in the gradient computation, in pixels.
-%
-%   Usage:
-%      [ax,ay ]=gradient_perso(a,dx,dy,n)
-
-s=size(a);
-ax=zeros(s(1),s(2));
-ay=zeros(s(1),s(2));
-
-for k=n+1:s(1)-n,
-   if mod(k,10)==0,
-      disp(k/s(1)*100);
-   end
-   
-   for j=n+1:s(2)-n,
-      if isnan(a(k,j)),
-         ax(k,j)=NaN;
-         ay(k,j)=NaN;
-      else
-         temp=a(k,j);
-         temp2=a(k,j);
-         
-         count=1;
-         while ~isnan(a(k,j+count)),
-            temp=[temp a(k,j+count)];
-            count=count+1;
-            if count>n,
-               count=count-1;
-               break;
-            end
-            
-         end
-         count=1;
-         while ~isnan(a(k,j-count)),
-            temp=[a(k,j-count) temp];
-            count=count+1;
-            if count>n,
-               count=count-1;
-               break;
-            end
-            
-         end
-         
-         count=1;
-         while ~isnan(a(k+count,j)),
-            temp2=[temp2 a(k+count,j)];
-            count=count+1;
-               if count>n,
-               count=count-1;
-               break;
-            end
-         
-         end
-         count=1;
-         while ~isnan(a(k-count,j)),
-            temp2=[a(k-count,j) temp2];
-            count=count+1;
-               if count>n,
-               count=count-1;
-               break;
-            end
-         
-         end
-    	   
-         if length(temp)==1,
-            ax(k,j)=NaN;
-         else
-            ax(k,j)=(temp(length(temp))-temp(1))/(length(temp)-1)/dx;
-         end
-         
-         if length(temp2)==1,
-            ay(k,j)=NaN;
-         else
-            ay(k,j)=(temp2(length(temp2))-temp2(1))/(length(temp2)-1)/dy;
-         end
-         
-      end
-   end
-end
-
-         
-          
-          
-          
-          
-          
-      
Index: sm/branches/trunk-jpl-damage/src/m/utils/ImageProcessing/transp.m
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/utils/ImageProcessing/transp.m	(revision 12167)
+++ 	(revision )
@@ -1,10 +1,0 @@
-bg = uint8(255.*rand(100, 100, 3));
-imview(bg);
-
-fg(:, :, 1) = uint8(255 .*(cumsum(ones(100, 100)) ./ 100));%
-fg(:, :, 2) = uint8(zeros(100));
-fg(:, :, 3) = flipud(fg(:, :, 1));
-imview(fg);
-
-res=immerge(bg, fg, .3);
-imview(res);
Index: /issm/branches/trunk-jpl-damage/src/m/utils/Meca/paterson.py
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/utils/Meca/paterson.py	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/m/utils/Meca/paterson.py	(revision 12168)
@@ -0,0 +1,50 @@
+from numpy import *
+
+def paterson(temperature):
+
+    # Local Variables: pos11, pos5, pos10, temperature, pos, T, pos8, pos9, pos6, pos7, pos4, rigidity, pos2, pos3, pos1
+    # Function calls: length, zeros, argwhere, paterson, error
+    #PATERSON - figure out the rigidity of ice for a given temperature
+    #
+    #   rigidigty (in s^(1/3)Pa) is the flow law paramter in the flow law sigma=B*e(1/3) (Paterson, p97). 
+    #   temperature is in Kelvin degrees
+    #
+    #   Usage:
+    #      rigidity=paterson(temperature)
+    
+	pos=argwhere(temperature<0.)
+	if len(pos):
+		print 'input temperature should be in Kelvin (positive)'
+		return []
+    
+	T = temperature-273.15
+	#The routine below is equivalent to:
+	# n=3; T=temperature-273;
+	# %From paterson,
+	# Temp=[0;-2;-5;-10;-15;-20;-25;-30;-35;-40;-45;-50];
+	# A=[6.8*10^-15;2.4*10^-15;1.6*10^-15;4.9*10^-16;2.9*10^-16;1.7*10^-16;9.4*
+	# 10^-17;5.1*10^-17;2.7*10^-17;1.4*10^-17;7.3*10^-18;3.6*10^-18];;%s-1(kPa-3)
+	# %Convert into rigidity B
+	# B=A.^(-1/n)*10^3; %s^(1/3)Pa
+	# %Now, do a cubic fit between Temp and B: 
+	# fittedmodel=fit(Temp,B,'cubicspline');
+	# rigidity=fittedmodel(temperature);
+
+	rigidity=zeros(len(T))
+	pos1=argwhere(T<=-45);           rigidity[pos1]=10**8*(-0.000292866376675*(T[pos1]+50)**3+ 0.011672640664130*(T[pos1]+50)**2  -0.325004442485481*(T[pos1]+50)+  6.524779401948101)
+	pos2=argwhere(logical_and(-45<=T,T<-40));   rigidity[pos2]=10**8*(-0.000292866376675*(T[pos2]+45)**3+ 0.007279645014004*(T[pos2]+45)**2  -0.230243014094813*(T[pos2]+45)+  5.154964909039554)
+	pos3=argwhere(logical_and(-40<=T,T<-35));   rigidity[pos3]=10**8*(0.000072737147457*(T[pos3]+40)**3+  0.002886649363879*(T[pos3]+40)**2  -0.179411542205399*(T[pos3]+40)+  4.149132666831214)
+	pos4=argwhere(logical_and(-35<=T,T<-30));   rigidity[pos4]=10**8*(-0.000086144770023*(T[pos4]+35)**3+ 0.003977706575736*(T[pos4]+35)**2  -0.145089762507325*(T[pos4]+35)+  3.333333333333331)
+	pos5=argwhere(logical_and(-30<=T,T<-25));   rigidity[pos5]=10**8*(-0.000043984685769*(T[pos5]+30)**3+ 0.002685535025386*(T[pos5]+30)**2  -0.111773554501713*(T[pos5]+30)+  2.696559088937191)
+	pos6=argwhere(logical_and(-25<=T,T<-20));   rigidity[pos6]=10**8*(-0.000029799523463*(T[pos6]+25)**3+ 0.002025764738854*(T[pos6]+25)**2  -0.088217055680511*(T[pos6]+25)+  2.199331606342181)
+	pos7=argwhere(logical_and(-20<=T,T<-15));   rigidity[pos7]=10**8*(0.000136920904777*(T[pos7]+20)**3+  0.001578771886910*(T[pos7]+20)**2  -0.070194372551690*(T[pos7]+20)+  1.805165505978111)
+	pos8=argwhere(logical_and(-15<=T,T<-10));   rigidity[pos8]=10**8*(-0.000899763781026*(T[pos8]+15)**3+ 0.003632585458564*(T[pos8]+15)**2  -0.044137585824322*(T[pos8]+15)+  1.510778053489523)
+	pos9=argwhere(logical_and(-10<=T,T<-5));    rigidity[pos9]=10**8*(0.001676964325070*(T[pos9]+10)**3-  0.009863871256831*(T[pos9]+10)**2  -0.075294014815659*(T[pos9]+10)+  1.268434288203714)
+	pos10=argwhere(logical_and(-5<=T,T<-2));    rigidity[pos10]=10**8*(-0.003748937622487*(T[pos10]+5)**3+0.015290593619213*(T[pos10]+5)**2  -0.048160403003748*(T[pos10]+5)+  0.854987973338348)
+	pos11=argwhere(-2<=T);           rigidity[pos11]=10**8*(-0.003748937622488*(T[pos11]+2)**3-0.018449844983174*(T[pos11]+2)**2  -0.057638157095631*(T[pos11]+2)+  0.746900791092860)
+
+	#Now make sure that rigidity is positive
+	pos=argwhere(rigidity<0);        rigidity[pos]=1**6 
+
+	return rigidity
+
Index: /issm/branches/trunk-jpl-damage/src/m/utils/Miscellaneous/issmdoc.m
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/utils/Miscellaneous/issmdoc.m	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/m/utils/Miscellaneous/issmdoc.m	(revision 12168)
@@ -2,9 +2,9 @@
 
 %First get ISSM tier: 
-ISSM_TIER=issmtier;
+ISSM_DIR=issmdir;
 
 disp(sprintf('\n%s','  A comprehensive documentation is available on http://issm.jpl.nasa.gov'));
 disp(sprintf('\n%s','  Example: how to create a square ice shelf'));
-disp(sprintf('%s','	   go to ',ISSM_TIER,'/examples/SquareIceshelf'));
+disp(sprintf('%s','	   go to ',ISSM_DIR,'/examples/SquareIceshelf'));
 disp(sprintf('%s','	   md=model;                                %creates a new empty model structure'));
 disp(sprintf('%s','	   md=triangle(md,''DomainOutline.exp'',50000);   %creates a mesh of the domain outline with a resolution of 50000m'));
Index: /issm/branches/trunk-jpl-damage/src/m/utils/OS/ispetsc.m
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/utils/OS/ispetsc.m	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/m/utils/OS/ispetsc.m	(revision 12168)
@@ -6,5 +6,5 @@
 
 
-configfile=[issmtier() '/bin/config.h']; %should find it in the install target
+configfile=[issmdir() '/bin/config.h']; %should find it in the install target
 if ~exist(configfile,'file'),
 	error(['File ' configfile ' not found. ISSM has not been configured yet!']);
Index: /issm/branches/trunk-jpl-damage/src/m/utils/OS/issmscpin.m
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/utils/OS/issmscpin.m	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/m/utils/OS/issmscpin.m	(revision 12168)
@@ -32,10 +32,10 @@
 		%use the putty project pscp.exe: it should be in the path.
 		
-		%get ISSM_TIER variable
-		[status,ISSM_TIER]=system('echo [%ISSM_TIER_WIN%]');
+		%get ISSM_DIR variable
+		[status,ISSM_DIR]=system('echo [%ISSM_DIR_WIN%]');
 		if status, 
-			error('scpin error message: could not find ISSM_TIER_WIN envirnoment variable');
+			error('scpin error message: could not find ISSM_DIR_WIN envirnoment variable');
 		end
-		ISSM_TIER=ISSM_TIER(2:end-2);
+		ISSM_DIR=ISSM_DIR(2:end-2);
 
 		username=input('Username: (quoted string) ');
@@ -43,5 +43,5 @@
 
 		for i=1:numel(packages),
-			[status,result]=system([ISSM_TIER '/externalpackages/ssh/pscp.exe -l "' username '" -pw "' key '" ' host ':' path '/' packages{i} ' ./']);
+			[status,result]=system([ISSM_DIR '/externalpackages/ssh/pscp.exe -l "' username '" -pw "' key '" ' host ':' path '/' packages{i} ' ./']);
 			if status, 
 				error('scpin error message: could not call putty pscp');
Index: /issm/branches/trunk-jpl-damage/src/m/utils/OS/issmscpout.m
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/utils/OS/issmscpout.m	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/m/utils/OS/issmscpout.m	(revision 12168)
@@ -23,10 +23,10 @@
 		%use the putty project pscp.exe: it should be in the path.
 		
-		%get ISSM_TIER variable
-		[status,ISSM_TIER]=system('echo [%ISSM_TIER_WIN%]');
+		%get ISSM_DIR variable
+		[status,ISSM_DIR]=system('echo [%ISSM_DIR_WIN%]');
 		if status, 
-			error('scpout error message: could not find ISSM_TIER_WIN envirnoment variable');
+			error('scpout error message: could not find ISSM_DIR_WIN envirnoment variable');
 		end
-		ISSM_TIER=ISSM_TIER(2:end-2);
+		ISSM_DIR=ISSM_DIR(2:end-2);
 
 		username=input('Username: (quoted string) ');
@@ -34,5 +34,5 @@
 
 		for i=1:numel(packages),
-			[status,result]=system([ISSM_TIER '/externalpackages/ssh/pscp.exe -l "' username '" -pw "' key '" ' packages{i} ' ' host ':' path]);
+			[status,result]=system([ISSM_DIR '/externalpackages/ssh/pscp.exe -l "' username '" -pw "' key '" ' packages{i} ' ' host ':' path]);
 			if status, 
 				error('scpout error message: could not call putty pscp');
Index: /issm/branches/trunk-jpl-damage/src/m/utils/OS/issmssh.m
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/utils/OS/issmssh.m	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/m/utils/OS/issmssh.m	(revision 12168)
@@ -15,15 +15,15 @@
 		%use the putty project plink.exe: it should be in the path.
 		
-		%get ISSM_TIER variable
-		[status,ISSM_TIER]=system('echo [%ISSM_TIER_WIN%]');
+		%get ISSM_DIR variable
+		[status,ISSM_DIR]=system('echo [%ISSM_DIR_WIN%]');
 		if status, 
-			error('issmssh error message: could not find ISSM_TIER_WIN envirnoment variable');
+			error('issmssh error message: could not find ISSM_DIR_WIN envirnoment variable');
 		end
-		ISSM_TIER=ISSM_TIER(2:end-2);
+		ISSM_DIR=ISSM_DIR(2:end-2);
 
 		username=input('Username: (quoted string) ');
 		key=input('Key: (quoted string) ');
 
-		system([ISSM_TIER '/externalpackages/ssh/plink.exe -ssh -l "' username '" -pw "' key '" ' host ' "' command '"']);
+		system([ISSM_DIR '/externalpackages/ssh/plink.exe -ssh -l "' username '" -pw "' key '" ' host ' "' command '"']);
 
 	else
Index: /issm/branches/trunk-jpl-damage/src/m/utils/Shell/flaimdir.m
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/utils/Shell/flaimdir.m	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/m/utils/Shell/flaimdir.m	(revision 12168)
@@ -5,3 +5,3 @@
 %      FLAIM_DIR=flaimdir()
 
-FLAIM_DIR=[issmtier '/externalpackages/flaim/install'];
+FLAIM_DIR=[issmdir '/externalpackages/flaim/install'];
Index: /issm/branches/trunk-jpl-damage/src/m/utils/Shell/issmdir.m
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/utils/Shell/issmdir.m	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/src/m/utils/Shell/issmdir.m	(revision 12168)
@@ -1,4 +1,4 @@
 function ISSM_DIR=issmdir()
-%ISSMDIR - Get ISSM_DIR environment variable contents.
+%ISSMDIR - Get ISSM_DIR environment variable
 %
 %   Usage:
@@ -9,4 +9,7 @@
 else
 	ISSM_DIR =getenv('ISSM_DIR_WIN');
+	if strcmpi(ISSM_DIR(end),'/') | strcmpi(ISSM_DIR(end),'\'),
+		ISSM_DIR = ISSM_DIR(1:end-1); %shave off the last '/'
+	end
 end
 
Index: sm/branches/trunk-jpl-damage/src/m/utils/Shell/issmtier.m
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/utils/Shell/issmtier.m	(revision 12167)
+++ 	(revision )
@@ -1,18 +1,0 @@
-function ISSM_TIER=issmtier()
-%ISSMTIER - Get ISSM_TIER environment variable contents.
-%
-%   Usage:
-%      ISSM_TIER=issmtier()
-
-if ~ispc, 
-	ISSM_TIER =getenv('ISSM_TIER');
-else
-	ISSM_TIER =getenv('ISSM_TIER_WIN');
-	if strcmpi(ISSM_TIER(end),'/') | strcmpi(ISSM_TIER(end),'\'),
-		ISSM_TIER = ISSM_TIER(1:end-1); %shave off the last '/'
-	end
-end
-
-if (isempty(ISSM_TIER)),
-	error('issmdir error message: ''ISSM_TIER'' environment variable is empty! You should define ISSM_TIER in your .cshrc or .bashrc!');
-end
Index: /issm/branches/trunk-jpl-damage/src/m/utils/Shell/jplsvn.m
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/utils/Shell/jplsvn.m	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/m/utils/Shell/jplsvn.m	(revision 12168)
@@ -0,0 +1,15 @@
+function JPL_SVN=jplsvn()
+%ISSMDIR - Get JPL_SVN environment variable
+%
+%   Usage:
+%      JPL_SVN=jplsvn()
+
+if ~ispc,
+	JPL_SVN =getenv('JPL_SVN');
+else
+	JPL_SVN =getenv('JPL_SVN_WIN');
+end
+
+if (isempty(JPL_SVN)),
+	error('jplsvn error message: ''JPL_SVN'' environment variable is empty! You should define JPL_SVN in your .cshrc or .bashrc');
+end
Index: /issm/branches/trunk-jpl-damage/src/m/utils/Shell/ucisvn.m
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/utils/Shell/ucisvn.m	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/m/utils/Shell/ucisvn.m	(revision 12168)
@@ -0,0 +1,15 @@
+function UCI_SVN=ucisvn()
+%ISSMDIR - Get UCI_SVN environment variable
+%
+%   Usage:
+%      UCI_SVN=ucisvn()
+
+if ~ispc,
+	UCI_SVN =getenv('UCI_SVN');
+else
+	UCI_SVN =getenv('UCI_SVN_WIN');
+end
+
+if (isempty(UCI_SVN)),
+	error('ucisvn error message: ''UCI_SVN'' environment variable is empty! You should define UCI_SVN in your .cshrc or .bashrc');
+end
Index: /issm/branches/trunk-jpl-damage/src/modules/AverageFilter/AverageFilter.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/modules/AverageFilter/AverageFilter.cpp	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/modules/AverageFilter/AverageFilter.cpp	(revision 12168)
@@ -0,0 +1,62 @@
+/*!\file:  AverageFilter.cpp
+ * \brief fill holes in matlab velocity array
+	this matlab module is an adaptation of a routine written by Robber 
+	Crippen.  The original routine was designed for the SRTM mission at JPL, 
+	and can be found in the current directory, under the name 
+	AverageFilterCrippen.  It fills void holes in an image, using an interpolation 
+	algorithm, and optionnally a smoothing algorithm. 
+	This matlab module extends the Crippen routine to be used in Matlab, 
+	using double arrays found in the workspace, and loaded directly into memory.
+*/
+
+
+#include "./AverageFilter.h"
+
+void mexFunction( int nlhs, mxArray* plhs[],
+				  int nrhs, const mxArray* prhs[])
+{
+
+	int i,j;
+
+	/* required input: */
+	double* imagein=NULL;
+	int     imagein_rows,imagein_cols;
+	int     smooth;
+
+
+	/* output: */
+	mxArray* pfield=NULL;
+	double* imageout=NULL;
+	int     imageout_rows,imageout_cols;
+
+	/*Boot module: */
+	MODULEBOOT();
+
+	/*checks on arguments on the matlab side: */
+	CheckNumMatlabArguments(nlhs,NLHS,nrhs,NRHS,__FUNCT__,&AverageFilterUsage);
+
+	/*Fetch data: */
+	FetchData(&imagein,&imagein_rows,&imagein_cols,IMAGEIN);
+	FetchData(&smooth,SMOOTH);
+	
+	/*Run core hole filler routine: */
+	AverageFilterx( &imageout,imagein,imagein_rows,imagein_cols,smooth);
+
+	/* output: */
+	WriteData(IMAGEOUT,imageout,imagein_rows,imagein_cols);
+
+	/*end module: */
+	MODULEEND();
+}
+
+
+void AverageFilterUsage(void)
+{
+	printf("   AverageFilter usage:\n");
+	printf("   [image_out]=AverageFilter(image_in,pixels);\n\n");
+	printf("   where:\n");
+	printf("      image_in in double format\n");
+	printf("      pixels: characteristic size of smoothing\n");
+	printf("      image_out in double format\n");
+	printf("\n");
+}
Index: /issm/branches/trunk-jpl-damage/src/modules/AverageFilter/AverageFilter.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/modules/AverageFilter/AverageFilter.h	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/modules/AverageFilter/AverageFilter.h	(revision 12168)
@@ -0,0 +1,36 @@
+
+/*
+	AverageFilter.h
+*/
+
+
+#ifndef _AVERAGEFILTER_H
+#define _AVERAGEFILTER_H
+
+/* local prototypes: */
+void AverageFilterUsage(void);
+
+#include "../../c/include/globals.h"
+#include "../../c/modules/modules.h"
+#include "../../c/Container/Container.h"
+#include "../../c/shared/shared.h"
+#include "../../c/issm-binding.h"
+
+#undef __FUNCT__ 
+#define __FUNCT__  "AverageFilter"
+
+
+/* serial input macros: */
+#define IMAGEIN prhs[0]
+#define SMOOTH prhs[1]
+
+/* serial output macros: */
+#define IMAGEOUT &plhs[0]
+
+/* serial arg counts: */
+#undef NLHS
+#define NLHS  1
+#undef NRHS
+#define NRHS  2
+
+#endif  /* _AVERAGEFILTER_H */
Index: /issm/branches/trunk-jpl-damage/src/modules/BamgConvertMesh/BamgConvertMesh.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/modules/BamgConvertMesh/BamgConvertMesh.cpp	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/modules/BamgConvertMesh/BamgConvertMesh.cpp	(revision 12168)
@@ -0,0 +1,86 @@
+/*\file BamgConvertMesh.c
+ *\brief: bamg module.
+ */
+#include "./BamgConvertMesh.h"
+
+void mexFunction( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]){
+
+	/*input: */
+	double* index=NULL;
+	int     index_rows;
+	double* x=NULL;
+	int     x_cols;
+	double* y=NULL;
+	int     y_rows;
+	int     y_cols;
+
+	/*Output*/
+	BamgMesh* bamgmesh=NULL;
+	BamgGeom* bamggeom=NULL;
+	mxArray* bamgmesh_mat=NULL;
+	mxArray* bamggeom_mat=NULL;
+
+	/*Intermediary*/
+	int nods;
+	int nels;
+	int verbose=0;
+
+	/*Boot module: */
+	MODULEBOOT();
+
+	/*checks on arguments on the matlab side: */
+	CheckNumMatlabArguments(nlhs,NLHS,nrhs,NRHS,__FUNCT__,&BamgConvertMeshUsage);
+
+	/*Initialize Bamg outputs*/
+	bamggeom=new BamgGeom();
+	bamgmesh=new BamgMesh();
+
+	/*Input datasets: */
+	if (verbose) printf("Fetching inputs\n");
+	FetchData(&index,&nels,&index_rows,INDEXHANDLE);
+	FetchData(&x,&nods,&x_cols,XHANDLE);
+	FetchData(&y,&y_rows,&y_cols,YHANDLE);
+
+	/*Check inputs*/
+	if (nels<0){
+		_error_("Number of elements must be positive, check index number of lines");
+	}
+	if (nods<0){
+		_error_("Number of nods must be positive, check x and y sizes");
+	}
+	if (index_rows!=3){
+		_error_("index should have 3 columns");
+	}
+	if (y_rows!=nods){
+		_error_("x and y do not have the same length");
+	}
+	if (x_cols>1 || y_cols>1){
+		_error_("x and y should have only one column");
+	}
+
+	/* Run core computations: */
+	if (verbose) printf("Call core\n");
+	BamgConvertMeshx(bamgmesh,bamggeom,index,x,y,nods,nels);
+
+	/*Generate output Matlab Structures*/
+	WriteData(BAMGGEOMOUT,bamggeom);
+	WriteData(BAMGMESHOUT,bamgmesh);
+
+	/*Clean up*/
+	delete bamggeom;
+	delete bamgmesh;
+
+	/*end module: */
+	MODULEEND();
+}
+
+void BamgConvertMeshUsage(void)
+{
+	_printf_(true,"BAMGCONVERTMESH - convert [x y index] to a bamg geom and mesh geom");
+	_printf_(true,"\n");
+	_printf_(true,"   Usage:\n");
+	_printf_(true,"      [bamggeom bamgmesh]=BamgConvertMesh(index,x,y);\n");
+	_printf_(true,"      index: index of the mesh\n");
+	_printf_(true,"      x,y: coordinates of the nodes\n");
+	_printf_(true,"\n");
+}
Index: /issm/branches/trunk-jpl-damage/src/modules/BamgConvertMesh/BamgConvertMesh.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/modules/BamgConvertMesh/BamgConvertMesh.h	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/modules/BamgConvertMesh/BamgConvertMesh.h	(revision 12168)
@@ -0,0 +1,36 @@
+/*!\file BamgConvertMesh.h
+ * \brief: prototype for Data Interpolation mex module.
+ */
+
+#ifndef _BAMGCONVERTMESH_H
+#define _BAMGCONVERTMESH_H
+
+/* local prototypes: */
+void BamgConvertMeshUsage(void);
+
+#include "../../c/include/globals.h"
+#include "../../c/modules/modules.h"
+#include "../../c/Container/Container.h"
+#include "../../c/shared/shared.h"
+#include "../../c/issm-binding.h"
+
+#undef __FUNCT__ 
+#define __FUNCT__  "BamgConvertMesh"
+
+
+/* serial input macros: */
+#define INDEXHANDLE prhs[0]
+#define XHANDLE prhs[1]
+#define YHANDLE prhs[2]
+
+/* serial output macros: */
+#define BAMGMESHOUT    (mxArray**)&plhs[0]
+#define BAMGGEOMOUT    (mxArray**)&plhs[1]
+
+/* serial arg counts: */
+#undef NLHS
+#define NLHS  2
+#undef NRHS
+#define NRHS  3
+
+#endif
Index: /issm/branches/trunk-jpl-damage/src/modules/BamgMesher/BamgMesher.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/modules/BamgMesher/BamgMesher.cpp	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/modules/BamgMesher/BamgMesher.cpp	(revision 12168)
@@ -0,0 +1,56 @@
+/*\file BamgMesher.c
+ *\brief: mesher that uses the bamg library
+ */
+#include "./BamgMesher.h"
+
+void mexFunction( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]){
+
+	/*Outputs*/
+	mxArray* bamgmesh_mat=NULL;
+	mxArray* bamggeom_mat=NULL;
+
+	/*diverse: */
+	BamgOpts *bamgopts=NULL;
+	BamgMesh *bamgmesh_in=NULL;
+	BamgGeom *bamggeom_in=NULL;
+	BamgMesh *bamgmesh_out=NULL;
+	BamgGeom *bamggeom_out=NULL;
+
+	/*Boot module: */
+	MODULEBOOT();
+
+	/*checks on arguments on the matlab side: */
+	CheckNumMatlabArguments(nlhs,NLHS,nrhs,NRHS,__FUNCT__,&BamgMesherUsage);
+
+	/*Initialize outputs*/
+	bamggeom_out=new BamgGeom();
+	bamgmesh_out=new BamgMesh();
+
+	/*Fetch inputs: */
+	FetchData(&bamgopts,BAMGOPTIONS);
+	FetchData(&bamggeom_in,BAMGGEOMIN);
+	FetchData(&bamgmesh_in,BAMGMESHIN);
+
+	/*Call x layer*/
+	Bamgx(bamgmesh_out,bamggeom_out,bamgmesh_in,bamggeom_in,bamgopts);
+
+	/*Generate output Matlab Structures*/
+	WriteData(BAMGGEOMOUT,bamggeom_out);
+	WriteData(BAMGMESHOUT,bamgmesh_out);
+
+	/*Free ressources: */
+	delete bamgopts;
+	delete bamggeom_in;
+	delete bamggeom_out;
+	delete bamgmesh_in;
+	delete bamgmesh_out;
+
+	/*end module: */
+	MODULEEND();
+}
+
+void BamgMesherUsage(void){
+	_printf_(true,"\n");
+	_printf_(true,"   usage: [bamgmesh,bamggeom]=%s(bamgmesh,bamggeom,bamgoptions);\n",__FUNCT__);
+	_printf_(true,"\n");
+}
Index: /issm/branches/trunk-jpl-damage/src/modules/BamgMesher/BamgMesher.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/modules/BamgMesher/BamgMesher.h	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/modules/BamgMesher/BamgMesher.h	(revision 12168)
@@ -0,0 +1,36 @@
+/*
+	BamgMesherUsage.h
+*/
+
+#ifndef _BAMG_MESHER_H_
+#define _BAMG_MESHER_H_
+
+/* local prototypes: */
+void BamgMesherUsage(void);
+
+#include "../../c/include/globals.h"
+#include "../../c/modules/modules.h"
+#include "../../c/Container/Container.h"
+#include "../../c/shared/shared.h"
+#include "../../c/issm-binding.h"
+
+#undef __FUNCT__ 
+#define __FUNCT__  "BamgMesher"
+    
+/* serial input macros: */
+#define BAMGMESHIN  (mxArray*)prhs[0]
+#define BAMGGEOMIN  (mxArray*)prhs[1]
+#define BAMGOPTIONS (mxArray*)prhs[2]
+
+/* serial output macros: */
+#define BAMGMESHOUT    (mxArray**)&plhs[0]
+#define BAMGGEOMOUT    (mxArray**)&plhs[1]
+
+/* serial arg counts: */
+#undef NLHS
+#define NLHS  2
+#undef NRHS
+#define NRHS  3
+
+#endif  /* _BAMG_MESHER_H_ */
+
Index: /issm/branches/trunk-jpl-damage/src/modules/BamgTriangulate/BamgTriangulate.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/modules/BamgTriangulate/BamgTriangulate.cpp	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/modules/BamgTriangulate/BamgTriangulate.cpp	(revision 12168)
@@ -0,0 +1,58 @@
+/*\file BamgTriangulate.c
+ *\brief: bamg module.
+ */
+#include "./BamgTriangulate.h"
+
+void mexFunction( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]){
+
+	/*input: */
+	double* x=NULL;
+	double* y=NULL;
+	int     x_cols;
+	int     y_rows,y_cols;
+	int nods;
+
+	/*Output*/
+	int* index=NULL;
+	int  nels;
+
+	/*Intermediary*/
+	int verbose=0;
+
+	/*Boot module: */
+	MODULEBOOT();
+
+	/*checks on arguments on the matlab side: */
+	CheckNumMatlabArguments(nlhs,NLHS,nrhs,NRHS,__FUNCT__,&BamgTriangulateUsage);
+
+	/*Input datasets: */
+	if (verbose) printf("Fetching inputs\n");
+	FetchData(&x,&nods,&x_cols,XHANDLE);
+	FetchData(&y,&y_rows,&y_cols,YHANDLE);
+
+	/*Check inputs*/
+	if(y_rows!=nods)         _error_("x and y do not have the same length");
+	if(x_cols>1 || y_cols>1) _error_("x and y should have only one column");
+	if(nods<3)               _error_("At least 3 points are required");
+
+	/* Run core computations: */
+	if (verbose) printf("Call core\n");
+	BamgTriangulatex(&index,&nels,x,y,nods);
+
+	/*Write output*/
+	WriteData(INDEX,index,nels,3);
+
+	/*end module: */
+	MODULEEND();
+}
+
+void BamgTriangulateUsage(void)
+{
+	_printf_(true,"BAMGTRIANGULATE - Delaunay Triangulation of a list of points");
+	_printf_(true,"\n");
+	_printf_(true,"   Usage:\n");
+	_printf_(true,"      index=BamgTriangulate(x,y);\n");
+	_printf_(true,"      index: index of the triangulation\n");
+	_printf_(true,"      x,y: coordinates of the nodes\n");
+	_printf_(true,"\n");
+}
Index: /issm/branches/trunk-jpl-damage/src/modules/BamgTriangulate/BamgTriangulate.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/modules/BamgTriangulate/BamgTriangulate.h	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/modules/BamgTriangulate/BamgTriangulate.h	(revision 12168)
@@ -0,0 +1,34 @@
+/*!\file BamgTriangulate.h
+ * \brief: prototype for Data Interpolation mex module.
+ */
+
+#ifndef _BAMGTRIANGULATE_H
+#define _BAMGTRIANGULATE_H
+
+/* local prototypes: */
+void BamgTriangulateUsage(void);
+
+#include "../../c/include/globals.h"
+#include "../../c/modules/modules.h"
+#include "../../c/Container/Container.h"
+#include "../../c/shared/shared.h"
+#include "../../c/issm-binding.h"
+
+#undef __FUNCT__ 
+#define __FUNCT__  "BamgTriangulate"
+
+
+/* serial input macros: */
+#define XHANDLE prhs[0]
+#define YHANDLE prhs[1]
+
+/* serial output macros: */
+#define INDEX (mxArray**)&plhs[0]
+
+/* serial arg counts: */
+#undef NLHS
+#define NLHS  1
+#undef NRHS
+#define NRHS  2
+
+#endif
Index: /issm/branches/trunk-jpl-damage/src/modules/Chaco/Chaco.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/modules/Chaco/Chaco.cpp	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/modules/Chaco/Chaco.cpp	(revision 12168)
@@ -0,0 +1,137 @@
+/*\file Chaco.c
+ *\brief:  Chaco partitioner mex module
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+
+#include "./Chaco.h"
+
+void mexFunction( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]){
+   
+	int i;
+	int nterms;
+
+	/*Inputs: */
+	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              */
+	int     nedges;
+	float  *ewgts       = NULL;  /* weights for all edges                 */
+	float  *x           = NULL;
+	float  *y           = NULL;
+	float  *z           = NULL;  /* coordinates for inertial method       */
+	double  options[10] = {1,1,0,0,1,1,50,0,.001,7654321}; /* architecture and partitioning options */
+	double *in_options  = NULL;
+	int    *nparts      = NULL;   /* number of parts options               */
+	int     npart;
+	double *goal        = NULL;   /* desired set sizes                     */
+
+	/*intermediary pointers: */
+	mwIndex *mwstart, *mwadjacency;
+	double  *doublepointer;
+
+	/*output: */
+   short  *assignment       = NULL; /* set number of each vtx (length nvtxs+1)                */
+   double *doubleassignment = NULL; /*holds assignment, in double format, to return to matlab */
+
+	#ifndef _HAVE_CHACO_ //only works if dakota library has been compiled in.
+	_error_(" Chaco not available! Cannot carry out Chaco partitioning!");
+	#endif
+
+	/*Boot module: */
+	MODULEBOOT();
+
+	/*checks on arguments on the matlab side: */
+	CheckNumMatlabArguments(nlhs,NLHS,nrhs,NRHS,__FUNCT__,&ChacoUsage);
+
+	/*Fetch adjacency matrix: */
+	nvtxs = mxGetN(A_IN);
+	mwstart = mxGetJc(A_IN);
+	start=(int*)xmalloc((nvtxs+1)*sizeof(int));
+	for (i=0; i<nvtxs+1;i++)start[i]=(int)mwstart[i];
+
+	mwadjacency = mxGetIr(A_IN);
+	adjacency = (int*)xmalloc(mxGetNzmax(A_IN)*sizeof(int));
+	for (i=0; i<mxGetNzmax(A_IN); i++) adjacency[i]= (int)mwadjacency[i];
+
+	nedges = start[nvtxs];
+	if(!mxIsEmpty(EWGTS_IN)){
+		ewgts = (float*)xcalloc(nedges, sizeof(float));
+		doublepointer=mxGetPr(A_IN);
+		for (i = 0; i < nedges; i++)ewgts[i] = (float)doublepointer[i];
+	}
+	else ewgts=NULL;
+
+	/*Fetch rest of data: */
+	FetchData(&vwgts,&nterms,VWGTS_IN); 
+	FetchData(&x,&nterms,X_IN); 
+	FetchData(&y,&nterms,Y_IN); 
+	FetchData(&z,&nterms,Z_IN); 
+	FetchData(&in_options,&nterms,OPTNS_IN); 
+	for (i=0;i<(nterms<10?nterms:10);i++) options[i]=in_options[i]; //copy in_options into default options
+	FetchData(&npart,NPARTS_IN); 
+	nparts=(int*)xmalloc(sizeof(int)); nparts[0]=npart; //weird Chacox interface ain't it?
+	FetchData(&goal,&nterms,GOAL_IN); 
+	
+	/*Some debugging print: {{{*/
+	#ifdef _DEBUG_
+	printf("nvtxs: %i\n",nvtxs);
+	printf("options: [");
+	for(i=0;i<10;i++)printf("%g|",options[i]);
+	printf("]\n");
+	printf("start: \n");
+	for (i=0; i<nvtxs+1;i++)printf("%i ",start[i]);
+	printf("\n");
+	printf("adjacency: \n");
+	for (i=0; i<mxGetNzmax(A_IN);i++)printf("%i ",adjacency[i]);
+	printf("\n");
+	printf("nedges: %i %p\n",nedges,ewgts);
+	if(ewgts) for (i = 0; i < nedges; i++)printf("%g ",ewgts[i]);
+	printf("\n");
+	printf("vwgts:\n");
+	for (i = 0; i < nvtxs; i++)printf("%g ",vwgts[i]);
+	printf("\n");
+	printf("nparts: %i\n",nparts[0]);
+	printf("goal: %p\n",goal);
+	#endif
+	/*}}}*/
+	
+	/*Allocate output: */
+	assignment = (short*)xcalloc(nvtxs, sizeof(short));
+	
+    /*Call core: */
+	Chacox(nvtxs, start, adjacency, vwgts, ewgts, x, y, z, assignment, options, nparts, goal);
+
+    /*Output data: */
+	doubleassignment=(double*)xmalloc(nvtxs*sizeof(double));
+	for(i=0;i<nvtxs;i++) doubleassignment[i]=(double)assignment[i];
+	WriteData(ASSGN_OUT,doubleassignment,nvtxs);
+
+	/*Free ressources:*/
+	xfree((void**)&assignment); 
+	xfree((void**)&goal);
+	xfree((void**)&nparts);
+	xfree((void**)&z);
+	xfree((void**)&y);
+	xfree((void**)&x);
+	xfree((void**)&ewgts);
+	xfree((void**)&vwgts);
+	xfree((void**)&adjacency);
+	xfree((void**)&start);
+	xfree((void**)&doubleassignment);
+
+	/*end module: */
+	MODULEEND();
+}
+
+void ChacoUsage(void){
+	_printf_(true,"\n");
+	_printf_(true,"Usage: [assgn] = Chaco(A,vwgts,ewgts,x,y,z,options,nparts,goal);\n");
+	_printf_(true,"\n");
+}
Index: /issm/branches/trunk-jpl-damage/src/modules/Chaco/Chaco.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/modules/Chaco/Chaco.h	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/modules/Chaco/Chaco.h	(revision 12168)
@@ -0,0 +1,44 @@
+/*!\file:  Chaco.h
+ * \brief header file for Chaco module.
+ */ 
+
+#ifndef _CHACO_H
+#define _CHACO_H
+
+/* local prototypes: */
+void ChacoUsage(void);
+
+#include <stdio.h>
+#include <string.h>    /*  strcasecmp  */
+#include <time.h>      /*  clock,time,difftime  */
+
+#include "../../c/include/globals.h"
+#include "../../c/modules/modules.h"
+#include "../../c/Container/Container.h"
+#include "../../c/shared/shared.h"
+#include "../../c/issm-binding.h"
+    
+/* serial input macros: */
+#define A_IN (mxArray*)prhs[0]
+#define VWGTS_IN (mxArray*)prhs[1]
+#define EWGTS_IN (mxArray*)prhs[2]
+#define X_IN (mxArray*)prhs[3]
+#define Y_IN (mxArray*)prhs[4]
+#define Z_IN (mxArray*)prhs[5]
+#define OPTNS_IN (mxArray*)prhs[6]
+#define NPARTS_IN (mxArray*)prhs[7]
+#define GOAL_IN (mxArray*)prhs[8]
+
+/* serial output macros: */
+#define ASSGN_OUT (mxArray**)&plhs[0]
+
+/* serial arg counts: */
+#undef NLHS
+#define NLHS  1
+#undef NRHS
+#define NRHS  9
+
+#undef __FUNCT__ 
+#define __FUNCT__  "Chaco"
+
+#endif  /* _CHACO_H */
Index: /issm/branches/trunk-jpl-damage/src/modules/ContourToMesh/ContourToMesh.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/modules/ContourToMesh/ContourToMesh.cpp	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/modules/ContourToMesh/ContourToMesh.cpp	(revision 12168)
@@ -0,0 +1,113 @@
+/*! \file  ContourtoMesh
+    \brief: takes an  contour file, and figures out which nodes or elements from the mesh  
+    are inside this contour. 
+	usage:
+	[in_nod,in_elem]=ContourToMesh(index,x,y,contours,interptype,edgevalue);
+	
+	input:
+
+		index,x,y: delaunay triangulation.
+		contours: structure holding sets of vertices making open contours. 
+		interptype: string definining type of interpolation ('element', or 'node', or 'element and node');
+		edgevalue: integer (0, 1 or 2) defining the value associated to the nodes on the edges of the polygons
+
+	output:
+		in_nod: vector of flags (0 or 1), of size nods if interptype is set to 'node' or 'element and node', 
+				or of size 0 otherwise.
+		in_elem: vector of flags (0 or 1), of size nel if interptype is set to 'element' or 'element and node', 
+				or of size 0 otherwise.
+*/
+	
+#include "./ContourToMesh.h"
+
+WRAPPER(ContourToMesh){
+
+	int i,j;
+
+	/* required input: */
+	int     edgevalue;
+	double *index      = NULL;
+	int     nel;
+	double *x          = NULL;
+	int     nods;
+	double *y          = NULL;
+	char   *interptype = NULL;
+	char* contourname  = NULL;
+	DataSet* contours  = NULL;
+
+	/* output: */
+	Vector *in_nod  = NULL;
+	Vector *in_elem = NULL;
+
+	/*Boot module: */
+	MODULEBOOT();
+
+	/*checks on output arguments on the matlab side: */
+	#ifdef _HAVE_MATLAB_MODULES_
+	if(nlhs!=1 && nlhs!=2){
+		ContourToMeshUsage();
+		_error_(" usage. See above");
+	}
+	#endif
+	/*check on input arguments: */
+	if(nrhs!=NRHS){
+		ContourToMeshUsage();
+		_error_(" usage. See above");
+	}
+
+
+	/*Fetch inputs: */
+	FetchData(&index,&nel,NULL,INDEX);
+	FetchData(&x,&nods,NULL,X);
+	FetchData(&y,NULL,NULL,Y);
+	FetchData(&edgevalue,EDGEVALUE);
+	FetchData(&contourname,CONTOURNAME);
+	contours=DomainOutlineRead(contourname);
+
+	/*Fetch  interptype: */
+	FetchData(&interptype,INTERPTYPE);
+
+	/*Run interpolation routine: */
+	ContourToMeshx( &in_nod,&in_elem,index,x,y,contours,interptype,nel,nods,edgevalue);
+
+	/* output: */
+	if (strcmp(interptype,"node")==0){
+		WriteData(PLHS0,in_nod);
+	}
+	else if (strcmp(interptype,"element")==0){
+		WriteData(PLHS0,in_elem);
+	}
+	else if (strcmp(interptype,"element and node")==0){
+		WriteData(PLHS0,in_nod);
+		WriteData(PLHS1,in_elem);
+	}
+	else _error_(" wrong interpolation type");
+
+	/*end module: */
+	MODULEEND();
+	
+}
+
+void ContourToMeshUsage(void)//{{{1
+{
+	printf("CONTOURTOMESH - Flag the elements or nodes inside a contour\n");
+	printf("\n");
+	printf("      Usage: \n");
+	printf("         [in_nod,in_elem]=ContourToMesh(index,x,y,contourname,interptype,edgevalue)\n\n");
+	printf("\n");
+	printf("         index,x,y: mesh triangulation.\n");
+	printf("         contourname: name of .exp file containing the contours.\n");
+	printf("         interptype: string definining type of interpolation ('element', or 'node').\n");
+	printf("         edgevalue: integer (0, 1 or 2) defining the value associated to the nodes on the edges of the polygons.\n");
+	printf("         in_nod: vector of flags (0 or 1), of size nods if interptype is set to 'node' or 'element and node', \n");
+	printf("            or of size 0 otherwise.\n");
+	printf("         in_elem: vector of flags (0 or 1), of size nel if interptype is set to 'element' or 'element and node', \n");
+	printf("            or of size 0 otherwise.\n");
+	printf("\n");
+	printf("      Example: \n");
+	printf("         in_nod=ContourToMesh(md.elements,md.x,md.y,'Contour.exp','node',1)\n");
+	printf("         in_elements=ContourToMesh(md.elements,md.x,md.y,'Contour.exp','element',0)\n");
+	printf("         [in_nodes,in_elements]=ContourToMesh(md.elements,md.x,md.y,'Contour.exp','element and node',0)\n");
+	printf("\n");
+}
+//}}}
Index: /issm/branches/trunk-jpl-damage/src/modules/ContourToMesh/ContourToMesh.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/modules/ContourToMesh/ContourToMesh.h	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/modules/ContourToMesh/ContourToMesh.h	(revision 12168)
@@ -0,0 +1,72 @@
+
+/*
+	ContourToMesh.h
+*/
+
+
+#ifndef _CONTOURTOMESH_H
+#define _CONTOURTOMESH_H
+
+
+#ifdef HAVE_CONFIG_H
+	#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+/*Very important definition in case we are compiling a python module!: needs to come before header files inclusion*/
+#ifdef _HAVE_PYTHON_
+#define PY_ARRAY_UNIQUE_SYMBOL PythonIOSymbol
+#endif
+
+/*Header files: */
+#include "../../c/include/globals.h"
+#include "../../c/toolkits/toolkits.h"
+#include "../../c/include/include.h"
+#include "../../c/modules/modules.h"
+#include "../../c/Container/Container.h"
+#include "../../c/shared/shared.h"
+#include "../../c/issm-binding.h"
+#include "../../c/io/io.h"
+#include "../../c/EnumDefinitions/EnumDefinitions.h"
+
+#ifdef _HAVE_MATLAB_MODULES_
+/* serial input macros: */
+#define INDEX (mxArray *)prhs[0]
+#define X (mxArray *)prhs[1]
+#define Y (mxArray *)prhs[2]
+#define CONTOURNAME (mxArray *)prhs[3]
+#define INTERPTYPE (mxArray *)prhs[4]
+#define EDGEVALUE (mxArray *)prhs[5]
+/* serial output macros: */
+#define PLHS0 (mxArray**)&plhs[0]
+#define PLHS1 (mxArray**)&plhs[1]
+#endif
+
+#ifdef _HAVE_PYTHON_MODULES_
+/* serial input macros: */
+#define INDEX PyTuple_GetItem(args,0)
+#define X PyTuple_GetItem(args,1)
+#define Y PyTuple_GetItem(args,2)
+#define CONTOURNAME PyTuple_GetItem(args,3)
+#define INTERPTYPE PyTuple_GetItem(args,4)
+#define EDGEVALUE PyTuple_GetItem(args,5)
+/* serial output macros: */
+#define PLHS0 output,0
+#define PLHS1 output,1
+#endif
+
+#undef __FUNCT__
+#define __FUNCT__ "ContourToMesh"
+
+/* serial arg counts: */
+#undef NLHS
+#define NLHS  2
+#undef NRHS
+#define NRHS 6
+
+/* local prototypes: */
+void ContourToMeshUsage(void);
+
+#endif  /* _CONTOURTOMESH_H */
+
Index: /issm/branches/trunk-jpl-damage/src/modules/ContourToNodes/ContourToNodes.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/modules/ContourToNodes/ContourToNodes.cpp	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/modules/ContourToNodes/ContourToNodes.cpp	(revision 12168)
@@ -0,0 +1,114 @@
+/*! \file  ContourtoNodes
+    \brief: takes a  contour file, and figures out which nodes  (x,y list)
+    are inside this contour. 
+
+	usage:
+	[flags]=ContourToNodes(x,y,contours,interptype,edgevalue);
+	
+	where:
+
+	input:
+
+		x,y: node cooredinates
+		
+		contours: structure holding sets of vertices making open contours. 
+		
+		interptype: string definining type of interpolation ('element', or 'node', or 'element and node');
+
+		edgevalue: integer (0, 1 or 2) defining the value associated to the nodes on the edges of the polygons
+
+	output:
+		flags: vector of flags (0 or 1), of size nods 
+*/
+	
+#include "./ContourToNodes.h"
+
+void mexFunction( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]) {
+
+	int i,j;
+
+	/* required input: */
+	double* x=NULL;
+	double* y=NULL;
+	int     edgevalue;
+	char*   interptype=NULL;
+
+	/* output: */
+	Vector*  flags=NULL;
+	int  nods;
+
+	//contours
+	mxArray*  matlabstructure=NULL;
+	int numcontours;
+	Contour** contours=NULL;
+	Contour*  contouri=NULL;
+
+	/*Boot module: */
+	MODULEBOOT();
+
+	/*checks on arguments on the matlab side: */
+	CheckNumMatlabArguments(nlhs,NLHS,nrhs,NRHS,__FUNCT__,&ContourToNodesUsage);
+
+	
+	/*Fetch inputs: */
+	FetchData(&x,&nods,NULL,XHANDLE);
+	FetchData(&y,NULL,NULL,YHANDLE);
+	FetchData(&edgevalue,EDGEVALUEHANDLE);
+
+	//Fetch contours
+
+	if(mxIsChar(FILENAME)){
+		/*Call expread on filename to build a contour array in the matlab workspace: */
+		mexCallMATLAB( 1, &matlabstructure, 1, (mxArray**)&FILENAME, "expread");
+	}
+	else{
+		/*FILENAME is actually a structure, coming directly from expread: */
+		matlabstructure=(mxArray*)FILENAME;
+	}
+
+	numcontours=mxGetNumberOfElements(matlabstructure);
+	contours=(Contour**)xmalloc(numcontours*sizeof(Contour*));
+	for(i=0;i<numcontours;i++){
+		//allocate
+		contouri=(Contour*)xmalloc(sizeof(Contour));
+		//retrieve dimension of this contour.
+		contouri->nods=(int)mxGetScalar(mxGetField(matlabstructure,i,"nods"));
+		//set pointers.
+		contouri->x=mxGetPr(mxGetField(matlabstructure,i,"x"));
+		contouri->y=mxGetPr(mxGetField(matlabstructure,i,"y"));
+		*(contours+i)=contouri;
+	}
+
+	/* Debugging of contours :{{{1*/
+	/*for(i=0;i<numcontours;i++){
+		printf("\nContour echo: contour number  %i / %i\n",i+1,numcontours);
+		contouri=*(contours+i);
+		printf("   Number of nodes %i\n",contouri->nods);
+		for (j=0;j<contouri->nods;j++){
+			printf("   %lf %lf\n",*(contouri->x+j),*(contouri->y+j));
+		}
+	}*/
+	/*}}}*/
+
+	/*Run interpolation routine: */
+	ContourToNodesx(&flags,x,y,nods,contours,numcontours,edgevalue);
+
+	/* output: */
+	WriteData(FLAGS,flags);
+
+	/*end module: */
+	MODULEEND();
+
+}
+
+void ContourToNodesUsage(void){
+	printf("   usage:\n");
+	printf("   [flags]=ContourToNodes(x,y,contourname,edgevalue);\n\n");
+	printf("   where:\n");
+	printf("      x,y: list of nodes.\n");
+	printf("      contourname: name of .exp file containing the contours, or resulting structure from call to expread.\n");
+	printf("      interptype: string definining type of interpolation ('element', or 'node').\n");
+	printf("      edgevalue: integer (0, 1 or 2) defining the value associated to the nodes on the edges of the polygons.\n");
+	printf("      flags: vector of flags (0 or 1), of size nods.\n");
+	printf("\n");
+}
Index: /issm/branches/trunk-jpl-damage/src/modules/ContourToNodes/ContourToNodes.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/modules/ContourToNodes/ContourToNodes.h	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/modules/ContourToNodes/ContourToNodes.h	(revision 12168)
@@ -0,0 +1,44 @@
+
+/*
+	ContourToNodes.h
+*/
+
+
+#ifndef _CONTOURTONODES_H
+#define _CONTOURTONODES_H
+
+/* local prototypes: */
+void ContourToNodesUsage(void);
+
+#include "../../c/include/globals.h"
+#include "../../c/modules/modules.h"
+#include "../../c/Container/Container.h"
+#include "../../c/shared/shared.h"
+#include "../../c/issm-binding.h"
+
+#undef __FUNCT__
+#define __FUNCT__ "ContourToNodes"
+
+
+#ifndef ALL
+#define ALL 0
+#endif
+
+/* input macros: */
+#define XHANDLE prhs[0]
+#define YHANDLE prhs[1]
+#define FILENAME prhs[2]
+#define EDGEVALUEHANDLE prhs[3]
+
+/* serial output macros: */
+#define FLAGS (mxArray**)&plhs[0]
+
+/* serial arg counts: */
+#undef NLHS
+#define NLHS 1
+#undef NRHS
+#define NRHS 4
+
+
+#endif  /* _CONTOURTONODES_H */
+
Index: /issm/branches/trunk-jpl-damage/src/modules/ElementConnectivity/ElementConnectivity.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/modules/ElementConnectivity/ElementConnectivity.cpp	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/modules/ElementConnectivity/ElementConnectivity.cpp	(revision 12168)
@@ -0,0 +1,42 @@
+/*\file ElementConnectivity.c
+ *\brief: build element connectivity using node connectivity and elements. 
+ */
+
+#include "./ElementConnectivity.h"
+
+WRAPPER(ElementConnectivity){
+
+	/*inputs: */
+	double* elements=NULL;
+	double* nodeconnectivity=NULL;
+	int     nel,nods;
+	int     width;
+
+	/*outputs: */
+	double* elementconnectivity=NULL;
+
+	/*Boot module: */
+	MODULEBOOT();
+
+	/*checks on arguments: */
+	CHECKARGUMENTS(NLHS,NRHS,&ElementConnectivityUsage);
+        
+	/*Input datasets: */
+	FetchData(&elements,&nel,NULL,ELEMENTS);
+	FetchData(&nodeconnectivity,&nods,&width,NODECONNECTIVITY);
+
+	/*!Generate internal degree of freedom numbers: */
+	ElementConnectivityx(&elementconnectivity, elements,nel, nodeconnectivity, nods, width);
+
+	/*write output datasets: */
+	WriteData(ELEMENTCONNECTIVITY,elementconnectivity,nel,3);
+
+	/*end module: */
+	MODULEEND();
+}
+
+void ElementConnectivityUsage(void) {
+	_printf_(true,"\n");
+	_printf_(true,"   usage: elementconnectivity = %s(elements, nodeconnectivity);\n",__FUNCT__);
+	_printf_(true,"\n");
+}
Index: /issm/branches/trunk-jpl-damage/src/modules/ElementConnectivity/ElementConnectivity.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/modules/ElementConnectivity/ElementConnectivity.h	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/modules/ElementConnectivity/ElementConnectivity.h	(revision 12168)
@@ -0,0 +1,60 @@
+/*
+	ElementConnectivity.h
+*/
+
+#ifndef _ELEMENTCONNECTIVITY_H
+#define _ELEMENTCONNECTIVITY_H
+
+#ifdef HAVE_CONFIG_H
+	#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+/*Very important definition in case we are compiling a python module!: needs to come before header files inclusion*/
+#ifdef _HAVE_PYTHON_
+#define PY_ARRAY_UNIQUE_SYMBOL PythonIOSymbol
+#endif
+
+/*Header files: */
+#include "../../c/include/globals.h"
+#include "../../c/toolkits/toolkits.h"
+#include "../../c/include/include.h"
+#include "../../c/modules/modules.h"
+#include "../../c/Container/Container.h"
+#include "../../c/shared/shared.h"
+#include "../../c/issm-binding.h"
+#include "../../c/io/io.h"
+#include "../../c/EnumDefinitions/EnumDefinitions.h"
+
+#ifdef _HAVE_MATLAB_MODULES_
+/* serial input macros: */
+/* serial input macros: */
+#define ELEMENTS (mxArray*)prhs[0]
+#define NODECONNECTIVITY (mxArray*)prhs[1]
+/* serial output macros: */
+#define ELEMENTCONNECTIVITY (mxArray**)&plhs[0]
+#endif
+
+#ifdef _HAVE_PYTHON_MODULES_
+/* serial input macros: */
+/* serial input macros: */
+#define ELEMENTS PyTuple_GetItem(args,0)
+#define NODECONNECTIVITY PyTuple_GetItem(args,1)
+/* serial output macros: */
+#define ELEMENTCONNECTIVITY output,0
+#endif
+
+#undef __FUNCT__ 
+#define __FUNCT__  "ElementConnectivity"
+
+/* serial arg counts: */
+#undef NLHS
+#define NLHS  1
+#undef NRHS
+#define NRHS  2
+
+/* local prototypes: */
+void ElementConnectivityUsage(void);
+
+#endif  /* _ELEMENTCONNECTIVITY_H */
Index: /issm/branches/trunk-jpl-damage/src/modules/EnumToString/EnumToString.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/modules/EnumToString/EnumToString.cpp	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/modules/EnumToString/EnumToString.cpp	(revision 12168)
@@ -0,0 +1,32 @@
+/*\file EnumToString.c
+ *\brief:convert enum (int) to string
+ */
+
+#include "./EnumToString.h"
+
+void mexFunction( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]){
+
+	char    *name    = NULL;
+	int      enum_in;
+
+	/*checks on arguments on the matlab side: */
+	if(nrhs!=NRHS){
+		EnumToStringUsage(); _error_(" usage. See above");
+	}
+
+	/*Fetch inputs: */
+	FetchData(&enum_in,ENUMIN);
+
+	/*Run core function: */
+	EnumToStringx(&name,enum_in);
+
+	/* output: */
+	WriteData(NAME,name);
+}
+
+void EnumToStringUsage(void)
+{
+	_printf_(true,"\n");
+	_printf_(true,"   usage: %sstring = EnumToString(enum);\n",__FUNCT__);
+	_printf_(true,"\n");
+}
Index: /issm/branches/trunk-jpl-damage/src/modules/EnumToString/EnumToString.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/modules/EnumToString/EnumToString.h	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/modules/EnumToString/EnumToString.h	(revision 12168)
@@ -0,0 +1,32 @@
+/*!\file:  EnumToString.h
+ * \brief header file for EnumToString module.
+ */ 
+
+#ifndef _ENUMTOSTRING_H
+#define _ENUMTOSTRING_H
+
+/* local prototypes: */
+void EnumToStringUsage(void);
+
+#include "../../c/include/globals.h"
+#include "../../c/modules/modules.h"
+#include "../../c/Container/Container.h"
+#include "../../c/shared/shared.h"
+#include "../../c/issm-binding.h"
+    
+/* serial input macros: */
+#define ENUMIN (mxArray*)prhs[0]
+
+/* serial output macros: */
+#define NAME (mxArray**)&plhs[0]
+
+/* serial arg counts: */
+#undef NLHS
+#define NLHS  1
+#undef NRHS
+#define NRHS  1
+
+#undef __FUNCT__ 
+#define __FUNCT__  "EnumToString"
+
+#endif  /* _TEST_H */
Index: /issm/branches/trunk-jpl-damage/src/modules/Exp2Kml/Exp2Kml.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/modules/Exp2Kml/Exp2Kml.cpp	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/modules/Exp2Kml/Exp2Kml.cpp	(revision 12168)
@@ -0,0 +1,98 @@
+/*\file Exp2Kml.c
+ *\brief: exp to kml file conversion mex module.
+ */
+#include "./Exp2Kml.h"
+
+void mexFunction( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]){
+
+	int i,verbose=1;
+
+	/*input: */
+	char    *filexp=NULL,*filkml=NULL;
+	int     sgn;
+
+	Options* options=NULL;
+	char     *choles=NULL;
+	bool     holes=false;
+	double   cm=0.,sp=0.;
+
+	/* output: */
+	int     iret=0;
+
+	/*Boot module: */
+	MODULEBOOT();
+
+	/*checks on arguments on the matlab side: */
+	if (nlhs > NLHS) {
+		Exp2KmlUsage(); _error_("Exp2Kml usage error");
+	}
+	if (nrhs < NRHS) {
+		Exp2KmlUsage(); _error_("Exp2Kml usage error");
+	}
+
+	/*Input datasets: */
+	FetchData(&filexp,EXP_IN);
+	FetchData(&filkml,KML_IN);
+	FetchData(&sgn,SGN_IN);
+	FetchData(&options,NRHS,nrhs,prhs);
+
+	options->Get(&choles,"holes","no");
+	if (!strncmp(choles,"y",1) || !strncmp(choles,"on",2)) holes=true;
+
+	/*  defaults are in Xy2lldef, so don't duplicate them here, and only use user values if both have been specified  */
+	if (options->GetOption("central_meridian") || options->GetOption("standard_parallel")) {
+		options->Get(&cm,"central_meridian");
+		if (verbose) printf("  cm=%g\n",cm);
+		options->Get(&sp,"standard_parallel");
+		if (verbose) printf("  sp=%g\n",sp);
+	}
+
+	/*some checks*/
+	if (sgn !=+1 && sgn !=-1) _error_("Hemisphere sgn=%d must be +1 (north) or -1 (south).",sgn);
+	if (fabs(cm)      > 180.) _error_("Central meridian cm=%g must be between -180 (west) and +180 (east) degrees.",cm);
+	if (sp < 0. || sp >  90.) _error_("Standard parallel sp=%g must be between 0 and 90 degrees (in specified hemisphere).",sp);
+
+	/* Run core computations: */
+	if (options->GetOption("central_meridian") && options->GetOption("standard_parallel"))
+		iret=Exp2Kmlx(filexp,filkml,sgn,cm,sp,holes);
+	else
+		iret=Exp2Kmlx(filexp,filkml,sgn,holes);
+
+	/*Write data: */
+	WriteData(RET_OUT,iret);
+
+	/*Clean-up*/
+	xfree((void**)&choles);
+	delete options;
+	xfree((void**)&filkml);
+	xfree((void**)&filexp);
+
+	/*end module: */
+	MODULEEND();
+}
+
+void Exp2KmlUsage(void){
+	_printf_(true,"Exp2Kml - exp to kml file conversion module:\n");
+	_printf_(true,"\n");
+	_printf_(true,"   This module converts a file from exp to kml format.\n");
+	_printf_(true,"\n");
+	_printf_(true,"   Usage:\n");
+	_printf_(true,"      [ret]=Exp2Kml(filexp,filkml,sgn,'param name',param,...);\n");
+	_printf_(true,"\n");
+	_printf_(true,"      filexp      file name of exp file to be read (char)\n");
+	_printf_(true,"      filkml      file name of kml file to be written (char)\n");
+	_printf_(true,"      sgn         sign for hemisphere (double, +1 (north) or -1 (south))\n");
+	_printf_(true,"\n");
+	_printf_(true,"      central_meridian     central meridian (double, optional, but must specify with sp)\n");
+	_printf_(true,"      standard_parallel    standard parallel (double, optional, but must specify with cm)\n");
+	_printf_(true,"      holes       flag for treatment of multiple profiles (char, optional, 'yes' for holes))\n");
+	_printf_(true,"\n");
+	_printf_(true,"      ret         return code (non-zero for warning)\n");
+	_printf_(true,"\n");
+	_printf_(true,"   Examples:\n");
+	_printf_(true,"      [ret]=Exp2Kml('file.exp','file.kml', 1);\n");
+	_printf_(true,"      [ret]=Exp2Kml('file.exp','file.kml', 1,'central_meridian',45,'standard_parallel',70,'holes','yes');\n");
+	_printf_(true,"      [ret]=Exp2Kml('file.exp','file.kml',-1,'central_meridian', 0,'standard_parallel',71,'holes','yes');\n");
+	_printf_(true,"\n");
+}
+
Index: /issm/branches/trunk-jpl-damage/src/modules/Exp2Kml/Exp2Kml.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/modules/Exp2Kml/Exp2Kml.h	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/modules/Exp2Kml/Exp2Kml.h	(revision 12168)
@@ -0,0 +1,36 @@
+/*!\file Exp2Kml.h
+ * \brief: prototype for exp to kml file conversion mex module.
+ */
+
+#ifndef _EXP2KML_H
+#define _EXP2KML_H
+
+/* local prototypes: */
+void Exp2KmlUsage(void);
+
+#include "../../c/include/globals.h"
+#include "../../c/modules/modules.h"
+#include "../../c/Container/Container.h"
+#include "../../c/shared/shared.h"
+#include "../../c/issm-binding.h"
+
+#undef __FUNCT__ 
+#define __FUNCT__  "Exp2Kml"
+
+
+/* serial input macros: */
+#define EXP_IN    prhs[0]
+#define KML_IN    prhs[1]
+#define SGN_IN    prhs[2]
+
+/* serial output macros: */
+#define RET_OUT    (mxArray**)&plhs[0]
+
+/* serial arg counts: */
+#undef NRHS
+#define NRHS  3
+#undef NLHS
+#define NLHS  1
+
+#endif
+
Index: /issm/branches/trunk-jpl-damage/src/modules/HoleFiller/HoleFiller.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/modules/HoleFiller/HoleFiller.cpp	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/modules/HoleFiller/HoleFiller.cpp	(revision 12168)
@@ -0,0 +1,69 @@
+/*!\file:  HoleFiller.cpp
+ * \brief fill holes in matlab velocity array
+	this matlab module is an adaptation of a routine written by Robber 
+	Crippen.  The original routine was designed for the SRTM mission at JPL, 
+	and can be found in the current directory, under the name 
+	HoleFillerCrippen.  It fills void holes in an image, using an interpolation 
+	algorithm, and optionnally a smoothing algorithm. 
+	This matlab module extends the Crippen routine to be used in Matlab, 
+	using double arrays found in the workspace, and loaded directly into memory.
+*/
+
+
+#include "./HoleFiller.h"
+
+void mexFunction( int nlhs, mxArray* plhs[],
+				  int nrhs, const mxArray* prhs[])
+{
+
+	int i,j;
+
+	/* required input: */
+	double* imagein=NULL;
+	int     imagein_rows,imagein_cols;
+	int     smooth_flag;
+	int     smooth;
+
+
+	/* output: */
+	mxArray* pfield=NULL;
+	double* imageout=NULL;
+	int     imageout_rows,imageout_cols;
+
+	/*Boot module: */
+	MODULEBOOT();
+
+	/*checks on arguments on the matlab side: */
+	CheckNumMatlabArguments(nlhs,NLHS,nrhs,NRHS,__FUNCT__,&HoleFillerUsage);
+
+	/*Fetch data: */
+	FetchData(&imagein,&imagein_rows,&imagein_cols,IMAGEIN);
+	FetchData(&smooth_flag,SMOOTH);
+	
+	/*Get smooth flag setup: */
+	if (smooth_flag==0)
+		smooth=1;
+	else
+		smooth=0;
+
+	/*Run core hole filler routine: */
+	HoleFillerx( &imageout,imagein,imagein_rows,imagein_cols,smooth);
+
+	/* output: */
+	WriteData(IMAGEOUT,imageout,imagein_rows,imagein_cols);
+
+	/*end module: */
+	MODULEEND();
+}
+
+
+void HoleFillerUsage(void)
+{
+	printf("   HoleFiller usage:\n");
+	printf("   [image_out]=HoleFiller(image_in,smooth);\n\n");
+	printf("   where:\n");
+	printf("      image_in in double format\n");
+	printf("      smooth: 1 to smooth with a box filer, 0 to leave data raw\n");
+	printf("      image_out in double format\n");
+	printf("\n");
+}
Index: /issm/branches/trunk-jpl-damage/src/modules/HoleFiller/HoleFiller.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/modules/HoleFiller/HoleFiller.h	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/modules/HoleFiller/HoleFiller.h	(revision 12168)
@@ -0,0 +1,36 @@
+
+/*
+	HoleFiller.h
+*/
+
+
+#ifndef _HOLEFILLER_H
+#define _HOLEFILLER_H
+
+/* local prototypes: */
+void HoleFillerUsage(void);
+
+#include "../../c/include/globals.h"
+#include "../../c/modules/modules.h"
+#include "../../c/Container/Container.h"
+#include "../../c/shared/shared.h"
+#include "../../c/issm-binding.h"
+
+#undef __FUNCT__ 
+#define __FUNCT__  "HoleFiller"
+
+
+/* serial input macros: */
+#define IMAGEIN prhs[0]
+#define SMOOTH prhs[1]
+
+/* serial output macros: */
+#define IMAGEOUT &plhs[0]
+
+/* serial arg counts: */
+#undef NLHS
+#define NLHS  1
+#undef NRHS
+#define NRHS  2
+
+#endif  /* _HOLEFILLER_H */
Index: /issm/branches/trunk-jpl-damage/src/modules/InternalFront/InternalFront.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/modules/InternalFront/InternalFront.cpp	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/modules/InternalFront/InternalFront.cpp	(revision 12168)
@@ -0,0 +1,99 @@
+/*\file InternalFront.c
+ *\brief: build pressureload
+ */
+
+#include "./InternalFront.h"
+
+void mexFunction( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]){
+
+	bool*   elementonwater=NULL;
+	int*    elements=NULL;
+	int*    connectivity=NULL;
+	int*    elementconnectivity=NULL;
+	int*    front=NULL;
+	double* front2=NULL;
+	bool    found;
+	int     numberofelements,numberofsegments;
+	int     N,M;
+	int     i,j,ii,jj,id;
+
+	/*Boot module: */
+	MODULEBOOT();
+
+	/*checks on arguments on the matlab side: */
+	CheckNumMatlabArguments(nlhs,NLHS,nrhs,NRHS,__FUNCT__,&InternalFrontUsage);
+
+	/*Fetch required fields*/
+	FetchData(&numberofelements,mxGetAssignedField(MODEL,0,"numberofelements"));
+	if(numberofelements<=0) _error_("No elements found in the model");
+	FetchData(&elements,&M,&N,mxGetAssignedField(MODEL,0,"elements"));
+	if(M!=numberofelements || N!=3) _error_("Field 'elements' should be of size [md.numberofelements 3]");
+	FetchData(&elementonwater,&M,&N,mxGetAssignedField(MODEL,0,"elementonwater"));
+	if(M!=numberofelements || N!=1) _error_("Field 'elementonwater' should be of size [md.numberofelements 1]");
+	FetchData(&elementconnectivity,&M,&N,mxGetAssignedField(MODEL,0,"elementconnectivity"));
+	if(M!=numberofelements || N!=3) _error_("Field 'elementconnectivity' should be of size [md.numberofelements 3]");
+
+	/*Allocate and initialize all variables*/
+	numberofsegments=0;
+	front=(int*)xmalloc(3*numberofelements*4*sizeof(int));
+
+	/*Loop over all elements on water*/
+	for(i=0;i<numberofelements;i++){
+
+		/*Skip if on water*/
+		if(!elementonwater[i]) continue;
+
+		/*Loop over all three adjacent elements*/
+		for(j=0;j<3;j++){
+
+			/*Skip if adjacent element does not exist or is on water*/
+			id=elementconnectivity[i*3+j];
+			if(id==0) continue;
+			if(elementonwater[id-1]) continue;
+
+			/*We have an ice front to add here, let's go!*/
+			for(ii=0;ii<3;ii++){
+
+				found=false;
+				for(jj=0;jj<3;jj++){
+					if(elements[(id-1)*3+ii]==elements[i*3+jj]){
+						found=true;
+						break;
+					}
+				}
+
+				/*OK, we just found the node of id, which is not in i. We have the segment*/
+				if(!found){
+					front[numberofsegments*4+0]=elements[(id-1)*3+(ii+1)%3];
+					front[numberofsegments*4+1]=elements[(id-1)*3+(ii+2)%3];
+					front[numberofsegments*4+2]=id;
+					front[numberofsegments*4+3]=IceEnum;
+					numberofsegments+=1;
+					break;
+				}
+			}
+
+			/*In debugging mode, check that the segment has been found*/
+			_assert_(!found);
+		}
+	}
+
+	/*Now that we know how many segments there is we can allocate the final matrix*/
+	if(numberofsegments){
+		front2=(double*)xmalloc(4*numberofsegments*sizeof(double));
+		for(i=0;i<4*numberofsegments;i++) front2[i]=(double)front[i];
+	}
+	xfree((void**)&front);
+
+	/*write output datasets: */
+	WriteData(FRONT,front2,numberofsegments,4);
+
+	/*end module: */
+	MODULEEND();
+}
+
+void InternalFrontUsage(void) {
+	_printf_(true,"\n");
+	_printf_(true,"   usage: icefront = %s(md);\n",__FUNCT__);
+	_printf_(true,"\n");
+}
Index: /issm/branches/trunk-jpl-damage/src/modules/InternalFront/InternalFront.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/modules/InternalFront/InternalFront.h	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/modules/InternalFront/InternalFront.h	(revision 12168)
@@ -0,0 +1,33 @@
+
+/*
+	InternalFront.h
+*/
+
+
+#ifndef _INTERNALFRONT_H
+#define _INTERNALFRONT_H
+
+/* local prototypes: */
+void InternalFrontUsage(void);
+
+#include "../../c/include/globals.h"
+#include "../../c/shared/shared.h"
+#include "../../c/issm-binding.h"
+#include "../../c/io/io.h"
+
+#undef __FUNCT__ 
+#define __FUNCT__  "InternalFront"
+
+/* serial input macros: */
+#define MODEL (mxArray*)prhs[0]
+
+/* serial output macros: */
+#define FRONT (mxArray**)&plhs[0]
+
+/* serial arg counts: */
+#undef NLHS
+#define NLHS  1
+#undef NRHS
+#define NRHS  1
+
+#endif
Index: /issm/branches/trunk-jpl-damage/src/modules/InterpFromGridToMesh/InterpFromGridToMesh.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/modules/InterpFromGridToMesh/InterpFromGridToMesh.cpp	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/modules/InterpFromGridToMesh/InterpFromGridToMesh.cpp	(revision 12168)
@@ -0,0 +1,95 @@
+/*!\file InterpFromGridToMesh.c
+ * \brief: data interpolation from a list of (x,y,values) into mesh vertices
+ 
+	InterpFromGridToMesh.c
+
+	usage:
+	data_mesh=InterpFromGridToMesh(x,y,data,x_mesh,y_mesh);
+	
+	where:
+
+		input:
+		x,y: coordinates of matrix data
+		data - matrix holding the data to be interpolated onto the mesh.
+		x_mesh,y_mesh: coordinates of the mesh vertices onto which we interpolate.
+		
+		output: 
+		data_mesh:  vector of mesh interpolated data.
+*/
+	
+#include "./InterpFromGridToMesh.h"
+
+void mexFunction( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]) {
+
+	int i,j;
+
+	/*input: */
+	double* x=NULL;
+	double* y=NULL;
+	int     x_rows,y_rows;
+	double* data=NULL; 
+	int     data_rows,data_cols;
+	double* x_mesh=NULL;
+	double* y_mesh=NULL;
+	int     x_mesh_rows,y_mesh_rows;
+	double  default_value;
+	int     interpolationenum;
+
+	/* output: */
+	Vector*  data_mesh=NULL;
+
+	/*Boot module: */
+	MODULEBOOT();
+
+	/*checks on arguments on the matlab side: */
+	//CheckNumMatlabArguments(nlhs,NLHS,nrhs,NRHS,__FUNCT__,&InterpFromGridToMeshUsage);
+	if((nlhs!=NLHS) || (nrhs!=6 && nrhs!=7)){
+		InterpFromGridToMeshUsage();
+		_error_(" usage. See above");
+	}
+
+	/*Input datasets: */
+	FetchData(&x,&x_rows,NULL,XHANDLE);
+	FetchData(&y,&y_rows,NULL,YHANDLE);
+	FetchData(&data,&data_rows,&data_cols,DATAHANDLE);
+	FetchData(&x_mesh,&x_mesh_rows,NULL,XMESHHANDLE);
+	FetchData(&y_mesh,&y_mesh_rows,NULL,YMESHHANDLE);
+	FetchData(&default_value,DEFAULTHANDLE);
+
+	/* Run core computations: */
+	if(nrhs==7){
+		FetchData(&interpolationenum,INTERPENUM);
+		InterpFromGridToMeshx(&data_mesh, x, x_rows,  y, y_rows, data, data_rows,data_cols, x_mesh, y_mesh, x_mesh_rows,default_value,interpolationenum);
+	}
+	else{
+		InterpFromGridToMeshx(&data_mesh, x, x_rows,  y, y_rows, data, data_rows,data_cols, x_mesh, y_mesh, x_mesh_rows,default_value);
+	}
+
+	/*Write data: */
+	WriteData(DATAMESH,data_mesh);
+
+	/*end module: */
+	MODULEEND();
+}
+
+void InterpFromGridToMeshUsage(void)
+{
+	_printf_(true,"INTERPFROMGRIDTOMESH - interpolation from a grid onto a list of points\n");
+	_printf_(true,"\n");
+	_printf_(true,"   This function is a multi-threaded mex file that interpolates a field\n");
+	_printf_(true,"   defined on a grid onto a list of points\n");
+	_printf_(true,"\n");
+	_printf_(true,"   Usage:\n");
+	_printf_(true,"      data_mesh=InterpFromGridToMesh(x,y,data,x_mesh,y_mesh,default_value);\n");
+	_printf_(true,"\n");
+	_printf_(true,"      data: matrix holding the data to be interpolated onto the mesh.\n");
+	_printf_(true,"      x,y: coordinates of matrix data. (x and y must be in increasing order)\n");
+	_printf_(true,"      x_mesh,y_mesh: coordinates of the points onto which we interpolate.\n");
+	_printf_(true,"      default_value: default value if no data is found (holes).\n");
+	_printf_(true,"      data_mesh: vector of mesh interpolated data.\n");
+	_printf_(true,"\n");
+	_printf_(true,"   Example:\n");
+	_printf_(true,"      load('velocities.mat');\n");
+	_printf_(true,"      md.inversion.vx_obs=InterpFromGridToMesh(x_n,y_m,vx,md.mesh.x,md.mesh.y,0);\n");
+	_printf_(true,"\n");
+}
Index: /issm/branches/trunk-jpl-damage/src/modules/InterpFromGridToMesh/InterpFromGridToMesh.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/modules/InterpFromGridToMesh/InterpFromGridToMesh.h	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/modules/InterpFromGridToMesh/InterpFromGridToMesh.h	(revision 12168)
@@ -0,0 +1,42 @@
+/*!\file InterpFromGridToMesh.h
+ * \brief: prototype for Data Interpolation mex module.
+ */
+
+#ifndef _InterpFromGridToMesh_H
+#define _InterpFromGridToMesh_H
+
+/* local prototypes: */
+void InterpFromGridToMeshUsage(void);
+
+#include "../../c/include/globals.h"
+#include "../../c/modules/modules.h"
+#include "../../c/Container/Container.h"
+#include "../../c/shared/shared.h"
+#include "../../c/issm-binding.h"
+
+#undef __FUNCT__ 
+#define __FUNCT__  "InterpFromGridToMesh"
+
+#undef CLEANUP
+#define CLEANUP InterpFromGridToMeshLocalCleanup();
+
+
+/* serial input macros: */
+#define XHANDLE prhs[0]
+#define YHANDLE prhs[1]
+#define DATAHANDLE prhs[2]
+#define XMESHHANDLE prhs[3]
+#define YMESHHANDLE prhs[4]
+#define DEFAULTHANDLE prhs[5]
+#define INTERPENUM prhs[6]
+
+/* serial output macros: */
+#define DATAMESH (mxArray**)&plhs[0]
+
+/* serial arg counts: */
+#undef NLHS
+#define NLHS  1
+#undef NRHS
+#define NRHS  6
+
+#endif  /* _INTERPFROMGRIDTOMESH_H */
Index: /issm/branches/trunk-jpl-damage/src/modules/InterpFromMesh2d/InterpFromMesh2d.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/modules/InterpFromMesh2d/InterpFromMesh2d.cpp	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/modules/InterpFromMesh2d/InterpFromMesh2d.cpp	(revision 12168)
@@ -0,0 +1,169 @@
+/*!\file InterpFromMesh2d.c
+ * \brief: data interpolation from a list of (x,y,values) into mesh vertices
+ 
+	InterpFromMesh2d.c
+
+	usage:
+	data_mesh=InterpFromMesh2d(index,x,y,data,x_mesh,y_mesh);
+	
+	where:
+
+		input:
+		x,y: coordinates of matrix data
+		data - matrix holding the data to be interpolated onto the mesh.
+		x_mesh,y_mesh: coordinates of the mesh vertices onto which we interpolate.
+		
+		output: 
+		data_mesh:  vector of mesh interpolated data.
+
+*/
+	
+#include "./InterpFromMesh2d.h"
+
+void mexFunction( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]) {
+
+	/*input: */
+	double* index_data=NULL;
+	int     index_data_rows;
+	int     dummy;
+
+	double* x_data=NULL;
+	int     x_data_rows;
+	
+	double* y_data=NULL;
+	int     y_data_rows;
+
+	double* data=NULL; 
+	int     data_rows;
+	int     data_cols;
+
+	double* x_prime=NULL;
+	double* y_prime=NULL;
+	
+	int     x_prime_rows;
+	int     y_prime_rows;
+
+
+	double* default_values=NULL;
+	int     num_default_values=0;
+
+	//contours
+	mxArray*  matlabstructure=NULL;
+	Contour** contours=NULL;
+	int       numcontours;
+	Contour*  contouri=NULL;
+	int       i;
+
+	/*Intermediary*/
+	int nods_data;
+	int nels_data;
+	int nods_prime;
+
+	/* output: */
+	Vector*  data_prime=NULL;
+
+	/*Boot module: */
+	MODULEBOOT();
+
+	/*checks on arguments on the matlab side: */
+	if(nlhs!=NLHS){
+		InterpFromMesh2dUsage();
+		_error_("InterpFromMeshToMesh2dUsage usage error");
+	}
+	if((nrhs!=6) && (nrhs!=7) && (nrhs!=8)){
+		InterpFromMesh2dUsage();
+		_error_("InterpFromMeshToMesh2dUsage usage error");
+	}
+
+	/*Input datasets: */
+	FetchData(&index_data,&index_data_rows,&dummy,INDEXHANDLE);
+	FetchData(&x_data,&x_data_rows,NULL,XHANDLE);
+	FetchData(&y_data,&y_data_rows,NULL,YHANDLE);
+	FetchData(&data,&data_rows,&data_cols,DATAHANDLE);
+	FetchData(&x_prime,&x_prime_rows,NULL,XPRIMEHANDLE);
+	FetchData(&y_prime,&y_prime_rows,NULL,YPRIMEHANDLE);
+
+	if(nrhs>=7){
+		/*default values: */
+		FetchData(&default_values,&num_default_values,DEFAULTHANDLE);
+	}
+	else{
+		default_values=NULL;
+		num_default_values=0;
+	}
+
+	if(nrhs>=8){
+		
+		/*Call expread on filename to build a contour array in the matlab workspace: */
+		mexCallMATLAB( 1, &matlabstructure, 1, (mxArray**)&FILENAME, "expread");
+
+		/*contours: */
+		numcontours=mxGetNumberOfElements(matlabstructure);
+		contours=(Contour**)xmalloc(numcontours*sizeof(Contour*));
+		for(i=0;i<numcontours;i++){
+			//allocate
+			contouri=(Contour*)xmalloc(sizeof(Contour));
+			//retrieve dimension of this contour.
+			contouri->nods=(int)mxGetScalar(mxGetField(matlabstructure,i,"nods"));
+			//set pointers.
+			contouri->x=mxGetPr(mxGetField(matlabstructure,i,"x"));
+			contouri->y=mxGetPr(mxGetField(matlabstructure,i,"y"));
+			*(contours+i)=contouri;
+		}
+
+		/* Debugging of contours :{{{1*/
+		/*for(i=0;i<numcontours;i++){
+		  printf("\nContour echo: contour number  %i / %i\n",i+1,numcontours);
+		  contouri=*(contours+i);
+		  printf("   Number of vertices %i\n",contouri->nods);
+		  for (j=0;j<contouri->nods;j++){
+		  printf("   %lf %lf\n",*(contouri->x+j),*(contouri->y+j));
+		  }
+		  }*/
+		/*}}}*/
+	}
+	else{
+		numcontours=0;
+		contours=NULL;
+	}
+
+
+	/*some checks*/
+	if (x_data_rows!=y_data_rows){
+		_error_("vectors x and y should have the same length!");
+	}
+	if (x_prime_rows!=y_prime_rows){
+		_error_("vectors x_prime and y_prime should have the same length!");
+	}
+	
+	/*get number of elements and number of nodes in the data*/
+	nels_data=index_data_rows;
+	nods_data=x_data_rows;
+	nods_prime=x_prime_rows;
+
+	/* Run core computations: */
+	InterpFromMesh2dx(&data_prime,index_data,x_data,y_data,nods_data,nels_data,data,data_rows,x_prime,y_prime,nods_prime,default_values,num_default_values,contours,numcontours);
+
+	/*Write data: */
+	WriteData(DATAPRIME,data_prime);
+
+	/*end module: */
+	MODULEEND();
+}
+
+void InterpFromMesh2dUsage(void)
+{
+	_printf_(true,"   usage:\n");
+	_printf_(true,"         data_prime=InterpFromMesh2d(index,x,y,data,x_prime,y_prime);\n\n");
+	_printf_(true,"      or data_prime=InterpFromMesh2d(index,x,y,data,x_prime,y_prime,default_value);\n\n");
+	_printf_(true,"      or data_prime=InterpFromMesh2d(index,x,y,data,x_prime,y_prime,default_value,contourname);\n\n");
+	_printf_(true,"   where:\n");
+	_printf_(true,"      x,y: coordinates of the nodes where data is defined\n");
+	_printf_(true,"      index: index of the mesh where data is defined\n");
+	_printf_(true,"      data - vector holding the data to be interpolated onto the points.\n");
+	_printf_(true,"      x_prime,y_prime: coordinates of the mesh vertices onto which we interpolate.\n");
+	_printf_(true,"      default_value: a scalar or vector of size length(x_prime).\n");
+	_printf_(true,"      contourname: linear interpolation will happen on all x_interp,y_interp inside the contour, default value will be adopted on the rest of the mesh.\n");
+	_printf_(true,"      data_prime:  vector of prime interpolated data.\n");
+	_printf_(true,"\n");
+}
Index: /issm/branches/trunk-jpl-damage/src/modules/InterpFromMesh2d/InterpFromMesh2d.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/modules/InterpFromMesh2d/InterpFromMesh2d.h	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/modules/InterpFromMesh2d/InterpFromMesh2d.h	(revision 12168)
@@ -0,0 +1,40 @@
+/*!\file InterpFromMesh2d.h
+ * \brief: prototype for Data Interpolation mex module.
+ */
+
+#ifndef _INTERPFROMMESH2D_H
+#define _INTERPFROMMESH2D_H
+
+/* local prototypes: */
+void InterpFromMesh2dUsage(void);
+
+#include "../../c/include/globals.h"
+#include "../../c/modules/modules.h"
+#include "../../c/Container/Container.h"
+#include "../../c/shared/shared.h"
+#include "../../c/issm-binding.h"
+
+#undef __FUNCT__ 
+#define __FUNCT__  "InterpFromMesh2d"
+
+#undef CLEANUP
+#define CLEANUP InterpFromMesh2dLocalCleanup();
+
+/* serial input macros: */
+#define INDEXHANDLE prhs[0]
+#define XHANDLE prhs[1]
+#define YHANDLE prhs[2]
+#define DATAHANDLE prhs[3]
+#define XPRIMEHANDLE prhs[4]
+#define YPRIMEHANDLE prhs[5]
+#define DEFAULTHANDLE prhs[6]
+#define FILENAME prhs[7]
+
+/* serial output macros: */
+#define DATAPRIME (mxArray**)&plhs[0]
+
+/* serial arg counts: */
+#undef NLHS
+#define NLHS  1
+
+#endif  /* _INTERPFROMMESH2D_H */
Index: /issm/branches/trunk-jpl-damage/src/modules/InterpFromMeshToGrid/InterpFromMeshToGrid.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/modules/InterpFromMeshToGrid/InterpFromMeshToGrid.cpp	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/modules/InterpFromMeshToGrid/InterpFromMeshToGrid.cpp	(revision 12168)
@@ -0,0 +1,79 @@
+/*\file InterpFromMeshToGrid.c
+ *\brief: compute diff between observed and modeled velocity
+ */
+
+#include "./InterpFromMeshToGrid.h"
+
+void mexFunction( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]){
+
+	/*input datasets: */
+	double* index=NULL;
+	int     nel;
+	double* x=NULL;
+	int     nods;
+	double* y=NULL;
+	double* meshdata=NULL;
+	int     meshdata_length;
+	double  xmin;
+	double  ymax;
+	double  xposting;
+	double  yposting;
+	int     nlines,ncols;
+	double  default_value;
+
+	/* output datasets: */
+	double* griddata=NULL;
+	double* x_m=NULL;
+	double* y_m=NULL;
+
+
+	/*Boot module: */
+	MODULEBOOT();
+
+	/*checks on arguments on the matlab side: */
+	CheckNumMatlabArguments(nlhs,NLHS,nrhs,NRHS,__FUNCT__,&InterpFromMeshToGridUsage);
+
+	/*Input datasets: */
+	FetchData(&index,&nel,NULL,INDEX);
+	FetchData(&x,&nods,NULL,X);
+	FetchData(&y,NULL,NULL,Y);
+	FetchData(&meshdata,&meshdata_length,NULL,MESHDATA);
+	FetchData(&xmin,XMIN);
+	FetchData(&ymax,YMAX);
+	FetchData(&xposting,XPOSTING);
+	FetchData(&yposting,YPOSTING);
+	FetchData(&nlines,NLINES);
+	FetchData(&ncols,NCOLS);
+	FetchData(&default_value,DEFAULTVALUE);
+
+	/*Call core of computation: */
+	InterpFromMeshToGridx(&x_m,&y_m,&griddata,index,x,y,nods,nel,meshdata,meshdata_length,xmin,ymax,xposting,yposting,nlines,ncols,default_value);
+
+	/*Write results: */
+	WriteData(XM,x_m,ncols);
+	WriteData(YM,y_m,nlines);
+	WriteData(GRIDDATA,griddata,nlines,ncols);
+
+	/*Free ressources: */
+	//let matlab do this.
+	
+	/*end module: */
+	MODULEEND();
+}
+
+void InterpFromMeshToGridUsage(void)
+{
+	_printf_(true,"INTERPFROMMESHTOGRID - interpolation of a data defined on a mesh onto a grid\n");
+	_printf_(true,"\n");
+	_printf_(true,"   This function is a multi-threaded mex file that interpolates a field\n");
+	_printf_(true,"   defined on a triangular mesh onto a regular grid\n");
+	_printf_(true,"\n");
+	_printf_(true,"   Usage:\n");
+	_printf_(true,"      [x_m,y_m,griddata]=InterpFromMeshToGrid(index,x,y,data,xmin,ymax,xposting,yposting,nlines,ncols,default_value)\n");
+	_printf_(true,"\n");
+	_printf_(true,"      index,x,y: delaunay triangulation defining the mesh.\n");
+	_printf_(true,"      meshdata: vertex values of data to be interpolated.\n");
+	_printf_(true,"      xmin,ymax,posting,nlines,ncols: parameters that define the grid\n");
+	_printf_(true,"      default_value: value of points located out of the mesh.\n");
+	_printf_(true,"\n");
+}
Index: /issm/branches/trunk-jpl-damage/src/modules/InterpFromMeshToGrid/InterpFromMeshToGrid.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/modules/InterpFromMeshToGrid/InterpFromMeshToGrid.h	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/modules/InterpFromMeshToGrid/InterpFromMeshToGrid.h	(revision 12168)
@@ -0,0 +1,46 @@
+
+/*
+	InterpFromMeshToGrid.h
+*/
+
+
+#ifndef _INTERPFROMMESHTOGRID_H
+#define _INTERPFROMMESHTOGRID_H
+
+/* local prototypes: */
+void InterpFromMeshToGridUsage(void);
+
+#include "../../c/include/globals.h"
+#include "../../c/modules/modules.h"
+#include "../../c/Container/Container.h"
+#include "../../c/shared/shared.h"
+#include "../../c/issm-binding.h"
+
+#undef __FUNCT__ 
+#define __FUNCT__  "InterpFromMeshToGrid"
+
+/* serial input macros: */
+#define INDEX (mxArray*)prhs[0]
+#define X (mxArray*)prhs[1]
+#define Y (mxArray*)prhs[2]
+#define MESHDATA (mxArray*)prhs[3]
+#define XMIN (mxArray*)prhs[4]
+#define YMAX (mxArray*)prhs[5]
+#define XPOSTING (mxArray*)prhs[6]
+#define YPOSTING (mxArray*)prhs[7]
+#define NLINES (mxArray*)prhs[8]
+#define NCOLS (mxArray*)prhs[9]
+#define DEFAULTVALUE (mxArray*)prhs[10]
+
+/* serial output macros: */
+#define XM (mxArray**)&plhs[0]
+#define YM (mxArray**)&plhs[1]
+#define GRIDDATA (mxArray**)&plhs[2]
+
+/* serial arg counts: */
+#undef NLHS
+#define NLHS  3
+#undef NRHS
+#define NRHS  11
+
+#endif  /* _INTERPFROMMESHTOGRID_H*/
Index: /issm/branches/trunk-jpl-damage/src/modules/InterpFromMeshToMesh2d/InterpFromMeshToMesh2d.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/modules/InterpFromMeshToMesh2d/InterpFromMeshToMesh2d.cpp	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/modules/InterpFromMeshToMesh2d/InterpFromMeshToMesh2d.cpp	(revision 12168)
@@ -0,0 +1,119 @@
+/*\file InterpFromMeshToMesh2d.c
+ *\brief: bamg module.
+ */
+#include "./InterpFromMeshToMesh2d.h"
+
+
+WRAPPER(InterpFromMeshToMesh2d){
+
+	/*input: */
+	double* index=NULL;
+	int     index_cols;
+	double* x_data=NULL;
+	int     x_data_rows;
+	double* y_data=NULL;
+	int     y_data_rows;
+	double* data=NULL; 
+	int     data_rows;
+	int     data_cols;
+	double* x_interp=NULL;
+	int     x_interp_rows;
+	double* y_interp=NULL;
+	int     y_interp_rows;
+	char*   contourname=NULL;
+	double* default_values=NULL;
+	int     num_default_values=0;
+	DataSet *contours = NULL;
+
+	/*Intermediary*/
+	int nels_data;
+
+	/* output: */
+	double* data_interp=NULL;
+
+	/*Boot module: */
+	MODULEBOOT();
+
+	/*checks on output arguments on the matlab side: */
+	#ifdef _HAVE_MATLAB_MODULES_
+	if(nlhs!=NLHS){
+		InterpFromMeshToMesh2dUsage();
+		_error_("InterpFromMeshToMesh2dUsage usage error");
+	}
+	#endif
+	/*check on input arguments: */
+	if((nrhs!=6) & (nrhs!=8)){
+		InterpFromMeshToMesh2dUsage();
+		_error_("InterpFromMeshToMesh2dUsage usage error");
+	}
+
+	/*Input datasets: */
+	FetchData(&index,&nels_data,&index_cols,INDEX);
+	FetchData(&x_data,&x_data_rows,NULL,X);
+	FetchData(&y_data,&y_data_rows,NULL,Y);
+	FetchData(&data,&data_rows,&data_cols,DATA);
+	FetchData(&x_interp,&x_interp_rows,XINTERP);
+	FetchData(&y_interp,&y_interp_rows,YINTERP);
+
+	/*Figure out contours and default values: */
+	if(nrhs==8){
+		FetchData(&default_values,&num_default_values,DEFAULT);
+		FetchData(&contourname,CONTOURNAME);
+		contours=DomainOutlineRead(contourname);
+	}
+	else{
+		num_default_values=0;
+		default_values=NULL;
+		contours=new DataSet();
+	}
+
+
+	/*some checks*/
+	if (x_data_rows!=y_data_rows){
+		_error_("vectors x and y should have the same length!");
+	}
+	if (x_interp_rows!=y_interp_rows){
+		_error_("vectors x_interp and y_interp should have the same length!");
+	}
+	if (index_cols!=3){
+		_error_("index should have 3 columns (input provided has %i columns)",index_cols);
+	}
+
+	/* Run core computations: */
+	InterpFromMeshToMesh2dx(&data_interp,index,x_data,y_data,x_data_rows,nels_data,data,data_rows,data_cols,x_interp,y_interp,x_interp_rows,default_values,num_default_values,contours);
+
+	/*Write data: */
+	WriteData(DATAINTERP,data_interp,x_interp_rows,data_cols);
+
+	/*end module: */
+	MODULEEND();
+}
+
+void InterpFromMeshToMesh2dUsage(void)//{{{1
+
+{
+	_printf_(true,"INTERFROMMESHTOMESH2D - interpolation from a 2d triangular mesh onto a list of point\n");
+	_printf_(true,"\n");
+	_printf_(true,"   This function is a multi-threaded mex file that interpolates a field\n");
+	_printf_(true,"   defined on a triangular mesh onto a list of point\n");
+	_printf_(true,"\n");
+	_printf_(true,"   Usage:\n");
+	_printf_(true,"         data_interp=InterpFromMeshToMesh2d(index,x,y,data,x_interp,y_interp);\n");
+	_printf_(true,"      or data_interp=InterpFromMeshToMesh2d(index,x,y,data,x_interp,y_interp,default_value,contourname);\n");
+	_printf_(true,"\n");
+	_printf_(true,"      index: index of the mesh where data is defined\n");
+	_printf_(true,"      x,y: coordinates of the nodes where data is defined\n");
+	_printf_(true,"      data: matrix holding the data to be interpolated onto the mesh. (one column per field)\n");
+	_printf_(true,"      x_interp,y_interp: coordinates of the points onto which we interpolate.\n");
+	_printf_(true,"      if default_value and contourname not specified: linear interpolation will happen on all x_interp,y_interp.\n");
+	_printf_(true,"      if (default_value,contourname) specified: linear interpolation will happen on all x_interp,y_interp inside the contour, default value will be adopted on the rest of the mesh.\n");
+	_printf_(true,"      note that default_value is either a scalar, or a vector of size  length(x_interp)\n");
+	_printf_(true,"      data_interp: vector of mesh interpolated data.\n");
+	_printf_(true,"\n");
+	_printf_(true,"   Example:\n");
+	_printf_(true,"      load('temperature.mat');\n");
+	_printf_(true,"      md.initialization.temperature=InterpFromMeshToMesh2d(index,x,y,temperature,md.mesh.x,md.mesh.y);\n");
+	_printf_(true,"      md.initialization.temperature=InterpFromMeshToMesh2d(index,x,y,temperature,md.mesh.x,md.mesh.y,253,'Contour.exp');\n");
+	_printf_(true,"\n");
+}
+//}}}
Index: /issm/branches/trunk-jpl-damage/src/modules/InterpFromMeshToMesh2d/InterpFromMeshToMesh2d.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/modules/InterpFromMeshToMesh2d/InterpFromMeshToMesh2d.h	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/modules/InterpFromMeshToMesh2d/InterpFromMeshToMesh2d.h	(revision 12168)
@@ -0,0 +1,71 @@
+/*!\file InterpFromMeshToMesh2d.h
+ * \brief: prototype for Data Interpolation mex module.
+ */
+
+#ifndef _INTERPFROMMESHTOMESH2d_H
+#define _INTERPFROMMESHTOMESH2d_H
+
+#ifdef HAVE_CONFIG_H
+	#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+/*Very important definition in case we are compiling a python module!: needs to come before header files inclusion*/
+#ifdef _HAVE_PYTHON_
+#define PY_ARRAY_UNIQUE_SYMBOL PythonIOSymbol
+#endif
+
+/*Header files: */
+#include "../../c/include/globals.h"
+#include "../../c/toolkits/toolkits.h"
+#include "../../c/include/include.h"
+#include "../../c/modules/modules.h"
+#include "../../c/Container/Container.h"
+#include "../../c/shared/shared.h"
+#include "../../c/issm-binding.h"
+#include "../../c/io/io.h"
+#include "../../c/EnumDefinitions/EnumDefinitions.h"
+
+#ifdef _HAVE_MATLAB_MODULES_
+/* serial input macros: */
+#define INDEX prhs[0]
+#define X prhs[1]
+#define Y prhs[2]
+#define DATA prhs[3]
+#define XINTERP prhs[4]
+#define YINTERP prhs[5]
+#define DEFAULT prhs[6]
+#define CONTOURNAME prhs[7]
+
+/* serial output macros: */
+#define DATAINTERP (mxArray**)&plhs[0]
+#endif
+
+#ifdef _HAVE_PYTHON_MODULES_
+/* serial input macros: */
+#define INDEX PyTuple_GetItem(args,0)
+#define X PyTuple_GetItem(args,1)
+#define Y PyTuple_GetItem(args,2)
+#define DATA PyTuple_GetItem(args,3)
+#define XINTERP PyTuple_GetItem(args,4)
+#define YINTERP PyTuple_GetItem(args,5)
+#define DEFAULT PyTuple_GetItem(args,6)
+#define CONTOURNAME PyTuple_GetItem(args,7)
+/* serial output macros: */
+#define DATAINTERP output,0
+#endif
+
+#undef __FUNCT__ 
+#define __FUNCT__  "InterpFromMeshToMesh2d"
+
+/* serial arg counts: */
+#undef NLHS
+#define NLHS  1
+#undef NRHS
+#define NRHS  6 //can be 8 though
+
+/* local prototypes: */
+void InterpFromMeshToMesh2dUsage(void);
+
+#endif
Index: /issm/branches/trunk-jpl-damage/src/modules/InterpFromMeshToMesh3d/InterpFromMeshToMesh3d.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/modules/InterpFromMeshToMesh3d/InterpFromMeshToMesh3d.cpp	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/modules/InterpFromMeshToMesh3d/InterpFromMeshToMesh3d.cpp	(revision 12168)
@@ -0,0 +1,119 @@
+/*!\file InterpFromMeshToMesh3d.c
+ * \brief: data interpolation from a list of (x,y,values) into mesh vertices
+ 
+	InterpFromMeshToMesh3d.c
+
+	usage:
+	data_mesh=InterpFromMeshToMesh3d(index,x,y,z,data,x_mesh,y_mesh,z_mesh);
+	
+	where:
+
+		input:
+		x,y,z: coordinates of matrix data
+		data - matrix holding the data to be interpolated onto the mesh.
+		x_mesh,y_mesh,z_mesh: coordinates of the mesh vertices onto which we interpolate.
+		
+		output: 
+		data_mesh:  vector of mesh interpolated data.
+
+*/
+	
+#include "./InterpFromMeshToMesh3d.h"
+
+void mexFunction( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]) {
+
+	/*input: */
+	double* index_data=NULL;
+	int     index_data_rows;
+
+	double* x_data=NULL;
+	double* y_data=NULL;
+	double* z_data=NULL;
+
+	int     x_data_rows;
+	int     y_data_rows;
+	int     z_data_rows;
+
+	double* data=NULL; 
+	int     data_rows;
+	int     data_cols;
+
+	double* x_prime=NULL;
+	double* y_prime=NULL;
+	double* z_prime=NULL;
+	
+	int     x_prime_rows;
+	int     y_prime_rows;
+	int     z_prime_rows;
+
+	double  default_value;
+
+	/*Intermediary*/
+	int nods_data;
+	int nels_data;
+	int nods_prime;
+
+	/* output: */
+	Vector*  data_prime=NULL;
+
+	/*Boot module: */
+	MODULEBOOT();
+
+	/*checks on arguments on the matlab side: */
+	CheckNumMatlabArguments(nlhs,NLHS,nrhs,NRHS,__FUNCT__,&InterpFromMeshToMesh3dUsage);
+
+	/*Input datasets: */
+	FetchData(&index_data,&index_data_rows,NULL,INDEXHANDLE);
+	FetchData(&x_data,&x_data_rows,NULL,XHANDLE);
+	FetchData(&y_data,&y_data_rows,NULL,YHANDLE);
+	FetchData(&z_data,&z_data_rows,NULL,ZHANDLE);
+	FetchData(&data,&data_rows,&data_cols,DATAHANDLE);
+	FetchData(&x_prime,&x_prime_rows,NULL,XPRIMEHANDLE);
+	FetchData(&y_prime,&y_prime_rows,NULL,YPRIMEHANDLE);
+	FetchData(&z_prime,&z_prime_rows,NULL,ZPRIMEHANDLE);
+	FetchData(&default_value,DEFAULTHANDLE);
+
+	/*some checks*/
+	if (x_data_rows!=y_data_rows || x_data_rows!=z_data_rows){
+		_error_("vectors x, y and z should have the same length!");
+	}
+	if (x_prime_rows!=y_prime_rows || x_prime_rows!=z_prime_rows){
+		_error_("vectors x_prime, y_prime and z_prime should have the same length!");
+	}
+	/*get number of elements and number of nodes in the data*/
+	nels_data=index_data_rows;
+	nods_data=x_data_rows;
+	nods_prime=x_prime_rows;
+
+	/* Run core computations: */
+	InterpFromMeshToMesh3dx(&data_prime,index_data,x_data,y_data,z_data,nods_data,nels_data,data,data_rows,x_prime,y_prime,z_prime,nods_prime,default_value);
+
+	/*Write data: */
+	WriteData(DATAPRIME,data_prime);
+
+	/*end module: */
+	MODULEEND();
+}
+
+void InterpFromMeshToMesh3dUsage(void)
+{
+	_printf_(true,"INTERPFROMMESHTOMESH3D - interpolation from a 3d hexahedron mesh onto a list of point\n");
+	_printf_(true,"\n");
+	_printf_(true,"   This function is a multi-threaded mex file that interpolates a field\n");
+	_printf_(true,"   defined on a triangular mesh onto a list of point\n");
+	_printf_(true,"\n");
+	_printf_(true,"   Usage:\n");
+	_printf_(true,"      data_prime=InterpFromMeshToMesh3d(index,x,y,z,data,x_prime,y_prime,z_prime,default_value);\n");
+	_printf_(true,"\n");
+	_printf_(true,"      index: index of the mesh where data is defined\n");
+	_printf_(true,"      x,y,z: coordinates of the nodes where data is defined\n");
+	_printf_(true,"      data: matrix holding the data to be interpolated onto the mesh.\n");
+	_printf_(true,"      x_prime,y_prime,z_prime: coordinates of the points onto which we interpolate.\n");
+	_printf_(true,"      default_value: default value if no data is found (holes).\n");
+	_printf_(true,"      data_prime: vector of mesh interpolated data.\n");
+	_printf_(true,"\n");
+	_printf_(true,"   Example:\n");
+	_printf_(true,"      load('temperature.mat');\n");
+	_printf_(true,"      md.initialization.temperature=InterpFromMeshToMesh3d(index,x,y,z,temperature,md.mesh.x,md.mesh.y,md.mesh.z,253);\n");
+	_printf_(true,"\n");
+}
Index: /issm/branches/trunk-jpl-damage/src/modules/InterpFromMeshToMesh3d/InterpFromMeshToMesh3d.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/modules/InterpFromMeshToMesh3d/InterpFromMeshToMesh3d.h	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/modules/InterpFromMeshToMesh3d/InterpFromMeshToMesh3d.h	(revision 12168)
@@ -0,0 +1,44 @@
+/*!\file InterpFromMeshToMesh3d.h
+ * \brief: prototype for Data Interpolation mex module.
+ */
+
+#ifndef _INTERPFROMMESH3D_H
+#define _INTERPFROMMESH3D_H
+
+/* local prototypes: */
+void InterpFromMeshToMesh3dUsage(void);
+
+#include "../../c/include/globals.h"
+#include "../../c/modules/modules.h"
+#include "../../c/Container/Container.h"
+#include "../../c/shared/shared.h"
+#include "../../c/issm-binding.h"
+
+#undef __FUNCT__ 
+#define __FUNCT__  "InterpFromMeshToMesh3d"
+
+#undef CLEANUP
+#define CLEANUP InterpFromMeshToMesh3dLocalCleanup();
+
+
+/* serial input macros: */
+#define INDEXHANDLE prhs[0]
+#define XHANDLE prhs[1]
+#define YHANDLE prhs[2]
+#define ZHANDLE prhs[3]
+#define DATAHANDLE prhs[4]
+#define XPRIMEHANDLE prhs[5]
+#define YPRIMEHANDLE prhs[6]
+#define ZPRIMEHANDLE prhs[7]
+#define DEFAULTHANDLE prhs[8]
+
+/* serial output macros: */
+#define DATAPRIME (mxArray**)&plhs[0]
+
+/* serial arg counts: */
+#undef NLHS
+#define NLHS  1
+#undef NRHS
+#define NRHS  9
+
+#endif  /* _INTERPFROMMESHTOMESH3D_H */
Index: /issm/branches/trunk-jpl-damage/src/modules/KMLFileRead/KMLFileRead.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/modules/KMLFileRead/KMLFileRead.cpp	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/modules/KMLFileRead/KMLFileRead.cpp	(revision 12168)
@@ -0,0 +1,129 @@
+/*\file KMLFileRead.c
+ *\brief: KML file reader module.
+ */
+#include "./KMLFileRead.h"
+
+void mexFunction( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]){
+
+	int i,j,nnodes=0,verbose=1;
+	KML_Object* kobj;
+
+	/*input: */
+	char*   name=NULL;
+	char*   notes=NULL;
+	const mxArray* notesi;
+	mwIndex        nindex;
+	int*    elem=NULL;
+	int     melem=0,nelem=0;
+	int*    nodecon=NULL;
+	int     mncon=0,nncon=0;
+	double* lat=NULL;
+	int     mlat=0,nlat=0,llat=0;
+	double* lng=NULL;
+	int     mlng=0,nlng=0,llng=0;
+	int     nparts=0;
+	int*    part=NULL;
+	int     mprt=0,nprt=0,lprt=0;
+	double* data=NULL;
+	int     mdata=0,ndata=0;
+	double* cmap=NULL;
+	int     mcmap=0,ncmap=0;
+	char*   filnam=NULL;
+	FILE*   fidi=NULL;
+	FILE*   fido=NULL;
+	Options* options=NULL;
+	char*    echo    =NULL;
+	char*    deepecho=NULL;
+	char*    write   =NULL;
+
+	/* output: */
+	int     ierror=0;
+
+	/*Boot module: */
+	MODULEBOOT();
+
+	/*checks on arguments on the matlab side: */
+	if (nlhs > NLHS) {
+		KMLFileReadUsage(); _error_("KMLFileRead usage error");
+	}
+	if (nrhs < NRHS) {
+		KMLFileReadUsage(); _error_("KMLFileRead usage error");
+	}
+
+	/*Input datasets: */
+	FetchData(&filnam,FILENAME);
+	FetchData(&options,NRHS,nrhs,prhs);
+	FetchData(&options,NRHS,nrhs,prhs);
+
+	options->Get(&echo    ,"echo"    ,"off");
+	options->Get(&deepecho,"deepecho","off");
+	options->Get(&write   ,"write"   ,"off");
+
+	/*some checks*/
+	if (!strlen(filnam)) strcpy(filnam,"stdout");
+
+	if (verbose) printf("Opening file \"%s\".\n",filnam);
+	fidi=fopen(filnam,"r");
+
+	/* Run core computations: */
+	if (verbose) printf("Calling core:\n");
+	kobj=KMLFileReadx(fidi);
+
+	if (verbose) printf("Closing file \"%s\".\n",filnam);
+	fclose(fidi);
+
+	if (kobj){
+		if (!strncmp(echo    ,"on",2) || !strncmp(echo    ,"y",1))
+			kobj->Echo();
+		if (!strncmp(deepecho,"on",2) || !strncmp(deepecho,"y",1))
+			kobj->DeepEcho();
+		if (strncmp(write,"off",3) && strncmp(write,"no",2)) {
+			if (!strncmp(write,"on",2) || !strncmp(write,"yes",3) || !strncmp(write,"stdout",6)) {
+				kobj->Write(stdout,"");
+			}
+			else {
+				if (verbose) printf("Opening file \"%s\".\n",write);
+				fido=fopen(write,"w");
+				kobj->Write(fido,"");
+				if (verbose) printf("Closing file \"%s\".\n",write);
+				ierror=fclose(fido);
+			}
+		}
+		delete kobj;
+	}
+
+	/*Write data: */
+	WriteData(ERRORFLAG,ierror);
+
+	/*Clean-up*/
+	xfree((void**)&write);
+	xfree((void**)&deepecho);
+	xfree((void**)&echo);
+	delete options;
+
+	/*end module: */
+	MODULEEND();
+}
+
+void KMLFileReadUsage(void){
+	_printf_(true,"KMLFileRead - KML file reader module:\n");
+	_printf_(true,"\n");
+	_printf_(true,"   This module reads a KML file.\n");
+	_printf_(true,"\n");
+	_printf_(true,"   Usage:\n");
+	_printf_(true,"      [ierror]=KMLFileRead(kmlfile,'param name',param,...);\n");
+	_printf_(true,"\n");
+	_printf_(true,"      kmlfile      file name of kml file to be read (char)\n");
+	_printf_(true,"\n");
+	_printf_(true,"      echo         echo command (char, optional, 'off'/'on')\n");
+	_printf_(true,"      deepecho     deep echo command (char, optional, 'off'/'on')\n");
+	_printf_(true,"      write        write command (char, optional, 'off'/'stdout'/kmlfile)\n");
+	_printf_(true,"\n");
+	_printf_(true,"      ierror       return code (non-zero for error)\n");
+	_printf_(true,"\n");
+	_printf_(true,"   Examples:\n");
+	_printf_(true,"      [ierror]=KMLFileRead('file.kml','deepecho','on');\n");
+	_printf_(true,"      [ierror]=KMLFileRead('filin.kml','echo','on','write','filout.kml');\n");
+	_printf_(true,"\n");
+}
+
Index: /issm/branches/trunk-jpl-damage/src/modules/KMLFileRead/KMLFileRead.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/modules/KMLFileRead/KMLFileRead.h	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/modules/KMLFileRead/KMLFileRead.h	(revision 12168)
@@ -0,0 +1,33 @@
+/*!\file KMLFileRead.h
+ * \brief: prototype for KML file reader mex module.
+ */
+
+#ifndef _KMLFILEREAD_H
+#define _KMLFILEREAD_H
+
+/* local prototypes: */
+void KMLFileReadUsage(void);
+
+#include "../../c/include/globals.h"
+#include "../../c/modules/modules.h"
+#include "../../c/Container/Container.h"
+#include "../../c/shared/shared.h"
+#include "../../c/issm-binding.h"
+
+#undef __FUNCT__ 
+#define __FUNCT__  "KMLFileRead"
+
+
+/* serial input macros: */
+#define FILENAME      prhs[0]
+
+/* serial output macros: */
+#define ERRORFLAG (mxArray**)&plhs[0]
+
+/* serial arg counts: */
+#undef NRHS
+#define NRHS  1
+#undef NLHS
+#define NLHS  1
+
+#endif
Index: /issm/branches/trunk-jpl-damage/src/modules/KMLMeshWrite/KMLMeshWrite.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/modules/KMLMeshWrite/KMLMeshWrite.cpp	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/modules/KMLMeshWrite/KMLMeshWrite.cpp	(revision 12168)
@@ -0,0 +1,143 @@
+/*\file KMLMeshWrite.c
+ *\brief: KML mesh writer module.
+ */
+#include "./KMLMeshWrite.h"
+
+void mexFunction( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]){
+
+	int i,j,nnodes=0,verbose=1;
+
+	/*input: */
+	char*   name=NULL;
+	char*   notes=NULL;
+	const mxArray* notesi;
+	mwIndex        nindex;
+	int*    elem=NULL;
+	int     melem=0,nelem=0;
+	int*    nodecon=NULL;
+	int     mncon=0,nncon=0;
+	double* lat=NULL;
+	int     mlat=0,nlat=0,llat=0;
+	double* lng=NULL;
+	int     mlng=0,nlng=0,llng=0;
+	int     nparts=0;
+	int*    part=NULL;
+	int     mprt=0,nprt=0,lprt=0;
+	double* data=NULL;
+	int     mdata=0,ndata=0;
+	double* cmap=NULL;
+	int     mcmap=0,ncmap=0;
+	char*   filnam=NULL;
+	FILE*   fid=NULL;
+	Options* options=NULL;
+
+	/* output: */
+	int     ierror=0;
+
+	/*Boot module: */
+	MODULEBOOT();
+
+	/*checks on arguments on the matlab side: */
+	if (nlhs > NLHS) {
+		KMLMeshWriteUsage(); _error_("KMLMeshWrite usage error");
+	}
+	if (nrhs < NRHS) {
+		KMLMeshWriteUsage(); _error_("KMLMeshWrite usage error");
+	}
+
+	/*Input datasets: */
+	FetchData(&name,NAME);
+
+/*  notes is typically a cell array of character strings  */
+	if (mxIsCell(NOTES)) {
+		for (nindex=0; nindex<mxGetNumberOfElements(NOTES); nindex++) {
+			notesi=mxGetCell(NOTES,nindex);
+			if (notesi && mxIsChar(notesi) && mxGetNumberOfElements(notesi)) {
+				if (!notes) {
+					notes=(char *) xmalloc((mxGetNumberOfElements(notesi)+1)*sizeof(char));
+					mxGetString(notesi,notes,mxGetNumberOfElements(notesi)+1);
+				}
+				else {
+/*  note that strlen does not include trailing null  */
+					notes=(char*)xrealloc(notes,(strlen(notes)+1+mxGetNumberOfElements(notesi)+1)*sizeof(char));
+					strcat(notes,"\n");
+					mxGetString(notesi,&notes[strlen(notes)],mxGetNumberOfElements(notesi)+1);
+				}
+			}
+		}
+	}
+	else
+		FetchData(&notes,NOTES);
+	FetchData(&elem,&melem,&nelem,ELEMHANDLE);
+	FetchData(&nodecon,&mncon,&nncon,NODECONHANDLE);
+	FetchData(&lat,&mlat,&nlat,LATHANDLE);
+	llat=mlat*nlat;
+	FetchData(&lng,&mlng,&nlng,LNGHANDLE);
+	llng=mlng*nlng;
+	FetchData(&part,&mprt,&nprt,PARTHANDLE);
+	lprt=mprt*nprt;
+	FetchData(&data,&mdata,&ndata,DATAHANDLE);
+	FetchData(&cmap,&mcmap,&ncmap,CMAPHANDLE);
+	FetchData(&filnam,FILENAME);
+	FetchData(&options,NRHS,nrhs,prhs);
+
+	/*some checks*/
+	for (i=0; i<melem*nelem; i++) if(elem[i]>nnodes) nnodes=elem[i];
+	if(part) for (i=0; i<lprt; i++) if (part[i]+1 > nparts) nparts=part[i]+1;
+
+	if (nodecon && (mncon != nnodes))
+		_error_("Nodal connectivity table, if supplied, must be supplied for all nodes.");
+	else if (!nodecon)
+		mncon=nnodes;
+	if ((llat != nnodes) || (llng != nnodes) || (llat != llng))
+		_error_("Latitude and longitude vectors must be supplied for all nodes.");
+	if (part && (lprt != nnodes))
+		_error_("Partitioning vector, if supplied, must be supplied for all nodes.");
+	if (data && !((mdata == nnodes) || (mdata == melem)))
+		_error_("Data matrix, if supplied, must be supplied for all nodes or all elements.");
+	if (cmap && (ncmap != 3))
+		_error_("Colormap matrix, if supplied, must have three columns for rgb.");
+	if (!strlen(filnam))
+		strcpy(filnam,"stdout");
+
+	/* Run core computations: */
+	fid=fopen(filnam,"w");
+	KMLMeshWritex(&ierror,name,notes,elem,melem,nelem,nodecon,mncon,nncon,lat,lng,part,data,mdata,ndata,cmap,mcmap,ncmap,fid);
+	fclose(fid);
+
+	/*Write data: */
+	WriteData(ERRORFLAG,ierror);
+
+	/*Clean-up*/
+	delete options;
+	if (mxIsCell(NOTES) && notes) xfree((void**)&notes);
+
+	/*end module: */
+	MODULEEND();
+}
+
+void KMLMeshWriteUsage(void){
+	_printf_(true,"KMLMeshWrite - KML mesh writer module:\n");
+	_printf_(true,"\n");
+	_printf_(true,"   This module writes the mesh of a model as KML polygons into the specified KML file.\n");
+	_printf_(true,"\n");
+	_printf_(true,"   Usage:\n");
+	_printf_(true,"      ierror=KMLMeshWrite(name,notes,elem,nodecon,lat,long,part,data,cmap,kmlfile);\n");
+	_printf_(true,"\n");
+	_printf_(true,"      name       model name (string, may be empty)\n");
+	_printf_(true,"      notes      model notes (string or cell array of strings, may be empty)\n");
+	_printf_(true,"      elem       elements (double array)\n");
+	_printf_(true,"      nodecon    nodal connectivity array (double array, may be empty)\n");
+	_printf_(true,"      lat        nodal latititudes (double vector)\n");
+	_printf_(true,"      long       nodal longitudes (double vector)\n");
+	_printf_(true,"      part       nodal partitions (double vector, may be empty)\n");
+	_printf_(true,"      data       nodal or element data (double vector, may be empty)\n");
+	_printf_(true,"      cmap       color map (double nx3 array, may be empty)\n");
+	_printf_(true,"      kmlfile    KML file name (string)\n");
+	_printf_(true,"\n");
+	_printf_(true,"      ierror     error flag (double, non-zero for error)\n");
+	_printf_(true,"\n");
+	_printf_(true,"   Example:\n");
+	_printf_(true,"      KMLMeshWrite(md.name,md.notes,md.elements,md.nodeconnectivity,md.lat,md.long,md.part,md.fm_criterion,options.cmap,filekml);\n");
+	_printf_(true,"\n");
+}
Index: /issm/branches/trunk-jpl-damage/src/modules/KMLMeshWrite/KMLMeshWrite.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/modules/KMLMeshWrite/KMLMeshWrite.h	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/modules/KMLMeshWrite/KMLMeshWrite.h	(revision 12168)
@@ -0,0 +1,42 @@
+/*!\file KMLMeshWrite.h
+ * \brief: prototype for KML mesh writer mex module.
+ */
+
+#ifndef _KMLMESHWRITE_H
+#define _KMLMESHWRITE_H
+
+/* local prototypes: */
+void KMLMeshWriteUsage(void);
+
+#include "../../c/include/globals.h"
+#include "../../c/modules/modules.h"
+#include "../../c/Container/Container.h"
+#include "../../c/shared/shared.h"
+#include "../../c/issm-binding.h"
+
+#undef __FUNCT__ 
+#define __FUNCT__  "KMLMeshWrite"
+
+
+/* serial input macros: */
+#define NAME          prhs[0]
+#define NOTES         prhs[1]
+#define ELEMHANDLE    prhs[2]
+#define NODECONHANDLE prhs[3]
+#define LATHANDLE     prhs[4]
+#define LNGHANDLE     prhs[5]
+#define PARTHANDLE    prhs[6]
+#define DATAHANDLE    prhs[7]
+#define CMAPHANDLE    prhs[8]
+#define FILENAME      prhs[9]
+
+/* serial output macros: */
+#define ERRORFLAG (mxArray**)&plhs[0]
+
+/* serial arg counts: */
+#undef NRHS
+#define NRHS 10
+#undef NLHS
+#define NLHS  1
+
+#endif
Index: /issm/branches/trunk-jpl-damage/src/modules/KMLOverlay/KMLOverlay.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/modules/KMLOverlay/KMLOverlay.cpp	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/modules/KMLOverlay/KMLOverlay.cpp	(revision 12168)
@@ -0,0 +1,134 @@
+/*\file KMLOverlay.c
+ *\brief: KML file overlay mex module.
+ */
+#include "./KMLOverlay.h"
+
+void mexFunction( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]){
+
+	int i,verbose=1;
+
+	/*input: */
+	char*   filkml=NULL;
+	char*   filkmz=NULL;
+
+	FILE*   fid=NULL;
+
+	Options* options=NULL;
+	int      nlat=0,nlong=0;
+	double*  lataxis =NULL;
+	double*  longaxis=NULL;
+	int      nimages=0;
+	char**   pimages=NULL;
+	double   dzip=0;
+	char*    czip=NULL;
+
+	/* output: */
+	int     ierror=0;
+
+	/*Boot module: */
+	MODULEBOOT();
+
+	/*checks on arguments on the matlab side: */
+	if(nlhs>NLHS){
+		KMLOverlayUsage(); _error_("KMLOverlay usage error");
+	}
+	if(nrhs<NRHS){
+		KMLOverlayUsage(); _error_("KMLOverlay usage error");
+	}
+
+	/*Input datasets: */
+	FetchData(&filkml,FILENAME);
+	FetchData(&options,NRHS,nrhs,prhs);
+
+	options->Get(&lataxis ,&nlat ,"lataxis" );
+	if (verbose && lataxis) for (i=0; i<nlat; i++) printf("  lataxis [%d]=%g\n",i,lataxis[i]);
+	options->Get(&longaxis,&nlong,"longaxis");
+	if (verbose && longaxis) for (i=0; i<nlong; i++) printf("  longaxis[%d]=%g\n",i,longaxis[i]);
+	options->Get(&pimages,&nimages,"images");
+	if (verbose && pimages) for (i=0; i<nimages; i++) printf("  pimages[%d]=\"%s\"\n",i,pimages[i]);
+	options->Get(&dzip,"zip",0.);
+	if (verbose) printf("  dzip=%g\n",dzip);
+
+	/*some checks*/
+	if (nlat !=2) _error_("Latitudinal axes \"lataxis\" require two double values, not %d.",nlat);
+	if (nlong!=2) _error_("Longitudinal axes \"longaxis\" require two double values, not %d.",nlong);
+	if (!nimages) _error_("No image files provided.");
+
+	if ((int)dzip){
+		filkmz=filkml;
+		filkml=(char*)mxMalloc(8*sizeof(char));
+		strcpy(filkml,"doc.kml");
+	}
+
+	if(!strlen(filkml)) strcpy(filkml,"stdout");
+
+	if(verbose) printf("Opening kml overlay file \"%s\".\n",filkml);
+	fid=fopen(filkml,"w");
+
+	/* Run core computations: */
+	if (verbose) printf("Calling core:\n");
+	KMLOverlayx(&ierror,lataxis,longaxis,nimages,pimages,fid);
+
+	if (verbose) printf("Closing file \"%s\".\n",filkml);
+	fclose(fid);
+
+	/* Create kmz file, if specified: */
+	if ((int)dzip) {
+		czip=(char*)mxMalloc((5+strlen(filkmz)+1+strlen(filkml)+1)*sizeof(char));
+		czip[0]='\0';
+		strcat(czip,"!zip ");
+		strcat(czip,filkmz);
+		strcat(czip," ");
+		strcat(czip,filkml);
+		for (i=0; i<nimages; i++)
+			if (strlen(pimages[i]) && strncmp(pimages[i],"http",4)) {
+				czip=(char*)mxRealloc(czip,(strlen(czip)+1+strlen(pimages[i])+1)*sizeof(char));
+				strcat(czip," ");
+				strcat(czip,pimages[i]);
+			}
+		if (verbose) printf("Zipping file \"%s\".\n",filkmz);
+		if (verbose) printf("%s\n",czip);
+
+		if (mexEvalString(czip)) _error_("Error zipping file \"%s\".",filkmz);
+		xfree((void**)&czip);
+		xfree((void**)&filkmz);
+	}
+
+	/*Write data: */
+	WriteData(ERRORFLAG,ierror);
+
+	/*Clean-up*/
+	if (pimages) {
+		for (i=nimages; i>0; i--) xfree((void**)&(pimages[i-1]));
+		xfree((void**)&pimages);
+	}
+	xfree((void**)&longaxis);
+	xfree((void**)&lataxis);
+	delete options;
+	xfree((void**)&filkml);
+
+	/*end module: */
+	MODULEEND();
+}
+
+void KMLOverlayUsage(void){
+	_printf_(true,"KMLOverlay - KML file overlay module:\n");
+	_printf_(true,"\n");
+	_printf_(true,"   This module reads a list of image files and writes a KML or KMZ overlay file.\n");
+	_printf_(true,"\n");
+	_printf_(true,"   Usage:\n");
+	_printf_(true,"      ierror=KMLOverlay(kmlfile,'param name',param,...);\n");
+	_printf_(true,"\n");
+	_printf_(true,"      kmlfile     KML or KMZ file name (string)\n");
+	_printf_(true,"\n");
+	_printf_(true,"      lataxis     latitude axis (double vector [south north], required)\n");
+	_printf_(true,"      longaxis    longitude axis (double vector [west east], required)\n");
+	_printf_(true,"      images      relative or http image file names (string or array of strings or cell array of strings, required)\n");
+	_printf_(true,"      zip         flag to zip the doc.kml and image files into kmzfile (double, non-zero for kmz)\n");
+	_printf_(true,"\n");
+	_printf_(true,"      ierror     error flag (double, non-zero for error)\n");
+	_printf_(true,"\n");
+	_printf_(true,"   Example:\n");
+	_printf_(true,"      KMLOverlay(kmlfile,'lataxis',[south north],'longaxis',[west east],'images',{'file1.png','http://issm/file2.png'},'zip',1);\n");
+	_printf_(true,"\n");
+}
Index: /issm/branches/trunk-jpl-damage/src/modules/KMLOverlay/KMLOverlay.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/modules/KMLOverlay/KMLOverlay.h	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/modules/KMLOverlay/KMLOverlay.h	(revision 12168)
@@ -0,0 +1,33 @@
+/*!\file KMLOverlay.h
+ * \brief: prototype for KML file overlay mex module.
+ */
+
+#ifndef _KMLOVERLAY_H
+#define _KMLOVERLAY_H
+
+/* local prototypes: */
+void KMLOverlayUsage(void);
+
+#include "../../c/include/globals.h"
+#include "../../c/modules/modules.h"
+#include "../../c/Container/Container.h"
+#include "../../c/shared/shared.h"
+#include "../../c/issm-binding.h"
+
+#undef __FUNCT__ 
+#define __FUNCT__  "KMLOverlay"
+
+
+/* serial input macros: */
+#define FILENAME      prhs[0]
+
+/* serial output macros: */
+#define ERRORFLAG (mxArray**)&plhs[0]
+
+/* serial arg counts: */
+#undef NRHS
+#define NRHS  1
+#undef NLHS
+#define NLHS  1
+
+#endif
Index: /issm/branches/trunk-jpl-damage/src/modules/Kml2Exp/Kml2Exp.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/modules/Kml2Exp/Kml2Exp.cpp	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/modules/Kml2Exp/Kml2Exp.cpp	(revision 12168)
@@ -0,0 +1,90 @@
+/*\file Kml2Exp.c
+ *\brief: kml to exp file conversion mex module.
+ */
+#include "./Kml2Exp.h"
+
+void mexFunction( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]){
+
+	int i,verbose=1;
+
+	/*input: */
+	char    *filkml=NULL,*filexp=NULL;
+	int     sgn;
+	Options* options=NULL;
+	double   cm=0.,sp=0.;
+
+	/* output: */
+	int     iret=0;
+
+	/*Boot module: */
+	MODULEBOOT();
+
+	/*checks on arguments on the matlab side: */
+	if (nlhs > NLHS) {
+		Kml2ExpUsage(); _error_("Kml2Exp usage error");
+	}
+	if (nrhs < NRHS) {
+		Kml2ExpUsage(); _error_("Kml2Exp usage error");
+	}
+
+	/*Input datasets: */
+	FetchData(&filkml,KML_IN);
+	FetchData(&filexp,EXP_IN);
+	FetchData(&sgn,SGN_IN);
+	FetchData(&options,NRHS,nrhs,prhs);
+
+	/*  defaults are in Ll2xydef, so don't duplicate them here, and only use user values if both have been specified  */
+	if (options->GetOption("central_meridian") || options->GetOption("standard_parallel")) {
+		options->Get(&cm,"central_meridian");
+		if (verbose) printf("  cm=%g\n",cm);
+		options->Get(&sp,"standard_parallel");
+		if (verbose) printf("  sp=%g\n",sp);
+	}
+
+	/*some checks*/
+	if (sgn !=+1 && sgn!= -1) _error_("Hemisphere sgn=%d must be +1 (north) or -1 (south).",sgn);
+	if (fabs(cm)      > 180.) _error_("Central meridian cm=%g must be between -180 (west) and +180 (east) degrees.",cm);
+	if (sp < 0. || sp >  90.) _error_("Standard parallel sp=%g must be between 0 and 90 degrees (in specified hemisphere).",sp);
+
+	/* Run core computations: */
+	if (options->GetOption("central_meridian") && options->GetOption("standard_parallel"))
+		iret=Kml2Expx(filkml,filexp,sgn,cm,sp);
+	else
+		iret=Kml2Expx(filkml,filexp,sgn);
+
+	/*Write data: */
+	WriteData(RET_OUT,iret);
+
+	/*Clean-up*/
+	delete options;
+	xfree((void**)&filexp);
+	xfree((void**)&filkml);
+
+	/*end module: */
+	MODULEEND();
+}
+
+void Kml2ExpUsage(void){
+	_printf_(true,"Kml2Exp - kml to exp file conversion module:\n");
+	_printf_(true,"\n");
+	_printf_(true,"   This module converts a file from kml to exp format.\n");
+	_printf_(true,"\n");
+	_printf_(true,"   Usage:\n");
+	_printf_(true,"      [ret]=Kml2Exp(filexp,filkml,sgn,'param name',param,...);\n");
+	_printf_(true,"\n");
+	_printf_(true,"      filkml      file name of kml file to be read (char)\n");
+	_printf_(true,"      filexp      file name of exp file to be written (char)\n");
+	_printf_(true,"      sgn         sign for hemisphere (double, +1 (north) or -1 (south))\n");
+	_printf_(true,"\n");
+	_printf_(true,"      central_meridian     central meridian (double, optional, but must specify with sp)\n");
+	_printf_(true,"      standard_parallel    standard parallel (double, optional, but must specify with cm)\n");
+	_printf_(true,"\n");
+	_printf_(true,"      ret         return code (non-zero for warning)\n");
+	_printf_(true,"\n");
+	_printf_(true,"   Examples:\n");
+	_printf_(true,"      [ret]=Kml2Exp('file.kml','file.exp', 1);\n");
+	_printf_(true,"      [ret]=Kml2Exp('file.kml','file.exp', 1,'central_meridian',45,'standard_parallel',70);\n");
+	_printf_(true,"      [ret]=Kml2Exp('file.kml','file.exp',-1,'central_meridian', 0,'standard_parallel',71);\n");
+	_printf_(true,"\n");
+}
+
Index: /issm/branches/trunk-jpl-damage/src/modules/Kml2Exp/Kml2Exp.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/modules/Kml2Exp/Kml2Exp.h	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/modules/Kml2Exp/Kml2Exp.h	(revision 12168)
@@ -0,0 +1,36 @@
+/*!\file Kml2Exp.h
+ * \brief: prototype for kml to exp file conversion mex module.
+ */
+
+#ifndef _KML2EXP_H
+#define _KML2EXP_H
+
+/* local prototypes: */
+void Kml2ExpUsage(void);
+
+#include "../../c/include/globals.h"
+#include "../../c/modules/modules.h"
+#include "../../c/Container/Container.h"
+#include "../../c/shared/shared.h"
+#include "../../c/issm-binding.h"
+
+#undef __FUNCT__ 
+#define __FUNCT__  "Kml2Exp"
+
+
+/* serial input macros: */
+#define KML_IN    prhs[0]
+#define EXP_IN    prhs[1]
+#define SGN_IN    prhs[2]
+
+/* serial output macros: */
+#define RET_OUT    (mxArray**)&plhs[0]
+
+/* serial arg counts: */
+#undef NRHS
+#define NRHS  3
+#undef NLHS
+#define NLHS  1
+
+#endif
+
Index: /issm/branches/trunk-jpl-damage/src/modules/Kriging/Kriging.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/modules/Kriging/Kriging.cpp	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/modules/Kriging/Kriging.cpp	(revision 12168)
@@ -0,0 +1,52 @@
+/*\file Kriging.c
+ *\brief: best linear predictor
+ */
+#include "./Kriging.h"
+
+void mexFunction( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]){
+
+	/*Outputs*/
+	double *x            = NULL;
+	double *y            = NULL;
+	double *observations = NULL;
+	double *x_interp     = NULL;
+	double *y_interp     = NULL;
+	double *predictions  = NULL;
+	int     n_interp,n,n_obs;
+
+	/*Boot module: */
+	MODULEBOOT();
+
+	/*checks on arguments on the matlab side: */
+	CheckNumMatlabArguments(nlhs,NLHS,nrhs,NRHS,__FUNCT__,&KrigingUsage);
+
+	/*Fetch inputs: */
+	FetchData(&x,&n_obs,X);
+	FetchData(&y,&n,Y);                       if(n_obs!=n) _error_("x and y should have the same size");
+	FetchData(&observations,&n,OBSERVATIONS); if(n_obs!=n) _error_("x and observations should have the same size");
+	FetchData(&x_interp,&n_interp,XINTERP);
+	FetchData(&y_interp,&n,YINTERP);          if(n_interp!=n) _error_("x_interp and y_interp should have the same size");
+
+	/*Call x layer*/
+	Krigingx(&predictions,x,y,observations,n_obs,x_interp,y_interp,n_interp);
+
+	/*Generate output Matlab Structures*/
+	WriteData(PREDICTIONS,predictions,n_interp);
+
+	/*Free ressources: */
+	xfree((void**)&x);
+	xfree((void**)&y);
+	xfree((void**)&observations);
+	xfree((void**)&x_interp);
+	xfree((void**)&y_interp);
+	xfree((void**)&predictions);
+
+	/*end module: */
+	MODULEEND();
+}
+
+void KrigingUsage(void){
+	_printf_(true,"\n");
+	_printf_(true,"   usage: predictions=%s(x,y,observations,x_interp,y_interp);\n",__FUNCT__);
+	_printf_(true,"\n");
+}
Index: /issm/branches/trunk-jpl-damage/src/modules/Kriging/Kriging.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/modules/Kriging/Kriging.h	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/modules/Kriging/Kriging.h	(revision 12168)
@@ -0,0 +1,35 @@
+/*
+	KrigingUsage.h
+*/
+
+#ifndef _KRIGING_H_
+#define _KRIGING_H_
+
+/* local prototypes: */
+void KrigingUsage(void);
+
+#include "../../c/include/globals.h"
+#include "../../c/modules/modules.h"
+#include "../../c/shared/shared.h"
+#include "../../c/issm-binding.h"
+
+#undef __FUNCT__ 
+#define __FUNCT__  "Kriging"
+    
+/* serial input macros: */
+#define X            (mxArray *)prhs[0]
+#define Y            (mxArray *)prhs[1]
+#define OBSERVATIONS (mxArray *)prhs[2]
+#define XINTERP      (mxArray *)prhs[3]
+#define YINTERP      (mxArray *)prhs[4]
+
+/* serial output macros: */
+#define PREDICTIONS (mxArray**)&plhs[0]
+
+/* serial arg counts: */
+#undef NLHS
+#define NLHS  1
+#undef NRHS
+#define NRHS  5
+
+#endif  /* _KRIGING_H_ */
Index: /issm/branches/trunk-jpl-damage/src/modules/Ll2xy/Ll2xy.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/modules/Ll2xy/Ll2xy.cpp	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/modules/Ll2xy/Ll2xy.cpp	(revision 12168)
@@ -0,0 +1,98 @@
+/*\file Ll2xy.c
+ *\brief: lat/long to x/y coordinate mex module.
+ */
+#include "./Ll2xy.h"
+
+void mexFunction( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]){
+
+	int i,verbose=1;
+
+	/*input: */
+	double  *lat=NULL,*lon=NULL;
+	int     nlat,nlon,ncoord;
+	int     sgn;
+
+	Options* options=NULL;
+	double   cm=0.,sp=0.;
+
+	/* output: */
+	double  *x=NULL,*y=NULL;
+	int     iret=0;
+
+	/*Boot module: */
+	MODULEBOOT();
+
+	/*checks on arguments on the matlab side: */
+	if (nlhs > NLHS) {
+		Ll2xyUsage(); _error_("Ll2xy usage error");
+	}
+	if (nrhs < NRHS) {
+		Ll2xyUsage(); _error_("Ll2xy usage error");
+	}
+
+	/*Input datasets: */
+	FetchData(&lat,&nlat,LAT_IN);
+	FetchData(&lon,&nlon,LON_IN);
+	FetchData(&sgn,SGN_IN);
+	FetchData(&options,NRHS,nrhs,prhs);
+
+	/*  defaults are in Ll2xydef, so don't duplicate them here, and only use user values if both have been specified  */
+	if(options->GetOption("central_meridian") || options->GetOption("standard_parallel")){
+		options->Get(&cm,"central_meridian");
+		if (verbose) printf("  cm=%g\n",cm);
+		options->Get(&sp,"standard_parallel");
+		if (verbose) printf("  sp=%g\n",sp);
+	}
+
+	/*some checks*/
+	if (verbose) printf("Checking inputs:\n");
+	if (nlat != nlon) _error_("Must have same number of lat[%d] and lon[%d] coordinates.",nlat,nlon);
+	else                ncoord=nlat;
+	if (sgn != +1 && sgn != -1) _error_("Hemisphere sgn=%d must be +1 (north) or -1 (south).",sgn);
+	if (fabs(cm)      > 180.) _error_("Central meridian cm=%g must be between -180 (west) and +180 (east) degrees.",cm);
+	if (sp < 0. || sp >  90.) _error_("Standard parallel sp=%g must be between 0 and 90 degrees (in specified hemisphere).",sp);
+
+	x=(double*)mxMalloc(ncoord*sizeof(double));
+	y=(double*)mxMalloc(ncoord*sizeof(double));
+
+	/* Run core computations: */
+	if (options->GetOption("central_meridian") && options->GetOption("standard_parallel"))
+		iret=Ll2xyx(x,y,lat,lon,ncoord,sgn,cm,sp);
+	else
+		iret=Ll2xyx(x,y,lat,lon,ncoord,sgn);
+
+	/*Write data: */
+	WriteData(X_OUT,x,ncoord);
+	WriteData(Y_OUT,y,ncoord);
+
+	/*Clean-up*/
+	delete options;
+
+	/*end module: */
+	MODULEEND();
+}
+
+void Ll2xyUsage(void){
+	_printf_(true,"Ll2xy - lat/long to x/y coordinate transformation module:\n");
+	_printf_(true,"\n");
+	_printf_(true,"   This module transforms lat/long to x/y coordinates.\n");
+	_printf_(true,"\n");
+	_printf_(true,"   Usage:\n");
+	_printf_(true,"      [x,y]=Ll2xy(lat,lon,sgn,'param name',param,...);\n");
+	_printf_(true,"\n");
+	_printf_(true,"      lat         latitude coordinates (double vector)\n");
+	_printf_(true,"      lon         longitude coordinates (double vector)\n");
+	_printf_(true,"      sgn         sign for hemisphere (double, +1 (north) or -1 (south))\n");
+	_printf_(true,"\n");
+	_printf_(true,"      central_meridian     central meridian (double, optional, but must specify with sp)\n");
+	_printf_(true,"      standard_parallel    standard parallel (double, optional, but must specify with cm)\n");
+	_printf_(true,"\n");
+	_printf_(true,"      x           x coordinates (double vector)\n");
+	_printf_(true,"      y           y coordinates (double vector)\n");
+	_printf_(true,"\n");
+	_printf_(true,"   Examples:\n");
+	_printf_(true,"      [x,y]=Ll2xy(lat,lon, 1);\n");
+	_printf_(true,"      [x,y]=Ll2xy(lat,lon, 1,'central_meridian',45,'standard_parallel',70);\n");
+	_printf_(true,"      [x,y]=Ll2xy(lat,lon,-1,'central_meridian', 0,'standard_parallel',71);\n");
+	_printf_(true,"\n");
+}
Index: /issm/branches/trunk-jpl-damage/src/modules/Ll2xy/Ll2xy.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/modules/Ll2xy/Ll2xy.h	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/modules/Ll2xy/Ll2xy.h	(revision 12168)
@@ -0,0 +1,37 @@
+/*!\file Ll2xy.h
+ * \brief: prototype for lat/long to x/y coordinate mex module.
+ */
+
+#ifndef _LL2XY_H
+#define _LL2XY_H
+
+/* local prototypes: */
+void Ll2xyUsage(void);
+
+#include "../../c/include/globals.h"
+#include "../../c/modules/modules.h"
+#include "../../c/Container/Container.h"
+#include "../../c/shared/shared.h"
+#include "../../c/issm-binding.h"
+
+#undef __FUNCT__ 
+#define __FUNCT__  "Ll2xy"
+
+
+/* serial input macros: */
+#define LAT_IN    prhs[0]
+#define LON_IN    prhs[1]
+#define SGN_IN    prhs[2]
+
+/* serial output macros: */
+#define X_OUT    (mxArray**)&plhs[0]
+#define Y_OUT    (mxArray**)&plhs[1]
+
+/* serial arg counts: */
+#undef NRHS
+#define NRHS  3
+#undef NLHS
+#define NLHS  2
+
+#endif
+
Index: /issm/branches/trunk-jpl-damage/src/modules/Makefile.am
===================================================================
--- /issm/branches/trunk-jpl-damage/src/modules/Makefile.am	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/modules/Makefile.am	(revision 12168)
@@ -0,0 +1,8 @@
+SUBDIRS = 
+if MATLAB
+SUBDIRS += matlab
+endif
+
+if PYTHON
+SUBDIRS += python
+endif
Index: /issm/branches/trunk-jpl-damage/src/modules/MeshPartition/MeshPartition.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/modules/MeshPartition/MeshPartition.cpp	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/modules/MeshPartition/MeshPartition.cpp	(revision 12168)
@@ -0,0 +1,104 @@
+/*!\file:  MeshPartition.cpp
+ * \brief: partition mesh according to number of areas, using Metis library.
+
+	usage:
+	[element_partitioning,node_partitioning]=MeshPartition(model,numareas)
+	
+	%Info needed from model are the following: 
+	%mesh info: 
+	numberofelements,numberofvertices,elements,elements_width
+	%Non-extruded 2d mesh info
+	nel2d,nods2d,elements2d,
+	%Extruded 2d mesh info
+	nel2d_ext,nods2d_ext,elements2d_ext,
+	%Diverse
+	numberoflayers,dim)
+
+	output:
+	vector of partitioning area numbers, for every element.
+	vector of partitioning area numbers, for every node.
+*/
+	
+#include "./MeshPartition.h"
+
+
+void mexFunction( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]) {
+
+
+	/*Indexing: */
+	int i,j;
+
+	/* required input: */
+	int     dim;
+	int     numberofelements;
+	int     numberofvertices;
+	double *elements         = NULL;
+	int     elements_width;
+
+	int numberofelements2d;
+	int numberofvertices2d;
+	double* elements2d=NULL;
+
+	int numberoflayers;
+	int numareas=1;
+
+	/* output: */
+	int    *int_element_partitioning = NULL;
+	int    *int_node_partitioning    = NULL;
+	double *element_partitioning     = NULL;
+	double *node_partitioning        = NULL;
+
+	/*Boot module: */
+	MODULEBOOT();
+
+	/*checks on arguments on the matlab side: */
+	CheckNumMatlabArguments(nlhs,NLHS,nrhs,NRHS,__FUNCT__,&MeshPartitionUsage);
+
+	/*Fetch data: */
+	FetchData(&dim,mxGetAssignedField(MODEL,0,"dimension"));
+	FetchData(&numberofelements,mxGetAssignedField(MODEL,0,"numberofelements"));
+	FetchData(&numberofvertices,mxGetAssignedField(MODEL,0,"numberofvertices"));
+	FetchData(&elements,NULL,&elements_width,mxGetAssignedField(MODEL,0,"elements"));
+
+	if (dim==3){
+		FetchData(&numberofelements2d,mxGetAssignedField(MODEL,0,"numberofelements2d"));
+		FetchData(&numberofvertices2d,mxGetAssignedField(MODEL,0,"numberofvertices2d"));
+		FetchData(&elements2d,NULL,NULL,mxGetAssignedField(MODEL,0,"elements2d"));
+	}
+	FetchData(&numberoflayers,mxGetAssignedField(MODEL,0,"numberoflayers"));
+	FetchData(&numareas,NUMAREAS);
+
+	/*Run partitioning algorithm based on a "clever" use of the Metis partitioner: */
+	MeshPartitionx(&int_element_partitioning,&int_node_partitioning,numberofelements,numberofvertices,elements,
+		numberofelements2d,numberofvertices2d,elements2d,numberoflayers,elements_width,dim,numareas);
+
+	/*Post process node_partitioning and element_partitioning to be in double format. Metis needed them in int* format: */
+	element_partitioning=(double*)xmalloc(numberofelements*sizeof(double));
+	for (i=0;i<numberofelements;i++){
+		element_partitioning[i]=(double)int_element_partitioning[i]+1; //Metis indexing from 0, matlab from 1.
+	}
+	
+	node_partitioning=(double*)xmalloc(numberofvertices*sizeof(double));
+	for (i=0;i<numberofvertices;i++){
+		node_partitioning[i]=(double)int_node_partitioning[i]+1; //Metis indexing from 0, matlab from 1.
+	}
+
+	/*Write data:*/
+	WriteData(ELEMENTPARTITIONING,element_partitioning,numberofelements);
+	WriteData(NODEPARTITIONING,node_partitioning,numberofvertices);
+	
+	/*Free ressources:*/
+	//don't! let matlab do it.
+
+	/*end module: */
+	MODULEEND();
+}
+
+void MeshPartitionUsage(void){
+	printf("   usage:\n");
+	printf("   [element_partitioning,node_partitioning]=MeshPartition(md.mesh,numpartitions)");
+	printf("   where:\n");
+	printf("      element_partitioning is a vector of partitioning area numbers, for every element.\n");
+	printf("      node_partitioning is a vector of partitioning area numbers, for every node.\n");
+	printf("\n");
+}
Index: /issm/branches/trunk-jpl-damage/src/modules/MeshPartition/MeshPartition.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/modules/MeshPartition/MeshPartition.h	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/modules/MeshPartition/MeshPartition.h	(revision 12168)
@@ -0,0 +1,41 @@
+
+/*
+	MeshPartition.h
+*/
+
+
+#ifndef _MESHPARTITION_H
+#define _MESHPARTITION_H
+
+/* local prototypes: */
+void MeshPartitionUsage(void);
+
+#include "../../c/include/globals.h"
+#include "../../c/modules/modules.h"
+#include "../../c/Container/Container.h"
+#include "../../c/shared/shared.h"
+#include "../../c/issm-binding.h"
+
+#undef CLEANUP
+#define CLEANUP MeshPartitionLocalCleanup();
+
+#undef __FUNCT__ 
+#define __FUNCT__  "MeshPartition"
+
+/* serial input macros: */
+#define MODEL (mxArray*)prhs[0]
+#define NUMAREAS (mxArray*)prhs[1]
+
+/* serial output macros: */
+#define ELEMENTPARTITIONING (mxArray**)&plhs[0]
+#define NODEPARTITIONING (mxArray**)&plhs[1]
+
+/* serial arg counts: */
+#undef NLHS
+#define NLHS  2
+#undef NRHS
+#define NRHS  2
+
+
+#endif  /* _MESHPARTITION_H */
+
Index: /issm/branches/trunk-jpl-damage/src/modules/MeshProfileIntersection/MeshProfileIntersection.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/modules/MeshProfileIntersection/MeshProfileIntersection.cpp	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/modules/MeshProfileIntersection/MeshProfileIntersection.cpp	(revision 12168)
@@ -0,0 +1,114 @@
+/*! \file  MeshProfileIntersection.cpp
+    \brief: takes a  .exp file (made of several profiles), and figures out its intersection 
+	with a mesh.
+
+	usage:
+	[segments]=MeshProfileIntersection(index,x,y,filename);
+
+	where:
+	input:
+		index,x,y is a triangulation
+		filename: name of Argus style .exp file containing the segments (can be groups of disconnected segments)
+	output:
+		segments: array made of x1,y1,x2,y2,element_id lines (x1,y1) and (x2,y2) are segment extremitis for a segment 
+		belonging to the elemnt_id element. there are as many lines in segments as there are segments intersecting the 
+		mesh.
+*/
+	
+#include "./MeshProfileIntersection.h"
+
+void mexFunction( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]) {
+
+	int i,j;
+
+	/* required input: */
+	//mesh
+	double* double_index=NULL;
+	int*    index=NULL;
+	int     nel;
+	double* x=NULL;
+	double* y=NULL;
+	int     nods;
+	int     dummy;
+	
+	//contours
+	mxArray*  matlabstructure=NULL;
+	Contour** contours=NULL;
+	int       numcontours;
+	Contour*  contouri=NULL;
+
+	/* output: */
+	double* segments=NULL;
+	int     numsegs;
+
+	/*Boot module: */
+	MODULEBOOT();
+
+	/*checks on arguments on the matlab side: */
+	CheckNumMatlabArguments(nlhs,NLHS,nrhs,NRHS,__FUNCT__,&MeshProfileIntersectionUsage);
+
+	/*First, call expread on filename to build a contour array in the matlab workspace: */
+	mexCallMATLAB( 1, &matlabstructure, 1, (mxArray**)&FILENAME, "expread");
+
+	/*Fetch inputs: */
+	//index
+	FetchData(&double_index,&nel,&dummy,INDEX);
+	if(dummy!=3 && dummy!=6)_error_(" element triangulation should be of 3 or 6 column width!");
+	index=(int*)xmalloc(nel*3*sizeof(int));
+	for(i=0;i<nel;i++){
+		for(j=0;j<3;j++){
+			*(index+3*i+j)=(int)*(double_index+dummy*i+j)-1; //"C" style indexing
+		}
+	}
+	//x and y
+	FetchData(&x,&nods,X);
+	FetchData(&y,&dummy,Y);
+
+	//contours
+	numcontours=mxGetNumberOfElements(matlabstructure);
+	contours=(Contour**)xmalloc(numcontours*sizeof(Contour*));
+	for(i=0;i<numcontours;i++){
+		//allocate
+		contouri=(Contour*)xmalloc(sizeof(Contour));
+		//retrieve dimension of this contour.
+		contouri->nods=(int)mxGetScalar(mxGetField(matlabstructure,i,"nods"));
+		//set pointers.
+		contouri->x=mxGetPr(mxGetField(matlabstructure,i,"x"));
+		contouri->y=mxGetPr(mxGetField(matlabstructure,i,"y"));
+		*(contours+i)=contouri;
+	}
+
+	/* Debugging of contours :{{{1*/
+	/*for(i=0;i<numcontours;i++){
+		printf("\nContour echo: contour number  %i / %i\n",i+1,numcontours);
+		contouri=*(contours+i);
+		printf("   Number of vertices %i\n",contouri->nods);
+		for (j=0;j<contouri->nods;j++){
+			printf("   %lf %lf\n",*(contouri->x+j),*(contouri->y+j));
+		}
+	}*/
+	/*}}}*/
+
+	/*Run interpolation routine: */
+	MeshProfileIntersectionx(&segments,&numsegs,index,x,y,nel,nods,contours,numcontours);
+
+	/* output: */
+	WriteData(SEGMENTS,segments,numsegs,5);
+
+	/*end module: */
+	MODULEEND();
+
+}
+
+void MeshProfileIntersectionUsage(void){
+	printf("   usage:\n");
+	printf("   [segments]=MeshProfileIntersection(index,x,y,filename);\n");
+	printf("   where:\n");
+	printf("   input:\n");
+	printf("        index,x,y is a triangulation\n");
+	printf("        filename: name of Argus style .exp file containing the segments (can be groups of disconnected segments)\n");
+	printf("   output:\n");
+	printf("        segments: array made of x1,y1,x2,y2,element_id lines (x1,y1) and (x2,y2) are segment extremitis for a segment \n");
+	printf("        belonging to the elemnt_id element. there are as many lines in segments as there are segments intersecting the \n");
+	printf("        mesh.\n");
+}
Index: /issm/branches/trunk-jpl-damage/src/modules/MeshProfileIntersection/MeshProfileIntersection.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/modules/MeshProfileIntersection/MeshProfileIntersection.h	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/modules/MeshProfileIntersection/MeshProfileIntersection.h	(revision 12168)
@@ -0,0 +1,38 @@
+
+/*
+	MeshProfileIntersection.h
+*/
+
+
+#ifndef _MESHPROFILEINTERSECTION_H
+#define _MESHPROFILEINTERSECTION_H
+
+/* local prototypes: */
+void MeshProfileIntersectionUsage(void);
+
+#include "../../c/include/globals.h"
+#include "../../c/modules/modules.h"
+#include "../../c/Container/Container.h"
+#include "../../c/shared/shared.h"
+#include "../../c/issm-binding.h"
+
+#undef __FUNCT__
+#define __FUNCT__ "MeshProfileIntersection"
+
+/* input macros: */
+#define INDEX prhs[0]
+#define X prhs[1]
+#define Y prhs[2]
+#define FILENAME prhs[3]
+
+/* serial output macros: */
+#define SEGMENTS (mxArray**)&plhs[0]
+
+/* serial arg counts: */
+#undef NLHS
+#define NLHS 1
+#undef NRHS
+#define NRHS 4
+
+#endif  /* _MESHPROFILEINTERSECTION_H */
+
Index: /issm/branches/trunk-jpl-damage/src/modules/NodeConnectivity/NodeConnectivity.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/modules/NodeConnectivity/NodeConnectivity.cpp	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/modules/NodeConnectivity/NodeConnectivity.cpp	(revision 12168)
@@ -0,0 +1,42 @@
+/*\file NodeConnectivity.c
+ *\brief: build node connectivity from elements. 
+ */
+
+#include "./NodeConnectivity.h"
+
+WRAPPER(NodeConnectivity){
+
+	/*inputs: */
+	double* elements=NULL;
+	int     nel;
+	int     nods;
+
+	/*outputs: */
+	double* connectivity=NULL;
+	int     width;
+
+	/*Boot module: */
+	MODULEBOOT();
+
+	/*checks on arguments: */
+	CHECKARGUMENTS(NLHS,NRHS,&NodeConnectivityUsage);
+        
+	/*Input datasets: */
+	FetchData(&elements,&nel,NULL,ELEMENTS);
+	FetchData(&nods,NUMNODES);
+
+	/*!Generate internal degree of freedom numbers: */
+	NodeConnectivityx(&connectivity, &width,elements,nel, nods);
+
+	/*write output datasets: */
+	WriteData(CONNECTIVITY,connectivity,nods,width);
+
+	/*end module: */
+	MODULEEND();
+}
+
+void NodeConnectivityUsage(void) {
+	_printf_(true,"\n");
+	_printf_(true,"   usage: connectivity = %s(elements, numnodes);\n",__FUNCT__);
+	_printf_(true,"\n");
+}
Index: /issm/branches/trunk-jpl-damage/src/modules/NodeConnectivity/NodeConnectivity.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/modules/NodeConnectivity/NodeConnectivity.h	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/modules/NodeConnectivity/NodeConnectivity.h	(revision 12168)
@@ -0,0 +1,58 @@
+/*
+	NodeConnectivity.h
+*/
+
+#ifndef _NODECONNECTIVITY_H
+#define _NODECONNECTIVITY_H
+
+#ifdef HAVE_CONFIG_H
+	#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+/*Very important definition in case we are compiling a python module!: needs to come before header files inclusion*/
+#ifdef _HAVE_PYTHON_
+#define PY_ARRAY_UNIQUE_SYMBOL PythonIOSymbol
+#endif
+
+/*Header files: */
+#include "../../c/include/globals.h"
+#include "../../c/toolkits/toolkits.h"
+#include "../../c/include/include.h"
+#include "../../c/modules/modules.h"
+#include "../../c/Container/Container.h"
+#include "../../c/shared/shared.h"
+#include "../../c/issm-binding.h"
+#include "../../c/io/io.h"
+#include "../../c/EnumDefinitions/EnumDefinitions.h"
+
+#ifdef _HAVE_MATLAB_MODULES_
+/* serial input macros: */
+#define ELEMENTS (mxArray*)prhs[0]
+#define NUMNODES (mxArray*)prhs[1]
+/* serial output macros: */
+#define CONNECTIVITY (mxArray**)&plhs[0]
+#endif
+
+#ifdef _HAVE_PYTHON_MODULES_
+/* serial input macros: */
+#define ELEMENTS PyTuple_GetItem(args,0)
+#define NUMNODES PyTuple_GetItem(args,1)
+/* serial output macros: */
+#define CONNECTIVITY output,0
+#endif
+
+#undef __FUNCT__ 
+#define __FUNCT__  "NodeConnectivity"
+
+/* serial arg counts: */
+#undef NLHS
+#define NLHS  1
+#undef NRHS
+#define NRHS  2
+
+/* local prototypes: */
+void NodeConnectivityUsage(void);
+
+#endif  /* _NODECONNECTIVITY_H */
Index: /issm/branches/trunk-jpl-damage/src/modules/PointCloudFindNeighbors/PointCloudFindNeighbors.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/modules/PointCloudFindNeighbors/PointCloudFindNeighbors.cpp	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/modules/PointCloudFindNeighbors/PointCloudFindNeighbors.cpp	(revision 12168)
@@ -0,0 +1,52 @@
+/*! \file  PointCloudFindNeighbors
+    \brief: flag points that are too near one another, within an array of point coordinates
+*/
+	
+#include "./PointCloudFindNeighbors.h"
+
+void mexFunction( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]) {
+
+	int i,j;
+
+	/* required input: */
+	double* x=NULL;
+	double* y=NULL;
+	int     nods;
+	double  mindistance;
+	double  multithread;
+
+	/* output: */
+	Vector*  flags=NULL;
+
+	/*Boot module: */
+	MODULEBOOT();
+
+	/*checks on arguments on the matlab side: */
+	CheckNumMatlabArguments(nlhs,NLHS,nrhs,NRHS,__FUNCT__,&PointCloudFindNeighborsUsage);
+
+	/*Fetch inputs: */
+	FetchData(&x,&nods,NULL,XHANDLE);  
+	FetchData(&y,NULL,NULL,YHANDLE);
+	FetchData(&mindistance,MINDISTANCE);
+	FetchData(&multithread,MULTITHREAD);
+
+	/*Run core routine: */
+	PointCloudFindNeighborsx(&flags,x,y,nods,mindistance,multithread);
+
+	/* output: */
+	WriteData(FLAGS,flags);
+
+	/*end module: */
+	MODULEEND();
+}
+
+void PointCloudFindNeighborsUsage(void){
+	printf("   usage:\n");
+	printf("   [flags]=PointCloudFindNeighbors(x,y,mindistance,multithread);\n\n");
+	printf("   where:\n");
+	printf("      x,y: list of points.\n");
+	printf("      mindistance: minimum distance that should exist between points in the cloud.\n");
+	printf("      multithread: run multithreaded or not. with multithreads, flags can get 1 and 2 values in duplicates.\n");
+	printf("      flags: array of flags (flag==1 means point is within mindistance of another point)\n");
+	printf("\n");
+}
Index: /issm/branches/trunk-jpl-damage/src/modules/PointCloudFindNeighbors/PointCloudFindNeighbors.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/modules/PointCloudFindNeighbors/PointCloudFindNeighbors.h	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/modules/PointCloudFindNeighbors/PointCloudFindNeighbors.h	(revision 12168)
@@ -0,0 +1,44 @@
+
+/*
+	PointCloudFindNeighbors.h
+*/
+
+
+#ifndef _POINTCLOUDFINDNEIGHBORS_H
+#define _POINTCLOUDFINDNEIGHBORS_H
+
+/* local prototypes: */
+void PointCloudFindNeighborsUsage(void);
+
+#include "../../c/include/globals.h"
+#include "../../c/modules/modules.h"
+#include "../../c/Container/Container.h"
+#include "../../c/shared/shared.h"
+#include "../../c/issm-binding.h"
+
+#undef __FUNCT__
+#define __FUNCT__ "PointCloudFindNeighbors"
+
+
+#ifndef ALL
+#define ALL 0
+#endif
+
+/* input macros: */
+#define XHANDLE prhs[0]
+#define YHANDLE prhs[1]
+#define MINDISTANCE prhs[2]
+#define MULTITHREAD prhs[3]
+
+/* serial output macros: */
+#define FLAGS (mxArray**)&plhs[0]
+
+/* serial arg counts: */
+#undef NLHS
+#define NLHS 1
+#undef NRHS
+#define NRHS 4
+
+
+#endif  /* _POINTCLOUDFINDNEIGHBORS_H */
+
Index: /issm/branches/trunk-jpl-damage/src/modules/PropagateFlagsFromConnectivity/PropagateFlagsFromConnectivity.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/modules/PropagateFlagsFromConnectivity/PropagateFlagsFromConnectivity.cpp	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/modules/PropagateFlagsFromConnectivity/PropagateFlagsFromConnectivity.cpp	(revision 12168)
@@ -0,0 +1,47 @@
+/*\file PropagateFlagsFromConnectivity.c
+ *\brief: propagate flags onto mesh, element by element, using connectivity.
+ */
+
+#include "./PropagateFlagsFromConnectivity.h"
+
+void mexFunction( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]){
+
+	/*input/output datasets: */
+	double* connectivity=NULL;
+	int     nel;
+	double* pool=NULL;
+	double* flags=NULL;
+	int     index;
+	int     dummy;
+	
+	/*Boot module: */
+	MODULEBOOT();
+
+	/*checks on arguments on the matlab side: */
+	CheckNumMatlabArguments(nlhs,NLHS,nrhs,NRHS,__FUNCT__,&PropagateFlagsFromConnectivityUsage);
+        
+	/*Input datasets: */
+	FetchData(&connectivity,&nel,&dummy,CONNECTIVITY);
+	FetchData(&pool,&dummy,POOL);
+	FetchData(&index,INDEX);
+	FetchData(&flags,&dummy,FLAGS);
+
+	/*!Generate internal degree of freedom numbers: */
+	PropagateFlagsFromConnectivityx(pool,connectivity,index,flags);
+
+	/*write output datasets: */
+	WriteData(POOLOUT,pool,nel);
+
+	/*Free ressources: */
+	xfree((void**)&connectivity);
+	xfree((void**)&flags);
+
+	/*end module: */
+	MODULEEND();
+}
+
+void PropagateFlagsFromConnectivityUsage(void) {
+	printf("\n");
+	printf("   usage: [pool] = %s(connectivity,pool,index,flags);\n",__FUNCT__);
+	printf("\n");
+}
Index: /issm/branches/trunk-jpl-damage/src/modules/PropagateFlagsFromConnectivity/PropagateFlagsFromConnectivity.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/modules/PropagateFlagsFromConnectivity/PropagateFlagsFromConnectivity.h	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/modules/PropagateFlagsFromConnectivity/PropagateFlagsFromConnectivity.h	(revision 12168)
@@ -0,0 +1,40 @@
+
+/*
+	PropagateFlagsFromConnectivity.h
+*/
+
+
+#ifndef _PROPAGATEFLAGSFROMCONNECTIVITY_H
+#define _PROPAGATEFLAGSFROMCONNECTIVITY_H
+
+/* local prototypes: */
+void PropagateFlagsFromConnectivityUsage(void);
+
+#include "../../c/include/globals.h"
+#include "../../c/modules/modules.h"
+#include "../../c/Container/Container.h"
+#include "../../c/shared/shared.h"
+#include "../../c/issm-binding.h"
+
+#undef __FUNCT__ 
+#define __FUNCT__  "PropagateFlagsFromConnectivity"
+
+/* serial input macros: */
+#define CONNECTIVITY (mxArray*)prhs[0]
+#define POOL (mxArray*)prhs[1]
+#define INDEX (mxArray*)prhs[2]
+#define FLAGS (mxArray*)prhs[3]
+
+/* serial output macros: */
+#define POOLOUT (mxArray**)&plhs[0]
+
+/* serial arg counts: */
+#undef NLHS
+#define NLHS  1
+#undef NRHS
+#define NRHS  4
+
+
+#endif  /* _PROPAGATEFLAGSFROMCONNECTIVITY_H */
+
+
Index: /issm/branches/trunk-jpl-damage/src/modules/Scotch/Scotch.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/modules/Scotch/Scotch.cpp	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/modules/Scotch/Scotch.cpp	(revision 12168)
@@ -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.
+	_error_(" 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",
+				  __FUNCT__,argvm[isi]);
+		isi++;
+	}
+	else {
+		argvm[isi] = (char *) calloc(5+1,sizeof(char));
+		strcpy(argvm[isi],"gpart");
+		mexPrintf("%s -- Using \"%s\" entry point.\n",
+				  __FUNCT__,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",
+				  __FUNCT__,argvm[isi]);
+		isi++;
+		imi++;
+	}
+
+	if (!mxIsNumeric(prhs[imi]) || (!mxIsEmpty(prhs[imi]) && !mxIsSparse(prhs[imi]))) {
+		mexPrintf("%s -- Adjacency matrix must be numeric and sparse.\n",__FUNCT__);
+		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",
+				  __FUNCT__,mxGetM(prhs[imi]),mxGetN(prhs[imi]),mxGetNzmax(prhs[imi]));
+	}
+	imi++;
+
+	if (!mxIsNumeric(prhs[imi])) {
+		mexPrintf("%s -- Vertex label vector must be numeric.\n",__FUNCT__);
+		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",
+				  __FUNCT__,mxGetM(prhs[imi]),mxGetN(prhs[imi]));
+	}
+	imi++;
+
+	if (!mxIsNumeric(prhs[imi])) {
+		mexPrintf("%s -- Vertex weight vector must be numeric.\n",__FUNCT__);
+		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",
+				  __FUNCT__,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",__FUNCT__);
+		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",
+				  __FUNCT__,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",__FUNCT__);
+			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",
+					  __FUNCT__,archtyp);
+		}
+		imi++;
+
+		if (!mxIsNumeric(prhs[imi])) {
+			mexPrintf("%s -- Architecture parameter vector must be numeric.\n",__FUNCT__);
+			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",
+					  __FUNCT__,mxGetM(prhs[imi]),mxGetN(prhs[imi]));
+		}
+		imi++;
+	}
+
+	while (imi < nrhs) {
+		if (!mxIsChar(prhs[imi])) {
+			mexPrintf("%s -- prhs[%d] must be character.\n",__FUNCT__,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",__FUNCT__,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/branches/trunk-jpl-damage/src/modules/Scotch/Scotch.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/modules/Scotch/Scotch.h	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/modules/Scotch/Scotch.h	(revision 12168)
@@ -0,0 +1,40 @@
+/*!\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/include/globals.h"
+#include "../../c/modules/modules.h"
+#include "../../c/Container/Container.h"
+#include "../../c/shared/shared.h"
+#include "../../c/issm-binding.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/branches/trunk-jpl-damage/src/modules/Shp2Kml/Shp2Kml.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/modules/Shp2Kml/Shp2Kml.cpp	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/modules/Shp2Kml/Shp2Kml.cpp	(revision 12168)
@@ -0,0 +1,100 @@
+/*\file Shp2Kml.c
+ *\brief: shp to kml file conversion mex module.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+#include "./Shp2Kml.h"
+
+void mexFunction( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]){
+
+	int i,verbose=1;
+
+	/*input: */
+	char    *filshp=NULL,*filkml=NULL;
+	int     sgn;
+	Options* options=NULL;
+	double   cm=0.,sp=0.;
+
+	/* output: */
+	int     iret=0;
+
+	#ifndef _HAVE_SHAPELIB_ //only works if shapelib library has been compiled in.
+	_error_(" Shapelib not available! Cannot carry out shp file translation!");
+	#endif
+
+	/*Boot module: */
+	MODULEBOOT();
+
+	/*checks on arguments on the matlab side: */
+	if (nlhs > NLHS) {
+		Shp2KmlUsage(); _error_("Shp2Kml usage error");
+	}
+	if (nrhs < NRHS) {
+		Shp2KmlUsage(); _error_("Shp2Kml usage error");
+	}
+
+	/*Input datasets: */
+	FetchData(&filshp,SHP_IN);
+	FetchData(&filkml,KML_IN);
+	FetchData(&sgn,SGN_IN);
+	FetchData(&options,NRHS,nrhs,prhs);
+
+	/*  defaults are in Xy2lldef, so don't duplicate them here, and only use user values if both have been specified  */
+	if (options->GetOption("central_meridian") || options->GetOption("standard_parallel")) {
+		options->Get(&cm,"central_meridian");
+		if (verbose) printf("  cm=%g\n",cm);
+		options->Get(&sp,"standard_parallel");
+		if (verbose) printf("  sp=%g\n",sp);
+	}
+
+	/*some checks*/
+	if (sgn < -1 || sgn > +1) _error_("Hemisphere sgn=%d must be +1 (north), -1 (south), or 0 (no translation).",sgn);
+	if (fabs(cm)      > 180.) _error_("Central meridian cm=%g must be between -180 (west) and +180 (east) degrees.",cm);
+	if (sp < 0. || sp >  90.) _error_("Standard parallel sp=%g must be between 0 and 90 degrees (in specified hemisphere).",sp);
+
+	/* Run core computations: */
+	if (options->GetOption("central_meridian") && options->GetOption("standard_parallel"))
+		iret=Shp2Kmlx(filshp,filkml,sgn,cm,sp);
+	else
+		iret=Shp2Kmlx(filshp,filkml,sgn);
+
+	/*Write data: */
+	WriteData(RET_OUT,iret);
+
+	/*Clean-up*/
+	delete options;
+	xfree((void**)&filkml);
+	xfree((void**)&filshp);
+
+	/*end module: */
+	MODULEEND();
+}
+
+void Shp2KmlUsage(void){
+	_printf_(true,"Shp2Kml - shp to kml file conversion module:\n");
+	_printf_(true,"\n");
+	_printf_(true,"   This module converts a file from shp to kml format.\n");
+	_printf_(true,"\n");
+	_printf_(true,"   Usage:\n");
+	_printf_(true,"      [ret]=Shp2Kml(filshp,filkml,sgn,'param name',param,...);\n");
+	_printf_(true,"\n");
+	_printf_(true,"      filshp      file name of shp file to be read (char, extension optional)\n");
+	_printf_(true,"      filkml      file name of kml file to be written (char)\n");
+	_printf_(true,"      sgn         sign for hemisphere (double, +1 (north); -1 (south); or 0 (no translation))\n");
+	_printf_(true,"\n");
+	_printf_(true,"      central_meridian     central meridian (double, optional, but must specify with sp)\n");
+	_printf_(true,"      standard_parallel    standard parallel (double, optional, but must specify with cm)\n");
+	_printf_(true,"\n");
+	_printf_(true,"      ret         return code (non-zero for warning)\n");
+	_printf_(true,"\n");
+	_printf_(true,"   Examples:\n");
+	_printf_(true,"      [ret]=Shp2Kml('file.shp','file.kml', 0);\n");
+	_printf_(true,"      [ret]=Shp2Kml('file.shp','file.kml', 1,'central_meridian',45,'standard_parallel',70);\n");
+	_printf_(true,"      [ret]=Shp2Kml('file.shp','file.kml',-1,'central_meridian', 0,'standard_parallel',71);\n");
+	_printf_(true,"\n");
+}
Index: /issm/branches/trunk-jpl-damage/src/modules/Shp2Kml/Shp2Kml.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/modules/Shp2Kml/Shp2Kml.h	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/modules/Shp2Kml/Shp2Kml.h	(revision 12168)
@@ -0,0 +1,36 @@
+/*!\file Shp2Kml.h
+ * \brief: prototype for shp to kml file conversion mex module.
+ */
+
+#ifndef _SHP2KML_H
+#define _SHP2KML_H
+
+/* local prototypes: */
+void Shp2KmlUsage(void);
+
+#include "../../c/include/globals.h"
+#include "../../c/modules/modules.h"
+#include "../../c/Container/Container.h"
+#include "../../c/shared/shared.h"
+#include "../../c/issm-binding.h"
+
+#undef __FUNCT__ 
+#define __FUNCT__  "Shp2Kml"
+
+
+/* serial input macros: */
+#define SHP_IN    prhs[0]
+#define KML_IN    prhs[1]
+#define SGN_IN    prhs[2]
+
+/* serial output macros: */
+#define RET_OUT    (mxArray**)&plhs[0]
+
+/* serial arg counts: */
+#undef NRHS
+#define NRHS  3
+#undef NLHS
+#define NLHS  1
+
+#endif
+
Index: /issm/branches/trunk-jpl-damage/src/modules/StringToEnum/StringToEnum.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/modules/StringToEnum/StringToEnum.cpp	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/modules/StringToEnum/StringToEnum.cpp	(revision 12168)
@@ -0,0 +1,32 @@
+/*\file StringToEnum.c
+ *\brief:convert enum (int) to string
+ */
+
+#include "./StringToEnum.h"
+
+void mexFunction( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]){
+
+	char    *name    = NULL;
+	int      enum_out;
+
+	/*checks on arguments on the matlab side: */
+	if(nrhs!=NRHS){
+		StringToEnumUsage(); _error_(" usage. See above");
+	}
+
+	/*Fetch inputs: */
+	FetchData(&name,NAME);
+
+	/*Run core function: */
+	enum_out=StringToEnumx(name);
+
+	/* output: */
+	WriteData(ENUMOUT,enum_out);
+}
+
+void StringToEnumUsage(void)
+{
+	_printf_(true,"\n");
+	_printf_(true,"   usage: %senum = StringToEnum(string);\n",__FUNCT__);
+	_printf_(true,"\n");
+}
Index: /issm/branches/trunk-jpl-damage/src/modules/StringToEnum/StringToEnum.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/modules/StringToEnum/StringToEnum.h	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/modules/StringToEnum/StringToEnum.h	(revision 12168)
@@ -0,0 +1,32 @@
+/*!\file:  StringToEnum.h
+ * \brief header file for StringToEnum module.
+ */ 
+
+#ifndef _STRINGTOENUM_H
+#define _STRINGTOENUM_H
+
+/* local prototypes: */
+void StringToEnumUsage(void);
+
+#include "../../c/include/globals.h"
+#include "../../c/modules/modules.h"
+#include "../../c/Container/Container.h"
+#include "../../c/shared/shared.h"
+#include "../../c/issm-binding.h"
+    
+/* serial input macros: */
+#define NAME (mxArray*)prhs[0]
+
+/* serial output macros: */
+#define ENUMOUT (mxArray**)&plhs[0]
+
+/* serial arg counts: */
+#undef NLHS
+#define NLHS  1
+#undef NRHS
+#define NRHS  1
+
+#undef __FUNCT__ 
+#define __FUNCT__  "StringToEnum"
+
+#endif  /* _TEST_H */
Index: /issm/branches/trunk-jpl-damage/src/modules/TriMesh/TriMesh.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/modules/TriMesh/TriMesh.cpp	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/modules/TriMesh/TriMesh.cpp	(revision 12168)
@@ -0,0 +1,73 @@
+/*
+ * TriMesh: mesh a domain using an .exp file
+ */
+
+#include "./TriMesh.h"
+
+WRAPPER(TriMesh){
+	
+	/* input: */
+	char   *domainname = NULL;
+	char   *riftsname  = NULL;
+	double  area;
+
+	/*intermediary: */
+	DataSet *domain = NULL;
+	DataSet *rifts  = NULL;
+
+	/* output: */
+	Matrix *index             = NULL;
+	Vector *x                 = NULL;
+	Vector *y                 = NULL;
+	Matrix *segments          = NULL;
+	Vector *segmentmarkerlist = NULL;
+
+	/*Boot module: */
+	MODULEBOOT();
+
+	/*checks on arguments: */
+	CHECKARGUMENTS(NLHS,NRHS,&TriMeshUsage);
+	
+	/*Fetch data needed for meshing: */
+	FetchData(&domainname,DOMAINOUTLINE);
+	FetchData(&riftsname,RIFTSOUTLINE);
+	FetchData(&area,AREA);
+
+	/*Read domain outline: */
+	domain = DomainOutlineRead(domainname);
+	rifts  = DomainOutlineRead(riftsname);
+
+	/*call x core: */
+	TriMeshx(&index,&x,&y,&segments,&segmentmarkerlist,domain,rifts,area);
+
+	/*write outputs: */
+	WriteData(INDEX,index);
+	WriteData(X,x);
+	WriteData(Y,y);
+	WriteData(SEGMENTS,segments);
+	WriteData(SEGMENTMARKERLIST,segmentmarkerlist);
+
+	/*free ressources: */
+	delete domain;
+	delete rifts;
+	xdelete_module(&index);
+	xdelete_module(&x);
+	xdelete_module(&y);
+	xdelete_module(&segments);
+	xdelete_module(&segmentmarkerlist);
+
+	/*end module: */
+	MODULEEND();
+}
+
+void TriMeshUsage(void) //{{{1
+{
+	printf("\n");
+	printf("   usage: [index,x,y,segments,segmentmarkers]=TriMesh(domainoutlinefilename,rifts,area) \n");
+	printf("      where: index,x,y defines a triangulation, segments is an array made \n");
+	printf("      of exterior segments to the mesh domain outline, segmentmarkers is an array flagging each segment, \n");
+	printf("      outlinefilename an Argus domain outline file, \n");
+	printf("      area is the maximum area desired for any element of the resulting mesh, \n");
+	printf("\n");
+}
+//}}}
Index: /issm/branches/trunk-jpl-damage/src/modules/TriMesh/TriMesh.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/modules/TriMesh/TriMesh.h	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/modules/TriMesh/TriMesh.h	(revision 12168)
@@ -0,0 +1,68 @@
+/*
+	TriMesh.h
+*/
+
+#ifndef _TRIMESH_H
+#define _TRIMESH_H
+
+#ifdef HAVE_CONFIG_H
+	#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+/*Very important definition in case we are compiling a python module!: needs to come before header files inclusion*/
+#ifdef _HAVE_PYTHON_
+#define PY_ARRAY_UNIQUE_SYMBOL PythonIOSymbol
+#endif
+
+/*Header files: */
+#include "../../c/include/globals.h"
+#include "../../c/toolkits/toolkits.h"
+#include "../../c/include/include.h"
+#include "../../c/modules/modules.h"
+#include "../../c/Container/Container.h"
+#include "../../c/shared/shared.h"
+#include "../../c/issm-binding.h"
+#include "../../c/io/io.h"
+#include "../../c/EnumDefinitions/EnumDefinitions.h"
+
+#ifdef _HAVE_MATLAB_MODULES_
+/* serial input macros: */
+#define DOMAINOUTLINE  (mxArray *)prhs[0]
+#define RIFTSOUTLINE   (mxArray *)prhs[1]
+#define AREA           (mxArray *)prhs[2]
+/* serial output macros: */
+#define INDEX             (mxArray**)&plhs[0]
+#define X                 (mxArray**)&plhs[1]
+#define Y                 (mxArray**)&plhs[2]
+#define SEGMENTS          (mxArray**)&plhs[3]
+#define SEGMENTMARKERLIST (mxArray**)&plhs[4]
+#endif
+
+#ifdef _HAVE_PYTHON_MODULES_
+/* serial input macros: */
+#define DOMAINOUTLINE PyTuple_GetItem(args,0)
+#define RIFTSOUTLINE  PyTuple_GetItem(args,1)
+#define AREA          PyTuple_GetItem(args,2)
+/* serial output macros: */
+#define INDEX             output,0
+#define X                 output,1
+#define Y                 output,2
+#define SEGMENTS          output,3
+#define SEGMENTMARKERLIST output,4
+#endif
+
+#undef __FUNCT__ 
+#define __FUNCT__  "TriMesh"
+
+/* serial arg counts: */
+#undef NLHS
+#define NLHS  5
+#undef NRHS
+#define NRHS  3
+
+/* local prototypes: */
+void TriMeshUsage(void);
+
+#endif  /* _TRIMESH_H */
Index: /issm/branches/trunk-jpl-damage/src/modules/TriMeshProcessRifts/TriMeshProcessRifts.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/modules/TriMeshProcessRifts/TriMeshProcessRifts.cpp	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/modules/TriMeshProcessRifts/TriMeshProcessRifts.cpp	(revision 12168)
@@ -0,0 +1,331 @@
+/*!\file:  TriMeshProcessRifts.cpp
+ * \brief split a mesh where a rift (or fault) is present
+ */ 
+
+#include "./TriMeshProcessRifts.h"
+
+void mexFunction(	int nlhs, mxArray* plhs[],
+					int nrhs, const mxArray* prhs[] ) {
+
+
+	/*Matlab arrays: */
+	mxArray* pmxa_array=NULL;
+	mxArray* pmxa_array2=NULL;
+	mxArray* pmxa_array3=NULL;
+	int i,j,k,counter;
+	
+	/* returned quantities: */
+	int      out_numrifts;
+	int*     out_riftsnumsegments=NULL;
+	double** out_riftssegments=NULL; 
+	int*     out_riftsnumpairs=NULL;
+	double** out_riftspairs=NULL;
+	double*  out_riftstips=NULL;
+	double** out_riftspenaltypairs=NULL;
+	int*     out_riftsnumpenaltypairs=NULL;
+
+	/*empty rifts structure: */
+	double* pNaN=NULL;
+	const	char*	fnames[10];
+	mwSize     ndim=2;
+	mwSize		dimensions[2] = {1,1};
+	double* pair=NULL;
+
+	
+	/* input: */
+	double* tindex_in=NULL;
+	double* index_in=NULL;
+	int     nel;
+	double* x_inm=NULL; //matlab vector
+	double* x_in=NULL; //copy of matlab vector
+	int     nods;
+	double* y_inm=NULL;//matlab vector
+	double* y_in=NULL;//copy of matlab vector
+	double* tsegments_in=NULL;
+	double* segments_in=NULL;
+	double* tsegmentmarkers_in=NULL;
+	double* segmentmarkers_in=NULL;
+
+	/* state: */
+	double* state=NULL;
+
+	int     num_seg;
+
+	/*rifts: */
+	int     riftflag;
+	int     numrifts;
+
+	/* verify correct usage: */
+	if (nlhs==0 && nrhs==0) {
+		/* special case: */
+		TriMeshProcessRiftsUsage();
+		return;
+	}
+	
+	if (!(  (nlhs==6) || (nrhs==5))){
+		mexPrintf("   %s format error.\n", __FUNCT__);
+		TriMeshProcessRiftsUsage();
+		printf("   ");
+		mexErrMsgTxt(" ");
+	}
+
+	/*Fetch index_in: */
+	if(mxIsDouble(prhs[0])){
+		nel=mxGetM(prhs[0]);
+		tindex_in=mxGetPr(prhs[0]);
+		index_in=(double*)xmalloc(nel*3*sizeof(double));
+		for (i=0;i<nel;i++){
+			for (j=0;j<3;j++){
+				*(index_in+3*i+j)=*(tindex_in+nel*j+i);
+			}
+		}
+	}
+	else{
+		printf("%s%s\n",__FUNCT__," error message: first argument should be the element list!");
+		mexErrMsgTxt(" ");
+	}
+
+	/*Fetch x_in: */
+	if(mxIsDouble(prhs[1])){
+		nods=mxGetM(prhs[1]);
+		x_inm=mxGetPr(prhs[1]);
+		x_in=(double*)xmalloc(nods*sizeof(double));
+		for (i=0;i<nods;i++){
+			x_in[i]=x_inm[i];
+		}
+	}
+	else{
+		printf("%s%s\n",__FUNCT__," error message: second argument should be the x corrdinate list!");
+		mexErrMsgTxt(" ");
+	}
+
+	/*Fetch y_in: */
+	if(mxIsDouble(prhs[2])){
+		y_inm=mxGetPr(prhs[2]);
+		y_in=(double*)xmalloc(nods*sizeof(double));
+		for (i=0;i<nods;i++){
+			y_in[i]=y_inm[i];
+		}
+	}
+	else{
+		printf("%s%s\n",__FUNCT__," error message: third argument should be the y corrdinate list!");
+		mexErrMsgTxt(" ");
+	}	
+
+	/*Fetch segments_in: */
+	if(mxIsDouble(prhs[3])){
+		num_seg=mxGetM(prhs[3]);
+		tsegments_in=mxGetPr(prhs[3]);
+		segments_in=(double*)xmalloc(num_seg*3*sizeof(double));
+		for (i=0;i<num_seg;i++){
+			for (j=0;j<3;j++){
+				*(segments_in+3*i+j)=*(tsegments_in+num_seg*j+i);
+			}
+		}
+	}
+	else{
+		printf("%s%s\n",__FUNCT__," error message: fourth argument should be the segments list!");
+		mexErrMsgTxt(" ");
+	}
+
+	/*Fetch segment markers: */
+	if(mxIsDouble(prhs[4])){
+		tsegmentmarkers_in=mxGetPr(prhs[4]);
+		segmentmarkers_in=(double*)xmalloc(num_seg*sizeof(double));
+		for (i=0;i<num_seg;i++){
+			segmentmarkers_in[i]=tsegmentmarkers_in[i];
+		}
+	}
+	else{
+		printf("%s%s\n",__FUNCT__," error message: fourth argument should be the segmentmarkers list!");
+		mexErrMsgTxt(" ");
+	}
+
+	/*
+	printf("Index: \n");
+	for (i=0;i<nel;i++){
+		for(j=0;j<3;j++){
+			printf("%lf ",*(index_in+3*i+j));
+		}
+		printf("\n");
+	}
+	printf("x,y: \n");
+	for (i=0;i<nods;i++){
+		printf("%16.16lf %16.16lf\n",x_in[i],y_in[i]);
+	}
+	printf("segments:\n");
+	for (i=0;i<num_seg;i++){
+		for(j=0;j<3;j++){
+			printf("%lf ",*(segments_in+3*i+j));
+		}
+		printf("%lf ",segmentmarkers_in[i]);
+		printf("\n");
+	}
+	*/
+
+	/*First, do some fixing on the existing mesh: we do not want any element belonging entirely to the segment list (ie: 
+	 *all the nodes of this element belong to the segments (tends to happen when there are corners: */
+	RemoveCornersFromRifts(&index_in,&nel,&x_in,&y_in,&nods,segments_in,segmentmarkers_in,num_seg);
+
+	/*Figure out if we have rifts, and how many: */
+	IsRiftPresent(&riftflag,&numrifts,segmentmarkers_in,num_seg);
+	
+	if(riftflag){	
+		SplitMeshForRifts(&nel,&index_in,&nods,&x_in,&y_in,&num_seg,&segments_in,&segmentmarkers_in);
+	}
+
+	/*Order segments so that their normals point outside the domain: */
+	OrderSegments(&segments_in,num_seg, index_in,nel);
+	
+	if(riftflag){
+		
+		/*We do not want to output segments mixed with rift segments: wring out the rifts from the segments, using the 
+		 *segmentmarkerlist:*/
+		SplitRiftSegments(&segments_in,&segmentmarkers_in,&num_seg,&out_numrifts,&out_riftsnumsegments,&out_riftssegments,numrifts,nods,nel);
+
+		/*Using rift segments, associate rift faces in pairs, each pair face representing opposite flanks of the rifts facing one another directly: */
+		PairRiftElements(&out_riftsnumpairs,&out_riftspairs,out_numrifts,out_riftsnumsegments,out_riftssegments,x_in,y_in);
+		
+		/*Order rifts so that they start from one tip, go to the other tip, and back: */
+		OrderRifts(&out_riftstips, out_riftssegments,out_riftspairs,numrifts,out_riftsnumsegments,x_in,y_in,nods,nel);
+
+		/*Create penalty pairs, used by Imp: */
+		PenaltyPairs(&out_riftspenaltypairs,&out_riftsnumpenaltypairs,numrifts,out_riftssegments,out_riftsnumsegments,out_riftspairs,out_riftstips,x_in,y_in);
+	}
+
+
+	/*Output : */
+	WriteData(&plhs[0],index_in,nel,3);
+	//pmxa_array= mxCreateDoubleMatrix(0,0,mxREAL);
+	//mxSetM(pmxa_array,3);
+	//mxSetN(pmxa_array,nel);
+	//mxSetPr(pmxa_array,index_in);
+	//mexCallMATLAB( 1, &plhs[0], 1, &pmxa_array, "transpose");
+
+	WriteData(&plhs[1],x_in,nods,1);
+	//pmxa_array= mxCreateDoubleMatrix(0,0,mxREAL);
+	//mxSetM(pmxa_array,1);
+	//mxSetN(pmxa_array,nods);
+	//mxSetPr(pmxa_array,x_in);
+	//mexCallMATLAB( 1, &plhs[1], 1, &pmxa_array, "transpose");
+
+	WriteData(&plhs[2],y_in,nods,1);
+	//pmxa_array= mxCreateDoubleMatrix(0,0,mxREAL);
+	//mxSetM(pmxa_array,1);
+	//mxSetN(pmxa_array,nods);
+	//mxSetPr(pmxa_array,y_in);
+	//mexCallMATLAB( 1, &plhs[2], 1, &pmxa_array, "transpose");
+
+	WriteData(&plhs[3],segments_in,num_seg,3);
+//pmxa_array= mxCreateDoubleMatrix(0,0,mxREAL);
+//mxSetM(pmxa_array,3);
+//mxSetN(pmxa_array,num_seg);
+//mxSetPr(pmxa_array,segments_in);
+//mexCallMATLAB( 1, &plhs[3], 1, &pmxa_array, "transpose");
+
+	WriteData(&plhs[4],segmentmarkers_in,num_seg,1);
+	//pmxa_array= mxCreateDoubleMatrix(0,0,mxREAL);
+	//mxSetM(pmxa_array,1);
+	//mxSetN(pmxa_array,num_seg);
+	//mxSetPr(pmxa_array,segmentmarkers_in);
+	//mexCallMATLAB( 1, &plhs[4], 1, &pmxa_array, "transpose");
+
+	if(riftflag){
+		/*Create a structure rifts where if i is a rift number, we have the following fields rifts(i).segments and rifts(i).numsegs: */
+
+		fnames[0] = "numsegs";
+		fnames[1] = "segments";
+		fnames[2] = "pairs";
+		fnames[3] = "tips";
+		fnames[4] = "penaltypairs";
+		fnames[5] = "fill";
+		fnames[6] = "friction";
+		fnames[7] = "fraction";
+		fnames[8] = "fractionincrement";
+		fnames[9] = "state";
+
+		dimensions[0]=out_numrifts;
+
+		pmxa_array=mxCreateStructArray( ndim,dimensions,10,fnames);
+		
+		for (i=0;i<out_numrifts;i++){
+
+			/*Segments: */
+			WriteData(&pmxa_array3,out_riftssegments[i],out_riftsnumsegments[i],3);
+			//pmxa_array2= mxCreateDoubleMatrix(0,0,mxREAL);
+			//mxSetM(pmxa_array2,3);
+			//mxSetN(pmxa_array2,out_riftsnumsegments[i]);
+			//mxSetPr(pmxa_array2,out_riftssegments[i]);
+			//mexCallMATLAB( 1, &pmxa_array3, 1, &pmxa_array2, "transpose");
+			mxSetField(pmxa_array,i,"segments",pmxa_array3);
+			mxSetField(pmxa_array,i,"numsegs",mxCreateDoubleScalar((double)out_riftsnumsegments[i]));
+
+			/*Element pairs: */
+			WriteData(&pmxa_array3,out_riftspairs[i],out_riftsnumpairs[i],2);
+			//pmxa_array2= mxCreateDoubleMatrix(0,0,mxREAL);
+			//mxSetM(pmxa_array2,2);
+			//mxSetN(pmxa_array2,out_riftsnumpairs[i]);
+			//mxSetPr(pmxa_array2,out_riftspairs[i]);
+			//mexCallMATLAB( 1, &pmxa_array3, 1, &pmxa_array2, "transpose");
+			mxSetField(pmxa_array,i,"pairs",pmxa_array3);
+
+			/*Tips: */
+			pmxa_array2= mxCreateDoubleMatrix(0,0,mxREAL);
+			mxSetM(pmxa_array2,1);
+			pair=(double*)mxMalloc(2*sizeof(double));
+			pair[0]=*(out_riftstips+2*i+0);
+			pair[1]=*(out_riftstips+2*i+1);
+			mxSetN(pmxa_array2,2);
+			mxSetPr(pmxa_array2,pair);
+			mxSetField(pmxa_array,i,"tips",pmxa_array2);
+
+			/*Penalty pairs: */
+			WriteData(&pmxa_array3,out_riftspenaltypairs[i],out_riftsnumpenaltypairs[i],7);
+			//pmxa_array2= mxCreateDoubleMatrix(0,0,mxREAL);
+			//mxSetM(pmxa_array2,7);
+			//mxSetN(pmxa_array2,out_riftsnumpenaltypairs[i]);
+			//mxSetPr(pmxa_array2,out_riftspenaltypairs[i]);
+			//mexCallMATLAB( 1, &pmxa_array3, 1, &pmxa_array2, "transpose");
+			mxSetField(pmxa_array,i,"penaltypairs",pmxa_array3);
+
+			/*Friction fraction, fractionincrement  and fill: */
+			mxSetField(pmxa_array,i,"friction",mxCreateDoubleScalar(0));
+			mxSetField(pmxa_array,i,"fill",mxCreateDoubleScalar(IceEnum)); //default is ice
+			mxSetField(pmxa_array,i,"fraction",mxCreateDoubleScalar(0)); //default is ice
+			mxSetField(pmxa_array,i,"fractionincrement",mxCreateDoubleScalar(0.1)); 
+
+			/*State: */
+			state=(double*)mxMalloc(out_riftsnumpenaltypairs[i]*sizeof(double));
+			for(j=0;j<out_riftsnumpenaltypairs[i];j++)state[j]=FreeEnum;
+			pmxa_array2= mxCreateDoubleMatrix(0,0,mxREAL);
+			mxSetM(pmxa_array2,1);
+			mxSetN(pmxa_array2,out_riftsnumpenaltypairs[i]);
+			mxSetPr(pmxa_array2,state);
+			mexCallMATLAB( 1, &pmxa_array3, 1, &pmxa_array2, "transpose");
+			
+			mxSetField(pmxa_array,i,"state",pmxa_array3);
+		}
+	}
+	else{
+		/*output NaN :*/
+		pNaN=(double*)mxMalloc(sizeof(double));
+		*pNaN=NAN;
+		pmxa_array= mxCreateDoubleMatrix(0,0,mxREAL);
+		mxSetM(pmxa_array,1);
+		mxSetN(pmxa_array,1);
+		mxSetPr(pmxa_array,pNaN);
+		
+	}
+	plhs[5]=pmxa_array;
+
+	return;
+}
+
+
+void TriMeshProcessRiftsUsage(void)
+{
+	printf("\n");
+	printf("   usage: [index2,x2,y2,segments2,segmentmarkers2,rifts2]=TriMeshProcessrifts(index1,x1,y1,segments1,segmentmarkers1) \n");
+	printf("      where: (index1,x1,y1,segments1,segmentmarkers1) is an initial triangulation.\n");
+	printf("      index2,x2,y2,segments2,segmentmarkers2,rifts2 is the resulting triangulation where rifts have been processed.\n");
+}
Index: /issm/branches/trunk-jpl-damage/src/modules/TriMeshProcessRifts/TriMeshProcessRifts.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/modules/TriMeshProcessRifts/TriMeshProcessRifts.h	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/modules/TriMeshProcessRifts/TriMeshProcessRifts.h	(revision 12168)
@@ -0,0 +1,23 @@
+/*!\file:  TriMeshProcessRifts.h
+ * \brief header prototype
+ */ 
+
+#ifndef _TRIMESH_PROCESSRIFTS_H_
+#define _TRIMESH_PROCESSRIFTS_H_
+
+#include "mex.h"
+#include "triangle.h"
+#include "string.h"
+
+#include "../../c/include/globals.h"
+#include "../../c/modules/modules.h"
+#include "../../c/Container/Container.h"
+#include "../../c/shared/shared.h"
+#include "../../c/issm-binding.h"
+#include "../../c/EnumDefinitions/EnumDefinitions.h"
+
+void TriMeshProcessRiftsUsage(void);
+#undef __FUNCT__ 
+#define __FUNCT__ "TriMeshProcessRifts"
+
+#endif
Index: /issm/branches/trunk-jpl-damage/src/modules/TriaSearch/TriaSearch.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/modules/TriaSearch/TriaSearch.cpp	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/modules/TriaSearch/TriaSearch.cpp	(revision 12168)
@@ -0,0 +1,66 @@
+/*\file TriaSearch.c
+ *\brief: TriaSearch module. See TriaSearchx for more details.
+ */
+#include "./TriaSearch.h"
+
+void mexFunction( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]){
+
+	int i;
+
+	/*input: */
+	double* index=NULL;
+	int     nel;
+	int     dummy;
+
+	double* x=NULL;
+	double* y=NULL;
+	int     nods;
+
+	double* x0=NULL;
+	double* y0=NULL;
+	int     numberofnodes;
+
+	/* output: */
+	double*  tria=NULL;
+
+	/*Boot module: */
+	MODULEBOOT();
+
+	/*checks on arguments on the matlab side: */
+	CheckNumMatlabArguments(nlhs,NLHS,nrhs,NRHS,__FUNCT__,&TriaSearchUsage);
+
+	/*Input datasets: */
+	FetchData(&index,&nel,&dummy,INDEXHANDLE);
+	FetchData(&x,&nods,XHANDLE);
+	FetchData(&y,&nods,YHANDLE);
+	FetchData(&x0,&numberofnodes,X0HANDLE);
+	FetchData(&y0,&numberofnodes,Y0HANDLE);
+
+	/* Echo: {{{1*/
+	//printf("(x0,y0)=(%g,%g)\n",x0,y0);
+	/*}}}*/
+
+	/* Run core computations: */
+	TriaSearchx(&tria,index,nel,x,y,nods,x0,y0,numberofnodes);
+
+	/* c to matlab: */
+	for(i=0;i<numberofnodes;i++)tria[i]++;
+
+	/*Write data: */
+	WriteData(TRIA,tria,numberofnodes);
+
+	/*end module: */
+	MODULEEND();
+}
+
+void TriaSearchUsage(void)
+{
+	_printf_(true,"TriaSearch- find triangle holding a point (x0,y0) in a mesh\n");
+	_printf_(true,"\n");
+	_printf_(true,"   Usage:\n");
+	_printf_(true,"         tria=TriaSearch(index,x,y,x0,y0);\n");
+	_printf_(true,"      index,x,y: mesh triangulatrion\n");
+	_printf_(true,"      x0,y0: coordinates of the point for which we are trying to find a triangle\n");
+	_printf_(true,"      x0,y0 can be an array of points\n");
+	_printf_(true,"\n");
+}
Index: /issm/branches/trunk-jpl-damage/src/modules/TriaSearch/TriaSearch.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/modules/TriaSearch/TriaSearch.h	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/modules/TriaSearch/TriaSearch.h	(revision 12168)
@@ -0,0 +1,37 @@
+/*!\file TriaSearch.h
+ */
+
+#ifndef _TRIASEARCH_H
+#define _TRIASEARCH_H
+
+/* local prototypes: */
+void TriaSearchUsage(void);
+
+#include "../../c/include/globals.h"
+#include "../../c/modules/modules.h"
+#include "../../c/Container/Container.h"
+#include "../../c/shared/shared.h"
+#include "../../c/issm-binding.h"
+
+#undef __FUNCT__ 
+#define __FUNCT__  "TriaSearch"
+
+
+/* serial input macros: */
+#define INDEXHANDLE prhs[0]
+#define XHANDLE prhs[1]
+#define YHANDLE prhs[2]
+#define X0HANDLE prhs[3]
+#define Y0HANDLE prhs[4]
+
+/* serial output macros: */
+#define TRIA (mxArray**)&plhs[0]
+
+/* serial arg counts: */
+#undef NLHS
+#define NLHS  1
+
+#undef NRHS
+#define NRHS  5
+
+#endif
Index: /issm/branches/trunk-jpl-damage/src/modules/Xy2ll/Xy2ll.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/modules/Xy2ll/Xy2ll.cpp	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/modules/Xy2ll/Xy2ll.cpp	(revision 12168)
@@ -0,0 +1,98 @@
+/*\file Xy2ll.c
+ *\brief: x/y to lat/long coordinate mex module.
+ */
+#include "./Xy2ll.h"
+
+void mexFunction( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]){
+
+	int i,verbose=1;
+
+	/*input: */
+	double  *x=NULL,*y=NULL;
+	int     nx,ny,ncoord;
+	int     sgn;
+	Options* options=NULL;
+	double   cm=0.,sp=0.;
+
+	/* output: */
+	double  *lat=NULL,*lon=NULL;
+	int     iret=0;
+
+	/*Boot module: */
+	MODULEBOOT();
+
+	/*checks on arguments on the matlab side: */
+	if (nlhs > NLHS) {
+		Xy2llUsage(); _error_("Xy2ll usage error");
+	}
+	if (nrhs < NRHS) {
+		Xy2llUsage(); _error_("Xy2ll usage error");
+	}
+
+	/*Input datasets: */
+	FetchData(&x,&nx,X_IN);
+	FetchData(&y,&ny,Y_IN);
+	FetchData(&sgn,SGN_IN);
+	FetchData(&options,NRHS,nrhs,prhs);
+
+	/*  defaults are in Xy2lldef, so don't duplicate them here, and only use user values if both have been specified  */
+	if (options->GetOption("central_meridian") || options->GetOption("standard_parallel")) {
+		options->Get(&cm,"central_meridian");
+		if (verbose) printf("  cm=%g\n",cm);
+		options->Get(&sp,"standard_parallel");
+		if (verbose) printf("  sp=%g\n",sp);
+	}
+
+	/*some checks*/
+	if   (nx != ny) _error_("Must have same number of x[%d] and y[%d] coordinates.",nx,ny);
+	else            ncoord=nx;
+	if (sgn != +1 && sgn != -1) _error_("Hemisphere sgn=%d must be +1 (north) or -1 (south).",sgn);
+	if (fabs(cm)      > 180.) _error_("Central meridian cm=%g must be between -180 (west) and +180 (east) degrees.",cm);
+	if (sp < 0. || sp >  90.) _error_("Standard parallel sp=%g must be between 0 and 90 degrees (in specified hemisphere).",sp);
+
+	lat=(double*)mxMalloc(ncoord*sizeof(double));
+	lon=(double*)mxMalloc(ncoord*sizeof(double));
+
+	/* Run core computations: */
+	if (verbose) printf("Calling core:\n");
+	if (options->GetOption("central_meridian") && options->GetOption("standard_parallel"))
+		iret=Xy2llx(lat,lon,x,y,ncoord,sgn,cm,sp);
+	else
+		iret=Xy2llx(lat,lon,x,y,ncoord,sgn);
+
+	/*Write data: */
+	WriteData(LAT_OUT,lat,ncoord);
+	WriteData(LON_OUT,lon,ncoord);
+
+	/*Clean-up*/
+	delete options;
+
+	/*end module: */
+	MODULEEND();
+}
+
+void Xy2llUsage(void){
+	_printf_(true,"Xy2ll - x/y to lat/long coordinate transformation module:\n");
+	_printf_(true,"\n");
+	_printf_(true,"   This module transforms x/y to lat/long coordinates.\n");
+	_printf_(true,"\n");
+	_printf_(true,"   Usage:\n");
+	_printf_(true,"      [lat,lon]=Xy2ll(x,y,sgn,'param name',param,...);\n");
+	_printf_(true,"\n");
+	_printf_(true,"      x           x coordinates (double vector)\n");
+	_printf_(true,"      y           y coordinates (double vector)\n");
+	_printf_(true,"      sgn         sign for hemisphere (double, +1 (north) or -1 (south))\n");
+	_printf_(true,"\n");
+	_printf_(true,"      central_meridian     central meridian (double, optional, but must specify with sp)\n");
+	_printf_(true,"      standard_parallel    standard parallel (double, optional, but must specify with cm)\n");
+	_printf_(true,"\n");
+	_printf_(true,"      lat         latitude coordinates (double vector)\n");
+	_printf_(true,"      lon         longitude coordinates (double vector)\n");
+	_printf_(true,"\n");
+	_printf_(true,"   Examples:\n");
+	_printf_(true,"      [lat,lon]=Xy2ll(x,y, 1);\n");
+	_printf_(true,"      [lat,lon]=Xy2ll(x,y, 1,'central_meridian',45,'standard_parallel',70);\n");
+	_printf_(true,"      [lat,lon]=Xy2ll(x,y,-1,'central_meridian', 0,'standard_parallel',71);\n");
+	_printf_(true,"\n");
+}
+
Index: /issm/branches/trunk-jpl-damage/src/modules/Xy2ll/Xy2ll.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/modules/Xy2ll/Xy2ll.h	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/modules/Xy2ll/Xy2ll.h	(revision 12168)
@@ -0,0 +1,37 @@
+/*!\file Xy2ll.h
+ * \brief: prototype for x/y to lat/long coordinate mex module.
+ */
+
+#ifndef _XY2LL_H
+#define _XY2LL_H
+
+/* local prototypes: */
+void Xy2llUsage(void);
+
+#include "../../c/include/globals.h"
+#include "../../c/modules/modules.h"
+#include "../../c/Container/Container.h"
+#include "../../c/shared/shared.h"
+#include "../../c/issm-binding.h"
+
+#undef __FUNCT__ 
+#define __FUNCT__  "Xy2ll"
+
+
+/* serial input macros: */
+#define X_IN      prhs[0]
+#define Y_IN      prhs[1]
+#define SGN_IN    prhs[2]
+
+/* serial output macros: */
+#define LAT_OUT    (mxArray**)&plhs[0]
+#define LON_OUT    (mxArray**)&plhs[1]
+
+/* serial arg counts: */
+#undef NRHS
+#define NRHS  3
+#undef NLHS
+#define NLHS  2
+
+#endif
+
Index: /issm/branches/trunk-jpl-damage/src/modules/matlab/Makefile.am
===================================================================
--- /issm/branches/trunk-jpl-damage/src/modules/matlab/Makefile.am	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/modules/matlab/Makefile.am	(revision 12168)
@@ -0,0 +1,163 @@
+INCLUDES = @MATLABINCL@ @PETSCINCL@ @MPIINCL@ @METISINCL@ @TRIANGLEINCL@ @CHACOINCL@ @SCOTCHINCL@ @SHAPELIBINCL@ @BOOSTINCL@ @PYTHONINCL@ @PYTHON_NUMPYINCL@
+EXEEXT=$(MATLABWRAPPEREXT)
+#Bin programs {{{1
+if MODULES
+bin_PROGRAMS =  AverageFilter\
+				BamgMesher\
+				BamgConvertMesh\
+				BamgTriangulate\
+				Chaco\
+				ContourToMesh \
+				ContourToNodes \
+				ElementConnectivity\
+				EnumToString\
+				Exp2Kml \
+				HoleFiller \
+				InternalFront\
+				InterpFromGridToMesh \
+				InterpFromMeshToMesh2d \
+				InterpFromMeshToMesh3d \
+				InterpFromMeshToGrid \
+				InterpFromMesh2d \
+				KMLFileRead \
+				KMLMeshWrite \
+				KMLOverlay \
+				Kml2Exp \
+				Kriging \
+				Ll2xy \
+				NodeConnectivity \
+				MeshPartition\
+				MeshProfileIntersection\
+				PointCloudFindNeighbors\
+				PropagateFlagsFromConnectivity\
+				Scotch\
+				Shp2Kml\
+				StringToEnum\
+				TriaSearch\
+				TriMesh\
+				TriMeshProcessRifts\
+				Xy2ll
+endif 
+#}}}
+#Flags and libraries {{{1
+LDADD = ../../c/libISSMCore.a ../../c/libISSMModules.a $(TRIANGLELIB) $(PETSCLIB) $(FLIBS) $(PLAPACKLIB) $(MUMPSLIB) $(SCALAPACKLIB) $(BLACSLIB) $(HYPRELIB) $(MLLIB) $(DAKOTALIB) $(METISLIB) $(CHACOLIB) $(SCOTCHLIB) $(BLASLAPACKLIB) $(MPILIB) $(MATHLIB) $(FORTRANLIB) $(GRAPHICSLIB) $(MULTITHREADINGLIB) $(SHAPELIBLIB) $(GSLLIB)
+
+#Triangle library
+AM_CXXFLAGS =  -DTRILIBRARY -DANSI_DECLARATORS -DNO_TIMER
+
+#Matlab part
+AM_LDFLAGS   = $(MEXLINK)
+AM_CXXFLAGS +=  -D_HAVE_MATLAB_MODULES_ -D_GNU_SOURCE -fPIC -fno-omit-frame-pointer -pthread 
+LDADD       += $(MEXLIB) ../../c/libISSMMatlab.a 
+
+LDADD       += ../../c/libISSMCore.a ../../c/libISSMModules.a 
+
+#Optimization flags:
+AM_CXXFLAGS += $(CXXOPTFLAGS) 
+#}}}
+#Bin sources {{{1
+AverageFilter_SOURCES = ../AverageFilter/AverageFilter.cpp\
+			  ../AverageFilter/AverageFilter.h
+
+BamgMesher_SOURCES = ../BamgMesher/BamgMesher.cpp\
+					../BamgMesher/BamgMesher.h
+
+BamgConvertMesh_SOURCES = ../BamgConvertMesh/BamgConvertMesh.cpp\
+					../BamgConvertMesh/BamgConvertMesh.h
+
+BamgTriangulate_SOURCES = ../BamgTriangulate/BamgTriangulate.cpp\
+								  ../BamgTriangulate/BamgTriangulate.h
+
+Chaco_SOURCES = ../Chaco/Chaco.cpp\
+					../Chaco/Chaco.h
+
+ContourToMesh_SOURCES = ../ContourToMesh/ContourToMesh.cpp\
+			  ../ContourToMesh/ContourToMesh.h
+
+ContourToNodes_SOURCES = ../ContourToNodes/ContourToNodes.cpp\
+			  ../ContourToNodes/ContourToNodes.h
+
+ElementConnectivity_SOURCES = ../ElementConnectivity/ElementConnectivity.cpp\
+			  ../ElementConnectivity/ElementConnectivity.h
+
+EnumToString_SOURCES = ../EnumToString/EnumToString.cpp\
+			  ../EnumToString/EnumToString.h
+
+StringToEnum_SOURCES = ../StringToEnum/StringToEnum.cpp\
+			  ../StringToEnum/StringToEnum.h
+
+HoleFiller_SOURCES = ../HoleFiller/HoleFiller.cpp\
+			  ../HoleFiller/HoleFiller.h
+
+InternalFront_SOURCES = ../InternalFront/InternalFront.cpp\
+										 ../InternalFront/InternalFront.h
+
+InterpFromGridToMesh_SOURCES = ../InterpFromGridToMesh/InterpFromGridToMesh.cpp\
+			  ../InterpFromGridToMesh/InterpFromGridToMesh.h
+
+InterpFromMeshToMesh2d_SOURCES = ../InterpFromMeshToMesh2d/InterpFromMeshToMesh2d.cpp\
+							../InterpFromMeshToMesh2d/InterpFromMeshToMesh2d.h
+
+InterpFromMeshToMesh3d_SOURCES = ../InterpFromMeshToMesh3d/InterpFromMeshToMesh3d.cpp\
+									../InterpFromMeshToMesh3d/InterpFromMeshToMesh3d.h
+
+InterpFromMeshToGrid_SOURCES = ../InterpFromMeshToGrid/InterpFromMeshToGrid.cpp\
+									../InterpFromMeshToGrid/InterpFromMeshToGrid.h
+
+InterpFromMesh2d_SOURCES = ../InterpFromMesh2d/InterpFromMesh2d.cpp\
+									../InterpFromMesh2d/InterpFromMesh2d.h
+
+KMLFileRead_SOURCES = ../KMLFileRead/KMLFileRead.cpp\
+			  ../KMLFileRead/KMLFileRead.h
+
+KMLMeshWrite_SOURCES = ../KMLMeshWrite/KMLMeshWrite.cpp\
+			  ../KMLMeshWrite/KMLMeshWrite.h
+
+KMLOverlay_SOURCES = ../KMLOverlay/KMLOverlay.cpp\
+			  ../KMLOverlay/KMLOverlay.h
+
+Xy2ll_SOURCES = ../Xy2ll/Xy2ll.cpp\
+			  ../Xy2ll/Xy2ll.h
+
+Ll2xy_SOURCES = ../Ll2xy/Ll2xy.cpp\
+			  ../Ll2xy/Ll2xy.h
+
+Exp2Kml_SOURCES = ../Exp2Kml/Exp2Kml.cpp\
+			  ../Exp2Kml/Exp2Kml.h
+
+Kml2Exp_SOURCES = ../Kml2Exp/Kml2Exp.cpp\
+			  ../Kml2Exp/Kml2Exp.h
+
+Kriging_SOURCES = ../Kriging/Kriging.cpp\
+						../Kriging/Kriging.h
+
+MeshPartition_SOURCES = ../MeshPartition/MeshPartition.cpp\
+			  ../MeshPartition/MeshPartition.h
+
+MeshProfileIntersection_SOURCES = ../MeshProfileIntersection/MeshProfileIntersection.cpp\
+			  ../MeshProfileIntersection/MeshProfileIntersection.h
+
+NodeConnectivity_SOURCES = ../NodeConnectivity/NodeConnectivity.cpp\
+										../NodeConnectivity/NodeConnectivity.h
+
+PointCloudFindNeighbors_SOURCES = ../PointCloudFindNeighbors/PointCloudFindNeighbors.cpp\
+			  ../PointCloudFindNeighbors/PointCloudFindNeighbors.h
+
+PropagateFlagsFromConnectivity_SOURCES = ../PropagateFlagsFromConnectivity/PropagateFlagsFromConnectivity.cpp\
+			  ../PropagateFlagsFromConnectivity/PropagateFlagsFromConnectivity.h
+
+Scotch_SOURCES = ../Scotch/Scotch.cpp\
+			  ../Scotch/Scotch.h
+
+Shp2Kml_SOURCES = ../Shp2Kml/Shp2Kml.cpp\
+			  ../Shp2Kml/Shp2Kml.h
+
+TriaSearch_SOURCES = ../TriaSearch/TriaSearch.cpp\
+			  ../TriaSearch/TriaSearch.h
+
+TriMesh_SOURCES = ../TriMesh/TriMesh.cpp\
+			  ../TriMesh/TriMesh.h
+
+TriMeshProcessRifts_SOURCES = ../TriMeshProcessRifts/TriMeshProcessRifts.cpp\
+			  ../TriMeshProcessRifts/TriMeshProcessRifts.h
+#}}}
Index: /issm/branches/trunk-jpl-damage/src/modules/python/Makefile.am
===================================================================
--- /issm/branches/trunk-jpl-damage/src/modules/python/Makefile.am	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/modules/python/Makefile.am	(revision 12168)
@@ -0,0 +1,42 @@
+INCLUDES = @MATLABINCL@ @PETSCINCL@ @MPIINCL@ @METISINCL@ @TRIANGLEINCL@ @CHACOINCL@ @SCOTCHINCL@ @SHAPELIBINCL@ @BOOSTINCL@ @PYTHONINCL@ @PYTHON_NUMPYINCL@
+EXEEXT=$(PYTHONWRAPPEREXT)
+#Bin programs {{{1
+if MODULES
+bin_PROGRAMS = ElementConnectivity\
+			   InterpFromMeshToMesh2d \
+			   NodeConnectivity\
+			   TriMesh 
+endif 
+#}}}
+#Flags and libraries {{{1
+LDADD = ../../c/libISSMCore.a ../../c/libISSMModules.a $(TRIANGLELIB) $(PETSCLIB) $(FLIBS) $(PLAPACKLIB) $(MUMPSLIB) $(SCALAPACKLIB) $(BLACSLIB) $(HYPRELIB) $(MLLIB) $(DAKOTALIB) $(METISLIB) $(CHACOLIB) $(SCOTCHLIB) $(BLASLAPACKLIB) $(MPILIB) $(MATHLIB) $(FORTRANLIB) $(GRAPHICSLIB) $(MULTITHREADINGLIB) $(SHAPELIBLIB) $(GSLLIB)
+
+#Triangle library
+AM_CXXFLAGS =  -DTRILIBRARY -DANSI_DECLARATORS -DNO_TIMER
+
+#Python part
+AM_LDFLAGS   = $(PYTHONLINK)
+AM_CXXFLAGS +=  -D_HAVE_PYTHON_MODULES_ 
+if PYTHON3
+AM_CXXFLAGS +=  -DNPY_NO_DEPRECATED_API 
+endif
+LDADD       += $(BOOSTLIB) $(PYTHONLIB) ../../c/libISSMPython.a
+
+LDADD       += ../../c/libISSMCore.a ../../c/libISSMModules.a 
+
+#Optimization flags:
+AM_CXXFLAGS += $(CXXOPTFLAGS) 
+#}}}
+#Bin sources {{{1
+ElementConnectivity_SOURCES = ../ElementConnectivity/ElementConnectivity.cpp\
+			  ../ElementConnectivity/ElementConnectivity.h
+
+InterpFromMeshToMesh2d_SOURCES = ../InterpFromMeshToMesh2d/InterpFromMeshToMesh2d.cpp\
+							../InterpFromMeshToMesh2d/InterpFromMeshToMesh2d.h
+
+NodeConnectivity_SOURCES = ../NodeConnectivity/NodeConnectivity.cpp\
+										../NodeConnectivity/NodeConnectivity.h
+
+TriMesh_SOURCES = ../TriMesh/TriMesh.cpp\
+			  ../TriMesh/TriMesh.h
+#}}}
Index: /issm/branches/trunk-jpl-damage/src/py/Makefile.am
===================================================================
--- /issm/branches/trunk-jpl-damage/src/py/Makefile.am	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/py/Makefile.am	(revision 12168)
@@ -0,0 +1,1 @@
+SUBDIRS = model
Index: /issm/branches/trunk-jpl-damage/src/py/model/Makefile.am
===================================================================
--- /issm/branches/trunk-jpl-damage/src/py/model/Makefile.am	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/py/model/Makefile.am	(revision 12168)
@@ -0,0 +1,11 @@
+bin_SCRIPTS = petscversion.py
+CLEANFILES = $(bin_SCRIPTS)
+
+if PYTHON3
+%.py : %.2.py
+	cp -f $< $@
+	2to3 -n -w  $@
+else
+%.py : %.2.py
+	ln -s -f $< $@
+endif
Index: sm/branches/trunk-jpl-damage/src/py/model/display/fielddisplay.rest
===================================================================
--- /issm/branches/trunk-jpl-damage/src/py/model/display/fielddisplay.rest	(revision 12167)
+++ 	(revision )
@@ -1,154 +1,0 @@
-def fielddisplay(md,name,comment):
-#FIELDDISPLAY - display model field
-#
-#   Usage:
-#      fielddisplay(md,offset,name,comment)
-
-	#get field
-	field=getattr(md,name)
-
-	#disp corresponding line as a function of field type (offset set as 9 spaces)
-	#parsedisplay('         ',name,field,comment);
-
-	return 
-
-function parsedisplay(offset,name,field,comment); %{{{
-
-	%string
-	if ischar(field),
-
-		if length(field)>30;
-			displayunit(offset,name,'not displayed',comment),
-		else
-			displayunit(offset,name,['''' field ''''],comment),
-		end
-
-	%numeric
-	elseif isnumeric(field)
-
-		%get size
-		fieldsize=size(field);
-
-		%double
-		if max(fieldsize)==1,
-			displayunit(offset,name,num2str(field),comment),
-		%matrix
-		else
-			displayunit(offset,name,['(' num2str(fieldsize(1)) 'x' num2str(fieldsize(2)) ')'],comment),
-		end
-
-	%logical
-	elseif islogical(field)
-
-		%get size
-		fieldsize=size(field);
-
-		%single value
-		if max(fieldsize)==1,
-			if (field)
-				displayunit(offset,name,'true',comment),
-			else
-				displayunit(offset,name,'false',comment),
-			end
-		%matrix
-		else
-			displayunit(offset,name,['(' num2str(fieldsize(1)) 'x' num2str(fieldsize(2)) ')'],comment),
-		end
-
-		%structure
-	elseif isstruct(field),
-		if ~isempty(fields(field))
-			displayunit(offset,name,'(structure)',comment),
-			struct_display(field,[offset '   ']),
-		else
-			displayunit(offset,name,'N/A',comment),
-		end
-
-	%cell
-	elseif iscell(field),
-		cell_display(offset,name,field,comment),
-
-	else
-		displayunit(offset,name,'not displayed',comment),
-
-	end
-end%}}}
-
-function struct_display(structure,offset) % {{{
-
-	structure_fields=fields(structure);
-
-	for i=1:length(structure_fields),
-
-		%get current field
-		field=structure.(structure_fields{i});
-
-		%recursive call if necessary
-		if isstruct(field),
-			displayunit(offset,structure_fields{i},'(structure)',''),
-			struct_display(field,[offset '   ']);
-
-		%display value
-		else
-			parsedisplay(offset,structure_fields{i},field,'');
-		end
-	end
-end% }}}
-function cell_display(offset,name,field,comment) % {{{
-
-	%initialization
-	string='{';
-
-	%go through the cell and fill string
-	if length(field)<5;
-		for i=1:length(field),
-			if ischar(field{i}),
-				string=[string ''''  field{i} ''','];
-			elseif (isnumeric(field{i}) & length(field{i})==1)
-				string=[string num2str(field{i}) ',' ];
-			else
-				string='{';
-				break
-			end
-		end
-	end
-	if strcmp(string,'{'),
-		string=['(' num2str(size(field,1)) 'x' num2str(size(field,2)) ')'];
-	else
-		string=[string(1:end-1) '}'];
-	end
-
-	%call displayunit
-	displayunit(offset,name,string,comment);
-end% }}}
-function displayunit(offset,name,characterization,comment),% {{{
-
-	%take care of name
-	if length(name)>23,
-		name=[name(1:20) '...'];
-	end
-
-	%take care of characterization
-	if (strcmp(characterization,['''' '''']) | strcmp(characterization,'NaN')),
-		characterization='N/A';
-	end
-	if length(characterization)>15,
-		characterization=[characterization(1:12) '...'];
-	end
-
-	%print
-	if isempty(comment)
-		disp(sprintf('%s%-23s: %-15s',offset,name,characterization));
-	else
-		if ischar(comment),
-			disp(sprintf('%s%-23s: %-15s -- %s',offset,name,characterization,comment));
-		elseif iscell(comment),
-			disp(sprintf('%s%-23s: %-15s -- %s',offset,name,characterization,comment{1}));
-			for i=2:length(comment),
-				disp(sprintf('%s%-23s  %-15s    %s',offset,'','',comment{i}));
-			end
-		else
-			error('fielddisplay error message: format for comment not supportet yet');
-		end
-	end
-end% }}}
Index: /issm/branches/trunk-jpl-damage/src/py/model/petscversion.2.py
===================================================================
--- /issm/branches/trunk-jpl-damage/src/py/model/petscversion.2.py	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/src/py/model/petscversion.2.py	(revision 12168)
@@ -0,0 +1,39 @@
+#PETSCVERSION - recover petsc version number, inside config.h file
+#
+#   Usage:
+#       PETSC_VERSION=petscversion();
+
+#Module imports {{{
+import os
+import sys
+from issmtier import *
+#}}}
+
+def petscversion():
+
+	#default
+	PETSC_VERSION=3;
+	
+	configfile=issmtier() + "/bin/config.h" #should find it in the install target
+	
+	if not os.path.isfile(configfile):
+		raise RuntimeError("%s%s%s"%("File ",configfile," not found. ISSM has not been configured yet!"))
+
+	#go through the file, and recover the line we want
+	fid=open(configfile,'r');
+
+	tline=fid.readline()
+	while tline:
+
+		if tline=='': 
+			break
+		
+		if tline[0:21]=="#define _PETSC_MAJOR_":
+			PETSC_VERSION=int(tline[22])
+			break
+		
+		tline=fid.readline()
+	
+	fid.close();
+
+	return PETSC_VERSION
Index: sm/branches/trunk-jpl-damage/src/py/model/petscversion.py
===================================================================
--- /issm/branches/trunk-jpl-damage/src/py/model/petscversion.py	(revision 12167)
+++ 	(revision )
@@ -1,39 +1,0 @@
-#PETSCVERSION - recover petsc version number, inside config.h file
-#
-#   Usage:
-#       PETSC_VERSION=petscversion();
-
-#Module imports {{{
-import os
-import sys
-from issmtier import *
-#}}}
-
-def petscversion():
-
-	#default
-	PETSC_VERSION=3;
-	
-	configfile=issmtier() + "/bin/config.h" #should find it in the install target
-	
-	if not os.path.isfile(configfile):
-		raise RuntimeError("%s%s%s"%("File ",configfile," not found. ISSM has not been configured yet!"))
-
-	#go through the file, and recover the line we want
-	fid=open(configfile,'r');
-
-	tline=fid.readline()
-	while tline:
-
-		if tline=='': 
-			break
-		
-		if tline[0:21]=="#define _PETSC_MAJOR_":
-			PETSC_VERSION=int(tline[22])
-			break
-		
-		tline=fid.readline()
-	
-	fid.close();
-
-	return PETSC_VERSION
Index: /issm/branches/trunk-jpl-damage/startup.m
===================================================================
--- /issm/branches/trunk-jpl-damage/startup.m	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/startup.m	(revision 12168)
@@ -11,35 +11,35 @@
 lastwarn(''); 
 
-%Recover ISSM_TIER , or if on a Windows machine, ISSM_TIER_WIN
+%Recover ISSM_DIR , or if on a Windows machine, ISSM_DIR_WIN
 if ~ispc,
-	ISSM_TIER=getenv('ISSM_TIER');
+	ISSM_DIR=getenv('ISSM_DIR');
 else
-	ISSM_TIER=getenv('ISSM_TIER_WIN');
-	%ISSM_TIER='';
+	ISSM_DIR=getenv('ISSM_DIR_WIN');
+	%ISSM_DIR='';
 end
-if (isempty(ISSM_TIER)),
-	error('''ISSM_TIER'' environment variable is empty! You should define ISSM_TIER in your .cshrc or .bashrc!');
+if (isempty(ISSM_DIR)),
+	error('''ISSM_DIR'' environment variable is empty! You should define ISSM_DIR in your .cshrc or .bashrc!');
 end
 
 %Now add all issm code paths necessary to run issm smoothly. 
 %We capture the error output, so that we can warn the user to update 
-%the variable ISSM_TIER in this file, in case it is not correctly setup. 
+%the variable ISSM_DIR in this file, in case it is not correctly setup. 
 
 %ISSM path
-addpath([ISSM_TIER '/src/m/utils/']); %loads recursivepath
-addpath([ISSM_TIER '/bin']);
-addpath(recursivepath([ISSM_TIER '/src/m']));
-addpath(recursivepath([ISSM_TIER '/externalpackages/scotch']));
-addpath(recursivepath([ISSM_TIER '/externalpackages/canos']));
-addpath(recursivepath([ISSM_TIER '/externalpackages/kml']));
-addpath(recursivepath([ISSM_TIER '/externalpackages/export_fig']));
-addpath(recursivepath([ISSM_TIER '/externalpackages/googleearthtoolbox']));
-addpath(recursivepath([ISSM_TIER '/externalpackages/cm_and_cb_utilities']));
+addpath([ISSM_DIR '/src/m/utils/']); %loads recursivepath
+addpath([ISSM_DIR '/bin']);
+addpath(recursivepath([ISSM_DIR '/src/m']));
+addpath(recursivepath([ISSM_DIR '/externalpackages/scotch']));
+addpath(recursivepath([ISSM_DIR '/externalpackages/canos']));
+addpath(recursivepath([ISSM_DIR '/externalpackages/kml']));
+addpath(recursivepath([ISSM_DIR '/externalpackages/export_fig']));
+addpath(recursivepath([ISSM_DIR '/externalpackages/googleearthtoolbox']));
+addpath(recursivepath([ISSM_DIR '/externalpackages/cm_and_cb_utilities']));
 
-clear ISSM_TIER;
+clear ISSM_DIR;
 
 %Check on any warning messages that might indicate that the paths were not correct. 
 if ~isempty(lastwarn),
-	fprintf('\n  Error trying to setup ''ISSM'' code paths. Try and update the ISSM_TIER variable in your .cshrc or .bashrc!\n');
+	fprintf('\n  Error trying to setup ''ISSM'' code paths. Try and update the ISSM_DIR variable in your .cshrc or .bashrc!\n');
 	fprintf('  ''ISSM'' will not  work at all until this is resolved\n\n');
 else
Index: /issm/branches/trunk-jpl-damage/startup.py
===================================================================
--- /issm/branches/trunk-jpl-damage/startup.py	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/startup.py	(revision 12168)
@@ -5,27 +5,30 @@
 #  before handing over the prompt to the user if the environment variable
 #  PYTHONSTARTUP is defined:
-#  export PYTHONSTARTUP=$ISSM_TIER/startup.py
+#  export PYTHONSTARTUP=$ISSM_DIR/startup.py
 #  This startup script should be run by users before trying to use ISSM.
 
 import os,sys
 
- 
-#First check we are running python 3 at least 
-if sys.version_info[0] < 3:
-	print("ISSM can only work in Python 3. Exiting python")
-	sys.exit(1)
-
-#Recover ISSM_TIER, ISSM_DIR  and USERNAME
-ISSM_TIER=os.getenv('ISSM_TIER')
+#Recover ISSM_DIR and USERNAME
+ISSM_DIR=os.getenv('ISSM_DIR')
 USERNAME =os.getenv('USER')
-if(ISSM_TIER==None):
-	raise NameError('"ISSM_TIER" environment variable is empty! You should define ISSM_TIER in your .cshrc or .bashrc!')
+if(ISSM_DIR==None):
+	raise NameError('"ISSM_DIR" environment variable is empty! You should define ISSM_DIR in your .cshrc or .bashrc!')
 
 #Now add all issm code paths necessary to run issm smoothly. 
 #We capture the error output, so that we can warn the user to update 
-#the variable ISSM_TIER in this file, in case it is not correctly setup. 
+#the variable ISSM_DIR in this file, in case it is not correctly setup. 
 
 #ISSM path. Go through src/py and load everything we find  that looks like a python file
-for root,dirs,files in os.walk(ISSM_TIER+ '/src/py'):
+for root,dirs,files in os.walk(ISSM_DIR+ '/src/py'):
+	for file in files:
+		if file.find(".py") != -1:
+			if file.find(".pyc") == -1:
+				#add to path 
+				sys.path.append(root)
+				file=os.path.splitext(file)[0]
+				#__import__(file)
+
+for root,dirs,files in os.walk(ISSM_DIR+ '/src/m'):
 	for file in files:
 		if file.find(".py") != -1:
@@ -36,5 +39,5 @@
 				#__import__(file)
 				
-sys.path.append(ISSM_TIER + '/src/mex')
+sys.path.append(ISSM_DIR + '/src/modules/python')
 
 #Deal with scipy import: 
@@ -79,5 +82,6 @@
 from miscellaneous import *
 from private import *
-from TriMesh import *
+from triangle import *
+from setmask import *
 
 #}}}
Index: /issm/branches/trunk-jpl-damage/test/NightlyRun/runme.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/runme.m	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/test/NightlyRun/runme.m	(revision 12168)
@@ -30,6 +30,6 @@
 %      md=runme('id',102,'procedure','model');
 
-%Get ISSM_TIER variable
-ISSM_TIER=issmtier();
+%Get ISSM_DIR variable
+ISSM_DIR=issmdir();
 
 %Check inputs
@@ -168,5 +168,5 @@
 					message=getReport(me2);
 					if strcmpi(output,'nightly')
-						fid=fopen([ISSM_TIER '/nightlylog/matlaberror.log'], 'at');
+						fid=fopen([ISSM_DIR '/nightlylog/matlaberror.log'], 'at');
 						fprintf(fid,'%s',message);
 						fprintf(fid,'\n------------------------------------------------------------------\n');
@@ -174,5 +174,5 @@
 						disp(sprintf(['FAILURE difference: N/A test id: %i test name: %s field: %s'],id,id_string,fieldname));
 					elseif strcmpi(output,'daily');
-						fid=fopen([ISSM_TIER '/dailylog/matlaberror.log'], 'at');
+						fid=fopen([ISSM_DIR '/dailylog/matlaberror.log'], 'at');
 						fprintf(fid,'%s',message);
 						fprintf(fid,'\n------------------------------------------------------------------\n');
@@ -193,5 +193,5 @@
 		message=getReport(me);
 		if strcmpi(output,'nightly')
-			fid=fopen([ISSM_TIER '/nightlylog/matlaberror.log'], 'at');
+			fid=fopen([ISSM_DIR '/nightlylog/matlaberror.log'], 'at');
 			fprintf(fid,'%s',message);
 			fprintf(fid,'\n------------------------------------------------------------------\n');
@@ -199,5 +199,5 @@
 			disp(sprintf(['FAILURE difference: N/A test id: %i test name: %s field: %s'],id,id_string,'N/A'));
 		elseif strcmpi(output,'daily');
-			fid=fopen([ISSM_TIER '/dailylog/matlaberror.log'], 'at');
+			fid=fopen([ISSM_DIR '/dailylog/matlaberror.log'], 'at');
 			fprintf(fid,'%s',message);
 			fprintf(fid,'\n------------------------------------------------------------------\n');
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test101.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test101.m	(revision 12167)
+++ 	(revision )
@@ -1,16 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',150000);
-md=setmask(md,'all','');
-md=parameterize(md,'../Par/SquareShelfConstrained.par');
-md=setflowequation(md,'macayeal','all');
-md.cluster=none;
-md=solve(md,DiagnosticSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Vx','Vy','Vel','Pressure'};
-field_tolerances={1e-13,1e-13,1e-13,1e-13};
-field_values={...
-	(md.results.DiagnosticSolution.Vx),...
-	(md.results.DiagnosticSolution.Vy),...
-	(md.results.DiagnosticSolution.Vel),...
-	(md.results.DiagnosticSolution.Pressure),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test101.py
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test101.py	(revision 12167)
+++ 	(revision )
@@ -1,6 +1,0 @@
-from model import *
-from TriMesh import *
-
-md=model()
-[a,b,c,d,e]=TriMesh('../Exp/Square.exp',15000.0**2.0,True)
-print(a,b,c,d,e)
Index: /issm/branches/trunk-jpl-damage/test/NightlyRun/test102.py
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test102.py	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/test/NightlyRun/test102.py	(revision 12168)
@@ -0,0 +1,9 @@
+from model import *
+from triangle import *
+from setmask import *
+from parameterize import *
+
+md=model();
+md=triangle(md,'../Exp/Square.exp',50000);
+md=setmask(md,'all','');
+md=parameterize(md,'../Par/SquareShelfConstrained.py')
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test103.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test103.m	(revision 12167)
+++ 	(revision )
@@ -1,18 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',180000);
-md=setmask(md,'all','');
-md=parameterize(md,'../Par/SquareShelfConstrained.par');
-md=extrude(md,3,2);
-md=setflowequation(md,'macayeal','all');
-md.cluster=none;
-md=solve(md,DiagnosticSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Vx','Vy','Vz','Vel','Pressure'};
-field_tolerances={1e-13,1e-13,1e-13,1e-13,1e-13};
-field_values={...
-	(md.results.DiagnosticSolution.Vx),...
-	(md.results.DiagnosticSolution.Vy),...
-	(md.results.DiagnosticSolution.Vz),...
-	(md.results.DiagnosticSolution.Vel),...
-	(md.results.DiagnosticSolution.Pressure),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test105.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test105.m	(revision 12167)
+++ 	(revision )
@@ -1,18 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',180000);
-md=setmask(md,'all','');
-md=parameterize(md,'../Par/SquareShelfConstrained.par');
-md=extrude(md,3,2);
-md=setflowequation(md,'pattyn','all');
-md.cluster=none;
-md=solve(md,DiagnosticSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Vx','Vy','Vz','Vel','Pressure'};
-field_tolerances={1e-09,1e-09,1e-09,1e-09,1e-09};
-field_values={...
-	(md.results.DiagnosticSolution.Vx),...
-	(md.results.DiagnosticSolution.Vy),...
-	(md.results.DiagnosticSolution.Vz),...
-	(md.results.DiagnosticSolution.Vel),...
-	(md.results.DiagnosticSolution.Pressure),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test107.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test107.m	(revision 12167)
+++ 	(revision )
@@ -1,18 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',180000);
-md=setmask(md,'all','');
-md=parameterize(md,'../Par/SquareShelfConstrained.par');
-md=extrude(md,3,2);
-md.cluster=none;
-md=setflowequation(md,'stokes','all');
-md=solve(md,DiagnosticSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Vx','Vy','Vz','Vel','Pressure'};
-field_tolerances={1e-08,1e-08,1e-08,1e-08,1e-08};
-field_values={...
-	(md.results.DiagnosticSolution.Vx),...
-	(md.results.DiagnosticSolution.Vy),...
-	(md.results.DiagnosticSolution.Vz),...
-	(md.results.DiagnosticSolution.Vel),...
-	(md.results.DiagnosticSolution.Pressure),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test109.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test109.m	(revision 12167)
+++ 	(revision )
@@ -1,13 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',150000);
-md=setmask(md,'all','');
-md=parameterize(md,'../Par/SquareShelfConstrained.par');
-md=setflowequation(md,'macayeal','all');
-md.cluster=none;
-md=solve(md,PrognosticSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Thickness'};
-field_tolerances={1e-13};
-field_values={...
-	(md.results.PrognosticSolution.Thickness),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test111.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test111.m	(revision 12167)
+++ 	(revision )
@@ -1,16 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',150000);
-md=meshconvert(md);
-md=setmask(md,'all','');
-md=parameterize(md,'../Par/SquareShelfConstrained.par');
-md=setflowequation(md,'macayeal','all');
-md.cluster=none;
-md.prognostic.stabilization=3;
-md.prognostic.spcthickness=md.geometry.thickness;
-md=solve(md,PrognosticSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Thickness'};
-field_tolerances={1e-13};
-field_values={...
-	(md.results.PrognosticSolution.Thickness),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test113.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test113.m	(revision 12167)
+++ 	(revision )
@@ -1,14 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',150000);
-md=setmask(md,'all','');
-md=parameterize(md,'../Par/SquareShelfConstrained.par');
-md=setflowequation(md,'macayeal','all');
-md=extrude(md,5,3);
-md.cluster=none;
-md=solve(md,PrognosticSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Thickness'};
-field_tolerances={1e-13};
-field_values={...
-	(md.results.PrognosticSolution.Thickness),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test115.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test115.m	(revision 12167)
+++ 	(revision )
@@ -1,16 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',180000);
-md=setmask(md,'all','');
-md=parameterize(md,'../Par/SquareShelfConstrained.par');
-md=extrude(md,3,1);
-md=setflowequation(md,'macayeal','all');
-md.timestepping.time_step=0;
-md.cluster=none;
-md=solve(md,ThermalSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Temperature','BasalforcingsMeltingRate'};
-field_tolerances={1e-13,1e-13};
-field_values={...
-	(md.results.ThermalSolution.Temperature),...
-	(md.results.ThermalSolution.BasalforcingsMeltingRate),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test117.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test117.m	(revision 12167)
+++ 	(revision )
@@ -1,19 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',180000);
-md=setmask(md,'all','');
-md=parameterize(md,'../Par/SquareShelfConstrained.par');
-md=extrude(md,3,1);
-md=setflowequation(md,'macayeal','all');
-md.cluster=none;
-md.transient.isdiagnostic=0;
-md.transient.isprognostic=0;
-md.transient.isthermal=1;
-md.transient.isgroundingline=0;
-md=solve(md,TransientSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Temperature','BasalforcingsMeltingRate'};
-field_tolerances={1e-13,1e-13};
-field_values={...
-	(md.results.TransientSolution(1).Temperature),...
-	(md.results.TransientSolution(1).BasalforcingsMeltingRate),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test119.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test119.m	(revision 12167)
+++ 	(revision )
@@ -1,39 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',150000);
-md=setmask(md,'all','');
-md=parameterize(md,'../Par/SquareShelfConstrained.par');
-md=setflowequation(md,'macayeal','all');
-md.cluster=none;
-md=solve(md,TransientSolutionEnum);
-
-
-
-
-
-
-
-%Fields and tolerances to track changes
-field_names     ={'Vx1','Vy1','Vel1','Pressure1','Bed1','Surface1','Thickness1','Vx2','Vy2','Vel2','Pressure2','Bed2','Surface2','Thickness2','Vx3','Vy3','Vel3','Pressure3','Bed3','Surface3','Thickness3'};
-field_tolerances={1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13};
-field_values={...
-	(md.results.TransientSolution(1).Vx),...
-	(md.results.TransientSolution(1).Vy),...
-	(md.results.TransientSolution(1).Vel),...
-	(md.results.TransientSolution(1).Pressure),...
-	(md.results.TransientSolution(1).Bed),...
-	(md.results.TransientSolution(1).Surface),...
-	(md.results.TransientSolution(1).Thickness),...
-	(md.results.TransientSolution(2).Vx),...
-	(md.results.TransientSolution(2).Vy),...
-	(md.results.TransientSolution(2).Vel),...
-	(md.results.TransientSolution(2).Pressure),...
-	(md.results.TransientSolution(2).Bed),...
-	(md.results.TransientSolution(2).Surface),...
-	(md.results.TransientSolution(2).Thickness),...
-	(md.results.TransientSolution(3).Vx),...
-	(md.results.TransientSolution(3).Vy),...
-	(md.results.TransientSolution(3).Vel),...
-	(md.results.TransientSolution(3).Pressure),...
-	(md.results.TransientSolution(3).Bed),...
-	(md.results.TransientSolution(3).Surface),...
-	(md.results.TransientSolution(3).Thickness),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test121.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test121.m	(revision 12167)
+++ 	(revision )
@@ -1,45 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',200000);
-md=setmask(md,'all','');
-md=parameterize(md,'../Par/SquareShelfConstrained.par');
-md=extrude(md,3,1);
-md=setflowequation(md,'pattyn','all');
-md.cluster=none;
-md=solve(md,TransientSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Vx1','Vy1','Vz1','Vel1','Pressure1','Bed1','Surface1','Thickness1','Temperature1','BasalforcingsMeltingRate1', ...
-				      'Vx2','Vy2','Vz2','Vel2','Pressure2','Bed2','Surface2','Thickness2','Temperature2','BasalforcingsMeltingRate2', ...
-					   'Vx3','Vy3','Vz3','Vel3','Pressure3','Bed3','Surface3','Thickness3','Temperature3','BasalforcingsMeltingRate3'};
-field_tolerances={1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-05,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-05,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-05};
-field_values={...
-	(md.results.TransientSolution(1).Vx),...
-	(md.results.TransientSolution(1).Vy),...
-	(md.results.TransientSolution(1).Vz),...
-	(md.results.TransientSolution(1).Vel),...
-	(md.results.TransientSolution(1).Pressure),...
-	(md.results.TransientSolution(1).Bed),...
-	(md.results.TransientSolution(1).Surface),...
-	(md.results.TransientSolution(1).Thickness),...
-	(md.results.TransientSolution(1).Temperature),...
-	(md.results.TransientSolution(1).BasalforcingsMeltingRate),...
-	(md.results.TransientSolution(2).Vx),...
-	(md.results.TransientSolution(2).Vy),...
-	(md.results.TransientSolution(2).Vz),...
-	(md.results.TransientSolution(2).Vel),...
-	(md.results.TransientSolution(2).Pressure),...
-	(md.results.TransientSolution(2).Bed),...
-	(md.results.TransientSolution(2).Surface),...
-	(md.results.TransientSolution(2).Thickness),...
-	(md.results.TransientSolution(2).Temperature),...
-	(md.results.TransientSolution(2).BasalforcingsMeltingRate),...
-	(md.results.TransientSolution(3).Vx),...
-	(md.results.TransientSolution(3).Vy),...
-	(md.results.TransientSolution(3).Vz),...
-	(md.results.TransientSolution(3).Vel),...
-	(md.results.TransientSolution(3).Pressure),...
-	(md.results.TransientSolution(3).Bed),...
-	(md.results.TransientSolution(3).Surface),...
-	(md.results.TransientSolution(3).Thickness),...
-	(md.results.TransientSolution(3).Temperature),...
-	(md.results.TransientSolution(3).BasalforcingsMeltingRate),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test123.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test123.m	(revision 12167)
+++ 	(revision )
@@ -1,14 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',150000);
-md=setmask(md,'all','');
-md=parameterize(md,'../Par/SquareShelfConstrained.par');
-md=setflowequation(md,'macayeal','all');
-md.cluster=none;
-md=solve(md,SurfaceSlopeSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'SurfaceSlopeX','SurfaceSlopeY'};
-field_tolerances={1e-13,1e-13};
-field_values={...
-	(md.results.SurfaceSlopeSolution.SurfaceSlopeX),...
-	(md.results.SurfaceSlopeSolution.SurfaceSlopeY),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test125.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test125.m	(revision 12167)
+++ 	(revision )
@@ -1,15 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',150000);
-md=setmask(md,'all','');
-md=parameterize(md,'../Par/SquareShelfConstrained.par');
-md=extrude(md,5,1);
-md=setflowequation(md,'macayeal','all');
-md.cluster=none;
-md=solve(md,SurfaceSlopeSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'SurfaceSlopeX','SurfaceSlopeY'};
-field_tolerances={1e-13,1e-13};
-field_values={...
-	(md.results.SurfaceSlopeSolution.SurfaceSlopeX),...
-	(md.results.SurfaceSlopeSolution.SurfaceSlopeY),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test127.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test127.m	(revision 12167)
+++ 	(revision )
@@ -1,14 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',150000);
-md=setmask(md,'all','');
-md=parameterize(md,'../Par/SquareShelfConstrained.par');
-md=setflowequation(md,'macayeal','all');
-md.cluster=none;
-md=solve(md,BedSlopeSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'BedSlopeX','BedSlopeY'};
-field_tolerances={1e-13,1e-13};
-field_values={...
-	(md.results.BedSlopeSolution.BedSlopeX),...
-	(md.results.BedSlopeSolution.BedSlopeY),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test129.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test129.m	(revision 12167)
+++ 	(revision )
@@ -1,15 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',150000);
-md=setmask(md,'all','');
-md=parameterize(md,'../Par/SquareShelfConstrained.par');
-md=extrude(md,5,1);
-md=setflowequation(md,'macayeal','all');
-md.cluster=none;
-md=solve(md,BedSlopeSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'BedSlopeX','BedSlopeY'};
-field_tolerances={1e-13,1e-13};
-field_values={...
-	(md.results.BedSlopeSolution.BedSlopeX),...
-	(md.results.BedSlopeSolution.BedSlopeY),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test131.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test131.m	(revision 12167)
+++ 	(revision )
@@ -1,16 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',150000);
-md=setmask(md,'all','');
-md=parameterize(md,'../Par/SquareShelfConstrained.par');
-%Add boundary conditions on thickness on the border
-pos=find(md.mesh.vertexonboundary);
-md.balancethickness.spcthickness(pos)=md.geometry.thickness(pos);
-md=setflowequation(md,'macayeal','all');
-md.cluster=none;
-md=solve(md,BalancethicknessSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Thickness'};
-field_tolerances={1e-13};
-field_values={...
-	(md.results.BalancethicknessSolution.Thickness),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test133.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test133.m	(revision 12167)
+++ 	(revision )
@@ -1,17 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',150000);
-md=setmask(md,'all','');
-md=parameterize(md,'../Par/SquareShelfConstrained.par');
-md=extrude(md,5,1);
-%Add boundary conditions on thickness on the border
-pos=find(md.mesh.vertexonboundary);
-md.balancethickness.spcthickness(pos)=md.geometry.thickness(pos);
-md=setflowequation(md,'macayeal','all');
-md.cluster=none;
-md=solve(md,BalancethicknessSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Thickness'};
-field_tolerances={1e-13};
-field_values={...
-	(md.results.BalancethicknessSolution.Thickness),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test135.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test135.m	(revision 12167)
+++ 	(revision )
@@ -1,16 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',150000);
-md=meshconvert(md);
-md=setmask(md,'all','');
-md=parameterize(md,'../Par/SquareShelfConstrained.par');
-md.balancethickness.stabilization=3;
-md.initialization.vy=md.initialization.vy+400;
-md=setflowequation(md,'macayeal','all');
-md.cluster=none;
-md=solve(md,BalancethicknessSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Thickness'};
-field_tolerances={1e-13};
-field_values={...
-	(md.results.BalancethicknessSolution.Thickness),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test137.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test137.m	(revision 12167)
+++ 	(revision )
@@ -1,25 +1,0 @@
-
-%Simple mesh
-md=bamg(model,'domain','../Exp/Square.exp','hmax',100000);
-x1=md.mesh.x;
-y1=md.mesh.y;
-
-%hVertices
-md=bamg(model,'domain','../Exp/Square.exp','hmax',300000,'hvertices',[10000 100000 400000 100000]');
-x2=md.mesh.x;
-y2=md.mesh.y;
-
-%big mesh
-t0=clock;
-md=bamg(model,'domain','../Exp/Square.exp','hmax',3000);
-nbelements=md.mesh.numberofelements;
-elapsedtime=etime(clock,t0);
-
-%Fields and tolerances to track changes
-field_names     ={'x1' 'y1' 'x2' 'y2' 'nbelements' 'elapsed time'};
-field_tolerances={1e-13 1e-13 1e-13 1e-13 1e-13 0.5};
-field_values={...
-	x1, y1,...
-	x2, y2,...
-	nbelements,elapsedtime...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test139.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test139.m	(revision 12167)
+++ 	(revision )
@@ -1,18 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',180000);
-md=setmask(md,'all','');
-md=parameterize(md,'../Par/SquareShelfConstrained.par');
-md=extrude(md,3,1);
-md=setflowequation(md,'macayeal','all');
-md.timestepping.time_step=0;
-md.cluster=none;
-md.initialization.waterfraction=zeros(md.mesh.numberofvertices,1);
-md=solve(md,EnthalpySolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Enthalpy','Waterfraction','Temperature'};
-field_tolerances={1e-13,1e-10,1e-13};
-field_values={...
-	(md.results.EnthalpySolution.Enthalpy),...
-	(md.results.EnthalpySolution.Waterfraction),...
-	(md.results.EnthalpySolution.Temperature),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test141.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test141.m	(revision 12167)
+++ 	(revision )
@@ -1,30 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',180000);
-md=setmask(md,'all','');
-md=parameterize(md,'../Par/SquareShelfConstrained.par');
-md=extrude(md,3,1);
-md=setflowequation(md,'macayeal','all');
-md.initialization.waterfraction=zeros(md.mesh.numberofvertices,1);
-md.cluster=none;
-md.transient.isdiagnostic=0;
-md.transient.isprognostic=0;
-md.transient.isthermal=1;
-md.transient.isgroundingline=0;
-md.thermal.isenthalpy=1;
-md=solve(md,TransientSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Enthalpy1','Waterfraction1','Temperature1',...
-	'Enthalpy2','Waterfraction2','Temperature2',...
-	'Enthalpy3','Waterfraction3','Temperature3'};
-field_tolerances={1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13};
-field_values={...
-	(md.results.TransientSolution(1).Enthalpy),...
-	(md.results.TransientSolution(1).Waterfraction),...
-	(md.results.TransientSolution(1).Temperature),...
-	(md.results.TransientSolution(2).Enthalpy),...
-	(md.results.TransientSolution(2).Waterfraction),...
-	(md.results.TransientSolution(2).Temperature),...
-	(md.results.TransientSolution(3).Enthalpy),...
-	(md.results.TransientSolution(3).Waterfraction),...
-	(md.results.TransientSolution(3).Temperature),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test143.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test143.m	(revision 12167)
+++ 	(revision )
@@ -1,53 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',200000);
-md=setmask(md,'all','');
-md=parameterize(md,'../Par/SquareShelfConstrained.par');
-md=extrude(md,3,1);
-md=setflowequation(md,'pattyn','all');
-md.initialization.waterfraction=zeros(md.mesh.numberofvertices,1);
-md.thermal.isenthalpy=1;
-md.thermal.stabilization=2;
-md.cluster=none;
-md=solve(md,TransientSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Vx1','Vy1','Vz1','Vel1','Pressure1','Bed1','Surface1','Thickness1','Temperature1','Enthalpy1','Waterfraction1', ...
-				      'Vx2','Vy2','Vz2','Vel2','Pressure2','Bed2','Surface2','Thickness2','Temperature2','Enthalpy2','Waterfraction2', ...
-					   'Vx3','Vy3','Vz3','Vel3','Pressure3','Bed3','Surface3','Thickness3','Temperature3','Enthalpy3','Waterfraction3'};
-field_tolerances={1e-09,1e-09,1e-09,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,...
-						1e-09,1e-09,1e-10,1e-09,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,...
-						1e-09,5e-10,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10};
-field_values={...
-	(md.results.TransientSolution(1).Vx),...
-	(md.results.TransientSolution(1).Vy),...
-	(md.results.TransientSolution(1).Vz),...
-	(md.results.TransientSolution(1).Vel),...
-	(md.results.TransientSolution(1).Pressure),...
-	(md.results.TransientSolution(1).Bed),...
-	(md.results.TransientSolution(1).Surface),...
-	(md.results.TransientSolution(1).Thickness),...
-	(md.results.TransientSolution(1).Temperature),...
-	(md.results.TransientSolution(1).Enthalpy),...
-	(md.results.TransientSolution(1).Waterfraction),...
-	(md.results.TransientSolution(2).Vx),...
-	(md.results.TransientSolution(2).Vy),...
-	(md.results.TransientSolution(2).Vz),...
-	(md.results.TransientSolution(2).Vel),...
-	(md.results.TransientSolution(2).Pressure),...
-	(md.results.TransientSolution(2).Bed),...
-	(md.results.TransientSolution(2).Surface),...
-	(md.results.TransientSolution(2).Thickness),...
-	(md.results.TransientSolution(2).Temperature),...
-	(md.results.TransientSolution(2).Enthalpy),...
-	(md.results.TransientSolution(2).Waterfraction),...
-	(md.results.TransientSolution(3).Vx),...
-	(md.results.TransientSolution(3).Vy),...
-	(md.results.TransientSolution(3).Vz),...
-	(md.results.TransientSolution(3).Vel),...
-	(md.results.TransientSolution(3).Pressure),...
-	(md.results.TransientSolution(3).Bed),...
-	(md.results.TransientSolution(3).Surface),...
-	(md.results.TransientSolution(3).Thickness),...
-	(md.results.TransientSolution(3).Temperature),...
-	(md.results.TransientSolution(3).Enthalpy),...
-	(md.results.TransientSolution(3).Waterfraction),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test201.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test201.m	(revision 12167)
+++ 	(revision )
@@ -1,16 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',150000);
-md=setmask(md,'all','');
-md=parameterize(md,'../Par/SquareShelf.par');
-md=setflowequation(md,'macayeal','all');
-md.cluster=none;
-md=solve(md,DiagnosticSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Vx','Vy','Vel','Pressure'};
-field_tolerances={1e-13,1e-13,1e-13,1e-13};
-field_values={...
-	(md.results.DiagnosticSolution.Vx),...
-	(md.results.DiagnosticSolution.Vy),...
-	(md.results.DiagnosticSolution.Vel),...
-	(md.results.DiagnosticSolution.Pressure),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test203.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test203.m	(revision 12167)
+++ 	(revision )
@@ -1,18 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',180000);
-md=setmask(md,'all','');
-md=parameterize(md,'../Par/SquareShelf.par');
-md=extrude(md,3,2);
-md=setflowequation(md,'macayeal','all');
-md.cluster=none;
-md=solve(md,DiagnosticSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Vx','Vy','Vz','Vel','Pressure'};
-field_tolerances={1e-13,1e-13,1e-13,1e-13,1e-13};
-field_values={...
-	(md.results.DiagnosticSolution.Vx),...
-	(md.results.DiagnosticSolution.Vy),...
-	(md.results.DiagnosticSolution.Vz),...
-	(md.results.DiagnosticSolution.Vel),...
-	(md.results.DiagnosticSolution.Pressure),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test205.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test205.m	(revision 12167)
+++ 	(revision )
@@ -1,18 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',180000);
-md=setmask(md,'all','');
-md=parameterize(md,'../Par/SquareShelf.par');
-md=extrude(md,3,2);
-md=setflowequation(md,'pattyn','all');
-md.cluster=none;
-md=solve(md,DiagnosticSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Vx','Vy','Vz','Vel','Pressure'};
-field_tolerances={1e-13,1e-13,1e-13,1e-13,1e-13};
-field_values={...
-	(md.results.DiagnosticSolution.Vx),...
-	(md.results.DiagnosticSolution.Vy),...
-	(md.results.DiagnosticSolution.Vz),...
-	(md.results.DiagnosticSolution.Vel),...
-	(md.results.DiagnosticSolution.Pressure),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test207.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test207.m	(revision 12167)
+++ 	(revision )
@@ -1,18 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',180000);
-md=setmask(md,'all','');
-md=parameterize(md,'../Par/SquareShelf.par');
-md=extrude(md,3,2);
-md.cluster=none;
-md=setflowequation(md,'stokes','all');
-md=solve(md,DiagnosticSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Vx','Vy','Vz','Vel','Pressure'};
-field_tolerances={1e-08,1e-08,1e-08,1e-08,1e-08};
-field_values={...
-	(md.results.DiagnosticSolution.Vx),...
-	(md.results.DiagnosticSolution.Vy),...
-	(md.results.DiagnosticSolution.Vz),...
-	(md.results.DiagnosticSolution.Vel),...
-	(md.results.DiagnosticSolution.Pressure),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test209.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test209.m	(revision 12167)
+++ 	(revision )
@@ -1,18 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',150000);
-md=setmask(md,'all','');
-md=parameterize(md,'../Par/SquareShelf.par');
-md=extrude(md,3,2);
-md=setflowequation(md,'pattyn','../Exp/SquareHalfRight.exp','fill','macayeal','coupling','penalties');
-md.cluster=none;
-md=solve(md,DiagnosticSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Vx','Vy','Vz','Vel','Pressure'};
-field_tolerances={1e-05,1e-05,1e-05,1e-05,1e-05};
-field_values={...
-	(md.results.DiagnosticSolution.Vx),...
-	(md.results.DiagnosticSolution.Vy),...
-	(md.results.DiagnosticSolution.Vz),...
-	(md.results.DiagnosticSolution.Vel),...
-	(md.results.DiagnosticSolution.Pressure),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test211.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test211.m	(revision 12167)
+++ 	(revision )
@@ -1,16 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',180000);
-md=setmask(md,'all','');
-md=parameterize(md,'../Par/SquareShelf.par');
-md=extrude(md,3,1);
-md=setflowequation(md,'macayeal','all');
-md.timestepping.time_step=0;
-md.cluster=none;
-md=solve(md,ThermalSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Temperature','BasalforcingsMeltingRate'};
-field_tolerances={1e-13,1e-13};
-field_values={...
-	(md.results.ThermalSolution.Temperature),...
-	(md.results.ThermalSolution.BasalforcingsMeltingRate),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test213.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test213.m	(revision 12167)
+++ 	(revision )
@@ -1,23 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',180000);
-md=setmask(md,'all','');
-md=parameterize(md,'../Par/SquareShelf.par');
-md=extrude(md,3,1);
-md=setflowequation(md,'macayeal','all');
-md.cluster=none;
-md.transient.isdiagnostic=0;
-md.transient.isprognostic=0;
-md.transient.isthermal=1;
-md.transient.isgroundingline=0;
-md=solve(md,TransientSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Temperature1','MeltingRate1','Temperature2','BasalforcingsMeltingRate2','Temperature3','BasalforcingsMeltingRate3'};
-field_tolerances={1e-13,1e-13,1e-13,1e-13,1e-13,1e-13};
-field_values={...
-	(md.results.TransientSolution(1).Temperature),...
-	(md.results.TransientSolution(1).BasalforcingsMeltingRate),...
-	(md.results.TransientSolution(2).Temperature),...
-	(md.results.TransientSolution(2).BasalforcingsMeltingRate),...
-	(md.results.TransientSolution(3).Temperature),...
-	(md.results.TransientSolution(3).BasalforcingsMeltingRate),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test215.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test215.m	(revision 12167)
+++ 	(revision )
@@ -1,33 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',150000);
-md=setmask(md,'all','');
-md=parameterize(md,'../Par/SquareShelf.par');
-md=setflowequation(md,'macayeal','all');
-md.cluster=none;
-md=solve(md,TransientSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Vx1','Vy1','Vel1','Pressure1','Bed1','Surface1','Thickness1','Vx2','Vy2','Vel2','Pressure2','Bed2','Surface2','Thickness2','Vx3','Vy3','Vel3','Pressure3','Bed3','Surface3','Thickness3'};
-field_tolerances={1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13};
-field_values={...
-	(md.results.TransientSolution(1).Vx),...
-	(md.results.TransientSolution(1).Vy),...
-	(md.results.TransientSolution(1).Vel),...
-	(md.results.TransientSolution(1).Pressure),...
-	(md.results.TransientSolution(1).Bed),...
-	(md.results.TransientSolution(1).Surface),...
-	(md.results.TransientSolution(1).Thickness),...
-	(md.results.TransientSolution(2).Vx),...
-	(md.results.TransientSolution(2).Vy),...
-	(md.results.TransientSolution(2).Vel),...
-	(md.results.TransientSolution(2).Pressure),...
-	(md.results.TransientSolution(2).Bed),...
-	(md.results.TransientSolution(2).Surface),...
-	(md.results.TransientSolution(2).Thickness),...
-	(md.results.TransientSolution(3).Vx),...
-	(md.results.TransientSolution(3).Vy),...
-	(md.results.TransientSolution(3).Vel),...
-	(md.results.TransientSolution(3).Pressure),...
-	(md.results.TransientSolution(3).Bed),...
-	(md.results.TransientSolution(3).Surface),...
-	(md.results.TransientSolution(3).Thickness),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test217.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test217.m	(revision 12167)
+++ 	(revision )
@@ -1,45 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',180000);
-md=setmask(md,'all','');
-md=parameterize(md,'../Par/SquareShelf.par');
-md=extrude(md,3,1);
-md=setflowequation(md,'macayeal','all');
-md.cluster=none;
-md=solve(md,TransientSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Vx1','Vy1','Vz1','Vel1','Pressure1','Bed1','Surface1','Thickness1','Temperature1','BasalforcingsMeltingRate1', ...
-				      'Vx2','Vy2','Vz2','Vel2','Pressure2','Bed2','Surface2','Thickness2','Temperature2','BasalforcingsMeltingRate2', ...
-					   'Vx3','Vy3','Vz3','Vel3','Pressure3','Bed3','Surface3','Thickness3','Temperature3','BasalforcingsMeltingRate3'};
-field_tolerances={1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13};
-field_values={...
-	(md.results.TransientSolution(1).Vx),...
-	(md.results.TransientSolution(1).Vy),...
-	(md.results.TransientSolution(1).Vz),...
-	(md.results.TransientSolution(1).Vel),...
-	(md.results.TransientSolution(1).Pressure),...
-	(md.results.TransientSolution(1).Bed),...
-	(md.results.TransientSolution(1).Surface),...
-	(md.results.TransientSolution(1).Thickness),...
-	(md.results.TransientSolution(1).Temperature),...
-	(md.results.TransientSolution(1).BasalforcingsMeltingRate),...
-	(md.results.TransientSolution(2).Vx),...
-	(md.results.TransientSolution(2).Vy),...
-	(md.results.TransientSolution(2).Vz),...
-	(md.results.TransientSolution(2).Vel),...
-	(md.results.TransientSolution(2).Pressure),...
-	(md.results.TransientSolution(2).Bed),...
-	(md.results.TransientSolution(2).Surface),...
-	(md.results.TransientSolution(2).Thickness),...
-	(md.results.TransientSolution(2).Temperature),...
-	(md.results.TransientSolution(2).BasalforcingsMeltingRate),...
-	(md.results.TransientSolution(3).Vx),...
-	(md.results.TransientSolution(3).Vy),...
-	(md.results.TransientSolution(3).Vz),...
-	(md.results.TransientSolution(3).Vel),...
-	(md.results.TransientSolution(3).Pressure),...
-	(md.results.TransientSolution(3).Bed),...
-	(md.results.TransientSolution(3).Surface),...
-	(md.results.TransientSolution(3).Thickness),...
-	(md.results.TransientSolution(3).Temperature),...
-	(md.results.TransientSolution(3).BasalforcingsMeltingRate),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test219.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test219.m	(revision 12167)
+++ 	(revision )
@@ -1,45 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',200000);
-md=setmask(md,'all','');
-md=parameterize(md,'../Par/SquareShelf.par');
-md=extrude(md,3,1);
-md=setflowequation(md,'pattyn','all');
-md.cluster=none;
-md=solve(md,TransientSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Vx1','Vy1','Vz1','Vel1','Pressure1','Bed1','Surface1','Thickness1','Temperature1','BasalforcingsMeltingRate1', ...
-				      'Vx2','Vy2','Vz2','Vel2','Pressure2','Bed2','Surface2','Thickness2','Temperature2','BasalforcingsMeltingRate2', ...
-					   'Vx3','Vy3','Vz3','Vel3','Pressure3','Bed3','Surface3','Thickness3','Temperature3','BasalforcingsMeltingRate3'};
-field_tolerances={1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-06};
-field_values={...
-	(md.results.TransientSolution(1).Vx),...
-	(md.results.TransientSolution(1).Vy),...
-	(md.results.TransientSolution(1).Vz),...
-	(md.results.TransientSolution(1).Vel),...
-	(md.results.TransientSolution(1).Pressure),...
-	(md.results.TransientSolution(1).Bed),...
-	(md.results.TransientSolution(1).Surface),...
-	(md.results.TransientSolution(1).Thickness),...
-	(md.results.TransientSolution(1).Temperature),...
-	(md.results.TransientSolution(1).BasalforcingsMeltingRate),...
-	(md.results.TransientSolution(2).Vx),...
-	(md.results.TransientSolution(2).Vy),...
-	(md.results.TransientSolution(2).Vz),...
-	(md.results.TransientSolution(2).Vel),...
-	(md.results.TransientSolution(2).Pressure),...
-	(md.results.TransientSolution(2).Bed),...
-	(md.results.TransientSolution(2).Surface),...
-	(md.results.TransientSolution(2).Thickness),...
-	(md.results.TransientSolution(2).Temperature),...
-	(md.results.TransientSolution(2).BasalforcingsMeltingRate),...
-	(md.results.TransientSolution(3).Vx),...
-	(md.results.TransientSolution(3).Vy),...
-	(md.results.TransientSolution(3).Vz),...
-	(md.results.TransientSolution(3).Vel),...
-	(md.results.TransientSolution(3).Pressure),...
-	(md.results.TransientSolution(3).Bed),...
-	(md.results.TransientSolution(3).Surface),...
-	(md.results.TransientSolution(3).Thickness),...
-	(md.results.TransientSolution(3).Temperature),...
-	(md.results.TransientSolution(3).BasalforcingsMeltingRate),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test221.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test221.m	(revision 12167)
+++ 	(revision )
@@ -1,48 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',200000);
-md=setmask(md,'all','');
-md=parameterize(md,'../Par/SquareShelf.par');
-md=extrude(md,3,1);
-md=setflowequation(md,'stokes','all');
-md.diagnostic.reltol=NaN;
-md.cluster=none;
-md=solve(md,TransientSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Vx1','Vy1','Vz1','Vel1','Pressure1','Bed1','Surface1','Thickness1','Temperature1','BasalforcingsMeltingRate1', ...
-				      'Vx2','Vy2','Vz2','Vel2','Pressure2','Bed2','Surface2','Thickness2','Temperature2','BasalforcingsMeltingRate2', ...
-					   'Vx3','Vy3','Vz3','Vel3','Pressure3','Bed3','Surface3','Thickness3','Temperature3','BasalforcingsMeltingRate3'};
-field_tolerances={1e-08,1e-08,1e-08,1e-08,1e-08,1e-08,1e-08,1e-08,1e-08,1e-08,...
-						1e-08,1e-08,1e-08,1e-08,1e-08,1e-08,1e-08,1e-08,1e-08,1e-08,...
-						1e-08,1e-08,1e-07,1e-08,1e-08,1e-08,1e-08,1e-08,1e-08,1e-06};
-field_values={...
-	(md.results.TransientSolution(1).Vx),...
-	(md.results.TransientSolution(1).Vy),...
-	(md.results.TransientSolution(1).Vz),...
-	(md.results.TransientSolution(1).Vel),...
-	(md.results.TransientSolution(1).Pressure),...
-	(md.results.TransientSolution(1).Bed),...
-	(md.results.TransientSolution(1).Surface),...
-	(md.results.TransientSolution(1).Thickness),...
-	(md.results.TransientSolution(1).Temperature),...
-	(md.results.TransientSolution(1).BasalforcingsMeltingRate),...
-	(md.results.TransientSolution(2).Vx),...
-	(md.results.TransientSolution(2).Vy),...
-	(md.results.TransientSolution(2).Vz),...
-	(md.results.TransientSolution(2).Vel),...
-	(md.results.TransientSolution(2).Pressure),...
-	(md.results.TransientSolution(2).Bed),...
-	(md.results.TransientSolution(2).Surface),...
-	(md.results.TransientSolution(2).Thickness),...
-	(md.results.TransientSolution(2).Temperature),...
-	(md.results.TransientSolution(2).BasalforcingsMeltingRate),...
-	(md.results.TransientSolution(3).Vx),...
-	(md.results.TransientSolution(3).Vy),...
-	(md.results.TransientSolution(3).Vz),...
-	(md.results.TransientSolution(3).Vel),...
-	(md.results.TransientSolution(3).Pressure),...
-	(md.results.TransientSolution(3).Bed),...
-	(md.results.TransientSolution(3).Surface),...
-	(md.results.TransientSolution(3).Thickness),...
-	(md.results.TransientSolution(3).Temperature),...
-	(md.results.TransientSolution(3).BasalforcingsMeltingRate),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test223.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test223.m	(revision 12167)
+++ 	(revision )
@@ -1,33 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',200000);
-md=setmask(md,'all','');
-md=parameterize(md,'../Par/SquareShelf.par');
-md=setflowequation(md,'macayeal','all');
-
-%control parameters
-md.inversion.iscontrol=1;
-md.inversion.control_parameters={'MaterialsRheologyBbar'};
-md.inversion.min_parameters=10^6*ones(md.mesh.numberofvertices,1);
-md.inversion.max_parameters=2*10^9*ones(md.mesh.numberofvertices,1);
-md.inversion.nsteps=2;
-md.inversion.cost_functions=101*ones(md.inversion.nsteps,1);
-md.inversion.cost_functions_coefficients=ones(md.mesh.numberofvertices,1);
-md.inversion.gradient_scaling=10^7*ones(md.inversion.nsteps,1);
-md.inversion.maxiter_per_step=2*ones(md.inversion.nsteps,1);
-md.inversion.step_threshold=0.3*ones(md.inversion.nsteps,1);
-md.inversion.vx_obs=md.initialization.vx; md.inversion.vy_obs=md.initialization.vy;
-
-md.cluster=none;
-md=solve(md,DiagnosticSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Gradient' 'Misfits' 'MaterialsRheologyBbar' 'Pressure' 'Vel' 'Vx' 'Vy'};
-field_tolerances={1e-12,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13};
-field_values={...
-	(md.results.DiagnosticSolution.Gradient1),...
-	md.results.DiagnosticSolution.J,...
-	(md.results.DiagnosticSolution.MaterialsRheologyBbar),...
-	(md.results.DiagnosticSolution.Pressure),...
-	(md.results.DiagnosticSolution.Vel),...
-	(md.results.DiagnosticSolution.Vx),...
-	(md.results.DiagnosticSolution.Vy)
-};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test225.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test225.m	(revision 12167)
+++ 	(revision )
@@ -1,34 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',200000);
-md=setmask(md,'all','');
-md=parameterize(md,'../Par/SquareShelf.par');
-md=extrude(md,3,1);
-md=setflowequation(md,'macayeal','all');
-
-%control parameters
-md.inversion.iscontrol=1;
-md.inversion.control_parameters={'MaterialsRheologyBbar'};
-md.inversion.min_parameters=10^6*ones(md.mesh.numberofvertices,1);
-md.inversion.max_parameters=2*10^9*ones(md.mesh.numberofvertices,1);
-md.inversion.nsteps=2;
-md.inversion.cost_functions=101*ones(md.inversion.nsteps,1);
-md.inversion.cost_functions_coefficients=ones(md.mesh.numberofvertices,1);
-md.inversion.gradient_scaling=10^7*ones(md.inversion.nsteps,1);
-md.inversion.maxiter_per_step=2*ones(md.inversion.nsteps,1);
-md.inversion.step_threshold=0.3*ones(md.inversion.nsteps,1);
-md.inversion.vx_obs=md.initialization.vx; md.inversion.vy_obs=md.initialization.vy;
-
-md.cluster=none;
-md=solve(md,DiagnosticSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Gradient' 'Misfits' 'MaterialsRheologyBbar' 'Pressure' 'Vel' 'Vx' 'Vy'};
-field_tolerances={1e-12,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13};
-field_values={...
-	(md.results.DiagnosticSolution.Gradient1),...
-	md.results.DiagnosticSolution.J,...
-	(md.results.DiagnosticSolution.MaterialsRheologyB),...
-	(md.results.DiagnosticSolution.Pressure),...
-	(md.results.DiagnosticSolution.Vel),...
-	(md.results.DiagnosticSolution.Vx),...
-	(md.results.DiagnosticSolution.Vy)
-};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test227.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test227.m	(revision 12167)
+++ 	(revision )
@@ -1,34 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',200000);
-md=setmask(md,'all','');
-md=parameterize(md,'../Par/SquareShelf.par');
-md=extrude(md,3,1);
-md=setflowequation(md,'pattyn','all');
-
-%control parameters
-md.inversion.iscontrol=1;
-md.inversion.control_parameters={'MaterialsRheologyBbar'};
-md.inversion.min_parameters=10^6*ones(md.mesh.numberofvertices,1);
-md.inversion.max_parameters=2*10^9*ones(md.mesh.numberofvertices,1);
-md.inversion.nsteps=2;
-md.inversion.cost_functions=101*ones(md.inversion.nsteps,1);
-md.inversion.cost_functions_coefficients=ones(md.mesh.numberofvertices,1);
-md.inversion.gradient_scaling=10^7*ones(md.inversion.nsteps,1);
-md.inversion.maxiter_per_step=2*ones(md.inversion.nsteps,1);
-md.inversion.step_threshold=0.3*ones(md.inversion.nsteps,1);
-md.inversion.vx_obs=md.initialization.vx; md.inversion.vy_obs=md.initialization.vy;
-
-md.cluster=none;
-md=solve(md,DiagnosticSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Gradient' 'Misfits' 'MaterialsRheologyBbar' 'Pressure' 'Vel' 'Vx' 'Vy'};
-field_tolerances={1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09};
-field_values={...
-	(md.results.DiagnosticSolution.Gradient1),...
-	md.results.DiagnosticSolution.J,...
-	(md.results.DiagnosticSolution.MaterialsRheologyB),...
-	(md.results.DiagnosticSolution.Pressure),...
-	(md.results.DiagnosticSolution.Vel),...
-	(md.results.DiagnosticSolution.Vx),...
-	(md.results.DiagnosticSolution.Vy)
-};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test229.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test229.m	(revision 12167)
+++ 	(revision )
@@ -1,34 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',200000);
-md=setmask(md,'all','');
-md=parameterize(md,'../Par/SquareShelf.par');
-md=extrude(md,3,1);
-md=setflowequation(md,'stokes','all');
-
-%control parameters
-md.inversion.iscontrol=1;
-md.inversion.control_parameters={'MaterialsRheologyBbar'};
-md.inversion.min_parameters=10^6*ones(md.mesh.numberofvertices,1);
-md.inversion.max_parameters=2*10^9*ones(md.mesh.numberofvertices,1);
-md.inversion.nsteps=2;
-md.inversion.cost_functions=101*ones(md.inversion.nsteps,1);
-md.inversion.cost_functions_coefficients=ones(md.mesh.numberofvertices,1);
-md.inversion.gradient_scaling=10^7*ones(md.inversion.nsteps,1);
-md.inversion.maxiter_per_step=2*ones(md.inversion.nsteps,1);
-md.inversion.step_threshold=0.3*ones(md.inversion.nsteps,1);
-md.inversion.vx_obs=md.initialization.vx; md.inversion.vy_obs=md.initialization.vy;
-
-md.cluster=none;
-md=solve(md,DiagnosticSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Gradient' 'Misfits' 'MaterialsRheologyBbar' 'Pressure' 'Vel' 'Vx' 'Vy'};
-field_tolerances={1e-08,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09};
-field_values={...
-	(md.results.DiagnosticSolution.Gradient1),...
-	md.results.DiagnosticSolution.J,...
-	(md.results.DiagnosticSolution.MaterialsRheologyB),...
-	(md.results.DiagnosticSolution.Pressure),...
-	(md.results.DiagnosticSolution.Vel),...
-	(md.results.DiagnosticSolution.Vx),...
-	(md.results.DiagnosticSolution.Vy)
-};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test233.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test233.m	(revision 12167)
+++ 	(revision )
@@ -1,69 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',150000);
-md=setmask(md,'all','');
-md=parameterize(md,'../Par/SquareShelf.par');
-md=setflowequation(md,'macayeal','all');
-md.cluster=none;
-
-%redo the parameter file for this special shelf. 
-%constant thickness, constrained (vy=0) flow into an icefront, 
-%from 0 m/yr at the grounding line.
-
-%tighten
-md.diagnostic.restol=10^-4;
-
-%needed later
-ymin=min(md.mesh.y);
-ymax=max(md.mesh.y);
-xmin=min(md.mesh.x);
-xmax=max(md.mesh.x);
-
-di=md.materials.rho_ice/md.materials.rho_water;
-
-h=1000;
-md.geometry.thickness=h*ones(md.mesh.numberofvertices,1);
-md.geometry.bed=-md.materials.rho_ice/md.materials.rho_water*md.geometry.thickness;
-md.geometry.surface=md.geometry.bed+md.geometry.thickness;
-
-%Initial velocity and pressure
-md.initialization.vx=zeros(md.mesh.numberofvertices,1);
-md.initialization.vy=zeros(md.mesh.numberofvertices,1);
-md.initialization.vz=zeros(md.mesh.numberofvertices,1);
-md.initialization.pressure=zeros(md.mesh.numberofvertices,1);
-
-%Materials
-md.initialization.temperature=(273-20)*ones(md.mesh.numberofvertices,1);
-md.materials.rheology_B=paterson(md.initialization.temperature);
-md.materials.rheology_n=3*ones(md.mesh.numberofelements,1);
-
-%Boundary conditions:
-md.diagnostic.spcvx=NaN*ones(md.mesh.numberofvertices,1);
-md.diagnostic.spcvy=NaN*ones(md.mesh.numberofvertices,1);
-md.diagnostic.spcvz=NaN*ones(md.mesh.numberofvertices,1);
-
-%constrain flanks to 0 normal velocity
-pos=find(md.mesh.x==xmin | md.mesh.x==xmax);
-md.diagnostic.spcvx(pos)=0;
-md.diagnostic.spcvz(pos)=NaN;
-
-%constrain grounding line to 0 velocity
-pos=find(md.mesh.y==ymin);
-md.diagnostic.spcvx(pos)=0;
-md.diagnostic.spcvy(pos)=0;
-
-%icefront
-nodeonicefront=zeros(md.mesh.numberofvertices,1);
-pos=find(md.mesh.y==ymax); nodeonicefront(pos)=1;
-pos=find(nodeonicefront(md.mesh.segments(:,1)) | nodeonicefront(md.mesh.segments(:,2))); diagnostic.icefront=md.mesh.segments(pos,:);
-diagnostic.icefront=[diagnostic.icefront 1*md.mask.elementonfloatingice(diagnostic.icefront(:,end))];
-md.diagnostic.icefront=diagnostic.icefront;
-
-md=solve(md,DiagnosticSolutionEnum);
-
-%create analytical solution: strain rate is constant = ((rho_ice*g*h)/4B)^3 (Paterson, 4th Edition, page 292.
-%ey_c=(md.materials.rho_ice*md.constants.g*(1-di)*md.geometry.thickness./(4*md.materials.rheology_B)).^3;
-%vy_c=ey_c.*md.mesh.y*md.constants.yts;
-
-%Fields and tolerances to track changes
-field_names     ={'Vy'};
-field_tolerances={1e-13};
-field_values={(md.results.DiagnosticSolution.Vy)};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test235.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test235.m	(revision 12167)
+++ 	(revision )
@@ -1,92 +1,0 @@
-md=squaremesh(model,1000000,1000000,5,5);
-md=setmask(md,'all','');
-md=parameterize(md,'../Par/SquareShelf.par');
-md=setflowequation(md,'macayeal','all');
-md.cluster=none;
-
-%redo the parameter file for this special shelf. 
-%constant thickness, constrained (vy=0) flow into an icefront, 
-%from 0 m/yr at the grounding line.
-
-%needed later
-ymin=min(md.mesh.y);
-ymax=max(md.mesh.y);
-xmin=min(md.mesh.x);
-xmax=max(md.mesh.x);
-
-di=md.materials.rho_ice/md.materials.rho_water;
-
-h=1000;
-md.geometry.thickness=h*ones(md.mesh.numberofvertices,1);
-md.geometry.bed=-md.materials.rho_ice/md.materials.rho_water*md.geometry.thickness;
-md.geometry.surface=md.geometry.bed+md.geometry.thickness;
-
-%Initial velocity and pressure
-md.initialization.vx=zeros(md.mesh.numberofvertices,1);
-md.initialization.vy=zeros(md.mesh.numberofvertices,1);
-md.initialization.vz=zeros(md.mesh.numberofvertices,1);
-md.initialization.pressure=zeros(md.mesh.numberofvertices,1);
-
-%Materials
-md.initialization.temperature=(273-20)*ones(md.mesh.numberofvertices,1);
-md.materials.rheology_B=paterson(md.initialization.temperature);
-md.materials.rheology_n=3*ones(md.mesh.numberofelements,1);
-
-%Boundary conditions:
-md.diagnostic.spcvx=NaN*ones(md.mesh.numberofvertices,1);
-md.diagnostic.spcvy=NaN*ones(md.mesh.numberofvertices,1);
-md.diagnostic.spcvz=NaN*ones(md.mesh.numberofvertices,1);
-
-%constrain flanks to 0 normal velocity
-pos=find(md.mesh.x==xmin | md.mesh.x==xmax);
-md.diagnostic.spcvx(pos)=0;
-md.diagnostic.spcvz(pos)=NaN;
-
-%constrain grounding line to 0 velocity
-pos=find(md.mesh.y==ymin);
-md.diagnostic.spcvx(pos)=0;
-md.diagnostic.spcvy(pos)=0;
-
-%icefront
-nodeonicefront=zeros(md.mesh.numberofvertices,1);
-pos=find(md.mesh.y==ymax); nodeonicefront(pos)=1;
-pos=find(nodeonicefront(md.mesh.segments(:,1)) | nodeonicefront(md.mesh.segments(:,2))); diagnostic.icefront=md.mesh.segments(pos,:);
-diagnostic.icefront=[diagnostic.icefront 1*md.mask.elementonfloatingice(diagnostic.icefront(:,end))];
-md.diagnostic.icefront=diagnostic.icefront;
-
-%partitioning
-md.qmu.numberofpartitions=md.mesh.numberofvertices;
-md=partitioner(md,'package','linear','npart',md.qmu.numberofpartitions);
-md.qmu.partition=md.qmu.partition-1;
-
-%Dakota options
-%variables
-md.qmu.variables.rheology_B=normal_uncertain('scaled_MaterialsRheologyB',1,.5);
-
-%responses
-md.qmu.responses.MaxVel=response_function('MaxVel',[],[0.0001 0.001 0.01 0.25 0.5 0.75 0.99 0.999 0.9999]);
-
-%method
-md.qmu.method     =dakota_method('nond_l');
-
-%parameters
-md.qmu.params.direct=true;
-md.qmu.params.analysis_driver='diagnostic';
-md.qmu.params.evaluation_concurrency=1;
-md.qmu.params.interval_type='forward';
-
-%imperative! 
-md.diagnostic.reltol=10^-10; %tighten for qmu analysese
-md.qmu.isdakota=1;
-
-%solve
-md=solve(md,DiagnosticSolutionEnum,'overwrite','y');
-
-%Fields and tolerances to track changes
-md=tres(md,'dakota');
-md.results.dakota.importancefactors=importancefactors(md,'scaled_MaterialsRheologyB','MaxVel')';
-field_names     ={'importancefactors'};
-field_tolerances={1e-10};
-field_values={...
-         md.results.dakota.importancefactors,...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test237.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test237.m	(revision 12167)
+++ 	(revision )
@@ -1,18 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',150000);
-md=setmask(md,'all','');
-md=parameterize(md,'../Par/SquareShelf.par');
-md=extrude(md,3,2);
-md=setflowequation(md,'pattyn','../Exp/SquareHalfRight.exp','fill','macayeal');
-md.cluster=none;
-md=solve(md,DiagnosticSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Vx','Vy','Vz','Vel','Pressure'};
-field_tolerances={1e-09,1e-09,1e-09,1e-09,1e-09};
-field_values={...
-	(md.results.DiagnosticSolution.Vx),...
-	(md.results.DiagnosticSolution.Vy),...
-	(md.results.DiagnosticSolution.Vz),...
-	(md.results.DiagnosticSolution.Vel),...
-	(md.results.DiagnosticSolution.Pressure),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test239.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test239.m	(revision 12167)
+++ 	(revision )
@@ -1,17 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',120000);
-md=setmask(md,'all','');
-md=parameterize(md,'../Par/SquareShelf.par');
-md=extrude(md,2,1);
-md=setflowequation(md,'stokes','../Exp/SquareHalfRight.exp','fill','pattyn');
-md=solve(md,DiagnosticSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Vx','Vy','Vz','Vel','Pressure'};
-field_tolerances={1e-09,1e-09,1e-09,1e-09,1e-09};
-field_values={...
-	(md.results.DiagnosticSolution.Vx),...
-	(md.results.DiagnosticSolution.Vy),...
-	(md.results.DiagnosticSolution.Vz),...
-	(md.results.DiagnosticSolution.Vel),...
-	(md.results.DiagnosticSolution.Pressure),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test241.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test241.m	(revision 12167)
+++ 	(revision )
@@ -1,18 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',120000);
-md=setmask(md,'all','');
-md=parameterize(md,'../Par/SquareShelf.par');
-md=extrude(md,2,1);
-md.diagnostic.viscosity_overshoot=0.0;
-md=setflowequation(md,'stokes','../Exp/SquareHalfRight.exp','fill','macayeal');
-md=solve(md,DiagnosticSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Vx','Vy','Vz','Vel','Pressure'};
-field_tolerances={1e-09,1e-09,1e-09,1e-09,1e-09};
-field_values={...
-	(md.results.DiagnosticSolution.Vx),...
-	(md.results.DiagnosticSolution.Vy),...
-	(md.results.DiagnosticSolution.Vz),...
-	(md.results.DiagnosticSolution.Vel),...
-	(md.results.DiagnosticSolution.Pressure),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test243.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test243.m	(revision 12167)
+++ 	(revision )
@@ -1,34 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',150000);
-md=setmask(md,'all','');
-md=parameterize(md,'../Par/SquareShelf.par');
-md=setflowequation(md,'macayeal','all');
-md.cluster=none;
-md.prognostic.hydrostatic_adjustment='Incremental';
-md=solve(md,TransientSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Vx1','Vy1','Vel1','Pressure1','Bed1','Surface1','Thickness1','Vx2','Vy2','Vel2','Pressure2','Bed2','Surface2','Thickness2','Vx3','Vy3','Vel3','Pressure3','Bed3','Surface3','Thickness3'};
-field_tolerances={1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13};
-field_values={...
-	(md.results.TransientSolution(1).Vx),...
-	(md.results.TransientSolution(1).Vy),...
-	(md.results.TransientSolution(1).Vel),...
-	(md.results.TransientSolution(1).Pressure),...
-	(md.results.TransientSolution(1).Bed),...
-	(md.results.TransientSolution(1).Surface),...
-	(md.results.TransientSolution(1).Thickness),...
-	(md.results.TransientSolution(2).Vx),...
-	(md.results.TransientSolution(2).Vy),...
-	(md.results.TransientSolution(2).Vel),...
-	(md.results.TransientSolution(2).Pressure),...
-	(md.results.TransientSolution(2).Bed),...
-	(md.results.TransientSolution(2).Surface),...
-	(md.results.TransientSolution(2).Thickness),...
-	(md.results.TransientSolution(3).Vx),...
-	(md.results.TransientSolution(3).Vy),...
-	(md.results.TransientSolution(3).Vel),...
-	(md.results.TransientSolution(3).Pressure),...
-	(md.results.TransientSolution(3).Bed),...
-	(md.results.TransientSolution(3).Surface),...
-	(md.results.TransientSolution(3).Thickness),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test245.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test245.m	(revision 12167)
+++ 	(revision )
@@ -1,35 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',150000);
-md=setmask(md,'all','');
-md=parameterize(md,'../Par/SquareShelf.par');
-md=setflowequation(md,'macayeal','all');
-md.geometry.bed=md.geometry.bed+50; md.geometry.surface=md.geometry.surface+50;
-md.cluster=none;
-md.prognostic.hydrostatic_adjustment='Incremental';
-md=solve(md,TransientSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Vx1','Vy1','Vel1','Pressure1','Bed1','Surface1','Thickness1','Vx2','Vy2','Vel2','Pressure2','Bed2','Surface2','Thickness2','Vx3','Vy3','Vel3','Pressure3','Bed3','Surface3','Thickness3'};
-field_tolerances={1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13};
-field_values={...
-	(md.results.TransientSolution(1).Vx),...
-	(md.results.TransientSolution(1).Vy),...
-	(md.results.TransientSolution(1).Vel),...
-	(md.results.TransientSolution(1).Pressure),...
-	(md.results.TransientSolution(1).Bed),...
-	(md.results.TransientSolution(1).Surface),...
-	(md.results.TransientSolution(1).Thickness),...
-	(md.results.TransientSolution(2).Vx),...
-	(md.results.TransientSolution(2).Vy),...
-	(md.results.TransientSolution(2).Vel),...
-	(md.results.TransientSolution(2).Pressure),...
-	(md.results.TransientSolution(2).Bed),...
-	(md.results.TransientSolution(2).Surface),...
-	(md.results.TransientSolution(2).Thickness),...
-	(md.results.TransientSolution(3).Vx),...
-	(md.results.TransientSolution(3).Vy),...
-	(md.results.TransientSolution(3).Vel),...
-	(md.results.TransientSolution(3).Pressure),...
-	(md.results.TransientSolution(3).Bed),...
-	(md.results.TransientSolution(3).Surface),...
-	(md.results.TransientSolution(3).Thickness),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test247.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test247.m	(revision 12167)
+++ 	(revision )
@@ -1,46 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',200000);
-md=setmask(md,'all','');
-md=parameterize(md,'../Par/SquareShelf.par');
-md=extrude(md,3,1);
-md=setflowequation(md,'pattyn','all');
-md.cluster=none;
-md.prognostic.hydrostatic_adjustment='Incremental';
-md=solve(md,TransientSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Vx1','Vy1','Vz1','Vel1','Pressure1','Bed1','Surface1','Thickness1','Temperature1','BasalforcingsMeltingRate1', ...
-				      'Vx2','Vy2','Vz2','Vel2','Pressure2','Bed2','Surface2','Thickness2','Temperature2','BasalforcingsMeltingRate2', ...
-					   'Vx3','Vy3','Vz3','Vel3','Pressure3','Bed3','Surface3','Thickness3','Temperature3','BasalforcingsMeltingRate3'};
-field_tolerances={1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-06};
-field_values={...
-	(md.results.TransientSolution(1).Vx),...
-	(md.results.TransientSolution(1).Vy),...
-	(md.results.TransientSolution(1).Vz),...
-	(md.results.TransientSolution(1).Vel),...
-	(md.results.TransientSolution(1).Pressure),...
-	(md.results.TransientSolution(1).Bed),...
-	(md.results.TransientSolution(1).Surface),...
-	(md.results.TransientSolution(1).Thickness),...
-	(md.results.TransientSolution(1).Temperature),...
-	(md.results.TransientSolution(1).BasalforcingsMeltingRate),...
-	(md.results.TransientSolution(2).Vx),...
-	(md.results.TransientSolution(2).Vy),...
-	(md.results.TransientSolution(2).Vz),...
-	(md.results.TransientSolution(2).Vel),...
-	(md.results.TransientSolution(2).Pressure),...
-	(md.results.TransientSolution(2).Bed),...
-	(md.results.TransientSolution(2).Surface),...
-	(md.results.TransientSolution(2).Thickness),...
-	(md.results.TransientSolution(2).Temperature),...
-	(md.results.TransientSolution(2).BasalforcingsMeltingRate),...
-	(md.results.TransientSolution(3).Vx),...
-	(md.results.TransientSolution(3).Vy),...
-	(md.results.TransientSolution(3).Vz),...
-	(md.results.TransientSolution(3).Vel),...
-	(md.results.TransientSolution(3).Pressure),...
-	(md.results.TransientSolution(3).Bed),...
-	(md.results.TransientSolution(3).Surface),...
-	(md.results.TransientSolution(3).Thickness),...
-	(md.results.TransientSolution(3).Temperature),...
-	(md.results.TransientSolution(3).BasalforcingsMeltingRate),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test249.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test249.m	(revision 12167)
+++ 	(revision )
@@ -1,47 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',200000);
-md=setmask(md,'all','');
-md=parameterize(md,'../Par/SquareShelf.par');
-md=extrude(md,3,1);
-md=setflowequation(md,'pattyn','all');
-md.geometry.bed=md.geometry.bed+50; md.geometry.surface=md.geometry.surface+50;
-md.cluster=none;
-md.prognostic.hydrostatic_adjustment='Incremental';
-md=solve(md,TransientSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Vx1','Vy1','Vz1','Vel1','Pressure1','Bed1','Surface1','Thickness1','Temperature1','BasalforcingsMeltingRate1', ...
-				      'Vx2','Vy2','Vz2','Vel2','Pressure2','Bed2','Surface2','Thickness2','Temperature2','BasalforcingsMeltingRate2', ...
-					   'Vx3','Vy3','Vz3','Vel3','Pressure3','Bed3','Surface3','Thickness3','Temperature3','BasalforcingsMeltingRate3'};
-field_tolerances={1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-06};
-field_values={...
-	(md.results.TransientSolution(1).Vx),...
-	(md.results.TransientSolution(1).Vy),...
-	(md.results.TransientSolution(1).Vz),...
-	(md.results.TransientSolution(1).Vel),...
-	(md.results.TransientSolution(1).Pressure),...
-	(md.results.TransientSolution(1).Bed),...
-	(md.results.TransientSolution(1).Surface),...
-	(md.results.TransientSolution(1).Thickness),...
-	(md.results.TransientSolution(1).Temperature),...
-	(md.results.TransientSolution(1).BasalforcingsMeltingRate),...
-	(md.results.TransientSolution(2).Vx),...
-	(md.results.TransientSolution(2).Vy),...
-	(md.results.TransientSolution(2).Vz),...
-	(md.results.TransientSolution(2).Vel),...
-	(md.results.TransientSolution(2).Pressure),...
-	(md.results.TransientSolution(2).Bed),...
-	(md.results.TransientSolution(2).Surface),...
-	(md.results.TransientSolution(2).Thickness),...
-	(md.results.TransientSolution(2).Temperature),...
-	(md.results.TransientSolution(2).BasalforcingsMeltingRate),...
-	(md.results.TransientSolution(3).Vx),...
-	(md.results.TransientSolution(3).Vy),...
-	(md.results.TransientSolution(3).Vz),...
-	(md.results.TransientSolution(3).Vel),...
-	(md.results.TransientSolution(3).Pressure),...
-	(md.results.TransientSolution(3).Bed),...
-	(md.results.TransientSolution(3).Surface),...
-	(md.results.TransientSolution(3).Thickness),...
-	(md.results.TransientSolution(3).Temperature),...
-	(md.results.TransientSolution(3).BasalforcingsMeltingRate),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test251.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test251.m	(revision 12167)
+++ 	(revision )
@@ -1,35 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',150000);
-md=setmask(md,'all','');
-md=parameterize(md,'../Par/SquareShelf.par');
-md=setflowequation(md,'macayeal','all');
-md.cluster=none;
-md.timestepping.time_adapt=1;
-md.timestepping.final_time=10;
-md=solve(md,TransientSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Vx1','Vy1','Vel1','Pressure1','Bed1','Surface1','Thickness1','Vx2','Vy2','Vel2','Pressure2','Bed2','Surface2','Thickness2','Vx3','Vy3','Vel3','Pressure3','Bed3','Surface3','Thickness3'};
-field_tolerances={1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13};
-field_values={...
-	(md.results.TransientSolution(1).Vx),...
-	(md.results.TransientSolution(1).Vy),...
-	(md.results.TransientSolution(1).Vel),...
-	(md.results.TransientSolution(1).Pressure),...
-	(md.results.TransientSolution(1).Bed),...
-	(md.results.TransientSolution(1).Surface),...
-	(md.results.TransientSolution(1).Thickness),...
-	(md.results.TransientSolution(2).Vx),...
-	(md.results.TransientSolution(2).Vy),...
-	(md.results.TransientSolution(2).Vel),...
-	(md.results.TransientSolution(2).Pressure),...
-	(md.results.TransientSolution(2).Bed),...
-	(md.results.TransientSolution(2).Surface),...
-	(md.results.TransientSolution(2).Thickness),...
-	(md.results.TransientSolution(3).Vx),...
-	(md.results.TransientSolution(3).Vy),...
-	(md.results.TransientSolution(3).Vel),...
-	(md.results.TransientSolution(3).Pressure),...
-	(md.results.TransientSolution(3).Bed),...
-	(md.results.TransientSolution(3).Surface),...
-	(md.results.TransientSolution(3).Thickness),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test253.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test253.m	(revision 12167)
+++ 	(revision )
@@ -1,49 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',200000);
-md=setmask(md,'all','');
-md=parameterize(md,'../Par/SquareShelf.par');
-md=extrude(md,3,1);
-md=setflowequation(md,'pattyn','all');
-md.cluster=none;
-md.timestepping.time_adapt=1;
-md.timestepping.final_time=10;
-md=solve(md,TransientSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Vx1','Vy1','Vz1','Vel1','Pressure1','Bed1','Surface1','Thickness1','Temperature1','BasalforcingsMeltingRate1', ...
-				      'Vx2','Vy2','Vz2','Vel2','Pressure2','Bed2','Surface2','Thickness2','Temperature2','BasalforcingsMeltingRate2', ...
-					   'Vx3','Vy3','Vz3','Vel3','Pressure3','Bed3','Surface3','Thickness3','Temperature3','BasalforcingsMeltingRate3'};
-field_tolerances={1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,...
-						1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,...
-						1e-09,1e-09,1e-08,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-06};
-field_values={...
-	(md.results.TransientSolution(1).Vx),...
-	(md.results.TransientSolution(1).Vy),...
-	(md.results.TransientSolution(1).Vz),...
-	(md.results.TransientSolution(1).Vel),...
-	(md.results.TransientSolution(1).Pressure),...
-	(md.results.TransientSolution(1).Bed),...
-	(md.results.TransientSolution(1).Surface),...
-	(md.results.TransientSolution(1).Thickness),...
-	(md.results.TransientSolution(1).Temperature),...
-	(md.results.TransientSolution(1).BasalforcingsMeltingRate),...
-	(md.results.TransientSolution(2).Vx),...
-	(md.results.TransientSolution(2).Vy),...
-	(md.results.TransientSolution(2).Vz),...
-	(md.results.TransientSolution(2).Vel),...
-	(md.results.TransientSolution(2).Pressure),...
-	(md.results.TransientSolution(2).Bed),...
-	(md.results.TransientSolution(2).Surface),...
-	(md.results.TransientSolution(2).Thickness),...
-	(md.results.TransientSolution(2).Temperature),...
-	(md.results.TransientSolution(2).BasalforcingsMeltingRate),...
-	(md.results.TransientSolution(3).Vx),...
-	(md.results.TransientSolution(3).Vy),...
-	(md.results.TransientSolution(3).Vz),...
-	(md.results.TransientSolution(3).Vel),...
-	(md.results.TransientSolution(3).Pressure),...
-	(md.results.TransientSolution(3).Bed),...
-	(md.results.TransientSolution(3).Surface),...
-	(md.results.TransientSolution(3).Thickness),...
-	(md.results.TransientSolution(3).Temperature),...
-	(md.results.TransientSolution(3).BasalforcingsMeltingRate),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test255.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test255.m	(revision 12167)
+++ 	(revision )
@@ -1,64 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',150000);
-md=setmask(md,'all','');
-md=parameterize(md,'../Par/SquareShelf.par');
-md=setflowequation(md,'macayeal','all');
-md.cluster=none;
-
-md.timestepping.time_step=1;
-md.settings.output_frequency=1;
-md.timestepping.final_time=4;
-
-%Set up transient
-smb = ones(md.mesh.numberofvertices,1)*3.6;
-smb=[ smb smb*-1 ];
-
-md.surfaceforcings.mass_balance= smb;
-md.surfaceforcings.mass_balance(end+1,:)=[1.5 3];
-md.transient.isthermal=0;
-
-md=solve(md,TransientSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names={'Vx1','Vy1','Vel1','Pressure1','Bed1','Surface1','Thickness1','SurfaceforcingsMassBalance1', ...
-	'Vx2','Vy2','Vel2','Pressure2','Bed2','Surface2','Thickness2','SurfaceforcingsMassBalance2', ...
-	'Vx3','Vy3','Vel3','Pressure3','Bed3','Surface3','Thickness3','SurfaceforcingsMassBalance3', ...
-	'Vx4','Vy4','Vel4','Pressure4','Bed4','Surface4','Thickness4','SurfaceforcingsMassBalance4'};
-field_tolerances={1e-09,1e-09,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,...
-	1e-09,1e-09,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,...
-	1e-09,1e-09,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,...
-	1e-09,1e-09,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10};
-
-field_values={...
-	(md.results.TransientSolution(1).Vx),...
-	(md.results.TransientSolution(1).Vy),...
-	(md.results.TransientSolution(1).Vel),...
-	(md.results.TransientSolution(1).Pressure),...
-	(md.results.TransientSolution(1).Bed),...
-	(md.results.TransientSolution(1).Surface),...
-	(md.results.TransientSolution(1).Thickness),...
-	(md.results.TransientSolution(1).SurfaceforcingsMassBalance),...
-	(md.results.TransientSolution(2).Vx),...
-	(md.results.TransientSolution(2).Vy),...
-	(md.results.TransientSolution(2).Vel),...
-	(md.results.TransientSolution(2).Pressure),...
-	(md.results.TransientSolution(2).Bed),...
-	(md.results.TransientSolution(2).Surface),...
-	(md.results.TransientSolution(2).Thickness),...
-	(md.results.TransientSolution(2).SurfaceforcingsMassBalance),...
-	(md.results.TransientSolution(3).Vx),...
-	(md.results.TransientSolution(3).Vy),...
-	(md.results.TransientSolution(3).Vel),...
-	(md.results.TransientSolution(3).Pressure),...
-	(md.results.TransientSolution(3).Bed),...
-	(md.results.TransientSolution(3).Surface),...
-	(md.results.TransientSolution(3).Thickness),...
-	(md.results.TransientSolution(3).SurfaceforcingsMassBalance),...
-	(md.results.TransientSolution(4).Vx),...
-	(md.results.TransientSolution(4).Vy),...
-	(md.results.TransientSolution(4).Vel),...
-	(md.results.TransientSolution(4).Pressure),...
-	(md.results.TransientSolution(4).Bed),...
-	(md.results.TransientSolution(4).Surface),...
-	(md.results.TransientSolution(4).Thickness),...
-	(md.results.TransientSolution(4).SurfaceforcingsMassBalance),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test257.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test257.m	(revision 12167)
+++ 	(revision )
@@ -1,64 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',150000);
-md=setmask(md,'all','');
-md=parameterize(md,'../Par/SquareShelf.par');
-md=setflowequation(md,'macayeal','all');
-md.cluster=none;
-
-md.timestepping.time_step=1;
-md.settings.output_frequency=1;
-md.timestepping.final_time=4;
-
-%Set up transient
-smb = ones(md.mesh.numberofvertices,1)*3.6;
-smb=[ smb smb*2 ];
-
-md.surfaceforcings.mass_balance= smb;
-md.surfaceforcings.mass_balance(end+1,:)=[1.5 3];
-md.transient.isthermal=0;
-
-md=solve(md,TransientSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names={'Vx1','Vy1','Vel1','Pressure1','Bed1','Surface1','Thickness1','SurfaceforcingsMassBalance1', ...
-	'Vx2','Vy2','Vel2','Pressure2','Bed2','Surface2','Thickness2','SurfaceforcingsMassBalance2', ...
-	'Vx3','Vy3','Vel3','Pressure3','Bed3','Surface3','Thickness3','SurfaceforcingsMassBalance3', ...
-	'Vx4','Vy4','Vel4','Pressure4','Bed4','Surface4','Thickness4','SurfaceforcingsMassBalance4'};
-field_tolerances={1e-09,1e-09,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,...
-	1e-09,1e-09,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,...
-	1e-09,1e-09,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,...
-	1e-09,1e-09,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10};
-
-field_values={...
-	(md.results.TransientSolution(1).Vx),...
-	(md.results.TransientSolution(1).Vy),...
-	(md.results.TransientSolution(1).Vel),...
-	(md.results.TransientSolution(1).Pressure),...
-	(md.results.TransientSolution(1).Bed),...
-	(md.results.TransientSolution(1).Surface),...
-	(md.results.TransientSolution(1).Thickness),...
-	(md.results.TransientSolution(1).SurfaceforcingsMassBalance),...
-	(md.results.TransientSolution(2).Vx),...
-	(md.results.TransientSolution(2).Vy),...
-	(md.results.TransientSolution(2).Vel),...
-	(md.results.TransientSolution(2).Pressure),...
-	(md.results.TransientSolution(2).Bed),...
-	(md.results.TransientSolution(2).Surface),...
-	(md.results.TransientSolution(2).Thickness),...
-	(md.results.TransientSolution(2).SurfaceforcingsMassBalance),...
-	(md.results.TransientSolution(3).Vx),...
-	(md.results.TransientSolution(3).Vy),...
-	(md.results.TransientSolution(3).Vel),...
-	(md.results.TransientSolution(3).Pressure),...
-	(md.results.TransientSolution(3).Bed),...
-	(md.results.TransientSolution(3).Surface),...
-	(md.results.TransientSolution(3).Thickness),...
-	(md.results.TransientSolution(3).SurfaceforcingsMassBalance),...
-	(md.results.TransientSolution(4).Vx),...
-	(md.results.TransientSolution(4).Vy),...
-	(md.results.TransientSolution(4).Vel),...
-	(md.results.TransientSolution(4).Pressure),...
-	(md.results.TransientSolution(4).Bed),...
-	(md.results.TransientSolution(4).Surface),...
-	(md.results.TransientSolution(4).Thickness),...
-	(md.results.TransientSolution(4).SurfaceforcingsMassBalance),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test259.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test259.m	(revision 12167)
+++ 	(revision )
@@ -1,69 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',350000);
-md=setmask(md,'all','');
-md=parameterize(md,'../Par/SquareShelf.par');
-md=extrude(md,3,1);
-md=setflowequation(md,'macayeal','all');
-md.cluster=none;
-
-md.timestepping.time_step=1;
-md.settings.output_frequency=1;
-md.timestepping.final_time=4;
-
-%Set up transient
-smb = ones(md.mesh.numberofvertices,1)*3.6;
-smb=[ smb smb*-1 ];
-
-md.surfaceforcings.mass_balance= smb;
-md.surfaceforcings.mass_balance(end+1,:)=[1.5 3];
-md.transient.isthermal=0;
-
-md=solve(md,TransientSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Vx1','Vy1','Vz1','Vel1','Pressure1','Bed1','Surface1','Thickness1','SurfaceforcingsMassBalance1', ...
-	'Vx2','Vy2','Vz2','Vel2','Pressure2','Bed2','Surface2','Thickness2','SurfaceforcingsMassBalance2', ...
-	'Vx3','Vy3','Vz3','Vel3','Pressure3','Bed3','Surface3','Thickness3','SurfaceforcingsMassBalance3',...
-	'Vx4','Vy4','Vz4','Vel4','Pressure4','Bed4','Surface4','Thickness4','SurfaceMassbalance4'};
-field_tolerances={1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,...
-	1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,...
-	1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,...
-	1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13};
-
-field_values={...
-	(md.results.TransientSolution(1).Vx),...
-	(md.results.TransientSolution(1).Vy),...
-	(md.results.TransientSolution(1).Vz),...
-	(md.results.TransientSolution(1).Vel),...
-	(md.results.TransientSolution(1).Pressure),...
-	(md.results.TransientSolution(1).Bed),...
-	(md.results.TransientSolution(1).Surface),...
-	(md.results.TransientSolution(1).Thickness),...
-	(md.results.TransientSolution(1).SurfaceforcingsMassBalance),...
-	(md.results.TransientSolution(2).Vx),...
-	(md.results.TransientSolution(2).Vy),...
-	(md.results.TransientSolution(2).Vz),...
-	(md.results.TransientSolution(2).Vel),...
-	(md.results.TransientSolution(2).Pressure),...
-	(md.results.TransientSolution(2).Bed),...
-	(md.results.TransientSolution(2).Surface),...
-	(md.results.TransientSolution(2).Thickness),...
-	(md.results.TransientSolution(2).SurfaceforcingsMassBalance),...
-	(md.results.TransientSolution(3).Vx),...
-	(md.results.TransientSolution(3).Vy),...
-	(md.results.TransientSolution(3).Vz),...
-	(md.results.TransientSolution(3).Vel),...
-	(md.results.TransientSolution(3).Pressure),...
-	(md.results.TransientSolution(3).Bed),...
-	(md.results.TransientSolution(3).Surface),...
-	(md.results.TransientSolution(3).Thickness),...
-	(md.results.TransientSolution(3).SurfaceforcingsMassBalance),...
-	(md.results.TransientSolution(4).Vx),...
-	(md.results.TransientSolution(4).Vy),...
-	(md.results.TransientSolution(4).Vz),...
-	(md.results.TransientSolution(4).Vel),...
-	(md.results.TransientSolution(4).Pressure),...
-	(md.results.TransientSolution(4).Bed),...
-	(md.results.TransientSolution(4).Surface),...
-	(md.results.TransientSolution(4).Thickness),...
-	(md.results.TransientSolution(4).SurfaceforcingsMassBalance),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test261.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test261.m	(revision 12167)
+++ 	(revision )
@@ -1,69 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',350000);
-md=setmask(md,'all','');
-md=parameterize(md,'../Par/SquareShelf.par');
-md=extrude(md,3,1);
-md=setflowequation(md,'macayeal','all');
-md.cluster=none;
-
-md.timestepping.time_step=1;
-md.settings.output_frequency=1;
-md.timestepping.final_time=4;
-
-%Set up transient
-smb = ones(md.mesh.numberofvertices,1)*3.6;
-smb=[ smb smb*2 ];
-
-md.surfaceforcings.mass_balance= smb;
-md.surfaceforcings.mass_balance(end+1,:)=[1.5 3];
-md.transient.isthermal=0;
-
-md=solve(md,TransientSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Vx1','Vy1','Vz1','Vel1','Pressure1','Bed1','Surface1','Thickness1','SurfaceforcingsMassBalance1', ...
-	'Vx2','Vy2','Vz2','Vel2','Pressure2','Bed2','Surface2','Thickness2','SurfaceforcingsMassBalance2', ...
-	'Vx3','Vy3','Vz3','Vel3','Pressure3','Bed3','Surface3','Thickness3','SurfaceforcingsMassBalance3',...
-	'Vx4','Vy4','Vz4','Vel4','Pressure4','Bed4','Surface4','Thickness4','SurfaceMassbalance4'};
-field_tolerances={1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,...
-	1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,...
-	1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,...
-	1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13};
-
-field_values={...
-	(md.results.TransientSolution(1).Vx),...
-	(md.results.TransientSolution(1).Vy),...
-	(md.results.TransientSolution(1).Vz),...
-	(md.results.TransientSolution(1).Vel),...
-	(md.results.TransientSolution(1).Pressure),...
-	(md.results.TransientSolution(1).Bed),...
-	(md.results.TransientSolution(1).Surface),...
-	(md.results.TransientSolution(1).Thickness),...
-	(md.results.TransientSolution(1).SurfaceforcingsMassBalance),...
-	(md.results.TransientSolution(2).Vx),...
-	(md.results.TransientSolution(2).Vy),...
-	(md.results.TransientSolution(2).Vz),...
-	(md.results.TransientSolution(2).Vel),...
-	(md.results.TransientSolution(2).Pressure),...
-	(md.results.TransientSolution(2).Bed),...
-	(md.results.TransientSolution(2).Surface),...
-	(md.results.TransientSolution(2).Thickness),...
-	(md.results.TransientSolution(2).SurfaceforcingsMassBalance),...
-	(md.results.TransientSolution(3).Vx),...
-	(md.results.TransientSolution(3).Vy),...
-	(md.results.TransientSolution(3).Vz),...
-	(md.results.TransientSolution(3).Vel),...
-	(md.results.TransientSolution(3).Pressure),...
-	(md.results.TransientSolution(3).Bed),...
-	(md.results.TransientSolution(3).Surface),...
-	(md.results.TransientSolution(3).Thickness),...
-	(md.results.TransientSolution(3).SurfaceforcingsMassBalance),...
-	(md.results.TransientSolution(4).Vx),...
-	(md.results.TransientSolution(4).Vy),...
-	(md.results.TransientSolution(4).Vz),...
-	(md.results.TransientSolution(4).Vel),...
-	(md.results.TransientSolution(4).Pressure),...
-	(md.results.TransientSolution(4).Bed),...
-	(md.results.TransientSolution(4).Surface),...
-	(md.results.TransientSolution(4).Thickness),...
-	(md.results.TransientSolution(4).SurfaceforcingsMassBalance),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test263.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test263.m	(revision 12167)
+++ 	(revision )
@@ -1,28 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',180000);
-md=setmask(md,'all','');
-md=parameterize(md,'../Par/SquareShelf.par');
-md=extrude(md,3,1);
-md=setflowequation(md,'macayeal','all');
-md.cluster=none;
-md.thermal.spctemperature=[md.thermal.spctemperature, md.thermal.spctemperature+5, md.thermal.spctemperature+10, md.thermal.spctemperature+15; 1.5 2.5 3.5 4];
-md.timestepping.time_step=1;
-md.timestepping.final_time=4;
-md.transient.isdiagnostic=0;
-md.transient.isprognostic=0;
-md.transient.isthermal=1;
-md.transient.isgroundingline=0;
-md=solve(md,TransientSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Temperature1','BasalforcingsMeltingRate1','Temperature2','BasalforcingsMeltingRate2','Temperature3','BasalforcingsMeltingRate3','Temperature4','BasalforcingsMeltingRate4'};
-field_tolerances={1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13};
-field_values={...
-	(md.results.TransientSolution(1).Temperature),...
-	(md.results.TransientSolution(1).BasalforcingsMeltingRate),...
-	(md.results.TransientSolution(2).Temperature),...
-	(md.results.TransientSolution(2).BasalforcingsMeltingRate),...
-	(md.results.TransientSolution(3).Temperature),...
-	(md.results.TransientSolution(3).BasalforcingsMeltingRate),...
-	(md.results.TransientSolution(4).Temperature),...
-	(md.results.TransientSolution(4).BasalforcingsMeltingRate),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test265.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test265.m	(revision 12167)
+++ 	(revision )
@@ -1,62 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',200000);
-md=setmask(md,'all','');
-md=parameterize(md,'../Par/SquareShelf.par');
-md=extrude(md,3,1);
-md=setflowequation(md,'pattyn','all');
-md.cluster=none;
-md.thermal.spctemperature=[md.thermal.spctemperature, md.thermal.spctemperature+5; 1 2];
-md.timestepping.time_step=0.5;
-md.timestepping.final_time=2;
-md=solve(md,TransientSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Vx1','Vy1','Vz1','Vel1','Pressure1','Bed1','Surface1','Thickness1','Temperature1','BasalforcingsMeltingRate1', ...
-				      'Vx2','Vy2','Vz2','Vel2','Pressure2','Bed2','Surface2','Thickness2','Temperature2','BasalforcingsMeltingRate2', ...
-					   'Vx3','Vy3','Vz3','Vel3','Pressure3','Bed3','Surface3','Thickness3','Temperature3','BasalforcingsMeltingRate3',...
-					   'Vx4','Vy4','Vz4','Vel4','Pressure4','Bed4','Surface4','Thickness4','Temperature4','BasalforcingsMeltingRate4'};
-field_tolerances={1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09, ...
-						1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09, ...
-						1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09, ...
-						1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-06};
-field_values={...
-	(md.results.TransientSolution(1).Vx),...
-	(md.results.TransientSolution(1).Vy),...
-	(md.results.TransientSolution(1).Vz),...
-	(md.results.TransientSolution(1).Vel),...
-	(md.results.TransientSolution(1).Pressure),...
-	(md.results.TransientSolution(1).Bed),...
-	(md.results.TransientSolution(1).Surface),...
-	(md.results.TransientSolution(1).Thickness),...
-	(md.results.TransientSolution(1).Temperature),...
-	(md.results.TransientSolution(1).BasalforcingsMeltingRate),...
-	(md.results.TransientSolution(2).Vx),...
-	(md.results.TransientSolution(2).Vy),...
-	(md.results.TransientSolution(2).Vz),...
-	(md.results.TransientSolution(2).Vel),...
-	(md.results.TransientSolution(2).Pressure),...
-	(md.results.TransientSolution(2).Bed),...
-	(md.results.TransientSolution(2).Surface),...
-	(md.results.TransientSolution(2).Thickness),...
-	(md.results.TransientSolution(2).Temperature),...
-	(md.results.TransientSolution(2).BasalforcingsMeltingRate),...
-	(md.results.TransientSolution(3).Vx),...
-	(md.results.TransientSolution(3).Vy),...
-	(md.results.TransientSolution(3).Vz),...
-	(md.results.TransientSolution(3).Vel),...
-	(md.results.TransientSolution(3).Pressure),...
-	(md.results.TransientSolution(3).Bed),...
-	(md.results.TransientSolution(3).Surface),...
-	(md.results.TransientSolution(3).Thickness),...
-	(md.results.TransientSolution(3).Temperature),...
-	(md.results.TransientSolution(3).BasalforcingsMeltingRate),...
-	(md.results.TransientSolution(4).Vx),...
-	(md.results.TransientSolution(4).Vy),...
-	(md.results.TransientSolution(4).Vz),...
-	(md.results.TransientSolution(4).Vel),...
-	(md.results.TransientSolution(4).Pressure),...
-	(md.results.TransientSolution(4).Bed),...
-	(md.results.TransientSolution(4).Surface),...
-	(md.results.TransientSolution(4).Thickness),...
-	(md.results.TransientSolution(4).Temperature),...
-	(md.results.TransientSolution(4).BasalforcingsMeltingRate),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test267.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test267.m	(revision 12167)
+++ 	(revision )
@@ -1,72 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',180000);
-md=setmask(md,'all','');
-md=parameterize(md,'../Par/SquareShelf.par');
-md=setflowequation(md,'macayeal','all');
-md.cluster=generic('name',oshostname(),'np',3);
-
-md.timestepping.time_step=1;
-md.settings.output_frequency=1;
-md.timestepping.final_time=4;
-
-smb = ones(md.mesh.numberofvertices,1)*3.6;
-smb=[ smb smb*-1 ];
-
-md.surfaceforcings.mass_balance= smb;
-md.surfaceforcings.mass_balance(end+1,:)=[1.5 3];
-md.transient.isthermal=0;
-%Dakota options
-
-%partitioning
-md.qmu.numberofpartitions=20;
-md=partitioner(md,'package','chaco','npart',md.qmu.numberofpartitions,'weighting','on');
-md.qmu.partition=md.qmu.partition-1;
-
-%variables
-md.qmu.variables.surface_mass_balance=normal_uncertain('scaled_SurfaceforcingsMassBalance',1,0.1);
-
-%responses
-md.qmu.responses.MaxVel=response_function('MaxVel',[],[0.0001 0.001 0.01 0.25 0.5 0.75 0.99 0.999 0.9999]);
-md.qmu.responses.IceVolume=response_function('IceVolume',[],[0.0001 0.001 0.01 0.25 0.5 0.75 0.99 0.999 0.9999]);
-md.qmu.responses.MassFlux1=response_function('indexed_MassFlux_1',[],[0.0001 0.001 0.01 0.25 0.5 0.75 0.99 0.999 0.9999]);
-md.qmu.responses.MassFlux2=response_function('indexed_MassFlux_2',[],[0.0001 0.001 0.01 0.25 0.5 0.75 0.99 0.999 0.9999]);
-md.qmu.responses.MassFlux3=response_function('indexed_MassFlux_3',[],[0.0001 0.001 0.01 0.25 0.5 0.75 0.99 0.999 0.9999]);
-md.qmu.responses.MassFlux4=response_function('indexed_MassFlux_4',[],[0.0001 0.001 0.01 0.25 0.5 0.75 0.99 0.999 0.9999]);
-md.qmu.responses.MassFlux5=response_function('indexed_MassFlux_5',[],[0.0001 0.001 0.01 0.25 0.5 0.75 0.99 0.999 0.9999]);
-md.qmu.responses.massFlux6=response_function('indexed_MassFlux_6',[],[0.0001 0.001 0.01 0.25 0.5 0.75 0.99 0.999 0.9999]);
-
-%mass flux profiles
-md.qmu.mass_flux_profiles={'../Exp/MassFlux1.exp','../Exp/MassFlux2.exp','../Exp/MassFlux3.exp','../Exp/MassFlux4.exp','../Exp/MassFlux5.exp','../Exp/MassFlux6.exp'};
-md.qmu.mass_flux_profile_directory=pwd;
-
-%%  nond_sampling study
-md.qmu.method=dakota_method('nond_samp');
-md.qmu.method(end)=dmeth_params_set(md.qmu.method(end),'seed',1234,'samples',20,'sample_type','lhs');
-
-%parameters
-md.qmu.params.direct=true;
-md.qmu.params.analysis_driver='';
-md.qmu.params.analysis_components='';
-md.qmu.params.evaluation_concurrency=1;
-md.qmu.params.interval_type='forward';
-md.qmu.isdakota=1;
-
-md.diagnostic.reltol=10^-5; %tighten for qmu analyses
-md.transient.requested_outputs=IceVolumeEnum();
-
-%solve
-md=solve(md,TransientSolutionEnum,'overwrite','y');
-md=tres(md,'dakota');
-
-%Fields and tolerances to track changes
-md.results.dakota.importancefactors=[];
-for i=1:8,
-	md.results.dakota.importancefactors=[md.results.dakota.importancefactors md.results.dakota.dresp_out(i).mean];
-end
-for i=1:8,
-	md.results.dakota.importancefactors=[md.results.dakota.importancefactors md.results.dakota.dresp_out(i).stddev];
-end
-field_names     ={'importancefactors'};
-field_tolerances={1e-11};
-field_values={...
-         md.results.dakota.importancefactors,...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test301.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test301.m	(revision 12167)
+++ 	(revision )
@@ -1,16 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',150000);
-md=setmask(md,'','');
-md=parameterize(md,'../Par/SquareSheetConstrained.par');
-md=setflowequation(md,'macayeal','all');
-md.cluster=none;
-md=solve(md,DiagnosticSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Vx','Vy','Vel','Pressure'};
-field_tolerances={1e-13,1e-13,1e-13,1e-13};
-field_values={...
-	(md.results.DiagnosticSolution.Vx),...
-	(md.results.DiagnosticSolution.Vy),...
-	(md.results.DiagnosticSolution.Vel),...
-	(md.results.DiagnosticSolution.Pressure),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test303.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test303.m	(revision 12167)
+++ 	(revision )
@@ -1,16 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',150000);
-md=setmask(md,'','');
-md=parameterize(md,'../Par/SquareSheetConstrained.par');
-md=setflowequation(md,'hutter','all');
-md.cluster=none;
-md=solve(md,DiagnosticSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Vx','Vy','Vel','Pressure'};
-field_tolerances={1e-13,1e-13,1e-13,1e-13};
-field_values={...
-	(md.results.DiagnosticSolution.Vx),...
-	(md.results.DiagnosticSolution.Vy),...
-	(md.results.DiagnosticSolution.Vel),...
-	(md.results.DiagnosticSolution.Pressure),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test305.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test305.m	(revision 12167)
+++ 	(revision )
@@ -1,16 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',150000);
-md=setmask(md,'','');
-md=parameterize(md,'../Par/SquareSheetConstrained.par');
-md=setflowequation(md,'hutter','../Exp/SquareHalfRight.exp','fill','macayeal');
-md.cluster=none;
-md=solve(md,DiagnosticSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Vx','Vy','Vel','Pressure'};
-field_tolerances={1e-13,1e-13,1e-13,1e-13};
-field_values={...
-	(md.results.DiagnosticSolution.Vx),...
-	(md.results.DiagnosticSolution.Vy),...
-	(md.results.DiagnosticSolution.Vel),...
-	(md.results.DiagnosticSolution.Pressure),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test307.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test307.m	(revision 12167)
+++ 	(revision )
@@ -1,18 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',180000);
-md=setmask(md,'','');
-md=parameterize(md,'../Par/SquareSheetConstrained.par');
-md=extrude(md,3,2);
-md=setflowequation(md,'macayeal','all');
-md.cluster=none;
-md=solve(md,DiagnosticSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Vx','Vy','Vz','Vel','Pressure'};
-field_tolerances={1e-13,1e-13,1e-13,1e-13,1e-13};
-field_values={...
-	(md.results.DiagnosticSolution.Vx),...
-	(md.results.DiagnosticSolution.Vy),...
-	(md.results.DiagnosticSolution.Vz),...
-	(md.results.DiagnosticSolution.Vel),...
-	(md.results.DiagnosticSolution.Pressure),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test309.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test309.m	(revision 12167)
+++ 	(revision )
@@ -1,18 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',180000);
-md=setmask(md,'','');
-md=parameterize(md,'../Par/SquareSheetConstrained.par');
-md=extrude(md,5,2);
-md=setflowequation(md,'hutter','all');
-md.cluster=none;
-md=solve(md,DiagnosticSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Vx','Vy','Vz','Vel','Pressure'};
-field_tolerances={1e-13,1e-13,1e-13,1e-13,1e-13};
-field_values={...
-	(md.results.DiagnosticSolution.Vx),...
-	(md.results.DiagnosticSolution.Vy),...
-	(md.results.DiagnosticSolution.Vz),...
-	(md.results.DiagnosticSolution.Vel),...
-	(md.results.DiagnosticSolution.Pressure),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test311.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test311.m	(revision 12167)
+++ 	(revision )
@@ -1,18 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',180000);
-md=setmask(md,'','');
-md=parameterize(md,'../Par/SquareSheetConstrained.par');
-md=extrude(md,4,2);
-md=setflowequation(md,'hutter','../Exp/SquareHalfRight.exp','fill','macayeal');
-md.cluster=none;
-md=solve(md,DiagnosticSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Vx','Vy','Vz','Vel','Pressure'};
-field_tolerances={1e-13,1e-13,1e-13,1e-13,1e-13};
-field_values={...
-	(md.results.DiagnosticSolution.Vx),...
-	(md.results.DiagnosticSolution.Vy),...
-	(md.results.DiagnosticSolution.Vz),...
-	(md.results.DiagnosticSolution.Vel),...
-	(md.results.DiagnosticSolution.Pressure),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test313.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test313.m	(revision 12167)
+++ 	(revision )
@@ -1,18 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',180000);
-md=setmask(md,'','');
-md=parameterize(md,'../Par/SquareSheetConstrained.par');
-md=extrude(md,3,1);
-md=setflowequation(md,'pattyn','all');
-md.cluster=none;
-md=solve(md,DiagnosticSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Vx','Vy','Vz','Vel','Pressure'};
-field_tolerances={1e-13,1e-13,1e-13,1e-13,1e-13};
-field_values={...
-	(md.results.DiagnosticSolution.Vx),...
-	(md.results.DiagnosticSolution.Vy),...
-	(md.results.DiagnosticSolution.Vz),...
-	(md.results.DiagnosticSolution.Vel),...
-	(md.results.DiagnosticSolution.Pressure),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test315.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test315.m	(revision 12167)
+++ 	(revision )
@@ -1,18 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',180000);
-md=setmask(md,'','');
-md=parameterize(md,'../Par/SquareSheetConstrained.par');
-md=extrude(md,3,1);
-md.cluster=none;
-md=setflowequation(md,'stokes','all');
-md=solve(md,DiagnosticSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Vx','Vy','Vz','Vel','Pressure'};
-field_tolerances={1e-09,1e-09,1e-09,1e-09,1e-09};
-field_values={...
-	(md.results.DiagnosticSolution.Vx),...
-	(md.results.DiagnosticSolution.Vy),...
-	(md.results.DiagnosticSolution.Vz),...
-	(md.results.DiagnosticSolution.Vel),...
-	(md.results.DiagnosticSolution.Pressure),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test317.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test317.m	(revision 12167)
+++ 	(revision )
@@ -1,13 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',150000);
-md=setmask(md,'','');
-md=parameterize(md,'../Par/SquareSheetConstrained.par');
-md=setflowequation(md,'macayeal','all');
-md.cluster=none;
-md=solve(md,PrognosticSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Thickness'};
-field_tolerances={1e-13};
-field_values={...
-	(md.results.PrognosticSolution.Thickness),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test319.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test319.m	(revision 12167)
+++ 	(revision )
@@ -1,16 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',150000);
-md=meshconvert(md);
-md=setmask(md,'','');
-md=parameterize(md,'../Par/SquareSheetConstrained.par');
-md=setflowequation(md,'macayeal','all');
-md.prognostic.stabilization=3;
-md.prognostic.spcthickness=md.geometry.thickness;
-md.cluster=none;
-md=solve(md,PrognosticSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Thickness'};
-field_tolerances={1e-13};
-field_values={...
-	(md.results.PrognosticSolution.Thickness),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test321.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test321.m	(revision 12167)
+++ 	(revision )
@@ -1,14 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',150000);
-md=setmask(md,'','');
-md=parameterize(md,'../Par/SquareSheetConstrained.par');
-md=setflowequation(md,'macayeal','all');
-md=extrude(md,5,0.5);
-md.cluster=none;
-md=solve(md,PrognosticSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Thickness'};
-field_tolerances={1e-13};
-field_values={...
-	(md.results.PrognosticSolution.Thickness),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test323.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test323.m	(revision 12167)
+++ 	(revision )
@@ -1,16 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',180000);
-md=setmask(md,'','');
-md=parameterize(md,'../Par/SquareSheetConstrained.par');
-md=extrude(md,3,1);
-md=setflowequation(md,'macayeal','all');
-md.timestepping.time_step=0;
-md.cluster=none;
-md=solve(md,ThermalSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Temperature','BasalforcingsMeltingRate'};
-field_tolerances={1e-13,1e-13};
-field_values={...
-	(md.results.ThermalSolution.Temperature),...
-	(md.results.ThermalSolution.BasalforcingsMeltingRate),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test325.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test325.m	(revision 12167)
+++ 	(revision )
@@ -1,19 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',180000);
-md=setmask(md,'','');
-md=parameterize(md,'../Par/SquareSheetConstrained.par');
-md=extrude(md,3,1);
-md=setflowequation(md,'macayeal','all');
-md.cluster=none;
-md.transient.isdiagnostic=0;
-md.transient.isprognostic=0;
-md.transient.isthermal=1;
-md.transient.isgroundingline=0;
-md=solve(md,TransientSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Temperature','BasalforcingsMeltingRate'};
-field_tolerances={1e-13,1e-13};
-field_values={...
-	(md.results.TransientSolution(1).Temperature),...
-	(md.results.TransientSolution(1).BasalforcingsMeltingRate),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test327.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test327.m	(revision 12167)
+++ 	(revision )
@@ -1,37 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',150000);
-md=setmask(md,'','');
-md=parameterize(md,'../Par/SquareSheetConstrained.par');
-md=setflowequation(md,'hutter','all');
-md.cluster=none;
-md=solve(md,TransientSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Vx1','Vy1','Vel1','Pressure1','Bed1','Surface1','Thickness1',...
-						'Vx2','Vy2','Vel2','Pressure2','Bed2','Surface2','Thickness2',...
-						'Vx3','Vy3','Vel3','Pressure3','Bed3','Surface3','Thickness3'};
-field_tolerances={1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,...
-						1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,...
-						1e-10,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13};
-field_values={...
-	(md.results.TransientSolution(1).Vx),...
-	(md.results.TransientSolution(1).Vy),...
-	(md.results.TransientSolution(1).Vel),...
-	(md.results.TransientSolution(1).Pressure),...
-	(md.results.TransientSolution(1).Bed),...
-	(md.results.TransientSolution(1).Surface),...
-	(md.results.TransientSolution(1).Thickness),...
-	(md.results.TransientSolution(2).Vx),...
-	(md.results.TransientSolution(2).Vy),...
-	(md.results.TransientSolution(2).Vel),...
-	(md.results.TransientSolution(2).Pressure),...
-	(md.results.TransientSolution(2).Bed),...
-	(md.results.TransientSolution(2).Surface),...
-	(md.results.TransientSolution(2).Thickness),...
-	(md.results.TransientSolution(3).Vx),...
-	(md.results.TransientSolution(3).Vy),...
-	(md.results.TransientSolution(3).Vel),...
-	(md.results.TransientSolution(3).Pressure),...
-	(md.results.TransientSolution(3).Bed),...
-	(md.results.TransientSolution(3).Surface),...
-	(md.results.TransientSolution(3).Thickness),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test329.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test329.m	(revision 12167)
+++ 	(revision )
@@ -1,47 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',150000);
-md=setmask(md,'','');
-md=parameterize(md,'../Par/SquareSheetConstrained.par');
-md=extrude(md,5,1.2);
-md=setflowequation(md,'hutter','all');
-md.cluster=none;
-md=solve(md,TransientSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Vx1','Vy1','Vz1','Vel1','Pressure1','Bed1','Surface1','Thickness1','Temperature1','BasalforcingsMeltingRate1', ...
-				      'Vx2','Vy2','Vz2','Vel2','Pressure2','Bed2','Surface2','Thickness2','Temperature2','BasalforcingsMeltingRate2', ...
-					   'Vx3','Vy3','Vz3','Vel3','Pressure3','Bed3','Surface3','Thickness3','Temperature3','BasalforcingsMeltingRate3'};
-field_tolerances={1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,...
-						1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,...
-						1e-10,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13};
-field_values={...
-	(md.results.TransientSolution(1).Vx),...
-	(md.results.TransientSolution(1).Vy),...
-	(md.results.TransientSolution(1).Vz),...
-	(md.results.TransientSolution(1).Vel),...
-	(md.results.TransientSolution(1).Pressure),...
-	(md.results.TransientSolution(1).Bed),...
-	(md.results.TransientSolution(1).Surface),...
-	(md.results.TransientSolution(1).Thickness),...
-	(md.results.TransientSolution(1).Temperature),...
-	(md.results.TransientSolution(1).BasalforcingsMeltingRate),...
-	(md.results.TransientSolution(2).Vx),...
-	(md.results.TransientSolution(2).Vy),...
-	(md.results.TransientSolution(2).Vz),...
-	(md.results.TransientSolution(2).Vel),...
-	(md.results.TransientSolution(2).Pressure),...
-	(md.results.TransientSolution(2).Bed),...
-	(md.results.TransientSolution(2).Surface),...
-	(md.results.TransientSolution(2).Thickness),...
-	(md.results.TransientSolution(2).Temperature),...
-	(md.results.TransientSolution(2).BasalforcingsMeltingRate),...
-	(md.results.TransientSolution(3).Vx),...
-	(md.results.TransientSolution(3).Vy),...
-	(md.results.TransientSolution(3).Vz),...
-	(md.results.TransientSolution(3).Vel),...
-	(md.results.TransientSolution(3).Pressure),...
-	(md.results.TransientSolution(3).Bed),...
-	(md.results.TransientSolution(3).Surface),...
-	(md.results.TransientSolution(3).Thickness),...
-	(md.results.TransientSolution(3).Temperature),...
-	(md.results.TransientSolution(3).BasalforcingsMeltingRate),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test331.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test331.m	(revision 12167)
+++ 	(revision )
@@ -1,33 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',150000);
-md=setmask(md,'','');
-md=parameterize(md,'../Par/SquareSheetConstrained.par');
-md=setflowequation(md,'macayeal','all');
-md.cluster=none;
-md=solve(md,TransientSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Vx1','Vy1','Vel1','Pressure1','Bed1','Surface1','Thickness1','Vx2','Vy2','Vel2','Pressure2','Bed2','Surface2','Thickness2','Vx3','Vy3','Vel3','Pressure3','Bed3','Surface3','Thickness3'};
-field_tolerances={1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13};
-field_values={...
-	(md.results.TransientSolution(1).Vx),...
-	(md.results.TransientSolution(1).Vy),...
-	(md.results.TransientSolution(1).Vel),...
-	(md.results.TransientSolution(1).Pressure),...
-	(md.results.TransientSolution(1).Bed),...
-	(md.results.TransientSolution(1).Surface),...
-	(md.results.TransientSolution(1).Thickness),...
-	(md.results.TransientSolution(2).Vx),...
-	(md.results.TransientSolution(2).Vy),...
-	(md.results.TransientSolution(2).Vel),...
-	(md.results.TransientSolution(2).Pressure),...
-	(md.results.TransientSolution(2).Bed),...
-	(md.results.TransientSolution(2).Surface),...
-	(md.results.TransientSolution(2).Thickness),...
-	(md.results.TransientSolution(3).Vx),...
-	(md.results.TransientSolution(3).Vy),...
-	(md.results.TransientSolution(3).Vel),...
-	(md.results.TransientSolution(3).Pressure),...
-	(md.results.TransientSolution(3).Bed),...
-	(md.results.TransientSolution(3).Surface),...
-	(md.results.TransientSolution(3).Thickness),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test333.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test333.m	(revision 12167)
+++ 	(revision )
@@ -1,47 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',200000);
-md=setmask(md,'','');
-md=parameterize(md,'../Par/SquareSheetConstrained.par');
-md=extrude(md,3,1);
-md=setflowequation(md,'pattyn','all');
-md.cluster=none;
-md=solve(md,TransientSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Vx1','Vy1','Vz1','Vel1','Pressure1','Bed1','Surface1','Thickness1','Temperature1','BasalforcingsMeltingRate1', ...
-				      'Vx2','Vy2','Vz2','Vel2','Pressure2','Bed2','Surface2','Thickness2','Temperature2','BasalforcingsMeltingRate2', ...
-					   'Vx3','Vy3','Vz3','Vel3','Pressure3','Bed3','Surface3','Thickness3','Temperature3','BasalforcingsMeltingRate3'};
-field_tolerances={1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,...
-						1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,...
-						1e-9,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10};
-field_values={...
-	(md.results.TransientSolution(1).Vx),...
-	(md.results.TransientSolution(1).Vy),...
-	(md.results.TransientSolution(1).Vz),...
-	(md.results.TransientSolution(1).Vel),...
-	(md.results.TransientSolution(1).Pressure),...
-	(md.results.TransientSolution(1).Bed),...
-	(md.results.TransientSolution(1).Surface),...
-	(md.results.TransientSolution(1).Thickness),...
-	(md.results.TransientSolution(1).Temperature),...
-	(md.results.TransientSolution(1).BasalforcingsMeltingRate),...
-	(md.results.TransientSolution(2).Vx),...
-	(md.results.TransientSolution(2).Vy),...
-	(md.results.TransientSolution(2).Vz),...
-	(md.results.TransientSolution(2).Vel),...
-	(md.results.TransientSolution(2).Pressure),...
-	(md.results.TransientSolution(2).Bed),...
-	(md.results.TransientSolution(2).Surface),...
-	(md.results.TransientSolution(2).Thickness),...
-	(md.results.TransientSolution(2).Temperature),...
-	(md.results.TransientSolution(2).BasalforcingsMeltingRate),...
-	(md.results.TransientSolution(3).Vx),...
-	(md.results.TransientSolution(3).Vy),...
-	(md.results.TransientSolution(3).Vz),...
-	(md.results.TransientSolution(3).Vel),...
-	(md.results.TransientSolution(3).Pressure),...
-	(md.results.TransientSolution(3).Bed),...
-	(md.results.TransientSolution(3).Surface),...
-	(md.results.TransientSolution(3).Thickness),...
-	(md.results.TransientSolution(3).Temperature),...
-	(md.results.TransientSolution(3).BasalforcingsMeltingRate),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test335.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test335.m	(revision 12167)
+++ 	(revision )
@@ -1,23 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',180000);
-md=setmask(md,'','');
-md=parameterize(md,'../Par/SquareSheetConstrained.par');
-md=extrude(md,4,1);
-md=setflowequation(md,'hutter','all');
-md.cluster=none;
-md.timestepping.time_step=0;
-md=solve(md,SteadystateSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Vx','Vy','Vz','Vel','Pressure','Temperature','BasalforcingsMeltingRate'};
-
-field_tolerances={1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13
-};
-field_values={...
-	(md.results.SteadystateSolution.Vx),...
-	(md.results.SteadystateSolution.Vy),...
-	(md.results.SteadystateSolution.Vz),...
-	(md.results.SteadystateSolution.Vel),...
-	(md.results.SteadystateSolution.Pressure),...
-	(md.results.SteadystateSolution.Temperature),...
-	(md.results.SteadystateSolution.BasalforcingsMeltingRate),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test337.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test337.m	(revision 12167)
+++ 	(revision )
@@ -1,33 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',200000);
-md=setmask(md,'','');
-md=parameterize(md,'../Par/SquareSheetConstrained.par');
-md=setflowequation(md,'macayeal','all');
-
-%control parameters
-md.inversion.iscontrol=1;
-md.inversion.control_parameters={'FrictionCoefficient'};
-md.inversion.min_parameters=1*ones(md.mesh.numberofvertices,1);
-md.inversion.max_parameters=200*ones(md.mesh.numberofvertices,1);
-md.inversion.nsteps=2;
-md.inversion.cost_functions=[103*ones(md.inversion.nsteps,1)  501*ones(md.inversion.nsteps,1)];
-md.inversion.cost_functions_coefficients=ones(md.mesh.numberofvertices,2); md.inversion.cost_functions_coefficients(:,2)=0*2*10^-7;
-md.inversion.gradient_scaling=3*ones(md.inversion.nsteps,1);
-md.inversion.maxiter_per_step=2*ones(md.inversion.nsteps,1);
-md.inversion.step_threshold=0.3*ones(md.inversion.nsteps,1);
-md.inversion.vx_obs=md.initialization.vx; md.inversion.vy_obs=md.initialization.vy;
-
-md.cluster=none;
-md=solve(md,DiagnosticSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Gradient' 'Misfits' 'FrictionCoefficient' 'Pressure' 'Vel' 'Vx' 'Vy'};
-field_tolerances={1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13};
-field_values={...
-	(md.results.DiagnosticSolution.Gradient1),...
-	md.results.DiagnosticSolution.J,...
-	(md.results.DiagnosticSolution.FrictionCoefficient),...
-	(md.results.DiagnosticSolution.Pressure),...
-	(md.results.DiagnosticSolution.Vel),...
-	(md.results.DiagnosticSolution.Vx),...
-	(md.results.DiagnosticSolution.Vy)
-};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test339.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test339.m	(revision 12167)
+++ 	(revision )
@@ -1,34 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',200000);
-md=setmask(md,'','');
-md=parameterize(md,'../Par/SquareSheetConstrained.par');
-md=extrude(md,3,1);
-md=setflowequation(md,'macayeal','all');
-
-%control parameters
-md.inversion.iscontrol=1;
-md.inversion.control_parameters={'FrictionCoefficient'};
-md.inversion.min_parameters=1*ones(md.mesh.numberofvertices,1);
-md.inversion.max_parameters=200*ones(md.mesh.numberofvertices,1);
-md.inversion.nsteps=2;
-md.inversion.cost_functions=[103*ones(md.inversion.nsteps,1)  501*ones(md.inversion.nsteps,1)];
-md.inversion.cost_functions_coefficients=ones(md.mesh.numberofvertices,2); md.inversion.cost_functions_coefficients(:,2)=2*10^-7;
-md.inversion.gradient_scaling=3*ones(md.inversion.nsteps,1);
-md.inversion.maxiter_per_step=2*ones(md.inversion.nsteps,1);
-md.inversion.step_threshold=0.3*ones(md.inversion.nsteps,1);
-md.inversion.vx_obs=md.initialization.vx; md.inversion.vy_obs=md.initialization.vy;
-
-md.cluster=none;
-md=solve(md,DiagnosticSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Gradient' 'Misfits' 'FrictionCoefficient' 'Pressure' 'Vel' 'Vx' 'Vy'};
-field_tolerances={1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13};
-field_values={...
-	(md.results.DiagnosticSolution.Gradient1),...
-	md.results.DiagnosticSolution.J,...
-	(md.results.DiagnosticSolution.FrictionCoefficient),...
-	(md.results.DiagnosticSolution.Pressure),...
-	(md.results.DiagnosticSolution.Vel),...
-	(md.results.DiagnosticSolution.Vx),...
-	(md.results.DiagnosticSolution.Vy)
-};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test341.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test341.m	(revision 12167)
+++ 	(revision )
@@ -1,34 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',200000);
-md=setmask(md,'','');
-md=parameterize(md,'../Par/SquareSheetConstrained.par');
-md=extrude(md,3,1);
-md=setflowequation(md,'pattyn','all');
-
-%control parameters
-md.inversion.iscontrol=1;
-md.inversion.control_parameters={'FrictionCoefficient'};
-md.inversion.min_parameters=1*ones(md.mesh.numberofvertices,1);
-md.inversion.max_parameters=200*ones(md.mesh.numberofvertices,1);
-md.inversion.nsteps=2;
-md.inversion.cost_functions=[102*ones(md.inversion.nsteps,1)  501*ones(md.inversion.nsteps,1)];
-md.inversion.cost_functions_coefficients=ones(md.mesh.numberofvertices,2); md.inversion.cost_functions_coefficients(:,2)=2*10^-7;
-md.inversion.gradient_scaling=3*ones(md.inversion.nsteps,1);
-md.inversion.maxiter_per_step=2*ones(md.inversion.nsteps,1);
-md.inversion.step_threshold=0.3*ones(md.inversion.nsteps,1);
-md.inversion.vx_obs=md.initialization.vx; md.inversion.vy_obs=md.initialization.vy;
-
-md.cluster=none;
-md=solve(md,DiagnosticSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Gradient' 'Misfits' 'FrictionCoefficient' 'Pressure' 'Vel' 'Vx' 'Vy'};
-field_tolerances={1e-09,1e-08,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09};
-field_values={...
-	(md.results.DiagnosticSolution.Gradient1),...
-	md.results.DiagnosticSolution.J,...
-	(md.results.DiagnosticSolution.FrictionCoefficient),...
-	(md.results.DiagnosticSolution.Pressure),...
-	(md.results.DiagnosticSolution.Vel),...
-	(md.results.DiagnosticSolution.Vx),...
-	(md.results.DiagnosticSolution.Vy)
-};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test343.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test343.m	(revision 12167)
+++ 	(revision )
@@ -1,34 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',200000);
-md=setmask(md,'','');
-md=parameterize(md,'../Par/SquareSheetConstrained.par');
-md=extrude(md,3,1);
-md=setflowequation(md,'stokes','all');
-
-%control parameters
-md.inversion.iscontrol=1;
-md.inversion.control_parameters={'FrictionCoefficient'};
-md.inversion.min_parameters=1*ones(md.mesh.numberofvertices,1);
-md.inversion.max_parameters=200*ones(md.mesh.numberofvertices,1);
-md.inversion.nsteps=2;
-md.inversion.cost_functions=[104*ones(md.inversion.nsteps,1)  501*ones(md.inversion.nsteps,1)];
-md.inversion.cost_functions_coefficients=ones(md.mesh.numberofvertices,2); md.inversion.cost_functions_coefficients(:,2)=2*10^-7;
-md.inversion.gradient_scaling=3*ones(md.inversion.nsteps,1);
-md.inversion.maxiter_per_step=2*ones(md.inversion.nsteps,1);
-md.inversion.step_threshold=0.3*ones(md.inversion.nsteps,1);
-md.inversion.vx_obs=md.initialization.vx; md.inversion.vy_obs=md.initialization.vy;
-
-md.cluster=none;
-md=solve(md,DiagnosticSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Gradient' 'Misfits' 'FrictionCoefficient' 'Pressure' 'Vel' 'Vx' 'Vy'};
-field_tolerances={1e-08,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09};
-field_values={...
-	(md.results.DiagnosticSolution.Gradient1),...
-	md.results.DiagnosticSolution.J,...
-	(md.results.DiagnosticSolution.FrictionCoefficient),...
-	(md.results.DiagnosticSolution.Pressure),...
-	(md.results.DiagnosticSolution.Vel),...
-	(md.results.DiagnosticSolution.Vx),...
-	(md.results.DiagnosticSolution.Vy)
-};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test345.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test345.m	(revision 12167)
+++ 	(revision )
@@ -1,35 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',150000);
-md=setmask(md,'','');
-md=parameterize(md,'../Par/SquareSheetConstrained.par');
-md=setflowequation(md,'macayeal','all');
-md.cluster=none;
-md.timestepping.time_adapt=1;
-md.timestepping.final_time=600;
-md=solve(md,TransientSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Vx1','Vy1','Vel1','Pressure1','Bed1','Surface1','Thickness1','Vx2','Vy2','Vel2','Pressure2','Bed2','Surface2','Thickness2','Vx3','Vy3','Vel3','Pressure3','Bed3','Surface3','Thickness3'};
-field_tolerances={1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13};
-field_values={...
-	(md.results.TransientSolution(1).Vx),...
-	(md.results.TransientSolution(1).Vy),...
-	(md.results.TransientSolution(1).Vel),...
-	(md.results.TransientSolution(1).Pressure),...
-	(md.results.TransientSolution(1).Bed),...
-	(md.results.TransientSolution(1).Surface),...
-	(md.results.TransientSolution(1).Thickness),...
-	(md.results.TransientSolution(2).Vx),...
-	(md.results.TransientSolution(2).Vy),...
-	(md.results.TransientSolution(2).Vel),...
-	(md.results.TransientSolution(2).Pressure),...
-	(md.results.TransientSolution(2).Bed),...
-	(md.results.TransientSolution(2).Surface),...
-	(md.results.TransientSolution(2).Thickness),...
-	(md.results.TransientSolution(3).Vx),...
-	(md.results.TransientSolution(3).Vy),...
-	(md.results.TransientSolution(3).Vel),...
-	(md.results.TransientSolution(3).Pressure),...
-	(md.results.TransientSolution(3).Bed),...
-	(md.results.TransientSolution(3).Surface),...
-	(md.results.TransientSolution(3).Thickness),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test347.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test347.m	(revision 12167)
+++ 	(revision )
@@ -1,49 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',200000);
-md=setmask(md,'','');
-md=parameterize(md,'../Par/SquareSheetConstrained.par');
-md=extrude(md,4,1.2);
-md=setflowequation(md,'hutter','all');
-md.cluster=none;
-md.timestepping.time_adapt=1;
-md.timestepping.final_time=500;
-md=solve(md,TransientSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Vx1','Vy1','Vz1','Vel1','Pressure1','Bed1','Surface1','Thickness1','Temperature1','BasalforcingsMeltingRate1', ...
-				      'Vx2','Vy2','Vz2','Vel2','Pressure2','Bed2','Surface2','Thickness2','Temperature2','BasalforcingsMeltingRate2'};
-					   %'Vx3','Vy3','Vz3','Vel3','Pressure3','Bed3','Surface3','Thickness3','Temperature3','BasalforcingsMeltingRate3'};
-field_tolerances={1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,...
-						1e-12,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,...
-						1e-12,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13};
-field_values={...
-	(md.results.TransientSolution(1).Vx),...
-	(md.results.TransientSolution(1).Vy),...
-	(md.results.TransientSolution(1).Vz),...
-	(md.results.TransientSolution(1).Vel),...
-	(md.results.TransientSolution(1).Pressure),...
-	(md.results.TransientSolution(1).Bed),...
-	(md.results.TransientSolution(1).Surface),...
-	(md.results.TransientSolution(1).Thickness),...
-	(md.results.TransientSolution(1).Temperature),...
-	(md.results.TransientSolution(1).BasalforcingsMeltingRate),...
-	(md.results.TransientSolution(2).Vx),...
-	(md.results.TransientSolution(2).Vy),...
-	(md.results.TransientSolution(2).Vz),...
-	(md.results.TransientSolution(2).Vel),...
-	(md.results.TransientSolution(2).Pressure),...
-	(md.results.TransientSolution(2).Bed),...
-	(md.results.TransientSolution(2).Surface),...
-	(md.results.TransientSolution(2).Thickness),...
-	(md.results.TransientSolution(2).Temperature),...
-	(md.results.TransientSolution(2).BasalforcingsMeltingRate),...
-%	(md.results.TransientSolution(3).Vx),...
-%	(md.results.TransientSolution(3).Vy),...
-%	(md.results.TransientSolution(3).Vz),...
-%	(md.results.TransientSolution(3).Vel),...
-%	(md.results.TransientSolution(3).Pressure),...
-%	(md.results.TransientSolution(3).Bed),...
-%	(md.results.TransientSolution(3).Surface),...
-%	(md.results.TransientSolution(3).Thickness),...
-%	(md.results.TransientSolution(3).Temperature),...
-%	(md.results.TransientSolution(3).BasalforcingsMeltingRate),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test349.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test349.m	(revision 12167)
+++ 	(revision )
@@ -1,18 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',180000);
-md=setmask(md,'','');
-md=parameterize(md,'../Par/SquareSheetConstrained.par');
-md=extrude(md,3,1);
-md=setflowequation(md,'macayeal','all');
-md.initialization.waterfraction=zeros(md.mesh.numberofvertices,1);
-md.timestepping.time_step=0;
-md.cluster=none;
-md=solve(md,EnthalpySolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Enthalpy','Waterfraction','Temperature'};
-field_tolerances={1e-13,1e-13,1e-13};
-field_values={...
-	(md.results.EnthalpySolution.Enthalpy),...
-	(md.results.EnthalpySolution.Waterfraction),...
-	(md.results.EnthalpySolution.Temperature),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test351.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test351.m	(revision 12167)
+++ 	(revision )
@@ -1,30 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',180000);
-md=setmask(md,'','');
-md=parameterize(md,'../Par/SquareSheetConstrained.par');
-md=extrude(md,3,1);
-md=setflowequation(md,'macayeal','all');
-md.initialization.waterfraction=zeros(md.mesh.numberofvertices,1);
-md.cluster=none;
-md.transient.isdiagnostic=0;
-md.transient.isprognostic=0;
-md.transient.isthermal=1;
-md.transient.isgroundingline=0;
-md.thermal.isenthalpy=1;
-md=solve(md,TransientSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Enthalpy1','Waterfraction1','Temperature1',...
-	'Enthalpy2','Waterfraction2','Temperature2',...
-	'Enthalpy3','Waterfraction3','Temperature3'};
-field_tolerances={1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13};
-field_values={...
-	(md.results.TransientSolution(1).Enthalpy),...
-	(md.results.TransientSolution(1).Waterfraction),...
-	(md.results.TransientSolution(1).Temperature),...
-	(md.results.TransientSolution(2).Enthalpy),...
-	(md.results.TransientSolution(2).Waterfraction),...
-	(md.results.TransientSolution(2).Temperature),...
-	(md.results.TransientSolution(3).Enthalpy),...
-	(md.results.TransientSolution(3).Waterfraction),...
-	(md.results.TransientSolution(3).Temperature),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test353.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test353.m	(revision 12167)
+++ 	(revision )
@@ -1,55 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',200000);
-md=setmask(md,'','');
-md=parameterize(md,'../Par/SquareSheetConstrained.par');
-md=extrude(md,3,1);
-md=setflowequation(md,'pattyn','all');
-md.cluster=none;
-md.initialization.waterfraction=zeros(md.mesh.numberofvertices,1);
-md.initialization.temperature(:)=272;
-md.thermal.spctemperature(find(md.mesh.vertexonsurface))=272;
-md.thermal.isenthalpy=1;
-md.basalforcings.geothermalflux(:)=5;
-md=solve(md,TransientSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Vx1','Vy1','Vz1','Vel1','Pressure1','Bed1','Surface1','Thickness1','Temperature1','Enthalpy1','Waterfraction1', ...
-				      'Vx2','Vy2','Vz2','Vel2','Pressure2','Bed2','Surface2','Thickness2','Temperature2','Enthalpy2','Waterfraction2', ...
-					   'Vx3','Vy3','Vz3','Vel3','Pressure3','Bed3','Surface3','Thickness3','Temperature3','Enthalpy3','Waterfraction3'};
-field_tolerances={1e-09,1e-09,1e-09,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,...
-						1e-09,1e-09,1e-10,1e-09,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,...
-						1e-09,5e-10,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10};
-field_values={...
-	(md.results.TransientSolution(1).Vx),...
-	(md.results.TransientSolution(1).Vy),...
-	(md.results.TransientSolution(1).Vz),...
-	(md.results.TransientSolution(1).Vel),...
-	(md.results.TransientSolution(1).Pressure),...
-	(md.results.TransientSolution(1).Bed),...
-	(md.results.TransientSolution(1).Surface),...
-	(md.results.TransientSolution(1).Thickness),...
-	(md.results.TransientSolution(1).Temperature),...
-	(md.results.TransientSolution(1).Enthalpy),...
-	(md.results.TransientSolution(1).Waterfraction),...
-	(md.results.TransientSolution(2).Vx),...
-	(md.results.TransientSolution(2).Vy),...
-	(md.results.TransientSolution(2).Vz),...
-	(md.results.TransientSolution(2).Vel),...
-	(md.results.TransientSolution(2).Pressure),...
-	(md.results.TransientSolution(2).Bed),...
-	(md.results.TransientSolution(2).Surface),...
-	(md.results.TransientSolution(2).Thickness),...
-	(md.results.TransientSolution(2).Temperature),...
-	(md.results.TransientSolution(2).Enthalpy),...
-	(md.results.TransientSolution(2).Waterfraction),...
-	(md.results.TransientSolution(3).Vx),...
-	(md.results.TransientSolution(3).Vy),...
-	(md.results.TransientSolution(3).Vz),...
-	(md.results.TransientSolution(3).Vel),...
-	(md.results.TransientSolution(3).Pressure),...
-	(md.results.TransientSolution(3).Bed),...
-	(md.results.TransientSolution(3).Surface),...
-	(md.results.TransientSolution(3).Thickness),...
-	(md.results.TransientSolution(3).Temperature),...
-	(md.results.TransientSolution(3).Enthalpy),...
-	(md.results.TransientSolution(3).Waterfraction),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test401.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test401.m	(revision 12167)
+++ 	(revision )
@@ -1,16 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',150000);
-md=setmask(md,'../Exp/SquareShelf.exp','');
-md=parameterize(md,'../Par/SquareSheetShelf.par');
-md=setflowequation(md,'macayeal','all');
-md.cluster=none;
-md=solve(md,DiagnosticSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Vx','Vy','Vel','Pressure'};
-field_tolerances={1e-13,1e-13,1e-13,1e-13};
-field_values={...
-	(md.results.DiagnosticSolution.Vx),...
-	(md.results.DiagnosticSolution.Vy),...
-	(md.results.DiagnosticSolution.Vel),...
-	(md.results.DiagnosticSolution.Pressure),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test403.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test403.m	(revision 12167)
+++ 	(revision )
@@ -1,18 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',150000);
-md=setmask(md,'../Exp/SquareShelf.exp','');
-md=parameterize(md,'../Par/SquareSheetShelf.par');
-md=extrude(md,4,1);
-md=setflowequation(md,'macayeal','all');
-md.cluster=none;
-md=solve(md,DiagnosticSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Vx','Vy','Vz','Vel','Pressure'};
-field_tolerances={1e-13,1e-13,1e-13,1e-13,1e-13};
-field_values={...
-	(md.results.DiagnosticSolution.Vx),...
-	(md.results.DiagnosticSolution.Vy),...
-	(md.results.DiagnosticSolution.Vz),...
-	(md.results.DiagnosticSolution.Vel),...
-	(md.results.DiagnosticSolution.Pressure),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test405.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test405.m	(revision 12167)
+++ 	(revision )
@@ -1,18 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',180000);
-md=setmask(md,'../Exp/SquareShelf.exp','');
-md=parameterize(md,'../Par/SquareSheetShelf.par');
-md=extrude(md,5,1);
-md=setflowequation(md,'pattyn','all');
-md.cluster=none;
-md=solve(md,DiagnosticSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Vx','Vy','Vz','Vel','Pressure'};
-field_tolerances={1e-09,1e-09,1e-09,1e-09,1e-09};
-field_values={...
-	(md.results.DiagnosticSolution.Vx),...
-	(md.results.DiagnosticSolution.Vy),...
-	(md.results.DiagnosticSolution.Vz),...
-	(md.results.DiagnosticSolution.Vel),...
-	(md.results.DiagnosticSolution.Pressure),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test407.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test407.m	(revision 12167)
+++ 	(revision )
@@ -1,17 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',180000);
-md=setmask(md,'../Exp/SquareShelf.exp','');
-md=parameterize(md,'../Par/SquareSheetShelf.par');
-md=extrude(md,3,1);
-md=setflowequation(md,'stokes','all');
-md=solve(md,DiagnosticSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Vx','Vy','Vz','Vel','Pressure'};
-field_tolerances={1e-13,1e-13,1e-13,1e-13,1e-13};
-field_values={...
-	(md.results.DiagnosticSolution.Vx),...
-	(md.results.DiagnosticSolution.Vy),...
-	(md.results.DiagnosticSolution.Vz),...
-	(md.results.DiagnosticSolution.Vel),...
-	(md.results.DiagnosticSolution.Pressure),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test409.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test409.m	(revision 12167)
+++ 	(revision )
@@ -1,18 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',180000);
-md=setmask(md,'../Exp/SquareShelf.exp','');
-md=parameterize(md,'../Par/SquareSheetShelf.par');
-md=extrude(md,5,1);
-md=setflowequation(md,'macayeal','../Exp/SquareHalfRight.exp','fill','pattyn','coupling','penalties');
-md.cluster=none;
-md=solve(md,DiagnosticSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Vx','Vy','Vz','Vel','Pressure'};
-field_tolerances={1e-05,1e-05,1e-05,1e-05,1e-05};
-field_values={...
-	(md.results.DiagnosticSolution.Vx),...
-	(md.results.DiagnosticSolution.Vy),...
-	(md.results.DiagnosticSolution.Vz),...
-	(md.results.DiagnosticSolution.Vel),...
-	(md.results.DiagnosticSolution.Pressure),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test411.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test411.m	(revision 12167)
+++ 	(revision )
@@ -1,16 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',150000);
-md=setmask(md,'../Exp/SquareShelf.exp','');
-md=parameterize(md,'../Par/SquareSheetShelf.par');
-md=extrude(md,4,1);
-md=setflowequation(md,'pattyn','all');
-md.cluster=none;
-md.timestepping.time_step=0;
-md=solve(md,ThermalSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Temperature','BasalforcingsMeltingRate'};
-field_tolerances={1e-13,1e-13};
-field_values={...
-	(md.results.ThermalSolution.Temperature),...
-	(md.results.ThermalSolution.BasalforcingsMeltingRate),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test413.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test413.m	(revision 12167)
+++ 	(revision )
@@ -1,19 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',150000);
-md=setmask(md,'../Exp/SquareShelf.exp','');
-md=parameterize(md,'../Par/SquareSheetShelf.par');
-md=extrude(md,4,1);
-md=setflowequation(md,'pattyn','all');
-md.cluster=none;
-md.transient.isdiagnostic=0;
-md.transient.isprognostic=0;
-md.transient.isthermal=1;
-md.transient.isgroundingline=0;
-md=solve(md,TransientSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Temperature','BasalforcingsMeltingRate'};
-field_tolerances={1e-13,1e-13};
-field_values={...
-	(md.results.TransientSolution(1).Temperature),...
-	(md.results.TransientSolution(1).BasalforcingsMeltingRate),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test415.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test415.m	(revision 12167)
+++ 	(revision )
@@ -1,33 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',150000);
-md=setmask(md,'../Exp/SquareShelf.exp','');
-md=parameterize(md,'../Par/SquareSheetShelf.par');
-md=setflowequation(md,'macayeal','all');
-md.cluster=none;
-md=solve(md,TransientSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Vx1','Vy1','Vel1','Pressure1','Bed1','Surface1','Thickness1','Vx2','Vy2','Vel2','Pressure2','Bed2','Surface2','Thickness2','Vx3','Vy3','Vel3','Pressure3','Bed3','Surface3','Thickness3'};
-field_tolerances={1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13};
-field_values={...
-	(md.results.TransientSolution(1).Vx),...
-	(md.results.TransientSolution(1).Vy),...
-	(md.results.TransientSolution(1).Vel),...
-	(md.results.TransientSolution(1).Pressure),...
-	(md.results.TransientSolution(1).Bed),...
-	(md.results.TransientSolution(1).Surface),...
-	(md.results.TransientSolution(1).Thickness),...
-	(md.results.TransientSolution(2).Vx),...
-	(md.results.TransientSolution(2).Vy),...
-	(md.results.TransientSolution(2).Vel),...
-	(md.results.TransientSolution(2).Pressure),...
-	(md.results.TransientSolution(2).Bed),...
-	(md.results.TransientSolution(2).Surface),...
-	(md.results.TransientSolution(2).Thickness),...
-	(md.results.TransientSolution(3).Vx),...
-	(md.results.TransientSolution(3).Vy),...
-	(md.results.TransientSolution(3).Vel),...
-	(md.results.TransientSolution(3).Pressure),...
-	(md.results.TransientSolution(3).Bed),...
-	(md.results.TransientSolution(3).Surface),...
-	(md.results.TransientSolution(3).Thickness),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test417.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test417.m	(revision 12167)
+++ 	(revision )
@@ -1,45 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',180000);
-md=setmask(md,'../Exp/SquareShelf.exp','');
-md=parameterize(md,'../Par/SquareSheetShelf.par');
-md=extrude(md,3,1);
-md=setflowequation(md,'macayeal','../Exp/SquareHalfRight.exp','fill','pattyn','coupling','penalties');
-md.cluster=none;
-md=solve(md,TransientSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Vx1','Vy1','Vz1','Vel1','Pressure1','Bed1','Surface1','Thickness1','Temperature1','BasalforcingsMeltingRate1', ...
-				      'Vx2','Vy2','Vz2','Vel2','Pressure2','Bed2','Surface2','Thickness2','Temperature2','BasalforcingsMeltingRate2', ...
-					   'Vx3','Vy3','Vz3','Vel3','Pressure3','Bed3','Surface3','Thickness3','Temperature3','BasalforcingsMeltingRate3'};
-field_tolerances={1e-05,1e-05,1e-05,1e-05,1e-05,1e-05,1e-05,1e-05,1e-05,1e-05,1e-05,1e-05,1e-05,1e-05,1e-05,1e-05,1e-05,1e-05,1e-05,1e-05,1e-05,1e-05,1e-05,1e-05,1e-05,1e-05,1e-05,1e-05,1e-05,1e-05};
-field_values={...
-	(md.results.TransientSolution(1).Vx),...
-	(md.results.TransientSolution(1).Vy),...
-	(md.results.TransientSolution(1).Vz),...
-	(md.results.TransientSolution(1).Vel),...
-	(md.results.TransientSolution(1).Pressure),...
-	(md.results.TransientSolution(1).Bed),...
-	(md.results.TransientSolution(1).Surface),...
-	(md.results.TransientSolution(1).Thickness),...
-	(md.results.TransientSolution(1).Temperature),...
-	(md.results.TransientSolution(1).BasalforcingsMeltingRate),...
-	(md.results.TransientSolution(2).Vx),...
-	(md.results.TransientSolution(2).Vy),...
-	(md.results.TransientSolution(2).Vz),...
-	(md.results.TransientSolution(2).Vel),...
-	(md.results.TransientSolution(2).Pressure),...
-	(md.results.TransientSolution(2).Bed),...
-	(md.results.TransientSolution(2).Surface),...
-	(md.results.TransientSolution(2).Thickness),...
-	(md.results.TransientSolution(2).Temperature),...
-	(md.results.TransientSolution(2).BasalforcingsMeltingRate),...
-	(md.results.TransientSolution(3).Vx),...
-	(md.results.TransientSolution(3).Vy),...
-	(md.results.TransientSolution(3).Vz),...
-	(md.results.TransientSolution(3).Vel),...
-	(md.results.TransientSolution(3).Pressure),...
-	(md.results.TransientSolution(3).Bed),...
-	(md.results.TransientSolution(3).Surface),...
-	(md.results.TransientSolution(3).Thickness),...
-	(md.results.TransientSolution(3).Temperature),...
-	(md.results.TransientSolution(3).BasalforcingsMeltingRate),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test419.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test419.m	(revision 12167)
+++ 	(revision )
@@ -1,22 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',150000);
-md=setmask(md,'../Exp/SquareShelf.exp','');
-md=parameterize(md,'../Par/SquareSheetShelf.par');
-md=extrude(md,3,2);
-md=setflowequation(md,'macayeal','all');
-md.cluster=none;
-md.timestepping.time_step=0;
-md=solve(md,SteadystateSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Vx','Vy','Vz','Vel','Pressure','Temperature','BasalforcingsMeltingRate'};
-field_tolerances={1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13
-};
-field_values={...
-	(md.results.SteadystateSolution.Vx),...
-	(md.results.SteadystateSolution.Vy),...
-	(md.results.SteadystateSolution.Vz),...
-	(md.results.SteadystateSolution.Vel),...
-	(md.results.SteadystateSolution.Pressure),...
-	(md.results.SteadystateSolution.Temperature),...
-	(md.results.SteadystateSolution.BasalforcingsMeltingRate),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test421.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test421.m	(revision 12167)
+++ 	(revision )
@@ -1,21 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',150000);
-md=setmask(md,'../Exp/SquareShelf.exp','');
-md=parameterize(md,'../Par/SquareSheetShelf.par');
-md=extrude(md,3,2);
-md=setflowequation(md,'pattyn','all');
-md.cluster=none;
-md.timestepping.time_step=0;
-md=solve(md,SteadystateSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Vx','Vy','Vz','Vel','Pressure','Temperature','BasalforcingsMeltingRate'};
-field_tolerances={1e-08,1e-08,1e-08,1e-08,1e-08,1e-08,1e-06};
-field_values={...
-	(md.results.SteadystateSolution.Vx),...
-	(md.results.SteadystateSolution.Vy),...
-	(md.results.SteadystateSolution.Vz),...
-	(md.results.SteadystateSolution.Vel),...
-	(md.results.SteadystateSolution.Pressure),...
-	(md.results.SteadystateSolution.Temperature),...
-	(md.results.SteadystateSolution.BasalforcingsMeltingRate),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test423.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test423.m	(revision 12167)
+++ 	(revision )
@@ -1,45 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',300000);
-md=setmask(md,'../Exp/SquareShelf.exp','');
-md=parameterize(md,'../Par/SquareSheetShelf.par');
-md=setflowequation(md,'macayeal','all');
-md.cluster=none;
-
-%partitioning
-md.qmu.numberofpartitions=md.mesh.numberofvertices;
-md=partitioner(md,'package','linear','npart',md.qmu.numberofpartitions);
-md.qmu.partition=md.qmu.partition-1;
-md.qmu.isdakota=1;
-
-%Dakota options
-%variables
-md.qmu.variables.rho_ice=normal_uncertain('MaterialsRhoIce',md.materials.rho_ice,0.01);
-md.qmu.variables.drag_coefficient=normal_uncertain('scaled_FrictionCoefficient',1,.01);
-%md.qmu.variables.drag_coefficient=normal_uncertain('scaled_FrictionCoefficient',1,.01*ones(md.qmu.numberofpartitions,1));
-
-%responses
-md.qmu.responses.MaxVel=response_function('MaxVel',[],[0.0001 0.001 0.01 0.25 0.5 0.75 0.99 0.999 0.9999]);
-
-%method
-md.qmu.method     =dakota_method('nond_l');
-
-%parameters
-md.qmu.params.direct=true;
-md.qmu.params.analysis_driver='diagnostic';
-md.qmu.params.evaluation_concurrency=1;
-md.qmu.params.interval_type='forward';
-
-
-%imperative! 
-md.diagnostic.reltol=10^-5; %tighten for qmu analysese
-
-%solve
-md=solve(md,DiagnosticSolutionEnum,'overwrite','y');
-
-%Fields and tolerances to track changes
-md=tres(md,'dakota');
-md.results.dakota.importancefactors=importancefactors(md,'scaled_FrictionCoefficient','MaxVel')';
-field_names     ={'importancefactors'};
-field_tolerances={1e-10};
-field_values={...
-         md.results.dakota.importancefactors,...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test425.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test425.m	(revision 12167)
+++ 	(revision )
@@ -1,45 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',150000);
-md=setmask(md,'../Exp/SquareShelf.exp','');
-md=parameterize(md,'../Par/SquareSheetShelf.par');
-md=setflowequation(md,'macayeal','all');
-md.cluster=none;
-
-%Dakota options
-
-%partitioning
-md.qmu.numberofpartitions=20;
-md=partitioner(md,'package','chaco','npart',md.qmu.numberofpartitions,'weighting','on');
-md.qmu.partition=md.qmu.partition-1;
-
-%variables
-md.qmu.variables.rho_ice=normal_uncertain('MaterialsRhoIce',md.materials.rho_ice,0.01);
-md.qmu.variables.drag_coefficient=normal_uncertain('scaled_FrictionCoefficient',1,0.01);
-
-%responses
-md.qmu.responses.MaxVel=response_function('MaxVel',[],[0.0001 0.001 0.01 0.25 0.5 0.75 0.99 0.999 0.9999]);
-
-%method
-md.qmu.method     =dakota_method('nond_l');
-
-%parameters
-md.qmu.params.direct=true;
-md.qmu.params.analysis_driver='diagnostic';
-md.qmu.params.evaluation_concurrency=1;
-md.qmu.params.interval_type='forward';
-
-
-%imperative!
-md.diagnostic.reltol=10^-5; %tighten for qmu analyses
-md.qmu.isdakota=1;
-
-%solve
-md=solve(md,DiagnosticSolutionEnum,'overwrite','y');
-
-%Fields and tolerances to track changes
-md=tres(md,'dakota');
-md.results.dakota.importancefactors=importancefactors(md,'scaled_FrictionCoefficient','MaxVel')';
-field_names     ={'importancefactors'};
-field_tolerances={1e-10};
-field_values={...
-         md.results.dakota.importancefactors,...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test427.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test427.m	(revision 12167)
+++ 	(revision )
@@ -1,71 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',150000);
-md=setmask(md,'../Exp/SquareShelf.exp','');
-md=parameterize(md,'../Par/SquareSheetShelf.par');
-md=setflowequation(md,'macayeal','all');
-md.cluster=none;
-md.materials.rho_ice=10^7; %involved in the mass flux, make it easy
-md.geometry.thickness(:)=1; %make it easy
-
-%constrain all velocities to 1 m/yr, in the y-direction
-md.diagnostic.spcvx(:)=0;
-md.diagnostic.spcvy(:)=1;
-md.diagnostic.spcvz(:)=0;
-
-%Dakota options
-
-%partitioning
-md.qmu.numberofpartitions=20;
-md=partitioner(md,'package','chaco','npart',md.qmu.numberofpartitions,'weighting','on');
-md.qmu.partition=md.qmu.partition-1;
-
-%variables
-md.qmu.variables.drag_coefficient=normal_uncertain('scaled_FrictionCoefficient',1,0.01);
-
-%responses
-md.qmu.responses.MaxVel=response_function('MaxVel',[],[0.0001 0.001 0.01 0.25 0.5 0.75 0.99 0.999 0.9999]);
-md.qmu.responses.MassFlux1=response_function('indexed_MassFlux_1',[],[0.0001 0.001 0.01 0.25 0.5 0.75 0.99 0.999 0.9999]);
-md.qmu.responses.MassFlux2=response_function('indexed_MassFlux_2',[],[0.0001 0.001 0.01 0.25 0.5 0.75 0.99 0.999 0.9999]);
-md.qmu.responses.MassFlux3=response_function('indexed_MassFlux_3',[],[0.0001 0.001 0.01 0.25 0.5 0.75 0.99 0.999 0.9999]);
-md.qmu.responses.MassFlux4=response_function('indexed_MassFlux_4',[],[0.0001 0.001 0.01 0.25 0.5 0.75 0.99 0.999 0.9999]);
-md.qmu.responses.MassFlux5=response_function('indexed_MassFlux_5',[],[0.0001 0.001 0.01 0.25 0.5 0.75 0.99 0.999 0.9999]);
-md.qmu.responses.MassFlux6=response_function('indexed_MassFlux_6',[],[0.0001 0.001 0.01 0.25 0.5 0.75 0.99 0.999 0.9999]);
-md.qmu.responses.MassFlux7=response_function('indexed_MassFlux_7',[],[0.0001 0.001 0.01 0.25 0.5 0.75 0.99 0.999 0.9999]);
-
-%mass flux profiles
-md.qmu.mass_flux_profiles={'../Exp/MassFlux1.exp','../Exp/MassFlux2.exp','../Exp/MassFlux3.exp','../Exp/MassFlux4.exp','../Exp/MassFlux5.exp','../Exp/MassFlux6.exp','../Exp/Square.exp'};
-md.qmu.mass_flux_profile_directory=pwd;
-
-%method
-md.qmu.method     =dakota_method('nond_l');
-
-%parameters
-md.qmu.params.direct=true;
-md.qmu.params.analysis_driver='diagnostic';
-md.qmu.params.evaluation_concurrency=1;
-md.qmu.params.interval_type='forward';
-md.qmu.isdakota=1;
-md.diagnostic.reltol=10^-5; %tighten for qmu analyses
-
-%solve
-md=solve(md,DiagnosticSolutionEnum,'overwrite','y');
-md=tres(md,'dakota');
-
-%Fields and tolerances to track changes
-
-%ok, mass flux of 3 profiles should be -3 Gt/yr -3 Gt/yr and the sum, which is -6 Gt/yr
-%we recover those mass fluxes through the mean of the response.
-%also, we recover the max velo, which should be 1m/yr. 
-%we put all that data in the importancefactors, which we will use to test for success.
-%also, check that the stddev are 0.
-md.results.dakota.importancefactors=[];
-for i=1:8,
-	md.results.dakota.importancefactors=[md.results.dakota.importancefactors md.results.dakota.dresp_out(i).mean];
-end
-for i=1:8,
-	md.results.dakota.importancefactors=[md.results.dakota.importancefactors md.results.dakota.dresp_out(i).stddev];
-end
-field_names     ={'importancefactors'};
-field_tolerances={1e-11};
-field_values={...
-         md.results.dakota.importancefactors,...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test429.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test429.m	(revision 12167)
+++ 	(revision )
@@ -1,38 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',170000);
-md=setmask(md,'../Exp/SquareShelf.exp','');
-md=parameterize(md,'../Par/SquareSheetShelf.par');
-md=extrude(md,3,1);
-md=setflowequation(md,'macayeal','all');
-
-%control parameters
-md.inversion.iscontrol=1;
-md.inversion.control_parameters={'FrictionCoefficient'};
-md.inversion.min_parameters=1*ones(md.mesh.numberofvertices,1);
-md.inversion.max_parameters=200*ones(md.mesh.numberofvertices,1);
-md.inversion.nsteps=2;
-md.inversion.cost_functions=[103*ones(md.inversion.nsteps,1)  501*ones(md.inversion.nsteps,1)];
-md.inversion.cost_functions_coefficients=ones(md.mesh.numberofvertices,2); md.inversion.cost_functions_coefficients(:,2)=2*10^-7;
-md.inversion.gradient_scaling=3*ones(md.inversion.nsteps,1);
-md.inversion.maxiter_per_step=2*ones(md.inversion.nsteps,1);
-md.inversion.step_threshold=0.3*ones(md.inversion.nsteps,1);
-md.timestepping.time_step=0;
-md.inversion.vx_obs=md.initialization.vx; md.inversion.vy_obs=md.initialization.vy;
-
-md.cluster=none;
-md=solve(md,SteadystateSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Gradient' 'Misfits' 'FrictionCoefficient' 'Pressure' 'Vel' 'Vx' 'Vy' 'Vz' 'Temperature' 'BasalforcingsMeltingRate'};
-field_tolerances={1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13};
-field_values={...
-	(md.results.SteadystateSolution.Gradient1),...
-	md.results.SteadystateSolution.J,...
-	(md.results.SteadystateSolution.FrictionCoefficient),...
-	(md.results.SteadystateSolution.Pressure),...
-	(md.results.SteadystateSolution.Vel),...
-	(md.results.SteadystateSolution.Vx),...
-	(md.results.SteadystateSolution.Vy),...
-	(md.results.SteadystateSolution.Vz),...
-	(md.results.SteadystateSolution.Temperature),...
-	(md.results.SteadystateSolution.BasalforcingsMeltingRate)
-};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test431.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test431.m	(revision 12167)
+++ 	(revision )
@@ -1,38 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',170000);
-md=setmask(md,'../Exp/SquareShelf.exp','');
-md=parameterize(md,'../Par/SquareSheetShelf.par');
-md=extrude(md,3,1);
-md=setflowequation(md,'pattyn','all');
-
-%control parameters
-md.inversion.iscontrol=1;
-md.inversion.control_parameters={'FrictionCoefficient'};
-md.inversion.min_parameters=1*ones(md.mesh.numberofvertices,1);
-md.inversion.max_parameters=200*ones(md.mesh.numberofvertices,1);
-md.inversion.nsteps=2;
-md.inversion.cost_functions=[102*ones(md.inversion.nsteps,1)  501*ones(md.inversion.nsteps,1)];
-md.inversion.cost_functions_coefficients=ones(md.mesh.numberofvertices,2); md.inversion.cost_functions_coefficients(:,2)=2*10^-7;
-md.inversion.gradient_scaling=3*ones(md.inversion.nsteps,1);
-md.inversion.maxiter_per_step=2*ones(md.inversion.nsteps,1);
-md.inversion.step_threshold=0.3*ones(md.inversion.nsteps,1);
-md.timestepping.time_step=0;
-md.inversion.vx_obs=md.initialization.vx; md.inversion.vy_obs=md.initialization.vy;
-
-md.cluster=none;
-md=solve(md,SteadystateSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Gradient' 'Misfits' 'FrictionCoefficient' 'Pressure' 'Vel' 'Vx' 'Vy' 'Vz' 'Temperature' 'BasalforcingsMeltingRate'};
-field_tolerances={1e-08,1e-08,1e-08,1e-08,1e-08,1e-08,1e-08,1e-08,1e-08,1e-06};
-field_values={...
-	(md.results.SteadystateSolution.Gradient1),...
-	md.results.SteadystateSolution.J,...
-	(md.results.SteadystateSolution.FrictionCoefficient),...
-	(md.results.SteadystateSolution.Pressure),...
-	(md.results.SteadystateSolution.Vel),...
-	(md.results.SteadystateSolution.Vx),...
-	(md.results.SteadystateSolution.Vy),...
-	(md.results.SteadystateSolution.Vz),...
-	(md.results.SteadystateSolution.Temperature),...
-	(md.results.SteadystateSolution.BasalforcingsMeltingRate)
-};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test435.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test435.m	(revision 12167)
+++ 	(revision )
@@ -1,21 +1,0 @@
-%test partitioning, and partition averaging
-md=triangle(model,'../Exp/Square.exp',30000);
-md=setmask(md,'../Exp/SquareShelf.exp','');
-md=parameterize(md,'../Par/SquareSheetShelf.par');
-md=setflowequation(md,'macayeal','all');
-md.cluster=none;
-
-%partitioning
-md.qmu.numberofpartitions=100;
-md=partitioner(md,'package','chaco','npart',md.qmu.numberofpartitions);
-md.qmu.partition=md.qmu.partition-1;
-
-vector=(1:1:md.mesh.numberofvertices)';
-vector_on_partition=AreaAverageOntoPartition(md,vector);
-vector_on_nodes=vector_on_partition(md.qmu.partition+1);
-
-field_names     ={'vector_on_nodes'};
-field_tolerances={1e-11};
-field_values={...
-         vector_on_nodes,...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test437.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test437.m	(revision 12167)
+++ 	(revision )
@@ -1,18 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',180000);
-md=setmask(md,'../Exp/SquareShelf.exp','');
-md=parameterize(md,'../Par/SquareSheetShelf.par');
-md=extrude(md,5,1);
-md=setflowequation(md,'macayeal','../Exp/SquareHalfRight.exp','fill','pattyn','coupling','tiling');
-md.cluster=none;
-md=solve(md,DiagnosticSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Vx','Vy','Vz','Vel','Pressure'};
-field_tolerances={1e-09,1e-09,1e-09,1e-09,1e-09};
-field_values={...
-	(md.results.DiagnosticSolution.Vx),...
-	(md.results.DiagnosticSolution.Vy),...
-	(md.results.DiagnosticSolution.Vz),...
-	(md.results.DiagnosticSolution.Vel),...
-	(md.results.DiagnosticSolution.Pressure),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test439.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test439.m	(revision 12167)
+++ 	(revision )
@@ -1,49 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',200000);
-md=setmask(md,'../Exp/SquareShelf.exp','');
-md=parameterize(md,'../Par/SquareSheetShelf.par');
-md=setflowequation(md,'macayeal','all');
-md.cluster=none;
-
-%partitioning
-md.qmu.numberofpartitions=10;
-md=partitioner(md,'package','chaco','npart',md.qmu.numberofpartitions);
-md.qmu.partition=md.qmu.partition-1;
-md.qmu.isdakota=1;
-
-%Dakota options
-%variables
-md.qmu.variables.rho_ice=normal_uncertain('MaterialsRhoIce',md.materials.rho_ice,0.01);
-
-%responses
-md.qmu.responses.MaxVel=response_function('scaled_Thickness',[],[0.0001 0.001 0.01 0.25 0.5 0.75 0.99 0.999 0.9999]);
-
-%method
-md.qmu.method     =dakota_method('nond_l');
-
-%parameters
-md.qmu.params.direct=true;
-md.qmu.params.analysis_driver='diagnostic';
-md.qmu.params.evaluation_concurrency=1;
-md.qmu.params.interval_type='forward';
-
-
-%imperative! 
-md.diagnostic.reltol=10^-5; %tighten for qmu analysese
-
-%solve
-md=solve(md,DiagnosticSolutionEnum,'overwrite','y');
-md=tres(md,'dakota');
-
-%test on thickness
-h=zeros(md.qmu.numberofpartitions,1);
-for i=1:md.qmu.numberofpartitions,
-	h(i)=md.qmu.results.dresp_out(i).mean;
-end
-
-%project onto grid
-thickness=h(md.qmu.partition+1);
-
-%Fields and tolerances to track changes
-field_names     ={'Thickness'};
-field_tolerances={1e-11};
-field_values={thickness};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test441.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test441.m	(revision 12167)
+++ 	(revision )
@@ -1,18 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',180000);
-md=setmask(md,'../Exp/SquareShelf.exp','');
-md=parameterize(md,'../Par/SquareSheetShelf.par');
-md=extrude(md,5,1);
-md=setflowequation(md,'stokes','../Exp/SquareHalfRight.exp','fill','pattyn','coupling','tiling');
-md.cluster=none;
-md=solve(md,DiagnosticSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Vx','Vy','Vz','Vel','Pressure'};
-field_tolerances={1e-09,1e-09,1e-09,1e-09,1e-09};
-field_values={...
-	(md.results.DiagnosticSolution.Vx),...
-	(md.results.DiagnosticSolution.Vy),...
-	(md.results.DiagnosticSolution.Vz),...
-	(md.results.DiagnosticSolution.Vel),...
-	(md.results.DiagnosticSolution.Pressure),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test443.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test443.m	(revision 12167)
+++ 	(revision )
@@ -1,19 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',180000);
-md=setmask(md,'../Exp/SquareShelf.exp','');
-md=parameterize(md,'../Par/SquareSheetShelf.par');
-md=extrude(md,5,1);
-md=setflowequation(md,'stokes','../Exp/SquareHalfRight.exp','fill','macayeal','coupling','tiling');
-md.cluster=none;
-md.diagnostic.reltol=0.4;
-md=solve(md,DiagnosticSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Vx','Vy','Vz','Vel','Pressure'};
-field_tolerances={1e-09,1e-09,1e-06,1e-09,1e-09};
-field_values={...
-	(md.results.DiagnosticSolution.Vx),...
-	(md.results.DiagnosticSolution.Vy),...
-	(md.results.DiagnosticSolution.Vz),...
-	(md.results.DiagnosticSolution.Vel),...
-	(md.results.DiagnosticSolution.Pressure),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test445.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test445.m	(revision 12167)
+++ 	(revision )
@@ -1,37 +1,0 @@
-radius=1e6;
-shelfextent=2e5;
-
-md=roundmesh(model,radius,200000);
-%fix center node to 0,0
-rad=sqrt(md.mesh.x.^2+md.mesh.y.^2);
-pos=find(rad==min(rad));
-md.mesh.x(pos)=0; md.mesh.y(pos)=0; %the closest node to the center is changed to be exactly at the center
-xelem=md.mesh.x(md.mesh.elements)*[1;1;1]/3;
-yelem=md.mesh.y(md.mesh.elements)*[1;1;1]/3;
-rad=sqrt(xelem.^2+yelem.^2);
-flags=zeros(md.mesh.numberofelements,1);
-pos=find(rad>=(radius-shelfextent));
-flags(pos)=1;
-md=setmask(md,flags,''); 
-md=parameterize(md,'../Par/RoundSheetShelf.par');
-md=setflowequation(md,'macayeal','all');
-md.cluster=none;
-
-md.transient.isthermal=0;
-md.transient.isprognostic=0;
-md.transient.isdiagnostic=0;
-md.transient.isgroundingline=1;
-
-%test different grounding line dynamics
-md.groundingline.migration='AgressiveMigration';
-md=solve(md,TransientSolutionEnum);
-element_on_iceshelf_agressive=(md.results.TransientSolution.MaskElementonfloatingice);
-
-md.groundingline.migration='SoftMigration';
-md=solve(md,TransientSolutionEnum);
-element_on_iceshelf_soft=(md.results.TransientSolution.MaskElementonfloatingice);
-
-%Fields and tolerances to track changes
-field_names     ={'ElementOnIceShelfAgressive','ElementOnIceShelfSoft'};
-field_tolerances={1e-13,1e-13};
-field_values={element_on_iceshelf_agressive,element_on_iceshelf_soft};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test447.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test447.m	(revision 12167)
+++ 	(revision )
@@ -1,39 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',150000);
-md=setmask(md,'../Exp/SquareShelf.exp','');
-md=parameterize(md,'../Par/SquareSheetShelf.par');
-md=setflowequation(md,'macayeal','all');
-md.cluster=none;
-md.initialization.vx(:)=0;
-md.initialization.vy(:)=0;
-md.initialization.vel(:)=0;
-md.geometry.bed=-700-abs(md.mesh.y-500000)/1000;
-md.geometry.bathymetry=-700-abs(md.mesh.y-500000)/1000;
-md.geometry.thickness(:)=1000;
-md.geometry.surface=md.geometry.bed+md.geometry.thickness;
-md.surfaceforcings.mass_balance(:)=100;
-md.transient.isdiagnostic=0;
-md.transient.isgroundingline=1;
-md.groundingline.migration='AgressiveMigration';
-md=solve(md,TransientSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Bed1','Surface1','Thickness1','Floatingice1',...
-	'Bed2','Surface2','Thickness2','Floatingice2',...
-	'Bed3','Surface3','Thickness3','Floatingice3'};
-field_tolerances={1e-13,1e-13,1e-13,1e-13,...
-	1e-13,1e-13,1e-13,1e-13,...
-	1e-13,1e-13,1e-13,1e-13};
-field_values={...
-	(md.results.TransientSolution(1).Bed),...
-	(md.results.TransientSolution(1).Surface),...
-	(md.results.TransientSolution(1).Thickness),...
-	(md.results.TransientSolution(1).MaskElementonfloatingice),...
-	(md.results.TransientSolution(2).Bed),...
-	(md.results.TransientSolution(2).Surface),...
-	(md.results.TransientSolution(2).Thickness),...
-	(md.results.TransientSolution(2).MaskElementonfloatingice),...
-	(md.results.TransientSolution(3).Bed),...
-	(md.results.TransientSolution(3).Surface),...
-	(md.results.TransientSolution(3).Thickness),...
-	(md.results.TransientSolution(3).MaskElementonfloatingice),...
-	};
Index: /issm/branches/trunk-jpl-damage/test/NightlyRun/test448.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test448.m	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/test/NightlyRun/test448.m	(revision 12168)
@@ -3,5 +3,4 @@
 md=parameterize(md,'../Par/SquareSheetShelf.par');
 md=setflowequation(md,'macayeal','all');
-md.cluster=none;
 md.initialization.vx(:)=0;
 md.initialization.vy(:)=0;
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test449.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test449.m	(revision 12167)
+++ 	(revision )
@@ -1,39 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',150000);
-md=setmask(md,'../Exp/SquareShelf.exp','');
-md=parameterize(md,'../Par/SquareSheetShelf.par');
-md=setflowequation(md,'macayeal','all');
-md.cluster=none;
-md.initialization.vx(:)=0;
-md.initialization.vy(:)=0;
-md.initialization.vel(:)=0;
-md.geometry.bed=-700-abs(md.mesh.y-500000)/1000;
-md.geometry.bathymetry=-700-abs(md.mesh.y-500000)/1000;
-md.geometry.thickness(:)=1300;
-md.geometry.surface=md.geometry.bed+md.geometry.thickness;
-md.surfaceforcings.mass_balance(:)=-150;
-md.transient.isdiagnostic=0;
-md.transient.isgroundingline=1;
-md.groundingline.migration='SoftMigration';
-md=solve(md,TransientSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Bed1','Surface1','Thickness1','Floatingice1',...
-	'Bed2','Surface2','Thickness2','Floatingice2',...
-	'Bed3','Surface3','Thickness3','Floatingice3'};
-field_tolerances={1e-13,1e-13,1e-13,1e-13,...
-	1e-13,1e-13,1e-13,1e-13,...
-	1e-13,1e-13,1e-13,1e-13};
-field_values={...
-	(md.results.TransientSolution(1).Bed),...
-	(md.results.TransientSolution(1).Surface),...
-	(md.results.TransientSolution(1).Thickness),...
-	(md.results.TransientSolution(1).MaskElementonfloatingice),...
-	(md.results.TransientSolution(2).Bed),...
-	(md.results.TransientSolution(2).Surface),...
-	(md.results.TransientSolution(2).Thickness),...
-	(md.results.TransientSolution(2).MaskElementonfloatingice),...
-	(md.results.TransientSolution(3).Bed),...
-	(md.results.TransientSolution(3).Surface),...
-	(md.results.TransientSolution(3).Thickness),...
-	(md.results.TransientSolution(3).MaskElementonfloatingice),...
-	};
Index: /issm/branches/trunk-jpl-damage/test/NightlyRun/test450.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test450.m	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/test/NightlyRun/test450.m	(revision 12168)
@@ -3,5 +3,4 @@
 md=parameterize(md,'../Par/SquareSheetShelf.par');
 md=setflowequation(md,'macayeal','all');
-md.cluster=none;
 md.initialization.vx(:)=0;
 md.initialization.vy(:)=0;
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test451.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test451.m	(revision 12167)
+++ 	(revision )
@@ -1,42 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',350000);
-md=setmask(md,'../Exp/SquareShelf.exp','');
-md=parameterize(md,'../Par/SquareSheetShelf.par');
-md.cluster=none;
-md.initialization.vx(:)=0;
-md.initialization.vy(:)=0;
-md.initialization.vel(:)=0;
-md.geometry.bed=-700-abs(md.mesh.y-500000)/1000;
-md.geometry.bathymetry=-700-abs(md.mesh.y-500000)/1000;
-md.geometry.thickness(:)=1000;
-md.geometry.surface=md.geometry.bed+md.geometry.thickness;
-md.surfaceforcings.mass_balance(:)=100;
-md=extrude(md,3,1);
-md=setflowequation(md,'macayeal','all');
-
-md.transient.isdiagnostic=0;
-md.transient.isgroundingline=1;
-md.groundingline.migration='AgressiveMigration';
-
-md=solve(md,TransientSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Bed1','Surface1','Thickness1','Floatingice1',...
-	'Bed2','Surface2','Thickness2','Floatingice2',...
-	'Bed3','Surface3','Thickness3','Floatingice3'};
-field_tolerances={1e-13,1e-13,1e-13,1e-13,...
-	1e-13,1e-13,1e-13,1e-13,...
-	1e-13,1e-13,1e-13,1e-13};
-field_values={...
-	(md.results.TransientSolution(1).Bed),...
-	(md.results.TransientSolution(1).Surface),...
-	(md.results.TransientSolution(1).Thickness),...
-	(md.results.TransientSolution(1).MaskElementonfloatingice),...
-	(md.results.TransientSolution(2).Bed),...
-	(md.results.TransientSolution(2).Surface),...
-	(md.results.TransientSolution(2).Thickness),...
-	(md.results.TransientSolution(2).MaskElementonfloatingice),...
-	(md.results.TransientSolution(3).Bed),...
-	(md.results.TransientSolution(3).Surface),...
-	(md.results.TransientSolution(3).Thickness),...
-	(md.results.TransientSolution(3).MaskElementonfloatingice),...
-	};
Index: /issm/branches/trunk-jpl-damage/test/NightlyRun/test452.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test452.m	(revision 12167)
+++ /issm/branches/trunk-jpl-damage/test/NightlyRun/test452.m	(revision 12168)
@@ -2,5 +2,4 @@
 md=setmask(md,'../Exp/SquareShelf.exp','');
 md=parameterize(md,'../Par/SquareSheetShelf.par');
-md.cluster=none;
 md.initialization.vx(:)=0;
 md.initialization.vy(:)=0;
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test453.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test453.m	(revision 12167)
+++ 	(revision )
@@ -1,41 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',150000);
-md=setmask(md,'../Exp/SquareShelf.exp','');
-md=parameterize(md,'../Par/SquareSheetShelf.par');
-md.initialization.vx(:)=0;
-md.initialization.vy(:)=0;
-md.initialization.vel(:)=0;
-md.geometry.bed=-700-abs(md.mesh.y-500000)/1000;
-md.geometry.bathymetry=-700-abs(md.mesh.y-500000)/1000;
-md.geometry.thickness(:)=1300;
-md.geometry.surface=md.geometry.bed+md.geometry.thickness;
-md=extrude(md,3,1);
-md=setflowequation(md,'macayeal','all');
-
-md.surfaceforcings.mass_balance(:)=-150;
-md.transient.isdiagnostic=0;
-md.transient.isgroundingline=1;
-md.groundingline.migration='SoftMigration';
-md.cluster=none;
-md=solve(md,TransientSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Bed1','Surface1','Thickness1','Floatingice1',...
-	'Bed2','Surface2','Thickness2','Floatingice2',...
-	'Bed3','Surface3','Thickness3','Floatingice3'};
-field_tolerances={1e-13,1e-13,1e-13,1e-13,...
-	1e-13,1e-13,1e-13,1e-13,...
-	1e-13,1e-13,1e-13,1e-13};
-field_values={...
-	(md.results.TransientSolution(1).Bed),...
-	(md.results.TransientSolution(1).Surface),...
-	(md.results.TransientSolution(1).Thickness),...
-	(md.results.TransientSolution(1).MaskElementonfloatingice),...
-	(md.results.TransientSolution(2).Bed),...
-	(md.results.TransientSolution(2).Surface),...
-	(md.results.TransientSolution(2).Thickness),...
-	(md.results.TransientSolution(2).MaskElementonfloatingice),...
-	(md.results.TransientSolution(3).Bed),...
-	(md.results.TransientSolution(3).Surface),...
-	(md.results.TransientSolution(3).Thickness),...
-	(md.results.TransientSolution(3).MaskElementonfloatingice),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test455.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test455.m	(revision 12167)
+++ 	(revision )
@@ -1,18 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',150000);
-md=setmask(md,'../Exp/SquareShelf.exp','');
-md=parameterize(md,'../Par/SquareSheetShelf.par');
-md=setflowequation(md,'macayeal','all');
-md.diagnostic.isnewton=1;
-md.diagnostic.restol=0.0001;
-md.cluster=none;
-md=solve(md,DiagnosticSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Vx','Vy','Vel','Pressure'};
-field_tolerances={1e-13,1e-13,1e-13,1e-13};
-field_values={...
-	(md.results.DiagnosticSolution.Vx),...
-	(md.results.DiagnosticSolution.Vy),...
-	(md.results.DiagnosticSolution.Vel),...
-	(md.results.DiagnosticSolution.Pressure),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test457.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test457.m	(revision 12167)
+++ 	(revision )
@@ -1,20 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',180000);
-md=setmask(md,'../Exp/SquareShelf.exp','');
-md=parameterize(md,'../Par/SquareSheetShelf.par');
-md=extrude(md,5,1);
-md=setflowequation(md,'pattyn','all');
-md.diagnostic.isnewton=1;
-md.diagnostic.restol=0.0001;
-md.cluster=none;
-md=solve(md,DiagnosticSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Vx','Vy','Vz','Vel','Pressure'};
-field_tolerances={1e-09,1e-09,1e-09,1e-09,1e-09};
-field_values={...
-	(md.results.DiagnosticSolution.Vx),...
-	(md.results.DiagnosticSolution.Vy),...
-	(md.results.DiagnosticSolution.Vz),...
-	(md.results.DiagnosticSolution.Vel),...
-	(md.results.DiagnosticSolution.Pressure),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test459.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test459.m	(revision 12167)
+++ 	(revision )
@@ -1,19 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',180000);
-md=setmask(md,'../Exp/SquareShelf.exp','');
-md=parameterize(md,'../Par/SquareSheetShelf.par');
-md=extrude(md,3,1);
-md=setflowequation(md,'stokes','all');
-md.diagnostic.isnewton=1;
-md.diagnostic.restol=0.0001;
-md=solve(md,DiagnosticSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Vx','Vy','Vz','Vel','Pressure'};
-field_tolerances={1e-13,1e-13,1e-13,1e-13,1e-13};
-field_values={...
-	(md.results.DiagnosticSolution.Vx),...
-	(md.results.DiagnosticSolution.Vy),...
-	(md.results.DiagnosticSolution.Vz),...
-	(md.results.DiagnosticSolution.Vel),...
-	(md.results.DiagnosticSolution.Pressure),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test461.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test461.m	(revision 12167)
+++ 	(revision )
@@ -1,24 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',150000);
-md=setmask(md,'../Exp/SquareShelf.exp','');
-md=parameterize(md,'../Par/SquareSheetShelf.par');
-md=extrude(md,3,2);
-md=setflowequation(md,'macayeal','all');
-md.cluster=none;
-md.timestepping.time_step=0;
-md.thermal.isenthalpy=1;
-md.initialization.waterfraction=zeros(md.mesh.numberofvertices,1);
-md=solve(md,SteadystateSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Vx','Vy','Vz','Vel','Pressure','Temperature','Water fraction','Enthalpy'};
-field_tolerances={1e-10,1e-10,1e-09,1e-10,1e-13,1e-10,1e-10,1e-10};
-field_values={...
-	(md.results.SteadystateSolution.Vx),...
-	(md.results.SteadystateSolution.Vy),...
-	(md.results.SteadystateSolution.Vz),...
-	(md.results.SteadystateSolution.Vel),...
-	(md.results.SteadystateSolution.Pressure),...
-	(md.results.SteadystateSolution.Temperature),...
-	(md.results.SteadystateSolution.Waterfraction),...
-	(md.results.SteadystateSolution.Enthalpy),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test463.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test463.m	(revision 12167)
+++ 	(revision )
@@ -1,24 +1,0 @@
-md=triangle(model,'../Exp/Square.exp',150000);
-md=setmask(md,'../Exp/SquareShelf.exp','');
-md=parameterize(md,'../Par/SquareSheetShelf.par');
-md=extrude(md,3,2);
-md=setflowequation(md,'pattyn','all');
-md.cluster=none;
-md.timestepping.time_step=0;
-md.thermal.isenthalpy=1;
-md.initialization.waterfraction=zeros(md.mesh.numberofvertices,1);
-md=solve(md,SteadystateSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Vx','Vy','Vz','Vel','Pressure','Temperature','Water fraction','Enthalpy'};
-field_tolerances={1e-09,1e-10,1e-09,1e-10,1e-13,1e-10,1e-10,1e-10};
-field_values={...
-	(md.results.SteadystateSolution.Vx),...
-	(md.results.SteadystateSolution.Vy),...
-	(md.results.SteadystateSolution.Vz),...
-	(md.results.SteadystateSolution.Vel),...
-	(md.results.SteadystateSolution.Pressure),...
-	(md.results.SteadystateSolution.Temperature),...
-	(md.results.SteadystateSolution.Waterfraction),...
-	(md.results.SteadystateSolution.Enthalpy),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test501.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test501.m	(revision 12167)
+++ 	(revision )
@@ -1,16 +1,0 @@
-md=triangle(model,'../Exp/Pig.exp',20000);
-md=setmask(md,'../Exp/PigShelves.exp','../Exp/PigIslands.exp');
-md=parameterize(md,'../Par/Pig.par');
-md=setflowequation(md,'macayeal','all');
-md.cluster=none;
-md=solve(md,DiagnosticSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Vx','Vy','Vel','Pressure'};
-field_tolerances={1e-13,1e-13,1e-13,1e-13};
-field_values={...
-	(md.results.DiagnosticSolution.Vx),...
-	(md.results.DiagnosticSolution.Vy),...
-	(md.results.DiagnosticSolution.Vel),...
-	(md.results.DiagnosticSolution.Pressure),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test503.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test503.m	(revision 12167)
+++ 	(revision )
@@ -1,18 +1,0 @@
-md=triangle(model,'../Exp/Pig.exp',20000);
-md=setmask(md,'../Exp/PigShelves.exp','../Exp/PigIslands.exp');
-md=parameterize(md,'../Par/Pig.par');
-md=extrude(md,3,0.9);
-md=setflowequation(md,'pattyn','all');
-md.cluster=none;
-md=solve(md,DiagnosticSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Vx','Vy','Vz','Vel','Pressure'};
-field_tolerances={1e-13,1e-13,1e-13,1e-13,1e-13};
-field_values={...
-	(md.results.DiagnosticSolution.Vx),...
-	(md.results.DiagnosticSolution.Vy),...
-	(md.results.DiagnosticSolution.Vz),...
-	(md.results.DiagnosticSolution.Vel),...
-	(md.results.DiagnosticSolution.Pressure),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test505.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test505.m	(revision 12167)
+++ 	(revision )
@@ -1,17 +1,0 @@
-md=triangle(model,'../Exp/Pig.exp',20000);
-md=setmask(md,'../Exp/PigShelves.exp','../Exp/PigIslands.exp');
-md=parameterize(md,'../Par/Pig.par');
-md=extrude(md,3,0.9);
-md=setflowequation(md,'stokes','all');
-md=solve(md,DiagnosticSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Vx','Vy','Vz','Vel','Pressure'};
-field_tolerances={1e-13,1e-13,1e-13,1e-13,1e-13};
-field_values={...
-	(md.results.DiagnosticSolution.Vx),...
-	(md.results.DiagnosticSolution.Vy),...
-	(md.results.DiagnosticSolution.Vz),...
-	(md.results.DiagnosticSolution.Vel),...
-	(md.results.DiagnosticSolution.Pressure),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test507.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test507.m	(revision 12167)
+++ 	(revision )
@@ -1,26 +1,0 @@
-md=triangle(model,'../Exp/Pig.exp',20000);
-md=setmask(md,'../Exp/PigShelves.exp','../Exp/PigIslands.exp');
-md=parameterize(md,'../Par/Pig.par');
-md=setflowequation(md,'macayeal','all');
-md.cluster=none;
-md=solve(md,TransientSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Vx1','Vy1','Vel1','Pressure1','Bed1','Surface1','Thickness1','Vx2','Vy2','Vel2','Pressure2','Bed2','Surface2','Thickness2'};
-field_tolerances={1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13};
-field_values={...
-	(md.results.TransientSolution(1).Vx),...
-	(md.results.TransientSolution(1).Vy),...
-	(md.results.TransientSolution(1).Vel),...
-	(md.results.TransientSolution(1).Pressure),...
-	(md.results.TransientSolution(1).Bed),...
-	(md.results.TransientSolution(1).Surface),...
-	(md.results.TransientSolution(1).Thickness),...
-	(md.results.TransientSolution(2).Vx),...
-	(md.results.TransientSolution(2).Vy),...
-	(md.results.TransientSolution(2).Vel),...
-	(md.results.TransientSolution(2).Pressure),...
-	(md.results.TransientSolution(2).Bed),...
-	(md.results.TransientSolution(2).Surface),...
-	(md.results.TransientSolution(2).Thickness),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test509.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test509.m	(revision 12167)
+++ 	(revision )
@@ -1,34 +1,0 @@
-md=triangle(model,'../Exp/Pig.exp',30000);
-md=setmask(md,'../Exp/PigShelves.exp','../Exp/PigIslands.exp');
-md=parameterize(md,'../Par/Pig.par');
-md=extrude(md,3,1);
-md=setflowequation(md,'macayeal','all');
-md.cluster=none;
-md=solve(md,TransientSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Vx1','Vy1','Vz1','Vel1','Pressure1','Bed1','Surface1','Thickness1','Temperature1','BasalforcingsMeltingRate1', ...
-				      'Vx2','Vy2','Vz2','Vel2','Pressure2','Bed2','Surface2','Thickness2','Temperature2','BasalforcingsMeltingRate2'};
-field_tolerances={1e-12,1e-12,1e-12,1e-12,1e-12,1e-12,1e-12,1e-12,1e-12,1e-12,1e-12,1e-12,1e-12,1e-12,1e-12,1e-12,1e-12,1e-12,1e-12,1e-12};
-field_values={...
-	(md.results.TransientSolution(1).Vx),...
-	(md.results.TransientSolution(1).Vy),...
-	(md.results.TransientSolution(1).Vz),...
-	(md.results.TransientSolution(1).Vel),...
-	(md.results.TransientSolution(1).Pressure),...
-	(md.results.TransientSolution(1).Bed),...
-	(md.results.TransientSolution(1).Surface),...
-	(md.results.TransientSolution(1).Thickness),...
-	(md.results.TransientSolution(1).Temperature),...
-	(md.results.TransientSolution(1).BasalforcingsMeltingRate),...
-	(md.results.TransientSolution(2).Vx),...
-	(md.results.TransientSolution(2).Vy),...
-	(md.results.TransientSolution(2).Vz),...
-	(md.results.TransientSolution(2).Vel),...
-	(md.results.TransientSolution(2).Pressure),...
-	(md.results.TransientSolution(2).Bed),...
-	(md.results.TransientSolution(2).Surface),...
-	(md.results.TransientSolution(2).Thickness),...
-	(md.results.TransientSolution(2).Temperature),...
-	(md.results.TransientSolution(2).BasalforcingsMeltingRate),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test511.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test511.m	(revision 12167)
+++ 	(revision )
@@ -1,35 +1,0 @@
-md=triangle(model,'../Exp/Pig.exp',30000);
-md=setmask(md,'../Exp/PigShelves.exp','../Exp/PigIslands.exp');
-md=parameterize(md,'../Par/Pig.par');
-md=extrude(md,2,1);
-md=setflowequation(md,'pattyn','all');
-md.cluster=none;
-md=solve(md,TransientSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Vx1','Vy1','Vz1','Vel1','Pressure1','Bed1','Surface1','Thickness1','Temperature1','BasalforcingsMeltingRate1', ...
-				      'Vx2','Vy2','Vz2','Vel2','Pressure2','Bed2','Surface2','Thickness2','Temperature2','BasalforcingsMeltingRate2'};
-field_tolerances={1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,...
-						1e-12,1e-12,1e-12,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13};
-field_values={...
-	(md.results.TransientSolution(1).Vx),...
-	(md.results.TransientSolution(1).Vy),...
-	(md.results.TransientSolution(1).Vz),...
-	(md.results.TransientSolution(1).Vel),...
-	(md.results.TransientSolution(1).Pressure),...
-	(md.results.TransientSolution(1).Bed),...
-	(md.results.TransientSolution(1).Surface),...
-	(md.results.TransientSolution(1).Thickness),...
-	(md.results.TransientSolution(1).Temperature),...
-	(md.results.TransientSolution(1).BasalforcingsMeltingRate),...
-	(md.results.TransientSolution(2).Vx),...
-	(md.results.TransientSolution(2).Vy),...
-	(md.results.TransientSolution(2).Vz),...
-	(md.results.TransientSolution(2).Vel),...
-	(md.results.TransientSolution(2).Pressure),...
-	(md.results.TransientSolution(2).Bed),...
-	(md.results.TransientSolution(2).Surface),...
-	(md.results.TransientSolution(2).Thickness),...
-	(md.results.TransientSolution(2).Temperature),...
-	(md.results.TransientSolution(2).BasalforcingsMeltingRate),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test513.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test513.m	(revision 12167)
+++ 	(revision )
@@ -1,35 +1,0 @@
-md=triangle(model,'../Exp/Pig.exp',30000);
-md=setmask(md,'../Exp/PigShelves.exp','../Exp/PigIslands.exp');
-md=parameterize(md,'../Par/Pig.par');
-md=extrude(md,2,1);
-md=setflowequation(md,'stokes','all');
-md.cluster=none;
-md=solve(md,TransientSolutionEnum);
-
-%Fields and tolerances to track changes
-%The thickness wants to be lower than 1 so we contrain it to 1
-field_names     ={'Vx1','Vy1','Vz1','Vel1','Pressure1','Bed1','Surface1','Thickness1','Temperature1','BasalforcingsMeltingRate1', ...
-				      'Vx2','Vy2','Vz2','Vel2','Pressure2','Bed2','Surface2','Thickness2','Temperature2','BasalforcingsMeltingRate2'};
-field_tolerances={1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,1e-08,1e-08,1e-08,1e-08,1e-08,1e-08,1e-08,1e-08,1e-08,1e-08};
-field_values={...
-	(md.results.TransientSolution(1).Vx),...
-	(md.results.TransientSolution(1).Vy),...
-	(md.results.TransientSolution(1).Vz),...
-	(md.results.TransientSolution(1).Vel),...
-	(md.results.TransientSolution(1).Pressure),...
-	(md.results.TransientSolution(1).Bed),...
-	(md.results.TransientSolution(1).Surface),...
-	(md.results.TransientSolution(1).Thickness),...
-	(md.results.TransientSolution(1).Temperature),...
-	(md.results.TransientSolution(1).BasalforcingsMeltingRate),...
-	(md.results.TransientSolution(2).Vx),...
-	(md.results.TransientSolution(2).Vy),...
-	(md.results.TransientSolution(2).Vz),...
-	(md.results.TransientSolution(2).Vel),...
-	(md.results.TransientSolution(2).Pressure),...
-	(md.results.TransientSolution(2).Bed),...
-	(md.results.TransientSolution(2).Surface),...
-	(md.results.TransientSolution(2).Thickness),...
-	(md.results.TransientSolution(2).Temperature),...
-	(md.results.TransientSolution(2).BasalforcingsMeltingRate),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test515.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test515.m	(revision 12167)
+++ 	(revision )
@@ -1,22 +1,0 @@
-md=triangle(model,'../Exp/Pig.exp',30000);
-md=setmask(md,'../Exp/PigShelves.exp','../Exp/PigIslands.exp');
-md=parameterize(md,'../Par/Pig.par');
-md=extrude(md,4,1.1);
-md=setflowequation(md,'macayeal','all');
-md.cluster=none;
-md.timestepping.time_step=0;
-md=solve(md,SteadystateSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Vx','Vy','Vz','Vel','Pressure','Temperature','BasalforcingsMeltingRate'};
-field_tolerances={1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13
-};
-field_values={...
-	(md.results.SteadystateSolution.Vx),...
-	(md.results.SteadystateSolution.Vy),...
-	(md.results.SteadystateSolution.Vz),...
-	(md.results.SteadystateSolution.Vel),...
-	(md.results.SteadystateSolution.Pressure),...
-	(md.results.SteadystateSolution.Temperature),...
-	(md.results.SteadystateSolution.BasalforcingsMeltingRate),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test517.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test517.m	(revision 12167)
+++ 	(revision )
@@ -1,22 +1,0 @@
-md=triangle(model,'../Exp/Pig.exp',30000);
-md=setmask(md,'../Exp/PigShelves.exp','../Exp/PigIslands.exp');
-md=parameterize(md,'../Par/Pig.par');
-md=extrude(md,3,1);
-md=setflowequation(md,'pattyn','all');
-md.cluster=none;
-md.timestepping.time_step=0;
-md=solve(md,SteadystateSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Vx','Vy','Vz','Vel','Pressure','Temperature','BasalforcingsMeltingRate'};
-field_tolerances={1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13
-};
-field_values={...
-	(md.results.SteadystateSolution.Vx),...
-	(md.results.SteadystateSolution.Vy),...
-	(md.results.SteadystateSolution.Vz),...
-	(md.results.SteadystateSolution.Vel),...
-	(md.results.SteadystateSolution.Pressure),...
-	(md.results.SteadystateSolution.Temperature),...
-	(md.results.SteadystateSolution.BasalforcingsMeltingRate),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test519.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test519.m	(revision 12167)
+++ 	(revision )
@@ -1,22 +1,0 @@
-md=triangle(model,'../Exp/Pig.exp',20000);
-md=setmask(md,'../Exp/PigShelves.exp','../Exp/PigIslands.exp');
-md=parameterize(md,'../Par/Pig.par');
-md=extrude(md,2,1);
-md=setflowequation(md,'stokes','all');
-md.cluster=none;
-md.timestepping.time_step=0;
-md=solve(md,SteadystateSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Vx','Vy','Vz','Vel','Pressure','Temperature','BasalforcingsMeltingRate'};
-field_tolerances={1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-06
-};
-field_values={...
-	(md.results.SteadystateSolution.Vx),...
-	(md.results.SteadystateSolution.Vy),...
-	(md.results.SteadystateSolution.Vz),...
-	(md.results.SteadystateSolution.Vel),...
-	(md.results.SteadystateSolution.Pressure),...
-	(md.results.SteadystateSolution.Temperature),...
-	(md.results.SteadystateSolution.BasalforcingsMeltingRate),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test521.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test521.m	(revision 12167)
+++ 	(revision )
@@ -1,39 +1,0 @@
-md=triangle(model,'../Exp/Pig.exp',10000);
-md=setmask(md,'../Exp/PigShelves.exp','../Exp/PigIslands.exp');
-md=parameterize(md,'../Par/Pig.par');
-
-%impose hydrostatic equilibrium (required by Stokes)
-md.geometry.bed=-md.materials.rho_ice/md.materials.rho_water*md.geometry.thickness;
-md.geometry.surface=md.geometry.bed+md.geometry.thickness;
-md=extrude(md,3,1);
-md=setflowequation(md,'stokes','all');
-md=modelextract(md,md.mask.elementonfloatingice);
-
-%control parameters
-md.inversion.iscontrol=1;
-md.inversion.control_parameters={'MaterialsRheologyBbar'};
-md.inversion.min_parameters=10^6*ones(md.mesh.numberofvertices,1);
-md.inversion.max_parameters=2*10^9*ones(md.mesh.numberofvertices,1);
-md.inversion.nsteps=2;
-md.inversion.cost_functions=101*ones(md.inversion.nsteps,1);
-md.inversion.cost_functions_coefficients=ones(md.mesh.numberofvertices,1);
-md.inversion.gradient_scaling=10^8*ones(md.inversion.nsteps,1);
-md.inversion.maxiter_per_step=2*ones(md.inversion.nsteps,1);
-md.inversion.step_threshold=0.99*ones(md.inversion.nsteps,1);
-md.inversion.vx_obs=md.initialization.vx; md.inversion.vy_obs=md.initialization.vy;
-
-md.cluster=none;
-md=solve(md,DiagnosticSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Gradient' 'Misfits' 'MaterialsRheologyB' 'Pressure' 'Vel' 'Vx' 'Vy'};
-field_tolerances={1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10};
-field_values={...
-	(md.results.DiagnosticSolution.Gradient1),...
-	md.results.DiagnosticSolution.J,...
-	(md.results.DiagnosticSolution.MaterialsRheologyB),...
-	(md.results.DiagnosticSolution.Pressure),...
-	(md.results.DiagnosticSolution.Vel),...
-	(md.results.DiagnosticSolution.Vx),...
-	(md.results.DiagnosticSolution.Vy)
-};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test523.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test523.m	(revision 12167)
+++ 	(revision )
@@ -1,34 +1,0 @@
-md=triangle(model,'../Exp/Pig.exp',20000);
-md=setmask(md,'../Exp/PigShelves.exp','../Exp/PigIslands.exp');
-md=parameterize(md,'../Par/Pig.par');
-md=extrude(md,3,1);
-md=setflowequation(md,'pattyn','all');
-
-%control parameters
-md.inversion.iscontrol=1;
-md.inversion.control_parameters={'FrictionCoefficient'};
-md.inversion.min_parameters=1*ones(md.mesh.numberofvertices,1);
-md.inversion.max_parameters=200*ones(md.mesh.numberofvertices,1);
-md.inversion.nsteps=2;
-md.inversion.cost_functions=[103*ones(md.inversion.nsteps,1)  501*ones(md.inversion.nsteps,1)];
-md.inversion.cost_functions_coefficients=ones(md.mesh.numberofvertices,2); md.inversion.cost_functions_coefficients(:,2)=2*10^-7;
-md.inversion.gradient_scaling=3*ones(md.inversion.nsteps,1);
-md.inversion.maxiter_per_step=2*ones(md.inversion.nsteps,1);
-md.inversion.step_threshold=0.99*ones(md.inversion.nsteps,1);
-md.inversion.vx_obs=md.initialization.vx; md.inversion.vy_obs=md.initialization.vy;
-
-md.cluster=none;
-md=solve(md,DiagnosticSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Gradient' 'Misfits' 'FrictionCoefficient' 'Pressure' 'Vel' 'Vx' 'Vy'};
-field_tolerances={1e-11,1e-11,1e-11,1e-11,1e-11,1e-11,1e-11,1e-11,1e-11,1e-11};
-field_values={...
-	(md.results.DiagnosticSolution.Gradient1),...
-	md.results.DiagnosticSolution.J,...
-	(md.results.DiagnosticSolution.FrictionCoefficient),...
-	(md.results.DiagnosticSolution.Pressure),...
-	(md.results.DiagnosticSolution.Vel),...
-	(md.results.DiagnosticSolution.Vx),...
-	(md.results.DiagnosticSolution.Vy)
-};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test525.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test525.m	(revision 12167)
+++ 	(revision )
@@ -1,39 +1,0 @@
-md=triangle(model,'../Exp/Pig.exp',30000);
-md=setmask(md,'../Exp/PigShelves.exp','../Exp/PigIslands.exp');
-md=parameterize(md,'../Par/Pig.par');
-md=extrude(md,3,1);
-md=setflowequation(md,'macayeal','all');
-
-%control parameters
-md.inversion.iscontrol=1;
-md.inversion.control_parameters={'FrictionCoefficient'};
-md.inversion.min_parameters=1*ones(md.mesh.numberofvertices,1);
-md.inversion.max_parameters=200*ones(md.mesh.numberofvertices,1);
-md.inversion.nsteps=2;
-md.inversion.cost_functions=[103*ones(md.inversion.nsteps,1)  501*ones(md.inversion.nsteps,1)];
-md.inversion.cost_functions_coefficients=ones(md.mesh.numberofvertices,2); md.inversion.cost_functions_coefficients(:,2)=2*10^-7;
-md.inversion.gradient_scaling=3*ones(md.inversion.nsteps,1);
-md.inversion.maxiter_per_step=2*ones(md.inversion.nsteps,1);
-md.inversion.step_threshold=0.99*ones(md.inversion.nsteps,1);
-md.inversion.vx_obs=md.initialization.vx; md.inversion.vy_obs=md.initialization.vy;
-md.timestepping.time_step=0;
-
-md.thermal.penalty_lock=5;
-md.cluster=none;
-md=solve(md,SteadystateSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Gradient' 'Misfits' 'FrictionCoefficient' 'Pressure' 'Vel' 'Vx' 'Vy' 'Vz' 'Temperature' 'BasalforcingsMeltingRate'};
-field_tolerances={1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13};
-field_values={...
-	(md.results.SteadystateSolution.Gradient1),...
-	md.results.SteadystateSolution.J,...
-	(md.results.SteadystateSolution.FrictionCoefficient),...
-	(md.results.SteadystateSolution.Pressure),...
-	(md.results.SteadystateSolution.Vel),...
-	(md.results.SteadystateSolution.Vx),...
-	(md.results.SteadystateSolution.Vy),...
-	(md.results.SteadystateSolution.Vz),...
-	(md.results.SteadystateSolution.Temperature),...
-	(md.results.SteadystateSolution.BasalforcingsMeltingRate)
-};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test527.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test527.m	(revision 12167)
+++ 	(revision )
@@ -1,56 +1,0 @@
-%Simple mesh 1
-hVertices=10000*ones(27,1);
-hVertices(1:5)=1000;
-md=bamg(model,'domain','../Exp/Pig.exp','hmax',20000,'hVertices',hVertices,'gradation',3,'geometricalmetric',1);
-x1=md.mesh.x;
-y1=md.mesh.y;
-
-%Simple mesh 2
-md=bamg(model,'domain','../Exp/Pig.exp','hmax',10000);
-md=setmask(md,'../Exp/PigShelves.exp','../Exp/PigIslands.exp');
-md=parameterize(md,'../Par/Pig.par');
-x2=md.mesh.x;
-y2=md.mesh.y;
-
-%refine existing mesh 1
-hessian=ComputeHessian(md.mesh.elements,md.mesh.x,md.mesh.y,md.inversion.vy_obs,'node');
-metric=ComputeMetric(hessian,2/9,1,1000,25*10^3,[]);
-md.miscellaneous.dummy=metric;
-md2=bamg(md,'metric',md.miscellaneous.dummy,'hmin',1000,'hmax',20000,'gradation',3,'geometricalmetric',1);
-x3=md2.mesh.x;
-y3=md2.mesh.y;
-
-%refine existing mesh 2
-md2=bamg(md,'metric',md.miscellaneous.dummy,'hmin',1000,'hmax',20000,'gradation',3,'geometricalmetric',1,'anisomax',1);
-x4=md2.mesh.x;
-y4=md2.mesh.y;
-
-%refine existing mesh 3
-hVertices=NaN*ones(md.mesh.numberofvertices,1);
-hVertices(find(md.mesh.vertexonboundary))=500;
-md2=bamg(md,'metric',md.miscellaneous.dummy,'hmin',1000,'hmax',20000,'gradation',3,'geometricalmetric',1,'anisomax',1,'hVertices',hVertices);
-x5=md2.mesh.x;
-y5=md2.mesh.y;
-
-%refine existing mesh 4
-md2=bamg(md,'field',md.inversion.vy_obs,'hmin',1000,'hmax',20000,'gradation',3,'geometricalmetric',1,'Hessiantype',0,'err',1);
-x6=md2.mesh.x;
-y6=md2.mesh.y;
-
-%refine existing mesh 5
-md2=bamg(md,'field',[md.inversion.vy_obs md.geometry.thickness],'hmin',1000,'hmax',20000,'gradation',3,'geometricalmetric',1,'Hessiantype',1,'err',[10 100]); 
-x7=md2.mesh.x;
-y7=md2.mesh.y;
-
-%Fields and tolerances to track changes
-field_names     ={'x1' 'y1' 'x2' 'y2' 'x3' 'y3' 'x4' 'y4' 'x5' 'y5' 'x6' 'y6'  'x7' 'y7' };
-field_tolerances={1e-13 1e-13 1e-13 1e-13 1e-13 1e-13 1e-13 1e-13 1e-13 1e-13 1e-13 1e-13 1e-13 1e-13};
-field_values={...
-	x1, y1,...
-	y2, y2,...
-	y3, y3,...
-	y4, y4,...
-	y5, y5,...
-	y6, y6,...
-	y7, y7,...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test529.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test529.m	(revision 12167)
+++ 	(revision )
@@ -1,22 +1,0 @@
-md=triangle(model,'../Exp/Pig.exp',30000);
-md=setmask(md,'../Exp/PigShelves.exp','../Exp/PigIslands.exp');
-md=parameterize(md,'../Par/Pig.par');
-md=extrude(md,3,1);
-md=setflowequation(md,'pattyn','all');
-md.thermal.stabilization=2;
-md.transient.isdiagnostic=0;
-md.transient.isprognostic=0;
-md.transient.isthermal=1;
-md.transient.isgroundingline=0;
-md=solve(md,TransientSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Temperature1','BasalforcingsMeltingRate1', ...
-				      'Temperature2','BasalforcingsMeltingRate2'};
-field_tolerances={1e-13,1e-9,1e-13,1e-9};
-field_values={...
-	(md.results.TransientSolution(1).Temperature),...
-	(md.results.TransientSolution(1).BasalforcingsMeltingRate),...
-	(md.results.TransientSolution(2).Temperature),...
-	(md.results.TransientSolution(2).BasalforcingsMeltingRate),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test531.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test531.m	(revision 12167)
+++ 	(revision )
@@ -1,17 +1,0 @@
-md=triangle(model,'../Exp/Pig.exp',30000);
-md=setmask(md,'../Exp/PigShelves.exp','../Exp/PigIslands.exp');
-md=parameterize(md,'../Par/Pig.par');
-md=extrude(md,3,1);
-md=setflowequation(md,'pattyn','all');
-md.thermal.stabilization=2;
-md.timestepping.time_step=0;
-md.thermal.penalty_threshold=40;
-md=solve(md,ThermalSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Temperature','BasalforcingsMeltingRate'};
-field_tolerances={1e-13,1e-12};
-field_values={...
-	(md.results.ThermalSolution.Temperature),...
-	(md.results.ThermalSolution.BasalforcingsMeltingRate),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test601.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test601.m	(revision 12167)
+++ 	(revision )
@@ -1,13 +1,0 @@
-md=triangle(model,'../Exp/79North.exp',10000);
-md=setmask(md,'../Exp/79NorthShelf.exp','');
-md=parameterize(md,'../Par/79North.par');
-md=setflowequation(md,'macayeal','all');
-md.cluster=none;
-md=solve(md,PrognosticSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Thickness'};
-field_tolerances={1e-13};
-field_values={...
-	(md.results.PrognosticSolution.Thickness),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test603.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test603.m	(revision 12167)
+++ 	(revision )
@@ -1,16 +1,0 @@
-md=triangle(model,'../Exp/79North.exp',10000);
-md=meshconvert(md);
-md=setmask(md,'../Exp/79NorthShelf.exp','');
-md=parameterize(md,'../Par/79North.par');
-md=setflowequation(md,'macayeal','all');
-md.prognostic.stabilization=3;
-md.prognostic.spcthickness=md.geometry.thickness;
-md.cluster=none;
-md=solve(md,PrognosticSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Thickness'};
-field_tolerances={1e-13};
-field_values={...
-	(md.results.PrognosticSolution.Thickness),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test605.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test605.m	(revision 12167)
+++ 	(revision )
@@ -1,14 +1,0 @@
-md=triangle(model,'../Exp/79North.exp',10000);
-md=setmask(md,'../Exp/79NorthShelf.exp','');
-md=parameterize(md,'../Par/79North.par');
-md=extrude(md,6,1);
-md=setflowequation(md,'macayeal','all');
-md.cluster=none;
-md=solve(md,PrognosticSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Thickness'};
-field_tolerances={1e-13};
-field_values={...
-	(md.results.PrognosticSolution.Thickness),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test607.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test607.m	(revision 12167)
+++ 	(revision )
@@ -1,14 +1,0 @@
-md=triangle(model,'../Exp/79North.exp',10000);
-md=setmask(md,'../Exp/79NorthShelf.exp','');
-md=parameterize(md,'../Par/79North.par');
-md=setflowequation(md,'macayeal','all');
-md.cluster=none;
-md=solve(md,SurfaceSlopeSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'SurfaceSlopeX','SurfaceSlopeY'};
-field_tolerances={1e-13,1e-13};
-field_values={...
-	(md.results.SurfaceSlopeSolution.SurfaceSlopeX),...
-	(md.results.SurfaceSlopeSolution.SurfaceSlopeY),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test609.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test609.m	(revision 12167)
+++ 	(revision )
@@ -1,15 +1,0 @@
-md=triangle(model,'../Exp/79North.exp',10000);
-md=setmask(md,'../Exp/79NorthShelf.exp','');
-md=parameterize(md,'../Par/79North.par');
-md=extrude(md,5,1.5);
-md=setflowequation(md,'pattyn','all');
-md.cluster=none;
-md=solve(md,SurfaceSlopeSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'SurfaceSlopeX','SurfaceSlopeY'};
-field_tolerances={1e-13,1e-13};
-field_values={...
-	(md.results.SurfaceSlopeSolution.SurfaceSlopeX),...
-	(md.results.SurfaceSlopeSolution.SurfaceSlopeY),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test611.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test611.m	(revision 12167)
+++ 	(revision )
@@ -1,14 +1,0 @@
-md=triangle(model,'../Exp/79North.exp',10000);
-md=setmask(md,'../Exp/79NorthShelf.exp','');
-md=parameterize(md,'../Par/79North.par');
-md=setflowequation(md,'macayeal','all');
-md.cluster=none;
-md=solve(md,BedSlopeSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'BedSlopeX','BedSlopeY'};
-field_tolerances={1e-13,1e-13};
-field_values={...
-	(md.results.BedSlopeSolution.BedSlopeX),...
-	(md.results.BedSlopeSolution.BedSlopeY),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test613.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test613.m	(revision 12167)
+++ 	(revision )
@@ -1,15 +1,0 @@
-md=triangle(model,'../Exp/79North.exp',10000);
-md=setmask(md,'../Exp/79NorthShelf.exp','');
-md=parameterize(md,'../Par/79North.par');
-md=extrude(md,2,1);
-md=setflowequation(md,'macayeal','all');
-md.cluster=none;
-md=solve(md,BedSlopeSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'BedSlopeX','BedSlopeY'};
-field_tolerances={1e-13,1e-13};
-field_values={...
-	(md.results.BedSlopeSolution.BedSlopeX),...
-	(md.results.BedSlopeSolution.BedSlopeY),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test615.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test615.m	(revision 12167)
+++ 	(revision )
@@ -1,13 +1,0 @@
-md=triangle(model,'../Exp/79North.exp',10000);
-md=setmask(md,'../Exp/79NorthShelf.exp','');
-md=parameterize(md,'../Par/79North.par');
-md=setflowequation(md,'macayeal','all');
-md.cluster=none;
-md=solve(md,BalancethicknessSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Thickness'};
-field_tolerances={1e-13};
-field_values={...
-	(md.results.BalancethicknessSolution.Thickness),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test617.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test617.m	(revision 12167)
+++ 	(revision )
@@ -1,15 +1,0 @@
-md=triangle(model,'../Exp/79North.exp',10000);
-md=meshconvert(md);
-md=setmask(md,'../Exp/79NorthShelf.exp','');
-md=parameterize(md,'../Par/79North.par');
-md=setflowequation(md,'macayeal','all');
-md.balancethickness.stabilization=3;
-md.cluster=none;
-md=solve(md,BalancethicknessSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Thickness'};
-field_tolerances={1e-13};
-field_values={...
-	(md.results.BalancethicknessSolution.Thickness),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test619.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test619.m	(revision 12167)
+++ 	(revision )
@@ -1,14 +1,0 @@
-md=triangle(model,'../Exp/79North.exp',10000);
-md=setmask(md,'../Exp/79NorthShelf.exp','');
-md=parameterize(md,'../Par/79North.par');
-md=extrude(md,3,1);
-md=setflowequation(md,'macayeal','all');
-md.cluster=none;
-md=solve(md,BalancethicknessSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Thickness'};
-field_tolerances={1e-13};
-field_values={...
-	(md.results.BalancethicknessSolution.Thickness),...
-	};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test621.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test621.m	(revision 12167)
+++ 	(revision )
@@ -1,31 +1,0 @@
-md=triangle(model,'../Exp/79North.exp',10000);
-md=setmask(md,'../Exp/79NorthShelf.exp','');
-md=parameterize(md,'../Par/79North.par');
-md=setflowequation(md,'macayeal','all');
-
-%control parameters
-md.inversion.nsteps=2;
-md.prognostic.stabilization=1;
-md.inversion.iscontrol=1;
-md.inversion.control_parameters={'BalancethicknessThickeningRate'};
-md.inversion.thickness_obs=md.geometry.thickness;
-md.inversion.min_parameters=-50*ones(md.mesh.numberofvertices,1);
-md.inversion.max_parameters=50*ones(md.mesh.numberofvertices,1);
-md.inversion.cost_functions=201*ones(md.inversion.nsteps,1);
-md.inversion.cost_functions_coefficients=ones(md.mesh.numberofvertices,1);
-md.inversion.gradient_scaling=10/md.constants.yts*ones(md.inversion.nsteps,1);
-md.inversion.maxiter_per_step=4*ones(md.inversion.nsteps,1);
-md.inversion.step_threshold=0.99*ones(md.inversion.nsteps,1);
-
-md.cluster=none;
-md=solve(md,BalancethicknessSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Gradient' 'Misfits' 'BalancethicknessThickeningRate' 'Thickness'};
-field_tolerances={1e-12,1e-12,1e-12,1e-12,1e-12,1e-12};
-field_values={...
-	(md.results.BalancethicknessSolution.Gradient1),...
-	md.results.BalancethicknessSolution.J,...
-	(md.results.BalancethicknessSolution.BalancethicknessThickeningRate),...
-	(md.results.BalancethicknessSolution.Thickness)
-};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test623.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test623.m	(revision 12167)
+++ 	(revision )
@@ -1,32 +1,0 @@
-md=triangle(model,'../Exp/79North.exp',10000);
-md=meshconvert(md);
-md=setmask(md,'../Exp/79NorthShelf.exp','');
-md=parameterize(md,'../Par/79North.par');
-md=setflowequation(md,'macayeal','all');
-
-%control parameters
-md.inversion.nsteps=2;
-md.balancethickness.stabilization=3;
-md.inversion.iscontrol=1;
-md.inversion.control_parameters={'BalancethicknessThickeningRate'};
-md.inversion.thickness_obs=md.geometry.thickness;
-md.inversion.min_parameters=-50*ones(md.mesh.numberofvertices,1);
-md.inversion.max_parameters=50*ones(md.mesh.numberofvertices,1);
-md.inversion.cost_functions=201*ones(md.inversion.nsteps,1);
-md.inversion.cost_functions_coefficients=ones(md.mesh.numberofvertices,1);
-md.inversion.gradient_scaling=10/md.constants.yts*ones(md.inversion.nsteps,1);
-md.inversion.maxiter_per_step=4*ones(md.inversion.nsteps,1);
-md.inversion.step_threshold=0.99*ones(md.inversion.nsteps,1);
-
-md.cluster=none;
-md=solve(md,BalancethicknessSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Gradient' 'Misfits' 'BalancethicknessThickeningRate' 'Thickness'};
-field_tolerances={1e-12,1e-12,1e-12,1e-12,1e-12,1e-12};
-field_values={...
-	(md.results.BalancethicknessSolution.Gradient1),...
-	md.results.BalancethicknessSolution.J,...
-	(md.results.BalancethicknessSolution.BalancethicknessThickeningRate),...
-	(md.results.BalancethicknessSolution.Thickness)
-};
Index: sm/branches/trunk-jpl-damage/test/NightlyRun/test625.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test625.m	(revision 12167)
+++ 	(revision )
@@ -1,40 +1,0 @@
-md=triangle(model,'../Exp/79North.exp',10000);
-md=meshconvert(md);
-md=setmask(md,'../Exp/79NorthShelf.exp','');
-md=parameterize(md,'../Par/79North.par');
-md=setflowequation(md,'macayeal','all');
-
-%Ice sheet only
-md=modelextract(md,md.mask.elementongroundedice);
-pos=find(md.mesh.vertexonboundary);
-md.balancethickness.spcthickness(pos)=md.geometry.thickness(pos);
-
-%control parameters
-md.inversion.thickness_obs=md.geometry.thickness;
-md.inversion.iscontrol=1;
-md.inversion.thickness_obs=md.geometry.thickness;
-md.inversion.nsteps=2;
-md.inversion.control_parameters={'Vx' 'Vy'};
-md.balancethickness.stabilization=1;
-md.inversion.gradient_scaling=[10/md.constants.yts*ones(md.inversion.nsteps,1) 10/md.constants.yts*ones(md.inversion.nsteps,1)];
-md.inversion.min_parameters=[-2000*ones(md.mesh.numberofvertices,1) -2000*ones(md.mesh.numberofvertices,1)];
-md.inversion.max_parameters=[+2000*ones(md.mesh.numberofvertices,1) +2000*ones(md.mesh.numberofvertices,1)];
-md.inversion.cost_functions=201*ones(md.inversion.nsteps,1);
-md.inversion.cost_functions_coefficients=ones(md.mesh.numberofvertices,1);
-md.inversion.maxiter_per_step=4*ones(md.inversion.nsteps,1);
-md.inversion.step_threshold=0.99*ones(md.inversion.nsteps,1);
-
-md.cluster=none;
-md=solve(md,BalancethicknessSolutionEnum);
-
-%Fields and tolerances to track changes
-field_names     ={'Gradient1' 'Gradient2' 'Misfits' 'Vx' 'Vy' 'Thickness'};
-field_tolerances={1e-12,1e-12,1e-12,1e-12,1e-12,1e-12};
-field_values={...
-	(md.results.BalancethicknessSolution.Gradient1),...
-	(md.results.BalancethicknessSolution.Gradient2),...
-	md.results.BalancethicknessSolution.J,...
-	(md.results.BalancethicknessSolution.Vx),...
-	(md.results.BalancethicknessSolution.Vy),...
-	(md.results.BalancethicknessSolution.Thickness)
-};
Index: /issm/branches/trunk-jpl-damage/test/Par/SquareShelfConstrained.py
===================================================================
--- /issm/branches/trunk-jpl-damage/test/Par/SquareShelfConstrained.py	(revision 12168)
+++ /issm/branches/trunk-jpl-damage/test/Par/SquareShelfConstrained.py	(revision 12168)
@@ -0,0 +1,59 @@
+from numpy import *
+from verbose import *
+import scipy.io as matio
+import InterpFromMeshToMesh2d as im
+from   paterson import  *
+
+#Start defining model parameters here
+#Geometry
+hmin = 300.
+hmax = 1000.
+ymin = min(md.mesh.y)
+ymax = max(md.mesh.y)
+
+md.geometry.thickness = hmax+(hmin-hmax)*(md.mesh.y-ymin)/(ymax-ymin)
+md.geometry.bed=-md.materials.rho_ice/md.materials.rho_water*md.geometry.thickness;
+md.geometry.surface = md.geometry.bed+md.geometry.thickness
+
+#Initial velocity 
+mat=matio.loadmat('../Data/SquareShelfConstrained.data')
+#deal with 'F' oriented matlab matrices!
+index=mat['index'].astype(float)
+index=reshape(index.T,(len(index),3),order='F')
+
+md.initialization.vx = im.InterpFromMeshToMesh2d(index, mat['x'], mat['y'], mat['vx'], md.mesh.x, md.mesh.y)
+md.initialization.vy = im.InterpFromMeshToMesh2d(index, mat['x'], mat['y'], mat['vy'], md.mesh.x, md.mesh.y)
+md.initialization.vz = zeros(md.mesh.numberofvertices)
+md.initialization.pressure = zeros(md.mesh.numberofvertices)
+#Materials
+md.initialization.temperature = (273.-20)*ones(md.mesh.numberofvertices)
+md.materials.rheology_B = paterson(md.initialization.temperature)
+md.materials.rheology_n = 3.*ones(md.mesh.numberofelements)
+#Surface mass balance and basal melting
+md.surfaceforcings.mass_balance = 10.*ones(md.mesh.numberofvertices)
+md.basalforcings.melting_rate = 5.*ones(md.mesh.numberofvertices)
+#Friction
+pos = nonzero(md.mask.elementonfloatingice)
+md.friction.coefficient = 20.*ones(md.mesh.numberofvertices)
+md.friction.coefficient[md.mesh.elements[pos,:].astype(int)-1] =0.
+md.friction.p = ones(md.mesh.numberofelements)
+md.friction.q = ones(md.mesh.numberofelements)
+#Numerical parameters
+md.diagnostic.viscosity_overshoot = 0.0
+md.prognostic.stabilization = 1.
+md.thermal.stabilization = 1.
+md.verbose = verbose()
+md.settings.waitonlock = 30.
+md.diagnostic.restol = 0.05
+md.diagnostic.reltol = 0.05
+md.steadystate.reltol = 0.05
+md.diagnostic.abstol = nan
+md.timestepping.time_step = 1.
+md.timestepping.final_time = 3.
+#Deal with boundary conditions:
+md = SetIceShelfBC(md)
+#Change name so that no test have the same name
+A = dbstack
+if length(A) > 2.:
+    md.miscellaneous.name = A[2].file[0:0-2.]
+
