Index: /issm/branches/trunk-jpl-damage/configs/config-macosx64-larour-ad.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/configs/config-macosx64-larour-ad.sh	(revision 11684)
+++ /issm/branches/trunk-jpl-damage/configs/config-macosx64-larour-ad.sh	(revision 11684)
@@ -0,0 +1,44 @@
+#!/bin/sh
+
+#petsc 3.2
+#mpich 1.4
+
+./configure \
+	--with-serial=no\
+	--prefix=$ISSM_TIER \
+	--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-petsc-arch=$ISSM_ARCH \
+	--with-blas-lapack-dir=$ISSM_TIER/externalpackages/petsc/install \
+	--with-chaco-dir=$ISSM_TIER/externalpackages/chaco/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-fortran-lib="/usr/local/lib/libgfortran.a" \
+	--with-dakota-dir=$ISSM_TIER/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-numthreads=8 \
+	--without-thermal \
+	--without-control \
+	--without-hydrology \
+	--without-diagnostic \
+	--without-balanced \
+	--without-responses \
+	--without-slope \
+	--without-rifts \
+	--without-steadystate \
+	--without-transient \
+	--without-3d \
+	--without-groundingline
+ 
+#--without-prognostic \
+
+ 
Index: /issm/branches/trunk-jpl-damage/configs/config-macosx64-larour.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/configs/config-macosx64-larour.sh	(revision 11684)
+++ /issm/branches/trunk-jpl-damage/configs/config-macosx64-larour.sh	(revision 11684)
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+#petsc 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-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-petsc-arch=$ISSM_ARCH \
+	--with-blas-lapack-dir=$ISSM_TIER/externalpackages/petsc/install \
+	--with-chaco-dir=$ISSM_TIER/externalpackages/chaco/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-fortran-lib="/usr/local/lib/libgfortran.a" \
+	--with-dakota-dir=$ISSM_TIER/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-numthreads=8
Index: /issm/branches/trunk-jpl-damage/configs/config-macosx64-nicole.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/configs/config-macosx64-nicole.sh	(revision 11684)
+++ /issm/branches/trunk-jpl-damage/configs/config-macosx64-nicole.sh	(revision 11684)
@@ -0,0 +1,28 @@
+#!/bin/sh
+
+#petsc 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-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-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-fortran-lib="/usr/local/gfortran/lib/gcc/x86_64-apple-darwin10/4.6.2/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
Index: /issm/branches/trunk-jpl-damage/configure.ac
===================================================================
--- /issm/branches/trunk-jpl-damage/configure.ac	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/configure.ac	(revision 11684)
@@ -19,5 +19,4 @@
 			src/Makefile
 			src/c/Makefile
-			src/ad/Makefile
 			src/mex/Makefile
 			src/m/Makefile
@@ -50,4 +49,6 @@
 			src/m/utils/Ecco3/Makefile
 			src/m/utils/Exp/Makefile
+			src/m/utils/Exp/manipulation/Makefile
+			src/m/utils/Exp/readwrite/Makefile
 			src/m/utils/Geometry/Makefile
 			src/m/utils/ImageProcessing/Makefile
Index: /issm/branches/trunk-jpl-damage/cron/configs/linux64_borstad_daily
===================================================================
--- /issm/branches/trunk-jpl-damage/cron/configs/linux64_borstad_daily	(revision 11684)
+++ /issm/branches/trunk-jpl-damage/cron/configs/linux64_borstad_daily	(revision 11684)
@@ -0,0 +1,100 @@
+#
+########### Configuration file for Mathieu Morlighem's nightly run on Linux ############
+
+#-------------------------------#
+# 1: ISSM general configuration #
+#-------------------------------#
+
+#ISSM main directory (full paths)
+ISSM_DIR="/u/astrid-r1b/cborstad/issmuci"
+ISSM_TIER="/u/astrid-r1b/cborstad/issmuci/trunk-jpl/cron/trunk-jpl"
+#ISSM_TIER="/u/astrid-r1b/seroussi/svn/issm/trunk/cron/issm2.2"
+
+#ISSM Architecture
+ISSM_ARCH="linux-gnu-amd64"
+
+#Machine configuration
+MACHINE="astrid"
+
+#COMPILATION CONFIGURATION FILE
+COMPILE_CONFIG_FILE="config-linux64-astrid.sh"
+
+#MATLAB path
+MATLAB_PATH="/usr/local/pkgs/matlab-7.6/"
+
+#----------------------#
+# 2: ISSM Installation #
+#----------------------#
+
+#ISSM_INSTALLATION can have 3 values:
+# - "checkout" the existing version of the code will be erased and
+#              the latest version will be checked out
+# - "update"   the directory won't be erased but ISSM will be updated
+#              ->skip to section 3
+# - "none"     leave ISSM as is in its directory
+#              ->skip to section 3
+ISSM_INSTALLATION="update"
+
+#SVN repository
+REPOSITORY="https://issm.ess.uci.edu/svn/issm/issm/trunk-jpl"
+#REPOSITORY="http://s383-rhat/issm/svn/issm/branches/issm2.2"
+
+#execution path used for parallel runs
+EXECUTION_PATH="/u/astrid-r1b/cborstad/ExecutionNightlyRun"
+
+#-----------------------------------#
+# 3: External packages installation #
+#-----------------------------------#
+
+#ISSM_EXTERNALPACKAGES can have 3 values:
+# - "install" install all external packages listed below
+# - "copy"    copy existing directories (EXTERNALPACKAGESDIR)
+# - "none"    leave external packages as is
+#             ->skip to section 4
+ISSM_EXTERNALPACKAGES="none"
+EXTERNALPACKAGESDIR="/u/astrid-r1b/cborstad/issmuci/trunk-jpl/externalpackages"
+
+#List of external pakages to be installed
+EXTERNALPACKAGES="autoconf automake matlab mpich2 petsc metis triangle dakota chaco"
+
+#Corresponding list of installation files to use
+EXTERNALPACKAGES_CONFIGS=" install.sh install.sh install.sh install-1.0.2-linux64.sh install-3.2-linux64.sh install-4.0-linux64.sh install-linux64.sh install-linux64-astrid.sh install.sh"
+
+#---------------------#
+# 4: ISSM Compilation #
+#---------------------#
+
+#ISSM_COMPILATION can have 2 values:
+# - "yes" compile ISSM
+# - "no"  do not compile ISSM
+ISSM_COMPILATION="yes"
+
+#----------------------#
+# 5: Mail notification #
+#----------------------#
+
+#Mail delivery. If SKIPMAIL="no", the html nightly run report will be
+#sent to the adresses present in $ISSM_TIER/cron/mailinglist.
+SKIPMAIL="no"
+
+#Sender email address
+EMAIL_ADRESS="cborstad@jpl.nasa.gov"
+
+#------------------------#
+# 6: Nightly run options #
+#------------------------#
+
+#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
+
+#number of cpus used in the nightly runs.
+NUMCPUS_RUN=7
+
+#Nightly run options. The matlab routine nightlyrun.m will be called
+#as follows: nightlyrun($NROPTIONS). The options must be understandable
+#by Matlab and nightlyrun.m
+#ex: "'id',[101 102 103]"
+
+NROPTIONS=""
+
Index: /issm/branches/trunk-jpl-damage/cron/configs/linux64_borstad_nightly
===================================================================
--- /issm/branches/trunk-jpl-damage/cron/configs/linux64_borstad_nightly	(revision 11684)
+++ /issm/branches/trunk-jpl-damage/cron/configs/linux64_borstad_nightly	(revision 11684)
@@ -0,0 +1,100 @@
+#
+########### Configuration file for Mathieu Morlighem's nightly run on Linux ############
+
+#-------------------------------#
+# 1: ISSM general configuration #
+#-------------------------------#
+
+#ISSM main directory (full path)
+ISSM_DIR="/u/astrid-r1b/cborstad/issmuci"
+ISSM_TIER="/u/astrid-r1b/cborstad/issmuci/trunk-jpl/cron/trunk-jpl"
+#ISSM_TIER="/u/astrid-r1b/seroussi/svn/issm/trunk/cron/issm2.2"
+
+#ISSM Architecture
+ISSM_ARCH="linux-gnu-amd64"
+
+#Machine configuration
+MACHINE="astrid"
+
+#COMPILATION CONFIGURATION FILE
+COMPILE_CONFIG_FILE="config-linux64-astrid.sh"
+
+#MATLAB path
+MATLAB_PATH="/usr/local/pkgs/matlab-7.6/"
+
+#----------------------#
+# 2: ISSM Installation #
+#----------------------#
+
+#ISSM_INSTALLATION can have 3 values:
+# - "checkout" the existing version of the code will be erased and
+#              the latest version will be checked out
+# - "update"   the directory won't be erased but ISSM will be updated
+#              ->skip to section 3
+# - "none"     leave ISSM as is in its directory
+#              ->skip to section 3
+ISSM_INSTALLATION="checkout"
+
+#SVN repository
+REPOSITORY="https://issm.ess.uci.edu/svn/issm/issm/trunk-jpl"
+#REPOSITORY="http://s383-rhat/issm/svn/issm/branches/issm2.2"
+
+#execution path used for parallel runs
+EXECUTION_PATH="/u/astrid-r1b/cborstad/ExecutionNightlyRun"
+
+#-----------------------------------#
+# 3: External packages installation #
+#-----------------------------------#
+
+#ISSM_EXTERNALPACKAGES can have 3 values:
+# - "install" install all external packages listed below
+# - "copy"    copy existing directories (EXTERNALPACKAGESDIR)
+# - "none"    leave external packages as is
+#             ->skip to section 4
+ISSM_EXTERNALPACKAGES="install"
+EXTERNALPACKAGESDIR="/u/astrid-r1b/cborstad/issmuci/trunk-jpl/externalpackages"
+
+#List of external pakages to be installed
+EXTERNALPACKAGES="autoconf automake matlab mpich2 petsc metis triangle dakota chaco"
+
+#Corresponding list of installation files to use
+EXTERNALPACKAGES_CONFIGS=" install.sh install.sh install.sh install-1.0.2-linux64.sh install-3.2-linux64.sh install-4.0-linux64.sh install-linux64.sh install-linux64-astrid.sh install.sh"
+
+#---------------------#
+# 4: ISSM Compilation #
+#---------------------#
+
+#ISSM_COMPILATION can have 2 values:
+# - "yes" compile ISSM
+# - "no"  do not compile ISSM
+ISSM_COMPILATION="yes"
+
+#----------------------#
+# 5: Mail notification #
+#----------------------#
+
+#Mail delivery. If SKIPMAIL="no", the html nightly run report will be
+#sent to the adresses present in $ISSM_TIER/cron/mailinglist.
+SKIPMAIL="no"
+
+#Sender email address
+EMAIL_ADRESS="cborstad@jpl.nasa.gov"
+
+#------------------------#
+# 6: Nightly run options #
+#------------------------#
+
+#number of cpus used in ISSM installation and compilation (one is usually
+#safer as some packages are very sensitive to parallel compilation)
+NUMCPUS_INSTALL=1
+
+#number of cpus used in the nightly runs.
+NUMCPUS_RUN=7
+
+#Nightly run options. The matlab routine nightlyrun.m will be called
+#as follows: nightlyrun($NROPTIONS). The options must be understandable
+#by Matlab and nightlyrun.m
+#ex: "'id',[101 102 103]"
+
+NROPTIONS=""
+
Index: /issm/branches/trunk-jpl-damage/cron/configs/linux64_borstad_ucitrunk
===================================================================
--- /issm/branches/trunk-jpl-damage/cron/configs/linux64_borstad_ucitrunk	(revision 11684)
+++ /issm/branches/trunk-jpl-damage/cron/configs/linux64_borstad_ucitrunk	(revision 11684)
@@ -0,0 +1,99 @@
+#
+########### Configuration file for Mathieu Morlighem's nightly run on Linux ############
+
+#-------------------------------#
+# 1: ISSM general configuration #
+#-------------------------------#
+
+#ISSM main directory (full path)
+ISSM_DIR="/u/astrid-r1b/cborstad/issmuci"
+ISSM_TIER="/u/astrid-r1b/cborstad/issmuci/trunk-jpl/cron/trunk"
+#ISSM_TIER="/u/astrid-r1b/seroussi/svn/issm/trunk/cron/issm2.2"
+
+#ISSM Architecture
+ISSM_ARCH="linux-gnu-amd64"
+
+#Machine configuration
+MACHINE="astrid"
+
+#COMPILATION CONFIGURATION FILE
+COMPILE_CONFIG_FILE="config-linux64-astrid.sh"
+
+#MATLAB path
+MATLAB_PATH="/usr/local/pkgs/matlab-7.6/"
+
+#----------------------#
+# 2: ISSM Installation #
+#----------------------#
+
+#ISSM_INSTALLATION can have 3 values:
+# - "checkout" the existing version of the code will be erased and
+#              the latest version will be checked out
+# - "update"   the directory won't be erased but ISSM will be updated
+#              ->skip to section 3
+# - "none"     leave ISSM as is in its directory
+#              ->skip to section 3
+ISSM_INSTALLATION="checkout"
+
+#SVN repository
+REPOSITORY="https://issm.ess.uci.edu/svn/issm/issm/trunk"
+#REPOSITORY="http://s383-rhat/issm/svn/issm/branches/issm2.2"
+
+#execution path used for parallel runs
+EXECUTION_PATH="/u/astrid-r1b/cborstad/ExecutionNightlyRun"
+
+#-----------------------------------#
+# 3: External packages installation #
+#-----------------------------------#
+
+#ISSM_EXTERNALPACKAGES can have 3 values:
+# - "install" install all external packages listed below
+# - "copy"    copy existing directories (EXTERNALPACKAGESDIR)
+# - "none"    leave external packages as is
+#             ->skip to section 4
+ISSM_EXTERNALPACKAGES="install"
+EXTERNALPACKAGESDIR="/u/astrid-r1b/cborstad/issmuci/trunk-jpl/externalpackages"
+
+#List of external pakages to be installed
+EXTERNALPACKAGES="autoconf automake matlab mpich2 petsc metis triangle dakota chaco"
+
+#Corresponding list of installation files to use
+EXTERNALPACKAGES_CONFIGS=" install.sh install.sh install.sh install-1.0.2-linux64.sh install-3.2-linux64.sh install-4.0-linux64.sh install-linux64.sh install-linux64-astrid.sh install.sh"
+
+#---------------------#
+# 4: ISSM Compilation #
+#---------------------#
+
+#ISSM_COMPILATION can have 2 values:
+# - "yes" compile ISSM
+# - "no"  do not compile ISSM
+ISSM_COMPILATION="yes"
+
+#----------------------#
+# 5: Mail notification #
+#----------------------#
+
+#Mail delivery. If SKIPMAIL="no", the html nightly run report will be
+#sent to the adresses present in $ISSM_TIER/cron/mailinglist.
+SKIPMAIL="no"
+
+#Sender email address
+EMAIL_ADRESS="cborstad@jpl.nasa.gov"
+
+#------------------------#
+# 6: Nightly run options #
+#------------------------#
+
+#number of cpus used in ISSM installation and compilation (one is usually
+#safer as some packages are very sensitive to parallel compilation)
+NUMCPUS_INSTALL=1
+
+#number of cpus used in the nightly runs.
+NUMCPUS_RUN=7
+
+#Nightly run options. The matlab routine nightlyrun.m will be called
+#as follows: nightlyrun($NROPTIONS). The options must be understandable
+#by Matlab and nightlyrun.m
+#ex: "'id',[101 102 103]"
+
+NROPTIONS=""
Index: /issm/branches/trunk-jpl-damage/cron/configs/linux64_borstad_validation
===================================================================
--- /issm/branches/trunk-jpl-damage/cron/configs/linux64_borstad_validation	(revision 11684)
+++ /issm/branches/trunk-jpl-damage/cron/configs/linux64_borstad_validation	(revision 11684)
@@ -0,0 +1,99 @@
+########### Configuration file for Mathieu Morlighem's nightly run on Linux ############
+
+#-------------------------------#
+# 1: ISSM general configuration #
+#-------------------------------#
+
+#ISSM main directory (full path)
+ISSM_DIR="/u/astrid-r1b/cborstad/issmuci"
+ISSM_TIER="/u/astrid-r1b/cborstad/issmuci/trunk-jpl/cron/trunk-jpl"
+#ISSM_TIER="/u/astrid-r1b/seroussi/svn/issm/trunk/cron/issm2.2"
+
+#ISSM Architecture
+ISSM_ARCH="linux-gnu-amd64"
+
+#Machine configuration
+MACHINE="astrid"
+
+#COMPILATION CONFIGURATION FILE
+COMPILE_CONFIG_FILE="config-linux64-astrid.sh"
+
+#MATLAB path
+MATLAB_PATH="/usr/local/pkgs/matlab-7.6/"
+
+#----------------------#
+# 2: ISSM Installation #
+#----------------------#
+
+#ISSM_INSTALLATION can have 3 values:
+# - "checkout" the existing version of the code will be erased and
+#              the latest version will be checked out
+# - "update"   the directory won't be erased but ISSM will be updated
+#              ->skip to section 3
+# - "none"     leave ISSM as is in its directory
+#              ->skip to section 3
+ISSM_INSTALLATION="checkout"
+
+#SVN repository
+REPOSITORY="https://issm.ess.uci.edu/svn/issm/issm/trunk-jpl"
+#REPOSITORY="http://s383-rhat/issm/svn/issm/branches/issm2.2"
+
+#execution path used for parallel runs
+EXECUTION_PATH="/u/astrid-r1b/cborstad/ExecutionNightlyRun"
+
+#-----------------------------------#
+# 3: External packages installation #
+#-----------------------------------#
+
+#ISSM_EXTERNALPACKAGES can have 3 values:
+# - "install" install all external packages listed below
+# - "copy"    copy existing directories (EXTERNALPACKAGESDIR)
+# - "none"    leave external packages as is
+#             ->skip to section 4
+ISSM_EXTERNALPACKAGES="install"
+EXTERNALPACKAGESDIR="/u/astrid-r1b/cborstad/issmuci/trunk-jpl/externalpackages"
+
+#List of external pakages to be installed
+EXTERNALPACKAGES="autoconf automake matlab mpich2 petsc metis triangle dakota chaco yams"
+
+#Corresponding list of installation files to use
+EXTERNALPACKAGES_CONFIGS=" install.sh install.sh install.sh install-1.0.2-linux64.sh install-3.2-linux64.sh install-4.0-linux64.sh install-linux64.sh install-linux64-astrid.sh install.sh install.sh"
+
+#---------------------#
+# 4: ISSM Compilation #
+#---------------------#
+
+#ISSM_COMPILATION can have 2 values:
+# - "yes" compile ISSM
+# - "no"  do not compile ISSM
+ISSM_COMPILATION="yes"
+
+#----------------------#
+# 5: Mail notification #
+#----------------------#
+
+#Mail delivery. If SKIPMAIL="no", the html nightly run report will be
+#sent to the adresses present in $ISSM_TIER/cron/mailinglist.
+SKIPMAIL="no"
+
+#Sender email address
+EMAIL_ADRESS="cborstad@jpl.nasa.gov"
+
+#------------------------#
+# 6: Nightly run options #
+#------------------------#
+
+#number of cpus used in ISSM installation and compilation (one is usually
+#safer as some packages are very sensitive to parallel compilation)
+NUMCPUS_INSTALL=1
+
+#number of cpus used in the nightly runs.
+NUMCPUS_RUN=7
+
+#Nightly run options. The matlab routine nightlyrun.m will be called
+#as follows: nightlyrun($NROPTIONS). The options must be understandable
+#by Matlab and nightlyrun.m
+#ex: "'id',[101 102 103]"
+
+NROPTIONS="'benchmark','all'"
+
Index: /issm/branches/trunk-jpl-damage/cron/configs/linux64_schlegel_daily
===================================================================
--- /issm/branches/trunk-jpl-damage/cron/configs/linux64_schlegel_daily	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/cron/configs/linux64_schlegel_daily	(revision 11684)
@@ -19,4 +19,7 @@
 #COMPILATION CONFIGURATION FILE
 COMPILE_CONFIG_FILE="config-linux64-astrid.sh"
+
+#MATLAB path
+MATLAB_PATH="/usr/local/pkgs/matlab-7.6/"
 
 #----------------------#
@@ -57,5 +60,4 @@
 #Corresponding list of installation files to use
 EXTERNALPACKAGES_CONFIGS=" install.sh install.sh install.sh install-1.0.2-linux64.sh install-3.2-linux64.sh install-4.0-linux64.sh install-linux64.sh install-linux64-astrid.sh install.sh"
-EXTERNALPACKAGES_NUMCPUS=" 8 8 8 8 8 8"
 
 #---------------------#
@@ -97,10 +99,2 @@
 NROPTIONS=""
 
-#------------------------#
-# 7: Matlab#
-#------------------------#
-
-#MATLAB path
-MATLAB_PATH="/usr/local/pkgs/matlab-7.6/"
-
-MATLABBIN="/usr/local/pkgs/matlab-7.6/bin/matlab"
Index: /issm/branches/trunk-jpl-damage/cron/configs/linux64_schlegel_nightly
===================================================================
--- /issm/branches/trunk-jpl-damage/cron/configs/linux64_schlegel_nightly	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/cron/configs/linux64_schlegel_nightly	(revision 11684)
@@ -19,4 +19,7 @@
 #COMPILATION CONFIGURATION FILE
 COMPILE_CONFIG_FILE="config-linux64-astrid.sh"
+
+#MATLAB path
+MATLAB_PATH="/usr/local/pkgs/matlab-7.6/"
 
 #----------------------#
@@ -57,5 +60,4 @@
 #Corresponding list of installation files to use
 EXTERNALPACKAGES_CONFIGS=" install.sh install.sh install.sh install-1.0.2-linux64.sh install-3.2-linux64.sh install-4.0-linux64.sh install-linux64.sh install-linux64-astrid.sh install.sh"
-EXTERNALPACKAGES_NUMCPUS=" 1 1 1 1 1 1"
 
 #---------------------#
@@ -97,11 +99,2 @@
 NROPTIONS=""
 
-
-#------------------------#
-# 7: Matlab#
-#------------------------#
-
-#MATLAB path
-MATLAB_PATH="/usr/local/pkgs/matlab-7.6/"
-
-MATLABBIN="/usr/local/pkgs/matlab-7.6/bin/matlab"
Index: /issm/branches/trunk-jpl-damage/cron/configs/linux64_schlegel_ucitrunk
===================================================================
--- /issm/branches/trunk-jpl-damage/cron/configs/linux64_schlegel_ucitrunk	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/cron/configs/linux64_schlegel_ucitrunk	(revision 11684)
@@ -16,4 +16,7 @@
 #Machine configuration
 MACHINE="astrid"
+
+#COMPILATION CONFIGURATION FILE
+COMPILE_CONFIG_FILE="config-linux64-astrid.sh"
 
 #MATLAB path
@@ -55,4 +58,7 @@
 EXTERNALPACKAGES="autoconf automake matlab mpich2 petsc metis triangle dakota chaco"
 
+#Corresponding list of installation files to use
+EXTERNALPACKAGES_CONFIGS=" install.sh install.sh install.sh install-1.0.2-linux64.sh install-3.2-linux64.sh install-4.0-linux64.sh install-linux64.sh install-linux64-astrid.sh install.sh"
+
 #---------------------#
 # 4: ISSM Compilation #
Index: /issm/branches/trunk-jpl-damage/cron/configs/linux64_schlegel_validation
===================================================================
--- /issm/branches/trunk-jpl-damage/cron/configs/linux64_schlegel_validation	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/cron/configs/linux64_schlegel_validation	(revision 11684)
@@ -18,4 +18,7 @@
 #COMPILATION CONFIGURATION FILE
 COMPILE_CONFIG_FILE="config-linux64-astrid.sh"
+
+#MATLAB path
+MATLAB_PATH="/usr/local/pkgs/matlab-7.6/"
 
 #----------------------#
@@ -55,6 +58,5 @@
 
 #Corresponding list of installation files to use
-EXTERNALPACKAGES_CONFIGS=" install.sh install.sh install.sh install-1.0.2-linux64.sh install-3.2-linux64.sh install-4.0-linux64.sh install-linux64.sh install-linux64-astrid.sh install.sh"
-EXTERNALPACKAGES_NUMCPUS=" 1 1 1 1 1 1"
+EXTERNALPACKAGES_CONFIGS=" install.sh install.sh install.sh install-1.0.2-linux64.sh install-3.2-linux64.sh install-4.0-linux64.sh install-linux64.sh install-linux64-astrid.sh install.sh install.sh"
 
 #---------------------#
@@ -96,10 +98,2 @@
 NROPTIONS="'benchmark','all'"
 
-#------------------------#
-# 7: Matlab#
-#------------------------#
-
-#MATLAB path
-MATLAB_PATH="/usr/local/pkgs/matlab-7.6/"
-
-MATLABBIN="/usr/local/pkgs/matlab-7.6/bin/matlab"
Index: /issm/branches/trunk-jpl-damage/cron/configs/macosx64_borstad
===================================================================
--- /issm/branches/trunk-jpl-damage/cron/configs/macosx64_borstad	(revision 11684)
+++ /issm/branches/trunk-jpl-damage/cron/configs/macosx64_borstad	(revision 11684)
@@ -0,0 +1,98 @@
+#
+########### Configuration file for Mathieu Morlighem's nightly run on Linux ############
+
+#-------------------------------#
+# 1: ISSM general configuration #
+#-------------------------------#
+
+#ISSM main directory (full path)
+ISSM_DIR="/Users/cborstad/issmuci"
+ISSM_TIER="/Users/cborstad/issmuci/trunk-jpl/cron/trunk-jpl"
+
+#ISSM Architecture
+ISSM_ARCH="macosx-gnu"
+
+#Machine configuration
+MACHINE="macosx-gil"
+
+#COMPILATION CONFIGURATION FILE
+COMPILE_CONFIG_FILE="config-macosx64-chris.sh"
+
+#MATLAB path
+MATLAB_PATH="/Applications/MATLAB_R2011b.app/"
+
+#----------------------#
+# 2: ISSM Installation #
+#----------------------#
+
+#ISSM_INSTALLATION can have 3 values:
+# - "checkout" the existing version of the code will be erased and
+#              the latest version will be checked out
+# - "update"   the directory won't be erased but ISSM will be updated
+#              ->skip to section 3
+# - "none"     leave ISSM as is in its directory
+#              ->skip to section 3
+ISSM_INSTALLATION="checkout"
+
+#SVN repository
+REPOSITORY="https://issm.ess.uci.edu/svn/issm/issm/trunk-jpl"
+
+#execution path used for parallel runs
+EXECUTION_PATH="/Users/cborstad/ExecutionNightlyRun"
+
+#-----------------------------------#
+# 3: External packages installation #
+#-----------------------------------#
+
+#ISSM_EXTERNALPACKAGES can have 3 values:
+# - "install" install all external packages listed below
+# - "copy"    copy existing directories (EXTERNALPACKAGESDIR)
+# - "none"    leave external packages as is
+#             ->skip to section 4
+ISSM_EXTERNALPACKAGES="install"
+EXTERNALPACKAGESDIR="/Users/cborstad/issmuci/trunk-jpl/externalpackages"
+
+#List of external pakages to be installed
+EXTERNALPACKAGES="autoconf automake matlab mpich2 petsc metis triangle dakota chaco"
+
+#Corresponding list of installation files to use
+EXTERNALPACKAGES_CONFIGS=" install.sh install.sh install.sh install-1.4-macosx64.sh install-3.2-macosx64.sh install-4.0-macosx64.sh install-macosx64.sh install-macosx64.sh install.sh"
+
+#---------------------#
+# 4: ISSM Compilation #
+#---------------------#
+
+#ISSM_COMPILATION can have 2 values:
+# - "yes" compile ISSM
+# - "no"  do not compile ISSM
+ISSM_COMPILATION="yes"
+
+#----------------------#
+# 5: Mail notification #
+#----------------------#
+
+#Mail delivery. If SKIPMAIL="no", the html nightly run report will be
+#sent to the adresses present in $ISSM_TIER/cron/mailinglist.
+SKIPMAIL="no"
+
+#Sender email address
+EMAIL_ADRESS="cborstad@jpl.nasa.gov"
+
+#------------------------#
+# 6: Nightly run options #
+#------------------------#
+
+#number of cpus used in ISSM installation and compilation (one is usually
+#safer as some packages are very sensitive to parallel compilation)
+NUMCPUS_INSTALL=1
+
+#number of cpus used in the nightly runs.
+NUMCPUS_RUN=4
+
+#Nightly run options. The matlab routine nightlyrun.m will be called
+#as follows: nightlyrun($NROPTIONS). The options must be understandable
+#by Matlab and nightlyrun.m
+#ex: "'id',[101 102 103]"
+
+NROPTIONS="'exclude',[137 425:434 527]"
+
Index: /issm/branches/trunk-jpl-damage/cron/configs/macosx64_borstad_daily
===================================================================
--- /issm/branches/trunk-jpl-damage/cron/configs/macosx64_borstad_daily	(revision 11684)
+++ /issm/branches/trunk-jpl-damage/cron/configs/macosx64_borstad_daily	(revision 11684)
@@ -0,0 +1,98 @@
+#
+########### Configuration file for Mathieu Morlighem's nightly run on Linux ############
+
+#-------------------------------#
+# 1: ISSM general configuration #
+#-------------------------------#
+
+#ISSM main directory (full path)
+ISSM_DIR="/Users/cborstad/issmuci"
+ISSM_TIER="/Users/cborstad/issmuci/trunk-jpl/cron/trunk-jpl"
+
+#ISSM Architecture
+ISSM_ARCH="macosx-gnu"
+
+#Machine configuration
+MACHINE="macosx-gil"
+
+#COMPILATION CONFIGURATION FILE
+COMPILE_CONFIG_FILE="config-macosx64-nicole.sh"
+
+#MATLAB path
+MATLAB_PATH="/Applications/MATLAB_R2011b.app/"
+
+#----------------------#
+# 2: ISSM Installation #
+#----------------------#
+
+#ISSM_INSTALLATION can have 3 values:
+# - "checkout" the existing version of the code will be erased and
+#              the latest version will be checked out
+# - "update"   the directory won't be erased but ISSM will be updated
+#              ->skip to section 3
+# - "none"     leave ISSM as is in its directory
+#              ->skip to section 3
+ISSM_INSTALLATION="update"
+
+#SVN repository
+REPOSITORY="https://issm.ess.uci.edu/svn/issm/issm/trunk-jpl"
+
+#execution path used for parallel runs
+EXECUTION_PATH="/Users/cborstad/ExecutionNightlyRun"
+
+#-----------------------------------#
+# 3: External packages installation #
+#-----------------------------------#
+
+#ISSM_EXTERNALPACKAGES can have 3 values:
+# - "install" install all external packages listed below
+# - "copy"    copy existing directories (EXTERNALPACKAGESDIR)
+# - "none"    leave external packages as is
+#             ->skip to section 4
+ISSM_EXTERNALPACKAGES="none"
+EXTERNALPACKAGESDIR="/Users/cborstad/issmuci/trunk-jpl/externalpackages"
+
+#List of external pakages to be installed
+EXTERNALPACKAGES="autoconf automake matlab mpich2 petsc metis triangle dakota chaco"
+
+#Corresponding list of installation files to use
+EXTERNALPACKAGES_CONFIGS=" install.sh install.sh install.sh install-1.4-macosx64.sh install-3.2-macosx64.sh install-4.0-macosx64.sh install-macosx64.sh install-macosx64.sh install.sh"
+
+#---------------------#
+# 4: ISSM Compilation #
+#---------------------#
+
+#ISSM_COMPILATION can have 2 values:
+# - "yes" compile ISSM
+# - "no"  do not compile ISSM
+ISSM_COMPILATION="yes"
+
+#----------------------#
+# 5: Mail notification #
+#----------------------#
+
+#Mail delivery. If SKIPMAIL="no", the html nightly run report will be
+#sent to the adresses present in $ISSM_TIER/cron/mailinglist.
+SKIPMAIL="no"
+
+#Sender email address
+EMAIL_ADRESS="cborstad@jpl.nasa.gov"
+
+#------------------------#
+# 6: Nightly run options #
+#------------------------#
+
+#number of cpus used in ISSM installation and compilation (one is usually
+#safer as some packages are very sensitive to parallel compilation)
+NUMCPUS_INSTALL=4
+
+#number of cpus used in the nightly runs.
+NUMCPUS_RUN=4
+
+#Nightly run options. The matlab routine nightlyrun.m will be called
+#as follows: nightlyrun($NROPTIONS). The options must be understandable
+#by Matlab and nightlyrun.m
+#ex: "'id',[101 102 103]"
+
+NROPTIONS="'exclude',[137 425:434 527]"
+
Index: /issm/branches/trunk-jpl-damage/cron/configs/macosx64_larour
===================================================================
--- /issm/branches/trunk-jpl-damage/cron/configs/macosx64_larour	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/cron/configs/macosx64_larour	(revision 11684)
@@ -48,5 +48,5 @@
 # - "none"    leave external packages as is
 #             ->skip to section 4
-ISSM_EXTERNALPACKAGES="install"
+ISSM_EXTERNALPACKAGES="copy"
 EXTERNALPACKAGESDIR="/Users/larour/issm-uci/trunk-jpl/externalpackages"
 
@@ -73,8 +73,8 @@
 #Mail delivery. If SKIPMAIL="no", the html nightly run report will be
 #sent to the adresses present in $ISSM_TIER/cron/mailinglist.
-SKIPMAIL="no"
+SKIPMAIL="yes"
 
 #Sender email address
-EMAIL_ADRESS="schlegel@jpl.nasa.gov"
+EMAIL_ADRESS="eric.larour@jpl.nasa.gov"
 
 #------------------------#
@@ -84,8 +84,8 @@
 #number of cpus used in ISSM installation and compilation (one is usually
 #safer as some packages are very sensitive to parallel compilation)
-NUMCPUS_INSTALL=1
+NUMCPUS_INSTALL=4
 
 #number of cpus used in the nightly runs.
-NUMCPUS_RUN=7
+NUMCPUS_RUN=1
 
 #Nightly run options. The matlab routine nightlyrun.m will be called
@@ -102,5 +102,5 @@
 
 #MATLAB path
-MATLAB_PATH="/usr/local/pkgs/matlab-7.6/"
+MATLAB_PATH="/Applications/MATLAB_R2010a.app/"
 
-MATLABBIN="/usr/local/pkgs/matlab-7.6/bin/matlab"
+MATLABBIN="/Applications/MATLAB_R2010a.app/bin/matlab"
Index: /issm/branches/trunk-jpl-damage/cron/configs/macosx64_larour_validation
===================================================================
--- /issm/branches/trunk-jpl-damage/cron/configs/macosx64_larour_validation	(revision 11684)
+++ /issm/branches/trunk-jpl-damage/cron/configs/macosx64_larour_validation	(revision 11684)
@@ -0,0 +1,108 @@
+#
+########### Configuration file for Mathieu Morlighem's nightly run on Linux ############
+
+#-------------------------------#
+# 1: ISSM general configuration #
+#-------------------------------#
+
+#ISSM main directory (full path)
+ISSM_DIR="/Users/larour/issm-uci"
+ISSM_TIER="/Users/larour/issm-uci/trunk-jpl/cron/trunk-jpl"
+
+#ISSM Architecture
+ISSM_ARCH="macosx-gnu"
+
+#Machine configuration
+MACHINE="macosx-gil"
+
+#COMPILATION CONFIGURATION FILE
+COMPILE_CONFIG_FILE="config-macosx64-larour.sh"
+
+
+#----------------------#
+# 2: ISSM Installation #
+#----------------------#
+
+#ISSM_INSTALLATION can have 3 values:
+# - "checkout" the existing version of the code will be erased and
+#              the latest version will be checked out
+# - "update"   the directory won't be erased but ISSM will be updated
+#              ->skip to section 3
+# - "none"     leave ISSM as is in its directory
+#              ->skip to section 3
+ISSM_INSTALLATION="checkout"
+
+#SVN repository
+REPOSITORY="https://issm.ess.uci.edu/svn/issm/issm/trunk-jpl"
+
+#execution path used for parallel runs
+EXECUTION_PATH="/Users/larour/ExecutionNightlyRun"
+
+#-----------------------------------#
+# 3: External packages installation #
+#-----------------------------------#
+
+#ISSM_EXTERNALPACKAGES can have 3 values:
+# - "install" install all external packages listed below
+# - "copy"    copy existing directories (EXTERNALPACKAGESDIR)
+# - "none"    leave external packages as is
+#             ->skip to section 4
+ISSM_EXTERNALPACKAGES="link"
+EXTERNALPACKAGESDIR="/Users/larour/issm-uci/trunk-jpl/externalpackages"
+
+#List of external pakages to be installed
+EXTERNALPACKAGES="autoconf automake matlab mpich2 petsc metis triangle dakota chaco"
+
+#Corresponding list of installation files to use
+EXTERNALPACKAGES_CONFIGS=" install.sh install.sh install.sh install-1.0.2-linux64.sh install-3.2-linux64.sh install-4.0-linux64.sh install-linux64.sh install-linux64-astrid.sh install.sh"
+EXTERNALPACKAGES_NUMCPUS=" 1 1 1 1 1 1"
+
+#---------------------#
+# 4: ISSM Compilation #
+#---------------------#
+
+#ISSM_COMPILATION can have 2 values:
+# - "yes" compile ISSM
+# - "no"  do not compile ISSM
+ISSM_COMPILATION="yes"
+
+#----------------------#
+# 5: Mail notification #
+#----------------------#
+
+#Mail delivery. If SKIPMAIL="no", the html nightly run report will be
+#sent to the adresses present in $ISSM_TIER/cron/mailinglist.
+SKIPMAIL="yes"
+
+#Sender email address
+EMAIL_ADRESS="eric.larour@jpl.nasa.gov"
+
+#------------------------#
+# 6: Nightly run options #
+#------------------------#
+
+#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
+
+#number of cpus used in the nightly runs.
+NUMCPUS_RUN=1
+
+#Nightly run options. The matlab routine nightlyrun.m will be called
+#as follows: nightlyrun($NROPTIONS). The options must be understandable
+#by Matlab and nightlyrun.m
+#ex: "'id',[101 102 103]"
+
+NROPTIONS="'id',101:151"
+
+#------------------------#
+# 7: Matlab#
+#------------------------#
+
+#MATLAB path
+MATLAB_PATH="/Applications/MATLAB_R2010a.app/"
+
+MATLABBIN="/Applications/MATLAB_R2010a.app/bin/matlab"
+
+#Specialty one: 
+export  FC=gfortran
Index: /issm/branches/trunk-jpl-damage/cron/configs/macosx64_schlegel
===================================================================
--- /issm/branches/trunk-jpl-damage/cron/configs/macosx64_schlegel	(revision 11684)
+++ /issm/branches/trunk-jpl-damage/cron/configs/macosx64_schlegel	(revision 11684)
@@ -0,0 +1,98 @@
+#
+########### Configuration file for Mathieu Morlighem's nightly run on Linux ############
+
+#-------------------------------#
+# 1: ISSM general configuration #
+#-------------------------------#
+
+#ISSM main directory (full path)
+ISSM_DIR="/Users/schlegel/issmuci"
+ISSM_TIER="/Users/schlegel/issmuci/trunk-jpl/cron/trunk-jpl"
+
+#ISSM Architecture
+ISSM_ARCH="macosx-gnu"
+
+#Machine configuration
+MACHINE="macosx-gil"
+
+#COMPILATION CONFIGURATION FILE
+COMPILE_CONFIG_FILE="config-macosx64-nicole.sh"
+
+#MATLAB path
+MATLAB_PATH="/Applications/MATLAB_R2011b.app/"
+
+#----------------------#
+# 2: ISSM Installation #
+#----------------------#
+
+#ISSM_INSTALLATION can have 3 values:
+# - "checkout" the existing version of the code will be erased and
+#              the latest version will be checked out
+# - "update"   the directory won't be erased but ISSM will be updated
+#              ->skip to section 3
+# - "none"     leave ISSM as is in its directory
+#              ->skip to section 3
+ISSM_INSTALLATION="checkout"
+
+#SVN repository
+REPOSITORY="https://issm.ess.uci.edu/svn/issm/issm/trunk-jpl"
+
+#execution path used for parallel runs
+EXECUTION_PATH="/Users/schlegel/ExecutionNightlyRun"
+
+#-----------------------------------#
+# 3: External packages installation #
+#-----------------------------------#
+
+#ISSM_EXTERNALPACKAGES can have 3 values:
+# - "install" install all external packages listed below
+# - "copy"    copy existing directories (EXTERNALPACKAGESDIR)
+# - "none"    leave external packages as is
+#             ->skip to section 4
+ISSM_EXTERNALPACKAGES="install"
+EXTERNALPACKAGESDIR="/Users/schlegel/issmuci/trunk-jpl/externalpackages"
+
+#List of external pakages to be installed
+EXTERNALPACKAGES="autoconf automake matlab mpich2 petsc metis triangle dakota chaco"
+
+#Corresponding list of installation files to use
+EXTERNALPACKAGES_CONFIGS=" install.sh install.sh install.sh install-1.4-macosx64.sh install-3.2-macosx64.sh install-4.0-macosx64.sh install-macosx64.sh install-macosx64.sh install.sh"
+
+#---------------------#
+# 4: ISSM Compilation #
+#---------------------#
+
+#ISSM_COMPILATION can have 2 values:
+# - "yes" compile ISSM
+# - "no"  do not compile ISSM
+ISSM_COMPILATION="yes"
+
+#----------------------#
+# 5: Mail notification #
+#----------------------#
+
+#Mail delivery. If SKIPMAIL="no", the html nightly run report will be
+#sent to the adresses present in $ISSM_TIER/cron/mailinglist.
+SKIPMAIL="no"
+
+#Sender email address
+EMAIL_ADRESS="schlegel@jpl.nasa.gov"
+
+#------------------------#
+# 6: Nightly run options #
+#------------------------#
+
+#number of cpus used in ISSM installation and compilation (one is usually
+#safer as some packages are very sensitive to parallel compilation)
+NUMCPUS_INSTALL=1
+
+#number of cpus used in the nightly runs.
+NUMCPUS_RUN=4
+
+#Nightly run options. The matlab routine nightlyrun.m will be called
+#as follows: nightlyrun($NROPTIONS). The options must be understandable
+#by Matlab and nightlyrun.m
+#ex: "'id',[101 102 103]"
+
+NROPTIONS="'exclude',[137 425:434 527]"
+
Index: /issm/branches/trunk-jpl-damage/cron/configs/macosx64_schlegel_daily
===================================================================
--- /issm/branches/trunk-jpl-damage/cron/configs/macosx64_schlegel_daily	(revision 11684)
+++ /issm/branches/trunk-jpl-damage/cron/configs/macosx64_schlegel_daily	(revision 11684)
@@ -0,0 +1,98 @@
+#
+########### Configuration file for Mathieu Morlighem's nightly run on Linux ############
+
+#-------------------------------#
+# 1: ISSM general configuration #
+#-------------------------------#
+
+#ISSM main directory (full path)
+ISSM_DIR="/Users/schlegel/issmuci"
+ISSM_TIER="/Users/schlegel/issmuci/trunk-jpl/cron/trunk-jpl"
+
+#ISSM Architecture
+ISSM_ARCH="macosx-gnu"
+
+#Machine configuration
+MACHINE="macosx-gil"
+
+#COMPILATION CONFIGURATION FILE
+COMPILE_CONFIG_FILE="config-macosx64-nicole.sh"
+
+#MATLAB path
+MATLAB_PATH="/Applications/MATLAB_R2011b.app/"
+
+#----------------------#
+# 2: ISSM Installation #
+#----------------------#
+
+#ISSM_INSTALLATION can have 3 values:
+# - "checkout" the existing version of the code will be erased and
+#              the latest version will be checked out
+# - "update"   the directory won't be erased but ISSM will be updated
+#              ->skip to section 3
+# - "none"     leave ISSM as is in its directory
+#              ->skip to section 3
+ISSM_INSTALLATION="update"
+
+#SVN repository
+REPOSITORY="https://issm.ess.uci.edu/svn/issm/issm/trunk-jpl"
+
+#execution path used for parallel runs
+EXECUTION_PATH="/Users/schlegel/ExecutionNightlyRun"
+
+#-----------------------------------#
+# 3: External packages installation #
+#-----------------------------------#
+
+#ISSM_EXTERNALPACKAGES can have 3 values:
+# - "install" install all external packages listed below
+# - "copy"    copy existing directories (EXTERNALPACKAGESDIR)
+# - "none"    leave external packages as is
+#             ->skip to section 4
+ISSM_EXTERNALPACKAGES="none"
+EXTERNALPACKAGESDIR="/Users/schlegel/issmuci/trunk-jpl/externalpackages"
+
+#List of external pakages to be installed
+EXTERNALPACKAGES="autoconf automake matlab mpich2 petsc metis triangle dakota chaco"
+
+#Corresponding list of installation files to use
+EXTERNALPACKAGES_CONFIGS=" install.sh install.sh install.sh install-1.4-macosx64.sh install-3.2-macosx64.sh install-4.0-macosx64.sh install-macosx64.sh install-macosx64.sh install.sh"
+
+#---------------------#
+# 4: ISSM Compilation #
+#---------------------#
+
+#ISSM_COMPILATION can have 2 values:
+# - "yes" compile ISSM
+# - "no"  do not compile ISSM
+ISSM_COMPILATION="yes"
+
+#----------------------#
+# 5: Mail notification #
+#----------------------#
+
+#Mail delivery. If SKIPMAIL="no", the html nightly run report will be
+#sent to the adresses present in $ISSM_TIER/cron/mailinglist.
+SKIPMAIL="no"
+
+#Sender email address
+EMAIL_ADRESS="schlegel@jpl.nasa.gov"
+
+#------------------------#
+# 6: Nightly run options #
+#------------------------#
+
+#number of cpus used in ISSM installation and compilation (one is usually
+#safer as some packages are very sensitive to parallel compilation)
+NUMCPUS_INSTALL=4
+
+#number of cpus used in the nightly runs.
+NUMCPUS_RUN=4
+
+#Nightly run options. The matlab routine nightlyrun.m will be called
+#as follows: nightlyrun($NROPTIONS). The options must be understandable
+#by Matlab and nightlyrun.m
+#ex: "'id',[101 102 103]"
+
+NROPTIONS="'exclude',[137 425:434 527]"
+
Index: /issm/branches/trunk-jpl-damage/cron/cronfiles/mac_cronfile
===================================================================
--- /issm/branches/trunk-jpl-damage/cron/cronfiles/mac_cronfile	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/cron/cronfiles/mac_cronfile	(revision 11684)
@@ -1,8 +1,9 @@
 #use /bin/bash to run commands, overriding the default set by cron
 SHELL=/bin/bash
+PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin
 
-#mail output to Helene
-MAILTO=eric.larour@jpl.nasa.gov,mathieu.morlighem@jpl.nasa.gov,helene.seroussi@jpl.nasa.gov
+#mail output to issm
+MAILTO=eric.larour@jpl.nasa.gov,mathieu.morlighem@jpl.nasa.gov,helene.seroussi@jpl.nasa.gov,Christopher.P.Borstad@jpl.nasa.gov,Nicole-Jeanne.Schlegel@jpl.nasa.gov,Feras.A.Habbal@jpl.nasa.gov
 
 #cronjob: issm 9:00pm
-50 9 * * * cd /Users/seroussi/Desktop/backup/svn/issm/trunk/cron/ && ./nightlyrun.sh configs/macosx32_seroussi
+30 00 * * 1 cd /Users/schlegel/issmuci/trunk-jpl/cron/ && ./nightlyrun.sh configs/macosx64_schlegel
Index: /issm/branches/trunk-jpl-damage/cron/nightlyrun.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/cron/nightlyrun.sh	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/cron/nightlyrun.sh	(revision 11684)
@@ -122,4 +122,10 @@
 cluster.executionpath='$EXECUTION_PATH';
 END
+   cat << END > $ISSM_TIER/externalpackages/matlab/install.sh
+#!/bin/bash
+rm -rf install
+ln -s $MATLAB_PATH install
+END
+
 fi
 #}}}
@@ -153,4 +159,12 @@
 	rm -rf externalpackages
 	cp -Rf $EXTERNALPACKAGESDIR ./
+
+elif [ "$ISSM_EXTERNALPACKAGES" == "link" ]
+then
+
+	#erase externapackages, and link with externalpackages_dir
+	cd $ISSM_TIER
+	rm -rf externalpackages
+	ln -s  $EXTERNALPACKAGESDIR  .
 
 elif [ "$ISSM_EXTERNALPACKAGES" == "none" ]
@@ -177,4 +191,14 @@
 	./scripts/automakererun.sh
 	source ./configs/$COMPILE_CONFIG_FILE
+
+	#4: compile and install ISSM
+	if [ $NUMCPUS_INSTALL -gt 1 ]
+	then
+		echo "Making with " $NUMCPUS_INSTALL "cpus"
+		make -j $NUMCPUS_INSTALL install
+	else
+		make install
+	fi
+
 	make install
 
@@ -259,4 +283,5 @@
 	cd $ISSM_TIER/nightlylog/
 
+	MATLABBIN=$MATLAB_PATH/bin/matlab
 	#Start test
 	$MATLABBIN  -nojvm -nosplash  -r matlab_run$i -logfile matlab_log$i.log &
@@ -312,6 +337,5 @@
 		if [ "$MACHINE" = "win7" ]
 		then
-			echo $i
-			email -html -s "Nightly runs of $ISSM_RELEASE , configuration: $MACHINE, host: $HOST_NAME, user: $USER. " $i < $ISSM_TIER/nightlylog/report.html
+			email -html -s "Nightly runs on $HOST_NAME (version: $ISSM_RELEASE)" $i < $ISSM_TIER/nightlylog/report.html
 		else 
 			if [ "$MACHINE" = "astrid" ]
@@ -320,5 +344,5 @@
 From: "ISSM Nightly run" <$EMAIL_ADRESS>
 To: $i
-Subject: Nightly runs of $ISSM_RELEASE, configuration: $MACHINE, host: $HOST_NAME, user: $USER.
+Subject: Nightly runs on $HOST_NAME (version: $ISSM_RELEASE)
 Mime-Version: 1.0
 Content-Type: text/html
@@ -328,5 +352,5 @@
 From: "ISSM Nightly run" <$EMAIL_ADRESS>
 To: $i
-Subject: Nightly runs of $ISSM_RELEASE, configuration: $MACHINE, host: $HOST_NAME, user: $USER.
+Subject: Nightly runs on $HOST_NAME (version: $ISSM_RELEASE)
 Mime-Version: 1.0
 Content-Type: text/html
Index: /issm/branches/trunk-jpl-damage/etc/environment.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/etc/environment.sh	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/etc/environment.sh	(revision 11684)
@@ -233,2 +233,14 @@
 #CCCL
 export PATH="$PATH:$CCCL_DIR/bin"
+
+#PACKAGEMAKER
+export PATH="$PATH:$PACKAGEMAKER_DIR"
+
+#ANDROID_NDK:
+export PATH="$PATH:$ANDROID_NDK_DIR/"
+
+#ANDROID_SDK
+export PATH="$PATH:$ANDROID_SDK_DIR/"
+
+#ANDROID_ANT
+export PATH="$PATH:$ANDROID_ANT_DIR/"
Index: /issm/branches/trunk-jpl-damage/etc/environment_variables.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/etc/environment_variables.sh	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/etc/environment_variables.sh	(revision 11684)
@@ -169,2 +169,14 @@
 #cccl
 CCCL_DIR="$ISSM_TIER/externalpackages/cccl/install"
+
+#packagemaker
+PACKAGEMAKER_DIR="$ISSM_TIER/externalpackages/packagemaker/install"
+
+#android-ndk
+ANDROID_NDK_DIR="$ISSM_TIER/externalpackages/android-ndk/install"
+
+#android-sdk
+ANDROID_SDK_DIR="$ISSM_TIER/externalpackages/android-sdk/install-sdk"
+
+#android-ant
+ANDROID_ANT_DIR="$ISSM_TIER/externalpackages/android-sdk/install-ant"
Index: /issm/branches/trunk-jpl-damage/examples/Jakobshavn/Domain.exp
===================================================================
--- /issm/branches/trunk-jpl-damage/examples/Jakobshavn/Domain.exp	(revision 11684)
+++ /issm/branches/trunk-jpl-damage/examples/Jakobshavn/Domain.exp	(revision 11684)
@@ -0,0 +1,34 @@
+## Name:JksOutline
+## Icon:0
+# Points Count Value
+28 1.000000
+# X pos Y pos
+-442320.3882147236 -2277080.6549030584
+-415649.3149820761 -2315476.9356749961
+-356259.6577274340 -2351834.4758754564
+-309585.2795717255 -2384114.5349311619
+-279812.9187561168 -2353193.6362587260
+-274850.8586214480 -2287953.9379578433
+-294854.1635456266 -2263149.2609987380
+-309585.2795753506 -2232228.3623235333
+-348041.2456311518 -2191113.7607873622
+-376728.1557929466 -2197909.5626934194
+-391614.3362011510 -2203685.9943137392
+-417355.0231571503 -2206404.3150757281
+-420122.3381705935 -2211830.0535394503
+-421889.2049176788 -2218344.8015625700
+-420705.1891998384 -2226200.5387845989
+-425774.4833068820 -2230306.5097973733
+-429242.2244052034 -2235353.9400299159
+-427025.7933000360 -2240741.0910965428
+-431045.5636035603 -2255158.9014255330
+-424708.0734753361 -2261343.7626088522
+-423137.8820362946 -2268466.9593191240
+-428054.2739333302 -2272589.0010017036
+-432362.3262468725 -2272393.9161962867
+-435068.8255516959 -2273140.2906106352
+-437641.3726878429 -2272612.1952726739
+-439529.7800752302 -2272929.1351353633
+-442475.4525940326 -2275381.7044264446
+-442320.3882147236 -2277080.6549030584
+
Index: /issm/branches/trunk-jpl-damage/examples/Jakobshavn/Front.exp
===================================================================
--- /issm/branches/trunk-jpl-damage/examples/Jakobshavn/Front.exp	(revision 11684)
+++ /issm/branches/trunk-jpl-damage/examples/Jakobshavn/Front.exp	(revision 11684)
@@ -0,0 +1,15 @@
+## Name:Front
+## Icon:0
+# Points Count Value
+9 1.000000
+# X pos Y pos
+-443691.7204476296 -2241744.0087129781
+-444020.9148401438 -2244124.0631026439
+-443856.3176438867 -2245205.9060070375
+-441551.9568962874 -2244773.1688452801
+-440399.7765224879 -2243474.9573600078
+-439905.9849337166 -2240662.1658085845
+-441387.3597000304 -2238065.7428380400
+-443856.3176438867 -2237633.0056762826
+-443691.7204476296 -2241744.0087129781
+
Index: /issm/branches/trunk-jpl-damage/examples/Jakobshavn/Jks.par
===================================================================
--- /issm/branches/trunk-jpl-damage/examples/Jakobshavn/Jks.par	(revision 11684)
+++ /issm/branches/trunk-jpl-damage/examples/Jakobshavn/Jks.par	(revision 11684)
@@ -0,0 +1,61 @@
+
+%Name and hemisphere
+md.mesh.hemisphere='n';
+md.miscellaneous.name='Jakobshavn';
+
+%Load SeaRISE dataset
+disp('   Loading SeaRISE data from NetCDF');
+ncdata = './Greenland_5km_v1.1.nc';
+x1    = ncread(ncdata,'x1');
+y1    = ncread(ncdata,'y1');
+thk   = ncread(ncdata,'thk')';
+topg  = ncread(ncdata,'topg')';
+velx  = ncread(ncdata,'surfvelx')';
+vely  = ncread(ncdata,'surfvely')';
+temp  = ncread(ncdata,'airtemp2m')';
+smb   = ncread(ncdata,'smb')';
+
+disp('   Interpolating thicknesses');
+md.geometry.thickness=InterpFromGridToMesh(x1,y1,thk,md.mesh.x,md.mesh.y,0);
+pos0=find(md.geometry.thickness<=10);
+md.geometry.thickness(pos0)=10;
+
+disp('   Interpolating bedrock topography');
+md.geometry.bed=InterpFromGridToMesh(x1,y1,topg,md.mesh.x,md.mesh.y,0);
+
+disp('   Constructing surface elevation');
+md.geometry.surface=md.geometry.thickness+md.geometry.bed;
+
+disp('   Interpolating velocities');
+md.inversion.vx_obs  = InterpFromGridToMesh(x1,y1,velx,md.mesh.x,md.mesh.y,0);
+md.inversion.vy_obs  = InterpFromGridToMesh(x1,y1,vely,md.mesh.x,md.mesh.y,0);
+md.inversion.vel_obs = sqrt(md.inversion.vx_obs.^2+md.inversion.vy_obs.^2);
+md.initialization.vx = md.inversion.vx_obs;
+md.initialization.vy = md.inversion.vy_obs;
+md.initialization.vel= md.inversion.vel_obs;
+
+disp('   Interpolating temperatures');
+md.initialization.temperature=InterpFromGridToMesh(x1,y1,temp,md.mesh.x,md.mesh.y,0)+273.15; %convert to Kelvin
+
+disp('   Interpolating surface mass balance');
+md.surfaceforcings.mass_balance=InterpFromGridToMesh(x1,y1,smb,md.mesh.x,md.mesh.y,0);
+md.surfaceforcings.mass_balance=md.surfaceforcings.mass_balance*md.materials.rho_water/md.materials.rho_ice;
+
+disp('   Construct basal friction parameters');
+md.friction.coefficient=30*ones(md.mesh.numberofvertices,1);
+pos=find(md.mask.vertexonfloatingice);
+md.friction.coefficient(pos)=0; %no friction applied on floating ice
+md.friction.p=ones(md.mesh.numberofelements,1);
+md.friction.q=ones(md.mesh.numberofelements,1);
+
+disp('   Construct ice rheological properties');
+md.materials.rheology_n=3*ones(md.mesh.numberofelements,1);
+md.materials.rheology_B=paterson(md.initialization.temperature);
+%Reduce viscosity along the shear margins
+weakb=ContourToMesh(md.mesh.elements,md.mesh.x,md.mesh.y,'WeakB.exp','node',2);
+pos=find(weakb);md.materials.rheology_B(pos)=.3*md.materials.rheology_B(pos);
+
+disp('   Set other boundary conditions');
+md=SetMarineIceSheetBC(md,'./Front.exp');
+md.diagnostic.icefront(:,end)=1; %Apply water pressure at the ice front
+md.basalforcings.melting_rate=zeros(md.mesh.numberofvertices,1);
Index: /issm/branches/trunk-jpl-damage/examples/Jakobshavn/WeakB.exp
===================================================================
--- /issm/branches/trunk-jpl-damage/examples/Jakobshavn/WeakB.exp	(revision 11684)
+++ /issm/branches/trunk-jpl-damage/examples/Jakobshavn/WeakB.exp	(revision 11684)
@@ -0,0 +1,60 @@
+## Name:WeakB
+## Icon:0
+# Points Count Value
+24 1.000000
+# X pos Y pos
+-441022.7144520371 -2238435.7116546673
+-441639.8422268176 -2239053.0142011684
+-439171.3311276956 -2240699.1543251718
+-437319.9478033541 -2241727.9919026736
+-435879.9829955329 -2241933.7594181742
+-432382.9256051101 -2242756.8294801759
+-430942.9607972889 -2242962.5969956759
+-429708.7052477279 -2243991.4345731782
+-428680.1589564271 -2245020.2721506800
+-427651.6126651262 -2246049.1097281822
+-425800.2293407847 -2247077.9473056840
+-424565.9737912237 -2247695.2498521851
+-419341.0001274022 -2251604.8326466926
+-416049.6519952395 -2253868.2753171972
+-416049.6519952395 -2252222.1351931938
+-418312.4538361013 -2249341.3899761885
+-423331.7182416627 -2245843.3422126817
+-425594.5200825246 -2245226.0396661805
+-426623.0663738254 -2244402.9696041788
+-427445.9034068661 -2243991.4345731782
+-428885.8682146872 -2242756.8294801759
+-431148.6700555491 -2241522.2243871735
+-436497.1107703134 -2239670.3167476696
+-441022.7144520371 -2238435.7116546673
+
+## Name:WeakB
+## Icon:0
+# Points Count Value
+24 1.000000
+# X pos Y pos
+-442668.3885181184 -2245226.0396661805
+-440405.5866772566 -2245843.3422126817
+-438759.9126111752 -2246049.1097281822
+-437525.6570616142 -2246460.6447591828
+-435879.9829955329 -2246872.1797901839
+-434028.5996711914 -2248106.7848831862
+-431354.3793138092 -2249547.1574916886
+-430120.1237642482 -2249341.3899761885
+-429297.2867312076 -2250164.4600381902
+-427857.3219233864 -2249958.6925226897
+-426623.0663738254 -2250164.4600381902
+-424771.6830494839 -2250575.9950691909
+-423537.4274999229 -2250781.7625846914
+-422714.5904668822 -2251399.0651311926
+-415226.8149621988 -2259629.7657512082
+-419135.2908691420 -2259218.2307202076
+-422838.0575178250 -2255720.1829567007
+-424977.3923077441 -2252016.3676776937
+-426623.0663738254 -2251810.6001621932
+-428268.7404399067 -2251399.0651311926
+-429708.7052477279 -2251399.0651311926
+-431560.0885720694 -2251399.0651311926
+-443902.6440676794 -2246460.6447591828
+-442668.3885181184 -2245226.0396661805
+
Index: /issm/branches/trunk-jpl-damage/examples/Jakobshavn/runme.m
===================================================================
--- /issm/branches/trunk-jpl-damage/examples/Jakobshavn/runme.m	(revision 11684)
+++ /issm/branches/trunk-jpl-damage/examples/Jakobshavn/runme.m	(revision 11684)
@@ -0,0 +1,92 @@
+steps=[1];
+
+if any(steps==1)
+	disp('	Step 1: Mesh creation'); 
+	md=triangle(model,'Domain.exp',2000);
+
+	%Get observed velocity field on mesh nodes
+	ncdata='Greenland_5km_v1.1.nc';
+	if ~exist(ncdata,'file'), 
+		error('Download Greenland5km_v1.1.nc first on http://websrv.cs.umt.edu/isis/index.php/Present_Day_Greenland');
+	end
+	x1   = ncread(ncdata,'x1');
+	y1   = ncread(ncdata,'y1');
+	velx = ncread(ncdata,'surfvelx');
+	vely = ncread(ncdata,'surfvely');
+	vx   = InterpFromGridToMesh(x1,y1,velx',md.mesh.x,md.mesh.y,0);
+	vy   = InterpFromGridToMesh(x1,y1,vely',md.mesh.x,md.mesh.y,0);
+	vel  = sqrt(vx.^2+vy.^2);
+
+	%refine mesh using surface velocities as metric
+	md=bamg(md,'hmin',1200,'hmax',15000,'field',vel,'err',5);
+	[md.mesh.lat,md.mesh.long]  = xy2ll(md.mesh.x,md.mesh.y,+1,39,71);
+	
+	save JksMesh.mdl md
+end 
+if any(steps==2)
+	disp('	Step 2: Parameterization');
+	md=loadmodel('JksMesh.mdl');
+	
+	md=setmask(md,'','');
+	md=parameterize(md,'Jks.par'); 
+
+	%zones of shear margin softening
+	weakb=ContourToMesh(md.mesh.elements,md.mesh.x,md.mesh.y,'WeakB.exp','node',2);
+	pos=find(weakb);
+	md.materials.rheology_B(pos)=.3*md.materials.rheology_B(pos);
+
+	save JksPar.mdl md
+end 
+if any(steps==3)
+	disp('	Step 3: Control method friction');
+	md=loadmodel('JksPar.mdl');
+
+	md=setflowequation(md,'macayeal','all');
+
+	%Control general
+	md.inversion.iscontrol=1;
+	md.inversion.nsteps=20;
+	md.inversion.step_threshold=0.99*ones(md.inversion.nsteps,1);
+	md.inversion.maxiter_per_step=5*ones(md.inversion.nsteps,1);
+	md.verbose=verbose('solution',true,'control',true);
+
+	%Cost functions
+	md.inversion.cost_functions=[101*ones(md.inversion.nsteps,1) 103*ones(md.inversion.nsteps,1)];
+	md.inversion.cost_functions_coefficients=ones(md.mesh.numberofvertices,2);
+	md.inversion.cost_functions_coefficients(:,1)=40;
+	md.inversion.cost_functions_coefficients(:,2)=1;
+
+	%Controls
+	md.inversion.control_parameters={'FrictionCoefficient'};
+	md.inversion.gradient_scaling(1:md.inversion.nsteps)=30;
+	md.inversion.min_parameters=1*ones(md.mesh.numberofvertices,1);
+	md.inversion.max_parameters=200*ones(md.mesh.numberofvertices,1);
+
+	%Additional parameters
+	md.diagnostic.restol=0.01;
+	md.diagnostic.reltol=0.1;
+	md.diagnostic.abstol=NaN;
+
+	%Go solve
+	md.cluster=generic('name',oshostname,'np',4);
+	md.solver=addoptions(md.solver,NoneAnalysisEnum,asmoptions);
+	md.solver=addoptions(md.solver,DiagnosticVertAnalysisEnum,jacobiasmoptions);
+	md=solve(md,DiagnosticSolutionEnum);
+	
+	save JksControl.mdl md
+end 
+if any(steps==4)
+	disp('	Plotting')
+	md=loadmodel('JksControl.mdl');
+
+	plotmodel(md,'unit#all','km','axis#all','equal',...
+		'FontSize#all',12,...
+		'data',md.inversion.vel_obs,'title','Observed velocity',...
+		'data',md.results.DiagnosticSolution.Vel,'title','Modeled Velocity',...
+		'colorbar#1','off','colorbar#2','on','colorbartitle#2','[m/yr]',...
+		'caxis#1-2',[0,7000],...
+		'data',md.geometry.bed,'title','Bed elevation',...
+		'data',md.results.DiagnosticSolution.FrictionCoefficient,...
+		'title','Friction Coefficient',...
+		'colorbar#3','on','colorbartitle#3','[m]','colorbar#4','on');
+end
Index: /issm/branches/trunk-jpl-damage/examples/SquareIceShelf/runme.m
===================================================================
--- /issm/branches/trunk-jpl-damage/examples/SquareIceShelf/runme.m	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/examples/SquareIceShelf/runme.m	(revision 11684)
@@ -4,3 +4,4 @@
 md=parameterize(md,'Square.par');
 md=setflowequation(md,'macayeal','all');
+md.cluster=generic('name',oshostname,'np',2);
 md=solve(md,DiagnosticSolutionEnum);
Index: /issm/branches/trunk-jpl-damage/externalpackages/android-ndk/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/android-ndk/install.sh	(revision 11684)
+++ /issm/branches/trunk-jpl-damage/externalpackages/android-ndk/install.sh	(revision 11684)
@@ -0,0 +1,18 @@
+#This installs the Android NDK (Native Development Kit)
+#which is needed for the compilation of C/C++ code into the 
+#native architecture of the Android device.
+
+#The android-ndk-r7b-darwin-x86.tar.bz2 dummy.tar.bz2 file was downloaded 
+#from the android developer website: 
+
+#Cleanup the install
+rm -rf install
+
+# Install Android SDK and NDK.
+cp android-ndk-r7b-darwin-x86.tar.bz2 dummy.tar.bz2
+bunzip2 dummy.tar.bz2
+tar -xvf dummy.tar
+rm -rf dummy.tar dummy.tar.bz2
+
+#Move to install
+mv android-ndk-r7b install
Index: /issm/branches/trunk-jpl-damage/externalpackages/android-sdk/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/android-sdk/install.sh	(revision 11684)
+++ /issm/branches/trunk-jpl-damage/externalpackages/android-sdk/install.sh	(revision 11684)
@@ -0,0 +1,60 @@
+#This installs the Android SDK (Software Development Kit)
+#which is needed for the compilation of the Java project. 
+
+step=1;
+
+#Different steps here. 
+#1: install sdk, ant and sdk tools
+#2: install an emulator.
+#3: test the emulator
+#4: cleanup
+
+present_dir=`pwd`;
+
+if [[ $step == "1" ]]; then
+
+	#Cleanup the install
+	rm -rf install-sdk install-ant
+
+	# Install Android SDK and NDK.
+	unzip -o android-sdk-r16-macosx.zip
+	unzip -o apache-ant-1.8.2-bin.zip
+
+	#Move to install
+	mv android-sdk-macosx install-sdk
+	mv apache-ant-1.8.2 install-ant
+
+	#Post_install configuration: 
+	#We need specific settings for specific platforms, for the SDK to 
+	#function properly
+
+	#For now, we need to install:  
+	#android sdk platform tools  
+	#a specific android api: API 15
+
+	cd install-sdk/tools/ && source ./android
+fi
+
+if [[ $step == "2" ]]; then
+
+	#Once this is done, we need to install an emulator. Location will default to ~/.android/avd, 
+	#which we will move to $ISSM_TIER/externalpackages/android-emulators.  
+	#For now, it's called: Android-4.0.3
+
+	cd $present_dir/install-sdk/tools
+	./android avd
+	mv ~/.android/avd/Android-4.0.3.*  $ISSM_TIER/externalpackages/android-emulators
+
+fi
+
+
+if [[ $step == "3" ]]; then
+	
+	cd $present_dir/install-sdk/platform-tools
+	./adb -p "$ISSM_TIER/externalpackages/android-emulators" devices
+
+fi
+
+if [[ $step == "4" ]]; then
+	rm -rf install-sdk install-ant
+fi
Index: /issm/branches/trunk-jpl-damage/externalpackages/chaco/chaco_njs_notes.txt
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/chaco/chaco_njs_notes.txt	(revision 11684)
+++ /issm/branches/trunk-jpl-damage/externalpackages/chaco/chaco_njs_notes.txt	(revision 11684)
@@ -0,0 +1,3 @@
+chaco build must be able to see malloc.h
+sudo ln -s /usr/include/malloc/malloc.h /usr/include/malloc.h
+or else make sure you include the malloc directory in path
Index: /issm/branches/trunk-jpl-damage/externalpackages/dakota/dakota_njs_notes_macos64.txt
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/dakota/dakota_njs_notes_macos64.txt	(revision 11684)
+++ /issm/branches/trunk-jpl-damage/externalpackages/dakota/dakota_njs_notes_macos64.txt	(revision 11684)
@@ -0,0 +1,5 @@
+Matlab might try to use its local /Applications/MATLAB_R2011b.app/sys/os/maci64/ fortran libraries
+instead of the gfortran package libraries.  Matlab library is missing some symbols, so you might
+need to link to the actual gfortran library 
+sudo cp /Applications/MATLAB_R2011b.app/sys/os/maci64/libgfortran.3.dynlib /Applications/MATLAB_R2011b.app/sys/os/maci64/libgfortran.3.dynlib.matlab
+sudo ln -s /usr/local/gfortran/lib/gcc/x86_64-apple-darwin10/4.6.2/libgfortran.3.dylib libgfortran.3.dylib
Index: /issm/branches/trunk-jpl-damage/externalpackages/dakota/install-macosx64.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/dakota/install-macosx64.sh	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/externalpackages/dakota/install-macosx64.sh	(revision 11684)
@@ -28,9 +28,11 @@
 #Configure dakota
 cd src
-./configure \ 
-	--prefix="$ISSM_TIER/externalpackages/dakota/install" \
-	--without-graphics  \
-	--with-pic \
-	--disable-mpi
+./configure \
+   --prefix="$ISSM_TIER/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 "
 cd ..
 
@@ -44,5 +46,5 @@
 mv temp ./src/methods/acro/packages/pebbl/src/Makefile
 
-cat ./src/methods/hopspack/src-nappspack/Makefile | sed 's/CXXFLAGS = -g -O2/CXXFLAGS = -g -O2  -fPIC/g' > temp
+cat ./src/methods/hopspack/src-nappspack/Makefile | sed 's/CXXFLAGS = -g -O2/CXXFLAGS = -g -O2 -fPIC/g' > temp
 mv temp ./src/methods/hopspack/src-nappspack/Makefile
 
@@ -53,5 +55,5 @@
 mv temp  ./src/methods/hopspack/src-shared/Makefile 
 
-cat ./src/methods/hopspack/src-shared/Makefile | sed 's/CXXFLAGS = -g -O2/CXXFLAGS = -g -O2  -fPIC/g' > temp
+cat ./src/methods/hopspack/src-shared/Makefile | sed 's/CXXFLAGS = -g -O2/CXXFLAGS = -g -O2 -fPIC/g' > temp
 mv temp  ./src/methods/hopspack/src-shared/Makefile 
 
@@ -59,5 +61,5 @@
 mv temp  ./src/methods/hopspack/src-conveyor/Makefile 
 
-cat ./src/methods/hopspack/src-appspack/Makefile | sed 's/CXXFLAGS = -g -O2/CXXFLAGS = -g -O2  -fPIC/g' > temp
+cat ./src/methods/hopspack/src-appspack/Makefile | sed 's/CXXFLAGS = -g -O2/CXXFLAGS = -g -O2 -fPIC/g' > temp
 mv temp ./src/methods/hopspack/src-appspack/Makefile 
 
@@ -74,5 +76,5 @@
 mv temp  ./src/methods/acro/packages/tpl/3po/Makefile 
 
-cat ./src/packages/ampl/Makefile | sed 's/CFLAGS = -g -O2/CFLAGS = -g -O2 -fPIC/g' > temp
+cat ./src/packages/ampl/Makefile | sed 's/CFLAGS = -g -O2 -D_NONSTD_SOURCE/CFLAGS = -g -O2 -fPIC/g' > temp
 mv temp  ./src/packages/ampl/Makefile 
 
Index: /issm/branches/trunk-jpl-damage/externalpackages/matlab/install-macosx-feras.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/matlab/install-macosx-feras.sh	(revision 11684)
+++ /issm/branches/trunk-jpl-damage/externalpackages/matlab/install-macosx-feras.sh	(revision 11684)
@@ -0,0 +1,13 @@
+#!/bin/bash
+
+#Erase symlink
+rm -rf install
+
+#Generic Matlab softlink for Macintosh (OSX) directory structure
+
+#ln -s /Applications/MATLAB_R2008a/ install
+#ln -s /Applications/MATLAB_R2009a.app/ install
+#ln -s /Applications/MATLAB_R2010a.app/ install
+#ln -s /Applications/MATLAB_R2011b.app/ install
+
+ln -s /Applications/MATLAB*.app/ install
Index: /issm/branches/trunk-jpl-damage/externalpackages/matlab/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/matlab/install.sh	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/externalpackages/matlab/install.sh	(revision 11684)
@@ -10,6 +10,9 @@
 ln -s /usr/local/matlab712/ install
 #ln -s /usr/local/pkgs/matlab-7.6/ install
+
+# Macintosh (OSX) simlink 
 #ln -s /Applications/MATLAB_R2008a/ install
 #ln -s /Applications/MATLAB_R2009a.app/ install
 #ln -s /Applications/MATLAB_R2010a.app/ install
 #ln -s /Applications/MATLAB_R2011b.app/ install
+#ln -s /Applications/MATLAB*.app/ install
Index: /issm/branches/trunk-jpl-damage/m4/issm_options.m4
===================================================================
--- /issm/branches/trunk-jpl-damage/m4/issm_options.m4	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/m4/issm_options.m4	(revision 11684)
@@ -250,6 +250,16 @@
 		HAVE_DAKOTA=yes
 		DAKOTAINCL=-I$DAKOTA_ROOT/include
-		DAKOTALIB="-L$DAKOTA_ROOT/lib -ldakota -lteuchos -lpecos -lfftw3 -llhs -levidence -lsurfpack -lconmin -lddace -lfsudace -ljega -lcport -lopt -lpsuade -lnewmat -lncsuopt -lgsl -lquadrature -lcoliny -lcolin -lpebbl -lutilib -l3po -lnappspack -lappspack -lconveyor -lshared -lcdd -lamplsolver"
-		dnl DAKOTALIB="-L$DAKOTA_ROOT/lib -ldakota -lteuchos -lpecos -lfftw3 -llhs -levidence -lsurfpack -lconmin -lddace -lfsudace -ljega -lcport -lopt -lpsuade -lnewmat -lncsuopt -lgsl -lgslcblas -lquadrature -lcoliny -lcolin -lpebbl -lutilib -l3po -lnappspack -lappspack -lconveyor -lshared -lcdd -lamplsolver"
+		case "${host_os}" in
+			*cygwin*)
+			DAKOTALIB="-L$DAKOTA_ROOT/lib -ldakota -lteuchos -lpecos -lfftw3 -llhs -levidence -lsurfpack -lconmin -lddace -lfsudace -ljega -lcport -lopt -lpsuade -lnewmat -lncsuopt -lgsl -lquadrature -lcoliny -lcolin -lpebbl -lutilib -l3po -lnappspack -lappspack -lconveyor -lshared -lcdd -lamplsolver"
+			;;
+			*linux*)
+			  DAKOTALIB="-L$DAKOTA_ROOT/lib -ldakota -lteuchos -lpecos -lfftw3 -llhs -levidence -lsurfpack -lconmin -lddace -lfsudace -ljega -lcport -lopt -lpsuade -lnewmat -lncsuopt -lgsl -lquadrature -lcoliny -lcolin -lpebbl -lutilib -l3po -lnappspack -lappspack -lconveyor -lshared -lcdd -lamplsolver"
+			;;
+			*darwin*)
+			  DAKOTALIB="-L$DAKOTA_ROOT/lib -ldakota -lteuchos -lpecos -lfftw3 -llhs -levidence -lsurfpack -lconmin -lddace -lfsudace -ljega -lcport -lopt -lpsuade -lnewmat -lncsuopt -lgsl -lquadrature -lcoliny -lcolin -lpebbl -lutilib -l3po -lnappspack -lappspack -lconveyor -lshared -lcdd -lamplsolver" 
+			  dnl DAKOTALIB+= "-lgslcblas -L/usr/lib -lblas -llapack"
+			;;
+		esac
 		AC_DEFINE([_HAVE_DAKOTA_],[1],[with Dakota in ISSM src])
 		AC_SUBST([DAKOTAINCL])
@@ -306,4 +316,32 @@
 	fi
 	AC_MSG_RESULT($HAVE_SCOTCH)
+	dnl }}}
+	dnl adolc{{{1
+	AC_ARG_WITH([adolc-dir],
+			  AS_HELP_STRING([--with-adolc-dir = DIR], [adolc root directory.]),
+			 [ADOLC_ROOT=$withval],[ADOLC_ROOT="no"]) 
+	AC_MSG_CHECKING(for ADOLC)
+
+	if test "x$ADOLC_ROOT" = "xno"; then
+		HAVE_ADOLC=no
+	else
+		if test -d "$ADOLC_ROOT"; then
+
+			dnl defaults
+			HAVE_ADOLC=yes
+			ADOLCINCL="-I$ADOLC_ROOT/include/adolc -I$ADOLC_ROOT/include"
+			ADOLCLIB="-L$ADOLC_ROOT/lib64 -ladolc"
+
+			AC_DEFINE([_HAVE_ADOLC_],[1],[with adolc in ISSM src])
+			AC_SUBST([ADOLCINCL])
+			AC_SUBST([ADOLCLIB])
+
+		else
+			echo  "Specified directory does not exist!"
+			exit 1
+		fi
+	fi
+	AM_CONDITIONAL([ADOLC], [test x$HAVE_ADOLC = xyes])
+	AC_MSG_RESULT($HAVE_ADOLC)
 	dnl }}}
 	dnl adic2{{{1
Index: /issm/branches/trunk-jpl-damage/src/Makefile.am
===================================================================
--- /issm/branches/trunk-jpl-damage/src/Makefile.am	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/Makefile.am	(revision 11684)
@@ -1,8 +1,2 @@
 EXTRA_DIST =  perl  pro
 SUBDIRS = c mex m
-
-if ADIC2
-SUBDIRS += ad
-endif
-
-
Index: sm/branches/trunk-jpl-damage/src/ad/Makefile.am
===================================================================
--- /issm/branches/trunk-jpl-damage/src/ad/Makefile.am	(revision 11683)
+++ 	(revision )
@@ -1,630 +1,0 @@
-INCLUDES = @DAKOTAINCL@ @PETSCINCL@ @SLEPCINCL@ @MPIINCL@ @MATLABINCL@  @METISINCL@  @CHACOINCL@ @SCOTCHINCL@ @PLAPACKINCL@  @BLASLAPACKINCL@ @MKLINCL@ @MUMPSINCL@  @TRIANGLEINCL@ @HYPREINCL@ @MLINCL@ @TAOINCL@  @ADIC2INCL@
-
-#This Makefile.am is for automatic differentiation of the parallel version of ISSM.
-#We do not compile in serial mode
-#If user requests no parallel compilation, we compile an empty ISSM.
-#Compilation can still be blocked if user has not activated --with-adic compilation
-
-#Library declaration {{{1
-
-if NOPARALLEL
-lib_LIBRARIES = 
-else
-lib_LIBRARIES = libpISSM.a   libOverload.a
-endif
-
-if ADIC2
-lib_LIBRARIES += libAD.a libpISSMRose.a
-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)
-#}}}
-#ISSM library  {{{1
-libpISSM_a_SOURCES = ./include/macros.h\
-					./include/typedefs.h\
-					./include/types.h\
-					./include/include.h\
-					./objects/objects.h\
-					./objects/Object.h\
-					./objects/Gauss/GaussTria.h\
-					./objects/Gauss/GaussTria.cpp\
-					./objects/Update.h\
-					./objects/Element.h\
-					./objects/FemModel.h\
-					./objects/FemModel.cpp\
-					./objects/Material.h\
-					./objects/Load.h\
-					./objects/Loads/Friction.h\
-					./objects/Loads/Friction.cpp\
-					./objects/Inputs/TransientInput.h\
-					./objects/Inputs/TransientInput.cpp\
-					./objects/Constraints/SpcTransient.cpp\
-					./objects/Constraints/SpcTransient.h\
-					./objects/DofIndexing.h\
-					./objects/DofIndexing.cpp\
-					./objects/IoModel.h\
-					./objects/IoModel.cpp\
-					./objects/Node.h\
-					./objects/Node.cpp\
-					./objects/Segment.h\
-					./objects/Segment.cpp\
-					./objects/Vertex.h\
-					./objects/Vertex.cpp\
-					./objects/Hook.h\
-					./objects/Hook.cpp\
-					./objects/Patch.h\
-					./objects/Patch.cpp\
-					./objects/ElementResults/ElementResultLocal.h\
-					./objects/ElementResults/DoubleElementResult.h\
-					./objects/ElementResults/DoubleElementResult.cpp\
-					./objects/ElementResults/TriaVertexElementResult.h\
-					./objects/ElementResults/TriaVertexElementResult.cpp\
-					./objects/ElementResults/BoolElementResult.h\
-					./objects/ElementResults/BoolElementResult.cpp\
-					./objects/ExternalResults/ExternalResult.h\
-					./objects/ExternalResults/BoolExternalResult.h\
-					./objects/ExternalResults/BoolExternalResult.cpp\
-					./objects/ExternalResults/DoubleExternalResult.h\
-					./objects/ExternalResults/DoubleExternalResult.cpp\
-					./objects/ExternalResults/DoubleVecExternalResult.h\
-					./objects/ExternalResults/DoubleVecExternalResult.cpp\
-					./objects/ExternalResults/DoubleMatExternalResult.h\
-					./objects/ExternalResults/DoubleMatExternalResult.cpp\
-					./objects/ExternalResults/IntExternalResult.h\
-					./objects/ExternalResults/IntExternalResult.cpp\
-					./objects/ExternalResults/StringExternalResult.h\
-					./objects/ExternalResults/StringExternalResult.cpp\
-					./objects/ExternalResults/PetscVecExternalResult.h\
-					./objects/ExternalResults/PetscVecExternalResult.cpp\
-					./objects/Elements/Tria.h\
-					./objects/Elements/Tria.cpp\
-					./objects/Elements/TriaHook.h\
-					./objects/Elements/TriaHook.cpp\
-					./objects/Elements/TriaRef.h\
-					./objects/Elements/TriaRef.cpp\
-					./objects/Inputs/Input.h\
-					./objects/Inputs/InputLocal.h\
-					./objects/Inputs/TriaVertexInput.h\
-					./objects/Inputs/TriaVertexInput.cpp\
-					./objects/Inputs/BoolInput.h\
-					./objects/Inputs/BoolInput.cpp\
-					./objects/Inputs/IntInput.h\
-					./objects/Inputs/IntInput.cpp\
-					./objects/Inputs/DoubleInput.h\
-					./objects/Inputs/DoubleInput.cpp\
-					./objects/Inputs/DatasetInput.h\
-					./objects/Inputs/DatasetInput.cpp\
-					./objects/Materials/Matice.h\
-					./objects/Materials/Matice.cpp\
-					./objects/Materials/Matpar.h\
-					./objects/Materials/Matpar.cpp\
-					./objects/Constraints/Constraint.h\
-					./objects/Constraints/SpcStatic.cpp\
-					./objects/Constraints/SpcStatic.h\
-					./objects/Constraints/SpcDynamic.cpp\
-					./objects/Constraints/SpcDynamic.h\
-					./objects/Loads/Penpair.cpp\
-					./objects/Loads/Penpair.h\
-					./objects/Loads/Pengrid.cpp\
-					./objects/Loads/Pengrid.h\
-					./objects/Loads/Icefront.cpp\
-					./objects/Loads/Icefront.h\
-					./objects/Loads/Numericalflux.cpp\
-					./objects/Loads/Numericalflux.h\
-					./objects/Numerics/ElementMatrix.h\
-					./objects/Numerics/ElementMatrix.cpp\
-					./objects/Numerics/ElementVector.h\
-					./objects/Numerics/ElementVector.cpp\
-					./objects/Params/Param.h\
-					./objects/Params/BoolParam.cpp\
-					./objects/Params/BoolParam.h\
-					./objects/Params/IntParam.cpp\
-					./objects/Params/IntParam.h\
-					./objects/Params/IntVecParam.cpp\
-					./objects/Params/IntVecParam.h\
-					./objects/Params/IntMatParam.cpp\
-					./objects/Params/IntMatParam.h\
-					./objects/Params/DoubleParam.cpp\
-					./objects/Params/DoubleParam.h\
-					./objects/Params/FileParam.cpp\
-					./objects/Params/FileParam.h\
-					./objects/Params/PetscMatParam.cpp\
-					./objects/Params/PetscMatParam.h\
-					./objects/Params/StringArrayParam.cpp\
-					./objects/Params/StringArrayParam.h\
-					./objects/Params/DoubleMatParam.cpp\
-					./objects/Params/DoubleMatParam.h\
-					./objects/Params/DoubleMatArrayParam.cpp\
-					./objects/Params/DoubleMatArrayParam.h\
-					./objects/Params/DoubleVecParam.cpp\
-					./objects/Params/DoubleVecParam.h\
-					./objects/Params/PetscVecParam.cpp\
-					./objects/Params/PetscVecParam.h\
-					./objects/Params/StringParam.cpp\
-					./objects/Params/StringParam.h\
-					./Container/Container.h\
-					./Container/Constraints.h\
-					./Container/Constraints.cpp\
-					./Container/DataSet.h\
-					./Container/DataSet.cpp\
-					./Container/Elements.h\
-					./Container/Elements.cpp\
-					./Container/Inputs.h\
-					./Container/Inputs.cpp\
-					./Container/Loads.h\
-					./Container/Loads.cpp\
-					./Container/Materials.h\
-					./Container/Materials.cpp\
-					./Container/Nodes.h\
-					./Container/Nodes.cpp\
-					./Container/Parameters.h\
-					./Container/Parameters.cpp\
-					./Container/Results.h\
-					./Container/Results.cpp\
-					./Container/Vertices.h\
-					./Container/Vertices.cpp\
-					./shared/shared.h\
-					./shared/Alloc/alloc.h\
-					./shared/Alloc/alloc.cpp\
-					./shared/Matrix/matrix.h\
-					./shared/Matrix/MatrixUtils.cpp\
-					./shared/Dofs/dofs.h\
-					./shared/Dofs/dofsetgen.cpp\
-					./shared/Numerics/numerics.h\
-					./shared/Numerics/Verbosity.h\
-					./shared/Numerics/Verbosity.cpp\
-					./shared/Numerics/IsInputConverged.cpp\
-					./shared/Numerics/GaussPoints.h\
-					./shared/Numerics/GaussPoints.cpp\
-					./shared/Numerics/cross.cpp\
-					./shared/Numerics/extrema.cpp\
-					./shared/Numerics/UnitConversion.cpp\
-					./shared/Numerics/PetscOptionsFromAnalysis.cpp\
-					./shared/Exceptions/exceptions.h\
-					./shared/Exceptions/Exceptions.cpp\
-					./shared/Exceptions/exprintf.cpp\
-					./shared/Sorting/binary_search.cpp\
-					./shared/Sorting/sorting.h\
-					./shared/Elements/elements.h\
-					./shared/Elements/Paterson.cpp\
-					./shared/Elements/Arrhenius.cpp\
-					./shared/Elements/GetVerticesCoordinates.cpp\
-					./shared/Elements/GetLocalDofList.cpp\
-					./shared/Elements/GetGlobalDofList.cpp\
-					./shared/Elements/GetNumberOfDofs.cpp\
-					./shared/String/sharedstring.h\
-					./toolkits/petsc\
-					./toolkits/petsc/patches\
-					./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/MatlabMatrixToDoubleMatrix.cpp\
-					./toolkits/petsc/patches/MatlabVectorToDoubleVector.cpp\
-					./toolkits/petsc/patches/PetscDetermineLocalSize.cpp\
-					./toolkits/petsc/patches/VecTranspose.cpp\
-					./toolkits/petsc/patches/VecToMPISerial.cpp\
-					./toolkits/petsc/patches/MatToSerial.cpp\
-					./toolkits/petsc/patches/VecMerge.cpp\
-					./toolkits/petsc/patches/NewVec.cpp\
-					./toolkits/petsc/patches/PetscOptionsDetermineSolverType.cpp\
-					./toolkits/petsc/patches/PetscOptionsInsertMultipleString.cpp\
-					./toolkits/petsc/patches/NewMat.cpp\
-					./toolkits/petsc/patches/SerialToVec.cpp\
-					./toolkits/petsc/patches/VecFree.cpp\
-					./toolkits/petsc/patches/VecDuplicatePatch.cpp\
-					./toolkits/petsc/patches/KSPFree.cpp\
-					./toolkits/petsc/patches/ISFree.cpp\
-					./toolkits/petsc/patches/MatFree.cpp\
-					./toolkits/petsc/patches/GetOwnershipBoundariesFromRange.cpp\
-					./toolkits/petsc/patches/VecPartition.cpp\
-					./toolkits/petsc/patches/MatPartition.cpp\
-					./toolkits/petsc/patches/MatInvert.cpp\
-					./toolkits/petsc/patches/MatMultPatch.cpp\
-					./toolkits/petsc/petscincludes.h\
-					./toolkits/mpi/mpiincludes.h\
-					./toolkits/mpi/patches/mpipatches.h\
-					./toolkits/mpi/patches/MPI_Upperrow.cpp\
-					./toolkits/mpi/patches/MPI_Lowerrow.cpp\
-					./toolkits/mpi/patches/MPI_Boundariesfromrange.cpp\
-					./toolkits/metis/metisincludes.h\
-					./toolkits/metis/patches/metispatches.h\
-					./toolkits/metis/patches/METIS_PartMeshNodalPatch.cpp\
-					./toolkits/triangle/triangleincludes.h\
-					./toolkits.h\
-					./io/io.h\
-					./io/Disk/diskio.h\
-					./io/Disk/pfopen.cpp\
-					./io/Disk/pfclose.cpp\
-					./io/PrintfFunction.cpp\
-					./EnumDefinitions/EnumDefinitions.h\
-					./EnumDefinitions/EnumToModelField.cpp\
-					./modules/ModelProcessorx/ModelProcessorx.h\
-					./modules/ModelProcessorx/ModelProcessorx.cpp\
-					./modules/ModelProcessorx/DistributeNumDofs.cpp\
-					./modules/ModelProcessorx/ElementsAndVerticesPartitioning.cpp\
-					./modules/ModelProcessorx/NodesPartitioning.cpp\
-					./modules/ModelProcessorx/SortDataSets.cpp\
-					./modules/ModelProcessorx/UpdateCounters.cpp\
-					./modules/ModelProcessorx/CreateDataSets.cpp\
-					./modules/ModelProcessorx/CreateParameters.cpp\
-					./modules/ModelProcessorx/CreateSingleNodeToElementConnectivity.cpp\
-					./modules/ModelProcessorx/CreateNumberNodeToElementConnectivity.cpp\
-					./modules/ModelProcessorx/CreateElementsVerticesAndMaterials.cpp\
-					./modules/ParsePetscOptionsx/ParsePetscOptionsx.h\
-					./modules/ParsePetscOptionsx/ParsePetscOptionsx.cpp\
-					./modules/NodesDofx/NodesDofx.h\
-					./modules/NodesDofx/NodesDofx.cpp\
-					./modules/VerticesDofx/VerticesDofx.h\
-					./modules/VerticesDofx/VerticesDofx.cpp\
-					./modules/OutputResultsx/OutputResultsx.h\
-					./modules/OutputResultsx/OutputResultsx.cpp\
-					./modules/InputDuplicatex/InputDuplicatex.h\
-					./modules/InputDuplicatex/InputDuplicatex.cpp\
-					./modules/InputScalex/InputScalex.h\
-					./modules/InputScalex/InputScalex.cpp\
-					./modules/CreateNodalConstraintsx/CreateNodalConstraintsx.h\
-					./modules/CreateNodalConstraintsx/CreateNodalConstraintsx.cpp\
-					./modules/UpdateDynamicConstraintsx/UpdateDynamicConstraintsx.h\
-					./modules/UpdateDynamicConstraintsx/UpdateDynamicConstraintsx.cpp\
-					./modules/IoModelToConstraintsx/IoModelToConstraintsx.h\
-					./modules/IoModelToConstraintsx/IoModelToConstraintsx.cpp\
-					./modules/InputUpdateFromConstantx/InputUpdateFromConstantx.h\
-					./modules/InputUpdateFromConstantx/InputUpdateFromConstantx.cpp\
-					./modules/InputUpdateFromSolutionx/InputUpdateFromSolutionx.h\
-					./modules/InputUpdateFromSolutionx/InputUpdateFromSolutionx.cpp\
-					./modules/GetSolutionFromInputsx/GetSolutionFromInputsx.h\
-					./modules/GetSolutionFromInputsx/GetSolutionFromInputsx.cpp\
-					./modules/GetVectorFromInputsx/GetVectorFromInputsx.h\
-					./modules/GetVectorFromInputsx/GetVectorFromInputsx.cpp\
-					./modules/InputUpdateFromVectorx/InputUpdateFromVectorx.h\
-					./modules/InputUpdateFromVectorx/InputUpdateFromVectorx.cpp\
-					./modules/InputArtificialNoisex/InputArtificialNoisex.h\
-					./modules/InputArtificialNoisex/InputArtificialNoisex.cpp\
-					./modules/TimeAdaptx/TimeAdaptx.h\
-					./modules/TimeAdaptx/TimeAdaptx.cpp\
-					./modules/UpdateVertexPositionsx/UpdateVertexPositionsx.h\
-					./modules/UpdateVertexPositionsx/UpdateVertexPositionsx.cpp\
-					./modules/ConfigureObjectsx/ConfigureObjectsx.h\
-					./modules/ConfigureObjectsx/ConfigureObjectsx.cpp\
-					./modules/ComputeBasalStressx/ComputeBasalStressx.h\
-					./modules/ComputeBasalStressx/ComputeBasalStressx.cpp\
-					./modules/ComputeStrainRatex/ComputeStrainRatex.h\
-					./modules/ComputeStrainRatex/ComputeStrainRatex.cpp\
-					./modules/SpcNodesx/SpcNodesx.h\
-					./modules/SpcNodesx/SpcNodesx.cpp\
-					./modules/UpdateConstraintsx/UpdateConstraintsx.h\
-					./modules/UpdateConstraintsx/UpdateConstraintsx.cpp\
-					./modules/MeshPartitionx/MeshPartitionx.cpp\
-					./modules/MeshPartitionx/MeshPartitionx.h\
-					./modules/Reducevectorgtofx/Reducevectorgtofx.cpp\
-					./modules/Reducevectorgtofx/Reducevectorgtofx.h\
-					./modules/Reduceloadx/Reduceloadx.h\
-					./modules/Reduceloadx/Reduceloadx.cpp\
-					./modules/EnumToStringx/EnumToStringx.cpp\
-					./modules/EnumToStringx/EnumToStringx.h\
-					./modules/StringToEnumx/StringToEnumx.cpp\
-					./modules/StringToEnumx/StringToEnumx.h\
-					./modules/SystemMatricesx/SystemMatricesx.cpp\
-					./modules/SystemMatricesx/SystemMatricesx.h\
-					./modules/ConstraintsStatex/ConstraintsStatex.cpp\
-					./modules/ConstraintsStatex/ConstraintsStatex.h\
-					./modules/ConstraintsStatex/ConstraintsStateLocal.h\
-					./modules/RequestedOutputsx/RequestedOutputsx.h\
-					./modules/RequestedOutputsx/RequestedOutputsx.cpp\
-					./modules/ResetConstraintsx/ResetConstraintsx.h\
-					./modules/ResetConstraintsx/ResetConstraintsx.cpp\
-					./modules/Solverx/Solverx.cpp\
-					./modules/Solverx/Solverx.h\
-					./modules/Solverx/DofTypesToIndexSet.cpp\
-					./modules/VecMergex/VecMergex.cpp\
-					./modules/VecMergex/VecMergex.h\
-					./modules/Mergesolutionfromftogx/Mergesolutionfromftogx.cpp\
-					./modules/Mergesolutionfromftogx/Mergesolutionfromftogx.h\
-					./modules/InputToResultx/InputToResultx.cpp\
-					./modules/InputToResultx/InputToResultx.h\
-					./modules/InputConvergencex/InputConvergencex.cpp\
-					./modules/InputConvergencex/InputConvergencex.h\
-					./solutions/convergence.cpp\
-					./solutions/WriteLockFile.cpp\
-					./solutions/ResetBoundaryConditions.cpp\
-					./solutions/AnalysisConfiguration.cpp\
-					./solutions/CorePointerFromSolutionEnum.cpp\
-					./solvers/solver_linear.cpp\
-					./solvers/solver_nonlinear.cpp
-
-
-libpISSM_a_CXXFLAGS = -fPIC -D_PARALLEL_   -D_C_ $(CXXOPTFLAGS) 
-#}}}
-#DAKOTA sources  {{{1
-if DAKOTA
-libpISSM_a_SOURCES +=  ./objects/DakotaPlugin.h\
-					  ./objects/DakotaPlugin.cpp\
-					  ./modules/InputUpdateFromDakotax/InputUpdateFromDakotax.h\
-					  ./modules/InputUpdateFromDakotax/InputUpdateFromDakotax.cpp\
-					  ./modules/DakotaResponsesx/DakotaResponsesx.h\
-					  ./modules/DakotaResponsesx/DakotaResponsesx.cpp\
-					  ./modules/InputUpdateFromVectorDakotax/InputUpdateFromVectorDakotax.h\
-					  ./modules/InputUpdateFromVectorDakotax/InputUpdateFromVectorDakotax.cpp\
-					  ./modules/AverageOntoPartitionx/AverageOntoPartitionx.cpp\
-					  ./modules/AverageOntoPartitionx/AverageOntoPartitionx.h\
-					  ./modules/Dakotax/Dakotax.h\
-					  ./modules/Dakotax/Dakotax.cpp\
-					  ./modules/Dakotax/DakotaMPI_Bcast.cpp\
-					  ./modules/Dakotax/DakotaFree.cpp\
-					  ./modules/Dakotax/SpawnCore.cpp\
-					  ./modules/Dakotax/SpawnCoreParallel.cpp\
-					  ./modules/Dakotax/DescriptorIndex.cpp\
-					  ./modules/AverageOntoPartitionx/AverageOntoPartitionx.cpp\
-					  ./modules/ModelProcessorx/Qmu/CreateParametersQmu.cpp\
-					  ./modules/AverageOntoPartitionx/AverageOntoPartitionx.h
-endif
-#}}}
-#Transient sources  {{{1
-if TRANSIENT
-libpISSM_a_SOURCES +=  ./solutions/transient_core.cpp\
-					   ./modules/ModelProcessorx/Transient/UpdateElementsTransient.cpp
-endif
-#}}}
-#Steadystate sources  {{{1
-if STEADYSTATE
-libpISSM_a_SOURCES += ./solutions/steadystate_core.cpp\
-					  ./solutions/steadystateconvergence.cpp
-endif
-#}}}
-#Prognostic sources  {{{1
-if PROGNOSTIC
-libpISSM_a_SOURCES +=  ./solutions/prognostic_core.cpp\
-					   ./modules/ModelProcessorx/Prognostic/UpdateElementsPrognostic.cpp\
-					   ./modules/ModelProcessorx/Prognostic/CreateNodesPrognostic.cpp\
-					   ./modules/ModelProcessorx/Prognostic/CreateConstraintsPrognostic.cpp\
-					   ./modules/ModelProcessorx/Prognostic/CreateLoadsPrognostic.cpp
-
-endif
-#}}}
-#Thermal sources  {{{1
-if THERMAL
-libpISSM_a_SOURCES +=  ./solutions/thermal_core.cpp\
-					   ./solutions/thermal_core_step.cpp\
-					   ./solutions/enthalpy_core.cpp\
-					   ./solvers/solver_thermal_nonlinear.cpp\
-					   ./modules/ModelProcessorx/Thermal/UpdateElementsThermal.cpp\
-					   ./modules/ModelProcessorx/Thermal/CreateNodesThermal.cpp\
-					   ./modules/ModelProcessorx/Thermal/CreateConstraintsThermal.cpp\
-					   ./modules/ModelProcessorx/Thermal/CreateLoadsThermal.cpp\
-					   ./modules/ModelProcessorx/Enthalpy/UpdateElementsEnthalpy.cpp\
-					   ./modules/ModelProcessorx/Enthalpy/CreateNodesEnthalpy.cpp\
-					   ./modules/ModelProcessorx/Enthalpy/CreateConstraintsEnthalpy.cpp\
-					   ./modules/ModelProcessorx/Enthalpy/CreateLoadsEnthalpy.cpp\
-					   ./modules/ModelProcessorx/Melting/UpdateElementsMelting.cpp\
-					   ./modules/ModelProcessorx/Melting/CreateNodesMelting.cpp\
-					   ./modules/ModelProcessorx/Melting/CreateConstraintsMelting.cpp\
-					   ./modules/ModelProcessorx/Melting/CreateLoadsMelting.cpp\
-					   ./modules/ConstraintsStatex/ThermalConstraintsState.cpp\
-					   ./modules/ConstraintsStatex/ThermalIsPresent.cpp\
-					   ./modules/ResetConstraintsx/ThermalConstraintsReset.cpp
-endif
-#}}}
-#Control sources  {{{1
-if CONTROL
-libpISSM_a_SOURCES += ./solutions/control_core.cpp\
-					  ./solutions/controltao_core.cpp\
-					  ./solutions/controlrestart.cpp\
-					  ./solutions/controlconvergence.cpp\
-					  ./solutions/objectivefunctionC.cpp\
-					  ./solutions/gradient_core.cpp\
-					  ./solutions/adjointdiagnostic_core.cpp\
-					  ./solutions/adjointbalancethickness_core.cpp\
-					  ./solutions/AdjointCorePointerFromSolutionEnum.cpp\
-					  ./solvers/solver_adjoint_linear.cpp\
-					  ./modules/ControlInputGetGradientx/ControlInputGetGradientx.cpp\
-					  ./modules/ControlInputGetGradientx/ControlInputGetGradientx.h\
-					  ./modules/ControlInputSetGradientx/ControlInputSetGradientx.cpp\
-					  ./modules/ControlInputSetGradientx/ControlInputSetGradientx.h\
-					  ./modules/ControlInputScaleGradientx/ControlInputScaleGradientx.cpp\
-					  ./modules/ControlInputScaleGradientx/ControlInputScaleGradientx.h\
-					  ./modules/ModelProcessorx/Control/CreateParametersControl.cpp\
-					  ./modules/ModelProcessorx/Control/UpdateElementsAndMaterialsControl.cpp\
-					  ./modules/InputControlUpdatex/InputControlUpdatex.h\
-					  ./modules/InputControlUpdatex/InputControlUpdatex.cpp\
-					  ./modules/SurfaceAbsVelMisfitx/SurfaceAbsVelMisfitx.h\
-					  ./modules/SurfaceAbsVelMisfitx/SurfaceAbsVelMisfitx.cpp\
-					  ./modules/SurfaceRelVelMisfitx/SurfaceRelVelMisfitx.h\
-					  ./modules/SurfaceRelVelMisfitx/SurfaceRelVelMisfitx.cpp\
-					  ./modules/SurfaceLogVelMisfitx/SurfaceLogVelMisfitx.h\
-					  ./modules/SurfaceLogVelMisfitx/SurfaceLogVelMisfitx.cpp\
-					  ./modules/SurfaceLogVxVyMisfitx/SurfaceLogVxVyMisfitx.h\
-					  ./modules/SurfaceLogVxVyMisfitx/SurfaceLogVxVyMisfitx.cpp\
-					  ./modules/SurfaceAverageVelMisfitx/SurfaceAverageVelMisfitx.h\
-					  ./modules/SurfaceAverageVelMisfitx/SurfaceAverageVelMisfitx.cpp\
-					  ./modules/ThicknessAbsMisfitx/ThicknessAbsMisfitx.h\
-					  ./modules/ThicknessAbsMisfitx/ThicknessAbsMisfitx.cpp\
-					  ./modules/CostFunctionx/CostFunctionx.h\
-					  ./modules/CostFunctionx/CostFunctionx.cpp\
-					  ./modules/Orthx/Orthx.h\
-					  ./modules/Orthx/Orthx.cpp\
-					  ./modules/Gradjx/Gradjx.h\
-					  ./modules/Gradjx/Gradjx.cpp\
-					  ./modules/DragCoefficientAbsGradientx/DragCoefficientAbsGradientx.cpp\
-					  ./modules/DragCoefficientAbsGradientx/DragCoefficientAbsGradientx.h\
-					  ./modules/ThicknessAbsGradientx/ThicknessAbsGradientx.cpp\
-					  ./modules/ThicknessAbsGradientx/ThicknessAbsGradientx.h\
-					  ./modules/RheologyBbarAbsGradientx/RheologyBbarAbsGradientx.cpp\
-					  ./modules/RheologyBbarAbsGradientx/RheologyBbarAbsGradientx.h\
-					  ./objects/Inputs/ControlInput.h\
-					  ./objects/Inputs/ControlInput.cpp\
-					  ./shared/Numerics/BrentSearch.cpp\
-					  ./shared/Numerics/OptimalSearch.cpp\
-					  ./shared/Numerics/OptFunc.cpp\
-					  ./objects/OptArgs.h\
-					  ./objects/OptPars.h
-
-endif
-#}}}
-#Hydrology sources  {{{1
-if HYDROLOGY
-libpISSM_a_SOURCES += ./modules/ModelProcessorx/Hydrology/UpdateElementsHydrology.cpp\
-					  ./modules/ModelProcessorx/Hydrology/CreateNodesHydrology.cpp\
-					  ./modules/ModelProcessorx/Hydrology/CreateConstraintsHydrology.cpp\
-					  ./modules/ModelProcessorx/Hydrology/CreateLoadsHydrology.cpp\
-					  ./solutions/hydrology_core.cpp\
-					  ./solutions/hydrology_core_step.cpp
-endif
-#}}}
-#Diagnostic sources  {{{1
-if DIAGNOSTIC
-libpISSM_a_SOURCES += ./modules/ModelProcessorx/DiagnosticHoriz/UpdateElementsDiagnosticHoriz.cpp\
-					  ./modules/ModelProcessorx/DiagnosticHoriz/CreateNodesDiagnosticHoriz.cpp \
-					  ./modules/ModelProcessorx/DiagnosticHoriz/CreateConstraintsDiagnosticHoriz.cpp \
-					  ./modules/ModelProcessorx/DiagnosticHoriz/CreateLoadsDiagnosticHoriz.cpp\
-					  ./modules/ModelProcessorx/DiagnosticVert/UpdateElementsDiagnosticVert.cpp\
-					  ./modules/ModelProcessorx/DiagnosticVert/CreateNodesDiagnosticVert.cpp \
-					  ./modules/ModelProcessorx/DiagnosticVert/CreateConstraintsDiagnosticVert.cpp \
-					  ./modules/ModelProcessorx/DiagnosticVert/CreateLoadsDiagnosticVert.cpp\
-					  ./modules/ModelProcessorx/DiagnosticHutter/UpdateElementsDiagnosticHutter.cpp\
-					  ./modules/ModelProcessorx/DiagnosticHutter/CreateNodesDiagnosticHutter.cpp \
-					  ./modules/ModelProcessorx/DiagnosticHutter/CreateConstraintsDiagnosticHutter.cpp \
-					  ./modules/ModelProcessorx/DiagnosticHutter/CreateLoadsDiagnosticHutter.cpp\
-					  ./solutions/diagnostic_core.cpp\
-					  ./solvers/solver_stokescoupling_nonlinear.cpp
-endif
-#}}}
-#Balanced sources  {{{1
-if BALANCED
-libpISSM_a_SOURCES += ./modules/ModelProcessorx/Balancethickness/UpdateElementsBalancethickness.cpp\
-					  ./modules/ModelProcessorx/Balancethickness/CreateNodesBalancethickness.cpp\
-					  ./modules/ModelProcessorx/Balancethickness/CreateConstraintsBalancethickness.cpp\
-					  ./modules/ModelProcessorx/Balancethickness/CreateLoadsBalancethickness.cpp\
-					  ./solutions/balancethickness_core.cpp
-endif
-#}}}
-#Responses sources  {{{1
-if RESPONSES
-libpISSM_a_SOURCES += ./modules/MinVelx/MinVelx.h\
-					  ./modules/MinVelx/MinVelx.cpp\
-					  ./modules/MaxVelx/MaxVelx.h\
-					  ./modules/MaxVelx/MaxVelx.cpp\
-					  ./modules/MaxAbsVxx/MaxAbsVxx.h\
-					  ./modules/MaxAbsVxx/MaxAbsVxx.cpp\
-					  ./modules/MaxAbsVyx/MaxAbsVyx.h\
-					  ./modules/MaxAbsVyx/MaxAbsVyx.cpp\
-					  ./modules/MaxAbsVzx/MaxAbsVzx.h\
-					  ./modules/MaxAbsVzx/MaxAbsVzx.cpp\
-					  ./modules/MaxVxx/MaxVxx.h\
-					  ./modules/MaxVxx/MaxVxx.cpp\
-					  ./modules/MaxVyx/MaxVyx.h\
-					  ./modules/MaxVyx/MaxVyx.cpp\
-					  ./modules/MaxVzx/MaxVzx.h\
-					  ./modules/MaxVzx/MaxVzx.cpp\
-					  ./modules/MinVxx/MinVxx.h\
-					  ./modules/MinVxx/MinVxx.cpp\
-					  ./modules/MinVyx/MinVyx.h\
-					  ./modules/MinVyx/MinVyx.cpp\
-					  ./modules/MinVzx/MinVzx.h\
-					  ./modules/MinVzx/MinVzx.cpp\
-					  ./modules/RheologyBbarx/RheologyBbarx.cpp\
-					  ./modules/RheologyBbarx/RheologyBbarx.h\
-					  ./modules/MassFluxx/MassFluxx.cpp\
-					  ./modules/MassFluxx/MassFluxx.h\
-					  ./modules/NodalValuex/NodalValuex.h\
-					  ./modules/NodalValuex/NodalValuex.cpp\
-					  ./modules/SurfaceAreax/SurfaceAreax.h\
-					  ./modules/SurfaceAreax/SurfaceAreax.cpp\
-					  ./modules/Responsex/Responsex.h\
-					  ./modules/Responsex/Responsex.cpp
-endif
-#}}}
-#Slope sources  {{{1
-if SLOPE
-libpISSM_a_SOURCES += ./modules/ModelProcessorx/BedSlope/UpdateElementsBedSlope.cpp\
-					  ./modules/ModelProcessorx/BedSlope/CreateNodesBedSlope.cpp \
-					  ./modules/ModelProcessorx/BedSlope/CreateConstraintsBedSlope.cpp\
-					  ./modules/ModelProcessorx/BedSlope/CreateLoadsBedSlope.cpp\
-					  ./modules/ModelProcessorx/SurfaceSlope/UpdateElementsSurfaceSlope.cpp\
-					  ./modules/ModelProcessorx/SurfaceSlope/CreateNodesSurfaceSlope.cpp \
-					  ./modules/ModelProcessorx/SurfaceSlope/CreateConstraintsSurfaceSlope.cpp\
-					  ./modules/ModelProcessorx/SurfaceSlope/CreateLoadsSurfaceSlope.cpp\
-					  ./solutions/surfaceslope_core.cpp\
-					  ./solutions/bedslope_core.cpp
-endif
-#}}}
-#GroundingLine sources  {{{1
-if GROUNDINGLINE
-libpISSM_a_SOURCES += ./modules/GroundingLineMigrationx/GroundingLineMigrationx.cpp\
-					  ./modules/GroundingLineMigrationx/GroundingLineMigrationx.h\
-					  ./modules/GroundingLineMigrationx/GroundingLineMigrationxLocal.h\
-					  ./modules/GroundingLineMigrationx/GroundingLineMigrationxUtils.cpp\
-					  ./solutions/groundinglinemigration2d_core.cpp
-endif
-#}}}
-#Rifts sources  {{{1
-if RIFTS
-libpISSM_a_SOURCES += ./objects/Loads/Riftfront.cpp\
-					  ./objects/Loads/Riftfront.h\
-					  ./modules/ConstraintsStatex/RiftConstraintsState.cpp
-endif
-#}}}
-#3D sources  {{{1
-if THREED
-libpISSM_a_SOURCES += ./objects/Gauss/GaussPenta.h\
-					  ./objects/Gauss/GaussPenta.cpp\
-					  ./objects/ElementResults/PentaVertexElementResult.h\
-					  ./objects/ElementResults/PentaVertexElementResult.cpp\
-					  ./objects/Inputs/PentaVertexInput.h\
-					  ./objects/Inputs/PentaVertexInput.cpp\
-					  ./objects/Elements/Penta.h\
-					  ./objects/Elements/Penta.cpp\
-					  ./objects/Elements/PentaHook.h\
-					  ./objects/Elements/PentaHook.cpp\
-					  ./objects/Elements/PentaRef.h\
-					  ./objects/Elements/PentaRef.cpp
-endif
-#}}}
-
-#ADIC2 library, for automatic differentiation {{{1
-if ADIC2
-#libAD_a_SOURCES = ./mini1.ad.c
-libAD_a_SOURCES = 
-libAD_a_CFLAGS = -fPIC -D_PARALLEL_   -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)
-#Automatic differentiation rules: 
-%.ad.c: %.c
-	adic2 -mforward  $< --nary
-endif
-#}}}
-#Executable {{{1
-
-if NOPARALLEL
-bin_PROGRAMS = 
-else 
-bin_PROGRAMS = issm.exe issmRose.exe
-endif
-
-#Standard libraries
-LDADD =      ./libOverload.a
-issm_exe_LDADD = ./libpISSM.a $(LDADD)
-if ADIC2
-issmRose_exe_LDADD = ./libpISSMRose.a $(LDADD)
-endif
-
-#External packages
-LDADD += $(PETSCLIB) $(TAOLIB) $(FLIBS) $(PLAPACKLIB)  $(MUMPSLIB) $(SCALAPACKLIB)  $(BLACSLIB) $(HYPRELIB) $(MLLIB) $(DAKOTALIB) $(METISLIB) $(CHACOLIB) $(SCOTCHLIB) $(BLASLAPACKLIB)  $(MKLLIB) $(MPILIB) $(MATHLIB) $(FORTRANLIB) $(GRAPHICSLIB) $(MULTITHREADINGLIB) $(ADIC2LIB) 
-
-
-issm_exe_SOURCES = solutions/issm.cpp
-issm_exe_CXXFLAGS= -fPIC -D_PARALLEL_  $(CXXOPTFLAGS) $(COPTFLAGS) 
-issmRose_exe_SOURCES = solutions/issm.cpp
-issmRose_exe_CXXFLAGS= -fPIC -D_PARALLEL_  $(CXXOPTFLAGS) $(COPTFLAGS) 
-
-#}}}
Index: sm/branches/trunk-jpl-damage/src/ad/eraselinks.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/src/ad/eraselinks.sh	(revision 11683)
+++ 	(revision )
@@ -1,14 +1,0 @@
-#/bin/bash
-#This script soflinks all files in trunk/src/c/ directory necessary for compilation 
-#of trunk/src/ad/ 
-rm include
-rm objects
-rm Container
-rm shared
-rm toolkits
-rm io
-rm EnumDefinitions
-rm modules
-rm solutions
-rm solvers
-rm issm.h
Index: sm/branches/trunk-jpl-damage/src/ad/softlink.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/src/ad/softlink.sh	(revision 11683)
+++ 	(revision )
@@ -1,14 +1,0 @@
-#/bin/bash
-#This script soflinks all files in trunk/src/c/ directory necessary for compilation 
-#of trunk/src/ad/ 
-ln -s ../c/include 
-ln -s ../c/objects 
-ln -s ../c/Container 
-ln -s ../c/shared 
-ln -s ../c/toolkits 
-ln -s ../c/io 
-ln -s ../c/EnumDefinitions 
-ln -s ../c/modules 
-ln -s ../c/solutions 
-ln -s ../c/solvers 
-ln -s ../c/issm.h 
Index: /issm/branches/trunk-jpl-damage/src/c/EnumDefinitions/EnumDefinitions.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/EnumDefinitions/EnumDefinitions.h	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/c/EnumDefinitions/EnumDefinitions.h	(revision 11684)
@@ -482,6 +482,3 @@
 };
 
-/*Functions on enums: */
-const char *EnumToModelField(int  en);
-
 #endif
Index: /issm/branches/trunk-jpl-damage/src/c/EnumDefinitions/README
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/EnumDefinitions/README	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/c/EnumDefinitions/README	(revision 11684)
@@ -4,5 +4,5 @@
 - EnumToStringx.cpp
 - src/m/enum/*
-all these files are automatically synchronized with EnumDefinitions.h and EnumToModelField.cpp
+all these files are automatically synchronized with EnumDefinitions.h
 
 TO ADD AN ENUM:
Index: /issm/branches/trunk-jpl-damage/src/c/EnumDefinitions/Synchronize.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/EnumDefinitions/Synchronize.sh	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/c/EnumDefinitions/Synchronize.sh	(revision 11684)
@@ -13,29 +13,4 @@
 NUMENUMS=$(wc -l temp | awk '{printf("%s",$1);}');
 
-#Take care of EnumToModelField.m first (easy)
-#Build EnumToModelField.m {{{1
-cat <<END > $ISSM_TIER/src/m/enum/EnumToModelField.m
-function string=EnumToModelField(enum)
-%ENUMTOMODELFIELD - output string of model field associated to enum
-%
-%   WARNING: DO NOT MODIFY THIS FILE
-%            this file has been automatically generated by src/c/EnumDefinitions/Synchronize.sh
-%            Please read src/c/EnumDefinitions/README for more information
-%
-%   Usage:
-%      string=EnumToModelField(enum)
-
-switch enum,
-
-END
-
-cat EnumToModelField.cpp | grep "case" | sed -e "s/Enum :/Enum(),/g" -e "s/\"/'/g" -e "s/return /string=/g" -e "s/;/; return/g" >> $ISSM_TIER/src/m/enum/EnumToModelField.m
-
-cat <<END >> $ISSM_TIER/src/m/enum/EnumToModelField.m
-		otherwise, error(['Enum ' num2str(enum)  ' not found associated to any model field']);
-
-end
-END
-#}}}
 #Build EnumToStringx.cpp {{{1
 #Header
Index: /issm/branches/trunk-jpl-damage/src/c/Makefile.am
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/Makefile.am	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/c/Makefile.am	(revision 11684)
@@ -1,3 +1,3 @@
-INCLUDES = @DAKOTAINCL@ @SHAPELIBINCL@ @PETSCINCL@ @SLEPCINCL@ @MPIINCL@ @MATLABINCL@  @METISINCL@  @CHACOINCL@ @SCOTCHINCL@ @PLAPACKINCL@  @BLASLAPACKINCL@ @MKLINCL@ @MUMPSINCL@  @TRIANGLEINCL@ @HYPREINCL@ @MLINCL@ @TAOINCL@
+INCLUDES = @DAKOTAINCL@ @SHAPELIBINCL@ @PETSCINCL@ @SLEPCINCL@ @MPIINCL@ @MATLABINCL@  @METISINCL@  @CHACOINCL@ @SCOTCHINCL@ @PLAPACKINCL@  @BLASLAPACKINCL@ @MKLINCL@ @MUMPSINCL@  @TRIANGLEINCL@ @HYPREINCL@ @MLINCL@ @TAOINCL@ @ADIC2INCL@ @ADOLCINCL@
 EXEEXT=$(ISSMEXT)
 
@@ -120,4 +120,8 @@
 					./objects/Numerics/ElementVector.h\
 					./objects/Numerics/ElementVector.cpp\
+					./objects/Numerics/Matrix.h\
+					./objects/Numerics/Matrix.cpp\
+					./objects/Numerics/Vector.h\
+					./objects/Numerics/Vector.cpp\
 					./objects/Params/Param.h\
 					./objects/Params/BoolParam.cpp\
@@ -204,5 +208,4 @@
 					./shared/Elements/GetGlobalDofList.cpp\
 					./shared/Elements/GetNumberOfDofs.cpp\
-					./shared/Elements/CoordinateSystemTransform.cpp\
 					./shared/String/sharedstring.h\
 					./toolkits/petsc\
@@ -253,5 +256,4 @@
 					./io/PrintfFunction.cpp\
 					./EnumDefinitions/EnumDefinitions.h\
-					./EnumDefinitions/EnumToModelField.cpp\
 					./modules/ModelProcessorx/ModelProcessorx.h\
 					./modules/ModelProcessorx/ModelProcessorx.cpp\
@@ -342,4 +344,5 @@
 					./modules/ResetCoordinateSystemx/ResetCoordinateSystemx.cpp\
 					./modules/Solverx/Solverx.cpp\
+					./modules/Solverx/SolverxPetsc.cpp\
 					./modules/Solverx/Solverx.h\
 					./modules/Solverx/DofTypesToIndexSet.cpp\
@@ -503,4 +506,5 @@
 					      ./modules/ModelProcessorx/DiagnosticHutter/CreateConstraintsDiagnosticHutter.cpp \
 					      ./modules/ModelProcessorx/DiagnosticHutter/CreateLoadsDiagnosticHutter.cpp \
+							./shared/Elements/CoordinateSystemTransform.cpp\
 							./shared/Elements/TransformLoadVectorCoord.cpp \
 							./shared/Elements/TransformStiffnessMatrixCoord.cpp \
@@ -725,4 +729,6 @@
 				    ./toolkits/matlab/matlabincludes.h\
 				    ./toolkits/matlab/MatlabNArrayToNArray.cpp\
+				    ./toolkits/matlab/MatlabMatrixToMatrix.cpp\
+				    ./toolkits/matlab/MatlabVectorToVector.cpp\
 				    ./io/Matlab/matlabio.h\
 				    ./io/Matlab/WriteMatlabData.cpp\
@@ -816,5 +822,6 @@
 
 #ISSM sources are a combination of core sources and sources related to specific capabilities (which can 
-#be activated by autotools conditionals {{{1
+#be activated by autotools conditionals 
+#{{{1
 
 #First the core
@@ -925,7 +932,40 @@
 
 #External packages
-LDADD += $(PETSCLIB) $(TAOLIB) $(FLIBS) $(PLAPACKLIB)  $(MUMPSLIB) $(SCALAPACKLIB)  $(BLACSLIB) $(HYPRELIB) $(MLLIB) $(DAKOTALIB) $(METISLIB) $(CHACOLIB) $(SCOTCHLIB) $(BLASLAPACKLIB)  $(MKLLIB) $(MPILIB) $(MATHLIB) $(FORTRANLIB) $(GRAPHICSLIB) $(MULTITHREADINGLIB) $(ADIC2LIB)  $(OSLIBS)
+LDADD += $(PETSCLIB) $(TAOLIB) $(FLIBS) $(PLAPACKLIB)  $(MUMPSLIB) $(SCALAPACKLIB)  $(BLACSLIB) $(HYPRELIB) $(MLLIB) $(DAKOTALIB) $(METISLIB) $(CHACOLIB) $(SCOTCHLIB) $(BLASLAPACKLIB)  $(MKLLIB) $(MPILIB) $(MATHLIB) $(FORTRANLIB) $(GRAPHICSLIB) $(MULTITHREADINGLIB) $(OSLIBS)
 
 issm_SOURCES = solutions/issm.cpp
 issm_CXXFLAGS= -fPIC -D_PARALLEL_  $(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
+
+#ADIC2 library, for automatic differentiation 
+#libAD_a_SOURCES = ./mini1.ad.c
+libAD_a_SOURCES = 
+libAD_a_CFLAGS = -fPIC -D_PARALLEL_   -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)
+
+
+
+#Automatic differentiation rules: 
+%.ad.c: %.c
+	adic2 -mforward  $< --nary
+
+
+
+#Executable
+bin_PROGRAMS +=  issmRose.exe
+issmRose_exe_LDADD = ./libpISSMRose.a $(LDADD)
+issmRose_exe_SOURCES = solutions/issm.cpp
+issmRose_exe_CXXFLAGS= -fPIC -D_PARALLEL_  $(CXXOPTFLAGS) $(COPTFLAGS) 
+LDADD +=  $(ADIC2LIB) 
+
+endif #}}}
Index: /issm/branches/trunk-jpl-damage/src/c/io/Matlab/FetchMatlabData.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/io/Matlab/FetchMatlabData.cpp	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/c/io/Matlab/FetchMatlabData.cpp	(revision 11684)
@@ -60,6 +60,5 @@
 		outmatrix=NULL;
 	}
-	else if (mxIsClass(dataref,"double") ){
-
+	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) ){
@@ -69,5 +68,4 @@
 		}
 		else{
-
 			/*Convert matlab matrix to double* matrix: */
 			MatlabMatrixToDoubleMatrix(&outmatrix,&outmatrix_rows,&outmatrix_cols,dataref);
@@ -305,4 +303,31 @@
 }
 /*}}}*/
+/*FUNCTION FetchMatlabData(Matrix** pmatrix,const mxArray* dataref){{{1*/
+void FetchMatlabData(Matrix** pmatrix,const mxArray* dataref){
+	
+	Matrix* outmatrix=NULL;
+	int dummy=0;
+
+	if (mxIsClass(dataref,"double") ){
+
+		/*Check dataref is not pointing to NaN: */
+		if ( mxIsNaN(*(mxGetPr(dataref))) && (mxGetM(dataref)==1) && (mxGetN(dataref)==1) ){
+			outmatrix=NULL;
+		}
+		else{
+
+			/*Convert matlab matrix to petsc 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 FetchMatlabData(double** pvector,int* pM,const mxArray* dataref){{{1*/
 void FetchMatlabData(double** pvector,int* pM,const mxArray* dataref){
@@ -442,4 +467,28 @@
 		/*Convert matlab vector to petsc vector: */
 		MatlabVectorToPetscVector(&vector,&dummy,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 FetchMatlabData(Vector** pvector,const mxArray* dataref){{{1*/
+void FetchMatlabData(Vector** pvector,const mxArray* dataref){
+
+	Vector* vector=NULL;
+	int dummy;
+
+	if(mxIsEmpty(dataref)){
+		/*Nothing to pick up. Just initialize matrix pointer to NULL: */
+		vector=NULL;
+	}
+	else if (mxIsClass(dataref,"double") ){
+
+		/*Convert matlab vector to petsc vector: */
+		vector=MatlabVectorToVector(dataref);
 	}
 	else{
Index: /issm/branches/trunk-jpl-damage/src/c/io/Matlab/WriteMatlabData.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/io/Matlab/WriteMatlabData.cpp	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/c/io/Matlab/WriteMatlabData.cpp	(revision 11684)
@@ -58,4 +58,21 @@
 }
 /*}}}*/
+/*FUNCTION WriteMatlabData(mxArray** pdataref,Matrix* matrix){{{1*/
+void WriteMatlabData(mxArray** pdataref,Matrix* matrix){
+		
+	mxArray* dataref=NULL;
+	
+	if(matrix){
+		
+		/*call toolkit routine: */
+		dataref=matrix->ToMatlabMatrix();
+	}
+	else{
+		dataref = mxCreateDoubleMatrix(0,0,mxREAL);
+	}
+
+	*pdataref=dataref;
+}
+/*}}}*/
 /*FUNCTION WriteMatlabData(mxArray** pdataref,double* matrix, int M,int N){{{1*/
 void WriteMatlabData(mxArray** pdataref,double* matrix, int M,int N){
@@ -117,4 +134,21 @@
 		/*call toolkit routine: */
 		PetscVectorToMatlabVector(&dataref,vector);
+	}
+	else{
+		dataref = mxCreateDoubleMatrix(0,0,mxREAL);
+	}
+	*pdataref=dataref;
+
+}
+/*}}}*/
+/*FUNCTION WriteMatlabData(mxArray** pdataref,Vector* vector){{{1*/
+void WriteMatlabData(mxArray** pdataref,Vector* vector){
+	
+	mxArray* dataref=NULL;
+	
+	if(vector){
+		
+		/*call toolkit routine: */
+		dataref=vector->ToMatlabVector();
 	}
 	else{
Index: /issm/branches/trunk-jpl-damage/src/c/io/Matlab/matlabio.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/io/Matlab/matlabio.h	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/c/io/Matlab/matlabio.h	(revision 11684)
@@ -17,7 +17,9 @@
 void WriteMatlabData(mxArray** pdataref,DataSet* dataset);
 void WriteMatlabData(mxArray** pdataref,Mat matrix);
+void WriteMatlabData(mxArray** pdataref,Matrix* matrix);
 void WriteMatlabData(mxArray** pdataref,double* matrix, int M,int N);
 void WriteMatlabData(mxArray** pdataref,int*    matrix, int M,int N);
 void WriteMatlabData(mxArray** pdataref,Vec vector);
+void WriteMatlabData(mxArray** pdataref,Vector* vector);
 void WriteMatlabData(mxArray** pdataref,double* vector, int M);
 void WriteMatlabData(mxArray** pdataref,int integer);
@@ -34,4 +36,5 @@
 void FetchMatlabData(bool** pmatrix,int* pnumel,int* pndims,int** psize,const mxArray* dataref);
 void FetchMatlabData(Mat* pmatrix,const mxArray* dataref);
+void FetchMatlabData(Matrix** pmatrix,const mxArray* dataref);
 void FetchMatlabData(int** pvector,int* pM,const mxArray* dataref);
 void FetchMatlabData(float** pvector,int* pM,const mxArray* dataref);
@@ -39,4 +42,5 @@
 void FetchMatlabData(bool** pvector,int* pM,const mxArray* dataref);
 void FetchMatlabData(Vec* pvector,const mxArray* dataref);
+void FetchMatlabData(Vector** pvector,const mxArray* dataref);
 void FetchMatlabData(char** pstring,const mxArray* dataref);
 void FetchMatlabData(char** pmatrix,int* pnumel,int* pndims,int** psize,const mxArray* dataref);
Index: /issm/branches/trunk-jpl-damage/src/c/modules/CreateJacobianMatrixx/CreateJacobianMatrixx.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/CreateJacobianMatrixx/CreateJacobianMatrixx.cpp	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/CreateJacobianMatrixx/CreateJacobianMatrixx.cpp	(revision 11684)
@@ -10,5 +10,5 @@
 #include "../../EnumDefinitions/EnumDefinitions.h"
 
-void CreateJacobianMatrixx(Mat* pJff,Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads,Materials* materials, Parameters* parameters,double kmax){
+void CreateJacobianMatrixx(Matrix** pJff,Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads,Materials* materials, Parameters* parameters,double kmax){
 	
 	int      i,connectivity;
@@ -17,5 +17,5 @@
 	Element *element = NULL;
 	Load    *load    = NULL;
-	Mat      Jff     = NULL;
+	Matrix*  Jff     = NULL;
 
 	/*Checks*/
@@ -29,5 +29,5 @@
 
 	/*Initialize Jacobian Matrix*/
-	Jff=NewMat(fsize,fsize,connectivity,numberofdofspernode);
+	Jff=new Matrix(fsize,fsize,connectivity,numberofdofspernode);
 	
 	/*Create and assemble matrix*/
@@ -41,6 +41,5 @@
 		if(load->InAnalysis(configuration_type)) load->PenaltyCreateJacobianMatrix(Jff,kmax);
 	}
-	MatAssemblyBegin(Jff,MAT_FINAL_ASSEMBLY);
-	MatAssemblyEnd(Jff,MAT_FINAL_ASSEMBLY);
+	Jff->Assemble();
 
 	/*Assign output pointer*/
Index: /issm/branches/trunk-jpl-damage/src/c/modules/CreateJacobianMatrixx/CreateJacobianMatrixx.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/CreateJacobianMatrixx/CreateJacobianMatrixx.h	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/CreateJacobianMatrixx/CreateJacobianMatrixx.h	(revision 11684)
@@ -10,5 +10,5 @@
 
 /* local prototypes: */
-void CreateJacobianMatrixx(Mat* pJff,Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads,Materials* materials, Parameters* parameters,double kmax);
+void CreateJacobianMatrixx(Matrix** pJff,Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads,Materials* materials, Parameters* parameters,double kmax);
 
 #endif  /* _CREATEJACOBIANMATRIXX_H */
Index: /issm/branches/trunk-jpl-damage/src/c/modules/CreateNodalConstraintsx/CreateNodalConstraintsx.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/CreateNodalConstraintsx/CreateNodalConstraintsx.cpp	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/CreateNodalConstraintsx/CreateNodalConstraintsx.cpp	(revision 11684)
@@ -10,5 +10,5 @@
 #include "../../EnumDefinitions/EnumDefinitions.h"
 
-void CreateNodalConstraintsx( Vec* pys, Nodes* nodes,int configuration_type){
+void CreateNodalConstraintsx( Vector** pys, Nodes* nodes,int configuration_type){
 
 	int i;
@@ -18,5 +18,5 @@
 
 	/*output: */
-	Vec ys=NULL;
+	Vector* ys=NULL;
 
 	/*figure out how many dofs we have: */
@@ -24,5 +24,5 @@
 
 	/*allocate:*/
-	ys=NewVec(numberofdofs);
+	ys=new Vector(numberofdofs);
 
 	/*go through all nodes, and for the ones corresponding to this configuration_type, fill the 
@@ -36,6 +36,5 @@
 
 	/*Assemble: */
-	VecAssemblyBegin(ys);
-	VecAssemblyEnd(ys);
+	ys->Assemble();
 
 	/*Assign output pointers: */
Index: /issm/branches/trunk-jpl-damage/src/c/modules/CreateNodalConstraintsx/CreateNodalConstraintsx.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/CreateNodalConstraintsx/CreateNodalConstraintsx.h	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/CreateNodalConstraintsx/CreateNodalConstraintsx.h	(revision 11684)
@@ -9,5 +9,5 @@
 
 /* local prototypes: */
-void CreateNodalConstraintsx( Vec* pys, Nodes* nodes,int configuration_type);
+void CreateNodalConstraintsx( Vector** pys, Nodes* nodes,int configuration_type);
 
 #endif  /* _CREATENODALCONSTRAINTSX_H */
Index: /issm/branches/trunk-jpl-damage/src/c/modules/GetSolutionFromInputsx/GetSolutionFromInputsx.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/GetSolutionFromInputsx/GetSolutionFromInputsx.cpp	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/GetSolutionFromInputsx/GetSolutionFromInputsx.cpp	(revision 11684)
@@ -9,5 +9,5 @@
 #include "../../EnumDefinitions/EnumDefinitions.h"
 
-void	GetSolutionFromInputsx( Vec* psolution, Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters){
+void	GetSolutionFromInputsx( Vector** psolution, Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters){
 
 	/*intermediary: */
@@ -19,5 +19,5 @@
 
 	/*output: */
-	Vec solution=NULL;
+	Vector* solution=NULL;
 
 	/*retrive parameters: */
@@ -29,5 +29,5 @@
 	
 	/*Initialize solution: */
-	solution=NewVec(gsize);
+	solution=new Vector(gsize);
 	
 	/*Go through elements and plug solution: */
@@ -38,6 +38,5 @@
 
 	/*Assemble vector: */
-	VecAssemblyBegin(solution);
-	VecAssemblyEnd(solution);
+	solution->Assemble();
 
 	/*Assign output pointers:*/
Index: /issm/branches/trunk-jpl-damage/src/c/modules/GetSolutionFromInputsx/GetSolutionFromInputsx.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/GetSolutionFromInputsx/GetSolutionFromInputsx.h	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/GetSolutionFromInputsx/GetSolutionFromInputsx.h	(revision 11684)
@@ -10,5 +10,5 @@
 
 /* local prototypes: */
-void GetSolutionFromInputsx( Vec* psolution, Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters);
+void GetSolutionFromInputsx( Vector** psolution, Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters);
 
 #endif  /* _GETSOLUTIONFROMINPUTSXX_H */
Index: /issm/branches/trunk-jpl-damage/src/c/modules/InputUpdateFromSolutionx/InputUpdateFromSolutionx.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/InputUpdateFromSolutionx/InputUpdateFromSolutionx.cpp	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/InputUpdateFromSolutionx/InputUpdateFromSolutionx.cpp	(revision 11684)
@@ -9,10 +9,10 @@
 #include "../../EnumDefinitions/EnumDefinitions.h"
 
-void InputUpdateFromSolutionx( Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,Vec solution){
+void InputUpdateFromSolutionx( Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,Vector* solution){
 
 	double* serial_solution=NULL;
 
 	/*Serialize solution, so that elements can index into it on every CPU: */
-	VecToMPISerial(&serial_solution,solution);
+	serial_solution=solution->ToMPISerial();
 
 	/*Call overloaded form of InputUpdateFromSolutionx: */
Index: /issm/branches/trunk-jpl-damage/src/c/modules/InputUpdateFromSolutionx/InputUpdateFromSolutionx.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/InputUpdateFromSolutionx/InputUpdateFromSolutionx.h	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/InputUpdateFromSolutionx/InputUpdateFromSolutionx.h	(revision 11684)
@@ -10,9 +10,9 @@
 
 /* local prototypes: */
-void		InputUpdateFromSolutionx( Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters,Vec solution);
+void		InputUpdateFromSolutionx( Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters,Vector* solution);
 void        InputUpdateFromSolutionx( Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,double* solution);
 
 //with timestep
-void		InputUpdateFromSolutionx( Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters,Vec solution,int timestep);
+void		InputUpdateFromSolutionx( Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters,Vector* solution,int timestep);
 void        InputUpdateFromSolutionx( Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,double* solution, int timestep);
 
Index: /issm/branches/trunk-jpl-damage/src/c/modules/Mergesolutionfromftogx/Mergesolutionfromftogx.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/Mergesolutionfromftogx/Mergesolutionfromftogx.cpp	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/Mergesolutionfromftogx/Mergesolutionfromftogx.cpp	(revision 11684)
@@ -7,8 +7,8 @@
 #include "./Mergesolutionfromftogx.h"
 
-void	Mergesolutionfromftogx( Vec* pug, Vec uf, Vec ys, Nodes* nodes, Parameters* parameters, bool flag_ys0){
+void	Mergesolutionfromftogx( Vector** pug, Vector* uf, Vector* ys, Nodes* nodes, Parameters* parameters, bool flag_ys0){
 
 	/*output: */
-	Vec ug=NULL;
+	Vector* ug=NULL;
 
 	/*intermediary: */
@@ -29,10 +29,10 @@
 	if(ssize){
 		if(flag_ys0){
-			VecSet(ys,0.0);
+			ys->Set(0.0);
 		}
 	}
 
 	/*initialize ug: */
-	ug=NewVec(gsize);
+	ug=new Vector(gsize);
 
 	/*Merge f set back into g set: */
Index: /issm/branches/trunk-jpl-damage/src/c/modules/Mergesolutionfromftogx/Mergesolutionfromftogx.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/Mergesolutionfromftogx/Mergesolutionfromftogx.h	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/Mergesolutionfromftogx/Mergesolutionfromftogx.h	(revision 11684)
@@ -9,5 +9,5 @@
 
 /* local prototypes: */
-void	Mergesolutionfromftogx( Vec* pug, Vec uf, Vec ys, Nodes* nodes, Parameters* parameters, bool flag_ys0=false);
+void	Mergesolutionfromftogx( Vector** pug, Vector* uf, Vector* ys, Nodes* nodes, Parameters* parameters, bool flag_ys0=false);
 
 #endif  /* _MERGESOLUTIONFROMFTOGX_H */
Index: /issm/branches/trunk-jpl-damage/src/c/modules/ModelProcessorx/ModelProcessorx.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/ModelProcessorx/ModelProcessorx.cpp	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/ModelProcessorx/ModelProcessorx.cpp	(revision 11684)
@@ -64,4 +64,7 @@
 		if(solution_type==TransientSolutionEnum && analysis_type==DiagnosticVertAnalysisEnum && isdiagnostic==false) continue;
 		if(solution_type==TransientSolutionEnum && analysis_type==DiagnosticHutterAnalysisEnum && isdiagnostic==false) continue;
+		if(solution_type==SteadystateSolutionEnum && analysis_type==ThermalAnalysisEnum && isenthalpy==true) continue;
+		if(solution_type==SteadystateSolutionEnum && analysis_type==MeltingAnalysisEnum && isenthalpy==true) continue;
+		if(solution_type==SteadystateSolutionEnum && analysis_type==EnthalpyAnalysisEnum && isenthalpy==false) continue;
 	
 		_printf_(VerboseMProcessor(),"   creating datasets for analysis %s\n",EnumToStringx(analysis_type));
Index: /issm/branches/trunk-jpl-damage/src/c/modules/Reduceloadx/Reduceloadx.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/Reduceloadx/Reduceloadx.cpp	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/Reduceloadx/Reduceloadx.cpp	(revision 11684)
@@ -12,12 +12,11 @@
 #include "../../io/io.h"
 
-void	Reduceloadx( Vec pf, Mat Kfs, Vec y_s,bool flag_ys0){
+void	Reduceloadx( Vector* pf, Matrix* Kfs, Vector* y_s,bool flag_ys0){
 
 	/*intermediary*/
-	Vec         y_s0   = NULL;
-	Vec         Kfsy_s = NULL;
+	Vector*     y_s0   = NULL;
+	Vector*     Kfsy_s = NULL;
 	int         Kfsm,Kfsn;
 	int         global_m,global_n;
-	PetscScalar a;
 	bool        fromlocalsize = true;
 	int         verbose;
@@ -25,5 +24,5 @@
 	_printf_(VerboseModule(),"   Dirichlet lifting applied to load vector\n");
 
-	MatGetSize(Kfs,&global_m,&global_n);
+	Kfs->GetSize(&global_m,&global_n);
 	if(pf && global_m*global_n){
 
@@ -32,28 +31,26 @@
 
 		/*pf = pf - Kfs * y_s;*/
-		MatGetLocalSize(Kfs,&Kfsm,&Kfsn);
-		Kfsy_s=NewVec(Kfsm,fromlocalsize);
+		Kfs->GetLocalSize(&Kfsm,&Kfsn);
+		Kfsy_s=new Vector(Kfsm,fromlocalsize);
 		if (flag_ys0){
 
 			/*Create y_s0, full of 0: */
-			VecDuplicate(y_s,&y_s0);
-			VecSet(y_s0,0.0);
-			VecAssemblyBegin(y_s0);
-			VecAssemblyEnd(y_s0);
+			y_s0=y_s->Duplicate();
+			y_s0->Set(0.0);
+			y_s0->Assemble();
 
-			MatMultPatch(Kfs,y_s0,Kfsy_s);
+			Kfs->MatMult(y_s0,Kfsy_s);
 		}
 		else{
-			MatMultPatch(Kfs,y_s,Kfsy_s);
+			Kfs->MatMult(y_s,Kfsy_s);
 		}
 
-		a=-1;
-		VecAXPY(pf,a,Kfsy_s);  
+		pf->AXPY(Kfsy_s,-1);
 	}
 
 
 	/*Free ressources and return*/
-	VecFree(&y_s0);
-	VecFree(&Kfsy_s);
+	delete y_s0;
+	delete Kfsy_s;
 
 }
Index: /issm/branches/trunk-jpl-damage/src/c/modules/Reduceloadx/Reduceloadx.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/Reduceloadx/Reduceloadx.h	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/Reduceloadx/Reduceloadx.h	(revision 11684)
@@ -9,5 +9,5 @@
 
 /* local prototypes: */
-void	Reduceloadx( Vec pf, Mat Kfs, Vec ys,bool flag_ys0=false);
+void	Reduceloadx( Vector* pf, Matrix* Kfs, Vector* ys,bool flag_ys0=false);
 
 #endif  /* _REDUCELOADX_H */
Index: /issm/branches/trunk-jpl-damage/src/c/modules/Reducevectorgtofx/Reducevectorgtofx.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/Reducevectorgtofx/Reducevectorgtofx.cpp	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/Reducevectorgtofx/Reducevectorgtofx.cpp	(revision 11684)
@@ -6,8 +6,8 @@
 #include "./Reducevectorgtofx.h"
  
-void Reducevectorgtofx(Vec* puf, Vec ug, Nodes* nodes,Parameters* parameters){
+void Reducevectorgtofx(Vector** puf, Vector* ug, Nodes* nodes,Parameters* parameters){
 
 	/*output: */
-	Vec uf=NULL;
+	Vector* uf=NULL;
 
 	/*variables: */
@@ -26,10 +26,10 @@
 	else{
 		/*allocate: */
-		uf=NewVec(fsize);
+		uf=new Vector(fsize);
 
 		if(nodes->NumberOfNodes(configuration_type)){ 
 
 			/*serialize ug, so nodes can index into it: */
-			VecToMPISerial(&ug_serial,ug);
+			ug_serial=ug->ToMPISerial();
 
 			/*Go through all nodes, and ask them to retrieve values from ug, and plug them into uf: */
@@ -47,6 +47,5 @@
 		}
 		/*Assemble vector: */
-		VecAssemblyBegin(uf);
-		VecAssemblyEnd(uf);
+		uf->Assemble();
 	}
 
Index: /issm/branches/trunk-jpl-damage/src/c/modules/Reducevectorgtofx/Reducevectorgtofx.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/Reducevectorgtofx/Reducevectorgtofx.h	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/Reducevectorgtofx/Reducevectorgtofx.h	(revision 11684)
@@ -10,5 +10,5 @@
 
 /* local prototypes: */
-void Reducevectorgtofx(Vec* puf, Vec ug, Nodes* nodes,Parameters* parameters);
+void Reducevectorgtofx(Vector** puf, Vector* ug, Nodes* nodes,Parameters* parameters);
 
 #endif  /* _REDUCEVECTORGTOFX_H */
Index: /issm/branches/trunk-jpl-damage/src/c/modules/Reducevectorgtosx/Reducevectorgtosx.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/Reducevectorgtosx/Reducevectorgtosx.cpp	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/Reducevectorgtosx/Reducevectorgtosx.cpp	(revision 11684)
@@ -6,8 +6,8 @@
 #include "./Reducevectorgtosx.h"
 
-void Reducevectorgtosx(Vec* pys, Vec yg, Nodes* nodes,Parameters* parameters){
+void Reducevectorgtosx(Vector** pys, Vector* yg, Nodes* nodes,Parameters* parameters){
 
 	/*output: */
-	Vec ys=NULL;
+	Vector* ys=NULL;
 
 	/*variables: */
@@ -26,10 +26,10 @@
 	else{
 		/*allocate: */
-		ys=NewVec(ssize);
+		ys=new Vector(ssize);
 
 		if(nodes->NumberOfNodes(configuration_type)){ 
 
 			/*serialize yg, so nodes can index into it: */
-			VecToMPISerial(&yg_serial,yg);
+			yg_serial=yg->ToMPISerial();
 
 			/*Go throygh all nodes, and ask them to retrieve values from yg, and plyg them into ys: */
@@ -47,6 +47,5 @@
 		}
 		/*Assemble vector: */
-		VecAssemblyBegin(ys);
-		VecAssemblyEnd(ys);
+		ys->Assemble();
 	}
 
Index: /issm/branches/trunk-jpl-damage/src/c/modules/Reducevectorgtosx/Reducevectorgtosx.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/Reducevectorgtosx/Reducevectorgtosx.h	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/Reducevectorgtosx/Reducevectorgtosx.h	(revision 11684)
@@ -10,5 +10,5 @@
 
 /* local prototypes: */
-void Reducevectorgtosx(Vec* pys, Vec yg, Nodes* nodes,Parameters* parameters);
+void Reducevectorgtosx(Vector** pys, Vector* yg, Nodes* nodes,Parameters* parameters);
 
 #endif  /* _REDUCEVECTORGTOSX_H */
Index: /issm/branches/trunk-jpl-damage/src/c/modules/Solverx/Solverx.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/Solverx/Solverx.cpp	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/Solverx/Solverx.cpp	(revision 11684)
@@ -14,166 +14,20 @@
 #endif
 
-void	Solverx(Vec* puf, Mat Kff, Vec pf, Vec uf0,Vec df, Parameters* parameters){
+void	Solverx(Vector** puf, Matrix* Kff, Vector* pf, Vector* uf0,Vector* df, Parameters* parameters){
 
-	/*Output: */
-	Vec        uf               = NULL;
+	/*output: */
+	Vector* uf=NULL;
+	uf=new Vector();
 
-	/*Intermediary: */
-	int        local_m,local_n,global_m,global_n;
-	int        analysis_type;
+	#ifdef _HAVE_PETSC_
+	Vec uf0_vector=NULL;
+	if (uf0)uf0_vector=uf0->vector;
 
-	/*Solver */
-	KSP        ksp              = NULL;
-	PC         pc               = NULL;
-	int        iteration_number;
-	int        solver_type;
-	bool       fromlocalsize    = true;
-	#if _PETSC_MAJOR_ < 3 || (_PETSC_MAJOR_ == 3 && _PETSC_MINOR_ < 2)
-	PetscTruth flag,flg;
+	SolverxPetsc(&uf->vector, Kff->matrix, pf->vector, uf0_vector, df->vector, parameters);
+	VecGetSize(uf->vector,&uf->M);
 	#else
-	PetscBool flag,flg;
+	_error_("not supported yet!");
 	#endif
 
-	/*Stokes: */
-	IS         isv=NULL;
-	IS         isp=NULL;
-
-	#if _PETSC_MAJOR_ >= 3 
-	char ksp_type[50];
-	#endif
-
-
-	/*Display message*/
-	_printf_(VerboseModule(),"   Solving\n");
-	#if _PETSC_MAJOR_ < 3 || (_PETSC_MAJOR_ == 3 && _PETSC_MINOR_ < 2)
-	if(VerboseSolver())PetscOptionsPrint(stdout);
-	#else
-	if(VerboseSolver())PetscOptionsView(PETSC_VIEWER_STDOUT_WORLD);
-	#endif
-
-	/*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);
-	if(!global_n){
-		*puf=NULL; return;
-	}
-	/*}}}*/
-	/*Initial guess logic here: {{{1*/
-	/*Now, check that we are not giving an initial guess to the solver, if we are running a direct solver: */
-	#if _PETSC_MAJOR_ >= 3 
-	PetscOptionsGetString(PETSC_NULL,"-ksp_type",ksp_type,49,&flg);
-	if (strcmp(ksp_type,"preonly")==0)uf0=NULL;
-	#endif
-
-	/*If initial guess for the solution exists, use it to create uf, otherwise, 
-	 * duplicate the right hand side so that the solution vector has the same structure*/
-	if(uf0){
-		VecDuplicate(uf0,&uf); VecCopy(uf0,uf);
-	}
-	else{
-		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*/
-	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);
-	}
-	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*/
-	KSPCreate(MPI_COMM_WORLD,&ksp);
-	KSPSetOperators(ksp,Kff,Kff,DIFFERENT_NONZERO_PATTERN);
-	KSPSetFromOptions(ksp);
-
-	#if defined(_SERIAL_) && _PETSC_MAJOR_==3
-	/*Specific solver?: */
-	KSPGetPC(ksp,&pc);
-	if (solver_type==MUMPSPACKAGE_LU){
-		#if _PETSC_MINOR_==1
-		PCFactorSetMatSolverPackage(pc,MAT_SOLVER_MUMPS);
-		#else
-		PCFactorSetMatSolverPackage(pc,MATSOLVERMUMPS);
-		#endif
-	}
-	#endif
-
-	#if defined(_PARALLEL_) && _PETSC_MAJOR_==3
-	/*Stokes: */
-	if (solver_type==StokesSolverEnum){
-		/*Make indices out of doftypes: */
-		if(!df)_error_("need doftypes for Stokes solver!\n");
-		DofTypesToIndexSet(&isv,&isp,df,StokesSolverEnum);
-
-		/*Set field splits: */
-		KSPGetPC(ksp,&pc);
-		#if _PETSC_MINOR_==1
-		PCFieldSplitSetIS(pc,isv);
-		PCFieldSplitSetIS(pc,isp);
-		#else
-		PCFieldSplitSetIS(pc,PETSC_NULL,isv);
-		PCFieldSplitSetIS(pc,PETSC_NULL,isp);
-		#endif
-
-	}
-	#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 (uf0){
-		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: */
-	KSPSolve(ksp,pf,uf);
-	
-	/*Check convergence*/
-	KSPGetIterationNumber(ksp,&iteration_number);
-	if (iteration_number<0) _error_("%s%i"," Solver diverged at iteration number: ",-iteration_number);
-
-	/*Free resources:*/
-	KSPFree(&ksp);
-		
 	/*Assign output pointers:*/
 	*puf=uf;
Index: /issm/branches/trunk-jpl-damage/src/c/modules/Solverx/Solverx.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/Solverx/Solverx.h	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/Solverx/Solverx.h	(revision 11684)
@@ -9,5 +9,6 @@
 
 /* local prototypes: */
-void	Solverx( Vec* puf, Mat Kff, Vec pf, Vec uf0,Vec df,Parameters* parameters);
+void	Solverx(Vector** puf, Matrix* Kff, Vector* pf, Vector* uf0,Vector* df, Parameters* parameters);
+void	SolverxPetsc(Vec* puf, Mat Kff, Vec pf, Vec uf0,Vec df, Parameters* parameters);
 void    DofTypesToIndexSet(IS* pisv, IS* pisp, Vec df,int typeenum);
 #endif  /* _SOLVERX_H */
Index: /issm/branches/trunk-jpl-damage/src/c/modules/Solverx/SolverxPetsc.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/Solverx/SolverxPetsc.cpp	(revision 11684)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/Solverx/SolverxPetsc.cpp	(revision 11684)
@@ -0,0 +1,180 @@
+/*!\file SolverxPetsc
+ * \brief Petsc implementation of solver
+ */
+
+#include "./Solverx.h"
+#include "../../shared/shared.h"
+#include "../../include/include.h"
+#include "../../io/io.h"
+
+#ifdef HAVE_CONFIG_H
+	#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+void	SolverxPetsc(Vec* puf, Mat Kff, Vec pf, Vec uf0,Vec df, Parameters* parameters){
+
+	/*Output: */
+	Vec        uf               = NULL;
+
+	/*Intermediary: */
+	int        local_m,local_n,global_m,global_n;
+	int        analysis_type;
+
+	/*Solver */
+	KSP        ksp              = NULL;
+	PC         pc               = NULL;
+	int        iteration_number;
+	int        solver_type;
+	bool       fromlocalsize    = true;
+	#if _PETSC_MAJOR_ < 3 || (_PETSC_MAJOR_ == 3 && _PETSC_MINOR_ < 2)
+	PetscTruth flag,flg;
+	#else
+	PetscBool flag,flg;
+	#endif
+
+	/*Stokes: */
+	IS         isv=NULL;
+	IS         isp=NULL;
+
+	#if _PETSC_MAJOR_ >= 3 
+	char ksp_type[50];
+	#endif
+
+
+	/*Display message*/
+	_printf_(VerboseModule(),"   Solving\n");
+	#if _PETSC_MAJOR_ < 3 || (_PETSC_MAJOR_ == 3 && _PETSC_MINOR_ < 2)
+	if(VerboseSolver())PetscOptionsPrint(stdout);
+	#else
+	if(VerboseSolver())PetscOptionsView(PETSC_VIEWER_STDOUT_WORLD);
+	#endif
+
+	/*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);
+	if(!global_n){
+		*puf=NULL; return;
+	}
+	/*}}}*/
+	/*Initial guess logic here: {{{1*/
+	/*Now, check that we are not giving an initial guess to the solver, if we are running a direct solver: */
+	#if _PETSC_MAJOR_ >= 3 
+	PetscOptionsGetString(PETSC_NULL,"-ksp_type",ksp_type,49,&flg);
+	if (strcmp(ksp_type,"preonly")==0)uf0=NULL;
+	#endif
+
+	/*If initial guess for the solution exists, use it to create uf, otherwise, 
+	 * duplicate the right hand side so that the solution vector has the same structure*/
+	if(uf0){
+		VecDuplicate(uf0,&uf); VecCopy(uf0,uf);
+	}
+	else{
+		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*/
+	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);
+	}
+	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*/
+	KSPCreate(MPI_COMM_WORLD,&ksp);
+	KSPSetOperators(ksp,Kff,Kff,DIFFERENT_NONZERO_PATTERN);
+	KSPSetFromOptions(ksp);
+
+	#if defined(_SERIAL_) && _PETSC_MAJOR_==3
+	/*Specific solver?: */
+	KSPGetPC(ksp,&pc);
+	if (solver_type==MUMPSPACKAGE_LU){
+		#if _PETSC_MINOR_==1
+		PCFactorSetMatSolverPackage(pc,MAT_SOLVER_MUMPS);
+		#else
+		PCFactorSetMatSolverPackage(pc,MATSOLVERMUMPS);
+		#endif
+	}
+	#endif
+
+	#if defined(_PARALLEL_) && _PETSC_MAJOR_==3
+	/*Stokes: */
+	if (solver_type==StokesSolverEnum){
+		/*Make indices out of doftypes: */
+		if(!df)_error_("need doftypes for Stokes solver!\n");
+		DofTypesToIndexSet(&isv,&isp,df,StokesSolverEnum);
+
+		/*Set field splits: */
+		KSPGetPC(ksp,&pc);
+		#if _PETSC_MINOR_==1
+		PCFieldSplitSetIS(pc,isv);
+		PCFieldSplitSetIS(pc,isp);
+		#else
+		PCFieldSplitSetIS(pc,PETSC_NULL,isv);
+		PCFieldSplitSetIS(pc,PETSC_NULL,isp);
+		#endif
+
+	}
+	#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 (uf0){
+		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: */
+	KSPSolve(ksp,pf,uf);
+	
+	/*Check convergence*/
+	KSPGetIterationNumber(ksp,&iteration_number);
+	if (iteration_number<0) _error_("%s%i"," Solver diverged at iteration number: ",-iteration_number);
+
+	/*Free resources:*/
+	KSPFree(&ksp);
+		
+	/*Assign output pointers:*/
+	*puf=uf;
+}
Index: /issm/branches/trunk-jpl-damage/src/c/modules/StringToEnumx/StringToEnumx.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/StringToEnumx/StringToEnumx.cpp	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/StringToEnumx/StringToEnumx.cpp	(revision 11684)
@@ -137,10 +137,10 @@
 	      else if (strcmp(name,"PrognosticHydrostaticAdjustment")==0) return PrognosticHydrostaticAdjustmentEnum;
 	      else if (strcmp(name,"PrognosticMinThickness")==0) return PrognosticMinThicknessEnum;
+	      else if (strcmp(name,"PrognosticPenaltyFactor")==0) return PrognosticPenaltyFactorEnum;
+	      else if (strcmp(name,"PrognosticSpcthickness")==0) return PrognosticSpcthicknessEnum;
          else stage=2;
    }
    if(stage==2){
-	      if (strcmp(name,"PrognosticPenaltyFactor")==0) return PrognosticPenaltyFactorEnum;
-	      else if (strcmp(name,"PrognosticSpcthickness")==0) return PrognosticSpcthicknessEnum;
-	      else if (strcmp(name,"PrognosticStabilization")==0) return PrognosticStabilizationEnum;
+	      if (strcmp(name,"PrognosticStabilization")==0) return PrognosticStabilizationEnum;
 	      else if (strcmp(name,"PrognosticVertexPairing")==0) return PrognosticVertexPairingEnum;
 	      else if (strcmp(name,"QmuIsdakota")==0) return QmuIsdakotaEnum;
Index: /issm/branches/trunk-jpl-damage/src/c/modules/SystemMatricesx/SystemMatricesx.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/SystemMatricesx/SystemMatricesx.cpp	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/SystemMatricesx/SystemMatricesx.cpp	(revision 11684)
@@ -10,5 +10,5 @@
 #include "../../EnumDefinitions/EnumDefinitions.h"
 
-void SystemMatricesx(Mat* pKff, Mat* pKfs, Vec* ppf, Vec* pdf, double* pkmax,Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads,Materials* materials, Parameters* parameters,bool kflag,bool pflag,bool penalty_kflag,bool penalty_pflag){
+void SystemMatricesx(Matrix** pKff, Matrix** pKfs, Vector** ppf, Vector** pdf, double* pkmax,Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads,Materials* materials, Parameters* parameters,bool kflag,bool pflag,bool penalty_kflag,bool penalty_pflag){
 	
 	/*intermediary: */
@@ -21,8 +21,8 @@
 	
 	/*output: */
-	Mat    Kff  = NULL;
-	Mat    Kfs  = NULL;
-	Vec    pf   = NULL;
-	Vec    df=NULL;
+	Matrix*    Kff  = NULL;
+	Matrix*    Kfs  = NULL;
+	Vector*    pf   = NULL;
+	Vector*    df=NULL;
 	double kmax = 0;
 
@@ -49,7 +49,7 @@
 	if(kflag){
 
-		Kff=NewMat(fsize,fsize,connectivity,numberofdofspernode);
-		Kfs=NewMat(fsize,ssize,connectivity,numberofdofspernode);
-		df=NewVec(fsize);
+		Kff=new Matrix(fsize,fsize,connectivity,numberofdofspernode);
+		Kfs=new Matrix(fsize,ssize,connectivity,numberofdofspernode);
+		df=new Vector(fsize);
 
 		/*Fill stiffness matrix from elements: */
@@ -66,17 +66,8 @@
 
 		/*Assemble matrix and doftypes and compress matrix to save memory: */
-		MatAssemblyBegin(Kff,MAT_FINAL_ASSEMBLY);
-		MatAssemblyEnd(Kff,MAT_FINAL_ASSEMBLY);
-		#if _PETSC_MAJOR_ == 2 
-		MatCompress(Kff);
-		#endif
+		Kff->Assemble();
+		Kfs->Assemble();
+		df->Assemble();
 
-		MatAssemblyBegin(Kfs,MAT_FINAL_ASSEMBLY);
-		MatAssemblyEnd(Kfs,MAT_FINAL_ASSEMBLY);
-		#if _PETSC_MAJOR_ == 2 
-		MatCompress(Kfs);
-		#endif
-		VecAssemblyBegin(df);
-		VecAssemblyEnd(df);
 		
 	}
@@ -84,5 +75,5 @@
 	if(pflag){
 
-		pf=NewVec(fsize);
+		pf=new Vector(fsize);
 
 		/*Fill right hand side vector, from elements: */
@@ -98,10 +89,9 @@
 		}
 
-		VecAssemblyBegin(pf);
-		VecAssemblyEnd(pf);
+		pf->Assemble();
 	}
 
 	/*Now, figure out maximum value of K_gg, so that we can penalize it correctly: */
-	MatNorm(Kff,NORM_INFINITY,&kmax);
+	kmax=Kff->Norm(NORM_INFINITY);
 
 	/*Now, deal with penalties*/
@@ -115,15 +105,6 @@
 
 		/*Assemble matrix and compress matrix to save memory: */
-		MatAssemblyBegin(Kff,MAT_FINAL_ASSEMBLY);
-		MatAssemblyEnd(Kff,MAT_FINAL_ASSEMBLY);
-		#if _PETSC_MAJOR_ == 2 
-		MatCompress(Kff);
-		#endif
-
-		MatAssemblyBegin(Kfs,MAT_FINAL_ASSEMBLY);
-		MatAssemblyEnd(Kfs,MAT_FINAL_ASSEMBLY);
-		#if _PETSC_MAJOR_ == 2 
-		MatCompress(Kfs);
-		#endif
+		Kff->Assemble();
+		Kfs->Assemble();
 	}
 
@@ -137,17 +118,17 @@
 		}
 
-		VecAssemblyBegin(pf);
-		VecAssemblyEnd(pf);
+		pf->Assemble();
+		pf->Assemble();
 	}
 
 	/*Assign output pointers: */
 	if(pKff) *pKff=Kff;
-	else      MatFree(&Kff);
+	else      delete Kff;
 	if(pKfs) *pKfs=Kfs;
-	else      MatFree(&Kfs);
+	else      delete Kfs;
 	if(ppf)  *ppf=pf;
-	else      VecFree(&pf);
+	else      delete pf;
 	if(pdf)  *pdf=df;
-	else      VecFree(&df);
+	else      delete df;
 	if(pkmax) *pkmax=kmax;
 }
Index: /issm/branches/trunk-jpl-damage/src/c/modules/SystemMatricesx/SystemMatricesx.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/SystemMatricesx/SystemMatricesx.h	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/SystemMatricesx/SystemMatricesx.h	(revision 11684)
@@ -10,5 +10,5 @@
 
 /* local prototypes: */
-void SystemMatricesx(Mat* pKff, Mat* pKfs, Vec* ppf, Vec* pdf, double* pkmax,Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads,Materials* materials, Parameters* parameters,
+void SystemMatricesx(Matrix** pKff, Matrix** pKfs, Vector** ppf, Vector** pdf, double* pkmax,Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads,Materials* materials, Parameters* parameters,
 			bool kflag=true,bool pflag=true,bool penalty_kflag=true,bool penalty_pflag=true);
 
Index: /issm/branches/trunk-jpl-damage/src/c/modules/UpdateDynamicConstraintsx/UpdateDynamicConstraintsx.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/UpdateDynamicConstraintsx/UpdateDynamicConstraintsx.cpp	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/UpdateDynamicConstraintsx/UpdateDynamicConstraintsx.cpp	(revision 11684)
@@ -10,5 +10,5 @@
 #include "../../EnumDefinitions/EnumDefinitions.h"
 
-void UpdateDynamicConstraintsx(Constraints* constraints,Nodes* nodes,Parameters* parameters,Vec yg){
+void UpdateDynamicConstraintsx(Constraints* constraints,Nodes* nodes,Parameters* parameters,Vector* yg){
 	
 	int configuration_type;
@@ -19,5 +19,5 @@
 
 	/*serialize yg, so nodes can index into it: */
-	VecToMPISerial(&yg_serial,yg);
+	yg_serial=yg->ToMPISerial();
 
 	for(int i=0;i<constraints->Size();i++){
Index: /issm/branches/trunk-jpl-damage/src/c/modules/UpdateDynamicConstraintsx/UpdateDynamicConstraintsx.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/UpdateDynamicConstraintsx/UpdateDynamicConstraintsx.h	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/UpdateDynamicConstraintsx/UpdateDynamicConstraintsx.h	(revision 11684)
@@ -9,5 +9,5 @@
 #include "../../objects/objects.h"
 
-void UpdateDynamicConstraintsx(Constraints* constraints,Nodes* nodes,Parameters* parameters,Vec yg);
+void UpdateDynamicConstraintsx(Constraints* constraints,Nodes* nodes,Parameters* parameters,Vector* yg);
 
 #endif  /* _UPDATESPCSX_H */
Index: /issm/branches/trunk-jpl-damage/src/c/modules/VecMergex/VecMergex.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/VecMergex/VecMergex.cpp	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/VecMergex/VecMergex.cpp	(revision 11684)
@@ -10,5 +10,5 @@
 #include "../../EnumDefinitions/EnumDefinitions.h"
 
-void VecMergex(Vec ug, Vec uf, Nodes* nodes, Parameters* parameters, int SetEnum){
+void VecMergex(Vector* ug, Vector* uf, Nodes* nodes, Parameters* parameters, int SetEnum){
 
 	/*variables: */
@@ -21,5 +21,6 @@
 	
 	/*serialize uf: */
-	VecToMPISerial(&uf_serial,uf);
+	uf_serial=uf->ToMPISerial();
+
 
 	/*Do we have any nodes for this configuration? :*/
@@ -43,6 +44,4 @@
 
 	/*Assemble vector: */
-	VecAssemblyBegin(ug);
-	VecAssemblyEnd(ug);
-
+	ug->Assemble();
 }
Index: /issm/branches/trunk-jpl-damage/src/c/modules/VecMergex/VecMergex.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/VecMergex/VecMergex.h	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/VecMergex/VecMergex.h	(revision 11684)
@@ -10,5 +10,5 @@
 
 /* local prototypes: */
-void VecMergex(Vec ug, Vec uf, Nodes* nodes, Parameters* parameters, int SetEnum);
+void VecMergex(Vector* ug, Vector* uf, Nodes* nodes, Parameters* parameters, int SetEnum);
 
 #endif  /* _VECMERGEX_H */
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Bamg/Mesh.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Bamg/Mesh.cpp	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Bamg/Mesh.cpp	(revision 11684)
@@ -1028,8 +1028,10 @@
 				Triangle &t=triangles[i];
 				if (t.det>0 && !(t.Hidden(0)||t.Hidden(1) || t.Hidden(2) )){
-					index[num*3+0]=GetId(t[0])+1; //back to M indexing
-					index[num*3+1]=GetId(t[1])+1; //back to M indexing
-					index[num*3+2]=GetId(t[2])+1; //back to M indexing
-					num=num+1;
+					if(t.Anisotropy()<2 & t.Length()<1.e+5){
+						index[num*3+0]=GetId(t[0])+1; //back to M indexing
+						index[num*3+1]=GetId(t[1])+1; //back to M indexing
+						index[num*3+2]=GetId(t[2])+1; //back to M indexing
+						num=num+1;
+					}
 				}
 			}
@@ -1038,5 +1040,5 @@
 		/*Assign output pointers*/
 		*pindex=index;
-		*pnels=k;
+		*pnels=num;
 	}
 	/*}}}1*/
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Bamg/Triangle.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Bamg/Triangle.cpp	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Bamg/Triangle.cpp	(revision 11684)
@@ -50,4 +50,55 @@
 	AdjacentTriangle Triangle::Adj(int i)  const {
 		return AdjacentTriangle(adj[i],AdjEdgeIndex[i]&3);
+	};/*}}}*/
+	/*FUNCTION Triangle::Anisotropy{{{1*/
+	double Triangle::Anisotropy() const{
+
+		double lmin,lmax;
+
+		/*Get three vertices A,B and C*/
+		R2 A=*this->vertices[0];
+		R2 B=*this->vertices[1];
+		R2 C=*this->vertices[2];
+
+		/*Compute edges*/
+		R2 e1=B-A;
+		R2 e2=C-A;
+		R2 e3=B-C;
+
+		/*Compute edge length*/
+		double l1=Norme2(e1);
+		double l2=Norme2(e2);
+		double l3=Norme2(e3);
+
+		lmin=l1;
+		lmin=min(lmin,l2);
+		lmin=min(lmin,l3);
+		lmax=l1;
+		lmax=max(lmax,l2);
+		lmax=max(lmax,l3);
+
+		return lmax/lmin;
+	};/*}}}*/
+	/*FUNCTION Triangle::Length{{{1*/
+	double Triangle::Length() const{
+
+		double l;
+
+		/*Get three vertices A,B and C*/
+		R2 A=*this->vertices[0];
+		R2 B=*this->vertices[1];
+		R2 C=*this->vertices[2];
+
+		/*Compute edges*/
+		R2 e1=B-A;
+		R2 e2=C-A;
+		R2 e3=B-C;
+
+		/*Compute edge length*/
+		l=Norme2(e1);
+		l=max(l,Norme2(e2));
+		l=max(l,Norme2(e3));
+
+		return l;
 	};/*}}}*/
 	/*FUNCTION Triangle::Echo {{{1*/
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Bamg/Triangle.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Bamg/Triangle.h	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Bamg/Triangle.h	(revision 11684)
@@ -41,4 +41,6 @@
 			//Methods
 			void              Echo();
+			double            Anisotropy() const;
+			double            Length() const;
 			int               swap(short a1,int=0);
 			long              Optim(short a,int =0);
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Elements/Element.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Elements/Element.h	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Elements/Element.h	(revision 11684)
@@ -16,4 +16,6 @@
 class Parameters;
 class Patch;
+class Matrix;
+class Vector;
 
 #include "../../toolkits/toolkits.h"
@@ -28,8 +30,8 @@
 		virtual void   Configure(Elements* elements,Loads* loads,DataSet* nodes,Materials* materials,Parameters* parameters)=0;
 		virtual void   SetCurrentConfiguration(Elements* elements,Loads* loads,DataSet* nodes,Materials* materials,Parameters* parameters)=0;
-		virtual void   CreateKMatrix(Mat Kff, Mat Kfs,Vec df)=0;
-		virtual void   CreatePVector(Vec pf)=0;
-		virtual void   CreateJacobianMatrix(Mat Jff)=0;
-		virtual void   GetSolutionFromInputs(Vec solution)=0;
+		virtual void   CreateKMatrix(Matrix* Kff, Matrix*  Kfs,Vector* df)=0;
+		virtual void   CreatePVector(Vector* pf)=0;
+		virtual void   CreateJacobianMatrix(Matrix* Jff)=0;
+		virtual void   GetSolutionFromInputs(Vector* solution)=0;
 		virtual int    GetNodeIndex(Node* node)=0;
 		virtual int    Sid()=0;
@@ -58,4 +60,5 @@
 		virtual void   RequestedOutput(int output_enum,int step,double time)=0;
 		
+		virtual int    NodalValue(double* pvalue, int index, int natureofdataenum,bool process_units)=0;
 		virtual void   InputScale(int enum_type,double scale_factor)=0;
 		virtual void   GetVectorFromInputs(Vec vector, int name_enum)=0;
@@ -88,5 +91,4 @@
 		virtual void   ElementResponse(double* presponse,int response_enum,bool process_units)=0;
 		virtual double IceVolume(void)=0;
-		virtual int    NodalValue(double* pvalue, int index, int natureofdataenum,bool process_units)=0;
 		#endif
 
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Elements/Penta.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Elements/Penta.cpp	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Elements/Penta.cpp	(revision 11684)
@@ -567,5 +567,5 @@
 /*}}}*/
 /*FUNCTION Penta::CreateKMatrix {{{1*/
-void  Penta::CreateKMatrix(Mat Kff, Mat Kfs,Vec df){
+void  Penta::CreateKMatrix(Matrix* Kff, Matrix* Kfs,Vector* df){
 
 	/*retrieve parameters: */
@@ -671,5 +671,5 @@
 /*}}}*/
 /*FUNCTION Penta::CreatePVector {{{1*/
-void  Penta::CreatePVector(Vec pf){
+void  Penta::CreatePVector(Vector* pf){
 
 	/*retrive parameters: */
@@ -773,5 +773,5 @@
 /*}}}*/
 /*FUNCTION Penta::CreateJacobianMatrix{{{1*/
-void  Penta::CreateJacobianMatrix(Mat Jff){
+void  Penta::CreateJacobianMatrix(Matrix* Jff){
 
 	/*retrieve parameters: */
@@ -1091,5 +1091,5 @@
 /*}}}*/
 /*FUNCTION Penta::GetSolutionFromInputs{{{1*/
-void  Penta::GetSolutionFromInputs(Vec solution){
+void  Penta::GetSolutionFromInputs(Vector* solution){
 
 	int analysis_type;
@@ -2331,4 +2331,35 @@
 	extern int my_rank;
 	return my_rank; 
+}
+/*}}}*/
+/*FUNCTION Penta::NodalValue {{{1*/
+int    Penta::NodalValue(double* pvalue, int index, int natureofdataenum,bool process_units){
+
+	int i;
+	int found=0;
+	double value;
+	Input* data=NULL;
+	GaussPenta* gauss=NULL;
+
+	/*First, serarch the input: */
+	data=inputs->GetInput(natureofdataenum); 
+
+	/*figure out if we have the vertex id: */
+	found=0;
+	for(i=0;i<NUMVERTICES;i++){
+		if(index==nodes[i]->GetVertexId()){
+			/*Do we have natureofdataenum in our inputs? :*/
+			if(data){
+				/*ok, we are good. retrieve value of input at vertex :*/
+				gauss=new GaussPenta(); gauss->GaussVertex(i);
+				data->GetInputValue(&value,gauss);
+				found=1;
+				break;
+			}
+		}
+	}
+
+	if(found)*pvalue=value;
+	return found;
 }
 /*}}}*/
@@ -3008,35 +3039,4 @@
 }
 /*}}}*/
-/*FUNCTION Penta::NodalValue {{{1*/
-int    Penta::NodalValue(double* pvalue, int index, int natureofdataenum,bool process_units){
-
-	int i;
-	int found=0;
-	double value;
-	Input* data=NULL;
-	GaussPenta* gauss=NULL;
-
-	/*First, serarch the input: */
-	data=inputs->GetInput(natureofdataenum); 
-
-	/*figure out if we have the vertex id: */
-	found=0;
-	for(i=0;i<NUMVERTICES;i++){
-		if(index==nodes[i]->GetVertexId()){
-			/*Do we have natureofdataenum in our inputs? :*/
-			if(data){
-				/*ok, we are good. retrieve value of input at vertex :*/
-				gauss=new GaussPenta(); gauss->GaussVertex(i);
-				data->GetInputValue(&value,gauss);
-				found=1;
-				break;
-			}
-		}
-	}
-
-	if(found)*pvalue=value;
-	return found;
-}
-/*}}}*/
 /*FUNCTION Penta::MinVel{{{1*/
 void  Penta::MinVel(double* pminvel, bool process_units){
@@ -4190,5 +4190,5 @@
 /*}}}*/
 /*FUNCTION Penta::GetSolutionFromInputsThermal{{{1*/
-void  Penta::GetSolutionFromInputsThermal(Vec solution){
+void  Penta::GetSolutionFromInputsThermal(Vector* solution){
 
 	const int    numdof=NDOF1*NUMVERTICES;
@@ -4213,5 +4213,5 @@
 
 	/*Add value to global vector*/
-	VecSetValues(solution,numdof,doflist,(const double*)values,INSERT_VALUES);
+	solution->SetValues(numdof,doflist,values,INSERT_VALUES);
 
 	/*Free ressources:*/
@@ -4221,5 +4221,5 @@
 /*}}}*/
 /*FUNCTION Penta::GetSolutionFromInputsEnthalpy{{{1*/
-void  Penta::GetSolutionFromInputsEnthalpy(Vec solution){
+void  Penta::GetSolutionFromInputsEnthalpy(Vector* solution){
 
 	const int    numdof=NDOF1*NUMVERTICES;
@@ -4244,5 +4244,5 @@
 
 	/*Add value to global vector*/
-	VecSetValues(solution,numdof,doflist,(const double*)values,INSERT_VALUES);
+	solution->SetValues(numdof,doflist,values,INSERT_VALUES);
 
 	/*Free ressources:*/
@@ -7862,5 +7862,5 @@
 /*}}}*/
 /*FUNCTION Penta::GetSolutionFromInputsDiagnosticHoriz{{{1*/
-void  Penta::GetSolutionFromInputsDiagnosticHoriz(Vec solution){
+void  Penta::GetSolutionFromInputsDiagnosticHoriz(Vector* solution){
 
 	const int    numdof=NDOF2*NUMVERTICES;
@@ -7896,5 +7896,5 @@
 
 	/*Add value to global vector*/
-	VecSetValues(solution,numdof,doflist,(const double*)values,INSERT_VALUES);
+	solution->SetValues(numdof,doflist,values,INSERT_VALUES);
 
 	/*Free ressources:*/
@@ -7904,5 +7904,5 @@
 /*}}}*/
 /*FUNCTION Penta::GetSolutionFromInputsDiagnosticHutter{{{1*/
-void  Penta::GetSolutionFromInputsDiagnosticHutter(Vec solution){
+void  Penta::GetSolutionFromInputsDiagnosticHutter(Vector* solution){
 
 	const int    numdof=NDOF2*NUMVERTICES;
@@ -7932,5 +7932,5 @@
 
 	/*Add value to global vector*/
-	VecSetValues(solution,numdof,doflist,(const double*)values,INSERT_VALUES);
+	solution->SetValues(numdof,doflist,values,INSERT_VALUES);
 
 	/*Free ressources:*/
@@ -7940,5 +7940,5 @@
 /*}}}*/
 /*FUNCTION Penta::GetSolutionFromInputsDiagnosticVert{{{1*/
-void  Penta::GetSolutionFromInputsDiagnosticVert(Vec solution){
+void  Penta::GetSolutionFromInputsDiagnosticVert(Vector* solution){
 
 	const int    numdof=NDOF1*NUMVERTICES;
@@ -7965,5 +7965,5 @@
 
 	/*Add value to global vector*/
-	VecSetValues(solution,numdof,doflist,(const double*)values,INSERT_VALUES);
+	solution->SetValues(numdof,doflist,values,INSERT_VALUES);
 
 	/*Free ressources:*/
@@ -7973,5 +7973,5 @@
 /*}}}*/
 /*FUNCTION Penta::GetSolutionFromInputsDiagnosticStokes{{{1*/
-void  Penta::GetSolutionFromInputsDiagnosticStokes(Vec solution){
+void  Penta::GetSolutionFromInputsDiagnosticStokes(Vector* solution){
 
 	const int    numdof=NDOF4*NUMVERTICES;
@@ -8010,5 +8010,5 @@
 
 	/*Add value to global vector*/
-	VecSetValues(solution,numdof,doflist,(const double*)values,INSERT_VALUES);
+	solution->SetValues(numdof,doflist,values,INSERT_VALUES);
 
 	/*Free ressources:*/
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Elements/Penta.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Elements/Penta.h	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Elements/Penta.h	(revision 11684)
@@ -86,10 +86,10 @@
 		void   Configure(Elements* elements,Loads* loads,DataSet* nodes,Materials* materials,Parameters* parameters);
 		void   SetCurrentConfiguration(Elements* elements,Loads* loads,DataSet* nodes,Materials* materials,Parameters* parameters);
-		void   CreateKMatrix(Mat Kff, Mat Kfs,Vec df);
-		void   CreatePVector(Vec pf);
-		void   CreateJacobianMatrix(Mat Jff);
+		void   CreateKMatrix(Matrix* Kff, Matrix* Kfs,Vector* df);
+		void   CreatePVector(Vector* pf);
+		void   CreateJacobianMatrix(Matrix* Jff);
 		void   DeleteResults(void);
 		int    GetNodeIndex(Node* node);
-		void   GetSolutionFromInputs(Vec solution);
+		void   GetSolutionFromInputs(Vector* solution);
 		double GetZcoord(GaussPenta* gauss);
 		void   GetVectorFromInputs(Vec vector,int name_enum);
@@ -118,4 +118,5 @@
 		void   Update(int index, IoModel* iomodel,int analysis_counter,int analysis_type);
 		int    UpdatePotentialSheetUngrounding(double* potential_sheet_ungrounding,Vec vec_nodes_on_iceshelf,double* nodes_on_iceshelf);
+		int    NodalValue(double* pvalue, int index, int natureofdataenum,bool process_units);
 		double TimeAdapt();
 		int*   GetHorizontalNeighboorSids(void);
@@ -129,5 +130,4 @@
 		void   MinVy(double* pminvy, bool process_units);
 		void   MinVz(double* pminvz, bool process_units);
-		int    NodalValue(double* pvalue, int index, int natureofdataenum,bool process_units);
 		double MassFlux(double* segment,bool process_units);
 		void   MaxAbsVx(double* pmaxabsvx, bool process_units);
@@ -183,5 +183,5 @@
 		void    GetInputValue(double* pvalue,Node* node,int enumtype);
 		void	  GetPhi(double* phi, double*  epsilon, double viscosity);
-		void	  GetSolutionFromInputsEnthalpy(Vec solutiong);
+		void	  GetSolutionFromInputsEnthalpy(Vector* solutiong);
 		double  GetStabilizationParameter(double u, double v, double w, double diameter, double kappa);
 		void    GetStrainRate3dPattyn(double* epsilon,double* xyz_list, GaussPenta* gauss, Input* vx_input, Input* vy_input);
@@ -250,8 +250,8 @@
 		void           InputUpdateFromSolutionDiagnosticVert( double* solutiong);
 		void           InputUpdateFromSolutionDiagnosticStokes( double* solutiong);
-		void	         GetSolutionFromInputsDiagnosticHoriz(Vec solutiong);
-		void	         GetSolutionFromInputsDiagnosticHutter(Vec solutiong);
-		void	         GetSolutionFromInputsDiagnosticStokes(Vec solutiong);
-		void	         GetSolutionFromInputsDiagnosticVert(Vec solutiong);
+		void	         GetSolutionFromInputsDiagnosticHoriz(Vector* solutiong);
+		void	         GetSolutionFromInputsDiagnosticHutter(Vector* solutiong);
+		void	         GetSolutionFromInputsDiagnosticStokes(Vector* solutiong);
+		void	         GetSolutionFromInputsDiagnosticVert(Vector* solutiong);
 		ElementVector* CreatePVectorCouplingMacAyealStokes(void);
 		ElementVector* CreatePVectorCouplingMacAyealStokesViscous(void);
@@ -307,5 +307,5 @@
 		ElementVector* CreatePVectorThermalShelf(void);
 		ElementVector* CreatePVectorThermalSheet(void);
-		void	       GetSolutionFromInputsThermal(Vec solutiong);
+		void	       GetSolutionFromInputsThermal(Vector* solutiong);
 		void           InputUpdateFromSolutionThermal( double* solutiong);
 		void           InputUpdateFromSolutionEnthalpy( double* solutiong);
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Elements/Tria.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Elements/Tria.cpp	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Elements/Tria.cpp	(revision 11684)
@@ -319,5 +319,5 @@
 /*}}}*/
 /*FUNCTION Tria::CreateKMatrix {{{1*/
-void  Tria::CreateKMatrix(Mat Kff, Mat Kfs,Vec df){
+void  Tria::CreateKMatrix(Matrix* Kff, Matrix* Kfs,Vector* df){
 
 	/*retreive parameters: */
@@ -672,5 +672,5 @@
 /*}}}*/
 /*FUNCTION Tria::CreatePVector {{{1*/
-void  Tria::CreatePVector(Vec pf){
+void  Tria::CreatePVector(Vector* pf){
 
 	/*retrive parameters: */
@@ -892,5 +892,5 @@
 /*}}}*/
 /*FUNCTION Tria::CreateJacobianMatrix{{{1*/
-void  Tria::CreateJacobianMatrix(Mat Jff){
+void  Tria::CreateJacobianMatrix(Matrix* Jff){
 
 	/*retrieve parameters: */
@@ -1274,5 +1274,5 @@
 /*}}}*/
 /*FUNCTION Tria::GetSolutionFromInputs{{{1*/
-void  Tria::GetSolutionFromInputs(Vec solution){
+void  Tria::GetSolutionFromInputs(Vector* solution){
 
 	/*retrive parameters: */
@@ -2124,4 +2124,35 @@
 }
 /*}}}*/
+/*FUNCTION Tria::NodalValue {{{1*/
+int    Tria::NodalValue(double* pvalue, int index, int natureofdataenum,bool process_units){
+
+	int i;
+	int found=0;
+	double value;
+	Input* data=NULL;
+	GaussTria *gauss                            = NULL;
+
+	/*First, serarch the input: */
+	data=inputs->GetInput(natureofdataenum); 
+
+	/*figure out if we have the vertex id: */
+	found=0;
+	for(i=0;i<NUMVERTICES;i++){
+		if(index==nodes[i]->GetVertexId()){
+			/*Do we have natureofdataenum in our inputs? :*/
+			if(data){
+				/*ok, we are good. retrieve value of input at vertex :*/
+				gauss=new GaussTria(); gauss->GaussVertex(i);
+				data->GetInputValue(&value,gauss);
+				found=1;
+				break;
+			}
+		}
+	}
+
+	if(found)*pvalue=value;
+	return found;
+}
+/*}}}*/
 /*FUNCTION Tria::PatchFill{{{1*/
 void  Tria::PatchFill(int* prow, Patch* patch){
@@ -2740,35 +2771,4 @@
 }
 /*}}}*/
-/*FUNCTION Tria::NodalValue {{{1*/
-int    Tria::NodalValue(double* pvalue, int index, int natureofdataenum,bool process_units){
-
-	int i;
-	int found=0;
-	double value;
-	Input* data=NULL;
-	GaussTria *gauss                            = NULL;
-
-	/*First, serarch the input: */
-	data=inputs->GetInput(natureofdataenum); 
-
-	/*figure out if we have the vertex id: */
-	found=0;
-	for(i=0;i<NUMVERTICES;i++){
-		if(index==nodes[i]->GetVertexId()){
-			/*Do we have natureofdataenum in our inputs? :*/
-			if(data){
-				/*ok, we are good. retrieve value of input at vertex :*/
-				gauss=new GaussTria(); gauss->GaussVertex(i);
-				data->GetInputValue(&value,gauss);
-				found=1;
-				break;
-			}
-		}
-	}
-
-	if(found)*pvalue=value;
-	return found;
-}
-/*}}}*/
 /*FUNCTION Tria::ElementResponse{{{1*/
 void Tria::ElementResponse(double* presponse,int response_enum,bool process_units){
@@ -3143,5 +3143,5 @@
 /*}}}*/
 /*FUNCTION Tria::GetSolutionFromInputsDiagnosticHoriz{{{1*/
-void  Tria::GetSolutionFromInputsDiagnosticHoriz(Vec solution){
+void  Tria::GetSolutionFromInputsDiagnosticHoriz(Vector* solution){
 
 	const int    numdof=NDOF2*NUMVERTICES;
@@ -3174,5 +3174,5 @@
 	}
 
-	VecSetValues(solution,numdof,doflist,(const double*)values,INSERT_VALUES);
+	solution->SetValues(numdof,doflist,values,INSERT_VALUES);
 
 	/*Free ressources:*/
@@ -3182,5 +3182,5 @@
 /*}}}*/
 /*FUNCTION Tria::GetSolutionFromInputsDiagnosticHutter{{{1*/
-void  Tria::GetSolutionFromInputsDiagnosticHutter(Vec solution){
+void  Tria::GetSolutionFromInputsDiagnosticHutter(Vector* solution){
 
 	const int    numdof=NDOF2*NUMVERTICES;
@@ -3213,5 +3213,5 @@
 	}
 
-	VecSetValues(solution,numdof,doflist,(const double*)values,INSERT_VALUES);
+	solution->SetValues(numdof,doflist,values,INSERT_VALUES);
 
 	/*Free ressources:*/
@@ -4985,4 +4985,5 @@
 }
 /*}}}*/
+
 /*FUNCTION Tria::InputUpdateFromSolutionAdjointBalancethickness {{{1*/
 void  Tria::InputUpdateFromSolutionAdjointBalancethickness(double* solution){
@@ -5289,5 +5290,5 @@
 /*}}}*/
 /*FUNCTION Tria::GetSolutionFromInputsHydrology{{{1*/
-void  Tria::GetSolutionFromInputsHydrology(Vec solution){
+void  Tria::GetSolutionFromInputsHydrology(Vector* solution){
 
 	const int    numdof=NDOF1*NUMVERTICES;
@@ -5317,5 +5318,5 @@
 	}
 
-	VecSetValues(solution,numdof,doflist,(const double*)values,INSERT_VALUES);
+	solution->SetValues(numdof,doflist,values,INSERT_VALUES);
 
 	/*Free ressources:*/
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Elements/Tria.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Elements/Tria.h	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Elements/Tria.h	(revision 11684)
@@ -82,7 +82,7 @@
 		void   Configure(Elements* elements,Loads* loads,DataSet* nodes,Materials* materials,Parameters* parameters);
 		void   SetCurrentConfiguration(Elements* elements,Loads* loads,DataSet* nodes,Materials* materials,Parameters* parameters);
-		void   CreateKMatrix(Mat Kff, Mat Kfs,Vec df);
-		void   CreatePVector(Vec pf);
-		void   CreateJacobianMatrix(Mat Jff);
+		void   CreateKMatrix(Matrix* Kff, Matrix* Kfs,Vector* df);
+		void   CreatePVector(Vector* pf);
+		void   CreateJacobianMatrix(Matrix* Jff);
 		int    GetNodeIndex(Node* node);
 		int    Sid();
@@ -92,5 +92,5 @@
 		bool   IsNodeOnShelfFromFlags(double* flags);
 		bool   IsOnWater(); 
-		void   GetSolutionFromInputs(Vec solution);
+		void   GetSolutionFromInputs(Vector* solution);
 		void   GetVectorFromInputs(Vec vector, int name_enum);
 		void   GetVectorFromResults(Vec vector,int offset,int interp);
@@ -106,4 +106,5 @@
 		void   MaterialUpdateFromTemperature(void){_error_("not implemented yet");};
 		void   MigrateGroundingLine(double* oldfloating,double* sheet_ungrounding);
+		int    NodalValue(double* pvalue, int index, int natureofdataenum,bool process_units);
 		void   PotentialSheetUngrounding(Vec potential_sheet_ungrounding);
 		void   PositiveDegreeDay(void);
@@ -127,5 +128,4 @@
 		void   MinVy(double* pminvy, bool process_units);
 		void   MinVz(double* pminvz, bool process_units);
-		int    NodalValue(double* pvalue, int index, int natureofdataenum,bool process_units);
 		double MassFlux(double* segment,bool process_units);
 		void   MaxAbsVx(double* pmaxabsvx, bool process_units);
@@ -212,6 +212,6 @@
 		ElementVector* CreatePVectorDiagnosticHutter(void);
 		ElementMatrix* CreateJacobianDiagnosticMacayeal(void);
-		void	  GetSolutionFromInputsDiagnosticHoriz(Vec solution);
-		void	  GetSolutionFromInputsDiagnosticHutter(Vec solution);
+		void	  GetSolutionFromInputsDiagnosticHoriz(Vector* solution);
+		void	  GetSolutionFromInputsDiagnosticHutter(Vector* solution);
 		void	  InputUpdateFromSolutionDiagnosticHoriz( double* solution);
 		void	  InputUpdateFromSolutionDiagnosticHutter( double* solution);
@@ -232,5 +232,5 @@
 		ElementVector* CreatePVectorHydrology(void);
 		void      CreateHydrologyWaterVelocityInput(void);
-		void	  GetSolutionFromInputsHydrology(Vec solution);
+		void	  GetSolutionFromInputsHydrology(Vector* solution);
 		void	  InputUpdateFromSolutionHydrology(double* solution);
 		#endif
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Loads/Icefront.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Loads/Icefront.cpp	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Loads/Icefront.cpp	(revision 11684)
@@ -316,5 +316,5 @@
 /*}}}*/
 /*FUNCTION Icefront::CreateKMatrix {{{1*/
-void  Icefront::CreateKMatrix(Mat Kff, Mat Kfs){
+void  Icefront::CreateKMatrix(Matrix* Kff, Matrix* Kfs){
 
 	/*No stiffness loads applied, do nothing: */
@@ -324,5 +324,5 @@
 /*}}}*/
 /*FUNCTION Icefront::CreatePVector {{{1*/
-void  Icefront::CreatePVector(Vec pf){
+void  Icefront::CreatePVector(Vector* pf){
 
 	/*Checks in debugging mode*/
@@ -362,10 +362,10 @@
 /*}}}*/
 /*FUNCTION Icefront::CreateJacobianMatrix{{{1*/
-void  Icefront::CreateJacobianMatrix(Mat Jff){
+void  Icefront::CreateJacobianMatrix(Matrix* Jff){
 	this->CreateKMatrix(Jff,NULL);
 }
 /*}}}1*/
 /*FUNCTION Icefront::PenaltyCreateKMatrix {{{1*/
-void  Icefront::PenaltyCreateKMatrix(Mat Kff, Mat Kfs, double kmax){
+void  Icefront::PenaltyCreateKMatrix(Matrix* Kff, Matrix* Kfs, double kmax){
 	/*do nothing: */
 	return;
@@ -373,5 +373,5 @@
 /*}}}*/
 /*FUNCTION Icefront::PenaltyCreatePVector{{{1*/
-void  Icefront::PenaltyCreatePVector(Vec pf,double kmax){
+void  Icefront::PenaltyCreatePVector(Vector* pf,double kmax){
 	/*do nothing: */
 	return;
@@ -379,5 +379,5 @@
 /*}}}*/
 /*FUNCTION Icefront::PenaltyCreateJacobianMatrix{{{1*/
-void  Icefront::PenaltyCreateJacobianMatrix(Mat Jff,double kmax){
+void  Icefront::PenaltyCreateJacobianMatrix(Matrix* Jff,double kmax){
 	this->PenaltyCreateKMatrix(Jff,NULL,kmax);
 }
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Loads/Icefront.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Loads/Icefront.h	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Loads/Icefront.h	(revision 11684)
@@ -74,10 +74,10 @@
 		void  Configure(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters);
 		void  SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters);
-		void  CreateKMatrix(Mat Kff, Mat Kfs);
-		void  CreatePVector(Vec pf);
-		void  CreateJacobianMatrix(Mat Jff);
-		void  PenaltyCreateKMatrix(Mat Kff, Mat kfs, double kmax);
-		void  PenaltyCreatePVector(Vec pf, double kmax);
-		void  PenaltyCreateJacobianMatrix(Mat Jff,double kmax);
+		void  CreateKMatrix(Matrix* Kff, Matrix* Kfs);
+		void  CreatePVector(Vector* pf);
+		void  CreateJacobianMatrix(Matrix* Jff);
+		void  PenaltyCreateKMatrix(Matrix* Kff, Matrix* kfs, double kmax);
+		void  PenaltyCreatePVector(Vector*  pf, double kmax);
+		void  PenaltyCreateJacobianMatrix(Matrix* Jff,double kmax);
 		bool  InAnalysis(int analysis_type);
 		/*}}}*/
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Loads/Load.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Loads/Load.h	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Loads/Load.h	(revision 11684)
@@ -12,4 +12,6 @@
 /*{{{1*/
 class Object;
+class Matrix;
+class Vector;
 
 #include "../Object.h"
@@ -27,10 +29,10 @@
 		virtual void  Configure(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters)=0;
 		virtual void  SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters)=0;
-		virtual void  CreateKMatrix(Mat Kff, Mat Kfs)=0;
-		virtual void  CreatePVector(Vec pf)=0;
-		virtual void  CreateJacobianMatrix(Mat Jff)=0;
-		virtual void  PenaltyCreateJacobianMatrix(Mat Jff,double kmax)=0;
-		virtual void  PenaltyCreateKMatrix(Mat Kff, Mat Kfs, double kmax)=0;
-		virtual void  PenaltyCreatePVector(Vec pf, double kmax)=0;
+		virtual void  CreateKMatrix(Matrix* Kff, Matrix* Kfs)=0;
+		virtual void  CreatePVector(Vector* pf)=0;
+		virtual void  CreateJacobianMatrix(Matrix* Jff)=0;
+		virtual void  PenaltyCreateJacobianMatrix(Matrix* Jff,double kmax)=0;
+		virtual void  PenaltyCreateKMatrix(Matrix* Kff, Matrix* Kfs, double kmax)=0;
+		virtual void  PenaltyCreatePVector(Vector* pf, double kmax)=0;
 		virtual bool  InAnalysis(int analysis_type)=0;
 		/*}}}*/
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Loads/Numericalflux.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Loads/Numericalflux.cpp	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Loads/Numericalflux.cpp	(revision 11684)
@@ -334,5 +334,5 @@
 /*}}}*/
 /*FUNCTION Numericalflux::CreateKMatrix {{{1*/
-void  Numericalflux::CreateKMatrix(Mat Kff, Mat Kfs){
+void  Numericalflux::CreateKMatrix(Matrix* Kff, Matrix* Kfs){
 
 	/*recover some parameters*/
@@ -365,5 +365,5 @@
 /*}}}*/
 /*FUNCTION Numericalflux::CreatePVector {{{1*/
-void  Numericalflux::CreatePVector(Vec pf){
+void  Numericalflux::CreatePVector(Vector* pf){
 
 	/*recover some parameters*/
@@ -395,5 +395,5 @@
 /*}}}*/
 /*FUNCTION Numericalflux::PenaltyCreateKMatrix {{{1*/
-void  Numericalflux::PenaltyCreateKMatrix(Mat Kff, Mat Kfs,double kmax){
+void  Numericalflux::PenaltyCreateKMatrix(Matrix* Kff, Matrix* Kfs,double kmax){
 
 	/*No stiffness loads applied, do nothing: */
@@ -403,5 +403,5 @@
 /*}}}*/
 /*FUNCTION Numericalflux::PenaltyCreatePVector{{{1*/
-void  Numericalflux::PenaltyCreatePVector(Vec pf,double kmax){
+void  Numericalflux::PenaltyCreatePVector(Vector* pf,double kmax){
 
 	/*No penalty loads applied, do nothing: */
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Loads/Numericalflux.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Loads/Numericalflux.h	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Loads/Numericalflux.h	(revision 11684)
@@ -70,10 +70,10 @@
 		void  Configure(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters);
 		void  SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters);
-		void  CreateKMatrix(Mat Kff, Mat Kfs);
-		void  CreatePVector(Vec pf);
-		void  CreateJacobianMatrix(Mat Jff){_error_("Not implemented yet");};
-		void  PenaltyCreateJacobianMatrix(Mat Jff,double kmax){_error_("Not implemented yet");};
-		void  PenaltyCreateKMatrix(Mat Kff, Mat kfs, double kmax);
-		void  PenaltyCreatePVector(Vec pf, double kmax);
+		void  CreateKMatrix(Matrix* Kff, Matrix* Kfs);
+		void  CreatePVector(Vector* pf);
+		void  CreateJacobianMatrix(Matrix* Jff){_error_("Not implemented yet");};
+		void  PenaltyCreateJacobianMatrix(Matrix* Jff,double kmax){_error_("Not implemented yet");};
+		void  PenaltyCreateKMatrix(Matrix* Kff, Matrix* kfs, double kmax);
+		void  PenaltyCreatePVector(Vector* pf, double kmax);
 		bool  InAnalysis(int analysis_type);
 		/*}}}*/
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Loads/Pengrid.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Loads/Pengrid.cpp	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Loads/Pengrid.cpp	(revision 11684)
@@ -295,5 +295,5 @@
 /*}}}1*/
 /*FUNCTION Pengrid::CreateKMatrix {{{1*/
-void  Pengrid::CreateKMatrix(Mat Kff, Mat Kfs){
+void  Pengrid::CreateKMatrix(Matrix* Kff, Matrix* Kfs){
 
 	/*No loads applied, do nothing: */
@@ -303,5 +303,5 @@
 /*}}}1*/
 /*FUNCTION Pengrid::CreatePVector {{{1*/
-void  Pengrid::CreatePVector(Vec pf){
+void  Pengrid::CreatePVector(Vector* pf){
 
 	/*No loads applied, do nothing: */
@@ -311,5 +311,5 @@
 /*}}}1*/
 /*FUNCTION Pengrid::PenaltyCreateMatrix {{{1*/
-void  Pengrid::PenaltyCreateKMatrix(Mat Kff, Mat Kfs,double kmax){
+void  Pengrid::PenaltyCreateKMatrix(Matrix* Kff, Matrix* Kfs,double kmax){
 
 	/*Retrieve parameters: */
@@ -319,7 +319,10 @@
 
 	switch(analysis_type){
+		#ifdef _HAVE_DIAGNOSTIC_
 		case DiagnosticHorizAnalysisEnum: case AdjointHorizAnalysisEnum:
 			Ke=PenaltyCreateKMatrixDiagnosticStokes(kmax);
 			break;
+		#endif
+		#ifdef _HAVE_THERMAL_
 		case ThermalAnalysisEnum:
 			Ke=PenaltyCreateKMatrixThermal(kmax);
@@ -328,4 +331,5 @@
 			Ke=PenaltyCreateKMatrixMelting(kmax);
 			break;
+		#endif
 		default:
 			_error_("analysis %i (%s) not supported yet",analysis_type,EnumToStringx(analysis_type));
@@ -340,5 +344,5 @@
 /*}}}1*/
 /*FUNCTION Pengrid::PenaltyCreatePVector {{{1*/
-void  Pengrid::PenaltyCreatePVector(Vec pf,double kmax){
+void  Pengrid::PenaltyCreatePVector(Vector* pf,double kmax){
 
 	/*Retrieve parameters: */
@@ -348,7 +352,10 @@
 
 	switch(analysis_type){
+		#ifdef _HAVE_DIAGNOSTIC_
 		case ThermalAnalysisEnum:
 			pe=PenaltyCreatePVectorThermal(kmax);
 			break;
+		#endif
+		#ifdef _HAVE_THERMAL_
 		case MeltingAnalysisEnum:
 			pe=PenaltyCreatePVectorMelting(kmax);
@@ -356,4 +363,5 @@
 		case DiagnosticHorizAnalysisEnum: case AdjointHorizAnalysisEnum:
 			break;
+		#endif
 		default:
 			_error_("analysis %i (%s) not supported yet",analysis_type,EnumToStringx(analysis_type));
@@ -539,4 +547,5 @@
 }
 /*}}}1*/
+#ifdef _HAVE_DIAGNOSTIC_
 /*FUNCTION Pengrid::PenaltyCreateKMatrixDiagnosticStokes {{{1*/
 ElementMatrix* Pengrid::PenaltyCreateKMatrixDiagnosticStokes(double kmax){
@@ -571,4 +580,6 @@
 }
 /*}}}1*/
+#endif
+#ifdef _HAVE_THERMAL_
 /*FUNCTION Pengrid::PenaltyCreateKMatrixMelting {{{1*/
 ElementMatrix* Pengrid::PenaltyCreateKMatrixMelting(double kmax){
@@ -690,4 +701,5 @@
 }
 /*}}}1*/
+#endif
 /*FUNCTION Pengrid::ResetConstraint {{{1*/
 void  Pengrid::ResetConstraint(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 11683)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Loads/Pengrid.h	(revision 11684)
@@ -75,18 +75,22 @@
 		void  Configure(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters);
 		void  SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters);
-		void  CreateKMatrix(Mat Kff, Mat Kfs);
-		void  CreatePVector(Vec pf);
-		void  CreateJacobianMatrix(Mat Jff){_error_("Not implemented yet");};
-		void  PenaltyCreateJacobianMatrix(Mat Jff,double kmax){_error_("Not implemented yet");};
-		void  PenaltyCreateKMatrix(Mat Kff, Mat kfs, double kmax);
-		void  PenaltyCreatePVector(Vec pf, double kmax);
+		void  CreateKMatrix(Matrix* Kff, Matrix* Kfs);
+		void  CreatePVector(Vector* pf);
+		void  CreateJacobianMatrix(Matrix* Jff){_error_("Not implemented yet");};
+		void  PenaltyCreateJacobianMatrix(Matrix* Jff,double kmax){_error_("Not implemented yet");};
+		void  PenaltyCreateKMatrix(Matrix* Kff, Matrix* kfs, double kmax);
+		void  PenaltyCreatePVector(Vector* pf, double kmax);
 		bool  InAnalysis(int analysis_type);
 		/*}}}*/
 		/*Pengrid management {{{1*/
+		#ifdef _HAVE_DIAGNOSTIC_
 		ElementMatrix* PenaltyCreateKMatrixDiagnosticStokes(double kmax);
+		#endif
+		#ifdef _HAVE_THERMAL_
 		ElementMatrix* PenaltyCreateKMatrixThermal(double kmax);
 		ElementMatrix* PenaltyCreateKMatrixMelting(double kmax);
 		ElementVector* PenaltyCreatePVectorThermal(double kmax);
 		ElementVector* PenaltyCreatePVectorMelting(double kmax);
+		#endif
 		void  ConstraintActivate(int* punstable);
 		void  ConstraintActivateThermal(int* punstable);
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Loads/Penpair.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Loads/Penpair.cpp	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Loads/Penpair.cpp	(revision 11684)
@@ -199,5 +199,5 @@
 /*}}}1*/
 /*FUNCTION Penpair::CreateKMatrix {{{1*/
-void  Penpair::CreateKMatrix(Mat Kff, Mat Kfs){
+void  Penpair::CreateKMatrix(Matrix* Kff, Matrix* Kfs){
 	/*If you code this piece, don't forget that a penalty will be inactive if it is dealing with clone nodes*/
 	/*No loads applied, do nothing: */
@@ -207,5 +207,5 @@
 /*}}}1*/
 /*FUNCTION Penpair::CreatePVector {{{1*/
-void  Penpair::CreatePVector(Vec pf){
+void  Penpair::CreatePVector(Vector* pf){
 
 	/*No loads applied, do nothing: */
@@ -215,10 +215,10 @@
 /*}}}1*/
 /*FUNCTION Penpair::CreateJacobianMatrix{{{1*/
-void  Penpair::CreateJacobianMatrix(Mat Jff){
+void  Penpair::CreateJacobianMatrix(Matrix* Jff){
 	this->CreateKMatrix(Jff,NULL);
 }
 /*}}}1*/
 /*FUNCTION Penpair::PenaltyCreateKMatrix {{{1*/
-void  Penpair::PenaltyCreateKMatrix(Mat Kff, Mat Kfs,double kmax){
+void  Penpair::PenaltyCreateKMatrix(Matrix* Kff, Matrix* Kfs,double kmax){
 
 	/*Retrieve parameters: */
@@ -246,5 +246,5 @@
 /*}}}1*/
 /*FUNCTION Penpair::PenaltyCreatePVector {{{1*/
-void  Penpair::PenaltyCreatePVector(Vec pf,double kmax){
+void  Penpair::PenaltyCreatePVector(Vector* pf,double kmax){
 	/*No loads applied, do nothing: */
 	return;
@@ -252,5 +252,5 @@
 /*}}}1*/
 /*FUNCTION Penpair::PenaltyCreateJacobianMatrix{{{1*/
-void  Penpair::PenaltyCreateJacobianMatrix(Mat Jff,double kmax){
+void  Penpair::PenaltyCreateJacobianMatrix(Matrix* Jff,double kmax){
 	this->PenaltyCreateKMatrix(Jff,NULL,kmax);
 }
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Loads/Penpair.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Loads/Penpair.h	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Loads/Penpair.h	(revision 11684)
@@ -62,10 +62,10 @@
 		void  Configure(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters);
 		void  SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters);
-		void  CreateKMatrix(Mat Kff, Mat Kfs);
-		void  CreatePVector(Vec pf);
-		void  CreateJacobianMatrix(Mat Jff);
-		void  PenaltyCreateKMatrix(Mat Kff,Mat Kfs,double kmax);
-		void  PenaltyCreatePVector(Vec pf, double kmax);
-		void  PenaltyCreateJacobianMatrix(Mat Jff,double kmax);
+		void  CreateKMatrix(Matrix* Kff, Matrix* Kfs);
+		void  CreatePVector(Vector* pf);
+		void  CreateJacobianMatrix(Matrix* Jff);
+		void  PenaltyCreateKMatrix(Matrix* Kff,Matrix* Kfs,double kmax);
+		void  PenaltyCreatePVector(Vector* pf, double kmax);
+		void  PenaltyCreateJacobianMatrix(Matrix* Jff,double kmax);
 		bool  InAnalysis(int analysis_type);
 		/*}}}*/
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Loads/Riftfront.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Loads/Riftfront.cpp	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Loads/Riftfront.cpp	(revision 11684)
@@ -428,5 +428,5 @@
 /*}}}*/
 /*FUNCTION Riftfront::PenaltyCreateKMatrix {{{1*/
-void  Riftfront::PenaltyCreateKMatrix(Mat Kff, Mat Kfs,double kmax){
+void  Riftfront::PenaltyCreateKMatrix(Matrix* Kff, Matrix* Kfs,double kmax){
 
 	/*Retrieve parameters: */
@@ -454,5 +454,5 @@
 /*}}}1*/
 /*FUNCTION Riftfront::PenaltyCreatePVector {{{1*/
-void  Riftfront::PenaltyCreatePVector(Vec pf,double kmax){
+void  Riftfront::PenaltyCreatePVector(Vector* pf,double kmax){
 
 	/*Retrieve parameters: */
@@ -480,5 +480,5 @@
 /*}}}1*/
 /*FUNCTION Riftfront::CreateKMatrix {{{1*/
-void  Riftfront::CreateKMatrix(Mat Kff, Mat Kfs){
+void  Riftfront::CreateKMatrix(Matrix* Kff, Matrix* Kfs){
 	/*do nothing: */
 	return;
@@ -486,5 +486,5 @@
 /*}}}1*/
 /*FUNCTION Riftfront::CreatePVector {{{1*/
-void  Riftfront::CreatePVector(Vec pf){
+void  Riftfront::CreatePVector(Vector* pf){
 	/*do nothing: */
 	return;
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Loads/Riftfront.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Loads/Riftfront.h	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Loads/Riftfront.h	(revision 11684)
@@ -82,10 +82,10 @@
 		void  Configure(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters);
 		void  SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters);
-		void  CreateKMatrix(Mat Kff, Mat Kfs);
-		void  CreatePVector(Vec pf);
-		void  CreateJacobianMatrix(Mat Jff){_error_("Not implemented yet");};
-		void  PenaltyCreateJacobianMatrix(Mat Jff,double kmax){_error_("Not implemented yet");};
-		void  PenaltyCreateKMatrix(Mat Kff, Mat kfs, double kmax);
-		void  PenaltyCreatePVector(Vec pf, double kmax);
+		void  CreateKMatrix(Matrix* Kff, Matrix* Kfs);
+		void  CreatePVector(Vector* pf);
+		void  CreateJacobianMatrix(Matrix* Jff){_error_("Not implemented yet");};
+		void  PenaltyCreateJacobianMatrix(Matrix* Jff,double kmax){_error_("Not implemented yet");};
+		void  PenaltyCreateKMatrix(Matrix* Kff, Matrix* kfs, double kmax);
+		void  PenaltyCreatePVector(Vector* pf, double kmax);
 		bool  InAnalysis(int analysis_type);
 		/*}}}*/
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Node.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Node.cpp	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Node.cpp	(revision 11684)
@@ -594,5 +594,5 @@
 /*}}}*/
 /*FUNCTION Node::CreateNodalConstraints{{{1*/
-void  Node::CreateNodalConstraints(Vec ys){
+void  Node::CreateNodalConstraints(Vector* ys){
 
 	int i;
@@ -613,5 +613,5 @@
 		
 		/*Add values into constraint vector: */
-		VecSetValues(ys,this->indexing.ssize,this->indexing.sdoflist,values,INSERT_VALUES);
+		ys->SetValues(this->indexing.ssize,this->indexing.sdoflist,values,INSERT_VALUES);
 	}
 
@@ -875,5 +875,5 @@
 /*}}}*/
 /*FUNCTION Node::VecMerge {{{1*/
-void   Node::VecMerge(Vec ug, double* vector_serial,int setenum){
+void   Node::VecMerge(Vector* ug, double* vector_serial,int setenum){
 
 	double* values=NULL;
@@ -897,5 +897,5 @@
 
 			/*Add values into ug: */
-			VecSetValues(ug,this->indexing.fsize,indices,(const double*)values,INSERT_VALUES);
+			ug->SetValues(this->indexing.fsize,indices,values,INSERT_VALUES);
 		}
 	}
@@ -915,5 +915,5 @@
 
 			/*Add values into ug: */
-			VecSetValues(ug,this->indexing.ssize,indices,(const double*)values,INSERT_VALUES);
+			ug->SetValues(this->indexing.ssize,indices,values,INSERT_VALUES);
 		}
 	}
@@ -926,5 +926,5 @@
 /*}}}*/
 /*FUNCTION Node::VecReduce {{{1*/
-void   Node::VecReduce(Vec vector, double* ug_serial,int setenum){
+void   Node::VecReduce(Vector* vector, double* ug_serial,int setenum){
 
 	double* values=NULL;
@@ -945,5 +945,5 @@
 
 			/*Add values into ug: */
-			VecSetValues(vector,this->indexing.fsize,this->indexing.fdoflist,(const double*)values,INSERT_VALUES);
+			vector->SetValues(this->indexing.fsize,this->indexing.fdoflist,values,INSERT_VALUES);
 		}
 	}
@@ -961,5 +961,5 @@
 
 			/*Add values into ug: */
-			VecSetValues(vector,this->indexing.ssize,this->indexing.sdoflist,(const double*)values,INSERT_VALUES);
+			vector->SetValues(this->indexing.ssize,this->indexing.sdoflist,values,INSERT_VALUES);
 		}
 	}
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Node.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Node.h	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Node.h	(revision 11684)
@@ -16,4 +16,6 @@
 class  DataSet;
 class  Vertices;
+class  Vector;
+class  Matrix;
 #include "./Update.h"
 /*}}}*/
@@ -67,5 +69,5 @@
 		/*Node numerical routines {{{1*/
 		void   Configure(DataSet* nodes,Vertices* vertices);
-		void   CreateNodalConstraints(Vec ys);
+		void   CreateNodalConstraints(Vector* ys);
 		void   SetCurrentConfiguration(DataSet* nodes,Vertices* vertices);
 		int    Sid(void); 
@@ -101,6 +103,6 @@
 		int    IsGrounded();
 		void   UpdateSpcs(double* ys);
-		void   VecMerge(Vec ug, double* vector_serial,int setnum);
-		void   VecReduce(Vec vector, double* ug_serial,int setnum);
+		void   VecMerge(Vector* ug, double* vector_serial,int setenum);
+		void   VecReduce(Vector* vector, double* ug_serial,int setnum);
 		
 		/*}}}*/
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Numerics/ElementMatrix.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Numerics/ElementMatrix.cpp	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Numerics/ElementMatrix.cpp	(revision 11684)
@@ -245,6 +245,6 @@
 
 /*ElementMatrix specific routines: */
-/*FUNCTION ElementMatrix::AddToGlobal(Mat Kff, Mat Kfs){{{1*/
-void ElementMatrix::AddToGlobal(Mat Kff, Mat Kfs){
+/*FUNCTION ElementMatrix::AddToGlobal(Matrix* Kff, Matrix* Kfs){{{1*/
+void ElementMatrix::AddToGlobal(Matrix* Kff, Matrix* Kfs){
 
 	int i,j;
@@ -260,46 +260,50 @@
 	this->CheckConsistency();
 
-	if(this->dofsymmetrical){
-		/*only use row dofs to add values into global matrices: */
-		
-		if(this->row_fsize){
-			/*first, retrieve values that are in the f-set from the g-set values matrix: */
-			localvalues=(double*)xmalloc(this->row_fsize*this->row_fsize*sizeof(double));
-			for(i=0;i<this->row_fsize;i++){
-				for(j=0;j<this->row_fsize;j++){
-					*(localvalues+this->row_fsize*i+j)=*(this->values+this->ncols*this->row_flocaldoflist[i]+this->row_flocaldoflist[j]);
+	#ifdef _HAVE_PETSC_
+		if(this->dofsymmetrical){
+			/*only use row dofs to add values into global matrices: */
+			
+			if(this->row_fsize){
+				/*first, retrieve values that are in the f-set from the g-set values matrix: */
+				localvalues=(double*)xmalloc(this->row_fsize*this->row_fsize*sizeof(double));
+				for(i=0;i<this->row_fsize;i++){
+					for(j=0;j<this->row_fsize;j++){
+						*(localvalues+this->row_fsize*i+j)=*(this->values+this->ncols*this->row_flocaldoflist[i]+this->row_flocaldoflist[j]);
+					}
 				}
+				/*add local values into global  matrix, using the fglobaldoflist: */
+				MatSetValues(Kff->matrix,this->row_fsize,this->row_fglobaldoflist,this->row_fsize,this->row_fglobaldoflist,(const double*)localvalues,ADD_VALUES);
+
+				/*Free ressources:*/
+				xfree((void**)&localvalues);
 			}
-			/*add local values into global  matrix, using the fglobaldoflist: */
-			MatSetValues(Kff,this->row_fsize,this->row_fglobaldoflist,this->row_fsize,this->row_fglobaldoflist,(const double*)localvalues,ADD_VALUES);
-
-			/*Free ressources:*/
-			xfree((void**)&localvalues);
-		}
-
-
-		if((this->row_ssize!=0) && (this->row_fsize!=0)){
-			/*first, retrieve values that are in the f and s-set from the g-set values matrix: */
-			localvalues=(double*)xmalloc(this->row_fsize*this->row_ssize*sizeof(double));
-			for(i=0;i<this->row_fsize;i++){
-				for(j=0;j<this->row_ssize;j++){
-					*(localvalues+this->row_ssize*i+j)=*(this->values+this->ncols*this->row_flocaldoflist[i]+this->row_slocaldoflist[j]);
+
+
+			if((this->row_ssize!=0) && (this->row_fsize!=0)){
+				/*first, retrieve values that are in the f and s-set from the g-set values matrix: */
+				localvalues=(double*)xmalloc(this->row_fsize*this->row_ssize*sizeof(double));
+				for(i=0;i<this->row_fsize;i++){
+					for(j=0;j<this->row_ssize;j++){
+						*(localvalues+this->row_ssize*i+j)=*(this->values+this->ncols*this->row_flocaldoflist[i]+this->row_slocaldoflist[j]);
+					}
 				}
+				/*add local values into global  matrix, using the fglobaldoflist: */
+				MatSetValues(Kfs->matrix,this->row_fsize,this->row_fglobaldoflist,this->row_ssize,this->row_sglobaldoflist,(const double*)localvalues,ADD_VALUES);
+
+				/*Free ressources:*/
+				xfree((void**)&localvalues);
 			}
-			/*add local values into global  matrix, using the fglobaldoflist: */
-			MatSetValues(Kfs,this->row_fsize,this->row_fglobaldoflist,this->row_ssize,this->row_sglobaldoflist,(const double*)localvalues,ADD_VALUES);
-
-			/*Free ressources:*/
-			xfree((void**)&localvalues);
-		}
-	}
-	else{
-		_error_(" non dofsymmetrical matrix AddToGlobal routine not support yet!");
-	}
-
-}
-/*}}}*/
-/*FUNCTION ElementMatrix::AddToGlobal(Mat Jff){{{1*/
-void ElementMatrix::AddToGlobal(Mat Jff){
+		}
+		else{
+			_error_(" non dofsymmetrical matrix AddToGlobal routine not support yet!");
+		}
+	#else
+		_error_("not supported yet!");
+	#endif
+
+}
+/*}}}*/
+/*FUNCTION ElementMatrix::AddToGlobal(Matrix* Jff){{{1*/
+void ElementMatrix::AddToGlobal(Matrix* Jff){
 
 	int i,j;
@@ -312,26 +316,30 @@
 	this->CheckConsistency();
 
-	if(this->dofsymmetrical){
-		/*only use row dofs to add values into global matrices: */
-
-		if(this->row_fsize){
-			/*first, retrieve values that are in the f-set from the g-set values matrix: */
-			localvalues=(double*)xmalloc(this->row_fsize*this->row_fsize*sizeof(double));
-			for(i=0;i<this->row_fsize;i++){
-				for(j=0;j<this->row_fsize;j++){
-					*(localvalues+this->row_fsize*i+j)=*(this->values+this->ncols*this->row_flocaldoflist[i]+this->row_flocaldoflist[j]);
+	#ifdef _HAVE_PETSC_
+		if(this->dofsymmetrical){
+			/*only use row dofs to add values into global matrices: */
+
+			if(this->row_fsize){
+				/*first, retrieve values that are in the f-set from the g-set values matrix: */
+				localvalues=(double*)xmalloc(this->row_fsize*this->row_fsize*sizeof(double));
+				for(i=0;i<this->row_fsize;i++){
+					for(j=0;j<this->row_fsize;j++){
+						*(localvalues+this->row_fsize*i+j)=*(this->values+this->ncols*this->row_flocaldoflist[i]+this->row_flocaldoflist[j]);
+					}
 				}
+				/*add local values into global  matrix, using the fglobaldoflist: */
+				MatSetValues(Jff->matrix,this->row_fsize,this->row_fglobaldoflist,this->row_fsize,this->row_fglobaldoflist,(const double*)localvalues,ADD_VALUES);
+
+				/*Free ressources:*/
+				xfree((void**)&localvalues);
 			}
-			/*add local values into global  matrix, using the fglobaldoflist: */
-			MatSetValues(Jff,this->row_fsize,this->row_fglobaldoflist,this->row_fsize,this->row_fglobaldoflist,(const double*)localvalues,ADD_VALUES);
-
-			/*Free ressources:*/
-			xfree((void**)&localvalues);
-		}
-
-	}
-	else{
-		_error_(" non dofsymmetrical matrix AddToGlobal routine not support yet!");
-	}
+
+		}
+		else{
+			_error_(" non dofsymmetrical matrix AddToGlobal routine not support yet!");
+		}
+	#else
+		_error_("not supported yet!");
+	#endif
 
 }
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Numerics/ElementMatrix.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Numerics/ElementMatrix.h	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Numerics/ElementMatrix.h	(revision 11684)
@@ -58,6 +58,6 @@
 		/*}}}*/
 		/*ElementMatrix specific routines {{{1*/
-		void AddToGlobal(Mat Kff, Mat Kfs);
-		void AddToGlobal(Mat Jff);
+		void AddToGlobal(Matrix* Kff, Matrix* Kfs);
+		void AddToGlobal(Matrix* Jff);
 		void Echo(void);
 		void CheckConsistency(void);
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Numerics/ElementVector.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Numerics/ElementVector.cpp	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Numerics/ElementVector.cpp	(revision 11684)
@@ -160,42 +160,52 @@
 
 /*ElementVector specific routines: */
-/*FUNCTION ElementVector::AddToGlobal(Vec pf){{{1*/
-void ElementVector::AddToGlobal(Vec pf){
+/*FUNCTION ElementVector::AddToGlobal(Vector* pf){{{1*/
+void ElementVector::AddToGlobal(Vector* pf){
 
 	int i;
 	double* localvalues=NULL;
 
-	if(this->fsize){
-		/*first, retrieve values that are in the f-set from the g-set values vector: */
-		localvalues=(double*)xmalloc(this->fsize*sizeof(double));
-		for(i=0;i<this->fsize;i++){
-			localvalues[i]=this->values[this->flocaldoflist[i]];
-		}
-		/*add local values into global  vector, using the fglobaldoflist: */
-		VecSetValues(pf,this->fsize,this->fglobaldoflist,(const double*)localvalues,ADD_VALUES);
-
-		/*Free ressources:*/
-		xfree((void**)&localvalues);
-	}
-}
-/*}}}*/
-/*FUNCTION ElementVector::InsertIntoGlobal(Vec pf){{{1*/
-void ElementVector::InsertIntoGlobal(Vec pf){
+	#ifdef _HAVE_PETSC_
+		if(this->fsize){
+			/*first, retrieve values that are in the f-set from the g-set values vector: */
+			localvalues=(double*)xmalloc(this->fsize*sizeof(double));
+			for(i=0;i<this->fsize;i++){
+				localvalues[i]=this->values[this->flocaldoflist[i]];
+			}
+			/*add local values into global  vector, using the fglobaldoflist: */
+			VecSetValues(pf->vector,this->fsize,this->fglobaldoflist,(const double*)localvalues,ADD_VALUES);
+
+			/*Free ressources:*/
+			xfree((void**)&localvalues);
+		}
+	#else
+		_error_("not supported yet!");
+	#endif
+	
+}
+/*}}}*/
+/*FUNCTION ElementVector::InsertIntoGlobal(Vector* pf){{{1*/
+void ElementVector::InsertIntoGlobal(Vector* pf){
 
 	int i;
 	double* localvalues=NULL;
 
-	if(this->fsize){
-		/*first, retrieve values that are in the f-set from the g-set values vector: */
-		localvalues=(double*)xmalloc(this->fsize*sizeof(double));
-		for(i=0;i<this->fsize;i++){
-			localvalues[i]=this->values[this->flocaldoflist[i]];
-		}
-		/*add local values into global  vector, using the fglobaldoflist: */
-		VecSetValues(pf,this->fsize,this->fglobaldoflist,(const double*)localvalues,INSERT_VALUES);
-
-		/*Free ressources:*/
-		xfree((void**)&localvalues);
-	}
+	#ifdef _HAVE_PETSC_
+		if(this->fsize){
+			/*first, retrieve values that are in the f-set from the g-set values vector: */
+			localvalues=(double*)xmalloc(this->fsize*sizeof(double));
+			for(i=0;i<this->fsize;i++){
+				localvalues[i]=this->values[this->flocaldoflist[i]];
+			}
+			/*add local values into global  vector, using the fglobaldoflist: */
+			VecSetValues(pf->vector,this->fsize,this->fglobaldoflist,(const double*)localvalues,INSERT_VALUES);
+
+			/*Free ressources:*/
+			xfree((void**)&localvalues);
+		}
+	#else
+		_error_("not supported yet!");
+	#endif
+
 }
 /*}}}*/
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Numerics/ElementVector.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Numerics/ElementVector.h	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Numerics/ElementVector.h	(revision 11684)
@@ -40,6 +40,6 @@
 		/*}}}*/
 		/*ElementVector specific routines {{{1*/
-		void AddToGlobal(Vec pf);
-		void InsertIntoGlobal(Vec pf);
+		void AddToGlobal(Vector* pf);
+		void InsertIntoGlobal(Vector* pf);
 		void Echo(void);
 		void Init(ElementVector* pe);
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Numerics/Matrix.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Numerics/Matrix.cpp	(revision 11684)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Numerics/Matrix.cpp	(revision 11684)
@@ -0,0 +1,202 @@
+/*!\file Matrix.cpp
+ * \brief: implementation of the Matrix object
+ */
+
+/*Headers:*/
+/*{{{1*/
+#ifdef HAVE_CONFIG_H
+	#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+#include <stdio.h>
+#include <string.h>
+#include "../objects.h"
+#include "../../shared/shared.h"
+#include "../../Container/Container.h"
+#include "../../include/include.h"
+#include "./Matrix.h"
+/*}}}*/
+
+/*Matrix constructors and destructor*/
+/*FUNCTION Matrix::Matrix(){{{1*/
+Matrix::Matrix(){
+
+	this->M=0;
+	this->N=0;
+
+	#ifdef _HAVE_PETSC_
+	this->matrix=NULL;
+	#else
+	this->matrix=NULL;
+	#endif
+	#ifdef _HAVE_ADOLC_
+	this->amatrix=NULL;
+	#endif
+}
+/*}}}*/
+/*FUNCTION Matrix::Matrix(int M,int N){{{1*/
+Matrix::Matrix(int pM,int pN){
+
+	this->M=pM;
+	this->N=pN;
+
+	#ifdef _HAVE_PETSC_
+	this->matrix=NewMat(pM,pN);
+	#else
+	this->matrix=(double*)xcalloc(pM*pN,sizeof(double));
+	#endif
+	#ifdef _HAVE_ADOLC_
+	this->amatrix=(adouble*)xmalloc(pM*pN*sizeof(adouble));
+	#endif
+}
+/*}}}*/
+/*FUNCTION Matrix::Matrix(int M,int N,double sparsity){{{1*/
+Matrix::Matrix(int pM,int pN,double sparsity){
+
+	this->M=pM;
+	this->N=pN;
+
+	#ifdef _HAVE_PETSC_
+	this->matrix=NewMat(pM,pN,sparsity);
+	#else
+	this->matrix=(double*)xcalloc(pM*pN,sizeof(double));
+	#endif
+	#ifdef _HAVE_ADOLC_
+	this->amatrix=(adouble*)xmalloc(pM*pN*sizeof(adouble));
+	#endif
+}
+/*}}}*/
+/*FUNCTION Matrix::Matrix(int M,int N,int connectivity,int numberofdofspernode){{{1*/
+Matrix::Matrix(int pM,int pN,int connectivity,int numberofdofspernode){
+	
+	this->M=pM;
+	this->N=pN;
+
+	#ifdef _HAVE_PETSC_
+	this->matrix=NewMat(pM,pN,connectivity,numberofdofspernode);
+	#else
+	this->matrix=(double*)xcalloc(pM*pN,sizeof(double));
+	#endif
+	#ifdef _HAVE_ADOLC_
+	this->amatrix=(adouble*)xmalloc(pM*pN*sizeof(adouble));
+	#endif
+}
+/*}}}*/
+/*FUNCTION Matrix::~Matrix(){{{1*/
+Matrix::~Matrix(){
+
+ 	#ifdef _HAVE_PETSC_
+	MatFree(&this->matrix);
+	#else
+	xfree((void**)&this->matrix);
+	#endif
+	#ifdef _HAVE_ADOLC_
+	xfree((void**)&this->amatrix);
+	#endif
+}
+/*}}}*/
+
+/*Matrix specific routines: */
+/*FUNCTION Matrix::Echo{{{1*/
+void Matrix::Echo(void){
+
+	int i,j;
+
+	#ifdef _HAVE_PETSC_
+	MatView(this->matrix,PETSC_VIEWER_STDOUT_WORLD);
+	#else
+	printf("Matrix size: %i-%i\n",M,N);
+	for(i=0;i<M;i++){
+		for(j=0;j<N;j++){
+			printf("%g ",*(matrix+N*i+j));
+		}
+		printf("\n");
+	}
+	#endif
+
+	#ifdef _HAVE_ADOLC_
+	/*Not sure about that one. Should we use the overloaded operator >>?*/
+	printf("ADOLC Matrix equivalent:" );
+	for(i=0;i<M;i++){
+		for(j=0;j<N;j++){
+			printf("%g ",*(amatrix+N*i+j));
+		}
+		printf("\n");
+	}
+	#endif
+}
+/*}}}*/
+
+#ifdef _SERIAL_
+/*FUNCTION Matrix::ToMatlabMatrix{{{1*/
+mxArray* Matrix::ToMatlabMatrix(void){
+
+	mxArray* dataref=NULL;
+	#ifdef _HAVE_PETSC_
+	PetscMatrixToMatlabMatrix(&dataref,this->matrix);
+	#else
+	_error_("not implemented yet!");
+	#endif
+	return dataref;
+
+}
+/*}}}*/
+#endif
+/*FUNCTION Matrix::Assemble{{{1*/
+void Matrix::Assemble(void){
+	#ifdef _HAVE_PETSC_
+		MatAssemblyBegin(this->matrix,MAT_FINAL_ASSEMBLY);
+		MatAssemblyEnd(this->matrix,MAT_FINAL_ASSEMBLY);
+		#if _PETSC_MAJOR_ == 2 
+			MatCompress(this->matrix);
+		#endif
+	#else
+		/*do nothing:*/
+	#endif
+
+}
+/*}}}*/
+/*FUNCTION Matrix::Norm{{{1*/
+double Matrix::Norm(int norm_type){
+	
+	double norm=0;
+	#ifdef _HAVE_PETSC_
+	    MatNorm(this->matrix,(NormType)norm_type,&norm);
+	#else
+		_error_("not implemented yet!");
+	#endif
+	return norm;
+}
+/*}}}*/
+/*FUNCTION Matrix::GetSize{{{1*/
+void Matrix::GetSize(int* pM,int* pN){
+	
+	#ifdef _HAVE_PETSC_
+	    MatGetSize(this->matrix,pM,pN);
+	#else
+		_error_("not implemented yet!");
+	#endif
+}
+/*}}}*/
+/*FUNCTION Matrix::GetLocalSize{{{1*/
+void Matrix::GetLocalSize(int* pM,int* pN){
+	
+	#ifdef _HAVE_PETSC_
+	    MatGetLocalSize(this->matrix,pM,pN);
+	#else
+		_error_("not implemented yet!");
+	#endif
+}
+/*}}}*/
+/*FUNCTION Matrix::MatMult{{{1*/
+void Matrix::MatMult(Vector* X,Vector* AX){
+
+	#ifdef _HAVE_PETSC_
+	    MatMultPatch(this->matrix,X->vector,AX->vector);
+	#else
+		_error_("not implemented yet!");
+	#endif
+}
+/*}}}*/
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Numerics/Matrix.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Numerics/Matrix.h	(revision 11684)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Numerics/Matrix.h	(revision 11684)
@@ -0,0 +1,66 @@
+/*!\file:  Matrix.h
+ * \brief wrapper to matrix objects. The goal is to control which API (PETSC,Scalpack, Plapack?) 
+ * implements our underlying matrix format.
+ */ 
+
+#ifndef _MATRIX_H_
+#define _MATRIX_H_
+
+/*Headers:*/
+/*{{{1*/
+#ifdef HAVE_CONFIG_H
+	#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+#include "../Object.h"
+#include "../../toolkits/toolkits.h"
+#include "../../EnumDefinitions/EnumDefinitions.h"
+
+#ifdef _HAVE_ADOLC_
+#include "adolc.h"
+#endif
+
+#ifdef _SERIAL_
+#include "mex.h"
+#endif
+class Vector;
+
+/*}}}*/
+
+class Matrix{
+
+	public:
+	
+		int M,N; 
+
+		#ifdef _HAVE_PETSC_
+		Mat matrix; 
+		#else
+		double* matrix; 
+		#endif
+		#ifdef _HAVE_ADOLC_
+		adouble* amatrix;
+		#endif
+
+		/*Matrix constructors, destructors {{{1*/
+		Matrix();
+		Matrix(int M,int N);
+		Matrix(int M,int N,double sparsity);
+		Matrix(int M,int N,int connectivity,int numberofdofspernode);
+		~Matrix();
+		/*}}}*/
+		/*Matrix specific routines {{{1*/
+		void Echo(void);
+		#ifdef _SERIAL_
+		mxArray* ToMatlabMatrix(void);
+		#endif
+		void Assemble(void);
+		double Norm(int norm_type);
+		void GetSize(int* pM,int* pN);
+		void GetLocalSize(int* pM,int* pN);
+		void MatMult(Vector* X,Vector* AX);
+		/*}}}*/
+
+};
+#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 11684)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Numerics/Vector.cpp	(revision 11684)
@@ -0,0 +1,248 @@
+/*!\file Vector.cpp
+ * \brief: implementation of the Vector object
+ */
+
+/*Headers:*/
+/*{{{1*/
+#ifdef HAVE_CONFIG_H
+	#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+#include <stdio.h>
+#include <string.h>
+#include "../objects.h"
+#include "../../shared/shared.h"
+#include "../../Container/Container.h"
+#include "../../include/include.h"
+#include "./Vector.h"
+/*}}}*/
+
+/*Vector constructors and destructor*/
+/*FUNCTION Vector::Vector(){{{1*/
+Vector::Vector(){
+
+	this->M=0;
+	#ifdef _HAVE_PETSC_
+	this->vector=NULL;
+	#else
+	this->vector=NULL;
+	#endif
+	#ifdef _HAVE_ADOLC_
+	this->avector=NULL;
+	#endif
+}
+/*}}}*/
+/*FUNCTION Vector::Vector(int M,bool fromlocalsize){{{1*/
+Vector::Vector(int pM,bool fromlocalsize){
+
+	#ifdef _HAVE_PETSC_
+	this->vector=NewVec(pM,fromlocalsize);
+	#else
+	this->M=pM;
+	this->vector=(double*)xcalloc(pM,sizeof(double));
+	#endif
+	#ifdef _HAVE_ADOLC_
+	this->avector=(adouble*)xmalloc(pM*sizeof(adouble));
+	#endif
+}
+/*}}}*/
+/*FUNCTION Vector::~Vector(){{{1*/
+Vector::~Vector(){
+
+ 	#ifdef _HAVE_PETSC_
+	VecFree(&this->vector);
+	#else
+	xfree((void**)&this->vector);
+	#endif
+	#ifdef _HAVE_ADOLC_
+	xfree((void**)&this->avector);
+	#endif
+}
+/*}}}*/
+
+/*Vector specific routines: */
+/*FUNCTION Vector::Echo{{{1*/
+void Vector::Echo(void){
+
+	int i;
+
+	#ifdef _HAVE_PETSC_
+	VecView(this->vector,PETSC_VIEWER_STDOUT_WORLD);
+	#else
+	printf("Vector size: %i\n",M);
+	for(i=0;i<M;i++){
+		printf("%g\n ",*(vector+i));
+	}
+	#endif
+
+	#ifdef _HAVE_ADOLC_
+	/*Not sure about that one. Should we use the overloaded operator >>?*/
+	printf("ADOLC Vector equivalent:" );
+	for(i=0;i<M;i++){
+		printf("%g\n ",*(avector+i));
+	}
+	#endif
+}
+/*}}}*/
+
+#ifdef _SERIAL_
+/*FUNCTION Vector::ToMatlabVector{{{1*/
+mxArray* Vector::ToMatlabVector(void){
+
+	mxArray* dataref=NULL;
+	#ifdef _HAVE_PETSC_
+	PetscVectorToMatlabVector(&dataref,this->vector);
+	#else
+	_error_("not implemented yet!");
+	#endif
+	return dataref;
+
+}
+/*}}}*/
+#endif
+/*FUNCTION Vector::Assemble{{{1*/
+void Vector::Assemble(void){
+		
+	#ifdef _HAVE_PETSC_
+		VecAssemblyBegin(this->vector); 
+		VecAssemblyEnd(this->vector);
+	#else
+		/*do nothing*/
+	#endif
+
+}
+/*}}}*/
+/*FUNCTION Vector::SetValues{{{1*/
+void Vector::SetValues(int ssize, int* list, double* values, int mode){
+		
+		
+	#ifdef _HAVE_PETSC_
+	VecSetValues(this->vector,ssize,list,values,(InsertMode)mode);
+	#else
+		_error_("not implemented yet!");
+	#endif
+
+}
+/*}}}*/
+/*FUNCTION Vector::GetSize{{{1*/
+void Vector::GetSize(int* pM){
+		
+	#ifdef _HAVE_PETSC_
+		VecGetSize(this->vector,pM);
+	#else
+		_error_("not implemented yet!");
+	#endif
+
+}
+/*}}}*/
+/*FUNCTION Vector::GetLocalSize{{{1*/
+void Vector::GetLocalSize(int* pM){
+		
+	#ifdef _HAVE_PETSC_
+		VecGetLocalSize(this->vector,pM);
+	#else
+		_error_("not implemented yet!");
+	#endif
+
+}
+/*}}}*/
+/*FUNCTION Vector::Duplicate{{{1*/
+Vector* Vector::Duplicate(void){
+	
+	Vector* output=NULL;
+	output=new Vector();
+	#ifdef _HAVE_PETSC_
+		Vec vec_output=NULL;
+		VecDuplicate(this->vector,&vec_output);
+		output->vector=vec_output;
+		VecGetSize(output->vector,&output->M);
+	#else
+		_error_("not implemented yet!");
+	#endif
+	return output;
+
+}
+/*}}}*/
+/*FUNCTION Vector::Set{{{1*/
+void Vector::Set(double value){
+	
+	#ifdef _HAVE_PETSC_
+		this->Set(value);
+	#else
+		_error_("not implemented yet!");
+	#endif
+
+}
+/*}}}*/
+/*FUNCTION Vector::AXPY{{{1*/
+void Vector::AXPY(Vector* X, double a){
+	
+	#ifdef _HAVE_PETSC_
+		VecAXPY(this->vector,a,X->vector);
+	#else
+		_error_("not implemented yet!");
+	#endif
+
+}
+/*}}}*/
+/*FUNCTION Vector::AYPX{{{1*/
+void Vector::AYPX(Vector* X, double a){
+	
+	#ifdef _HAVE_PETSC_
+		VecAYPX(this->vector,a,X->vector);
+	#else
+		_error_("not implemented yet!");
+	#endif
+
+}
+/*}}}*/
+/*FUNCTION Vector::ToMPISerial{{{1*/
+double* Vector::ToMPISerial(void){
+
+	double* vec_serial=NULL;
+
+	#ifdef _HAVE_PETSC_
+		VecToMPISerial(&vec_serial, this->vector);
+	#else
+		_error_("not implemented yet!");
+	#endif
+
+	return vec_serial;
+
+}
+/*}}}*/
+/*FUNCTION Vector::Copy{{{1*/
+void Vector::Copy(Vector* to){
+
+	#ifdef _HAVE_PETSC_
+		VecCopy(this->vector,to->vector);
+	#else
+		_error_("not implemented yet!");
+	#endif
+
+}
+/*}}}*/
+/*FUNCTION Vector::Norm{{{1*/
+double Vector::Norm(int norm_type){
+	
+	double norm=0;
+	#ifdef _HAVE_PETSC_
+	    VecNorm(this->vector,(NormType)norm_type,&norm);
+	#else
+		_error_("not implemented yet!");
+	#endif
+	return norm;
+}
+/*}}}*/
+/*FUNCTION Vector::Scale{{{1*/
+void Vector::Scale(double scale_factor){
+	
+	#ifdef _HAVE_PETSC_
+	    VecScale(this->vector,scale_factor); 
+	#else
+		_error_("not implemented yet!");
+	#endif
+}
+/*}}}*/
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Numerics/Vector.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Numerics/Vector.h	(revision 11684)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Numerics/Vector.h	(revision 11684)
@@ -0,0 +1,70 @@
+/*!\file:  Vector.h
+ * \brief wrapper to vector objects. The goal is to control which API (PETSC,Scalpack, Plapack?) 
+ * implements our underlying vector format.
+ */ 
+
+#ifndef _VECTOR_H_
+#define _VECTOR_H_
+
+/*Headers:*/
+/*{{{1*/
+#ifdef HAVE_CONFIG_H
+	#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+#include "../Object.h"
+#include "../../toolkits/toolkits.h"
+#include "../../EnumDefinitions/EnumDefinitions.h"
+
+#ifdef _HAVE_ADOLC_
+#include "adolc.h"
+#endif
+		
+
+#ifdef _SERIAL_
+#include "mex.h"
+#endif
+
+/*}}}*/
+
+class Vector{
+
+	public:
+	
+		int M;
+
+		#ifdef _HAVE_PETSC_
+		Vec vector; 
+		#else
+		double* vector; 
+		#endif
+		#ifdef _HAVE_ADOLC_
+		adouble* avector;
+		#endif
+
+		/*Vector constructors, destructors {{{1*/
+		Vector();
+		Vector(int M,bool fromlocalsize=false);
+		~Vector();
+		/*}}}*/
+		/*Vector specific routines {{{1*/
+		void Echo(void);
+		#ifdef _SERIAL_
+		mxArray* ToMatlabVector(void);
+		#endif
+		void Assemble(void);
+		void SetValues(int ssize, int* list, double* values, int mode);
+		void GetSize(int* pM);
+		void GetLocalSize(int* pM);
+		Vector* Duplicate(void);
+		void Set(double value);
+		void AXPY(Vector* X, double a);
+		void AYPX(Vector* X, double a);
+		double* ToMPISerial(void);
+		void Copy(Vector* to);
+		double Norm(int norm_type);
+		void Scale(double scale_factor);
+		/*}}}*/
+};
+#endif //#ifndef _VECTOR_H_
Index: /issm/branches/trunk-jpl-damage/src/c/objects/objects.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/objects.h	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/objects.h	(revision 11684)
@@ -120,4 +120,6 @@
 #include "./Numerics/ElementMatrix.h"
 #include "./Numerics/ElementVector.h"
+#include "./Numerics/Vector.h"
+#include "./Numerics/Matrix.h"
 
 /*Params: */
Index: /issm/branches/trunk-jpl-damage/src/c/shared/Alloc/alloc.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/shared/Alloc/alloc.cpp	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/c/shared/Alloc/alloc.cpp	(revision 11684)
@@ -29,4 +29,5 @@
 #include "../Exceptions/exceptions.h"
 #include "../../include/include.h"
+#include "../../objects/objects.h"
 
 void* xmalloc(int size){
@@ -80,4 +81,23 @@
 }
 
+void xdelete( Matrix** pv){
+
+	if (pv && *pv) {
+
+		delete *pv;
+		*pv=NULL;
+	}
+}
+
+void xdelete( Vector** pv){
+
+	if (pv && *pv) {
+
+		delete *pv;
+		*pv=NULL;
+	}
+}
+
+
 void* xrealloc ( void* pv, int size){
 	
Index: /issm/branches/trunk-jpl-damage/src/c/shared/Alloc/alloc.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/shared/Alloc/alloc.h	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/c/shared/Alloc/alloc.h	(revision 11684)
@@ -5,9 +5,12 @@
 #ifndef _ALLOC_H_
 #define _ALLOC_H_
-
+class Matrix;
+class Vector;
 void* xmalloc(int size);
 void* xcalloc(int n,int size);
 void  xfree(void** pvptr);
 void* xrealloc ( void* pv, int size);
+void xdelete(Matrix** pvptr);
+void xdelete(Vector** pvptr);
 
 #endif
Index: /issm/branches/trunk-jpl-damage/src/c/shared/Elements/elements.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/shared/Elements/elements.h	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/c/shared/Elements/elements.h	(revision 11684)
@@ -17,6 +17,6 @@
 int*   GetLocalDofList( Node** nodes,int numnodes,int setenum,int approximation_enum);
 int*   GetGlobalDofList(Node** nodes,int numnodes,int setenum,int approximation_enum);
+#ifdef _HAVE_DIAGNOSTIC_
 void   CoordinateSystemTransform(double** ptransform,Node** nodes,int numnodes,int* cs_array);
-#ifdef _HAVE_DIAGNOSTIC_
 void   TransformInvStiffnessMatrixCoord(ElementMatrix* Ke,Node** nodes,int numnodes,int cs_enum);
 void   TransformInvStiffnessMatrixCoord(ElementMatrix* Ke,Node** nodes,int numnodes,int* cs_array);
Index: /issm/branches/trunk-jpl-damage/src/c/solutions/AnalysisConfiguration.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/solutions/AnalysisConfiguration.cpp	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/c/solutions/AnalysisConfiguration.cpp	(revision 11684)
@@ -38,5 +38,5 @@
 
 		case SteadystateSolutionEnum:
-			numanalyses=7;
+			numanalyses=8;
 			analyses=(int*)xmalloc(numanalyses*sizeof(int));
 			analyses[0]=DiagnosticHorizAnalysisEnum;
@@ -45,6 +45,7 @@
 			analyses[3]=SurfaceSlopeAnalysisEnum;
 			analyses[4]=BedSlopeAnalysisEnum;
-			analyses[5]=ThermalAnalysisEnum;
-			analyses[6]=MeltingAnalysisEnum;
+			analyses[5]=EnthalpyAnalysisEnum;
+			analyses[6]=ThermalAnalysisEnum;
+			analyses[7]=MeltingAnalysisEnum;
 			break;
 
Index: /issm/branches/trunk-jpl-damage/src/c/solutions/ResetBoundaryConditions.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/solutions/ResetBoundaryConditions.cpp	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/c/solutions/ResetBoundaryConditions.cpp	(revision 11684)
@@ -11,5 +11,5 @@
 	
 	/*variables: */
-	Vec    yg    = NULL;
+	Vector*    yg    = NULL;
 	Nodes *nodes = NULL;
 	int    i;
@@ -30,4 +30,4 @@
 
 	/*Free ressources:*/
-	VecFree(&yg);
+	delete yg;
 }
Index: /issm/branches/trunk-jpl-damage/src/c/solutions/convergence.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/solutions/convergence.cpp	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/c/solutions/convergence.cpp	(revision 11684)
@@ -8,5 +8,5 @@
 #include "../EnumDefinitions/EnumDefinitions.h"
 
-void convergence(bool* pconverged, Mat Kff,Vec pf,Vec uf,Vec old_uf,Parameters* parameters){
+void convergence(bool* pconverged, Matrix* Kff,Vector* pf,Vector* uf,Vector* old_uf,Parameters* parameters){
 
 	/*output*/
@@ -14,9 +14,9 @@
 
 	/*intermediary*/
-	Vec KU=NULL;
-	Vec KUF=NULL;
-	Vec KUold=NULL;
-	Vec KUoldF=NULL;
-	Vec duf=NULL;
+	Vector* KU=NULL;
+	Vector* KUF=NULL;
+	Vector* KUold=NULL;
+	Vector* KUoldF=NULL;
+	Vector* duf=NULL;
 	double ndu,nduinf,nu;
 	double nKUF;
@@ -48,16 +48,16 @@
 
 		//compute KUF = KU - F = K*U - F
-		VecDuplicate(uf,&KU); MatMultPatch(Kff,uf,KU);
-		VecDuplicate(KU,&KUF);VecCopy(KU,KUF); VecAYPX(KUF,-1.0,pf);
+		KU=uf->Duplicate(); Kff->MatMult(uf,KU);
+		KUF=KU->Duplicate(); KU->Copy(KUF); KUF->AYPX(pf,-1.0);
 
 		//compute norm(KUF), norm(F) and residue
-		VecNorm(KUF,NORM_2,&nKUF);
-		VecNorm(pf,NORM_2,&nF);
+		nKUF=KUF->Norm(NORM_2);
+		nF=pf->Norm(NORM_2);
 		solver_residue=nKUF/nF;
 		_printf_(true,"\n%s%g\n","   solver residue: norm(KU-F)/norm(F)=",solver_residue);
 
 		//clean up
-		VecFree(&KU);
-		VecFree(&KUF);
+		delete KU;
+		delete KUF;
 	}
 
@@ -65,8 +65,8 @@
 
 	//compute K[n]U[n-1]F = K[n]U[n-1] - F
-	VecDuplicate(uf,&KUold); MatMultPatch(Kff,old_uf,KUold);
-	VecDuplicate(KUold,&KUoldF);VecCopy(KUold,KUoldF); VecAYPX(KUoldF,-1.0,pf);
-	VecNorm(KUoldF,NORM_2,&nKUoldF);
-	VecNorm(pf,NORM_2,&nF);
+	KUold=uf->Duplicate(); Kff->MatMult(old_uf,KUold);
+	KUoldF=KUold->Duplicate();KUold->Copy(KUoldF); KUoldF->AYPX(pf,-1.0);
+	nKUoldF=KUoldF->Norm(NORM_2);
+	nF=pf->Norm(NORM_2);
 	res=nKUoldF/nF;
 	if (isnan(res)){
@@ -76,6 +76,6 @@
 
 	//clean up
-	VecFree(&KUold);
-	VecFree(&KUoldF);
+	delete KUold;
+	delete KUoldF;
 
 	//print
@@ -93,11 +93,11 @@
 
 		//compute norm(du)/norm(u)
-		VecDuplicate(old_uf,&duf);VecCopy(old_uf,duf); VecAYPX(duf,-1.0,uf);
-		VecNorm(duf,NORM_2,&ndu); VecNorm(old_uf,NORM_2,&nu);
+		duf=old_uf->Duplicate(); old_uf->Copy(duf); duf->AYPX(uf,-1.0);
+		ndu=duf->Norm(NORM_2); nu=old_uf->Norm(NORM_2);
 
 		if (isnan(ndu) || isnan(nu)) _error_("convergence criterion is NaN!");
 
 		//clean up
-		VecFree(&duf);
+		delete duf;
 
 		//print
@@ -119,10 +119,10 @@
 
 		//compute max(du)
-		VecDuplicate(old_uf,&duf);VecCopy(old_uf,duf); VecAYPX(duf,-1.0,uf);
-		VecNorm(duf,NORM_2,&ndu); VecNorm(duf,NORM_INFINITY,&nduinf);
+		duf=old_uf->Duplicate(); old_uf->Copy(duf); duf->AYPX(uf,-1.0);
+		ndu=duf->Norm(NORM_2); nduinf=duf->Norm(NORM_INFINITY);
 		if (isnan(ndu) || isnan(nu)) _error_("convergence criterion is NaN!");
 
 		//clean up
-		VecFree(&duf);
+		delete duf;
 
 		//print
Index: /issm/branches/trunk-jpl-damage/src/c/solutions/solutions.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/solutions/solutions.h	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/c/solutions/solutions.h	(revision 11684)
@@ -35,5 +35,5 @@
 
 //convergence:
-void convergence(bool* pconverged, Mat K_ff,Vec p_f,Vec u_f,Vec u_f_old,Parameters* parameters);
+void convergence(bool* pconverged, Matrix* K_ff,Vector* p_f,Vector* u_f,Vector* u_f_old,Parameters* parameters);
 bool controlconvergence(double J,double tol_cm);
 bool steadystateconvergence(FemModel* femmodel);
Index: /issm/branches/trunk-jpl-damage/src/c/solutions/steadystate_core.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/solutions/steadystate_core.cpp	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/c/solutions/steadystate_core.cpp	(revision 11684)
@@ -25,8 +25,8 @@
 
 	/*parameters: */
-	int dim;
-	int solution_type;
-	int maxiter;
-	bool control_analysis;
+	bool control_analysis,isenthalpy;
+	int  dim;
+	int  solution_type;
+	int  maxiter;
 	int  numoutputs         = 0;
 	int  *requested_outputs = NULL;
@@ -38,4 +38,5 @@
 	femmodel->parameters->FindParam(&maxiter,SteadystateMaxiterEnum);
 	femmodel->parameters->FindParam(&numoutputs,SteadystateNumRequestedOutputsEnum);
+	femmodel->parameters->FindParam(&isenthalpy,ThermalIsenthalpyEnum);
 	if(numoutputs) femmodel->parameters->FindParam(&requested_outputs,&numoutputs,SteadystateRequestedOutputsEnum);
 
@@ -47,5 +48,10 @@
 		_printf_(VerboseSolution(),"%s%i\n","   computing temperature and velocity for step: ",step);
 		#ifdef _HAVE_THERMAL_
-		thermal_core(femmodel);
+		if(isenthalpy==0){
+			thermal_core(femmodel);
+		}
+		else{
+			enthalpy_core(femmodel);
+		}
 		#else
 		_error_("ISSM was not compiled with thermal capabilities. Exiting");
@@ -83,5 +89,7 @@
 		InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,PressureEnum);
 		InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,TemperatureEnum);
-		InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,BasalforcingsMeltingRateEnum);
+		if(isenthalpy) InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,WaterfractionEnum);
+		if(isenthalpy) InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,EnthalpyEnum);
+		if(!isenthalpy) InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,BasalforcingsMeltingRateEnum);
 		RequestedOutputsx(femmodel->results,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,requested_outputs,numoutputs);
 	}
Index: /issm/branches/trunk-jpl-damage/src/c/solvers/solver_adjoint_linear.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/solvers/solver_adjoint_linear.cpp	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/c/solvers/solver_adjoint_linear.cpp	(revision 11684)
@@ -13,9 +13,11 @@
 
 	/*intermediary: */
-	Mat  Kff = NULL, Kfs = NULL;
-	Vec  ug  = NULL, uf  = NULL;
-	Vec  pf  = NULL;
-	Vec  df  = NULL;
-	Vec  ys  = NULL;
+	Matrix*  Kff = NULL;
+	Matrix*  Kfs = NULL;
+	Vector*  ug  = NULL;
+	Vector*  uf  = NULL;
+	Vector*  pf  = NULL;
+	Vector*  df  = NULL;
+	Vector*  ys  = NULL;
 	int  configuration_type;
 
@@ -26,8 +28,8 @@
 	SystemMatricesx(&Kff, &Kfs, &pf, &df, NULL,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters);
 	CreateNodalConstraintsx(&ys,femmodel->nodes,configuration_type);
-	Reduceloadx(pf, Kfs, ys,true); MatFree(&Kfs); //true means spc = 0
-	Solverx(&uf, Kff, pf, NULL, df, femmodel->parameters); MatFree(&Kff); VecFree(&pf); VecFree(&df);
-	Mergesolutionfromftogx(&ug, uf,ys,femmodel->nodes,femmodel->parameters,true); VecFree(&uf);VecFree(&ys); //true means spc0
+	Reduceloadx(pf, Kfs, ys,true); xdelete(&Kfs); //true means spc = 0
+	Solverx(&uf, Kff, pf, NULL, df, femmodel->parameters); xdelete(&Kff); xdelete(&pf); xdelete(&df);
+	Mergesolutionfromftogx(&ug, uf,ys,femmodel->nodes,femmodel->parameters,true); xdelete(&uf);xdelete(&ys); //true means spc0
 	InputUpdateFromSolutionx(femmodel->elements,femmodel->nodes, femmodel->vertices, femmodel->loads, femmodel->materials, femmodel->parameters,ug);
-	VecFree(&ug); VecFree(&uf); 
+	xdelete(&ug); xdelete(&uf);
 }
Index: /issm/branches/trunk-jpl-damage/src/c/solvers/solver_linear.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/solvers/solver_linear.cpp	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/c/solvers/solver_linear.cpp	(revision 11684)
@@ -11,10 +11,11 @@
 
 	/*intermediary: */
-	Mat  Kff = NULL, Kfs   = NULL;
-	Vec  ug  = NULL;
-	Vec  uf  = NULL;
-	Vec  pf  = NULL;
-	Vec  df  = NULL;
-	Vec  ys  = NULL;
+	Matrix*  Kff = NULL;
+	Matrix*  Kfs = NULL;
+	Vector*  ug  = NULL;
+	Vector*  uf  = NULL;
+	Vector*  pf  = NULL;
+	Vector*  df  = NULL;
+	Vector*  ys  = NULL;
 	int  configuration_type;
 
@@ -25,8 +26,9 @@
 	SystemMatricesx(&Kff, &Kfs, &pf, &df, NULL,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters);
 	CreateNodalConstraintsx(&ys,femmodel->nodes,configuration_type);
-	Reduceloadx(pf, Kfs, ys); MatFree(&Kfs);
-	Solverx(&uf, Kff, pf, NULL, df, femmodel->parameters); MatFree(&Kff); VecFree(&pf); VecFree(&df);
-	Mergesolutionfromftogx(&ug, uf,ys,femmodel->nodes,femmodel->parameters);VecFree(&uf);VecFree(&ys);
+	Reduceloadx(pf, Kfs, ys); xdelete(&Kfs);
+	Solverx(&uf, Kff, pf, NULL, df, femmodel->parameters); 
+	xdelete(&Kff); xdelete(&pf); xdelete(&df);
+	Mergesolutionfromftogx(&ug, uf,ys,femmodel->nodes,femmodel->parameters);xdelete(&uf); xdelete(&ys);
 	InputUpdateFromSolutionx( femmodel->elements,femmodel->nodes, femmodel->vertices, femmodel->loads, femmodel->materials, femmodel->parameters,ug); 
-	VecFree(&ug); VecFree(&uf);
+	xdelete(&ug);  xdelete(&uf);
 }
Index: /issm/branches/trunk-jpl-damage/src/c/solvers/solver_newton.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/solvers/solver_newton.cpp	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/c/solvers/solver_newton.cpp	(revision 11684)
@@ -18,10 +18,16 @@
 	int    count;
 	double kmax;
-	Mat Kff = NULL, Kfs    = NULL, Jff = NULL;
-	Vec ug  = NULL, old_ug = NULL;
-	Vec uf  = NULL, old_uf = NULL, duf = NULL;
-	Vec pf  = NULL, pJf    = NULL;
-	Vec df  = NULL;
-	Vec ys  = NULL;
+	Matrix* Kff = NULL;
+	Matrix* Kfs    = NULL;
+	Matrix* Jff = NULL;
+	Vector* ug  = NULL;
+	Vector* old_ug = NULL;
+	Vector* uf  = NULL;
+	Vector* old_uf = NULL;
+	Vector* duf = NULL;
+	Vector* pf  = NULL;
+	Vector* pJf    = NULL;
+	Vector* df  = NULL;
+	Vector* ys  = NULL;
 
 	/*parameters:*/
@@ -47,18 +53,18 @@
 	for(;;){
 
-		VecFree(&old_ug);old_ug=ug;
-		VecFree(&old_uf);old_uf=uf;
+		xdelete(&old_ug);old_ug=ug;
+		xdelete(&old_uf);old_uf=uf;
 
 		/*Solver forward model*/
 		SystemMatricesx(&Kff,&Kfs,&pf,&df,NULL,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters);
 		CreateNodalConstraintsx(&ys,femmodel->nodes,configuration_type);
-		Reduceloadx(pf,Kfs,ys);MatFree(&Kfs);
-		Solverx(&uf,Kff,pf,old_uf,df,femmodel->parameters);VecFree(&df);
-		Mergesolutionfromftogx(&ug,uf,ys,femmodel->nodes,femmodel->parameters);VecFree(&ys);
-		InputUpdateFromSolutionx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,ug);VecFree(&ug);
+		Reduceloadx(pf,Kfs,ys);xdelete(&Kfs);
+		Solverx(&uf,Kff,pf,old_uf,df,femmodel->parameters);xdelete(&df);
+		Mergesolutionfromftogx(&ug,uf,ys,femmodel->nodes,femmodel->parameters);xdelete(&ys);
+		InputUpdateFromSolutionx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,ug);xdelete(&ug);
 
 		/*Check convergence*/
 		convergence(&converged,Kff,pf,uf,old_uf,femmodel->parameters); 
-		MatFree(&Kff);VecFree(&pf);
+		xdelete(&Kff); xdelete(&pf);
 		if(converged==true) break;
 		if(count>=max_nonlinear_iterations){
@@ -70,15 +76,13 @@
 		SystemMatricesx(&Kff,&Kfs,&pf,NULL,&kmax,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters);
 		CreateNodalConstraintsx(&ys,femmodel->nodes,configuration_type);
-		Reduceloadx(pf,Kfs,ys);   MatFree(&Kfs);
+		Reduceloadx(pf,Kfs,ys);   xdelete(&Kfs);
 
-		VecDuplicate(pf,&pJf);
-		MatMultPatch(Kff,uf,pJf); MatFree(&Kff);
-		VecScale(pJf,-1.);
-		VecAXPY(pJf,+1.,pf);      VecFree(&pf);
+		pJf=pf->Duplicate(); Kff->MatMult(uf,pJf); xdelete(&Kff);
+		pJf->Scale(-1.0); pJf->AXPY(pf,+1.0);     xdelete(&pf);
 
 		CreateJacobianMatrixx(&Jff,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,kmax);
-		Solverx(&duf,Jff,pJf,NULL,NULL,femmodel->parameters); MatFree(&Jff);VecFree(&pJf);
-		VecAXPY(uf,1.,duf);      VecFree(&duf);
-		Mergesolutionfromftogx(&ug,uf,ys,femmodel->nodes,femmodel->parameters);VecFree(&ys);
+		Solverx(&duf,Jff,pJf,NULL,NULL,femmodel->parameters); xdelete(&Jff); xdelete(&pJf);
+		uf->AXPY(duf, 1.0); xdelete(&duf);
+		Mergesolutionfromftogx(&ug,uf,ys,femmodel->nodes,femmodel->parameters);xdelete(&ys);
 		InputUpdateFromSolutionx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,ug);
 
@@ -89,7 +93,7 @@
 
 	/*clean-up*/
-	VecFree(&uf);
-	VecFree(&ug);
-	VecFree(&old_ug);
-	VecFree(&old_uf);
+	xdelete(&uf);
+	xdelete(&ug);
+	xdelete(&old_ug);
+	xdelete(&old_uf);
 }
Index: /issm/branches/trunk-jpl-damage/src/c/solvers/solver_nonlinear.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/solvers/solver_nonlinear.cpp	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/c/solvers/solver_nonlinear.cpp	(revision 11684)
@@ -14,10 +14,13 @@
 
 	/*intermediary: */
-	Mat Kff = NULL, Kfs   = NULL;
-	Vec ug  = NULL, old_ug = NULL;
-	Vec uf  = NULL, old_uf = NULL;
-	Vec pf  = NULL;
-	Vec df  = NULL;
-	Vec ys  = NULL;
+	Matrix* Kff = NULL;
+	Matrix* Kfs = NULL;
+	Vector* ug  = NULL;
+	Vector* old_ug = NULL;
+	Vector* uf  = NULL;
+	Vector* old_uf = NULL;
+	Vector* pf  = NULL;
+	Vector* df  = NULL;
+	Vector* ys  = NULL;
 	
 	Loads* loads=NULL;
@@ -56,14 +59,14 @@
 
 		//save pointer to old velocity
-		VecFree(&old_ug);old_ug=ug;
-		VecFree(&old_uf);old_uf=uf;
+		xdelete(&old_ug);old_ug=ug;
+		xdelete(&old_uf);old_uf=uf;
 
 		SystemMatricesx(&Kff, &Kfs, &pf, &df, NULL,femmodel->elements,femmodel->nodes,femmodel->vertices,loads,femmodel->materials,femmodel->parameters);
 		CreateNodalConstraintsx(&ys,femmodel->nodes,configuration_type);
-		Reduceloadx(pf, Kfs, ys); MatFree(&Kfs);
+		Reduceloadx(pf, Kfs, ys); xdelete(&Kfs);
 		Solverx(&uf, Kff, pf, old_uf, df, femmodel->parameters);
-		Mergesolutionfromftogx(&ug, uf,ys,femmodel->nodes,femmodel->parameters);VecFree(&ys);
+		Mergesolutionfromftogx(&ug, uf,ys,femmodel->nodes,femmodel->parameters);xdelete(&ys);
 
-		convergence(&converged,Kff,pf,uf,old_uf,femmodel->parameters); MatFree(&Kff);VecFree(&pf); VecFree(&df);
+		convergence(&converged,Kff,pf,uf,old_uf,femmodel->parameters); xdelete(&Kff); xdelete(&pf); xdelete(&df);
 		InputUpdateFromConstantx( femmodel->elements,femmodel->nodes, femmodel->vertices, femmodel->loads, femmodel->materials, femmodel->parameters,converged,ConvergedEnum);
 		InputUpdateFromSolutionx( femmodel->elements,femmodel->nodes, femmodel->vertices, femmodel->loads, femmodel->materials, femmodel->parameters,ug);
@@ -96,7 +99,7 @@
 	/*clean-up*/
 	if(conserve_loads) delete loads;
-	VecFree(&uf);
-	VecFree(&ug);
-	VecFree(&old_ug);
-	VecFree(&old_uf);
+	xdelete(&uf);
+	xdelete(&ug);
+	xdelete(&old_ug);
+	xdelete(&old_uf);
 }
Index: /issm/branches/trunk-jpl-damage/src/c/solvers/solver_stokescoupling_nonlinear.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/solvers/solver_stokescoupling_nonlinear.cpp	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/c/solvers/solver_stokescoupling_nonlinear.cpp	(revision 11684)
@@ -14,13 +14,18 @@
 
 	/*intermediary: */
-	Mat  Kff_horiz = NULL, Kfs_horiz   = NULL;
-	Vec  ug_horiz  = NULL, uf_horiz  = NULL, old_uf_horiz = NULL;
-	Vec  pf_horiz  = NULL;
-	Vec  df_horiz  = NULL;
-	Mat  Kff_vert  = NULL, Kfs_vert    = NULL;
-	Vec  ug_vert   = NULL, uf_vert   = NULL;
-	Vec  pf_vert   = NULL;
-	Vec  df_vert   = NULL;
-	Vec  ys   = NULL;
+	Matrix*  Kff_horiz = NULL;
+	Matrix* Kfs_horiz   = NULL;
+	Vector*  ug_horiz  = NULL;
+	Vector*  uf_horiz  = NULL;
+	Vector*  old_uf_horiz = NULL;
+	Vector*  pf_horiz  = NULL;
+	Vector*  df_horiz  = NULL;
+	Matrix*  Kff_vert  = NULL;
+	Matrix*  Kfs_vert  = NULL;
+	Vector*  ug_vert   = NULL;
+	Vector*  uf_vert   = NULL;
+	Vector*  pf_vert   = NULL;
+	Vector*  df_vert   = NULL;
+	Vector*  ys   = NULL;
 	bool converged;
 	int  constraints_converged;
@@ -54,18 +59,18 @@
 		//Update once again the solution to make sure that vx and vxold are similar (for next step in transient or steadystate)
 		InputUpdateFromSolutionx(femmodel->elements,femmodel->nodes, femmodel->vertices, femmodel->loads, femmodel->materials, femmodel->parameters,ug_horiz);
-		VecFree(&ug_horiz);
+		xdelete(&ug_horiz);
 
 		//save pointer to old velocity
-		VecFree(&old_uf_horiz);old_uf_horiz=uf_horiz;
+		xdelete(&old_uf_horiz); old_uf_horiz=uf_horiz;
 
 		/*solve: */
 		SystemMatricesx(&Kff_horiz, &Kfs_horiz, &pf_horiz, &df_horiz, NULL,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters);
 		CreateNodalConstraintsx(&ys,femmodel->nodes,configuration_type);
-		Reduceloadx(pf_horiz, Kfs_horiz, ys); MatFree(&Kfs_horiz);
+		Reduceloadx(pf_horiz, Kfs_horiz, ys); xdelete(&Kfs_horiz);
 		Solverx(&uf_horiz, Kff_horiz, pf_horiz, old_uf_horiz, df_horiz,femmodel->parameters);
-		Mergesolutionfromftogx(&ug_horiz, uf_horiz,ys,femmodel->nodes,femmodel->parameters); VecFree(&ys);
+		Mergesolutionfromftogx(&ug_horiz, uf_horiz,ys,femmodel->nodes,femmodel->parameters); xdelete(&ys);
 		InputUpdateFromSolutionx( femmodel->elements,femmodel->nodes, femmodel->vertices, femmodel->loads, femmodel->materials, femmodel->parameters,ug_horiz);
 
-		convergence(&converged,Kff_horiz,pf_horiz,uf_horiz,old_uf_horiz,femmodel->parameters); MatFree(&Kff_horiz);VecFree(&pf_horiz); VecFree(&df_horiz);
+		convergence(&converged,Kff_horiz,pf_horiz,uf_horiz,old_uf_horiz,femmodel->parameters); xdelete(&Kff_horiz); xdelete(&pf_horiz); xdelete(&df_horiz);
 
 		/*Second compute vertical velocity: */
@@ -76,9 +81,9 @@
 		SystemMatricesx(&Kff_vert, &Kfs_vert, &pf_vert,  &df_vert,NULL,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters);
 		CreateNodalConstraintsx(&ys,femmodel->nodes,configuration_type);
-		Reduceloadx(pf_vert, Kfs_vert, ys); MatFree(&Kfs_vert);
-		Solverx(&uf_vert, Kff_vert, pf_vert, NULL, df_vert,femmodel->parameters); MatFree(&Kff_vert); VecFree(&pf_vert); VecFree(&df_vert);
-		Mergesolutionfromftogx(&ug_vert, uf_vert,ys,femmodel->nodes,femmodel->parameters);VecFree(&uf_vert); VecFree(&ys);
+		Reduceloadx(pf_vert, Kfs_vert, ys); xdelete(&Kfs_vert);
+		Solverx(&uf_vert, Kff_vert, pf_vert, NULL, df_vert,femmodel->parameters); xdelete(&Kff_vert); xdelete(&pf_vert); xdelete(&df_vert);
+		Mergesolutionfromftogx(&ug_vert, uf_vert,ys,femmodel->nodes,femmodel->parameters);xdelete(&uf_vert); xdelete(&ys); 
 		InputUpdateFromSolutionx( femmodel->elements,femmodel->nodes, femmodel->vertices, femmodel->loads, femmodel->materials, femmodel->parameters,ug_vert);
-		VecFree(&ug_vert); VecFree(&uf_vert);
+		xdelete(&ug_vert); xdelete(&uf_vert);
 
 		/*Increase count: */
@@ -92,7 +97,7 @@
 
 	/*clean-up*/
-	VecFree(&old_uf_horiz);
-	VecFree(&uf_horiz);
-	VecFree(&ug_horiz);
-	VecFree(&ys);
+	xdelete(&old_uf_horiz);
+	xdelete(&uf_horiz);
+	xdelete(&ug_horiz);
+	xdelete(&ys);
 }
Index: /issm/branches/trunk-jpl-damage/src/c/solvers/solver_thermal_nonlinear.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/solvers/solver_thermal_nonlinear.cpp	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/c/solvers/solver_thermal_nonlinear.cpp	(revision 11684)
@@ -12,15 +12,15 @@
 
 	/*solution : */
-	Vec tg=NULL; 
-	Vec tf=NULL; 
-	Vec tf_old=NULL; 
-	Vec ys=NULL; 
+	Vector* tg=NULL; 
+	Vector* tf=NULL; 
+	Vector* tf_old=NULL; 
+	Vector* ys=NULL; 
 	double melting_offset;
 
 	/*intermediary: */
-	Mat Kff=NULL;
-	Mat Kfs=NULL;
-	Vec pf=NULL;
-	Vec df=NULL;
+	Matrix* Kff=NULL;
+	Matrix* Kfs=NULL;
+	Vector* pf=NULL;
+	Vector* df=NULL;
 
 	bool converged;
@@ -56,9 +56,9 @@
 		SystemMatricesx(&Kff, &Kfs, &pf,&df, &melting_offset,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters);
 		CreateNodalConstraintsx(&ys,femmodel->nodes,configuration_type);
-		Reduceloadx(pf, Kfs, ys); MatFree(&Kfs); VecFree(&tf);
+		Reduceloadx(pf, Kfs, ys); xdelete(&Kfs); xdelete(&tf);
 		Solverx(&tf, Kff, pf,tf_old, df, femmodel->parameters);
-		VecFree(&tf_old); VecDuplicatePatch(&tf_old,tf);
-		MatFree(&Kff);VecFree(&pf);VecFree(&tg); VecFree(&df);
-		Mergesolutionfromftogx(&tg, tf,ys,femmodel->nodes,femmodel->parameters); VecFree(&ys);
+		xdelete(&tf_old); tf_old=tf->Duplicate();
+		xdelete(&Kff);xdelete(&pf);xdelete(&tg); xdelete(&df);
+		Mergesolutionfromftogx(&tg, tf,ys,femmodel->nodes,femmodel->parameters); xdelete(&ys);
 		InputUpdateFromSolutionx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,tg);
 
@@ -84,7 +84,7 @@
 
 	/*Free ressources: */
-	VecFree(&tg);
-	VecFree(&tf);
-	VecFree(&tf_old);
-	VecFree(&ys);
+	xdelete(&tg);
+	xdelete(&tf);
+	xdelete(&tf_old);
+	xdelete(&ys);
 }
Index: /issm/branches/trunk-jpl-damage/src/c/toolkits/matlab/MatlabMatrixToMatrix.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/toolkits/matlab/MatlabMatrixToMatrix.cpp	(revision 11684)
+++ /issm/branches/trunk-jpl-damage/src/c/toolkits/matlab/MatlabMatrixToMatrix.cpp	(revision 11684)
@@ -0,0 +1,36 @@
+/* \file MatlabMatrixToMatrix.cpp
+ * \brief: convert a sparse or dense matlab matrix to a matrix:
+ */
+
+
+#ifdef HAVE_CONFIG_H
+	#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+
+#ifdef _SERIAL_
+
+/*Matlab includes: */
+#include "mex.h"
+#include "../../objects/objects.h"
+
+Matrix* MatlabMatrixToMatrix(const mxArray* mxmatrix){
+
+	Matrix* matrix=NULL;
+
+	#ifdef _HAVE_PETSC_
+	/*allocate matrix object: */
+	matrix=new Matrix();
+	
+	/*Call Matlab to Petsc API: */
+	MatlabMatrixToPetscMatrix(&matrix->matrix,&matrix->M,&matrix->N,mxmatrix);
+
+	#else
+		_error_("not supported yet!");
+	#endif
+
+	return matrix;
+}
+#endif
Index: /issm/branches/trunk-jpl-damage/src/c/toolkits/matlab/MatlabVectorToVector.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/toolkits/matlab/MatlabVectorToVector.cpp	(revision 11684)
+++ /issm/branches/trunk-jpl-damage/src/c/toolkits/matlab/MatlabVectorToVector.cpp	(revision 11684)
@@ -0,0 +1,36 @@
+/* \file MatlabVectorToVector.cpp
+ * \brief: convert a sparse or dense matlab vector to a vector:
+ */
+
+
+#ifdef HAVE_CONFIG_H
+	#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+
+#ifdef _SERIAL_
+
+/*Matlab includes: */
+#include "mex.h"
+#include "../../objects/objects.h"
+
+Vector* MatlabVectorToVector(const mxArray* mxvector){
+
+	Vector* vector=NULL;
+
+	#ifdef _HAVE_PETSC_
+	/*allocate vector object: */
+	vector=new Vector();
+	
+	/*Call Matlab to Petsc API: */
+	MatlabVectorToPetscVector(&vector->vector,&vector->M,mxvector);
+
+	#else
+		_error_("not supported yet!");
+	#endif
+
+	return vector;
+}
+#endif
Index: /issm/branches/trunk-jpl-damage/src/c/toolkits/matlab/matlabincludes.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/toolkits/matlab/matlabincludes.h	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/c/toolkits/matlab/matlabincludes.h	(revision 11684)
@@ -8,7 +8,12 @@
 #ifdef _SERIAL_
 #include <mex.h>
+class Matrix;
+class Vector;
+
 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);
+Matrix* MatlabMatrixToMatrix(const mxArray* mxmatrix);
+Vector* MatlabVectorToVector(const mxArray* mxvector);
 #endif
 
Index: /issm/branches/trunk-jpl-damage/src/c/toolkits/petsc/patches/MatlabMatrixToDoubleMatrix.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/toolkits/petsc/patches/MatlabMatrixToDoubleMatrix.cpp	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/c/toolkits/petsc/patches/MatlabMatrixToDoubleMatrix.cpp	(revision 11684)
@@ -25,8 +25,7 @@
 int MatlabMatrixToDoubleMatrix(double** pmatrix,int* pmatrix_rows,int* pmatrix_cols,const mxArray* mxmatrix){
 
-	int rows, cols;
-	double* mxmatrix_ptr=NULL;
-	int ierr;
-	int i,j;
+	int     i,j,count,rows,cols;
+	double *pmxdoublematrix = NULL;
+	float  *pmxsinglematrix = NULL;
 
 	/*output: */
@@ -36,8 +35,4 @@
 	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 matrix: */
@@ -45,14 +40,10 @@
 
 		/*Dealing with sparse matrix: recover size first: */
-		mxmatrix_ptr=(double*)mxGetPr(mxmatrix);
+		pmxdoublematrix=(double*)mxGetPr(mxmatrix);
 		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: */
-		pr=mxGetPr(mxmatrix);
 		ir=mxGetIr(mxmatrix);
 		jc=mxGetJc(mxmatrix);
@@ -62,5 +53,5 @@
 		for(i=0;i<cols;i++){
 			for(j=0;j<(jc[i+1]-jc[i]);j++){
-				*(matrix+rows*ir[count]+i)=pr[count];
+				matrix[rows*ir[count]+i]=pmxdoublematrix[count];
 				count++;
 			}
@@ -68,12 +59,9 @@
 
 	}
-	else{
-
-
+	else if(mxIsClass(mxmatrix,"double")){
 		/*Dealing with dense matrix: recover pointer and size: */
-		mxmatrix_ptr=(double*)mxGetPr(mxmatrix);
+		pmxdoublematrix=(double*)mxGetPr(mxmatrix);
 		rows=mxGetM(mxmatrix);
 		cols=mxGetN(mxmatrix);
-
 		
 		/*Create serial matrix: */
@@ -82,8 +70,25 @@
 		for(i=0;i<rows;i++){
 			for(j=0;j<cols;j++){
-				*(matrix+cols*i+j)=*(mxmatrix_ptr+rows*j+i);
+				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: */
+		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");
 	}
 
Index: /issm/branches/trunk-jpl-damage/src/m/classes/friction.m
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/classes/friction.m	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/m/classes/friction.m	(revision 11684)
@@ -39,5 +39,5 @@
 		end % }}}
 		function disp(obj) % {{{
-			disp(sprintf('Sigma= drag^2 * Neff ^r * u ^s, with Neff=rho_ice*g*thickness+rho_ice*g*bed, r=q/p and s=1/p'));
+			disp(sprintf('Sigma= drag^2 * Neff ^r * u ^s, with Neff=rho_ice*g*thickness+rho_water*g*bed, r=q/p and s=1/p'));
 			fielddisplay(obj,'coefficient','friction coefficient [SI]');
 			fielddisplay(obj,'p','p exponent');
Index: /issm/branches/trunk-jpl-damage/src/m/classes/inversion.m
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/classes/inversion.m	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/m/classes/inversion.m	(revision 11684)
@@ -92,4 +92,7 @@
 			checkfield(md,'inversion.iscontrol','values',[0 1]);
 			checkfield(md,'inversion.control_parameters','cell',1,'values',{'BalancethicknessThickeningRate' 'FrictionCoefficient' 'MaterialsRheologyBbar' 'MaterialsRheologyZbar' 'Vx' 'Vy'});
+			checkfield(md,'inversion.tao','values',[0 1]);
+			checkfield(md,'inversion.incomplete_adjoint','values',[0 1]);
+			checkfield(md,'inversion.control_parameters','cell',1,'values',{'BalancethicknessThickeningRate' 'FrictionCoefficient' 'MaterialsRheologyBbar' 'Vx' 'Vy'});
 			checkfield(md,'inversion.nsteps','numel',1,'>=',1);
 			checkfield(md,'inversion.maxiter_per_step','size',[md.inversion.nsteps 1],'>=',0);
Index: /issm/branches/trunk-jpl-damage/src/m/classes/model/model.m
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/classes/model/model.m	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/m/classes/model/model.m	(revision 11684)
@@ -158,7 +158,9 @@
 			 if isfield(structmd,'drag_p'), md.friction.p=structmd.drag_p; end
 			 if isfield(structmd,'drag_q'), md.friction.q=structmd.drag_q; end
-			 if isfield(structmd,'riftproperties'),
-				 md.rifts=rifts;
+			 if isfield(structmd,'riftproperties'), %old implementation
+				 md.rifts=rifts();
 				 md.rifts.riftproperties=structmd.riftproperties; 
+				 md.rifts.riftstruct=structmd.rifts;
+				 md.rifts.riftproperties=structmd.riftinfo;
 			 end
 			 if isfield(structmd,'bamg'), md.private.bamg=structmd.bamg; end
@@ -273,6 +275,7 @@
 			 if isfield(structmd,'z'), md.mesh.z=structmd.z; end
 			 if isfield(structmd,'mask'), md.flaim.criterion=structmd.mask; end
-          if isfield(structmd,'pressureload'), md.diagnostic.icefront=structmd.pressureload; end
+			 if isfield(structmd,'pressureload'), md.diagnostic.icefront=structmd.pressureload; end
 			 if isfield(structmd,'diagnostic_ref'), md.diagnostic.referential=structmd.diagnostic_ref; end
+
 
 			 %Field changes
@@ -359,4 +362,5 @@
 				 pos=find(structmd.cm_responses==382); md.inversion.cost_functions(pos)=503;
 			 end
+
 			 if isfield(structmd,'artificial_diffusivity') & structmd.artificial_diffusivity==2,
 					 md.thermal.stabilization=2;
Index: /issm/branches/trunk-jpl-damage/src/m/enum/EnumToModelField.m
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/enum/EnumToModelField.m	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/m/enum/EnumToModelField.m	(revision 11684)
@@ -1,28 +1,0 @@
-function string=EnumToModelField(enum)
-%ENUMTOMODELFIELD - output string of model field associated to enum
-%
-%   WARNING: DO NOT MODIFY THIS FILE
-%            this file has been automatically generated by src/c/EnumDefinitions/Synchronize.sh
-%            Please read src/c/EnumDefinitions/README for more information
-%
-%   Usage:
-%      string=EnumToModelField(enum)
-
-switch enum,
-
-		case ThicknessEnum(), string='thickness'; return
-		case FrictionCoefficientEnum(), string='drag_coefficient'; return
-		case MaterialsRheologyBEnum(), string='rheology_B'; return
-		case MaterialsRheologyBbarEnum(), string='rheology_B'; return
-		case MaterialsRheologyZEnum(), string='rheology_Z'; return
-		case MaterialsRheologyZbarEnum(), string='rheology_Z'; return
-		case BalancethicknessThickeningRateEnum: string='dhdt'; return
-		case VxEnum(), string='vx'; return
-		case InversionVxObsEnum(), string='vx_obs'; return
-		case VyEnum(), string='vy'; return
-		case InversionVyObsEnum(), string='vy_obs'; return
-		case BasalforcingsMeltingRateEnum(), string='basal_melting_rate'; return
-		case SurfaceforcingsMassBalanceEnum(), string='surface_mass_balance'; return
-		otherwise, error(['Enum ' num2str(enum)  ' not found associated to any model field']);
-
-end
Index: /issm/branches/trunk-jpl-damage/src/m/model/EnumToModelField.m
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/model/EnumToModelField.m	(revision 11684)
+++ /issm/branches/trunk-jpl-damage/src/m/model/EnumToModelField.m	(revision 11684)
@@ -0,0 +1,26 @@
+function string=EnumToModelField(enum)
+%ENUMTOMODELFIELD - output string of model field associated to enum
+%
+%   Usage:
+%      string=EnumToModelField(enum)
+
+disp('Warning: EnumToModelField is deprecated, it cannot work with new model definition. This function will be removed in the future');
+
+switch enum,
+
+		case ThicknessEnum(), string='thickness'; return
+		case FrictionCoefficientEnum(), string='drag_coefficient'; return
+		case MaterialsRheologyBEnum(), string='rheology_B'; return
+		case MaterialsRheologyBbarEnum(), string='rheology_B'; return
+		case BalancethicknessThickeningRateEnum: string='dhdt'; return
+		case VxEnum(), string='vx'; return
+		case InversionVxObsEnum(), string='vx_obs'; return
+		case VyEnum(), string='vy'; return
+		case InversionVyObsEnum(), string='vy_obs'; return
+		case BasalforcingsMeltingRateEnum(), string='basal_melting_rate'; return
+      case SurfaceforcingsAccumulationRateEnum(), string='surface_accumulation_rate'; return
+		case SurfaceforcingsAblationRateEnum(), string='surface_ablation_rate'; return
+		case SurfaceforcingsMassBalanceEnum(), string='surface_mass_balance'; return
+		otherwise, error(['Enum ' num2str(enum)  ' not found associated to any model field']);
+
+end
Index: /issm/branches/trunk-jpl-damage/src/m/model/SectionValues.m
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/model/SectionValues.m	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/m/model/SectionValues.m	(revision 11684)
@@ -82,5 +82,6 @@
 
 	%Interpolation of data on specified points
-	data_interp=InterpFromMeshToMesh2d(md.mesh.elements,md.mesh.x,md.mesh.y,data,X,Y);
+	data_interp=InterpFromMesh2d(md.mesh.elements,md.mesh.x,md.mesh.y,data,X,Y);
+	%data_interp=InterpFromMeshToMesh2d(md.mesh.elements,md.mesh.x,md.mesh.y,data,X,Y);
 	%data_interp=griddata(md.mesh.x,md.mesh.y,data,X,Y);
 
Index: /issm/branches/trunk-jpl-damage/src/m/model/collapse.m
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/model/collapse.m	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/m/model/collapse.m	(revision 11684)
@@ -93,4 +93,5 @@
 md.geometry.bed=project2d(md,md.geometry.bed,1);
 md.mesh.vertexonboundary=project2d(md,md.mesh.vertexonboundary,1);
+md.mesh.elementconnectivity=project2d(md,md.mesh.elementconnectivity,1);
 md.mask.elementonfloatingice=project2d(md,md.mask.elementonfloatingice,1);
 md.mask.vertexonfloatingice=project2d(md,md.mask.vertexonfloatingice,1);
@@ -111,4 +112,6 @@
 md.mesh.lowervertex=NaN;
 md.mesh.uppervertex=NaN;
+md.mesh.lowerelements=NaN;
+md.mesh.upperelements=NaN;
 
 %Remove old mesh 
Index: /issm/branches/trunk-jpl-damage/src/m/model/mesh/bamg.m
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/model/mesh/bamg.m	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/m/model/mesh/bamg.m	(revision 11684)
@@ -4,43 +4,43 @@
 %   Available options (for more details see ISSM website http://issm.jpl.nasa.gov/):
 %
-%   - domain: followed by an ARGUS file that prescribes the domain outline
-%   - hmin  : minimum edge length (default is 10^-100)
-%   - hmax  : maximum esge length (default is 10^100)
-%   - hVertices   : imposed edge length for each vertex (geometry or mesh)
-%   - hminVertices: minimum edge length for each vertex (mesh)
-%   - hmaxVertices: maximum edge length for each vertex (mesh)
-%
-%   - anisomax    : maximum ration between the smallest and largest edges (default is 10^30)
-%   - coeff       : coefficient applied to the metric (2-> twice as many elements, default is 1)
-%   - cutoff      : scalar used to compute the metric when metric type 2 or 3 are applied
-%   - err         : error used to generate the metric from a field
-%   - errg        : geometrical error (default is 0.1)
-%   - field       : field of the model that will be used to compute the metric
-%                   to apply several fields, use one column per field
-%   - gradation   : maximum ration between two adjacent edges
-%   - Hessiantype : 0 -> use double P2 projection (default)
-%                   1 -> use Green formula
-%   - KeepVertices: try to keep initial vertices when adaptation is done on an existing mesh (default 1)
-%   - MaxCornerAngle: maximal angle of corners in degree (default is 10)
-%   - maxnbv      : maximum number of vertices used to allocate memory (default is 10^6)
-%   - maxsubdiv   : maximum subdivision of exisiting elements (default is 10)
-%   - metric      : matrix (numberofnodes x 3) used as a metric
-%   - Metrictype  : 1 -> absolute error          c/(err coeff^2) * Abs(H)        (default)
-%                   2 -> relative error          c/(err coeff^2) * Abs(H)/max(s,cutoff*max(s))
-%                   3 -> rescaled absolute error c/(err coeff^2) * Abs(H)/(smax-smin)
-%   - nbjacoby    : correction used by Hessiantype=1 (default is 1)
-%   - nbsmooth    : number of metric smoothing procedure (default is 3)
-%   - omega       : relaxation parameter of the smoothing procedure (default is 1.8)
-%   - power       : power applied to the metric (default is 1)
-%   - splitcorners : split triangles whuch have 3 vertices on the outline (default is 1)
-%   - geometricalmetric : Take the geometry into account to generate the metric (default is 0)
-%   - verbose     : level of verbosity (default is 1)
-%
-%   - rifts : followed by an ARGUS file that prescribes the rifts
-%   - toltip: tolerance to move tip on an existing point of the domain outline
-%   - tracks: followed by an ARGUS file that prescribes the tracks that the mesh will stick to
-%   - RequiredVertices: mesh vertices that are required. [x,y,ref]; ref is optional
-%   - tol:    if the distance between 2 points of the domain outline is less than tol, they
-%             will be merged
+%   - domain :            followed by an ARGUS file that prescribes the domain outline
+%   - hmin :              minimum edge length (default is 10^-100)
+%   - hmax :              maximum edge length (default is 10^100)
+%   - hVertices :         imposed edge length for each vertex (geometry or mesh)
+%   - hminVertices :      minimum edge length for each vertex (mesh)
+%   - hmaxVertices :      maximum edge length for each vertex (mesh)
+%
+%   - anisomax :          maximum ratio between the smallest and largest edges (default is 10^30)
+%   - coeff :             coefficient applied to the metric (2-> twice as many elements, default is 1)
+%   - cutoff :            scalar used to compute the metric when metric type 2 or 3 are applied
+%   - err :               error used to generate the metric from a field
+%   - errg :              geometric error (default is 0.1)
+%   - field :             field of the model that will be used to compute the metric
+%                         to apply several fields, use one column per field
+%   - gradation :         maximum ratio between two adjacent edges
+%   - Hessiantype :       0 -> use double P2 projection (default)
+%                         1 -> use Green formula
+%   - KeepVertices :      try to keep initial vertices when adaptation is done on an existing mesh (default 1)
+%   - MaxCornerAngle :    maximum angle of corners in degree (default is 10)
+%   - maxnbv :            maximum number of vertices used to allocate memory (default is 10^6)
+%   - maxsubdiv :         maximum subdivision of exisiting elements (default is 10)
+%   - metric :            matrix (numberofnodes x 3) used as a metric
+%   - Metrictype :        1 -> absolute error          c/(err coeff^2) * Abs(H)        (default)
+%                         2 -> relative error          c/(err coeff^2) * Abs(H)/max(s,cutoff*max(s))
+%                         3 -> rescaled absolute error c/(err coeff^2) * Abs(H)/(smax-smin)
+%   - nbjacoby :          correction used by Hessiantype=1 (default is 1)
+%   - nbsmooth :          number of metric smoothing procedure (default is 3)
+%   - omega :             relaxation parameter of the smoothing procedure (default is 1.8)
+%   - power :             power applied to the metric (default is 1)
+%   - splitcorners :      split triangles whuch have 3 vertices on the outline (default is 1)
+%   - geometricalmetric : take the geometry into account to generate the metric (default is 0)
+%   - verbose :           level of verbosity (default is 1)
+%
+%   - rifts :             followed by an ARGUS file that prescribes the rifts
+%   - toltip :            tolerance to move tip on an existing point of the domain outline
+%   - tracks :            followed by an ARGUS file that prescribes the tracks that the mesh will stick to
+%   - RequiredVertices :  mesh vertices that are required. [x,y,ref]; ref is optional
+%   - tol :               if the distance between 2 points of the domain outline is less than tol, they
+%                         will be merged
 %
 %   Examples:
Index: /issm/branches/trunk-jpl-damage/src/m/qmu/dakota_in_data.m
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/qmu/dakota_in_data.m	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/m/qmu/dakota_in_data.m	(revision 11684)
@@ -80,6 +80,6 @@
 if strcmpi(params.analysis_driver,'matlab') && ...
    isempty(params.analysis_components)
-    [pathstr,name,ext,versn] = fileparts(filei);
-    params.analysis_components=fullfile(pathstr,[name '.m' versn]);
+    [pathstr,name,ext] = fileparts(filei);
+    params.analysis_components=fullfile(pathstr,[name '.m']);
 end
 
Index: /issm/branches/trunk-jpl-damage/src/m/qmu/dakota_in_write.m
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/qmu/dakota_in_write.m	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/m/qmu/dakota_in_write.m	(revision 11684)
@@ -63,10 +63,10 @@
     filei=input('Dakota input file to write?  ','s');
 end
-[pathstr,name,ext,versn] = fileparts(filei);
+[pathstr,name,ext] = fileparts(filei);
 if isempty(ext)
 % fileparts only considers '.in' to be the extension, not '.qmu.in'
     ext='.qmu.in';
 end
-filei2=fullfile(pathstr,[name ext versn]);
+filei2=fullfile(pathstr,[name ext]);
 
 display(sprintf('Opening Dakota input file ''%s''.',filei2));
@@ -234,9 +234,9 @@
     param_write(fidi,'\t  ','evaluation_static_scheduling','','\n',params);
     if ~isempty(params.analysis_components)
-        [pathstr,name,ext,versn] = fileparts(params.analysis_components);
+        [pathstr,name,ext] = fileparts(params.analysis_components);
         if isempty(ext)
             ext='.m';
         end
-        params.analysis_components=fullfile(pathstr,[name ext versn]);
+        params.analysis_components=fullfile(pathstr,[name ext]);
         param_write(fidi,'\t  ','analysis_components',' = ''','''\n',params);
     end
Index: /issm/branches/trunk-jpl-damage/src/m/solutions/AnalysisConfiguration.m
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/solutions/AnalysisConfiguration.m	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/m/solutions/AnalysisConfiguration.m	(revision 11684)
@@ -14,6 +14,6 @@
 
 	case SteadystateSolutionEnum,
-		numanalyses=7; 
-		analyses=[DiagnosticHorizAnalysisEnum;DiagnosticVertAnalysisEnum;DiagnosticHutterAnalysisEnum;SurfaceSlopeAnalysisEnum;BedSlopeAnalysisEnum;ThermalAnalysisEnum;MeltingAnalysisEnum];
+		numanalyses=8; 
+		analyses=[DiagnosticHorizAnalysisEnum;DiagnosticVertAnalysisEnum;DiagnosticHutterAnalysisEnum;SurfaceSlopeAnalysisEnum;BedSlopeAnalysisEnum;EnthalpyAnalysisEnum;ThermalAnalysisEnum;MeltingAnalysisEnum];
 
 	case ThermalSolutionEnum,
Index: /issm/branches/trunk-jpl-damage/src/m/solutions/steadystate_core.m
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/solutions/steadystate_core.m	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/m/solutions/steadystate_core.m	(revision 11684)
@@ -10,4 +10,5 @@
 	control_analysis=femmodel.parameters.InversionIscontrol;
 	solution_type=femmodel.parameters.SolutionType;
+	isenthalpy=femmodel.parameters.ThermalIsenthalpy;
 
 	%Initialize counter
@@ -17,5 +18,9 @@
 
 		issmprintf(VerboseSolution,'\n%s%i\n','   computing velocities and temperatures for step: ',step);
-		femmodel=thermal_core(femmodel); 
+		if (isenthalpy==0),
+			femmodel=thermal_core(femmodel); 
+		else
+			femmodel=enthalpy_core(femmodel); 
+		end
 
 		issmprintf(VerboseSolution,'\n%s',['   computing new velocity']);
@@ -46,6 +51,10 @@
 		femmodel.elements=InputToResult(femmodel.elements,femmodel.nodes,femmodel.vertices,femmodel.loads,femmodel.materials,femmodel.parameters,PressureEnum);
 		femmodel.elements=InputToResult(femmodel.elements,femmodel.nodes,femmodel.vertices,femmodel.loads,femmodel.materials,femmodel.parameters,TemperatureEnum);
-		femmodel.elements=InputToResult(femmodel.elements,femmodel.nodes,femmodel.vertices,femmodel.loads,femmodel.materials,femmodel.parameters,BasalforcingsMeltingRateEnum);
-	end
+		if (isenthalpy),
+			femmodel.elements=InputToResult(femmodel.elements,femmodel.nodes,femmodel.vertices,femmodel.loads,femmodel.materials,femmodel.parameters,EnthalpyEnum);
+			femmodel.elements=InputToResult(femmodel.elements,femmodel.nodes,femmodel.vertices,femmodel.loads,femmodel.materials,femmodel.parameters,WaterfractionEnum);
+		else
+			femmodel.elements=InputToResult(femmodel.elements,femmodel.nodes,femmodel.vertices,femmodel.loads,femmodel.materials,femmodel.parameters,BasalforcingsMeltingRateEnum);
+		end
 
 end %end of function
Index: /issm/branches/trunk-jpl-damage/src/m/utils/Analysis/setcluster.m
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/utils/Analysis/setcluster.m	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/m/utils/Analysis/setcluster.m	(revision 11684)
@@ -5,3 +5,4 @@
 %      md=setcluster(md,cluster);
 
+disp('Warning: setcluster is deprecated, use md.cluster=cluster instead');
 md.cluster=cluster;
Index: /issm/branches/trunk-jpl-damage/src/m/utils/Exp/manipulation/Makefile.am
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/utils/Exp/manipulation/Makefile.am	(revision 11684)
+++ /issm/branches/trunk-jpl-damage/src/m/utils/Exp/manipulation/Makefile.am	(revision 11684)
@@ -0,0 +1,1 @@
+bin_SCRIPTS=*.m 
Index: /issm/branches/trunk-jpl-damage/src/m/utils/Exp/readwrite/Makefile.am
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/utils/Exp/readwrite/Makefile.am	(revision 11684)
+++ /issm/branches/trunk-jpl-damage/src/m/utils/Exp/readwrite/Makefile.am	(revision 11684)
@@ -0,0 +1,1 @@
+bin_SCRIPTS=*.m 
Index: /issm/branches/trunk-jpl-damage/src/mex/CreateJacobianMatrix/CreateJacobianMatrix.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/mex/CreateJacobianMatrix/CreateJacobianMatrix.cpp	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/mex/CreateJacobianMatrix/CreateJacobianMatrix.cpp	(revision 11684)
@@ -17,5 +17,5 @@
 	
 	/* output datasets: */
-	Mat    Jff  = NULL;
+	Matrix*    Jff  = NULL;
 
 	/*Boot module: */
@@ -53,5 +53,5 @@
 	delete materials;
 	delete parameters;
-	MatFree(&Jff);
+	delete Jff;
 
 	/*end module: */
Index: /issm/branches/trunk-jpl-damage/src/mex/CreateNodalConstraints/CreateNodalConstraints.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/mex/CreateNodalConstraints/CreateNodalConstraints.cpp	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/mex/CreateNodalConstraints/CreateNodalConstraints.cpp	(revision 11684)
@@ -12,5 +12,5 @@
 
 	/* output datasets: */
-	Vec ys=NULL;
+	Vector* ys=NULL;
 
 	/*Boot module: */
@@ -32,5 +32,5 @@
 	/*Free ressources: */
 	delete nodes;
-	VecFree(&ys);
+	delete ys;
 
 	/*end module: */
Index: /issm/branches/trunk-jpl-damage/src/mex/GetSolutionFromInputs/GetSolutionFromInputs.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/mex/GetSolutionFromInputs/GetSolutionFromInputs.cpp	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/mex/GetSolutionFromInputs/GetSolutionFromInputs.cpp	(revision 11684)
@@ -14,5 +14,5 @@
 	Materials* materials=NULL;
 	Parameters* parameters=NULL;
-	Vec      ug=NULL;
+	Vector*      ug=NULL;
 
 	/* output datasets: elements and loads*/
Index: /issm/branches/trunk-jpl-damage/src/mex/InputUpdateFromSolution/InputUpdateFromSolution.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/mex/InputUpdateFromSolution/InputUpdateFromSolution.cpp	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/mex/InputUpdateFromSolution/InputUpdateFromSolution.cpp	(revision 11684)
@@ -14,5 +14,5 @@
 	Materials* materials=NULL;
 	Parameters* parameters=NULL;
-	Vec      solution=NULL;
+	Vector*      solution=NULL;
 
 	/*Boot module: */
@@ -50,5 +50,5 @@
 	delete materials;
 	delete parameters;
-	VecFree(&solution);
+	delete solution;
 
 	/*end module: */
Index: /issm/branches/trunk-jpl-damage/src/mex/Mergesolutionfromftog/Mergesolutionfromftog.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/mex/Mergesolutionfromftog/Mergesolutionfromftog.cpp	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/mex/Mergesolutionfromftog/Mergesolutionfromftog.cpp	(revision 11684)
@@ -9,11 +9,11 @@
 	/*input datasets: */
 	bool        flag_ys0;
-	Vec         uf         = NULL;
-	Vec         ys         = NULL;
+	Vector*         uf         = NULL;
+	Vector*         ys         = NULL;
 	Nodes*      nodes   = NULL;
 	Parameters* parameters   = NULL;
 
 	/* output datasets: */
-	Vec ug=NULL;
+	Vector* ug=NULL;
 
 	/*Boot module: */
@@ -45,7 +45,7 @@
 
 	/*Free ressources: */
-	VecFree(&uf);
-	VecFree(&ug);
-	VecFree(&ys);
+	delete uf;
+	delete ug;
+	delete ys;
 	delete nodes;
 	delete parameters;
Index: /issm/branches/trunk-jpl-damage/src/mex/Reduceload/Reduceload.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/mex/Reduceload/Reduceload.cpp	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/mex/Reduceload/Reduceload.cpp	(revision 11684)
@@ -8,7 +8,7 @@
 
 	/*input datasets: */
-	Vec         pf         = NULL;
-	Mat         Kfs        = NULL;
-	Vec         ys         = NULL;
+	Vector*         pf         = NULL;
+	Matrix*         Kfs        = NULL;
+	Vector*         ys         = NULL;
 	bool        flag_ys0=false;
 
@@ -40,7 +40,7 @@
 
 	/*Free ressources: */
-	VecFree(&pf);
-	MatFree(&Kfs);
-	VecFree(&ys);
+	delete pf;
+	delete Kfs;
+	delete ys;
 
 	MODULEEND();
Index: /issm/branches/trunk-jpl-damage/src/mex/Reducevectorgtof/Reducevectorgtof.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/mex/Reducevectorgtof/Reducevectorgtof.cpp	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/mex/Reducevectorgtof/Reducevectorgtof.cpp	(revision 11684)
@@ -8,10 +8,10 @@
 
 	/*input datasets: */
-	Vec ug=NULL;
+	Vector* ug=NULL;
 	Nodes* nodes=NULL;
 	Parameters* parameters=NULL;
 
 	/* output datasets: */
-	Vec uf=NULL;
+	Vector* uf=NULL;
 
 	/*Boot module: */
@@ -35,6 +35,6 @@
 	delete nodes;
 	delete parameters;
-	VecFree(&ug);
-	VecFree(&uf);
+	delete ug;
+	delete uf;
 
 	/*end module: */
Index: /issm/branches/trunk-jpl-damage/src/mex/Reducevectorgtos/Reducevectorgtos.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/mex/Reducevectorgtos/Reducevectorgtos.cpp	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/mex/Reducevectorgtos/Reducevectorgtos.cpp	(revision 11684)
@@ -8,10 +8,10 @@
 
 	/*input datasets: */
-	Vec yg=NULL;
+	Vector* yg=NULL;
 	Nodes* nodes=NULL;
 	Parameters* parameters=NULL;
 
 	/* output datasets: */
-	Vec ys=NULL;
+	Vector* ys=NULL;
 
 	/*Boot module: */
@@ -35,6 +35,6 @@
 	delete nodes;
 	delete parameters;
-	VecFree(&yg);
-	VecFree(&ys);
+	delete yg;
+	delete ys;
 
 	/*end module: */
Index: /issm/branches/trunk-jpl-damage/src/mex/Solver/Solver.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/mex/Solver/Solver.cpp	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/mex/Solver/Solver.cpp	(revision 11684)
@@ -8,9 +8,9 @@
 
 	/*input datasets: */
-	Mat         Kff           = NULL;
-	Vec         pf            = NULL;
-	Vec         uf0           = NULL;
-	Vec         uf            = NULL;
-	Vec         df            = NULL;
+	Matrix*         Kff           = NULL;
+	Vector*         pf            = NULL;
+	Vector*         uf0           = NULL;
+	Vector*         uf            = NULL;
+	Vector*         df            = NULL;
 	Parameters *parameters    = NULL;
 	int         analysis_type;
@@ -66,9 +66,9 @@
 
 	/*Free ressources: */
-	MatFree(&Kff);
-	VecFree(&pf);
-	VecFree(&uf0);
-	VecFree(&uf);
-	VecFree(&df);
+	delete Kff;
+	delete pf;
+	delete uf0;
+	delete uf;
+	delete df;
 	delete parameters;
 
Index: /issm/branches/trunk-jpl-damage/src/mex/SystemMatrices/SystemMatrices.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/mex/SystemMatrices/SystemMatrices.cpp	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/mex/SystemMatrices/SystemMatrices.cpp	(revision 11684)
@@ -17,8 +17,8 @@
 	
 	/* output datasets: */
-	Mat    Kff  = NULL;
-	Mat    Kfs  = NULL;
-	Vec    pf   = NULL;
-	Vec    df   = NULL;
+	Matrix*    Kff  = NULL;
+	Matrix*    Kfs  = NULL;
+	Vector*    pf   = NULL;
+	Vector*    df   = NULL;
 
 	double kmax;
@@ -72,8 +72,8 @@
 	delete materials;
 	delete parameters;
-	MatFree(&Kff);
-	MatFree(&Kfs);
-	VecFree(&pf);
-	VecFree(&df);
+	delete Kff;
+	delete Kfs;
+	delete pf;
+	delete df;
 
 	/*end module: */
Index: /issm/branches/trunk-jpl-damage/src/mex/UpdateDynamicConstraints/UpdateDynamicConstraints.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/mex/UpdateDynamicConstraints/UpdateDynamicConstraints.cpp	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/src/mex/UpdateDynamicConstraints/UpdateDynamicConstraints.cpp	(revision 11684)
@@ -11,5 +11,5 @@
 	Nodes       *nodes       = NULL;
 	Parameters  *parameters  = NULL;
-	Vec          yg          = NULL;
+	Vector*          yg          = NULL;
 
 	/*Boot module: */
@@ -32,5 +32,5 @@
 
 	/*Free ressources: */
-	VecFree(&yg);
+	delete yg;
 	delete constraints;
 	delete nodes;
Index: /issm/branches/trunk-jpl-damage/test/NightlyRun/IdToName.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/IdToName.m	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/test/NightlyRun/IdToName.m	(revision 11684)
@@ -224,4 +224,14 @@
 	case 453, name='SquareSheetShelfGroundingLine3dSoftSerial';
 	case 454, name='SquareSheetShelfGroundingLine3dSoftParallel';
+	case 455, name='SquareSheetShelfDiagM2dNewtonSerial';
+	case 456, name='SquareSheetShelfDiagM2dNewtonParallel';
+	case 457, name='SquareSheetShelfDiagP3dNewtonSerial';
+	case 458, name='SquareSheetShelfDiagP3dNewtonParallel';
+	case 459, name='SquareSheetShelfDiagS3dNewtonSerial';
+	case 460, name='SquareSheetShelfDiagS3dNewtonParallel';
+	case 461, name='SquareSheetShelfSteaEnthalpyM3dSerial';
+	case 462, name='SquareSheetShelfSteaEnthalpyM3dParallel';
+	case 463, name='SquareSheetShelfSteaEnthalpyP3dSerial';
+	case 464, name='SquareSheetShelfSteaEnthalpyP3dParallel';
 	case 501, name='PigDiagM2dSerial';
 	case 502, name='PigDiagM2dParallel';
Index: /issm/branches/trunk-jpl-damage/test/NightlyRun/runme.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/runme.m	(revision 11683)
+++ /issm/branches/trunk-jpl-damage/test/NightlyRun/runme.m	(revision 11684)
@@ -180,4 +180,5 @@
 						disp(sprintf(['FAILURE difference: N/A test id: %i test name: %s field: %s'],id,id_string,fieldname));
 					else
+						disp(sprintf(['FAILURE difference: N/A test id: %i test name: %s field: %s'],id,id_string,fieldname));
 						rethrow(me2);
 					end
@@ -204,4 +205,5 @@
 			disp(sprintf(['FAILURE difference: N/A test id: %i test name: %s field: %s'],id,id_string,'N/A'));
 		else
+			disp(sprintf(['FAILURE difference: N/A test id: %i test name: %s field: %s'],id,id_string,'N/A'));
 			rethrow(me);
 		end
Index: /issm/branches/trunk-jpl-damage/test/NightlyRun/test455.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test455.m	(revision 11684)
+++ /issm/branches/trunk-jpl-damage/test/NightlyRun/test455.m	(revision 11684)
@@ -0,0 +1,18 @@
+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: /issm/branches/trunk-jpl-damage/test/NightlyRun/test456.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test456.m	(revision 11684)
+++ /issm/branches/trunk-jpl-damage/test/NightlyRun/test456.m	(revision 11684)
@@ -0,0 +1,18 @@
+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=generic('name',oshostname(),'np',3);
+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: /issm/branches/trunk-jpl-damage/test/NightlyRun/test457.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test457.m	(revision 11684)
+++ /issm/branches/trunk-jpl-damage/test/NightlyRun/test457.m	(revision 11684)
@@ -0,0 +1,20 @@
+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: /issm/branches/trunk-jpl-damage/test/NightlyRun/test458.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test458.m	(revision 11684)
+++ /issm/branches/trunk-jpl-damage/test/NightlyRun/test458.m	(revision 11684)
@@ -0,0 +1,20 @@
+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=generic('name',oshostname(),'np',3);
+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: /issm/branches/trunk-jpl-damage/test/NightlyRun/test459.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test459.m	(revision 11684)
+++ /issm/branches/trunk-jpl-damage/test/NightlyRun/test459.m	(revision 11684)
@@ -0,0 +1,19 @@
+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: /issm/branches/trunk-jpl-damage/test/NightlyRun/test460.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test460.m	(revision 11684)
+++ /issm/branches/trunk-jpl-damage/test/NightlyRun/test460.m	(revision 11684)
@@ -0,0 +1,20 @@
+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.cluster=generic('name',oshostname(),'np',3);
+md=solve(md,DiagnosticSolutionEnum);
+
+%Fields and tolerances to track changes
+field_names     ={'Vx','Vy','Vz','Vel','Pressure'};
+field_tolerances={1e-07,1e-07,1e-06,1e-07,1e-07};
+field_values={...
+	(md.results.DiagnosticSolution.Vx),...
+	(md.results.DiagnosticSolution.Vy),...
+	(md.results.DiagnosticSolution.Vz),...
+	(md.results.DiagnosticSolution.Vel),...
+	(md.results.DiagnosticSolution.Pressure),...
+	};
Index: /issm/branches/trunk-jpl-damage/test/NightlyRun/test461.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test461.m	(revision 11684)
+++ /issm/branches/trunk-jpl-damage/test/NightlyRun/test461.m	(revision 11684)
@@ -0,0 +1,24 @@
+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: /issm/branches/trunk-jpl-damage/test/NightlyRun/test462.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test462.m	(revision 11684)
+++ /issm/branches/trunk-jpl-damage/test/NightlyRun/test462.m	(revision 11684)
@@ -0,0 +1,24 @@
+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=generic('name',oshostname(),'np',3);
+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: /issm/branches/trunk-jpl-damage/test/NightlyRun/test463.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test463.m	(revision 11684)
+++ /issm/branches/trunk-jpl-damage/test/NightlyRun/test463.m	(revision 11684)
@@ -0,0 +1,24 @@
+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: /issm/branches/trunk-jpl-damage/test/NightlyRun/test464.m
===================================================================
--- /issm/branches/trunk-jpl-damage/test/NightlyRun/test464.m	(revision 11684)
+++ /issm/branches/trunk-jpl-damage/test/NightlyRun/test464.m	(revision 11684)
@@ -0,0 +1,24 @@
+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=generic('name',oshostname(),'np',3);
+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-09,1e-09,1e-09,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),...
+	};
