Index: /issm/trunk/INSTALL
===================================================================
--- /issm/trunk/INSTALL	(revision 11526)
+++ /issm/trunk/INSTALL	(revision 11527)
@@ -1,2 +1,3 @@
-For the installation process please go to the ISSM website 
+For the installation process please go to the ISSM website:
+
 http://issm.jpl.nasa.gov/
Index: /issm/trunk/Makefile.am
===================================================================
--- /issm/trunk/Makefile.am	(revision 11526)
+++ /issm/trunk/Makefile.am	(revision 11527)
@@ -1,2 +1,3 @@
 EXTRA_DIST = reconf  scripts test INSTALLICE LICENSE m4 examples cron etc doc packages ChangeLogCielo ChangeLogIce contributors.txt run READMEICE startup.m startup.m startup.m startup.m  todo MakefileIce
 SUBDIRS = src bin
+bin_SCRIPTS=config.h startup.m README.rtf
Index: /issm/trunk/README
===================================================================
--- /issm/trunk/README	(revision 11526)
+++ /issm/trunk/README	(revision 11527)
@@ -10,44 +10,53 @@
 Jet Propulsion Laboratory
 
-Eric    Larour (Project Lead)
-Mathieu Morlighem (Anisotropic Meshing, Control Methods)
-Helene  Seroussi (Coupling 2D-3D, Multi-model, full-Stokes)
+Eric    Larour (Project Manager)
+Mathieu Morlighem (Core Developer, Anisotropic Meshing, Control Methods)
+Helene  Seroussi (Core Develper Coupling 2D-3D, Multi-model, full-Stokes)
+Nicole  Schlegel (Developer, Atmospheric Forcing)
+Chris   Borstad (Developer, Rifting/Faulting/Crack Propagation)
+Feras   Habbal (Developer, Solver Technologies)
+Daria   Halkides (Analyst, Atmospheric Forcing)
+Ala     Khazendar (Analyst, Ice Sheet Processes)
 
 Email: issm@jpl.nasa.gov
 
 ------------------------------------------------------------------------------
+
+Website: ttp://issm.jpl.nasa.gov/ for additional information.
+
+------------------------------------------------------------------------------
+
 License
 
-ISSM is California Institute of Technology Copyright.
+ISSM is California Institute of Technology Copyright, Distributed under BSD Three Clause License.
+
+
+Copyright (c) 2002-2011, California Institute of Technology.
+All rights reserved.  Based on Government Sponsored Research under contracts
+NAS7-1407 and/or NAS7-03001.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+1. Redistributions of source code must retain the above copyright notice,
+   this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+3. Neither the name of the California Institute of Technology (Caltech),
+   its operating division the Jet Propulsion Laboratory (JPL), the National
+   Aeronautics and Space Administration (NASA), nor the names of its
+   contributors may be used to endorse or promote products derived from
+   this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE CALIFORNIA INSTITUTE OF TECHNOLOGY BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 ------------------------------------------------------------------------------
-Overview
-
-More to come
-
-Refer to http://issm.jpl.nasa.gov/ for additional information.
-------------------------------------------------------------------------------
-Distribution
-
-The directories contained in this distribution include:
-
-examples            Example problems 
-
-externalpackages    Other libraries 
-
-m4                  m4 macros used for supporting autoconf.
-
-doc                 The Users, Reference, and Developers Manuals are 
-                    maintained here.  Other references are available from
-                    the ISSM Web site (http://issm.jpl.nasa.gov/)
-
-src                 The main source code repository for the ISSM system.
-
-test                Files for regression and unit testing of the ISSM system.
-------------------------------------------------------------------------------
-Installation
-
-The installation procedure uses a standard GNU installation based on autoconf.
-The basic steps are to invoke 'configure' to generate Makefiles for your 
-particular system and then invoke 'make' to compile the sources.  See the 
-INSTALL file for detailed instructions.
-------------------------------------------------------------------------------
Index: /issm/trunk/ar-lib
===================================================================
--- /issm/trunk/ar-lib	(revision 11527)
+++ /issm/trunk/ar-lib	(revision 11527)
@@ -0,0 +1,265 @@
+#! /bin/sh
+# Wrapper for Microsoft lib.exe
+
+me=ar-lib
+scriptversion=2012-01-30.22; # UTC
+
+# Copyright (C) 2010, 2012 Free Software Foundation, Inc.
+# Written by Peter Rosin <peda@lysator.liu.se>.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# This file is maintained in Automake, please report
+# bugs to <bug-automake@gnu.org> or send patches to
+# <automake-patches@gnu.org>.
+
+
+# func_error message
+func_error ()
+{
+  echo "$me: $1" 1>&2
+  exit 1
+}
+
+file_conv=
+
+# func_file_conv build_file
+# Convert a $build file to $host form and store it in $file
+# Currently only supports Windows hosts.
+func_file_conv ()
+{
+  file=$1
+  case $file in
+    / | /[!/]*) # absolute file, and not a UNC file
+      if test -z "$file_conv"; then
+	# lazily determine how to convert abs files
+	case `uname -s` in
+	  MINGW*)
+	    file_conv=mingw
+	    ;;
+	  CYGWIN*)
+	    file_conv=cygwin
+	    ;;
+	  *)
+	    file_conv=wine
+	    ;;
+	esac
+      fi
+      case $file_conv in
+	mingw)
+	  file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
+	  ;;
+	cygwin)
+	  file=`cygpath -m "$file" || echo "$file"`
+	  ;;
+	wine)
+	  file=`winepath -w "$file" || echo "$file"`
+	  ;;
+      esac
+      ;;
+  esac
+}
+
+# func_at_file at_file operation archive
+# Iterate over all members in AT_FILE performing OPERATION on ARCHIVE
+# for each of them.
+# When interpreting the content of the @FILE, do NOT use func_file_conv,
+# since the user would need to supply preconverted file names to
+# binutils ar, at least for MinGW.
+func_at_file ()
+{
+  operation=$2
+  archive=$3
+  at_file_contents=`cat "$1"`
+  eval set x "$at_file_contents"
+  shift
+
+  for member
+  do
+    $AR -NOLOGO $operation:"$member" "$archive" || exit $?
+  done
+}
+
+case $1 in
+  '')
+     func_error "no command.  Try '$0 --help' for more information."
+     ;;
+  -h | --h*)
+    cat <<EOF
+Usage: $me [--help] [--version] PROGRAM ACTION ARCHIVE [MEMBER...]
+
+Members may be specified in a file named with @FILE.
+EOF
+    exit $?
+    ;;
+  -v | --v*)
+    echo "$me, version $scriptversion"
+    exit $?
+    ;;
+esac
+
+if test $# -lt 3; then
+  func_error "you must specify a program, an action and an archive"
+fi
+
+AR=$1
+shift
+while :
+do
+  if test $# -lt 2; then
+    func_error "you must specify a program, an action and an archive"
+  fi
+  case $1 in
+    -lib | -LIB \
+    | -ltcg | -LTCG \
+    | -machine* | -MACHINE* \
+    | -subsystem* | -SUBSYSTEM* \
+    | -verbose | -VERBOSE \
+    | -wx* | -WX* )
+      AR="$AR $1"
+      shift
+      ;;
+    *)
+      action=$1
+      shift
+      break
+      ;;
+  esac
+done
+orig_archive=$1
+shift
+func_file_conv "$orig_archive"
+archive=$file
+
+# strip leading dash in $action
+action=${action#-}
+
+delete=
+extract=
+list=
+replace=
+create=
+
+while test -n "$action"
+do
+  case $action in
+    d*) delete=yes  ;;
+    x*) extract=yes ;;
+    t*) list=yes    ;;
+    r*) replace=yes ;;
+    c*) create=yes  ;;
+    u*)             ;; # TODO: don't ignore the update modifier
+    v*)             ;; # TODO: don't ignore the verbose modifier
+    *)
+      func_error "unknown action specified"
+      ;;
+  esac
+  action=${action#?}
+done
+
+case $delete$extract$list$replace in
+  yes)
+    ;;
+  yesyes*)
+    func_error "more than one action specified"
+    ;;
+  *)
+    func_error "no action specified"
+    ;;
+esac
+
+if test -n "$delete"; then
+  if test ! -f "$orig_archive"; then
+    func_error "archive not found"
+  fi
+  for member
+  do
+    case $1 in
+      @*)
+        func_at_file "${1#@}" -REMOVE "$archive"
+        ;;
+      *)
+        func_file_conv "$1"
+        $AR -NOLOGO -REMOVE:"$file" "$archive" || exit $?
+        ;;
+    esac
+  done
+
+elif test -n "$extract"; then
+  if test ! -f "$orig_archive"; then
+    func_error "archive not found"
+  fi
+  if test $# -gt 0; then
+    for member
+    do
+      case $1 in
+        @*)
+          func_at_file "${1#@}" -EXTRACT "$archive"
+          ;;
+        *)
+          func_file_conv "$1"
+          $AR -NOLOGO -EXTRACT:"$file" "$archive" || exit $?
+          ;;
+      esac
+    done
+  else
+    $AR -NOLOGO -LIST "$archive" | sed -e 's/\\/\\\\/g' | while read member
+    do
+      $AR -NOLOGO -EXTRACT:"$member" "$archive" || exit $?
+    done
+  fi
+
+elif test -n "$replace"; then
+  if test ! -f "$orig_archive"; then
+    if test -z "$create"; then
+      echo "$me: creating $orig_archive"
+    fi
+    orig_archive=
+  else
+    orig_archive=$archive
+  fi
+
+  for member
+  do
+    case $1 in
+    @*)
+      func_file_conv "${1#@}"
+      set x "$@" "@$file"
+      ;;
+    *)
+      func_file_conv "$1"
+      set x "$@" "$file"
+      ;;
+    esac
+    shift
+    shift
+  done
+
+  if test -n "$orig_archive"; then
+    $AR -NOLOGO -OUT:"$archive" "$orig_archive" "$@" || exit $?
+  else
+    $AR -NOLOGO -OUT:"$archive" "$@" || exit $?
+  fi
+
+elif test -n "$list"; then
+  if test ! -f "$orig_archive"; then
+    func_error "archive not found"
+  fi
+  $AR -NOLOGO -LIST "$archive" || exit $?
+fi
Index: /issm/trunk/configs/config-greenplanet.sh
===================================================================
--- /issm/trunk/configs/config-greenplanet.sh	(revision 11527)
+++ /issm/trunk/configs/config-greenplanet.sh	(revision 11527)
@@ -0,0 +1,24 @@
+#!/bin/csh
+
+#PETSc 3.2
+#MPI /sopt/mpi/openmpi-1.5.4_psm/intel
+
+./configure \
+ --prefix=$ISSM_TIER \
+ --with-serial=no \
+ --with-triangle-dir=$ISSM_TIER/externalpackages/triangle/install \
+ --with-metis-dir=$ISSM_TIER/externalpackages/metis/install \
+ --with-petsc-dir=$ISSM_TIER/externalpackages/petsc/install \
+ --with-mpi-include="/sopt/mpi/openmpi-1.5.4_psm/intel/include/" \
+ --with-mpi-lib="-L/sopt/mpi/openmpi-1.5.4_psm/intel/lib/ -lmpi -lmpi_f77" \
+ --with-petsc-arch=$ISSM_ARCH \
+ --with-dakota-dir=$ISSM_TIER/externalpackages/dakota/install \
+ --with-mkl-dir=/opt/intel/mkl/10.2.4.032/ \
+ --with-plapack-lib="-L$ISSM_TIER/externalpackages/petsc/install/ -lPLAPACK" \
+ --with-plapack-include="-I$ISSM_TIER/externalpackages/petsc/install/externalpackages/PLAPACKR32-hg/INCLUDE" \
+ --with-mumps-dir=$ISSM_TIER/externalpackages/petsc/install/ \
+ --with-scalapack-dir=$ISSM_TIER/externalpackages/petsc/install/ \
+ --with-blacs-dir=$ISSM_TIER/externalpackages/petsc/install/ \
+ --with-graphics-lib=/usr/lib64/libX11.so \
+ --with-cxxoptflags="-O3 -xS" \
+ --with-vendor=intel-linux
Index: /issm/trunk/configs/config-win7-32.sh
===================================================================
--- /issm/trunk/configs/config-win7-32.sh	(revision 11527)
+++ /issm/trunk/configs/config-win7-32.sh	(revision 11527)
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+
+#get configure.sh to pick up the win7 Visual Studio compiler 
+./configure --prefix=$ISSM_TIER --with-vendor=intel-win7-32  --with-matlab-dir=$MATLAB_DIR --with-triangle-dir=$ISSM_TIER_WIN/externalpackages/triangle/install --with-metis-dir=$ISSM_TIER_WIN/externalpackages/metis/install --with-petsc-dir=$ISSM_TIER_WIN/externalpackages/petsc/install  --with-petsc-arch=$ISSM_ARCH  --with-blas-lapack-dir=$ISSM_TIER/externalpackages/petsc/install/lib/  --with-mpi-lib=$ISSM_TIER_WIN/externalpackages/petsc/install/lib/libpetsc.lib --with-mpi-include=$ISSM_TIER_WIN/externalpackages/petsc/install/include/mpiuni
Index: /issm/trunk/configs/config-win7-64.sh
===================================================================
--- /issm/trunk/configs/config-win7-64.sh	(revision 11527)
+++ /issm/trunk/configs/config-win7-64.sh	(revision 11527)
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+
+#get configure.sh to pick up the win7 Visual Studio compiler 
+./configure --prefix=$ISSM_TIER --with-vendor=intel-win7-64  --with-matlab-dir=$MATLAB_DIR --with-triangle-dir=$ISSM_TIER_WIN/externalpackages/triangle/install --with-metis-dir=$ISSM_TIER_WIN/externalpackages/metis/install --with-petsc-dir=$ISSM_TIER_WIN/externalpackages/petsc/install  --with-petsc-arch=$ISSM_ARCH  --with-blas-lapack-dir=$ISSM_TIER/externalpackages/petsc/install/lib/  --with-mpi-lib=$ISSM_TIER_WIN/externalpackages/petsc/install/lib/libpetsc.lib --with-mpi-include=$ISSM_TIER_WIN/externalpackages/petsc/install/include/mpiuni
Index: /issm/trunk/configure.ac
===================================================================
--- /issm/trunk/configure.ac	(revision 11526)
+++ /issm/trunk/configure.ac	(revision 11527)
@@ -5,8 +5,9 @@
 AC_CANONICAL_TARGET
 AM_INIT_AUTOMAKE
+AM_SILENT_RULES([yes])
 AC_PROG_RANLIB
-AC_PROG_CC([gcc icl])
+AC_PROG_CC([gcc icl cccl cl])
 AC_PROG_CPP
-AC_PROG_CXX([g++ icl])
+AC_PROG_CXX([g++ icl cccl cl])
 AC_PROG_F77([ifort g77 gfortran])
 AC_F77_LIBRARY_LDFLAGS
@@ -14,4 +15,5 @@
 AC_PATH_XTRA
 ISSM_OPTIONS
+AM_PROG_AR
 AC_CONFIG_FILES([Makefile
 			src/Makefile
@@ -19,5 +21,52 @@
 			src/ad/Makefile
 			src/mex/Makefile
+			src/m/Makefile
+			src/m/classes/Makefile
+			src/m/classes/@modellist/Makefile
+			src/m/classes/@pairoptions/Makefile
+			src/m/classes/model/Makefile
+			src/m/classes/clusters/Makefile
+			src/m/enum/Makefile
+			src/m/kml/Makefile
+			src/m/model/Makefile
+			src/m/model/plot/Makefile
+			src/m/model/mesh/Makefile
+			src/m/model/display/Makefile
+			src/m/model/parameterization/Makefile
+			src/m/model/partition/Makefile
+			src/m/model/solvers/Makefile
+			src/m/planet/Makefile
+			src/m/qmu/Makefile
+			src/m/shared/Makefile
+			src/m/solutions/Makefile
+			src/m/solvers/Makefile
+			src/m/utils/Makefile
+			src/m/utils/Analysis/Makefile
+			src/m/utils/Array/Makefile
+			src/m/utils/BC/Makefile
+			src/m/utils/Basins/Makefile
+			src/m/utils/Cluster/Makefile
+			src/m/utils/DataProcessing/Makefile
+			src/m/utils/Ecco3/Makefile
+			src/m/utils/Exp/Makefile
+			src/m/utils/Geometry/Makefile
+			src/m/utils/ImageProcessing/Makefile
+			src/m/utils/Interp/Makefile
+			src/m/utils/Kml/Makefile
+			src/m/utils/LatLong/Makefile
+			src/m/utils/Math/Makefile
+			src/m/utils/Meca/Makefile
+			src/m/utils/Mesh/Makefile
+			src/m/utils/Miscellaneous/Makefile
+			src/m/utils/Model/Makefile
+			src/m/utils/Numerics/Makefile
+			src/m/utils/OS/Makefile
+			src/m/utils/Plot/Makefile
+			src/m/utils/Shell/Makefile
+			src/m/utils/String/Makefile
+			src/m/utils/consistency/Makefile
+			src/m/utils/qmu/Makefile
 			bin/Makefile])
 AC_OUTPUT
 
+
Index: /issm/trunk/cron/configs/linux64_schlegel_daily
===================================================================
--- /issm/trunk/cron/configs/linux64_schlegel_daily	(revision 11527)
+++ /issm/trunk/cron/configs/linux64_schlegel_daily	(revision 11527)
@@ -0,0 +1,93 @@
+#
+########### Configuration file for Mathieu Morlighem's nightly run on Linux ############
+
+#-------------------------------#
+# 1: ISSM general configuration #
+#-------------------------------#
+
+#ISSM main directory (full paths)
+ISSM_DIR="/u/astrid-r1b/schlegel/issmuci"
+ISSM_TIER="/u/astrid-r1b/schlegel/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"
+
+#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/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="/u/astrid-r1b/schlegel/issmuci/trunk-jpl/externalpackages"
+
+#List of external pakages to be installed
+EXTERNALPACKAGES="autoconf automake matlab mpich2 petsc metis triangle dakota chaco"
+
+#---------------------#
+# 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=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/trunk/cron/configs/linux64_schlegel_nightly
===================================================================
--- /issm/trunk/cron/configs/linux64_schlegel_nightly	(revision 11527)
+++ /issm/trunk/cron/configs/linux64_schlegel_nightly	(revision 11527)
@@ -0,0 +1,93 @@
+#
+########### Configuration file for Mathieu Morlighem's nightly run on Linux ############
+
+#-------------------------------#
+# 1: ISSM general configuration #
+#-------------------------------#
+
+#ISSM main directory (full path)
+ISSM_DIR="/u/astrid-r1b/schlegel/issmuci"
+ISSM_TIER="/u/astrid-r1b/schlegel/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"
+
+#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/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="/u/astrid-r1b/schlegel/issmuci/trunk-jpl/externalpackages"
+
+#List of external pakages to be installed
+EXTERNALPACKAGES="autoconf automake matlab mpich2 petsc metis triangle dakota chaco"
+
+#---------------------#
+# 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=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/trunk/cron/configs/linux64_schlegel_ucitrunk
===================================================================
--- /issm/trunk/cron/configs/linux64_schlegel_ucitrunk	(revision 11527)
+++ /issm/trunk/cron/configs/linux64_schlegel_ucitrunk	(revision 11527)
@@ -0,0 +1,93 @@
+#
+########### Configuration file for Mathieu Morlighem's nightly run on Linux ############
+
+#-------------------------------#
+# 1: ISSM general configuration #
+#-------------------------------#
+
+#ISSM main directory (full path)
+ISSM_DIR="/u/astrid-r1b/schlegel/issmuci"
+ISSM_TIER="/u/astrid-r1b/schlegel/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"
+
+#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/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="/u/astrid-r1b/schlegel/issmuci/trunk-jpl/externalpackages"
+
+#List of external pakages to be installed
+EXTERNALPACKAGES="autoconf automake matlab mpich2 petsc metis triangle dakota chaco"
+
+#---------------------#
+# 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=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/trunk/cron/configs/linux64_schlegel_validation
===================================================================
--- /issm/trunk/cron/configs/linux64_schlegel_validation	(revision 11527)
+++ /issm/trunk/cron/configs/linux64_schlegel_validation	(revision 11527)
@@ -0,0 +1,92 @@
+########### Configuration file for Mathieu Morlighem's nightly run on Linux ############
+
+#-------------------------------#
+# 1: ISSM general configuration #
+#-------------------------------#
+
+#ISSM main directory (full path)
+ISSM_DIR="/u/astrid-r1b/schlegel/issmuci"
+ISSM_TIER="/u/astrid-r1b/schlegel/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"
+
+#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/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="/u/astrid-r1b/schlegel/issmuci/trunk-jpl/externalpackages"
+
+#List of external pakages to be installed
+EXTERNALPACKAGES="autoconf automake matlab mpich2 petsc metis triangle dakota chaco yams"
+
+#---------------------#
+# 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=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/trunk/cron/cronfiles/linux_cronfile
===================================================================
--- /issm/trunk/cron/cronfiles/linux_cronfile	(revision 11526)
+++ /issm/trunk/cron/cronfiles/linux_cronfile	(revision 11527)
@@ -3,12 +3,17 @@
 
 #mail output to Mathieu
-MAILTO=eric.larour@jpl.nasa.gov,mathieu.morlighem@jpl.nasa.gov,helene.seroussi@jpl.nasa.gov
+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
-00 09 * * 1-5 cd /u/astrid-r1b/seroussi/issm/trunk-jpl/cron/ && ./nightlyrun.sh configs/linux64_seroussi_daily
-30 12 * * 1-5 cd /u/astrid-r1b/seroussi/issm/trunk-jpl/cron/ && ./nightlyrun.sh configs/linux64_seroussi_daily
-00 15 * * 1-5 cd /u/astrid-r1b/seroussi/issm/trunk-jpl/cron/ && ./nightlyrun.sh configs/linux64_seroussi_daily
-00 18 * * 1-5 cd /u/astrid-r1b/seroussi/issm/trunk-jpl/cron/ && ./nightlyrun.sh configs/linux64_seroussi_daily
-00 23 * * 1-5 cd /u/astrid-r1b/seroussi/issm/trunk-jpl/cron/ && ./nightlyrun.sh configs/linux64_seroussi_nightly
-00 23 * * 6   cd /u/astrid-r1b/seroussi/issm/trunk-jpl/cron/ && ./nightlyrun.sh configs/linux64_seroussi_validation
-00 23 * * 7   cd /u/astrid-r1b/seroussi/issm/trunk-jpl/cron/ && ./nightlyrun.sh configs/linux64_seroussi_ucitrunk
+00 09 * * 1-5 cd /u/astrid-r1b/schlegel/issmuci/trunk-jpl/cron/ && ./nightlyrun.sh configs/linux64_schlegel_daily
+30 12 * * 1-5 cd /u/astrid-r1b/schlegel/issmuci/trunk-jpl/cron/ && ./nightlyrun.sh configs/linux64_schlegel_daily
+00 15 * * 1-5 cd /u/astrid-r1b/schlegel/issmuci/trunk-jpl/cron/ && ./nightlyrun.sh configs/linux64_schlegel_daily
+00 18 * * 1-5 cd /u/astrid-r1b/schlegel/issmuci/trunk-jpl/cron/ && ./nightlyrun.sh configs/linux64_schlegel_daily
+00 23 * * 1-5 cd /u/astrid-r1b/schlegel/issmuci/trunk-jpl/cron/ && ./nightlyrun.sh configs/linux64_schlegel_nightly
+00 20 * * 6   cd /u/astrid-r1b/schlegel/ExecutionNightlyRun && rm -r test*
+00 21 * * 6   cd /u/astrid-r1b/schlegel/issmuci/trunk-jpl/cron/trunk-jpl/test/NightlyRun && make clean
+00 22 * * 6   cd /u/astrid-r1b/schlegel/issmuci/trunk-jpl/cron/trunk-jpl/test/NightlyRun && rm -r qmu*
+00 23 * * 6   cd /u/astrid-r1b/schlegel/issmuci/trunk-jpl/cron/ && ./nightlyrun.sh configs/linux64_schlegel_validation
+00 21 * * 7   cd /u/astrid-r1b/schlegel/issmuci/trunk-jpl/cron/trunk/test/NightlyRun && make clean
+00 22 * * 7   cd /u/astrid-r1b/schlegel/issmuci/trunk-jpl/cron/trunk/test/NightlyRun && rm -r qmu*
+00 23 * * 7   cd /u/astrid-r1b/schlegel/issmuci/trunk-jpl/cron/ && ./nightlyrun.sh configs/linux64_schlegel_ucitrunk
Index: /issm/trunk/etc/environment.sh
===================================================================
--- /issm/trunk/etc/environment.sh	(revision 11526)
+++ /issm/trunk/etc/environment.sh	(revision 11527)
@@ -224,2 +224,5 @@
 #SHAPELIB
 export PATH="$PATH:$SHAPELIB_DIR/exec"
+
+#CCCL
+export PATH="$PATH:$CCCL_DIR/bin"
Index: /issm/trunk/etc/environment_variables.sh
===================================================================
--- /issm/trunk/etc/environment_variables.sh	(revision 11526)
+++ /issm/trunk/etc/environment_variables.sh	(revision 11527)
@@ -166,2 +166,5 @@
 #shapelib
 SHAPELIB_DIR="$ISSM_TIER/externalpackages/shapelib/install"
+
+#cccl
+CCCL_DIR="$ISSM_TIER/externalpackages/cccl/install"
Index: /issm/trunk/externalpackages/android/HelloWorldAppProject/AndroidManifest.xml
===================================================================
--- /issm/trunk/externalpackages/android/HelloWorldAppProject/AndroidManifest.xml	(revision 11527)
+++ /issm/trunk/externalpackages/android/HelloWorldAppProject/AndroidManifest.xml	(revision 11527)
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+      package="com.example.helloworld"
+      android:versionCode="1"
+      android:versionName="1.0">
+    <application android:label="@string/app_name" >
+        <activity android:name="HelloWorldAppActivity"
+                  android:label="@string/app_name">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.LAUNCHER" />
+            </intent-filter>
+        </activity>
+    </application>
+</manifest> 
Index: /issm/trunk/externalpackages/android/HelloWorldAppProject/ant.properties
===================================================================
--- /issm/trunk/externalpackages/android/HelloWorldAppProject/ant.properties	(revision 11527)
+++ /issm/trunk/externalpackages/android/HelloWorldAppProject/ant.properties	(revision 11527)
@@ -0,0 +1,17 @@
+# This file is used to override default values used by the Ant build system.
+#
+# This file must be checked in Version Control Systems, as it is
+# integral to the build system of your project.
+
+# This file is only used by the Ant script.
+
+# You can use this to override default values such as
+#  'source.dir' for the location of your java source folder and
+#  'out.dir' for the location of your output folder.
+
+# You can also use it define how the release builds are signed by declaring
+# the following properties:
+#  'key.store' for the location of your keystore and
+#  'key.alias' for the name of the key to use.
+# The password will be asked during the build when you use the 'release' target.
+
Index: /issm/trunk/externalpackages/android/HelloWorldAppProject/bin/HelloWorldApp-debug-unaligned.apk.d
===================================================================
--- /issm/trunk/externalpackages/android/HelloWorldAppProject/bin/HelloWorldApp-debug-unaligned.apk.d	(revision 11527)
+++ /issm/trunk/externalpackages/android/HelloWorldAppProject/bin/HelloWorldApp-debug-unaligned.apk.d	(revision 11527)
@@ -0,0 +1,3 @@
+/Users/gperez/HelloWorldAppProject/bin/HelloWorldApp-debug-unaligned.apk : \
+/Users/gperez/HelloWorldAppProject/bin/HelloWorldApp.ap_ \
+/Users/gperez/HelloWorldAppProject/bin/classes.dex \
Index: /issm/trunk/externalpackages/android/HelloWorldAppProject/bin/HelloWorldApp.ap_.d
===================================================================
--- /issm/trunk/externalpackages/android/HelloWorldAppProject/bin/HelloWorldApp.ap_.d	(revision 11527)
+++ /issm/trunk/externalpackages/android/HelloWorldAppProject/bin/HelloWorldApp.ap_.d	(revision 11527)
@@ -0,0 +1,4 @@
+/Users/gperez/HelloWorldAppProject/bin/HelloWorldApp.ap_ \
+ : /Users/gperez/HelloWorldAppProject/res/layout/main.xml \
+/Users/gperez/HelloWorldAppProject/res/values/strings.xml \
+/Users/gperez/HelloWorldAppProject/AndroidManifest.xml \
Index: /issm/trunk/externalpackages/android/HelloWorldAppProject/bin/build.prop
===================================================================
--- /issm/trunk/externalpackages/android/HelloWorldAppProject/bin/build.prop	(revision 11527)
+++ /issm/trunk/externalpackages/android/HelloWorldAppProject/bin/build.prop	(revision 11527)
@@ -0,0 +1,10 @@
+#Last build type
+#Tue, 21 Feb 2012 11:52:47 -0800
+
+build.last.target=debug
+
+build.last.is.instrumented=false
+
+build.last.is.packaging.debug=true
+
+build.last.is.signing.debug=true
Index: /issm/trunk/externalpackages/android/HelloWorldAppProject/bin/classes.dex.d
===================================================================
--- /issm/trunk/externalpackages/android/HelloWorldAppProject/bin/classes.dex.d	(revision 11527)
+++ /issm/trunk/externalpackages/android/HelloWorldAppProject/bin/classes.dex.d	(revision 11527)
@@ -0,0 +1,1 @@
+/Users/gperez/HelloWorldAppProject/bin/classes.dex : \
Index: /issm/trunk/externalpackages/android/HelloWorldAppProject/build.xml
===================================================================
--- /issm/trunk/externalpackages/android/HelloWorldAppProject/build.xml	(revision 11527)
+++ /issm/trunk/externalpackages/android/HelloWorldAppProject/build.xml	(revision 11527)
@@ -0,0 +1,85 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="HelloWorldApp" default="help">
+
+    <!-- The local.properties file is created and updated by the 'android' tool.
+         It contains the path to the SDK. It should *NOT* be checked into
+         Version Control Systems. -->
+    <property file="local.properties" />
+
+    <!-- The ant.properties file can be created by you. It is only edited by the
+         'android' tool to add properties to it.
+         This is the place to change some Ant specific build properties.
+         Here are some properties you may want to change/update:
+
+         source.dir
+             The name of the source directory. Default is 'src'.
+         out.dir
+             The name of the output directory. Default is 'bin'.
+
+         For other overridable properties, look at the beginning of the rules
+         files in the SDK, at tools/ant/build.xml
+
+         Properties related to the SDK location or the project target should
+         be updated using the 'android' tool with the 'update' action.
+
+         This file is an integral part of the build system for your
+         application and should be checked into Version Control Systems.
+
+         -->
+    <property file="ant.properties" />
+
+    <!-- The project.properties file is created and updated by the 'android'
+         tool, as well as ADT.
+
+         This contains project specific properties such as project target, and library
+         dependencies. Lower level build properties are stored in ant.properties
+         (or in .classpath for Eclipse projects).
+
+         This file is an integral part of the build system for your
+         application and should be checked into Version Control Systems. -->
+    <loadproperties srcFile="project.properties" />
+
+    <!-- quick check on sdk.dir -->
+    <fail
+            message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through an env var"
+            unless="sdk.dir"
+    />
+
+
+<!-- extension targets. Uncomment the ones where you want to do custom work
+     in between standard targets -->
+<!--
+    <target name="-pre-build">
+    </target>
+    <target name="-pre-compile">
+    </target>
+
+    /* This is typically used for code obfuscation.
+       Compiled code location: ${out.classes.absolute.dir}
+       If this is not done in place, override ${out.dex.input.absolute.dir} */
+    <target name="-post-compile">
+    </target>
+-->
+
+    <!-- Import the actual build file.
+
+         To customize existing targets, there are two options:
+         - Customize only one target:
+             - copy/paste the target into this file, *before* the
+               <import> task.
+             - customize it to your needs.
+         - Customize the whole content of build.xml
+             - copy/paste the content of the rules files (minus the top node)
+               into this file, replacing the <import> task.
+             - customize to your needs.
+
+         ***********************
+         ****** IMPORTANT ******
+         ***********************
+         In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
+         in order to avoid having your file be overridden by tools such as "android update project"
+    -->
+    <!-- version-tag: 1 -->
+    <import file="${sdk.dir}/tools/ant/build.xml" />
+
+</project>
Index: /issm/trunk/externalpackages/android/HelloWorldAppProject/gen/R.java.d
===================================================================
--- /issm/trunk/externalpackages/android/HelloWorldAppProject/gen/R.java.d	(revision 11527)
+++ /issm/trunk/externalpackages/android/HelloWorldAppProject/gen/R.java.d	(revision 11527)
@@ -0,0 +1,4 @@
+/Users/gperez/HelloWorldAppProject/gen/com/example/helloworld/R.java \
+ : /Users/gperez/HelloWorldAppProject/res/layout/main.xml \
+/Users/gperez/HelloWorldAppProject/res/values/strings.xml \
+/Users/gperez/HelloWorldAppProject/AndroidManifest.xml \
Index: /issm/trunk/externalpackages/android/HelloWorldAppProject/gen/com/example/helloworld/R.java
===================================================================
--- /issm/trunk/externalpackages/android/HelloWorldAppProject/gen/com/example/helloworld/R.java	(revision 11527)
+++ /issm/trunk/externalpackages/android/HelloWorldAppProject/gen/com/example/helloworld/R.java	(revision 11527)
@@ -0,0 +1,19 @@
+/* AUTO-GENERATED FILE.  DO NOT MODIFY.
+ *
+ * This class was automatically generated by the
+ * aapt tool from the resource data it found.  It
+ * should not be modified by hand.
+ */
+
+package com.example.helloworld;
+
+public final class R {
+    public static final class attr {
+    }
+    public static final class layout {
+        public static final int main=0x7f020000;
+    }
+    public static final class string {
+        public static final int app_name=0x7f030000;
+    }
+}
Index: /issm/trunk/externalpackages/android/HelloWorldAppProject/proguard.cfg
===================================================================
--- /issm/trunk/externalpackages/android/HelloWorldAppProject/proguard.cfg	(revision 11527)
+++ /issm/trunk/externalpackages/android/HelloWorldAppProject/proguard.cfg	(revision 11527)
@@ -0,0 +1,40 @@
+-optimizationpasses 5
+-dontusemixedcaseclassnames
+-dontskipnonpubliclibraryclasses
+-dontpreverify
+-verbose
+-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
+
+-keep public class * extends android.app.Activity
+-keep public class * extends android.app.Application
+-keep public class * extends android.app.Service
+-keep public class * extends android.content.BroadcastReceiver
+-keep public class * extends android.content.ContentProvider
+-keep public class * extends android.app.backup.BackupAgentHelper
+-keep public class * extends android.preference.Preference
+-keep public class com.android.vending.licensing.ILicensingService
+
+-keepclasseswithmembernames class * {
+    native <methods>;
+}
+
+-keepclasseswithmembers class * {
+    public <init>(android.content.Context, android.util.AttributeSet);
+}
+
+-keepclasseswithmembers class * {
+    public <init>(android.content.Context, android.util.AttributeSet, int);
+}
+
+-keepclassmembers class * extends android.app.Activity {
+   public void *(android.view.View);
+}
+
+-keepclassmembers enum * {
+    public static **[] values();
+    public static ** valueOf(java.lang.String);
+}
+
+-keep class * implements android.os.Parcelable {
+  public static final android.os.Parcelable$Creator *;
+}
Index: /issm/trunk/externalpackages/android/HelloWorldAppProject/project.properties
===================================================================
--- /issm/trunk/externalpackages/android/HelloWorldAppProject/project.properties	(revision 11527)
+++ /issm/trunk/externalpackages/android/HelloWorldAppProject/project.properties	(revision 11527)
@@ -0,0 +1,11 @@
+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must be checked in Version Control Systems.
+#
+# To customize properties used by the Ant build system use,
+# "ant.properties", and override values to adapt the script to your
+# project structure.
+
+# Project target.
+target=android-7
Index: /issm/trunk/externalpackages/android/HelloWorldAppProject/res/layout/main.xml
===================================================================
--- /issm/trunk/externalpackages/android/HelloWorldAppProject/res/layout/main.xml	(revision 11527)
+++ /issm/trunk/externalpackages/android/HelloWorldAppProject/res/layout/main.xml	(revision 11527)
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:orientation="vertical"
+    android:layout_width="fill_parent"
+    android:layout_height="fill_parent"
+    >
+<TextView  
+    android:layout_width="fill_parent" 
+    android:layout_height="wrap_content" 
+    android:text="Hello World, HelloWorldAppActivity"
+    />
+</LinearLayout>
+
Index: /issm/trunk/externalpackages/android/HelloWorldAppProject/res/values/strings.xml
===================================================================
--- /issm/trunk/externalpackages/android/HelloWorldAppProject/res/values/strings.xml	(revision 11527)
+++ /issm/trunk/externalpackages/android/HelloWorldAppProject/res/values/strings.xml	(revision 11527)
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+    <string name="app_name">HelloWorldAppActivity</string>
+</resources>
Index: /issm/trunk/externalpackages/android/HelloWorldAppProject/src/com/example/helloworld/HelloWorldAppActivity.java
===================================================================
--- /issm/trunk/externalpackages/android/HelloWorldAppProject/src/com/example/helloworld/HelloWorldAppActivity.java	(revision 11527)
+++ /issm/trunk/externalpackages/android/HelloWorldAppProject/src/com/example/helloworld/HelloWorldAppActivity.java	(revision 11527)
@@ -0,0 +1,15 @@
+package com.example.helloworld;
+
+import android.app.Activity;
+import android.os.Bundle;
+
+public class HelloWorldAppActivity extends Activity
+{
+    /** Called when the activity is first created. */
+    @Override
+    public void onCreate(Bundle savedInstanceState)
+    {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.main);
+    }
+}
Index: /issm/trunk/externalpackages/android/README
===================================================================
--- /issm/trunk/externalpackages/android/README	(revision 11527)
+++ /issm/trunk/externalpackages/android/README	(revision 11527)
@@ -0,0 +1,19 @@
+//Written by: Gilberto Perez
+//Last Modified 2/21/2012
+/*
+ * This is a temporary readme file for the installation of the Android emulator.
+ */
+1) Download the Android SDK <http://developer.android.com/sdk/index.html>. 
+2) Add to your PATH the following:
+	ANDROID_HOME=~/android-sdk-macosx
+	PATH=${PATH}:ANDROID_HOME/platforms/android-15/:~ANDROID_HOME/platform-tools/:ANDROID_HOME/tools/
+3) Run Android and install the newest Android distribution(as of the last update: android-15)
+4) Navigate to the project directory and run Android update project ./
+5) Run ant debug.
+6) Initiate an emulator by entering:
+	1) android list targets (this will produce a list of available of system image targets)
+	2) android create avd -n <name> -t<targetID> (Choose targetID to match android-15)
+7) Start up the emulator by entering: emulator -avd <avd_name>
+8) Install the app by entering: adb install <path_to_your_bin>.apk
+
+The app should be installed and ready to run from the virtual device!
Index: /issm/trunk/externalpackages/autoconf/install.sh
===================================================================
--- /issm/trunk/externalpackages/autoconf/install.sh	(revision 11526)
+++ /issm/trunk/externalpackages/autoconf/install.sh	(revision 11527)
@@ -2,5 +2,5 @@
 
 #Some cleanup
-rm -rf install autoconf-2.63 src
+rm -rf install autoconf-2.68 src
 
 #Create install directories
@@ -8,8 +8,8 @@
 
 #Untar 
-tar -zxvf  autoconf-2.63.tar.gz
+tar -zxvf  autoconf-2.68.tar.gz
 
 #Move autoconf into src directory
-mv autoconf-2.63 src
+mv autoconf-2.68 src
 
 #Compile autoconf
Index: /issm/trunk/externalpackages/automake/install.sh
===================================================================
--- /issm/trunk/externalpackages/automake/install.sh	(revision 11526)
+++ /issm/trunk/externalpackages/automake/install.sh	(revision 11527)
@@ -2,5 +2,5 @@
 
 #Some cleanup
-rm -rf install automake-1.10.2 src
+rm -rf install automake-1.11.3 src
 
 #Create install directories
@@ -8,6 +8,6 @@
 
 #Untar 
-tar -zxvf  automake-1.10.2.tar.gz
-mv automake-1.10.2 src
+tar -zxvf  automake-1.11.3.tar.gz
+mv automake-1.11.3 src
 
 #Compile automake
Index: /issm/trunk/externalpackages/bsdtar/install-win7.sh
===================================================================
--- /issm/trunk/externalpackages/bsdtar/install-win7.sh	(revision 11527)
+++ /issm/trunk/externalpackages/bsdtar/install-win7.sh	(revision 11527)
@@ -0,0 +1,17 @@
+#!/bin/bash
+
+#Some cleanup
+rm -rf install src libarchive-3.0.3
+mkdir install src
+
+#Untar 
+tar -zxvf  libarchive-3.0.3.tar.gz
+
+#Move libarchive into src directory
+mv libarchive-3.0.3/* src
+rm -rf libarchive-3.0.3
+
+cd src 
+./configure --prefix="$ISSM_TIER/externalpackages/bsdtar/install" 
+make
+make install
Index: /issm/trunk/externalpackages/cccl/install-win7.orig.sh
===================================================================
--- /issm/trunk/externalpackages/cccl/install-win7.orig.sh	(revision 11527)
+++ /issm/trunk/externalpackages/cccl/install-win7.orig.sh	(revision 11527)
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+#Some cleanup
+rm -rf src install cccl-0.03
+mkdir install src
+
+#Untar 
+tar -zxvf  cccl-0.03.tar.gz
+
+#Move cccl into install directory
+mv cccl-0.03/* src
+rm -rf cccl-0.03
+
+cd src 
+
+#Compile
+./configure --prefix="$ISSM_TIER/externalpackages/cccl/install"
+
+make
+make install
Index: /issm/trunk/externalpackages/cccl/install-win7.sh
===================================================================
--- /issm/trunk/externalpackages/cccl/install-win7.sh	(revision 11527)
+++ /issm/trunk/externalpackages/cccl/install-win7.sh	(revision 11527)
@@ -0,0 +1,9 @@
+#!/bin/bash
+
+#Some cleanup
+rm -rf install src cccl-0.03
+mkdir install 
+mkdir install/bin
+
+#Move cccl into install directory
+cp issm/cccl install/bin
Index: /issm/trunk/externalpackages/cccl/issm/cccl
===================================================================
--- /issm/trunk/externalpackages/cccl/issm/cccl	(revision 11527)
+++ /issm/trunk/externalpackages/cccl/issm/cccl	(revision 11527)
@@ -0,0 +1,90 @@
+#!/bin/sh
+
+# cccl 
+# Wrapper around MS's cl.exe and link.exe to make them act more like
+# Unix cc and ld
+#
+# Copyright (C) 2000-2003 Geoffrey Wossum (gwossum@acm.org)
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your optsion) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+
+usage()
+{
+    cat <<EOF
+Usage: cccl [OPTIONS]
+
+cccl is a wrapper around Microsoft's cl.exe and link.exe.  It translates
+parameters that Unix cc's and ld's understand to parameters that cl and link
+understand.
+EOF
+    exit $1
+}
+
+prog=cl
+
+### Run through every optsion and convert it to the proper MS one
+while test $# -gt 0; do
+
+    case "$1" in
+    --version)
+	cat <<EOF
+cccl 0.03
+
+Copyright 2000-2003 Geoffrey Wossum
+This is free software; see the source for copying conditions.  There is NO
+waranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+EOF
+	exit 1;
+	;;
+
+    -o)
+	# specifying output file, is it an object or an executable
+	shift
+	case "$1" in
+			
+		*.exe)
+			opts="$opts /Fe$1";
+		;;
+
+
+		*.mex*)
+			opts="$opts -o $1"
+		;;
+
+		*.o | *.obj)
+			opts="$opts /Fo$1"
+		;;
+
+		*)
+			opts="$opts /Fo$1"
+		;;
+    esac
+	;;
+	*)
+		#do nothing
+		opts="$opts $1"
+	;;
+
+	
+    esac
+    shift
+done
+
+echo "$prog $opts"
+exec $prog $opts
+exit 0
+
+    
Index: /issm/trunk/externalpackages/doxygen/install.sh
===================================================================
--- /issm/trunk/externalpackages/doxygen/install.sh	(revision 11526)
+++ /issm/trunk/externalpackages/doxygen/install.sh	(revision 11527)
@@ -1,23 +1,12 @@
 #!/bin/bash
 
-#wget http://ftp.stack.nl/pub/users/dimitri/doxygen-1.7.4.src.tar.gz
+#Some cleanup
+rm -rf install
 
-#Some cleanup
-rm -rf src
-rm -rf install
-rm -rf doxygen-1.7.4
-
-#Create src and install directories
-mkdir src install
-
-#Untar 
-tar -zxvf  doxygen-1.7.4.src.tar.gz
-
-#Move doxygen into src directory
-mv doxygen-1.7.4/* src
-rm -rf doxygen-1.7.4
+#Download latest version
+svn co https://doxygen.svn.sourceforge.net/svnroot/doxygen/trunk install
 
 #Configure doxygen
-cd src && ./configure --prefix "$ISSM_TIER/externalpackages/doxygen/install"
+cd install && ./configure --prefix "$ISSM_TIER/externalpackages/doxygen/install"
 if [ -z $1 ]; then
 	make
Index: sm/trunk/externalpackages/flaim/install
===================================================================
--- /issm/trunk/externalpackages/flaim/install	(revision 11526)
+++ 	(revision )
@@ -1,1 +1,0 @@
-link /proj/ice/larour/flaim/trunk/
Index: /issm/trunk/externalpackages/flaim/install.sh
===================================================================
--- /issm/trunk/externalpackages/flaim/install.sh	(revision 11526)
+++ /issm/trunk/externalpackages/flaim/install.sh	(revision 11527)
@@ -5,3 +5,3 @@
 
 #symlink to flaim directory
-ln -s /proj/ice/larour/flaim/trunk/ ./install
+ln -s /home/jschierm/flaim/svn/trunk ./install
Index: /issm/trunk/externalpackages/metis/configs/4.0/greenplanet/Makefile.in.patch
===================================================================
--- /issm/trunk/externalpackages/metis/configs/4.0/greenplanet/Makefile.in.patch	(revision 11527)
+++ /issm/trunk/externalpackages/metis/configs/4.0/greenplanet/Makefile.in.patch	(revision 11527)
@@ -0,0 +1,10 @@
+3,5c3
+< CC = gcc
+< OBJ_EXT=o
+< LIB_EXT=a
+---
+> CC = icc
+8c6
+< OPTFLAGS = -DLINUX -fPIC
+---
+> OPTFLAGS = -O3
Index: /issm/trunk/externalpackages/metis/configs/4.0/win7/Makefile.in.patch
===================================================================
--- /issm/trunk/externalpackages/metis/configs/4.0/win7/Makefile.in.patch	(revision 11527)
+++ /issm/trunk/externalpackages/metis/configs/4.0/win7/Makefile.in.patch	(revision 11527)
@@ -0,0 +1,25 @@
+3,5c3,5
+< CC = cl
+< OBJ_EXT=obj
+< LIB_EXT=lib
+---
+> CC = gcc
+> OBJ_EXT=o
+> LIB_EXT=a
+8c8
+< OPTFLAGS = -DWIN32 -D__VC__
+---
+> OPTFLAGS = -DLINUX -fPIC
+16,17c16,24
+< # What tool to use to create library
+< LIB=lib.exe
+---
+> # What archiving to use
+> AR = ar rv
+> 
+> # What to use for indexing the archive
+> RANLIB = ranlib
+> #RANLIB = ar -ts
+> #RANLIB = 
+> 
+> 
Index: /issm/trunk/externalpackages/metis/configs/4.0/win7/Makefile.patch
===================================================================
--- /issm/trunk/externalpackages/metis/configs/4.0/win7/Makefile.patch	(revision 11527)
+++ /issm/trunk/externalpackages/metis/configs/4.0/win7/Makefile.patch	(revision 11527)
@@ -0,0 +1,5 @@
+24c24,25
+< 	$(LIB) -out:$@ $(OBJS)
+---
+> 	$(AR) $@ $(OBJS)
+> 	$(RANLIB) $@
Index: /issm/trunk/externalpackages/metis/install-4.0-greenplanet.sh
===================================================================
--- /issm/trunk/externalpackages/metis/install-4.0-greenplanet.sh	(revision 11527)
+++ /issm/trunk/externalpackages/metis/install-4.0-greenplanet.sh	(revision 11527)
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+#Some cleanup
+rm -rf install metis-4.0
+mkdir install
+
+#Untar 
+tar -zxvf  metis-4.0.tar.gz
+
+#Move metis into install directory
+mv metis-4.0/* install
+rm -rf metis-4.0
+
+#Apply patches
+cd install 
+patch -p1 < ../metis-4.0.patch
+patch Makefile.in ../configs/4.0/greenplanet/Makefile.in.patch
+
+#Compile
+make
Index: /issm/trunk/externalpackages/metis/install-4.0-win7.sh
===================================================================
--- /issm/trunk/externalpackages/metis/install-4.0-win7.sh	(revision 11527)
+++ /issm/trunk/externalpackages/metis/install-4.0-win7.sh	(revision 11527)
@@ -0,0 +1,21 @@
+#!/bin/bash
+
+#Some cleanup
+rm -rf install metis-4.0
+mkdir install
+
+#Untar 
+tar -zxvf  metis-4.0.tar.gz
+
+#Move metis into install directory
+mv metis-4.0/* install
+rm -rf metis-4.0
+
+#Apply patches
+cd install 
+patch -p1 < ../metis-4.0.patch
+patch -R Lib/Makefile ../configs/4.0/win7/Makefile.patch
+patch -R Makefile.in ../configs/4.0/win7/Makefile.in.patch
+
+#Compile
+make
Index: /issm/trunk/externalpackages/petsc/install-2.3.2-win7.sh
===================================================================
--- /issm/trunk/externalpackages/petsc/install-2.3.2-win7.sh	(revision 11527)
+++ /issm/trunk/externalpackages/petsc/install-2.3.2-win7.sh	(revision 11527)
@@ -0,0 +1,25 @@
+#!/bin/bash
+
+#Some cleanup
+rm -rf install petsc-2.3.2-p3 src
+mkdir install src
+
+#Untar and move petsc to install directory
+tar -zxvf  petsc-2.3.2-p3.tar.gz
+mv petsc-2.3.2-p3/* install/
+rm -rf petsc-2.3.2-p3
+
+#configure
+cd install
+./config/configure.py  \
+	--with-parallel-no \
+	--prefix="$ISSM_TIER/externalpackages/petsc/install" \
+	--PETSC_ARCH=cygwin-intel \
+	--PETSC_DIR="$ISSM_TIER/externalpackages/petsc/install" \
+	--with-debugging=0 \
+	--with-mpi=0 \
+	--download-c-blas-lapack=1
+
+#Compile petsc and install it
+make
+make install
Index: /issm/trunk/externalpackages/petsc/install-3.1-win7.sh
===================================================================
--- /issm/trunk/externalpackages/petsc/install-3.1-win7.sh	(revision 11527)
+++ /issm/trunk/externalpackages/petsc/install-3.1-win7.sh	(revision 11527)
@@ -0,0 +1,44 @@
+#!/bin/bash
+
+#Some cleanup
+rm -rf install petsc-3.1-p7 src
+mkdir install src
+
+#Untar and move petsc to install directory
+tar -zxvf  petsc-3.1-p7.tar.gz
+mv petsc-3.1-p7/* src/
+rm -rf petsc-3.1-p7
+
+#configure
+cd src
+./config/configure.py  \
+	--with-parallel-no \
+	--prefix="$ISSM_TIER/externalpackages/petsc/install" \
+	--PETSC_ARCH=cygwin-intel \
+	--PETSC_DIR="$ISSM_TIER/externalpackages/petsc/src" \
+	--with-debugging=0 \
+	--with-mpi=0 \
+	--download-c-blas-lapack=1
+
+#./config/configure.py  \
+# --prefix="$ISSM_TIER/externalpackages/petsc/install" \
+# --PETSC_DIR="$ISSM_TIER/externalpackages/petsc/src" \
+# --PETSC_ARCH=macosx-gnu \
+# --with-mpi-dir=$ISSM_TIER/externalpackages/mpich2/install \
+# --with-debugging=0 \
+# --with-shared=0 \
+# --download-mumps=yes \
+# --download-scalapack=yes \
+# --download-blacs=yes \
+# --download-blas=yes \
+# --download-f-blas-lapack=yes \
+# --download-plapack=yes \
+# --FFLAGS="-I$ISSM_TIER/externalpackages/mpich2/install/include -arch i386" \
+# --COPTFLAGS="-march=opteron -O2 -arch i386" \
+# --FOPTFLAGS="-march=opteron -O2 -arch i386" \
+# --CXXOPTFLAGS="-march=opteron -O2 -arch i386" \
+# --download-parmetis=yes
+
+#Compile petsc and install it
+make
+make install
Index: /issm/trunk/externalpackages/petsc/install-3.2-greenplanet.sh
===================================================================
--- /issm/trunk/externalpackages/petsc/install-3.2-greenplanet.sh	(revision 11527)
+++ /issm/trunk/externalpackages/petsc/install-3.2-greenplanet.sh	(revision 11527)
@@ -0,0 +1,31 @@
+#!/bin/bash
+
+#Some cleanup
+rm -rf install petsc-3.2-p3 src
+mkdir install src
+
+#Untar and move petsc to install directory
+tar -zxvf  petsc-3.2-p3.tar.gz
+mv petsc-3.2-p3/* src/
+rm -rf petsc-3.2-p3
+
+#configure
+cd src
+./config/configure.py \
+	--prefix="$ISSM_TIER/externalpackages/petsc/install" \
+	--PETSC_DIR="$ISSM_TIER/externalpackages/petsc/src" \
+	--PETSC_ARCH="$ISSM_ARCH" \
+	--with-batch=1 \
+	--with-debugging=0 \
+	--with-shared-libraries=0 \
+	--known-mpi-shared-libraries=1 \
+	--with-mpi-dir=/sopt/mpi/openmpi-1.5.4_psm/intel/ \
+	--with-blas-lapack-dir=/opt/intel/mkl/10.2.4.032/ \
+	--download-mumps=yes \
+	--download-scalapack=yes \
+	--download-blacs=yes \
+	--download-plapack=yes \
+	--download-parmetis=yes \
+	--with-pic=1
+
+echo "== Follow PETSc's instructions"
Index: /issm/trunk/externalpackages/tao/install.sh
===================================================================
--- /issm/trunk/externalpackages/tao/install.sh	(revision 11526)
+++ /issm/trunk/externalpackages/tao/install.sh	(revision 11527)
@@ -1,14 +1,16 @@
 #!/bin/bash
+#http://www.mcs.anl.gov/research/projects/tao/download/index.html
+#wget http://www.mcs.anl.gov/research/projects/tao/download/tao-2.0-p3.tar.gz
 
 #Some cleanup
-rm -rf install tao-1.10.1-p1
+rm -rf install tao-2.0-p3
 mkdir install
 
 #Untar 
-tar -zxvf  tao-1.10.1-p1.tar.gz
+tar -zxvf  tao-2.0-p3.tar.gz
 
 #move into place
-mv tao-1.10.1-p1/* install/
-rm -rf tao-1.10.1-p1
+mv tao-2.0-p3/* install/
+rm -rf tao-2.0-p3
 cd install
 export TAO_DIR="$ISSM_TIER/externalpackages/tao/install/"
Index: /issm/trunk/externalpackages/triangle/configs/win7/configure.make
===================================================================
--- /issm/trunk/externalpackages/triangle/configs/win7/configure.make	(revision 11527)
+++ /issm/trunk/externalpackages/triangle/configs/win7/configure.make	(revision 11527)
@@ -0,0 +1,4 @@
+CC=cl
+CSWITCHES = $(CFLAGS) -I$(MATLAB_DIR)/extern/include  -I$(MATLAB_DIR)/include -DWIN32
+OBJ_EXT=obj
+LIB_EXT=lib
Index: /issm/trunk/externalpackages/triangle/configs/win7/makefile
===================================================================
--- /issm/trunk/externalpackages/triangle/configs/win7/makefile	(revision 11527)
+++ /issm/trunk/externalpackages/triangle/configs/win7/makefile	(revision 11527)
@@ -0,0 +1,21 @@
+#Adaptation of Triangle makefile to compile only the triangle.c file, 
+#into a standalone library that can then be used to compile mex modules
+
+include ./configure.make
+
+AR = ar
+
+TRILIBDEFS = -DTRILIBRARY
+
+all: triangle.$(LIB_EXT)
+
+OBJECTS=triangle.$(OBJ_EXT)
+
+triangle.$(LIB_EXT): $(OBJECTS)
+	lib -out:triangle.$(LIB_EXT) $(OBJECTS)
+
+triangle.$(OBJ_EXT): triangle.c triangle.h
+	$(CC) $(CSWITCHES) $(TRILIBDEFS) -c triangle.c
+
+clean: 
+	rm -rf *.$(LIB_EXT) *.$(OBJ_EXT) *.LIB *.LST *.$(OBJ_EXT)bj *.BAK
Index: /issm/trunk/externalpackages/triangle/install-win7.sh
===================================================================
--- /issm/trunk/externalpackages/triangle/install-win7.sh	(revision 11527)
+++ /issm/trunk/externalpackages/triangle/install-win7.sh	(revision 11527)
@@ -0,0 +1,23 @@
+#!/bin/bash
+
+#Some cleanup 
+rm -rf install triangle
+mkdir install
+
+#Untar 
+cd install
+cp ../triangle.zip ./
+unzip triangle.zip
+
+#copy new makefile
+cp ../configs/win7/configure.make ./
+cp ../configs/win7/makefile ./
+
+#Patch triangle.c 
+patch triangle.c ../triangle.c.patch
+
+#Compile triangle
+make
+
+#Patch triangle.h
+patch triangle.h ../triangle.h.patch
Index: /issm/trunk/externalpackages/vim/addons/vim/syntax/c.vim
===================================================================
--- /issm/trunk/externalpackages/vim/addons/vim/syntax/c.vim	(revision 11526)
+++ /issm/trunk/externalpackages/vim/addons/vim/syntax/c.vim	(revision 11527)
@@ -404,5 +404,5 @@
 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
 "ISSM containers:
-syn keyword	cType		Constraints DataSet Elements Inputs Loads Materials Parameters Results Vertices
+syn keyword	cType		Constraints DataSet Elements Inputs Loads Materials Nodes Parameters Results Vertices
 "Petsc
 syn keyword	cType		Vec Mat 
@@ -434,4 +434,5 @@
 syn keyword cType Pengrid
 syn keyword cType Element
+syn keyword cType Load
 syn keyword cType Penta
 syn keyword cType PentaHook
@@ -465,4 +466,5 @@
 syn keyword cType KML_StyleSelector
 syn keyword cType KML_SubStyle
+syn keyword cType KML_Unknown
 syn keyword cType KMLFileReadUtils
 syn keyword cType Option
@@ -477,6 +479,6 @@
 syn keyword cType DoubleInput
 syn keyword cType IntInput
-syn keyword cType PentaVertexInput
-syn keyword cType TriaVertexInput
+syn keyword cType PentaP1Input
+syn keyword cType TriaP1Input
 syn keyword cType ControlInput
 syn keyword cType DatasetInput
@@ -484,6 +486,6 @@
 syn keyword cType ElementResult
 syn keyword cType DoubleElementResult
-syn keyword cType TriaVertexElementResult
-syn keyword cType PentaVertexElementResult
+syn keyword cType TriaP1ElementResult
+syn keyword cType PentaP1ElementResult
 syn keyword cType BoolElementResult
 syn keyword cType ExternalResult
@@ -562,4 +564,5 @@
 syn keyword cConstant DiagnosticAbstolEnum
 syn keyword cConstant DiagnosticIcefrontEnum
+syn keyword cConstant DiagnosticIsnewtonEnum
 syn keyword cConstant DiagnosticMaxiterEnum
 syn keyword cConstant DiagnosticNumRequestedOutputsEnum
@@ -605,4 +608,5 @@
 syn keyword cConstant InversionGradientScalingEnum
 syn keyword cConstant InversionIscontrolEnum
+syn keyword cConstant InversionTaoEnum
 syn keyword cConstant InversionMaxParametersEnum
 syn keyword cConstant InversionMaxiterPerStepEnum
@@ -660,4 +664,5 @@
 syn keyword cConstant MiscellaneousNameEnum
 syn keyword cConstant PrognosticHydrostaticAdjustmentEnum
+syn keyword cConstant PrognosticMinThicknessEnum
 syn keyword cConstant PrognosticPenaltyFactorEnum
 syn keyword cConstant PrognosticSpcthicknessEnum
@@ -785,5 +790,5 @@
 syn keyword cConstant PenpairEnum
 syn keyword cConstant PentaEnum
-syn keyword cConstant PentaVertexInputEnum
+syn keyword cConstant PentaP1InputEnum
 syn keyword cConstant PetscMatParamEnum
 syn keyword cConstant PetscVecParamEnum
@@ -798,5 +803,5 @@
 syn keyword cConstant StringParamEnum
 syn keyword cConstant TriaEnum
-syn keyword cConstant TriaVertexInputEnum
+syn keyword cConstant TriaP1InputEnum
 syn keyword cConstant VertexEnum
 syn keyword cConstant AirEnum
@@ -885,4 +890,11 @@
 syn keyword cConstant HydrologyWaterVxEnum
 syn keyword cConstant HydrologyWaterVyEnum
+syn keyword cConstant StressTensorEnum
+syn keyword cConstant StressTensorxxEnum
+syn keyword cConstant StressTensorxyEnum
+syn keyword cConstant StressTensorxzEnum
+syn keyword cConstant StressTensoryyEnum
+syn keyword cConstant StressTensoryzEnum
+syn keyword cConstant StressTensorzzEnum
 syn keyword cConstant IceVolumeEnum
 syn keyword cConstant P0Enum
@@ -900,9 +912,9 @@
 syn keyword cConstant PatchNodesEnum
 syn keyword cConstant PatchVerticesEnum
-syn keyword cConstant PentaVertexElementResultEnum
+syn keyword cConstant PentaP1ElementResultEnum
 syn keyword cConstant PetscVecExternalResultEnum
 syn keyword cConstant StringExternalResultEnum
 syn keyword cConstant TimeEnum
-syn keyword cConstant TriaVertexElementResultEnum
+syn keyword cConstant TriaP1ElementResultEnum
 syn keyword cConstant WaterColumnOldEnum
 syn keyword cConstant MinVelEnum
Index: /issm/trunk/externalpackages/win7/notes
===================================================================
--- /issm/trunk/externalpackages/win7/notes	(revision 11527)
+++ /issm/trunk/externalpackages/win7/notes	(revision 11527)
@@ -0,0 +1,8 @@
+Compiling ISSM using Matlab compatible  compilers. 
+
+At: http://www.mathworks.com/support/compilers/R2011b/win64.html#n2 
+you will find a list of Matlab supported compilers. 
+
+
+
+We'll try the compile with the Microsoft Windows SDK 7.1: http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=8279
Index: /issm/trunk/externalpackages/win7/sdk7.1.32bits.sh
===================================================================
--- /issm/trunk/externalpackages/win7/sdk7.1.32bits.sh	(revision 11527)
+++ /issm/trunk/externalpackages/win7/sdk7.1.32bits.sh	(revision 11527)
@@ -0,0 +1,73 @@
+declare -x ALLUSERSPROFILE="C:\\ProgramData"
+declare -x APPDATA="C:\\Users\\larour\\AppData\\Roaming"
+declare -x APPVER="6.1"
+declare -x CL="/AI C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319"
+declare -x COMMONPROGRAMFILES="C:\\Program Files (x86)\\Common Files"
+declare -x COMPUTERNAME="WIN-IH1FCG0JVB1"
+declare -x COMSPEC="C:\\Windows\\system32\\cmd.exe"
+declare -x CURRENT_CPU="x64"
+declare -x CommandPromptType="Cross"
+declare -x CommonProgramW6432="C:\\Program Files\\Common Files"
+declare -x Configuration="Debug"
+declare -x FP_NO_HOST_CHECK="NO"
+declare -x FrameworkVersion="v4.0.30319"
+declare -x GREP_COLOR="00;38;5;226"
+declare -x GREP_OPTIONS="--binary-file=without-match"
+declare -x HOME="/home/larour"
+declare -x HOMEDRIVE="C:"
+declare -x HOMEPATH="\\Users\\larour"
+declare -x HOSTNAME="WIN-IH1FCG0JVB1"
+declare -x INCLUDE="C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\INCLUDE;C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\INCLUDE;C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\INCLUDE\\gl;C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\ATLMFC\\INCLUDE;"
+declare -x INFOPATH="/usr/local/info:/usr/share/info:/usr/info:"
+declare -x LANG="en_US.UTF-8"
+declare -x LIB="C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\Lib;C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\Lib;C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319;C:\\Windows\\Microsoft.NET\\Framework\\v3.5;;C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\ATLMFC\\LIB;"
+declare -x LIBPATH="C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319;C:\\Windows\\Microsoft.NET\\Framework\\v3.5;;C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\Lib;"
+declare -x LOCALAPPDATA="C:\\Users\\larour\\AppData\\Local"
+declare -x LOGONSERVER="\\\\WIN-IH1FCG0JVB1"
+declare -x MANPATH="/usr/local/man:/usr/share/man:/usr/man:"
+declare -x NUMBER_OF_PROCESSORS="8"
+declare -x OS="Windows_NT"
+declare -x PATH="/usr/local/bin:/usr/bin:/cygdrive/c/Windows/Microsoft.NET/Framework/v4.0.30319:/cygdrive/c/Windows/Microsoft.NET/Framework/v3.5:/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 10.0/Common7/IDE:/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 10.0/Common7/Tools:/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 10.0/VC/Bin:/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 10.0/VC/Bin/VCPackages:/cygdrive/c/Program Files/Microsoft SDKs/Windows/v7.1/Bin/NETFX 4.0 Tools:/cygdrive/c/Program Files/Microsoft SDKs/Windows/v7.1/Bin:/cygdrive/c/Windows/system32:/cygdrive/c/Windows:/cygdrive/c/Windows/System32/Wbem:/cygdrive/c/Windows/System32/WindowsPowerShell/v1.0:/cygdrive/c/Program Files/Microsoft Windows Performance Toolkit:/cygdrive/c/MATLAB/R2011b32/runtime/win32:/cygdrive/c/MATLAB/R2011b32/bin:/cygdrive/c/MATLAB/R2011b/runtime/win64:/cygdrive/c/MATLAB/R2011b/bin:/cygdrive/c/Program Files (x86)/Microsoft SQL Server/100/Tools/Binn:/cygdrive/c/Program Files/Microsoft SQL Server/100/Tools/Binn:/cygdrive/c/Program Files/Microsoft SQL Server/100/DTS/Binn:/cygdrive/c/Program Files/Microsoft Network Monitor 3"
+declare -x PATHEXT=".COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC"
+declare -x PRINTER="137.78.140.129#:1"
+declare -x PROCESSOR_ARCHITECTURE="x86"
+declare -x PROCESSOR_ARCHITEW6432="AMD64"
+declare -x PROCESSOR_IDENTIFIER="Intel64 Family 6 Model 42 Stepping 7, GenuineIntel"
+declare -x PROCESSOR_LEVEL="6"
+declare -x PROCESSOR_REVISION="2a07"
+declare -x PROGRAMFILES="C:\\Program Files (x86)"
+declare -x PROMPT="\$P\$G"
+declare -x PS1="\\[\\e]0;\\w\\a\\]\\n\\[\\e[32m\\]\\u@\\h \\[\\e[33m\\]\\w\\[\\e[0m\\]\\n\\\$ "
+declare -x PSModulePath="C:\\Windows\\system32\\WindowsPowerShell\\v1.0\\Modules\\"
+declare -x PUBLIC="C:\\Users\\Public"
+declare -x PWD="/cygdrive/c/issm-uci/trunk-jpl-32/externalpackages/win7"
+declare -x PlatformToolset="Windows7.1SDK"
+declare -x ProgramData="C:\\ProgramData"
+declare -x ProgramW6432="C:\\Program Files"
+declare -x REPO="jpl"
+declare -x SESSIONNAME="Console"
+declare -x SHELL="/bin/bash"
+declare -x SHLVL="1"
+declare -x SVN_EDITOR="/usr/bin/vim"
+declare -x SYSTEMDRIVE="C:"
+declare -x SYSTEMROOT="C:\\Windows"
+declare -x TARGET_CPU="x86"
+declare -x TARGET_PLATFORM="WIN7"
+declare -x TEMP="/tmp"
+declare -x TERM="cygwin"
+declare -x TMP="/tmp"
+declare -x TZ="America/Los_Angeles"
+declare -x ToolsVersion="4.0"
+declare -x USER="larour"
+declare -x USERDOMAIN="WIN-IH1FCG0JVB1"
+declare -x USERNAME="larour"
+declare -x USERPROFILE="C:\\Users\\larour"
+declare -x VS100COMNTOOLS="C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\Common7\\Tools\\"
+declare -x WINDIR="C:\\Windows"
+declare -x WindowsSDKDir="C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\"
+declare -x WindowsSDKVersionOverride="v7.1"
+declare -x sdkdir="C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\"
+declare -x temp="C:\\Users\\larour\\AppData\\Local\\Temp"
+declare -x tmp="C:\\Users\\larour\\AppData\\Local\\Temp"
+declare -x windows_tracing_flags="3"
+declare -x windows_tracing_logfile="C:\\BVTBin\\Tests\\installpackage\\csilogfile.log"
Index: /issm/trunk/externalpackages/win7/sdk7.1.64bits.sh
===================================================================
--- /issm/trunk/externalpackages/win7/sdk7.1.64bits.sh	(revision 11527)
+++ /issm/trunk/externalpackages/win7/sdk7.1.64bits.sh	(revision 11527)
@@ -0,0 +1,69 @@
+declare -x ALLUSERSPROFILE="C:\\ProgramData"
+declare -x APPDATA="C:\\Users\\larour\\AppData\\Roaming"
+declare -x APPVER="6.1"
+declare -x CL="/AI C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319"
+declare -x COMMONPROGRAMFILES="C:\\Program Files (x86)\\Common Files"
+declare -x COMPUTERNAME="WIN-IH1FCG0JVB1"
+declare -x COMSPEC="C:\\Windows\\system32\\cmd.exe"
+declare -x CURRENT_CPU="x64"
+declare -x CommandPromptType="Native"
+declare -x CommonProgramW6432="C:\\Program Files\\Common Files"
+declare -x Configuration="Debug"
+declare -x FP_NO_HOST_CHECK="NO"
+declare -x FrameworkVersion="v4.0.30319"
+declare -x GREP_COLOR="00;38;5;226"
+declare -x GREP_OPTIONS="--binary-file=without-match"
+declare -x HOME="/home/larour"
+declare -x HOMEDRIVE="C:"
+declare -x HOMEPATH="\\Users\\larour"
+declare -x HOSTNAME="WIN-IH1FCG0JVB1"
+declare -x INCLUDE="C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\INCLUDE;C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\INCLUDE;C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\INCLUDE\\gl;"
+declare -x INFOPATH="/usr/local/info:/usr/share/info:/usr/info:"
+declare -x LANG="C.UTF-8"
+declare -x LIB="C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\Lib\\amd64;C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\Lib\\X64;"
+declare -x LIBPATH="C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319;C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319;C:\\Windows\\Microsoft.NET\\Framework64\\v3.5;C:\\Windows\\Microsoft.NET\\Framework\\v3.5;;C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\Lib\\amd64;"
+declare -x LOCALAPPDATA="C:\\Users\\larour\\AppData\\Local"
+declare -x LOGONSERVER="\\\\WIN-IH1FCG0JVB1"
+declare -x MANPATH="/usr/local/man:/usr/share/man:/usr/man:"
+declare -x NUMBER_OF_PROCESSORS="1"
+declare -x OLDPWD="/cygdrive/c/issm-uci/trunk-jpl/externalpackages"
+declare -x OS="Windows_NT"
+declare -x PATH="/usr/local/bin:/usr/bin:/cygdrive/c/Windows/Microsoft.NET/Framework64/v4.0.30319:/cygdrive/c/Windows/Microsoft.NET/Framework/v4.0.30319:/cygdrive/c/Windows/Microsoft.NET/Framework64/v3.5:/cygdrive/c/Windows/Microsoft.NET/Framework/v3.5:/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 10.0/Common7/IDE:/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 10.0/Common7/Tools:/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 10.0/VC/Bin/amd64:/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 10.0/VC/Bin/VCPackages:/cygdrive/c/Program Files/Microsoft SDKs/Windows/v7.1/Bin/NETFX 4.0 Tools/x64:/cygdrive/c/Program Files/Microsoft SDKs/Windows/v7.1/Bin/x64:/cygdrive/c/Program Files/Microsoft SDKs/Windows/v7.1/Bin:/cygdrive/c/Windows/system32:/cygdrive/c/Windows:/cygdrive/c/Windows/System32/Wbem:/cygdrive/c/Windows/System32/WindowsPowerShell/v1.0:/cygdrive/c/Program Files/Microsoft Windows Performance Toolkit:/cygdrive/c/MATLAB/R2011b/runtime/win64:/cygdrive/c/MATLAB/R2011b/bin"
+declare -x PATHEXT=".COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC"
+declare -x PRINTER="137.78.140.129#:1"
+declare -x PROCESSOR_ARCHITECTURE="x86"
+declare -x PROCESSOR_ARCHITEW6432="AMD64"
+declare -x PROCESSOR_IDENTIFIER="Intel64 Family 6 Model 42 Stepping 7, GenuineIntel"
+declare -x PROCESSOR_LEVEL="6"
+declare -x PROCESSOR_REVISION="2a07"
+declare -x PROGRAMFILES="C:\\Program Files (x86)"
+declare -x PROMPT="\$P\$G"
+declare -x PS1="\\[\\e]0;\\w\\a\\]\\n\\[\\e[32m\\]\\u@\\h \\[\\e[33m\\]\\w\\[\\e[0m\\]\\n\\\$ "
+declare -x PSModulePath="C:\\Windows\\system32\\WindowsPowerShell\\v1.0\\Modules\\"
+declare -x PUBLIC="C:\\Users\\Public"
+declare -x PWD="/cygdrive/c/issm-uci/trunk-jpl/externalpackages/win7"
+declare -x PlatformToolset="Windows7.1SDK"
+declare -x ProgramData="C:\\ProgramData"
+declare -x ProgramW6432="C:\\Program Files"
+declare -x REPO="jpl"
+declare -x SESSIONNAME="Console"
+declare -x SHLVL="1"
+declare -x SYSTEMDRIVE="C:"
+declare -x SYSTEMROOT="C:\\Windows"
+declare -x TARGET_CPU="x64"
+declare -x TARGET_PLATFORM="WIN7"
+declare -x TEMP="/tmp"
+declare -x TERM="cygwin"
+declare -x TMP="/tmp"
+declare -x ToolsVersion="4.0"
+declare -x USER="larour"
+declare -x USERDOMAIN="WIN-IH1FCG0JVB1"
+declare -x USERNAME="larour"
+declare -x USERPROFILE="C:\\Users\\larour"
+declare -x VS100COMNTOOLS="C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\Common7\\Tools\\"
+declare -x WINDIR="C:\\Windows"
+declare -x WindowsSDKDir="C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\"
+declare -x WindowsSDKVersionOverride="v7.1"
+declare -x sdkdir="C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\"
+declare -x windows_tracing_flags="3"
+declare -x windows_tracing_logfile="C:\\BVTBin\\Tests\\installpackage\\csilogfile.log"
Index: /issm/trunk/externalpackages/win7/vs10.0.sh
===================================================================
--- /issm/trunk/externalpackages/win7/vs10.0.sh	(revision 11527)
+++ /issm/trunk/externalpackages/win7/vs10.0.sh	(revision 11527)
@@ -0,0 +1,64 @@
+declare -x ALLUSERSPROFILE="C:\\ProgramData"
+declare -x APPDATA="C:\\Users\\larour\\AppData\\Roaming"
+declare -x COMMONPROGRAMFILES="C:\\Program Files (x86)\\Common Files"
+declare -x COMPUTERNAME="WIN-IH1FCG0JVB1"
+declare -x COMSPEC="C:\\Windows\\system32\\cmd.exe"
+declare -x CommonProgramW6432="C:\\Program Files\\Common Files"
+declare -x DevEnvDir="C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\Common7\\IDE\\"
+declare -x FP_NO_HOST_CHECK="NO"
+declare -x Framework35Version="v3.5"
+declare -x FrameworkDIR32="C:\\Windows\\Microsoft.NET\\Framework\\"
+declare -x FrameworkDir="C:\\Windows\\Microsoft.NET\\Framework\\"
+declare -x FrameworkVersion="v4.0.30319"
+declare -x FrameworkVersion32="v4.0.30319"
+declare -x GREP_COLOR="00;38;5;226"
+declare -x GREP_OPTIONS="--binary-file=without-match"
+declare -x HOME="/home/larour"
+declare -x HOMEDRIVE="C:"
+declare -x HOMEPATH="\\Users\\larour"
+declare -x HOSTNAME="WIN-IH1FCG0JVB1"
+declare -x INCLUDE="C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\INCLUDE;C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v7.0A\\include;"
+declare -x INFOPATH="/usr/local/info:/usr/share/info:/usr/info:"
+declare -x LANG="C.UTF-8"
+declare -x LIB="C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\LIB;C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v7.0A\\lib;"
+declare -x LIBPATH="C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319;C:\\Windows\\Microsoft.NET\\Framework\\v3.5;C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\LIB;"
+declare -x LOCALAPPDATA="C:\\Users\\larour\\AppData\\Local"
+declare -x LOGONSERVER="\\\\WIN-IH1FCG0JVB1"
+declare -x MANPATH="/usr/local/man:/usr/share/man:/usr/man:"
+declare -x NUMBER_OF_PROCESSORS="1"
+declare -x OLDPWD="/cygdrive/c/issm-uci/trunk-jpl"
+declare -x OS="Windows_NT"
+declare -x PATH="/usr/local/bin:/usr/bin:/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 10.0/Common7/IDE:/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 10.0/VC/BIN:/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 10.0/Common7/Tools:/cygdrive/c/Windows/Microsoft.NET/Framework/v4.0.30319:/cygdrive/c/Windows/Microsoft.NET/Framework/v3.5:/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 10.0/VC/VCPackages:/cygdrive/c/Program Files (x86)/Microsoft SDKs/Windows/v7.0A/bin/NETFX 4.0 Tools:/cygdrive/c/Program Files (x86)/Microsoft SDKs/Windows/v7.0A/bin:/cygdrive/c/Windows/system32:/cygdrive/c/Windows:/cygdrive/c/Windows/System32/Wbem:/cygdrive/c/Windows/System32/WindowsPowerShell/v1.0:/cygdrive/c/Program Files/Microsoft Windows Performance Toolkit"
+declare -x PATHEXT=".COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC"
+declare -x PRINTER="137.78.140.129#:1"
+declare -x PROCESSOR_ARCHITECTURE="x86"
+declare -x PROCESSOR_ARCHITEW6432="AMD64"
+declare -x PROCESSOR_IDENTIFIER="Intel64 Family 6 Model 42 Stepping 7, GenuineIntel"
+declare -x PROCESSOR_LEVEL="6"
+declare -x PROCESSOR_REVISION="2a07"
+declare -x PROGRAMFILES="C:\\Program Files (x86)"
+declare -x PROMPT="\$P\$G"
+declare -x PS1="\\[\\e]0;\\w\\a\\]\\n\\[\\e[32m\\]\\u@\\h \\[\\e[33m\\]\\w\\[\\e[0m\\]\\n\\\$ "
+declare -x PSModulePath="C:\\Windows\\system32\\WindowsPowerShell\\v1.0\\Modules\\"
+declare -x PUBLIC="C:\\Users\\Public"
+declare -x ProgramData="C:\\ProgramData"
+declare -x ProgramW6432="C:\\Program Files"
+declare -x REPO="jpl"
+declare -x SESSIONNAME="Console"
+declare -x SHLVL="1"
+declare -x SYSTEMDRIVE="C:"
+declare -x SYSTEMROOT="C:\\Windows"
+declare -x TEMP="/tmp"
+declare -x TERM="cygwin"
+declare -x TMP="/tmp"
+declare -x USER="larour"
+declare -x USERDOMAIN="WIN-IH1FCG0JVB1"
+declare -x USERNAME="larour"
+declare -x USERPROFILE="C:\\Users\\larour"
+declare -x VCINSTALLDIR="C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\"
+declare -x VS100COMNTOOLS="C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\Common7\\Tools\\"
+declare -x VSINSTALLDIR="C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\"
+declare -x WINDIR="C:\\Windows"
+declare -x WindowsSdkDir="C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v7.0A\\"
+declare -x windows_tracing_flags="3"
+declare -x windows_tracing_logfile="C:\\BVTBin\\Tests\\installpackage\\csilogfile.log"
Index: /issm/trunk/installers/macosx/ISSM.pmdoc/index.xml
===================================================================
--- /issm/trunk/installers/macosx/ISSM.pmdoc/index.xml	(revision 11527)
+++ /issm/trunk/installers/macosx/ISSM.pmdoc/index.xml	(revision 11527)
@@ -0,0 +1,1 @@
+<pkmkdoc spec="1.12"><properties><organization>http://issm.jpl.nasa.gov</organization><userSees ui="easy"/><min-target os="3"/><domain anywhere="true"/></properties><distribution><versions min-spec="1.000000"/><scripts></scripts></distribution><contents/><resources bg-scale="none" bg-align="topleft"><locale lang="en"/></resources><flags/></pkmkdoc>
Index: /issm/trunk/installers/win7/ISSM.initial.aip
===================================================================
--- /issm/trunk/installers/win7/ISSM.initial.aip	(revision 11527)
+++ /issm/trunk/installers/win7/ISSM.initial.aip	(revision 11527)
@@ -0,0 +1,146 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<DOCUMENT Type="Advanced Installer" CreateVersion="8.9" version="8.9" Modules="simple" RootPath="." Language="en" Id="{36DC7549-63BC-4A22-AE82-A96C27BF7B21}">
+  <COMPONENT cid="caphyon.advinst.msicomp.MsiPropsComponent">
+    <ROW Property="ALLUSERS" Value="2"/>
+    <ROW Property="ARPCOMMENTS" Value="This installer database contains the logic and data required to install [|ProductName]." ValueLocId="*"/>
+    <ROW Property="ARPCONTACT" Value="Eric Larour, Helene Seroussi and Mathieu Morlighem"/>
+    <ROW Property="ARPHELPTELEPHONE" Value="001 (818) 393-2435"/>
+    <ROW Property="ARPURLINFOABOUT" Value="http://issm.jpl.nasa.gov"/>
+    <ROW Property="CTRLS" Value="1"/>
+    <ROW Property="Manufacturer" Value="JPL-UCI" ValueLocId="*"/>
+    <ROW Property="ProductCode" Value="1033:{387D11EC-1489-4A6F-8CA2-BA65601C19BE} " Type="16"/>
+    <ROW Property="ProductLanguage" Value="1033"/>
+    <ROW Property="ProductName" Value="ISSM" ValueLocId="*"/>
+    <ROW Property="ProductVersion" Value="1.0"/>
+    <ROW Property="SecureCustomProperties" Value="OLDPRODUCTS;AI_NEWERPRODUCTFOUND"/>
+    <ROW Property="UpgradeCode" Value="{F12D1A74-5079-41A3-A02A-15754B89E390}"/>
+    <ROW Property="VIEWREADME" Value="1" Type="4"/>
+    <ROW Property="WindowsType9X" MultiBuildValue="DefaultBuild:Windows 9x/ME" ValueLocId="-"/>
+    <ROW Property="WindowsType9XDisplay" MultiBuildValue="DefaultBuild:Windows 9x/ME" ValueLocId="-"/>
+  </COMPONENT>
+  <COMPONENT cid="caphyon.advinst.msicomp.MsiDirsComponent">
+    <ROW Directory="APPDIR" Directory_Parent="TARGETDIR" DefaultDir="APPDIR:." IsPseudoRoot="1"/>
+    <ROW Directory="AppDataFolder" Directory_Parent="TARGETDIR" DefaultDir="AppDat~1|AppDataFolder" IsPseudoRoot="1"/>
+    <ROW Directory="DesktopFolder" Directory_Parent="TARGETDIR" DefaultDir="Deskto~1|DesktopFolder" IsPseudoRoot="1"/>
+    <ROW Directory="InternetExplorer_Dir" Directory_Parent="Microsoft_Dir" DefaultDir="Intern~1|Internet Explorer"/>
+    <ROW Directory="Microsoft_Dir" Directory_Parent="AppDataFolder" DefaultDir="Micros~1|Microsoft"/>
+    <ROW Directory="QuickLaunch_Dir" Directory_Parent="InternetExplorer_Dir" DefaultDir="QuickL~1|Quick Launch"/>
+    <ROW Directory="SHORTCUTDIR" Directory_Parent="TARGETDIR" DefaultDir="SHORTC~1|SHORTCUTDIR" IsPseudoRoot="1"/>
+    <ROW Directory="StartMenuFolder" Directory_Parent="TARGETDIR" DefaultDir="StartM~1|StartMenuFolder" IsPseudoRoot="1"/>
+    <ROW Directory="TARGETDIR" DefaultDir="SourceDir"/>
+  </COMPONENT>
+  <COMPONENT cid="caphyon.advinst.msicomp.MsiCompsComponent">
+    <ROW Component="ProductInformation" ComponentId="{9BA1DCE1-2716-4161-BFC1-9427FF450B3F}" Directory_="APPDIR" Attributes="4" KeyPath="Version"/>
+    <ROW Component="QuickLaunch" ComponentId="{73BCCA29-216A-4FD5-A030-FFEAC0435857}" Directory_="QuickLaunch_Dir" Attributes="0"/>
+    <ROW Component="SHORTCUTDIR" ComponentId="{92285889-F321-4F14-B289-6895275D45D7}" Directory_="SHORTCUTDIR" Attributes="0"/>
+    <ROW Component="matlabissm.bat" ComponentId="{239E0327-22CA-433B-B84D-609A42F7F608}" Directory_="APPDIR" Attributes="0" KeyPath="matlabissm.bat" Type="0"/>
+  </COMPONENT>
+  <COMPONENT cid="caphyon.advinst.msicomp.MsiFeatsComponent">
+    <ROW Feature="MainFeature" Title="MainFeature" Description="Description" Display="1" Level="1" Directory_="APPDIR" Attributes="0" Components="ProductInformation QuickLaunch SHORTCUTDIR matlabissm.bat"/>
+    <ATTRIBUTE name="CurrentFeature" value="MainFeature"/>
+  </COMPONENT>
+  <COMPONENT cid="caphyon.advinst.msicomp.MsiFilesComponent">
+    <ROW File="README.rtf" Component_="matlabissm.bat" FileName="README.rtf" Attributes="0" SourcePath="..\..\bin\README.rtf" SelfReg="false"/>
+    <ROW File="matlabissm.bat" Component_="matlabissm.bat" FileName="matlab~1.bat|matlabissm.bat" Attributes="0" SourcePath="..\..\scripts\matlabissm.bat" SelfReg="false" NextFile="README.rtf"/>
+  </COMPONENT>
+  <COMPONENT cid="caphyon.advinst.msicomp.BuildComponent">
+    <ROW BuildKey="DefaultBuild" BuildName="DefaultBuild" BuildOrder="1" BuildType="0" Languages="en" InstallationType="4" MsiPackageType="x64"/>
+    <ATTRIBUTE name="CurrentBuild" value="DefaultBuild"/>
+  </COMPONENT>
+  <COMPONENT cid="caphyon.advinst.msicomp.CacheComponent">
+    <ATTRIBUTE name="Enable" value="false"/>
+  </COMPONENT>
+  <COMPONENT cid="caphyon.advinst.msicomp.DictionaryComponent">
+    <ROW Path="&lt;AI_DICTS&gt;ui.ail"/>
+    <ROW Path="&lt;AI_DICTS&gt;ui_en.ail"/>
+  </COMPONENT>
+  <COMPONENT cid="caphyon.advinst.msicomp.FragmentComponent">
+    <ROW Fragment="CommonUI.aip" Path="&lt;AI_FRAGS&gt;CommonUI.aip"/>
+    <ROW Fragment="FolderDlg.aip" Path="&lt;AI_THEMES&gt;classic\fragments\FolderDlg.aip"/>
+    <ROW Fragment="SequenceDialogs.aip" Path="&lt;AI_THEMES&gt;classic\fragments\SequenceDialogs.aip"/>
+    <ROW Fragment="Sequences.aip" Path="&lt;AI_FRAGS&gt;Sequences.aip"/>
+    <ROW Fragment="StaticUIStrings.aip" Path="&lt;AI_FRAGS&gt;StaticUIStrings.aip"/>
+    <ROW Fragment="UI.aip" Path="&lt;AI_THEMES&gt;classic\fragments\UI.aip"/>
+    <ROW Fragment="Validation.aip" Path="&lt;AI_FRAGS&gt;Validation.aip"/>
+  </COMPONENT>
+  <COMPONENT cid="caphyon.advinst.msicomp.MsiBinaryComponent">
+    <ROW Name="aicustact.dll" SourcePath="&lt;AI_CUSTACTS&gt;aicustact.dll"/>
+  </COMPONENT>
+  <COMPONENT cid="caphyon.advinst.msicomp.MsiControlComponent">
+    <ATTRIBUTE name="FixedSizeBitmaps" value="0"/>
+  </COMPONENT>
+  <COMPONENT cid="caphyon.advinst.msicomp.MsiControlEventComponent">
+    <ROW Dialog_="FolderDlg" Control_="Back" Event="NewDialog" Argument="WelcomeDlg" Condition="AI_INSTALL" Ordering="1"/>
+    <ROW Dialog_="WelcomeDlg" Control_="Next" Event="NewDialog" Argument="FolderDlg" Condition="AI_INSTALL" Ordering="1"/>
+    <ROW Dialog_="VerifyReadyDlg" Control_="Back" Event="NewDialog" Argument="FolderDlg" Condition="AI_INSTALL" Ordering="201"/>
+    <ROW Dialog_="FolderDlg" Control_="Next" Event="NewDialog" Argument="VerifyReadyDlg" Condition="AI_INSTALL" Ordering="201"/>
+    <ROW Dialog_="VerifyReadyDlg" Control_="Install" Event="EndDialog" Argument="Return" Condition="AI_INSTALL" Ordering="197"/>
+    <ROW Dialog_="MaintenanceTypeDlg" Control_="Back" Event="NewDialog" Argument="MaintenanceWelcomeDlg" Condition="AI_MAINT" Ordering="1"/>
+    <ROW Dialog_="MaintenanceWelcomeDlg" Control_="Next" Event="NewDialog" Argument="MaintenanceTypeDlg" Condition="AI_MAINT" Ordering="99"/>
+    <ROW Dialog_="CustomizeDlg" Control_="Back" Event="NewDialog" Argument="MaintenanceTypeDlg" Condition="AI_MAINT" Ordering="1"/>
+    <ROW Dialog_="MaintenanceTypeDlg" Control_="ChangeButton" Event="NewDialog" Argument="CustomizeDlg" Condition="AI_MAINT" Ordering="401"/>
+    <ROW Dialog_="VerifyReadyDlg" Control_="Back" Event="NewDialog" Argument="CustomizeDlg" Condition="AI_MAINT" Ordering="202"/>
+    <ROW Dialog_="CustomizeDlg" Control_="Next" Event="NewDialog" Argument="VerifyReadyDlg" Condition="AI_MAINT" Ordering="101"/>
+    <ROW Dialog_="VerifyReadyDlg" Control_="Install" Event="EndDialog" Argument="Return" Condition="AI_MAINT" Ordering="198"/>
+    <ROW Dialog_="VerifyReadyDlg" Control_="Back" Event="NewDialog" Argument="PatchWelcomeDlg" Condition="AI_PATCH" Ordering="203"/>
+    <ROW Dialog_="PatchWelcomeDlg" Control_="Next" Event="NewDialog" Argument="VerifyReadyDlg" Condition="AI_PATCH" Ordering="201"/>
+    <ROW Dialog_="VerifyReadyDlg" Control_="Install" Event="EndDialog" Argument="Return" Condition="AI_PATCH" Ordering="199"/>
+    <ROW Dialog_="ResumeDlg" Control_="Install" Event="EndDialog" Argument="Return" Condition="AI_RESUME" Ordering="299"/>
+  </COMPONENT>
+  <COMPONENT cid="caphyon.advinst.msicomp.MsiCreateFolderComponent">
+    <ROW Directory_="SHORTCUTDIR" Component_="SHORTCUTDIR"/>
+    <ROW Directory_="QuickLaunch_Dir" Component_="QuickLaunch"/>
+  </COMPONENT>
+  <COMPONENT cid="caphyon.advinst.msicomp.MsiCustActComponent">
+    <ROW Action="AI_DOWNGRADE" Type="19" Target="4010"/>
+    <ROW Action="AI_InstallModeCheck" Type="1" Source="aicustact.dll" Target="UpdateInstallMode" WithoutSeq="true"/>
+    <ROW Action="AI_PREPARE_UPGRADE" Type="65" Source="aicustact.dll" Target="PrepareUpgrade"/>
+    <ROW Action="AI_RESTORE_LOCATION" Type="65" Source="aicustact.dll" Target="RestoreLocation"/>
+    <ROW Action="AI_ResolveKnownFolders" Type="1" Source="aicustact.dll" Target="AI_ResolveKnownFolders"/>
+    <ROW Action="AI_SHOW_LOG" Type="65" Source="aicustact.dll" Target="LaunchLogFile" WithoutSeq="true"/>
+    <ROW Action="AI_STORE_LOCATION" Type="51" Source="ARPINSTALLLOCATION" Target="[APPDIR]"/>
+    <ROW Action="AI_ViewReadme" Type="1" Source="aicustact.dll" Target="[#README.rtf]"/>
+    <ROW Action="SET_APPDIR" Type="307" Source="APPDIR" Target="[ProgramFilesFolder][Manufacturer]\[ProductName]" MultiBuildTarget="DefaultBuild:[ProgramFiles64Folder][Manufacturer]\[ProductName]"/>
+    <ROW Action="SET_SHORTCUTDIR" Type="307" Source="SHORTCUTDIR" Target="[ProgramMenuFolder][ProductName]"/>
+    <ROW Action="SET_TARGETDIR_TO_APPDIR" Type="51" Source="TARGETDIR" Target="[APPDIR]"/>
+  </COMPONENT>
+  <COMPONENT cid="caphyon.advinst.msicomp.MsiEnvComponent">
+    <ROW Environment="ISSM_TESTS_1" Name="=-ISSM_TESTS" Value="[test_Dir]" Component_="ProductInformation"/>
+    <ROW Environment="ISSM_TIER" Name="=-ISSM_TIER" Value="[APPDIR]" Component_="ProductInformation"/>
+    <ROW Environment="ISSM_TIER_WIN" Name="=-ISSM_TIER_WIN" Value="[APPDIR]" Component_="ProductInformation"/>
+  </COMPONENT>
+  <COMPONENT cid="caphyon.advinst.msicomp.MsiIconsComponent">
+    <ROW Name="matlabissm.exe" SourcePath="ISSMlogo.ico" Index="0"/>
+  </COMPONENT>
+  <COMPONENT cid="caphyon.advinst.msicomp.MsiInstExSeqComponent">
+    <ROW Action="AI_DOWNGRADE" Condition="AI_NEWERPRODUCTFOUND AND (UILevel &lt;&gt; 5)" Sequence="210"/>
+    <ROW Action="AI_RESTORE_LOCATION" Condition="APPDIR=&quot;&quot;" Sequence="749"/>
+    <ROW Action="AI_STORE_LOCATION" Condition="(Not Installed) OR REINSTALL" Sequence="1501"/>
+    <ROW Action="AI_PREPARE_UPGRADE" Condition="AI_UPGRADE=&quot;No&quot; AND (Not Installed)" Sequence="1399"/>
+    <ROW Action="AI_ResolveKnownFolders" Sequence="51"/>
+  </COMPONENT>
+  <COMPONENT cid="caphyon.advinst.msicomp.MsiInstallUISequenceComponent">
+    <ROW Action="AI_RESTORE_LOCATION" Condition="APPDIR=&quot;&quot;" Sequence="749"/>
+    <ROW Action="AI_ResolveKnownFolders" Sequence="51"/>
+  </COMPONENT>
+  <COMPONENT cid="caphyon.advinst.msicomp.MsiLaunchConditionsComponent">
+    <ROW Condition="VersionNT" Description="[ProductName] cannot be installed on [WindowsType9XDisplay]" DescriptionLocId="AI.LaunchCondition.No9X" IsPredefined="true" Builds="DefaultBuild"/>
+  </COMPONENT>
+  <COMPONENT cid="caphyon.advinst.msicomp.MsiRegsComponent">
+    <ROW Registry="Path" Root="-1" Key="Software\[Manufacturer]\[ProductName]" Name="Path" Value="[APPDIR]" Component_="ProductInformation"/>
+    <ROW Registry="Version" Root="-1" Key="Software\[Manufacturer]\[ProductName]" Name="Version" Value="[ProductVersion]" Component_="ProductInformation"/>
+  </COMPONENT>
+  <COMPONENT cid="caphyon.advinst.msicomp.MsiShortsComponent">
+    <ROW Shortcut="ISSM" Directory_="SHORTCUTDIR" Name="ISSM" Component_="matlabissm.bat" Target="[#matlabissm.bat]" Hotkey="0" Icon_="matlabissm.exe" IconIndex="0" ShowCmd="1" WkDir="APPDIR"/>
+    <ROW Shortcut="ISSM_1" Directory_="DesktopFolder" Name="ISSM" Component_="matlabissm.bat" Target="[#matlabissm.bat]" Hotkey="0" Icon_="matlabissm.exe" IconIndex="0" ShowCmd="1" WkDir="APPDIR"/>
+    <ROW Shortcut="ISSM_2" Directory_="QuickLaunch_Dir" Name="ISSM" Component_="matlabissm.bat" Target="[#matlabissm.bat]" Hotkey="0" Icon_="matlabissm.exe" IconIndex="0" ShowCmd="1" WkDir="APPDIR"/>
+    <ROW Shortcut="ISSM_3" Directory_="StartMenuFolder" Name="ISSM" Component_="matlabissm.bat" Target="[#matlabissm.bat]" Hotkey="0" Icon_="matlabissm.exe" IconIndex="0" ShowCmd="1" WkDir="APPDIR"/>
+  </COMPONENT>
+  <COMPONENT cid="caphyon.advinst.msicomp.MsiThemeComponent">
+    <ATTRIBUTE name="UsedTheme" value="classic"/>
+  </COMPONENT>
+  <COMPONENT cid="caphyon.advinst.msicomp.MsiUpgradeComponent">
+    <ROW UpgradeCode="[|UpgradeCode]" VersionMax="[|ProductVersion]" Attributes="1025" ActionProperty="OLDPRODUCTS"/>
+    <ROW UpgradeCode="[|UpgradeCode]" VersionMin="[|ProductVersion]" Attributes="2" ActionProperty="AI_NEWERPRODUCTFOUND"/>
+  </COMPONENT>
+</DOCUMENT>
Index: /issm/trunk/installers/win7/aic.sh
===================================================================
--- /issm/trunk/installers/win7/aic.sh	(revision 11527)
+++ /issm/trunk/installers/win7/aic.sh	(revision 11527)
@@ -0,0 +1,35 @@
+#!/bin/bash
+
+#get brand new project: 
+rm -rf ISSM.aip  ISSM-SetupFiles ISSM.msi
+cp ISSM.initial.aip ISSM.aip
+
+#build list of files to put into the installer: 
+rm -rf ISSM.aic 
+cat << END > ISSM.aic
+;aic
+SetVersion "1.0"
+SetPackageName "ISSM.msi"
+END
+
+ls $ISSM_TIER_WIN/scripts/*.bat $ISSM_TIER_WIN/bin/startup.m $ISSM_TIER_WIN/bin/*.h | awk '{printf("AddFile APPDIR %s\n",$1);}' | sed 's/\//\\/g' >> ISSM.aic
+
+cat << END >> ISSM.aic
+AddFolder PersonalFolder $ISSM_TIER_WIN\test
+AddFolder APPDIR $ISSM_TIER_WIN\bin
+DelEnvironment ISSM_TESTS
+NewEnvironment -name ISSM_TESTS -value [test_Dir]
+DelEnvironment ISSM_TIER
+NewEnvironment -name ISSM_TIER -value [APPDIR]
+DelEnvironment ISSM_TIER_WIN
+NewEnvironment -name ISSM_TIER_WIN -value [APPDIR]
+Save
+Rebuild
+END
+
+#Run installer: 
+"C:/Program Files (x86)/Caphyon/Advanced Installer 8.9/bin/x86/AdvancedInstaller.com" /execute  ./ISSM.aip ./ISSM.aic
+
+#Get rid of temporary files: 
+cp ISSM-SetupFiles/ISSM.msi ./
+rm -rf ISSM.aip ISSM-SetupFiles ISSM.aic
Index: /issm/trunk/m4/ar-lib.m4
===================================================================
--- /issm/trunk/m4/ar-lib.m4	(revision 11527)
+++ /issm/trunk/m4/ar-lib.m4	(revision 11527)
@@ -0,0 +1,61 @@
+##                                                          -*- Autoconf -*-
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# serial 1
+
+# AM_PROG_AR([ACT-IF-FAIL])
+# -------------------------
+# Try to determine the archiver interface, and trigger the ar-lib wrapper
+# if it is needed.  If the detection of archiver interface fails, run
+# ACT-IF-FAIL (default is to abort configure with a proper error message).
+AC_DEFUN([AM_PROG_AR],
+[AC_BEFORE([$0], [LT_INIT])dnl
+AC_BEFORE([$0], [AC_PROG_LIBTOOL])dnl
+AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
+AC_REQUIRE_AUX_FILE([ar-lib])dnl
+AC_CHECK_TOOLS([AR], [ar lib "link -lib"], [false])
+: ${AR=ar}
+
+AC_CACHE_CHECK([the archiver ($AR) interface], [am_cv_ar_interface],
+  [am_cv_ar_interface=ar
+   AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int some_variable = 0;]])],
+     [am_ar_try='$AR cru libconftest.a conftest.$ac_objext >&AS_MESSAGE_LOG_FD'
+      AC_TRY_EVAL([am_ar_try])
+      if test "$ac_status" -eq 0; then
+        am_cv_ar_interface=ar
+      else
+        am_ar_try='$AR -NOLOGO -OUT:conftest.lib conftest.$ac_objext >&AS_MESSAGE_LOG_FD'
+        AC_TRY_EVAL([am_ar_try])
+        if test "$ac_status" -eq 0; then
+          am_cv_ar_interface=lib
+        else
+          am_cv_ar_interface=unknown
+        fi
+      fi
+      rm -f conftest.lib libconftest.a
+     ])
+   ])
+
+case $am_cv_ar_interface in
+ar)
+  ;;
+lib)
+  # Microsoft lib, so override with the ar-lib wrapper script.
+  # FIXME: It is wrong to rewrite AR.
+  # But if we don't then we get into trouble of one sort or another.
+  # A longer-term fix would be to have automake use am__AR in this case,
+  # and then we could set am__AR="$am_aux_dir/ar-lib \$(AR)" or something
+  # similar.
+  AR="$am_aux_dir/ar-lib $AR"
+  ;;
+unknown)
+  m4_default([$1],
+             [AC_MSG_ERROR([could not determine $AR interface])])
+  ;;
+esac
+AC_SUBST([AR])dnl
+])
Index: /issm/trunk/m4/issm_options.m4
===================================================================
--- /issm/trunk/m4/issm_options.m4	(revision 11526)
+++ /issm/trunk/m4/issm_options.m4	(revision 11527)
@@ -29,4 +29,6 @@
 	AM_CONDITIONAL([NOPARALLEL], [test $PARALLEL_VALUE = no])
 	AC_MSG_RESULT($PARALLEL_VALUE) 
+	ISSMEXT=".exe"
+	AC_SUBST([ISSMEXT])
 	dnl }}}
 	dnl Serial or Parallel check {{{1
@@ -40,4 +42,48 @@
 
 	dnl ISSM's externalpackages
+	dnl vendor{{{1
+	AC_ARG_WITH([vendor],
+			  AS_HELP_STRING([--with-vendor = VENDOR], [vendor name, ex: intel]), [VENDOR=$withval],[VENDOR=""]) 
+	AC_MSG_CHECKING(for vendor compilers)
+	if test -n "$VENDOR"; then
+
+		if  test $VENDOR = intel-win32; then
+			export CC=icl
+			export CXX=icl
+			export CFLAGS="-DWIN32 -D_INTEL_WIN_"
+			export CXXFLAGS="-DWIN32 -D_INTEL_WIN_"
+		elif  test $VENDOR = intel-win7-32; then
+			export CC=cccl
+			export CXX=cccl
+			export CXXFLAGS="-DWIN32 -D_INTEL_WIN_ -EHsc"
+			export CFLAGS="-DWIN32 -D_INTEL_WIN_ -EHsc"
+			export AR=lib
+			export RANLIB=true
+			OSLIBS="kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib"
+		elif  test $VENDOR = intel-win7-64; then
+			export CC=cccl
+			export CXX=cccl
+			export CXXFLAGS="-DWIN32 -D_INTEL_WIN_ -EHsc"
+			export CFLAGS="-DWIN32 -D_INTEL_WIN_ -EHsc"
+			export AR=lib
+			export RANLIB=true
+			OSLIBS="kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib"
+		elif test $VENDOR = intel-linux; then
+			export CC=icc
+			export CXX=icpc
+			export CFLAGS=" -D_INTEL_LINUX_"
+			export CXXFLAGS=" -D_INTEL_LINUX_"
+		elif test $VENDOR = intel-pleiades; then
+			export CC=icc
+			export CXX=icpc
+			export CXXFLAGS=" -O3 -xS -D_INTEL_LINUX_ "
+			export CFLAGS=" -O3 -xS -D_INTEL_LINUX_ "
+		else
+		AC_MSG_ERROR([unknow compiler vendor!])
+		fi
+	fi
+	AC_SUBST([OSLIBS]) 
+	AC_MSG_RESULT(done)
+	dnl }}}
 	dnl Matlab {{{1
 	AC_ARG_WITH([matlab-dir],
@@ -76,11 +122,12 @@
 				dnl if matlab version is 7.10 or more, we must use mexmaci64 (64 bits)
 				MEXLINK="-O -Wl,-flat_namespace -undefined suppress -arch i386 -bundle -Wl,-exported_symbols_list,$MATLAB_ROOT/extern/lib/maci/mexFunction.map"
+				MEXLIB=" -L$MATLAB_ROOT/bin/maci/ -lmx -lmex -lmat -lstdc++ -largeArrayDims"
 				if test $MATLAB_MAJOR -ge 7; then 
 					 if test $MATLAB_MINOR -ge 10; then 
 						  MEXLINK="-O -Wl,-flat_namespace -undefined suppress -bundle -Wl,-exported_symbols_list,$MATLAB_ROOT/extern/lib/maci64/mexFunction.map"
+							 MEXLIB=" -L$MATLAB_ROOT/bin/maci64/ -lmx -lmex -lmat -lstdc++"
 					 fi
 				fi
 
-				MEXLIB=" mexversion.o -L$MATLAB_ROOT/bin/maci/ -lmx -lmex -lmat -lstdc++ -largeArrayDims"
 				MEXEXT=`$MATLAB_ROOT/bin/mexext`
 				MEXEXT=".$MEXEXT"
@@ -89,7 +136,10 @@
 				dnl MEXLINK="-Wl,-twolevel_namespace -undefined error -arch i386 -Wl,-syslibroot,/Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5 -bundle -Wl,-exported_symbols_list,$MATLAB_ROOT/extern/lib/maci/mexFunction.map"
 			;;
-			*cygwin*)
-				MEXLIB="-dll -export:mexFunction -LIBPATH:\"$MATLAB_ROOT\extern\lib\win32\microsoft\" libmx.lib libmex.lib libmat.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib  -NOLOGO -INCREMENTAL:NO"
-
+			*cygwin*) 
+				if  test $VENDOR = intel-win7-32; then
+					MEXLIB="-dll -export:mexFunction -LIBPATH:\"$MATLAB_ROOT\extern\lib\win32\microsoft\" libmx.lib libmex.lib libmat.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib  -NOLOGO -INCREMENTAL:NO -manifest" 
+				elif  test $VENDOR = intel-win7-64; then
+					MEXLIB="-dll -export:mexFunction -LIBPATH:\"$MATLAB_ROOT\extern\lib\win64\microsoft\" libmx.lib libmex.lib libmat.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib  -NOLOGO -INCREMENTAL:NO -manifest" 
+				fi
 				MEXEXT=`$MATLAB_ROOT/bin/mexext.bat`
 				MEXEXT=".$MEXEXT"
@@ -130,4 +180,8 @@
 						fi
 					;;
+					*cygwin*)
+						largearrays=yes 
+					;;
+
 					*darwin*)
 						if test $MATLAB_MAJOR -ge 7; then 
@@ -155,5 +209,16 @@
 		HAVE_TRIANGLE=yes
 		TRIANGLEINCL=-I$TRIANGLE_ROOT/
-		TRIANGLELIB=$TRIANGLE_ROOT/triangle.a
+
+		case "${host_os}" in
+				*cygwin*)
+				TRIANGLELIB=$TRIANGLE_ROOT/triangle.lib
+				;;
+				*linux*)
+				TRIANGLELIB=$TRIANGLE_ROOT/triangle.a
+				;;
+				*darwin*)
+				TRIANGLELIB=$TRIANGLE_ROOT/triangle.a
+				;;
+			esac
 
 		AC_DEFINE([_HAVE_TRIANGLE_],[1],[with Triangle in ISSM src])
@@ -315,5 +380,6 @@
 					                          
 		if test "$METIS_VERSION" = "4" ; then
-
+   			
+			METISINCL=-I"$METIS_ROOT/Lib" 
 			case "${host_os}" in
 				*cygwin*)
@@ -328,5 +394,4 @@
 			esac
 
-   			METISINCL=-I"$METIS_ROOT/Lib" 
    			AC_DEFINE([_METIS_VERSION_],[4],[ Metis version number])
 		fi
@@ -432,4 +497,5 @@
 	AC_MSG_CHECKING(for Petsc headers and libraries in $PETSC_ROOT for architecture $PETSC_ARCH)
 	
+	
 	if test -d "$PETSC_ROOT"; then
 
@@ -438,5 +504,9 @@
 		case "${host_os}" in
 			*cygwin*)
-			PETSCLIB="-link -LIBPATH:\"$PETSC_ROOT/$PETSC_ARCH/lib\" -LIBPATH:\"$PETSC_ROOT/lib\" -LIBPATH:\"$PETSC_ROOT/lib/$PETSC_ARCH\" libpetscksp.lib  libpetscdm.lib  libpetscmat.lib  libpetscvec.lib libpetscsnes.lib libpetscts.lib libmpiuni.lib libpetsc.lib"
+			if test "$PETSC_MAJOR" = "2" ; then
+				PETSCLIB="-link -LIBPATH:\"$PETSC_ROOT/$PETSC_ARCH/lib\" -LIBPATH:\"$PETSC_ROOT/lib\" -LIBPATH:\"$PETSC_ROOT/lib/$PETSC_ARCH\" libpetscksp.lib  libpetscdm.lib  libpetscmat.lib  libpetscvec.lib libpetscsnes.lib libpetscts.lib libmpiuni.lib libpetsc.lib"
+			else
+				PETSCLIB="-link -LIBPATH:\"$PETSC_ROOT/$PETSC_ARCH/lib\" -LIBPATH:\"$PETSC_ROOT/lib\" -LIBPATH:\"$PETSC_ROOT/lib/$PETSC_ARCH\" libpetsc.lib"
+			fi
 			;;
 			*linux*)
@@ -482,5 +552,5 @@
 		  HAVE_TAO=yes
 		  TAOINCL="-I$TAO_ROOT/ -I$TAO_ROOT/include -I$TAO_ROOT/bmake/ "
-		  TAOLIB="-L$TAO_ROOT/lib -ltao -ltaopetsc -lpetsc"
+		  TAOLIB="-L$TAO_ROOT/lib -ltao -lpetsc"
 
 		  AC_DEFINE([_HAVE_TAO_],[1],[with Tao in ISSM src])
@@ -501,5 +571,5 @@
 		case "${host_os}" in
 			*cygwin*)
-			MPILIB="-link -LIBPATH:\"$PETSC_ROOT/$PETSC_ARCH/lib\" -LIBPATH:\"$PETSC_ROOT/lib\" -LIBPATH:\"$PETSC_ROOT/lib/$PETSC_ARCH\" libmpiuni.lib"
+			dnl MPILIB="-link -LIBPATH:\"$PETSC_ROOT/$PETSC_ARCH/lib\" -LIBPATH:\"$PETSC_ROOT/lib\" -LIBPATH:\"$PETSC_ROOT/lib/$PETSC_ARCH\" libmpiuni.lib"
 			;;
 			*linux*)
@@ -817,28 +887,4 @@
 		AC_DEFINE([_HAVE_GRAPHICS_],[1],[with GRAPHICS in ISSM src])
 		AC_SUBST([GRAPHICSLIB])
-	fi
-	AC_MSG_RESULT(done)
-	dnl }}}
-	dnl vendor{{{1
-	AC_ARG_WITH([vendor],
-			  AS_HELP_STRING([--with-vendor = VENDOR], [vendor name, ex: intel]), [VENDOR=$withval],[VENDOR=""]) 
-	AC_MSG_CHECKING(for vendor compilers)
-	if test -n "$VENDOR"; then
-
-		if  test $VENDOR = intel-win; then
-			export CC=icl
-			export CXX=icl
-			export CXXFLAGS="-DWIN32 -D_INTEL_WIN_"
-		elif test $VENDOR = intel-linux; then
-			export CC=icc
-			export CXX=icpc
-			export CXXFLAGS=" -D_INTEL_LINUX_"
-		elif test $VENDOR = intel-pleiades; then
-			export CC=icc
-			export CXX=icpc
-			export CXXFLAGS=" -O3 -xS -D_INTEL_LINUX_ "
-		else
-		AC_MSG_ERROR([unknow compiler vendor!])
-		fi
 	fi
 	AC_MSG_RESULT(done)
Index: /issm/trunk/scripts/Update.sh
===================================================================
--- /issm/trunk/scripts/Update.sh	(revision 11526)
+++ /issm/trunk/scripts/Update.sh	(revision 11527)
@@ -11,4 +11,5 @@
 fi
 
+cat $FILE | sed -e "s/md\.name/md.miscellaneous.name/g" > $FILE$$.bak && mv $FILE$$.bak $FILE
 cat $FILE | sed -e "s/md\.spcvx/md.diagnostic.spcvx/g" > $FILE$$.bak && mv $FILE$$.bak $FILE
 cat $FILE | sed -e "s/md\.spcvy/md.diagnostic.spcvy/g" > $FILE$$.bak && mv $FILE$$.bak $FILE
Index: /issm/trunk/scripts/cloc2html.py
===================================================================
--- /issm/trunk/scripts/cloc2html.py	(revision 11526)
+++ /issm/trunk/scripts/cloc2html.py	(revision 11527)
@@ -79,5 +79,5 @@
 
 #write header
-outfile.write('</table>\n\n')
+outfile.write('</table>\n')
 
 #close all files
Index: /issm/trunk/scripts/getloc.sh
===================================================================
--- /issm/trunk/scripts/getloc.sh	(revision 11526)
+++ /issm/trunk/scripts/getloc.sh	(revision 11527)
@@ -1,5 +1,5 @@
 #!/bin/bash
 #get number of lines of code
-cloc-1.55.pl $ISSM_TIER/src --exclude-dir=.svn --exclude-ext=exp --exclude-lang=make --out=temp
+cloc-1.55.pl $ISSM_TIER/src $ISSM_TIER/m4 --exclude-dir=.svn --exclude-ext=exp --exclude-lang=make --out=temp
 cat temp
 ./cloc2html.py
Index: /issm/trunk/scripts/intel-compile.sh
===================================================================
--- /issm/trunk/scripts/intel-compile.sh	(revision 11527)
+++ /issm/trunk/scripts/intel-compile.sh	(revision 11527)
@@ -0,0 +1,21 @@
+#!/bin/bash
+#Why don't we just type make? (shouldn't automake have taken care of this?)
+#The problem is the /Fe option from the intel compiler, which we weren't able to 
+#get automake to recognize. End result is that every file compiled is not named libISSM_a-name, 
+#but just name.  This makes the creation of libISSM.a impossible, as none of its objects 
+#can be found with the correct name. 
+#As a fix, we rename the objects, and then link.
+
+#First compile.
+#make
+
+#Then change the names
+list=`ls *.obj | grep -v libISSM_a`
+for i in `echo $list`
+do
+	mv $i libISSM_a-$i
+done
+
+#Now create the library out the .obj files
+rm -rf libISSM.a
+lib.exe /out:libISSM.a *.obj
Index: /issm/trunk/scripts/matlabissm.bat
===================================================================
--- /issm/trunk/scripts/matlabissm.bat	(revision 11527)
+++ /issm/trunk/scripts/matlabissm.bat	(revision 11527)
@@ -0,0 +1,2 @@
+@echo off
+matlab 
Index: /issm/trunk/scripts/wincron.sh
===================================================================
--- /issm/trunk/scripts/wincron.sh	(revision 11527)
+++ /issm/trunk/scripts/wincron.sh	(revision 11527)
@@ -0,0 +1,5 @@
+#/bin/bash
+#Launch cron as a windows service, using cygrunsrv: 
+
+cygrunsrv --install cron --path /usr/sbin/cron --args -n
+net start cron
Index: /issm/trunk/src/Makefile.am
===================================================================
--- /issm/trunk/src/Makefile.am	(revision 11526)
+++ /issm/trunk/src/Makefile.am	(revision 11527)
@@ -1,4 +1,4 @@
-EXTRA_DIST = m  perl  pro
-SUBDIRS = c mex
+EXTRA_DIST =  perl  pro
+SUBDIRS = c mex m
 
 if ADIC2
Index: /issm/trunk/src/ad/wrappers.txt
===================================================================
--- /issm/trunk/src/ad/wrappers.txt	(revision 11526)
+++ /issm/trunk/src/ad/wrappers.txt	(revision 11527)
@@ -127,4 +127,5 @@
 KSPSetFromOptions
 KSPGetPC
+KSPSetUp
 KSPSolve
 KSPGetIterationNumber
@@ -140,5 +141,4 @@
 PetscOptionsGetString
 PetscOptionsDetermineSolverType
-KSPFree
 VecMergex
 VecToMPISerial
Index: /issm/trunk/src/c/Container/DataSet.cpp
===================================================================
--- /issm/trunk/src/c/Container/DataSet.cpp	(revision 11526)
+++ /issm/trunk/src/c/Container/DataSet.cpp	(revision 11527)
@@ -224,14 +224,14 @@
 				dataset->AddObject(tria);}
 				break;
-			case TriaVertexInputEnum:{
-				TriaVertexInput* triavertexinput=NULL;
-				triavertexinput=new TriaVertexInput();
+			case TriaP1InputEnum:{
+				TriaP1Input* triavertexinput=NULL;
+				triavertexinput=new TriaP1Input();
 				triavertexinput->Demarshall(&marshalled_dataset);
 				dataset->AddObject(triavertexinput);}
 				break;
 			#ifdef _HAVE_THREED_
-			case PentaVertexInputEnum:{
-				PentaVertexInput* pentavertexinput=NULL;
-				pentavertexinput=new PentaVertexInput();
+			case PentaP1InputEnum:{
+				PentaP1Input* pentavertexinput=NULL;
+				pentavertexinput=new PentaP1Input();
 				pentavertexinput->Demarshall(&marshalled_dataset);
 				dataset->AddObject(pentavertexinput);}
@@ -258,14 +258,14 @@
 				dataset->AddObject(datasetinputinput);}
 				break;
-			case TriaVertexElementResultEnum:{
-				TriaVertexElementResult* triavertexelementresult=NULL;
-				triavertexelementresult=new TriaVertexElementResult();
+			case TriaP1ElementResultEnum:{
+				TriaP1ElementResult* triavertexelementresult=NULL;
+				triavertexelementresult=new TriaP1ElementResult();
 				triavertexelementresult->Demarshall(&marshalled_dataset);
 				dataset->AddObject(triavertexelementresult);}
 				break;
 			 #ifdef _HAVE_THREED_
-			case PentaVertexElementResultEnum:{
-				PentaVertexElementResult* pentavertexelementresult=NULL;
-				pentavertexelementresult=new PentaVertexElementResult();
+			case PentaP1ElementResultEnum:{
+				PentaP1ElementResult* pentavertexelementresult=NULL;
+				pentavertexelementresult=new PentaP1ElementResult();
 				pentavertexelementresult->Demarshall(&marshalled_dataset);
 				dataset->AddObject(pentavertexelementresult);}
Index: /issm/trunk/src/c/Container/Nodes.cpp
===================================================================
--- /issm/trunk/src/c/Container/Nodes.cpp	(revision 11526)
+++ /issm/trunk/src/c/Container/Nodes.cpp	(revision 11527)
@@ -60,5 +60,4 @@
 
 	int  i;
-	
 	int  dofcount=0;
 	int  maxdofspernode=0;
@@ -69,7 +68,7 @@
 
 	/*some check: */
-	if ((setenum!=GsetEnum) && (setenum!=FsetEnum) && (setenum!=SsetEnum))_error_("%s%s%s"," dof distribution for set of enum type ",EnumToStringx(setenum)," not supported yet!");
-
-	/*Go through objects, and distribute dofs locally, from 0 to numberofdofs: */
+	_assert_(setenum==GsetEnum || setenum==FsetEnum || setenum==SsetEnum);
+
+	/*Go through objects, and distribute dofs locally, from 0 to numberofdofsperobject*/
 	for (i=0;i<this->Size();i++){
 		Node* node=(Node*)this->GetObjectByOffset(i);
@@ -81,27 +80,20 @@
 	}
 
-	/*Ok, now every object has distributed dofs, but locally, and with a dof count starting from 
-	 *0. This means the dofs between all the cpus are not synchronized! We need to synchronize all 
-	 *dof on all cpus, and use those to update the dofs of every object: */
-
+	/* Now every object has distributed dofs, but locally, and with a dof count starting from 
+	 * 0. This means the dofs between all the cpus are not unique. We now offset the dofs of eache
+	 * cpus by the total last dofs of the previus cpu, starting from 0.
+	 * First: bet number of dofs for each cpu*/
 	alldofcount=(int*)xmalloc(num_procs*sizeof(int));
 	MPI_Gather(&dofcount,1,MPI_INT,alldofcount,1,MPI_INT,0,MPI_COMM_WORLD);
 	MPI_Bcast(alldofcount,num_procs,MPI_INT,0,MPI_COMM_WORLD);
 
-	/*Ok, now every cpu should start its own dof count at the end of the dofcount 
-	 * from cpu-1. : */
+	/* Every cpu should start its own dof count at the end of the dofcount from cpu-1*/
 	dofcount=0;
-	if(my_rank==0){
-		dofcount=0;
-	}
-	else{
+	if(my_rank!=0){
 		for(i=0;i<my_rank;i++){
 			dofcount+=alldofcount[i];
 		}
 	}
-
-	/*Ok, now every cpu knows where his dofs should start. Update the dof count: */
 	for (i=0;i<this->Size();i++){
-
 		/*Check that this node corresponds to our analysis currently being carried out: */
 		Node* node=(Node*)this->GetObjectByOffset(i);
@@ -109,20 +101,17 @@
 			node->OffsetDofs(dofcount,setenum);
 		}
-
-	}
-
-	/*Finally, remember that cpus may have skipped some objects, because they were clones. For every 
+	}
+
+	/* Finally, remember that cpus may have skipped some objects, because they were clones. For every 
 	 * object that is not a clone, tell them to show their dofs, so that later on, they can get picked 
 	 * up by their clones: */
 	maxdofspernode=this->MaxNumDofs(analysis_type,setenum);
 	numnodes=this->NumberOfNodes(analysis_type);
-
-	if (numnodes*maxdofspernode){
-		truedofs=(int*)xcalloc(numnodes*maxdofspernode,sizeof(int)); //initialize to 0, so that we can pick up the max
+	if(numnodes*maxdofspernode){
+		truedofs=   (int*)xcalloc(numnodes*maxdofspernode,sizeof(int)); //initialize to 0, so that we can pick up the max
 		alltruedofs=(int*)xcalloc(numnodes*maxdofspernode,sizeof(int));
 	}
 
 	for (i=0;i<this->Size();i++){
-		/*Check that this node corresponds to our analysis currently being carried out: */
 		Node* node=(Node*)this->GetObjectByOffset(i);
 		if (node->InAnalysis(analysis_type)){
@@ -130,13 +119,11 @@
 		}
 	}
-
 	MPI_Allreduce ( (void*)truedofs,(void*)alltruedofs,numnodes*maxdofspernode,MPI_INT,MPI_MAX,MPI_COMM_WORLD);
 
-	/*Ok, now every cpu knows the true dofs of everyone else that is not a clone. Let the clones recover those true dofs: */
+	/* Now every cpu knows the true dofs of everyone else that is not a clone*/
 	for (i=0;i<this->Size();i++){
-		/*Check that this node corresponds to our analysis currently being carried out: */
-		Node* node=(Node*)this->GetObjectByOffset(i);
-		if (node->InAnalysis(analysis_type)){
-			node->UpdateCloneDofs(alltruedofs,maxdofspernode,setenum); //give maxdofspernode, column size, so that nodes can index into alltruedofs
+		Node* node=(Node*)this->GetObjectByOffset(i);
+		if (node->InAnalysis(analysis_type)){
+			node->UpdateCloneDofs(alltruedofs,maxdofspernode,setenum);
 		}
 	}
@@ -146,6 +133,4 @@
 	xfree((void**)&truedofs);
 	xfree((void**)&alltruedofs);
-
-
 }
 /*}}}*/
Index: /issm/trunk/src/c/Container/Vertices.cpp
===================================================================
--- /issm/trunk/src/c/Container/Vertices.cpp	(revision 11526)
+++ /issm/trunk/src/c/Container/Vertices.cpp	(revision 11527)
@@ -45,5 +45,4 @@
 
 	int  i;
-	
 	int  dofcount=0;
 	int* alldofcount=NULL;
@@ -51,5 +50,5 @@
 	int* alltruedofs=NULL;
 
-	/*Go through objects, and distribute dofs locally, from 0 to numberofdofsperobject: */
+	/*Go through objects, and distribute dofs locally, from 0 to numberofdofsperobject*/
 	for (i=0;i<this->Size();i++){
 		Vertex* vertex=(Vertex*)this->GetObjectByOffset(i);
@@ -57,26 +56,19 @@
 	}
 
-	/*Ok, now every object has distributed dofs, but locally, and with a dof count starting from 
-	 *0. This means the dofs between all the cpus are not synchronized! We need to synchronize all 
-	 *dof on all cpus, and use those to update the dofs of every object: */
-
+	/* Now every object has distributed dofs, but locally, and with a dof count starting from 
+	 * 0. This means the dofs between all the cpus are not unique. We now offset the dofs of eache
+	 * cpus by the total last dofs of the previus cpu, starting from 0.
+	 * First: bet number of dofs for each cpu*/
 	alldofcount=(int*)xmalloc(num_procs*sizeof(int));
 	MPI_Gather(&dofcount,1,MPI_INT,alldofcount,1,MPI_INT,0,MPI_COMM_WORLD);
 	MPI_Bcast(alldofcount,num_procs,MPI_INT,0,MPI_COMM_WORLD);
 
-	/*Ok, now every cpu should start its own dof count at the end of the dofcount 
-	 * from cpu-1. : */
+	/* Every cpu should start its own dof count at the end of the dofcount from cpu-1*/
 	dofcount=0;
-	if(my_rank==0){
-		dofcount=0;
-	}
-	else{
+	if(my_rank!=0){
 		for(i=0;i<my_rank;i++){
 			dofcount+=alldofcount[i];
 		}
 	}
-
-
-	/*Ok, now every cpu knows where his dofs should start. Update the dof count: */
 	for (i=0;i<this->Size();i++){
 		Vertex* vertex=(Vertex*)this->GetObjectByOffset(i);
@@ -84,18 +76,16 @@
 	}
 
-	/*Finally, remember that cpus may have skipped some objects, because they were clones. For every 
+	/* Finally, remember that cpus may have skipped some objects, because they were clones. For every 
 	 * object that is not a clone, tell them to show their dofs, so that later on, they can get picked 
 	 * up by their clones: */
-	truedofs=(int*)xcalloc(numberofobjects*numberofdofsperobject,sizeof(int));
+	truedofs   =(int*)xcalloc(numberofobjects*numberofdofsperobject,sizeof(int));
 	alltruedofs=(int*)xcalloc(numberofobjects*numberofdofsperobject,sizeof(int));
-
 	for (i=0;i<this->Size();i++){
 		Vertex* vertex=(Vertex*)this->GetObjectByOffset(i);
 		vertex->ShowTrueDofs(truedofs);
 	}
-	
-	MPI_Allreduce ( (void*)truedofs,(void*)alltruedofs,numberofobjects*numberofdofsperobject,MPI_INT,MPI_MAX,MPI_COMM_WORLD);
+	MPI_Allreduce((void*)truedofs,(void*)alltruedofs,numberofobjects*numberofdofsperobject,MPI_INT,MPI_MAX,MPI_COMM_WORLD);
 
-	/*Ok, now every cpu knows the true dofs of everyone else that is not a clone. Let the clones recover those true dofs: */
+	/* Now every cpu knows the true dofs of everyone else that is not a clone*/
 	for (i=0;i<this->Size();i++){
 		Vertex* vertex=(Vertex*)this->GetObjectByOffset(i);
@@ -107,5 +97,4 @@
 	xfree((void**)&truedofs);
 	xfree((void**)&alltruedofs);
-
 }
 /*}}}*/
Index: /issm/trunk/src/c/EnumDefinitions/EnumDefinitions.h
===================================================================
--- /issm/trunk/src/c/EnumDefinitions/EnumDefinitions.h	(revision 11526)
+++ /issm/trunk/src/c/EnumDefinitions/EnumDefinitions.h	(revision 11527)
@@ -28,4 +28,5 @@
 	DiagnosticAbstolEnum,
 	DiagnosticIcefrontEnum,
+	DiagnosticIsnewtonEnum,
 	DiagnosticMaxiterEnum,
 	DiagnosticNumRequestedOutputsEnum,
@@ -71,4 +72,6 @@
 	InversionGradientScalingEnum,
 	InversionIscontrolEnum,
+	InversionTaoEnum,
+	InversionIncompleteAdjointEnum,
 	InversionMaxParametersEnum,
 	InversionMaxiterPerStepEnum,
@@ -150,6 +153,5 @@
 	SteadystateRequestedOutputsEnum,
 	SurfaceEnum,
-	SurfaceforcingsAblationRateEnum,
-	SurfaceforcingsAccumulationRateEnum,
+	SurfaceforcingsPrecipitationEnum,
 	SurfaceforcingsMassBalanceEnum,
 	ThermalMaxiterEnum,
@@ -159,4 +161,5 @@
 	ThermalSpctemperatureEnum,
 	ThermalStabilizationEnum,
+	ThermalIsenthalpyEnum,
 	ThicknessEnum,
 	TimesteppingCflCoefficientEnum,
@@ -260,5 +263,5 @@
 	PenpairEnum,
 	PentaEnum,
-	PentaVertexInputEnum,
+	PentaP1InputEnum,
 	PetscMatParamEnum,
 	PetscVecParamEnum,
@@ -273,5 +276,5 @@
 	StringParamEnum,
 	TriaEnum,
-	TriaVertexInputEnum,
+	TriaP1InputEnum,
 	VertexEnum,
 	/*}}}*/
@@ -392,9 +395,9 @@
 	PatchNodesEnum,
 	PatchVerticesEnum,
-	PentaVertexElementResultEnum,
+	PentaP1ElementResultEnum,
 	PetscVecExternalResultEnum,
 	StringExternalResultEnum,
 	TimeEnum,
-	TriaVertexElementResultEnum,
+	TriaP1ElementResultEnum,
 	WaterColumnOldEnum,
 	/*}}}*/
Index: /issm/trunk/src/c/EnumDefinitions/EnumToModelField.cpp
===================================================================
--- /issm/trunk/src/c/EnumDefinitions/EnumToModelField.cpp	(revision 11526)
+++ /issm/trunk/src/c/EnumDefinitions/EnumToModelField.cpp	(revision 11527)
@@ -23,6 +23,4 @@
 		case InversionVyObsEnum : return "vy_obs";
 		case BasalforcingsMeltingRateEnum : return "basal_melting_rate";
-      case SurfaceforcingsAccumulationRateEnum : return "surface_accumulation_rate";
-		case SurfaceforcingsAblationRateEnum : return "surface_ablation_rate";
 		case SurfaceforcingsMassBalanceEnum : return "surface_mass_balance";
 		default : _error_("No model field is associated to enum %s",EnumToStringx(en));
Index: /issm/trunk/src/c/EnumDefinitions/Synchronize.sh
===================================================================
--- /issm/trunk/src/c/EnumDefinitions/Synchronize.sh	(revision 11526)
+++ /issm/trunk/src/c/EnumDefinitions/Synchronize.sh	(revision 11527)
@@ -9,4 +9,7 @@
 rm $ISSM_TIER/src/c/modules/EnumToStringx/EnumToStringx.cpp
 rm $ISSM_TIER/src/c/modules/StringToEnumx/StringToEnumx.cpp
+
+#Get number of enums
+NUMENUMS=$(wc -l temp | awk '{printf("%s",$1);}');
 
 #Take care of EnumToModelField.m first (easy)
@@ -95,20 +98,33 @@
 int  StringToEnumx(const char* name){
 
+   int  stage=1;
+
 END
+
 #core
-cat temp |  awk '{print "\t" ((NR==1)?"if":"else if") " (strcmp(name,\"" substr($2,1,length($2)-4) "\")==0) return " $2 ";"}' >> $ISSM_TIER//src/c/modules/StringToEnumx/StringToEnumx.cpp
-#Footer
+i1=1;
+i2=120;
+for (( i=1 ; i<=100 ; i++ )); do
+	echo "   if(stage==$i){" >> $ISSM_TIER//src/c/modules/StringToEnumx/StringToEnumx.cpp
+	awk -v i1=$i1 -v i2=$i2 '{if(NR>=i1 && NR<=i2) print $0 }' temp |
+	awk '{print "\t" ((NR==1)?"      if":"      else if") " (strcmp(name,\"" substr($2,1,length($2)-4) "\")==0) return " $2 ";"}' >> $ISSM_TIER//src/c/modules/StringToEnumx/StringToEnumx.cpp
+	echo "         else stage=$(($i+1));" >> $ISSM_TIER//src/c/modules/StringToEnumx/StringToEnumx.cpp
+	echo "   }" >> $ISSM_TIER//src/c/modules/StringToEnumx/StringToEnumx.cpp
+	
+	if [ $i2 -ge $NUMENUMS ]; then break; fi
+	let i1=$i1+120
+	let i2=$i2+120
+done
+
+#footer
 cat <<END >> $ISSM_TIER/src/c/modules/StringToEnumx/StringToEnumx.cpp
-	else _error_("Enum %s not found",name);
-
+	/*If we reach this point, the string provided has not been found*/
+   _error_("Enum %s not found",name);
 }
 END
 #}}}
 
-#get number of lines in temp
-NUMBEROFLINES=$(wc -l temp | awk '{printf("%s",$1);}');
-
 # go through the lines of temp
-for (( i=1 ; i<=$NUMBEROFLINES ; i++ )); do
+for (( i=1 ; i<=$NUMENUMS ; i++ )); do
 
 	#Get name and enum of the line i
@@ -123,13 +139,13 @@
 	then
 		printf "\r                                                                      "
-		printf "\r  $i/$NUMBEROFLINES Adding "$NAME"..."
+		printf "\r  $i/$NUMENUMS Adding "$NAME"..."
 	else
 		if [ $i -lt 100 ]
 		then
 			printf "\r                                                                      "
-			printf "\r $i/$NUMBEROFLINES Adding "$NAME"..."
+			printf "\r $i/$NUMENUMS Adding "$NAME"..."
 		else
 			printf "\r                                                                      "
-			printf "\r$i/$NUMBEROFLINES Adding "$NAME"..."
+			printf "\r$i/$NUMENUMS Adding "$NAME"..."
 		fi
 	fi
@@ -153,5 +169,4 @@
 done
 
-
 #clean up{{{
 rm temp
Index: /issm/trunk/src/c/Makefile.am
===================================================================
--- /issm/trunk/src/c/Makefile.am	(revision 11526)
+++ /issm/trunk/src/c/Makefile.am	(revision 11527)
@@ -1,3 +1,4 @@
 INCLUDES = @DAKOTAINCL@ @SHAPELIBINCL@ @PETSCINCL@ @SLEPCINCL@ @MPIINCL@ @MATLABINCL@  @METISINCL@  @CHACOINCL@ @SCOTCHINCL@ @PLAPACKINCL@  @BLASLAPACKINCL@ @MKLINCL@ @MUMPSINCL@  @TRIANGLEINCL@ @HYPREINCL@ @MLINCL@ @TAOINCL@
+EXEEXT=$(ISSMEXT)
 
 #Library declaration {{{1
@@ -61,6 +62,6 @@
 					./objects/ElementResults/DoubleElementResult.h\
 					./objects/ElementResults/DoubleElementResult.cpp\
-					./objects/ElementResults/TriaVertexElementResult.h\
-					./objects/ElementResults/TriaVertexElementResult.cpp\
+					./objects/ElementResults/TriaP1ElementResult.h\
+					./objects/ElementResults/TriaP1ElementResult.cpp\
 					./objects/ElementResults/BoolElementResult.h\
 					./objects/ElementResults/BoolElementResult.cpp\
@@ -88,6 +89,6 @@
 					./objects/Inputs/Input.h\
 					./objects/Inputs/InputLocal.h\
-					./objects/Inputs/TriaVertexInput.h\
-					./objects/Inputs/TriaVertexInput.cpp\
+					./objects/Inputs/TriaP1Input.h\
+					./objects/Inputs/TriaP1Input.cpp\
 					./objects/Inputs/BoolInput.h\
 					./objects/Inputs/BoolInput.cpp\
@@ -185,4 +186,6 @@
 					./shared/Numerics/GaussPoints.cpp\
 					./shared/Numerics/cross.cpp\
+					./shared/Numerics/isnan.h\
+					./shared/Numerics/isnan.cpp\
 					./shared/Numerics/extrema.cpp\
 					./shared/Numerics/XZvectorsToCoordinateSystem.cpp\
@@ -309,4 +312,6 @@
 					./modules/SpcNodesx/SpcNodesx.h\
 					./modules/SpcNodesx/SpcNodesx.cpp\
+					./modules/PositiveDegreeDayx/PositiveDegreeDayx.h\
+					./modules/PositiveDegreeDayx/PositiveDegreeDayx.cpp\
 					./modules/UpdateConstraintsx/UpdateConstraintsx.h\
 					./modules/UpdateConstraintsx/UpdateConstraintsx.cpp\
@@ -323,4 +328,6 @@
 					./modules/SystemMatricesx/SystemMatricesx.cpp\
 					./modules/SystemMatricesx/SystemMatricesx.h\
+					./modules/CreateJacobianMatrixx/CreateJacobianMatrixx.cpp\
+					./modules/CreateJacobianMatrixx/CreateJacobianMatrixx.h\
 					./modules/ConstraintsStatex/ConstraintsStatex.cpp\
 					./modules/ConstraintsStatex/ConstraintsStatex.h\
@@ -352,5 +359,6 @@
 					./solutions/CorePointerFromSolutionEnum.cpp\
 					./solvers/solver_linear.cpp\
-					./solvers/solver_nonlinear.cpp
+					./solvers/solver_nonlinear.cpp\
+					./solvers/solver_newton.cpp
 #}}}
 #DAKOTA sources  {{{1
@@ -413,4 +421,5 @@
 					    ./solutions/thermal_core_step.cpp\
 					    ./solutions/enthalpy_core.cpp\
+					    ./solutions/enthalpy_core_step.cpp\
 					    ./solvers/solver_thermal_nonlinear.cpp
 #}}}
@@ -422,4 +431,8 @@
 					  ./modules/ControlInputScaleGradientx/ControlInputScaleGradientx.cpp\
 					  ./modules/ControlInputScaleGradientx/ControlInputScaleGradientx.h\
+					  ./modules/GetVectorFromControlInputsx/GetVectorFromControlInputsx.cpp\
+					  ./modules/GetVectorFromControlInputsx/GetVectorFromControlInputsx.h\
+					  ./modules/SetControlInputsFromVectorx/SetControlInputsFromVectorx.cpp\
+					  ./modules/SetControlInputsFromVectorx/SetControlInputsFromVectorx.h\
 					  ./modules/ModelProcessorx/Control/CreateParametersControl.cpp\
 					  ./modules/ModelProcessorx/Control/UpdateElementsAndMaterialsControl.cpp\
@@ -558,8 +571,8 @@
 threed_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/ElementResults/PentaP1ElementResult.h\
+				     ./objects/ElementResults/PentaP1ElementResult.cpp\
+				     ./objects/Inputs/PentaP1Input.h\
+				     ./objects/Inputs/PentaP1Input.cpp\
 				     ./objects/Elements/Penta.h\
 				     ./objects/Elements/Penta.cpp\
@@ -642,8 +655,8 @@
 			     ./modules/Shp2Kmlx/Shp2Kmlx.h\
 			     ./modules/Shp2Kmlx/Shp2Kmlx.cpp\
+			     ./modules/KMLFileReadx/KMLFileReadx.h\
+			     ./modules/KMLFileReadx/KMLFileReadx.cpp\
 			     ./modules/KMLMeshWritex/KMLMeshWritex.h\
 			     ./modules/KMLMeshWritex/KMLMeshWritex.cpp\
-			     ./modules/KMLMeshWritex/KMLFileReadx.h\
-			     ./modules/KMLMeshWritex/KMLFileReadx.cpp\
 			     ./modules/KMLOverlayx/KMLOverlayx.h\
 			     ./modules/KMLOverlayx/KMLOverlayx.cpp\
@@ -698,4 +711,6 @@
 			     ./objects/KML/KML_SubStyle.cpp\
 			     ./objects/KML/KML_SubStyle.h\
+			     ./objects/KML/KML_Unknown.cpp\
+			     ./objects/KML/KML_Unknown.h\
 			     ./objects/KML/KMLFileReadUtils.cpp\
 			     ./objects/KML/KMLFileReadUtils.h
@@ -733,6 +748,4 @@
 			./shared/Threads/LaunchThread.cpp\
 			./shared/Threads/PartitionRange.cpp\
-			./shared/Numerics/isnan.h\
-			./shared/Numerics/isnan.cpp\
 			./shared/Exp/exp.h\
 			./shared/Exp/IsInPoly.cpp\
@@ -884,5 +897,5 @@
 libISSM_a_SOURCES += $(matlab_sources)
 
-libISSM_a_CXXFLAGS = -fPIC -DMATLAB -D_SERIAL_ -ansi -D_GNU_SOURCE -fno-omit-frame-pointer -pthread -D_CPP_  $(CXXOPTFLAGS)
+libISSM_a_CXXFLAGS = -fPIC -DMATLAB -D_SERIAL_ -D_GNU_SOURCE -fno-omit-frame-pointer -pthread -D_CPP_  $(CXXFLAGS) $(CXXOPTFLAGS) 
 if LARGEARRAYS
 libISSM_a_CXXFLAGS += -D__GCC4BUILD__  
@@ -894,9 +907,9 @@
 libpISSM_a_SOURCES  = $(issm_sources)
 libpISSM_a_SOURCES += $(issm_psources)
-libpISSM_a_CXXFLAGS = -fPIC -D_PARALLEL_   -D_C_ $(CXXOPTFLAGS) 
+libpISSM_a_CXXFLAGS = -fPIC -D_PARALLEL_   -D_C_ $(CXXFLAGS) $(CXXOPTFLAGS) 
 #}}}
 #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)
+libOverload_a_CFLAGS  = -fPIC -D_PARALLEL_   -D_C_ $(COPTFLAGS) $(CFLAGS)
 #}}}
 
@@ -905,5 +918,5 @@
 bin_PROGRAMS = 
 else 
-bin_PROGRAMS = issm.exe
+bin_PROGRAMS = issm
 endif
 
@@ -912,7 +925,7 @@
 
 #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) 
-#}}}
+LDADD += $(PETSCLIB) $(TAOLIB) $(FLIBS) $(PLAPACKLIB)  $(MUMPSLIB) $(SCALAPACKLIB)  $(BLACSLIB) $(HYPRELIB) $(MLLIB) $(DAKOTALIB) $(METISLIB) $(CHACOLIB) $(SCOTCHLIB) $(BLASLAPACKLIB)  $(MKLLIB) $(MPILIB) $(MATHLIB) $(FORTRANLIB) $(GRAPHICSLIB) $(MULTITHREADINGLIB) $(ADIC2LIB)  $(OSLIBS)
+
+issm_SOURCES = solutions/issm.cpp
+issm_CXXFLAGS= -fPIC -D_PARALLEL_  $(CXXFLAGS) $(CXXOPTFLAGS) $(COPTFLAGS) 
+#}}}
Index: /issm/trunk/src/c/include/typedefs.h
===================================================================
--- /issm/trunk/src/c/include/typedefs.h	(revision 11526)
+++ /issm/trunk/src/c/include/typedefs.h	(revision 11527)
@@ -23,6 +23,19 @@
 /*Windows specific typefefs: */
 #ifdef _INTEL_WIN_
-#define NAN 0.0/0.0
-#define INFINITY 1.0/0.0
+
+/*Complicated way, which does not handle INFINITY though: */
+/*#ifndef NAN
+	static const unsigned long __nan[2] = {0xffffffff, 0x7fffffff};
+	#define NAN (*(const float *) __nan)
+#endif*/
+
+//For reference, for Intel compile on win64
+//#define NAN 0.0/0.0 
+//#define INFINITY 1.0/0.0
+
+//Most generic way it would seem:
+#define INFINITY (DBL_MAX+DBL_MAX)
+#define NAN (INFINITY-INFINITY)
+	
 #endif
 
Index: sm/trunk/src/c/intel-compile.sh
===================================================================
--- /issm/trunk/src/c/intel-compile.sh	(revision 11526)
+++ 	(revision )
@@ -1,21 +1,0 @@
-#!/bin/bash
-#Why don't we just type make? (shouldn't automake have taken care of this?)
-#The problem is the /Fe option from the intel compiler, which we weren't able to 
-#get automake to recognize. End result is that every file compiled is not named libISSM_a-name, 
-#but just name.  This makes the creation of libISSM.a impossible, as none of its objects 
-#can be found with the correct name. 
-#As a fix, we rename the objects, and then link.
-
-#First compile.
-make
-
-#Then change the names
-list=`ls *.obj | grep -v libISSM_a`
-for i in `echo $list`
-do
-	mv $i libISSM_a-$i
-done
-
-#Now create the library out the .obj files
-rm -rf libISSM.a
-ar cru libISSM.a *.obj
Index: /issm/trunk/src/c/modules/BamgTriangulatex/BamgTriangulatex.cpp
===================================================================
--- /issm/trunk/src/c/modules/BamgTriangulatex/BamgTriangulatex.cpp	(revision 11526)
+++ /issm/trunk/src/c/modules/BamgTriangulatex/BamgTriangulatex.cpp	(revision 11527)
@@ -17,4 +17,5 @@
 	Th.WriteIndex(pindex,pnels);
 	//delete &Th;
+	return 0;
 
 }
Index: /issm/trunk/src/c/modules/Chacox/Chacox.cpp
===================================================================
--- /issm/trunk/src/c/modules/Chacox/Chacox.cpp	(revision 11526)
+++ /issm/trunk/src/c/modules/Chacox/Chacox.cpp	(revision 11527)
@@ -191,4 +191,6 @@
 
 
-	#endif //ifdef _HAVE_CHACO_
+	#else //ifdef _HAVE_CHACO_
+	return (0);
+	#endif
 }
Index: /issm/trunk/src/c/modules/Chacox/input_parse.cpp
===================================================================
--- /issm/trunk/src/c/modules/Chacox/input_parse.cpp	(revision 11526)
+++ /issm/trunk/src/c/modules/Chacox/input_parse.cpp	(revision 11527)
@@ -262,4 +262,6 @@
 	return(0);
 
-	#endif //#ifdef _HAVE_CHACO_ 
+	#else //#ifdef _HAVE_CHACO_ 
+	return(0);
+	#endif
 }
Index: /issm/trunk/src/c/modules/ContourToMeshx/ContourToMeshxt.cpp
===================================================================
--- /issm/trunk/src/c/modules/ContourToMeshx/ContourToMeshxt.cpp	(revision 11526)
+++ /issm/trunk/src/c/modules/ContourToMeshx/ContourToMeshxt.cpp	(revision 11527)
@@ -69,3 +69,5 @@
 	}
 
+	return NULL;
+
 }
Index: /issm/trunk/src/c/modules/ContourToNodesx/ContourToNodesx.cpp
===================================================================
--- /issm/trunk/src/c/modules/ContourToNodesx/ContourToNodesx.cpp	(revision 11526)
+++ /issm/trunk/src/c/modules/ContourToNodesx/ContourToNodesx.cpp	(revision 11527)
@@ -36,4 +36,5 @@
 	/*Assign output pointers: */
 	*pflags=flags;
-
+	
+	return 1;
 }
Index: /issm/trunk/src/c/modules/ControlInputGetGradientx/ControlInputGetGradientx.cpp
===================================================================
--- /issm/trunk/src/c/modules/ControlInputGetGradientx/ControlInputGetGradientx.cpp	(revision 11526)
+++ /issm/trunk/src/c/modules/ControlInputGetGradientx/ControlInputGetGradientx.cpp	(revision 11527)
@@ -9,12 +9,23 @@
 #include "../../EnumDefinitions/EnumDefinitions.h"
 
-void ControlInputGetGradientx( Vec* pgradient, Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters, int name){
+void ControlInputGetGradientx( Vec* pgradient, Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters){
 
-	Vec gradient=NULL;
-	gradient=NewVec(vertices->NumberOfVertices());
+	/*Intermediaries*/
+	int  num_controls;
+	int *control_type = NULL;
+	Vec  gradient=NULL;
 
-	for(int i=0;i<elements->Size();i++){
-		Element* element=(Element*)elements->GetObjectByOffset(i);
-		element->ControlInputGetGradient(gradient,name);
+	/*Retrieve some parameters*/
+	parameters->FindParam(&num_controls,InversionNumControlParametersEnum);
+	parameters->FindParam(&control_type,NULL,InversionControlParametersEnum);
+
+	/*Allocate and populate gradient*/
+	gradient=NewVec(num_controls*vertices->NumberOfVertices());
+
+	for(int i=0;i<num_controls;i++){
+		for(int j=0;j<elements->Size();j++){
+			Element* element=(Element*)elements->GetObjectByOffset(j);
+			element->ControlInputGetGradient(gradient,control_type[i],i);
+		}
 	}
 
@@ -22,5 +33,6 @@
 	VecAssemblyEnd(gradient);
 
-	/*Assign output pointers:*/
+	/*Clean up and return*/
+	xfree((void**)&control_type);
 	*pgradient=gradient;
 }
Index: /issm/trunk/src/c/modules/ControlInputGetGradientx/ControlInputGetGradientx.h
===================================================================
--- /issm/trunk/src/c/modules/ControlInputGetGradientx/ControlInputGetGradientx.h	(revision 11526)
+++ /issm/trunk/src/c/modules/ControlInputGetGradientx/ControlInputGetGradientx.h	(revision 11527)
@@ -8,5 +8,5 @@
 #include "../../Container/Container.h"
 
-void	ControlInputGetGradientx( Vec* pgradient, Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters,int name);
+void	ControlInputGetGradientx( Vec* pgradient, Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters);
 
 #endif
Index: /issm/trunk/src/c/modules/ControlInputScaleGradientx/ControlInputScaleGradientx.cpp
===================================================================
--- /issm/trunk/src/c/modules/ControlInputScaleGradientx/ControlInputScaleGradientx.cpp	(revision 11526)
+++ /issm/trunk/src/c/modules/ControlInputScaleGradientx/ControlInputScaleGradientx.cpp	(revision 11527)
@@ -9,10 +9,33 @@
 #include "../../EnumDefinitions/EnumDefinitions.h"
 
-void ControlInputScaleGradientx(Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters, int name,double scale){
+void ControlInputScaleGradientx(Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,double* norm_list,int step){
 
-	for(int i=0;i<elements->Size();i++){
-		Element* element=(Element*)elements->GetObjectByOffset(i);
-		element->ControlInputScaleGradient(name,scale);
+	/*Intermediaries*/
+	int     i,j,num_controls;
+	int    *control_type = NULL;
+	double *scalar_list = NULL;
+	double  scalar;
+
+
+	/*Retrieve some parameters*/
+	parameters->FindParam(&num_controls,InversionNumControlParametersEnum);
+	parameters->FindParam(&control_type,NULL,InversionControlParametersEnum);
+	parameters->FindParam(&scalar_list,NULL,NULL,InversionGradientScalingEnum);
+
+	/*Compute scaling factor*/
+	scalar=scalar_list[0]/norm_list[0];
+	for(i=0;i<num_controls;i++){
+		scalar=min(scalar,scalar_list[num_controls*step+i]/norm_list[i]);
 	}
 
+	for(i=0;i<num_controls;i++){
+		for(j=0;j<elements->Size();j++){
+			Element* element=(Element*)elements->GetObjectByOffset(j);
+			element->ControlInputScaleGradient(control_type[i],scalar);
+		}
+	}
+
+	/*Clean up and return*/
+	xfree((void**)&control_type);
+	xfree((void**)&scalar_list);
 }
Index: /issm/trunk/src/c/modules/ControlInputScaleGradientx/ControlInputScaleGradientx.h
===================================================================
--- /issm/trunk/src/c/modules/ControlInputScaleGradientx/ControlInputScaleGradientx.h	(revision 11526)
+++ /issm/trunk/src/c/modules/ControlInputScaleGradientx/ControlInputScaleGradientx.h	(revision 11527)
@@ -8,5 +8,5 @@
 #include "../../Container/Container.h"
 
-void	ControlInputScaleGradientx(Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters,int name,double scale);
+void	ControlInputScaleGradientx(Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters,double* norm_list,int step);
 
 #endif
Index: /issm/trunk/src/c/modules/ControlInputSetGradientx/ControlInputSetGradientx.cpp
===================================================================
--- /issm/trunk/src/c/modules/ControlInputSetGradientx/ControlInputSetGradientx.cpp	(revision 11526)
+++ /issm/trunk/src/c/modules/ControlInputSetGradientx/ControlInputSetGradientx.cpp	(revision 11527)
@@ -9,13 +9,26 @@
 #include "../../EnumDefinitions/EnumDefinitions.h"
 
-void ControlInputSetGradientx(Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters, int name,double* gradient){
+void ControlInputSetGradientx(Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,double* gradient){
 
-	for(int i=0;i<elements->Size();i++){
-		Element* element=(Element*)elements->GetObjectByOffset(i);
-		element->ControlInputSetGradient(gradient,name);
+	/*Intermediaries*/
+	int  num_controls;
+	int *control_type = NULL;
+
+	/*Retrieve some parameters*/
+	parameters->FindParam(&num_controls,InversionNumControlParametersEnum);
+	parameters->FindParam(&control_type,NULL,InversionControlParametersEnum);
+
+	for(int i=0;i<num_controls;i++){
+		for(int j=0;j<elements->Size();j++){
+			Element* element=(Element*)elements->GetObjectByOffset(j);
+			element->ControlInputSetGradient(gradient,control_type[i],i);
+		}
 	}
 
+	/*Clean up and return*/
+	xfree((void**)&control_type);
+
 }
-void ControlInputSetGradientx(Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters, int name,Vec gradient){
+void ControlInputSetGradientx(Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,Vec gradient){
 
 	/*Serialize gradient*/
@@ -23,5 +36,5 @@
 	VecToMPISerial(&serial_gradient,gradient);
 
-	ControlInputSetGradientx(elements,nodes,vertices, loads, materials, parameters, name,serial_gradient);
+	ControlInputSetGradientx(elements,nodes,vertices, loads, materials, parameters,serial_gradient);
 
 	/*Clean up and return*/
Index: /issm/trunk/src/c/modules/ControlInputSetGradientx/ControlInputSetGradientx.h
===================================================================
--- /issm/trunk/src/c/modules/ControlInputSetGradientx/ControlInputSetGradientx.h	(revision 11526)
+++ /issm/trunk/src/c/modules/ControlInputSetGradientx/ControlInputSetGradientx.h	(revision 11527)
@@ -8,6 +8,6 @@
 #include "../../Container/Container.h"
 
-void	ControlInputSetGradientx(Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters,int name,double* gradient);
-void	ControlInputSetGradientx(Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters,int name,Vec gradient);
+void	ControlInputSetGradientx(Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters,double* gradient);
+void	ControlInputSetGradientx(Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters,Vec gradient);
 
 #endif
Index: /issm/trunk/src/c/modules/CreateJacobianMatrixx/CreateJacobianMatrixx.cpp
===================================================================
--- /issm/trunk/src/c/modules/CreateJacobianMatrixx/CreateJacobianMatrixx.cpp	(revision 11527)
+++ /issm/trunk/src/c/modules/CreateJacobianMatrixx/CreateJacobianMatrixx.cpp	(revision 11527)
@@ -0,0 +1,48 @@
+/*!\file CreateJacobianMatrixx
+ * \brief: create system matrices (stiffness matrix, loads vector)
+ */
+
+#include "./CreateJacobianMatrixx.h"
+#include "../../shared/shared.h"
+#include "../../include/include.h"
+#include "../../io/io.h"
+#include "../../toolkits/toolkits.h"
+#include "../../EnumDefinitions/EnumDefinitions.h"
+
+void CreateJacobianMatrixx(Mat* pJff,Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads,Materials* materials, Parameters* parameters,double kmax){
+	
+	int      i,connectivity;
+	int      numberofdofspernode;
+	int      fsize,configuration_type;
+	Element *element = NULL;
+	Load    *load    = NULL;
+	Mat      Jff     = NULL;
+
+	/*Checks*/
+	_assert_(nodes && elements);
+
+	/*Recover some parameters*/
+	parameters->FindParam(&configuration_type,ConfigurationTypeEnum);
+	parameters->FindParam(&connectivity,MeshAverageVertexConnectivityEnum);
+	fsize=nodes->NumberOfDofs(configuration_type,FsetEnum);
+	numberofdofspernode=nodes->MaxNumDofs(configuration_type,GsetEnum);
+
+	/*Initialize Jacobian Matrix*/
+	Jff=NewMat(fsize,fsize,connectivity,numberofdofspernode);
+	
+	/*Create and assemble matrix*/
+	for(i=0;i<elements->Size();i++){
+		element=(Element*)elements->GetObjectByOffset(i);
+		element->CreateJacobianMatrix(Jff);
+	}
+	for (i=0;i<loads->Size();i++){
+		load=(Load*)loads->GetObjectByOffset(i);
+		if(load->InAnalysis(configuration_type)) load->CreateJacobianMatrix(Jff);
+		if(load->InAnalysis(configuration_type)) load->PenaltyCreateJacobianMatrix(Jff,kmax);
+	}
+	MatAssemblyBegin(Jff,MAT_FINAL_ASSEMBLY);
+	MatAssemblyEnd(Jff,MAT_FINAL_ASSEMBLY);
+
+	/*Assign output pointer*/
+	*pJff=Jff;
+}
Index: /issm/trunk/src/c/modules/CreateJacobianMatrixx/CreateJacobianMatrixx.h
===================================================================
--- /issm/trunk/src/c/modules/CreateJacobianMatrixx/CreateJacobianMatrixx.h	(revision 11527)
+++ /issm/trunk/src/c/modules/CreateJacobianMatrixx/CreateJacobianMatrixx.h	(revision 11527)
@@ -0,0 +1,14 @@
+/*!\file:  CreateJacobianMatrixx.h
+ * \brief header file for degree of freedoms distribution routines.
+ */ 
+
+#ifndef _CREATEJACOBIANMATRIXX_H
+#define _CREATEJACOBIANMATRIXX_H
+
+#include "../../Container/Container.h"
+#include "../../objects/objects.h"
+
+/* local prototypes: */
+void CreateJacobianMatrixx(Mat* pJff,Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads,Materials* materials, Parameters* parameters,double kmax);
+
+#endif  /* _CREATEJACOBIANMATRIXX_H */
Index: /issm/trunk/src/c/modules/EnumToStringx/EnumToStringx.cpp
===================================================================
--- /issm/trunk/src/c/modules/EnumToStringx/EnumToStringx.cpp	(revision 11526)
+++ /issm/trunk/src/c/modules/EnumToStringx/EnumToStringx.cpp	(revision 11527)
@@ -32,4 +32,5 @@
 		case DiagnosticAbstolEnum : return "DiagnosticAbstol";
 		case DiagnosticIcefrontEnum : return "DiagnosticIcefront";
+		case DiagnosticIsnewtonEnum : return "DiagnosticIsnewton";
 		case DiagnosticMaxiterEnum : return "DiagnosticMaxiter";
 		case DiagnosticNumRequestedOutputsEnum : return "DiagnosticNumRequestedOutputs";
@@ -75,4 +76,6 @@
 		case InversionGradientScalingEnum : return "InversionGradientScaling";
 		case InversionIscontrolEnum : return "InversionIscontrol";
+		case InversionTaoEnum : return "InversionTao";
+		case InversionIncompleteAdjointEnum : return "InversionIncompleteAdjoint";
 		case InversionMaxParametersEnum : return "InversionMaxParameters";
 		case InversionMaxiterPerStepEnum : return "InversionMaxiterPerStep";
@@ -154,6 +157,5 @@
 		case SteadystateRequestedOutputsEnum : return "SteadystateRequestedOutputs";
 		case SurfaceEnum : return "Surface";
-		case SurfaceforcingsAblationRateEnum : return "SurfaceforcingsAblationRate";
-		case SurfaceforcingsAccumulationRateEnum : return "SurfaceforcingsAccumulationRate";
+		case SurfaceforcingsPrecipitationEnum : return "SurfaceforcingsPrecipitation";
 		case SurfaceforcingsMassBalanceEnum : return "SurfaceforcingsMassBalance";
 		case ThermalMaxiterEnum : return "ThermalMaxiter";
@@ -163,4 +165,5 @@
 		case ThermalSpctemperatureEnum : return "ThermalSpctemperature";
 		case ThermalStabilizationEnum : return "ThermalStabilization";
+		case ThermalIsenthalpyEnum : return "ThermalIsenthalpy";
 		case ThicknessEnum : return "Thickness";
 		case TimesteppingCflCoefficientEnum : return "TimesteppingCflCoefficient";
@@ -256,5 +259,5 @@
 		case PenpairEnum : return "Penpair";
 		case PentaEnum : return "Penta";
-		case PentaVertexInputEnum : return "PentaVertexInput";
+		case PentaP1InputEnum : return "PentaP1Input";
 		case PetscMatParamEnum : return "PetscMatParam";
 		case PetscVecParamEnum : return "PetscVecParam";
@@ -269,5 +272,5 @@
 		case StringParamEnum : return "StringParam";
 		case TriaEnum : return "Tria";
-		case TriaVertexInputEnum : return "TriaVertexInput";
+		case TriaP1InputEnum : return "TriaP1Input";
 		case VertexEnum : return "Vertex";
 		case AirEnum : return "Air";
@@ -378,9 +381,9 @@
 		case PatchNodesEnum : return "PatchNodes";
 		case PatchVerticesEnum : return "PatchVertices";
-		case PentaVertexElementResultEnum : return "PentaVertexElementResult";
+		case PentaP1ElementResultEnum : return "PentaP1ElementResult";
 		case PetscVecExternalResultEnum : return "PetscVecExternalResult";
 		case StringExternalResultEnum : return "StringExternalResult";
 		case TimeEnum : return "Time";
-		case TriaVertexElementResultEnum : return "TriaVertexElementResult";
+		case TriaP1ElementResultEnum : return "TriaP1ElementResult";
 		case WaterColumnOldEnum : return "WaterColumnOld";
 		case MinVelEnum : return "MinVel";
Index: /issm/trunk/src/c/modules/GetVectorFromControlInputsx/GetVectorFromControlInputsx.cpp
===================================================================
--- /issm/trunk/src/c/modules/GetVectorFromControlInputsx/GetVectorFromControlInputsx.cpp	(revision 11527)
+++ /issm/trunk/src/c/modules/GetVectorFromControlInputsx/GetVectorFromControlInputsx.cpp	(revision 11527)
@@ -0,0 +1,55 @@
+/*!\file GetVectorFromControlInputsx
+ * \brief retrieve vector from inputs in elements
+ */
+
+#include "./GetVectorFromControlInputsx.h"
+#include "../../shared/shared.h"
+#include "../../include/include.h"
+#include "../../toolkits/toolkits.h"
+#include "../../EnumDefinitions/EnumDefinitions.h"
+
+void GetVectorFromControlInputsx(Vec* pvector, Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,const char* data){
+
+	int  num_controls;
+	int *control_type = NULL;
+	Vec  vector=NULL;
+
+	/*Retrieve some parameters*/
+	parameters->FindParam(&num_controls,InversionNumControlParametersEnum);
+	parameters->FindParam(&control_type,NULL,InversionControlParametersEnum);
+
+	/*Allocate and populate gradient*/
+	vector=NewVec(num_controls*vertices->NumberOfVertices());
+
+	for(int i=0;i<num_controls;i++){
+		for(int j=0;j<elements->Size();j++){
+			Element* element=(Element*)elements->GetObjectByOffset(j);
+			element->GetVectorFromControlInputs(vector,control_type[i],i,data);
+		}
+	}
+
+	VecAssemblyBegin(vector);
+	VecAssemblyEnd(vector);
+
+	/*Assign output pointers:*/
+	xfree((void**)&control_type);
+	*pvector=vector;
+}
+
+void GetVectorFromControlInputsx( double** pvector, Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters, const char* data){
+	
+	/*output: */
+	double* vector=NULL;
+	
+	/*intermediary: */
+	Vec vec_vector=NULL;
+
+	GetVectorFromControlInputsx( &vec_vector, elements,nodes, vertices, loads, materials, parameters,data);
+	VecToMPISerial(&vector,vec_vector);
+
+	/*Free ressources:*/
+	VecFree(&vec_vector);
+
+	/*Assign output pointers:*/
+	*pvector=vector;
+}
Index: /issm/trunk/src/c/modules/GetVectorFromControlInputsx/GetVectorFromControlInputsx.h
===================================================================
--- /issm/trunk/src/c/modules/GetVectorFromControlInputsx/GetVectorFromControlInputsx.h	(revision 11527)
+++ /issm/trunk/src/c/modules/GetVectorFromControlInputsx/GetVectorFromControlInputsx.h	(revision 11527)
@@ -0,0 +1,15 @@
+/*!\file:  GetVectorFromControlInputsx.h
+ */ 
+
+#ifndef _GETVECTORFROMCONTROLINPUTSXX_H
+#define _GETVECTORFROMCONTROLINPUTSXX_H
+
+#include "../../objects/objects.h"
+#include "../../Container/Container.h"
+
+/* local prototypes: */
+void	GetVectorFromControlInputsx( Vec* pvector, Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters,const char* data="value");
+void	GetVectorFromControlInputsx( double** pvector, Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters,const char* data="value");
+
+#endif  /* _GETVECTORFROMCONTROLINPUTSXX_H */
+
Index: /issm/trunk/src/c/modules/GetVectorFromInputsx/GetVectorFromInputsx.cpp
===================================================================
--- /issm/trunk/src/c/modules/GetVectorFromInputsx/GetVectorFromInputsx.cpp	(revision 11526)
+++ /issm/trunk/src/c/modules/GetVectorFromInputsx/GetVectorFromInputsx.cpp	(revision 11527)
@@ -10,5 +10,4 @@
 
 void GetVectorFromInputsx( Vec* pvector, Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters, int name, int type){
-
 
 	int i;
@@ -41,5 +40,4 @@
 	/*Assign output pointers:*/
 	*pvector=vector;
-
 }
 
Index: /issm/trunk/src/c/modules/Gradjx/Gradjx.cpp
===================================================================
--- /issm/trunk/src/c/modules/Gradjx/Gradjx.cpp	(revision 11526)
+++ /issm/trunk/src/c/modules/Gradjx/Gradjx.cpp	(revision 11527)
@@ -10,29 +10,61 @@
 #include "../../EnumDefinitions/EnumDefinitions.h"
 
-void Gradjx( Vec* pgradient, Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,int control_type){
+void Gradjx(Vec* pgradient,double** pnorm_list, Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters){
 
-	int  i;
-	int  dim;
-	int  numberofvertices;
-	Vec  gradient = NULL;
+	int     i,j,numberofvertices;
+	int     num_controls;
+	double  norm_inf;
+	double *norm_list       = NULL;
+	int    *control_type    = NULL;
+	Vec     gradient        = NULL;
+	Vec    *gradient_list   = NULL;
 	
 	/*retrieve some parameters: */
-	parameters->FindParam(&dim,MeshDimensionEnum);
+	parameters->FindParam(&num_controls,InversionNumControlParametersEnum);   _assert_(num_controls);
+	parameters->FindParam(&control_type,NULL,InversionControlParametersEnum);
 	numberofvertices=vertices->NumberOfVertices();
 
-	/*Allocate gradient: */
-	gradient=NewVec(numberofvertices);
+	/*Allocate gradient_list */
+	gradient_list = (Vec*)xmalloc(num_controls*sizeof(Vec));
+	norm_list = (double*)xmalloc(num_controls*sizeof(double));
+	for(i=0;i<num_controls;i++){
+		gradient_list[i]=NewVec(num_controls*numberofvertices);
+	}
+	gradient=NewVec(num_controls*numberofvertices);
 
-	/*Compute gradients: */
-	for (i=0;i<elements->Size();i++){
-		Element* element=(Element*)elements->GetObjectByOffset(i);
-		element->Gradj(gradient,control_type);
+	/*Compute all gradient_list*/
+	for(i=0;i<num_controls;i++){
+
+		for(j=0;j<elements->Size();j++){
+			Element* element=(Element*)elements->GetObjectByOffset(j);
+			element->Gradj(gradient_list[i],control_type[i],i);
+		}
+
+		VecAssemblyBegin(gradient_list[i]);
+		VecAssemblyEnd(gradient_list[i]);
+
+		VecNorm(gradient_list[i],NORM_INFINITY,&norm_list[i]);
 	}
 
-	/*Assemble vector: */
-	VecAssemblyBegin(gradient);
-	VecAssemblyEnd(gradient);
+	/*Add all gradient_list together*/
+	for(i=0;i<num_controls;i++){
+		VecAXPY(gradient,1.,gradient_list[i]);
+		VecFree(&gradient_list[i]);
+	}
 
-	/*Assign output pointers: */
-	*pgradient=gradient;
+	/*Check that gradient is clean*/
+	VecNorm(gradient,NORM_INFINITY,&norm_inf);
+	if(norm_inf<=0)    _error_("||∂J/∂α||∞ = 0    gradient norm is zero");
+	if(isnan(norm_inf))_error_("||∂J/∂α||∞ = NaN  gradient norm is NaN");
+
+	/*Clean-up and assign output pointer*/
+	if(pnorm_list){
+		*pnorm_list=norm_list;
+	}
+	else{
+		xfree((void**)&norm_list);
+	}
+	if(pgradient)  *pgradient=gradient;
+	xfree((void**)&gradient_list);
+	xfree((void**)&control_type);
 }
Index: /issm/trunk/src/c/modules/Gradjx/Gradjx.h
===================================================================
--- /issm/trunk/src/c/modules/Gradjx/Gradjx.h	(revision 11526)
+++ /issm/trunk/src/c/modules/Gradjx/Gradjx.h	(revision 11527)
@@ -10,6 +10,5 @@
 
 /* local prototypes: */
-void Gradjx(Vec* pgrad_g, Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials,  Parameters* parameters, int control_type);
+void Gradjx(Vec* pgrad_g,double** pgrad_norm,Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials,Parameters* parameters);
 
 #endif  /* _GRADJX_H */
-
Index: /issm/trunk/src/c/modules/InterpFromMesh2dx/InterpFromMesh2dxt.cpp
===================================================================
--- /issm/trunk/src/c/modules/InterpFromMesh2dx/InterpFromMesh2dxt.cpp	(revision 11526)
+++ /issm/trunk/src/c/modules/InterpFromMesh2dx/InterpFromMesh2dxt.cpp	(revision 11527)
@@ -126,4 +126,6 @@
 	}
 	if (debug && my_thread==0) printf("\b\b\b\b\b\b\b%5.2lf %%\n",100.0);
+	
+	return NULL;
 
 }
Index: /issm/trunk/src/c/modules/KMLFileReadx/KMLFileReadx.cpp
===================================================================
--- /issm/trunk/src/c/modules/KMLFileReadx/KMLFileReadx.cpp	(revision 11527)
+++ /issm/trunk/src/c/modules/KMLFileReadx/KMLFileReadx.cpp	(revision 11527)
@@ -0,0 +1,67 @@
+/*!\file KMLFileReadx.cpp
+ */
+
+#include "./KMLFileReadx.h"
+#include "../../shared/shared.h"
+#include "../../include/include.h"
+#include "../../io/io.h"
+#include "../../toolkits/toolkits.h"
+#include "../../EnumDefinitions/EnumDefinitions.h"
+
+KML_Object* KMLFileReadx(FILE* fid){
+
+	char*   kstr;
+	KML_File*      kxml=NULL;
+	KML_File*      kdtd=NULL;
+	KML_File*      kfil=NULL;
+
+	clock_t clock0,clock1;
+	time_t  time0, time1;
+
+	clock0=clock();
+	time0 =time(NULL);
+	_printf_(true,"\nKMLFileReadx Module -- %s",ctime(&time0));
+
+/*  read kml file  */
+
+	while (kstr=KMLFileToken(fid,
+							 NULL,NULL)) {
+		if      (!strncmp(kstr,"<?xml"    ,5)) {
+			kxml=new KML_File();
+			KMLFileTagAttrib(kxml,
+							 kstr);
+		}
+		else if (!strncmp(kstr,"<!DOCTYPE",9)) {
+			kdtd=new KML_File();
+			KMLFileTagAttrib(kdtd,
+							 kstr);
+		}
+		else if (!strncmp(kstr,"<kml"     ,4)) {
+			kfil=new KML_File();
+			kfil->Read(fid,kstr);
+//			kfil->DeepEcho();
+		}
+
+//		_printf_(true,"%s\n",kstr);
+		xfree((void**)&kstr);
+	}
+
+	if (kxml) {
+		_printf_(true,"XML declaration:\n");
+		kxml->DeepEcho("  ");
+		delete kxml;
+	}
+	if (kdtd) {
+		_printf_(true,"DTD declaration (not yet implemented):\n");
+		kdtd->DeepEcho("  ");
+		delete kdtd;
+	}
+
+	clock1=clock();
+	time1 =time(NULL);
+	_printf_(true,"KMLFileReadx Module -- %f CPU seconds; %f elapsed seconds.\n\n",
+			 ((double)(clock1-clock0))/CLOCKS_PER_SEC,difftime(time1,time0));
+
+	return(kfil);
+}
+
Index: /issm/trunk/src/c/modules/KMLFileReadx/KMLFileReadx.h
===================================================================
--- /issm/trunk/src/c/modules/KMLFileReadx/KMLFileReadx.h	(revision 11527)
+++ /issm/trunk/src/c/modules/KMLFileReadx/KMLFileReadx.h	(revision 11527)
@@ -0,0 +1,15 @@
+/*!\file:  KMLFileReadx.h
+ * \brief header file for kml mesh writer routines.
+ */ 
+
+#ifndef _KMLFILEREADX_H
+#define _KMLFILEREADX_H
+
+#include <float.h>    /*  DBL_MAX  */
+#include "../../Container/Container.h"
+#include "../../objects/objects.h"
+
+/* local prototypes: */
+KML_Object* KMLFileReadx(FILE* fid);
+
+#endif  /* _KMLFILEREADX_H */
Index: sm/trunk/src/c/modules/KMLMeshWritex/KMLFileReadx.cpp
===================================================================
--- /issm/trunk/src/c/modules/KMLMeshWritex/KMLFileReadx.cpp	(revision 11526)
+++ 	(revision )
@@ -1,67 +1,0 @@
-/*!\file KMLFileReadx.cpp
- */
-
-#include "./KMLFileReadx.h"
-#include "../../shared/shared.h"
-#include "../../include/include.h"
-#include "../../io/io.h"
-#include "../../toolkits/toolkits.h"
-#include "../../EnumDefinitions/EnumDefinitions.h"
-
-KML_Object* KMLFileReadx(FILE* fid){
-
-	char*   kstr;
-	KML_File*      kxml=NULL;
-	KML_File*      kdtd=NULL;
-	KML_File*      kfil=NULL;
-
-	clock_t clock0,clock1;
-	time_t  time0, time1;
-
-	clock0=clock();
-	time0 =time(NULL);
-	_printf_(true,"\nKMLFileReadx Module -- %s",ctime(&time0));
-
-/*  read kml file  */
-
-	while (kstr=KMLFileToken(fid,
-							 NULL,NULL)) {
-		if      (!strncmp(kstr,"<?xml"    ,5)) {
-			kxml=new KML_File();
-			KMLFileTagAttrib(kxml,
-							 kstr);
-		}
-		else if (!strncmp(kstr,"<!DOCTYPE",9)) {
-			kdtd=new KML_File();
-			KMLFileTagAttrib(kdtd,
-							 kstr);
-		}
-		else if (!strncmp(kstr,"<kml"     ,4)) {
-			kfil=new KML_File();
-			kfil->Read(fid,kstr);
-//			kfil->DeepEcho();
-		}
-
-//		_printf_(true,"%s\n",kstr);
-		xfree((void**)&kstr);
-	}
-
-	if (kxml) {
-		_printf_(true,"XML declaration:\n");
-		kxml->DeepEcho("  ");
-		delete kxml;
-	}
-	if (kdtd) {
-		_printf_(true,"DTD declaration (not yet implemented):\n");
-		kdtd->DeepEcho("  ");
-		delete kdtd;
-	}
-
-	clock1=clock();
-	time1 =time(NULL);
-	_printf_(true,"KMLFileReadx Module -- %f CPU seconds; %f elapsed seconds.\n\n",
-			 ((double)(clock1-clock0))/CLOCKS_PER_SEC,difftime(time1,time0));
-
-	return(kfil);
-}
-
Index: sm/trunk/src/c/modules/KMLMeshWritex/KMLFileReadx.h
===================================================================
--- /issm/trunk/src/c/modules/KMLMeshWritex/KMLFileReadx.h	(revision 11526)
+++ 	(revision )
@@ -1,15 +1,0 @@
-/*!\file:  KMLFileReadx.h
- * \brief header file for kml mesh writer routines.
- */ 
-
-#ifndef _KMLFILEREADX_H
-#define _KMLFILEREADX_H
-
-#include <float.h>    /*  DBL_MAX  */
-#include "../../Container/Container.h"
-#include "../../objects/objects.h"
-
-/* local prototypes: */
-KML_Object* KMLFileReadx(FILE* fid);
-
-#endif  /* _KMLFILEREADX_H */
Index: /issm/trunk/src/c/modules/ModelProcessorx/Balancethickness/UpdateElementsBalancethickness.cpp
===================================================================
--- /issm/trunk/src/c/modules/ModelProcessorx/Balancethickness/UpdateElementsBalancethickness.cpp	(revision 11526)
+++ /issm/trunk/src/c/modules/ModelProcessorx/Balancethickness/UpdateElementsBalancethickness.cpp	(revision 11527)
@@ -42,6 +42,4 @@
 	iomodel->FetchDataToInput(elements,VyEnum);
 	iomodel->FetchDataToInput(elements,BasalforcingsMeltingRateEnum);
-	iomodel->FetchDataToInput(elements,SurfaceforcingsAccumulationRateEnum);
-	iomodel->FetchDataToInput(elements,SurfaceforcingsAblationRateEnum);
 	iomodel->FetchDataToInput(elements,SurfaceforcingsMassBalanceEnum);
 	iomodel->FetchDataToInput(elements,BalancethicknessThickeningRateEnum);
Index: /issm/trunk/src/c/modules/ModelProcessorx/Control/CreateParametersControl.cpp
===================================================================
--- /issm/trunk/src/c/modules/ModelProcessorx/Control/CreateParametersControl.cpp	(revision 11526)
+++ /issm/trunk/src/c/modules/ModelProcessorx/Control/CreateParametersControl.cpp	(revision 11527)
@@ -40,4 +40,5 @@
 		parameters->AddObject(iomodel->CopyConstantObject(InversionCostFunctionThresholdEnum));
 		parameters->AddObject(iomodel->CopyConstantObject(InversionGradientOnlyEnum));
+		parameters->AddObject(iomodel->CopyConstantObject(InversionIncompleteAdjointEnum));
 
 		/*What solution type?*/
Index: /issm/trunk/src/c/modules/ModelProcessorx/CreateParameters.cpp
===================================================================
--- /issm/trunk/src/c/modules/ModelProcessorx/CreateParameters.cpp	(revision 11526)
+++ /issm/trunk/src/c/modules/ModelProcessorx/CreateParameters.cpp	(revision 11527)
@@ -40,4 +40,5 @@
 	parameters->AddObject(iomodel->CopyConstantObject(DiagnosticReltolEnum));
 	parameters->AddObject(iomodel->CopyConstantObject(DiagnosticAbstolEnum));
+	parameters->AddObject(iomodel->CopyConstantObject(DiagnosticIsnewtonEnum));
 	parameters->AddObject(iomodel->CopyConstantObject(DiagnosticMaxiterEnum));
 	parameters->AddObject(iomodel->CopyConstantObject(SteadystateReltolEnum));
@@ -78,4 +79,5 @@
 	parameters->AddObject(iomodel->CopyConstantObject(TransientIsthermalEnum));
 	parameters->AddObject(iomodel->CopyConstantObject(TransientIsgroundinglineEnum));
+	parameters->AddObject(iomodel->CopyConstantObject(ThermalIsenthalpyEnum));
 	parameters->AddObject(iomodel->CopyConstantObject(MaterialsRheologyLawEnum));
 	parameters->AddObject(iomodel->CopyConstantObject(AutodiffIsautodiffEnum));
@@ -84,4 +86,5 @@
 	parameters->AddObject(iomodel->CopyConstantObject(QmuIsdakotaEnum));
 	parameters->AddObject(iomodel->CopyConstantObject(InversionIscontrolEnum));
+	parameters->AddObject(iomodel->CopyConstantObject(InversionTaoEnum));
 
 	/*some parameters that did not come with the iomodel: */
Index: /issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHoriz/UpdateElementsDiagnosticHoriz.cpp
===================================================================
--- /issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHoriz/UpdateElementsDiagnosticHoriz.cpp	(revision 11526)
+++ /issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHoriz/UpdateElementsDiagnosticHoriz.cpp	(revision 11527)
@@ -66,6 +66,4 @@
 		iomodel->FetchDataToInput(elements,MeshElementonsurfaceEnum);
 		iomodel->FetchDataToInput(elements,VzEnum);
-		iomodel->FetchDataToInput(elements,SurfaceforcingsAccumulationRateEnum);
-		iomodel->FetchDataToInput(elements,SurfaceforcingsAblationRateEnum);
 		iomodel->FetchDataToInput(elements,SurfaceforcingsMassBalanceEnum);
 		iomodel->FetchDataToInput(elements,BasalforcingsMeltingRateEnum);
Index: /issm/trunk/src/c/modules/ModelProcessorx/DiagnosticVert/UpdateElementsDiagnosticVert.cpp
===================================================================
--- /issm/trunk/src/c/modules/ModelProcessorx/DiagnosticVert/UpdateElementsDiagnosticVert.cpp	(revision 11526)
+++ /issm/trunk/src/c/modules/ModelProcessorx/DiagnosticVert/UpdateElementsDiagnosticVert.cpp	(revision 11527)
@@ -48,6 +48,4 @@
 	iomodel->FetchDataToInput(elements,MaskElementonwaterEnum);
 	iomodel->FetchDataToInput(elements,BasalforcingsMeltingRateEnum);
-	iomodel->FetchDataToInput(elements,SurfaceforcingsAccumulationRateEnum);
-	iomodel->FetchDataToInput(elements,SurfaceforcingsAblationRateEnum);
 	iomodel->FetchDataToInput(elements,SurfaceforcingsMassBalanceEnum);
 	iomodel->FetchDataToInput(elements,VxEnum);
Index: /issm/trunk/src/c/modules/ModelProcessorx/Enthalpy/CreateConstraintsEnthalpy.cpp
===================================================================
--- /issm/trunk/src/c/modules/ModelProcessorx/Enthalpy/CreateConstraintsEnthalpy.cpp	(revision 11526)
+++ /issm/trunk/src/c/modules/ModelProcessorx/Enthalpy/CreateConstraintsEnthalpy.cpp	(revision 11527)
@@ -55,7 +55,7 @@
 		if((iomodel->my_vertices[i])){
 
-			if ((int)spctemperature[2*i]){
+			if (!isnan(spctemperature[i])){
 
-				constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,1,heatcapacity*(spctemperature[2*i+1]-referencetemperature),EnthalpyAnalysisEnum));
+				constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,1,heatcapacity*(spctemperature[i]-referencetemperature),EnthalpyAnalysisEnum));
 				count++;
 
Index: /issm/trunk/src/c/modules/ModelProcessorx/Enthalpy/UpdateElementsEnthalpy.cpp
===================================================================
--- /issm/trunk/src/c/modules/ModelProcessorx/Enthalpy/UpdateElementsEnthalpy.cpp	(revision 11526)
+++ /issm/trunk/src/c/modules/ModelProcessorx/Enthalpy/UpdateElementsEnthalpy.cpp	(revision 11527)
@@ -27,5 +27,5 @@
 
 	/*Fetch data needed: */
-	iomodel->FetchData(1,MeshElementsEnum);
+	iomodel->FetchData(4,MeshElementsEnum,TemperatureEnum,WaterfractionEnum,PressureEnum);
 
 	/*Update elements: */
@@ -61,4 +61,4 @@
 	
 	/*Free data: */
-	iomodel->DeleteData(1,MeshElementsEnum);
+	iomodel->DeleteData(4,MeshElementsEnum,TemperatureEnum,WaterfractionEnum,PressureEnum);
 }
Index: /issm/trunk/src/c/modules/ModelProcessorx/Melting/UpdateElementsMelting.cpp
===================================================================
--- /issm/trunk/src/c/modules/ModelProcessorx/Melting/UpdateElementsMelting.cpp	(revision 11526)
+++ /issm/trunk/src/c/modules/ModelProcessorx/Melting/UpdateElementsMelting.cpp	(revision 11527)
@@ -53,7 +53,4 @@
 	iomodel->FetchDataToInput(elements,MaterialsRheologyBEnum);
 	iomodel->FetchDataToInput(elements,MaterialsRheologyNEnum);
-	iomodel->FetchDataToInput(elements,SurfaceforcingsAccumulationRateEnum);
-	iomodel->FetchDataToInput(elements,SurfaceforcingsAblationRateEnum);
-	iomodel->FetchDataToInput(elements,SurfaceforcingsMassBalanceEnum);
 	iomodel->FetchDataToInput(elements,BasalforcingsMeltingRateEnum);
 	iomodel->FetchDataToInput(elements,PressureEnum);
Index: /issm/trunk/src/c/modules/ModelProcessorx/ModelProcessorx.cpp
===================================================================
--- /issm/trunk/src/c/modules/ModelProcessorx/ModelProcessorx.cpp	(revision 11526)
+++ /issm/trunk/src/c/modules/ModelProcessorx/ModelProcessorx.cpp	(revision 11527)
@@ -20,5 +20,5 @@
 
 	int   i,analysis_type,dim,verbose;
-	bool  isthermal,isprognostic,isdiagnostic,isgroundingline;
+	bool  isthermal,isprognostic,isdiagnostic,isgroundingline,isenthalpy;
 	
 	/*output: */
@@ -39,4 +39,5 @@
 	iomodel->Constant(&verbose,VerboseEnum);
 	iomodel->Constant(&isthermal,TransientIsthermalEnum);
+	iomodel->Constant(&isenthalpy,ThermalIsenthalpyEnum);
 	iomodel->Constant(&isprognostic,TransientIsprognosticEnum);
 	iomodel->Constant(&isdiagnostic,TransientIsdiagnosticEnum);
@@ -52,6 +53,11 @@
 		if(solution_type==TransientSolutionEnum && analysis_type==ThermalAnalysisEnum && dim==2) continue;
 		if(solution_type==TransientSolutionEnum && analysis_type==MeltingAnalysisEnum && dim==2) continue;
+		if(solution_type==TransientSolutionEnum && analysis_type==EnthalpyAnalysisEnum && dim==2) continue;
 		if(solution_type==TransientSolutionEnum && analysis_type==ThermalAnalysisEnum && isthermal==false) continue;
 		if(solution_type==TransientSolutionEnum && analysis_type==MeltingAnalysisEnum && isthermal==false) continue;
+		if(solution_type==TransientSolutionEnum && analysis_type==EnthalpyAnalysisEnum && isthermal==false) continue;
+		if(solution_type==TransientSolutionEnum && analysis_type==ThermalAnalysisEnum && isenthalpy==true) continue;
+		if(solution_type==TransientSolutionEnum && analysis_type==MeltingAnalysisEnum && isenthalpy==true) continue;
+		if(solution_type==TransientSolutionEnum && analysis_type==EnthalpyAnalysisEnum && isenthalpy==false) continue;
 		if(solution_type==TransientSolutionEnum && analysis_type==PrognosticAnalysisEnum && isprognostic==false && isgroundingline==false) continue;
 		if(solution_type==TransientSolutionEnum && analysis_type==DiagnosticHorizAnalysisEnum && isdiagnostic==false) continue;
Index: /issm/trunk/src/c/modules/ModelProcessorx/Prognostic/UpdateElementsPrognostic.cpp
===================================================================
--- /issm/trunk/src/c/modules/ModelProcessorx/Prognostic/UpdateElementsPrognostic.cpp	(revision 11526)
+++ /issm/trunk/src/c/modules/ModelProcessorx/Prognostic/UpdateElementsPrognostic.cpp	(revision 11527)
@@ -44,6 +44,5 @@
 	iomodel->FetchDataToInput(elements,MaskElementonfloatingiceEnum);
 	iomodel->FetchDataToInput(elements,MaskElementonwaterEnum);
-	iomodel->FetchDataToInput(elements,SurfaceforcingsAccumulationRateEnum);
-	iomodel->FetchDataToInput(elements,SurfaceforcingsAblationRateEnum);
+	iomodel->FetchDataToInput(elements,SurfaceforcingsPrecipitationEnum);
 	iomodel->FetchDataToInput(elements,SurfaceforcingsMassBalanceEnum);
 	iomodel->FetchDataToInput(elements,BasalforcingsMeltingRateEnum);
Index: /issm/trunk/src/c/modules/PointCloudFindNeighborsx/PointCloudFindNeighborsx.cpp
===================================================================
--- /issm/trunk/src/c/modules/PointCloudFindNeighborsx/PointCloudFindNeighborsx.cpp	(revision 11526)
+++ /issm/trunk/src/c/modules/PointCloudFindNeighborsx/PointCloudFindNeighborsx.cpp	(revision 11527)
@@ -36,3 +36,5 @@
 	/*Assign output pointers: */
 	*pflags=flags;
+
+	return 1;
 }
Index: /issm/trunk/src/c/modules/PointCloudFindNeighborsx/PointCloudFindNeighborsxt.cpp
===================================================================
--- /issm/trunk/src/c/modules/PointCloudFindNeighborsx/PointCloudFindNeighborsxt.cpp	(revision 11526)
+++ /issm/trunk/src/c/modules/PointCloudFindNeighborsx/PointCloudFindNeighborsxt.cpp	(revision 11527)
@@ -74,3 +74,5 @@
 	/*Free ressources:*/
 	xfree((void**)&already);
+	
+	return NULL;
 }
Index: /issm/trunk/src/c/modules/PositiveDegreeDayx/PositiveDegreeDayx.cpp
===================================================================
--- /issm/trunk/src/c/modules/PositiveDegreeDayx/PositiveDegreeDayx.cpp	(revision 11527)
+++ /issm/trunk/src/c/modules/PositiveDegreeDayx/PositiveDegreeDayx.cpp	(revision 11527)
@@ -0,0 +1,21 @@
+/*!\file PositiveDegreeDayx
+ * \brief: create system matrices (stiffness matrix, loads vector)
+ */
+
+#include "./PositiveDegreeDayx.h"
+#include "../../shared/shared.h"
+#include "../../include/include.h"
+#include "../../io/io.h"
+#include "../../toolkits/toolkits.h"
+#include "../../EnumDefinitions/EnumDefinitions.h"
+
+void PositiveDegreeDayx(Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads,Materials* materials, Parameters* parameters){
+	
+	Element* element = NULL;
+
+	for(int i=0;i<elements->Size();i++){
+		element=(Element*)elements->GetObjectByOffset(i);
+		element->PositiveDegreeDay();
+	}
+
+}
Index: /issm/trunk/src/c/modules/PositiveDegreeDayx/PositiveDegreeDayx.h
===================================================================
--- /issm/trunk/src/c/modules/PositiveDegreeDayx/PositiveDegreeDayx.h	(revision 11527)
+++ /issm/trunk/src/c/modules/PositiveDegreeDayx/PositiveDegreeDayx.h	(revision 11527)
@@ -0,0 +1,14 @@
+/*!\file:  PositiveDegreeDayx.h
+ * \brief header file for degree of freedoms distribution routines.
+ */ 
+
+#ifndef _POSITIVEDEGREEDAYX_H
+#define _POSITIVEDEGREEDAYX_H
+
+#include "../../Container/Container.h"
+#include "../../objects/objects.h"
+
+/* local prototypes: */
+void PositiveDegreeDayx(Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads,Materials* materials, Parameters* parameters);
+
+#endif  /* _POSITIVEDEGREEDAYX_H*/
Index: /issm/trunk/src/c/modules/Scotchx/Scotchx.cpp
===================================================================
--- /issm/trunk/src/c/modules/Scotchx/Scotchx.cpp	(revision 11526)
+++ /issm/trunk/src/c/modules/Scotchx/Scotchx.cpp	(revision 11527)
@@ -339,4 +339,6 @@
   return (0);
 
-#endif //#ifdef _HAVE_SCOTCH_ 
+#else //#ifdef _HAVE_SCOTCH_ 
+  return(0);
+#endif
 }
Index: /issm/trunk/src/c/modules/SetControlInputsFromVectorx/SetControlInputsFromVectorx.cpp
===================================================================
--- /issm/trunk/src/c/modules/SetControlInputsFromVectorx/SetControlInputsFromVectorx.cpp	(revision 11527)
+++ /issm/trunk/src/c/modules/SetControlInputsFromVectorx/SetControlInputsFromVectorx.cpp	(revision 11527)
@@ -0,0 +1,40 @@
+/*!\file SetControlInputsFromVectorx
+ * \brief retrieve vector from inputs in elements
+ */
+
+#include "./SetControlInputsFromVectorx.h"
+#include "../../shared/shared.h"
+#include "../../include/include.h"
+#include "../../toolkits/toolkits.h"
+#include "../../EnumDefinitions/EnumDefinitions.h"
+
+void SetControlInputsFromVectorx(Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,double* vector){
+
+	int  num_controls;
+	int *control_type = NULL;
+
+	/*Retrieve some parameters*/
+	parameters->FindParam(&num_controls,InversionNumControlParametersEnum);
+	parameters->FindParam(&control_type,NULL,InversionControlParametersEnum);
+
+	for(int i=0;i<num_controls;i++){
+		for(int j=0;j<elements->Size();j++){
+			Element* element=(Element*)elements->GetObjectByOffset(j);
+			element->SetControlInputsFromVector(vector,control_type[i],i);
+		}
+	}
+
+	xfree((void**)&control_type);
+}
+
+void SetControlInputsFromVectorx(Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,Vec vector){
+	
+	double* serial_vector=NULL;
+
+	VecToMPISerial(&serial_vector,vector);
+
+	SetControlInputsFromVectorx(elements,nodes, vertices, loads, materials, parameters,serial_vector);
+
+	/*Free ressources:*/
+	xfree((void**)&serial_vector);
+}
Index: /issm/trunk/src/c/modules/SetControlInputsFromVectorx/SetControlInputsFromVectorx.h
===================================================================
--- /issm/trunk/src/c/modules/SetControlInputsFromVectorx/SetControlInputsFromVectorx.h	(revision 11527)
+++ /issm/trunk/src/c/modules/SetControlInputsFromVectorx/SetControlInputsFromVectorx.h	(revision 11527)
@@ -0,0 +1,14 @@
+/*!\file:  SetControlInputsFromVectorx.h
+ */ 
+
+#ifndef _SETCONTROLINPUTSXFROMVECTOR_H
+#define _SETCONTROLINPUTSXFROMVECTOR_H
+
+#include "../../objects/objects.h"
+#include "../../Container/Container.h"
+
+/* local prototypes: */
+void SetControlInputsFromVectorx(Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters,Vec vector);
+void SetControlInputsFromVectorx(Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters,double* vector);
+
+#endif 
Index: /issm/trunk/src/c/modules/Shp2Kmlx/Shp2Kmlx.cpp
===================================================================
--- /issm/trunk/src/c/modules/Shp2Kmlx/Shp2Kmlx.cpp	(revision 11526)
+++ /issm/trunk/src/c/modules/Shp2Kmlx/Shp2Kmlx.cpp	(revision 11527)
@@ -24,5 +24,7 @@
 					sgn,cm,sp));
 
-	#endif //ifdef _HAVE_SHAPELIB_
+	#else //ifdef _HAVE_SHAPELIB_
+	return 0;
+	#endif
 }
 
@@ -607,5 +609,7 @@
 	return(iret);
 
-	#endif //ifdef _HAVE_SHAPELIB_
+	#else //ifdef _HAVE_SHAPELIB_
+	return 0;
+	#endif
 }
 
Index: /issm/trunk/src/c/modules/SmearFunctionx/SmearFunctionx.cpp
===================================================================
--- /issm/trunk/src/c/modules/SmearFunctionx/SmearFunctionx.cpp	(revision 11527)
+++ /issm/trunk/src/c/modules/SmearFunctionx/SmearFunctionx.cpp	(revision 11527)
@@ -0,0 +1,56 @@
+/*!\file SmearFunctionx
+ * \brief: create 
+ */
+
+#include "./SmearFunctionx.h"
+#include "../../shared/shared.h"
+#include "../../include/include.h"
+#include "../../io/io.h"
+#include "../../toolkits/toolkits.h"
+#include "../../EnumDefinitions/EnumDefinitions.h"
+
+void SmearFunctionx(Vec* psmearedvector,double (*WeightFunction)(double distance,double radius), int SmearedFieldEnum, double radius,Elements* elements,Nodes* nodes, Parameters* parameters){
+	
+	Element *element = NULL;
+	Vec x=NULL;
+	Vec y=NULL;
+	Vec z=NULL;
+	Vec smearedvector=NULL;
+	int i;
+
+	double* x_serial=NULL;
+	double* y_serial=NULL;
+	double* z_serial=NULL;
+
+	/*retrive parameters: */
+	parameters->FindParam(&configuration_type,ConfigurationTypeEnum);
+
+	/*allocate: */
+	gsize=nodes->NumberOfDofs(configuration_type,GsetEnum);
+	smearedvector=NewVec(gsize);
+	
+	x=NewVec(gsize);
+	y=NewVec(gsize);
+	z=NewVec(gsize);
+
+	for(i=0;i<nodes->Size();i++){
+
+	}
+
+
+
+	/*Fill smearedvector vector: */
+	for (i=0;i<elements->Size();i++){
+		element=(Element*)elements->GetObjectByOffset(i);
+		element->SmearFunction(smearedvector,WeightFunction,SmearedFieldEnum,radius);
+	}
+
+
+	VecAssemblyBegin(smearedvector);
+	VecAssemblyEnd(smearedvector);
+	
+	/*Assign output pointers: */
+	*psmearedvector=smearedvector;
+
+}
+
Index: /issm/trunk/src/c/modules/SmearFunctionx/SmearFunctionx.h
===================================================================
--- /issm/trunk/src/c/modules/SmearFunctionx/SmearFunctionx.h	(revision 11527)
+++ /issm/trunk/src/c/modules/SmearFunctionx/SmearFunctionx.h	(revision 11527)
@@ -0,0 +1,15 @@
+/*!\file:  SystemMatricesx.h
+ * \brief header file for degree of freedoms distribution routines.
+ */ 
+
+#ifndef _SYSTEMMATRICESX_H
+#define _SYSTEMMATRICESX_H
+
+#include "../../Container/Container.h"
+#include "../../objects/objects.h"
+
+/* 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,
+			bool kflag=true,bool pflag=true,bool penalty_kflag=true,bool penalty_pflag=true);
+
+#endif  /* _SYSTEMMATRICESX_H */
Index: /issm/trunk/src/c/modules/Solverx/Solverx.cpp
===================================================================
--- /issm/trunk/src/c/modules/Solverx/Solverx.cpp	(revision 11526)
+++ /issm/trunk/src/c/modules/Solverx/Solverx.cpp	(revision 11527)
@@ -108,4 +108,14 @@
 	#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);
@@ -113,13 +123,17 @@
 	KSPSetFromOptions(ksp);
 
-	#if defined(_SERIAL_) && _PETSC_VERSION_==3
+	#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_VERSION_==3
+	#if defined(_PARALLEL_) && _PETSC_MAJOR_==3
 	/*Stokes: */
 	if (solver_type==StokesSolverEnum){
@@ -130,6 +144,11 @@
 		/*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
 
 	}
Index: /issm/trunk/src/c/modules/StringToEnumx/StringToEnumx.cpp
===================================================================
--- /issm/trunk/src/c/modules/StringToEnumx/StringToEnumx.cpp	(revision 11526)
+++ /issm/trunk/src/c/modules/StringToEnumx/StringToEnumx.cpp	(revision 11527)
@@ -14,430 +14,447 @@
 int  StringToEnumx(const char* name){
 
-	if (strcmp(name,"AutodiffForward")==0) return AutodiffForwardEnum;
-	else if (strcmp(name,"AutodiffIsautodiff")==0) return AutodiffIsautodiffEnum;
-	else if (strcmp(name,"AutodiffReverse")==0) return AutodiffReverseEnum;
-	else if (strcmp(name,"BalancethicknessSpcthickness")==0) return BalancethicknessSpcthicknessEnum;
-	else if (strcmp(name,"BalancethicknessStabilization")==0) return BalancethicknessStabilizationEnum;
-	else if (strcmp(name,"BalancethicknessThickeningRate")==0) return BalancethicknessThickeningRateEnum;
-	else if (strcmp(name,"BasalforcingsGeothermalflux")==0) return BasalforcingsGeothermalfluxEnum;
-	else if (strcmp(name,"BasalforcingsMeltingRateCorrection")==0) return BasalforcingsMeltingRateCorrectionEnum;
-	else if (strcmp(name,"BasalforcingsMeltingRate")==0) return BasalforcingsMeltingRateEnum;
-	else if (strcmp(name,"Bathymetry")==0) return BathymetryEnum;
-	else if (strcmp(name,"Bed")==0) return BedEnum;
-	else if (strcmp(name,"ConstantsG")==0) return ConstantsGEnum;
-	else if (strcmp(name,"ConstantsReferencetemperature")==0) return ConstantsReferencetemperatureEnum;
-	else if (strcmp(name,"ConstantsYts")==0) return ConstantsYtsEnum;
-	else if (strcmp(name,"DiagnosticAbstol")==0) return DiagnosticAbstolEnum;
-	else if (strcmp(name,"DiagnosticIcefront")==0) return DiagnosticIcefrontEnum;
-	else if (strcmp(name,"DiagnosticMaxiter")==0) return DiagnosticMaxiterEnum;
-	else if (strcmp(name,"DiagnosticNumRequestedOutputs")==0) return DiagnosticNumRequestedOutputsEnum;
-	else if (strcmp(name,"DiagnosticPenaltyFactor")==0) return DiagnosticPenaltyFactorEnum;
-	else if (strcmp(name,"DiagnosticReferential")==0) return DiagnosticReferentialEnum;
-	else if (strcmp(name,"DiagnosticReltol")==0) return DiagnosticReltolEnum;
-	else if (strcmp(name,"DiagnosticRequestedOutputs")==0) return DiagnosticRequestedOutputsEnum;
-	else if (strcmp(name,"DiagnosticRestol")==0) return DiagnosticRestolEnum;
-	else if (strcmp(name,"DiagnosticRiftPenaltyLock")==0) return DiagnosticRiftPenaltyLockEnum;
-	else if (strcmp(name,"DiagnosticRiftPenaltyThreshold")==0) return DiagnosticRiftPenaltyThresholdEnum;
-	else if (strcmp(name,"DiagnosticShelfDampening")==0) return DiagnosticShelfDampeningEnum;
-	else if (strcmp(name,"DiagnosticSpcvx")==0) return DiagnosticSpcvxEnum;
-	else if (strcmp(name,"DiagnosticSpcvy")==0) return DiagnosticSpcvyEnum;
-	else if (strcmp(name,"DiagnosticSpcvz")==0) return DiagnosticSpcvzEnum;
-	else if (strcmp(name,"DiagnosticStokesreconditioning")==0) return DiagnosticStokesreconditioningEnum;
-	else if (strcmp(name,"DiagnosticVertexPairing")==0) return DiagnosticVertexPairingEnum;
-	else if (strcmp(name,"DiagnosticViscosityOvershoot")==0) return DiagnosticViscosityOvershootEnum;
-	else if (strcmp(name,"FlowequationBordermacayeal")==0) return FlowequationBordermacayealEnum;
-	else if (strcmp(name,"FlowequationBorderpattyn")==0) return FlowequationBorderpattynEnum;
-	else if (strcmp(name,"FlowequationBorderstokes")==0) return FlowequationBorderstokesEnum;
-	else if (strcmp(name,"FlowequationElementEquation")==0) return FlowequationElementEquationEnum;
-	else if (strcmp(name,"FlowequationIshutter")==0) return FlowequationIshutterEnum;
-	else if (strcmp(name,"FlowequationIsmacayealpattyn")==0) return FlowequationIsmacayealpattynEnum;
-	else if (strcmp(name,"FlowequationIsstokes")==0) return FlowequationIsstokesEnum;
-	else if (strcmp(name,"FlowequationVertexEquation")==0) return FlowequationVertexEquationEnum;
-	else if (strcmp(name,"FrictionCoefficient")==0) return FrictionCoefficientEnum;
-	else if (strcmp(name,"FrictionP")==0) return FrictionPEnum;
-	else if (strcmp(name,"FrictionQ")==0) return FrictionQEnum;
-	else if (strcmp(name,"GeometryHydrostaticRatio")==0) return GeometryHydrostaticRatioEnum;
-	else if (strcmp(name,"HydrologyCR")==0) return HydrologyCREnum;
-	else if (strcmp(name,"HydrologyKn")==0) return HydrologyKnEnum;
-	else if (strcmp(name,"HydrologyN")==0) return HydrologyNEnum;
-	else if (strcmp(name,"HydrologyP")==0) return HydrologyPEnum;
-	else if (strcmp(name,"HydrologyQ")==0) return HydrologyQEnum;
-	else if (strcmp(name,"HydrologySpcwatercolumn")==0) return HydrologySpcwatercolumnEnum;
-	else if (strcmp(name,"HydrologyStabilization")==0) return HydrologyStabilizationEnum;
-	else if (strcmp(name,"InversionControlParameters")==0) return InversionControlParametersEnum;
-	else if (strcmp(name,"InversionCostFunction")==0) return InversionCostFunctionEnum;
-	else if (strcmp(name,"InversionCostFunctionThreshold")==0) return InversionCostFunctionThresholdEnum;
-	else if (strcmp(name,"InversionCostFunctionsCoefficients")==0) return InversionCostFunctionsCoefficientsEnum;
-	else if (strcmp(name,"InversionCostFunctions")==0) return InversionCostFunctionsEnum;
-	else if (strcmp(name,"InversionGradientOnly")==0) return InversionGradientOnlyEnum;
-	else if (strcmp(name,"InversionGradientScaling")==0) return InversionGradientScalingEnum;
-	else if (strcmp(name,"InversionIscontrol")==0) return InversionIscontrolEnum;
-	else if (strcmp(name,"InversionMaxParameters")==0) return InversionMaxParametersEnum;
-	else if (strcmp(name,"InversionMaxiterPerStep")==0) return InversionMaxiterPerStepEnum;
-	else if (strcmp(name,"InversionMinParameters")==0) return InversionMinParametersEnum;
-	else if (strcmp(name,"InversionNsteps")==0) return InversionNstepsEnum;
-	else if (strcmp(name,"InversionNumControlParameters")==0) return InversionNumControlParametersEnum;
-	else if (strcmp(name,"InversionNumCostFunctions")==0) return InversionNumCostFunctionsEnum;
-	else if (strcmp(name,"InversionStepThreshold")==0) return InversionStepThresholdEnum;
-	else if (strcmp(name,"InversionThicknessObs")==0) return InversionThicknessObsEnum;
-	else if (strcmp(name,"InversionVelObs")==0) return InversionVelObsEnum;
-	else if (strcmp(name,"InversionVxObs")==0) return InversionVxObsEnum;
-	else if (strcmp(name,"InversionVyObs")==0) return InversionVyObsEnum;
-	else if (strcmp(name,"InversionVzObs")==0) return InversionVzObsEnum;
-	else if (strcmp(name,"MaskElementonfloatingice")==0) return MaskElementonfloatingiceEnum;
-	else if (strcmp(name,"MaskElementongroundedice")==0) return MaskElementongroundediceEnum;
-	else if (strcmp(name,"MaskElementonwater")==0) return MaskElementonwaterEnum;
-	else if (strcmp(name,"MaskVertexonfloatingice")==0) return MaskVertexonfloatingiceEnum;
-	else if (strcmp(name,"MaskVertexongroundedice")==0) return MaskVertexongroundediceEnum;
-	else if (strcmp(name,"MaskVertexonwater")==0) return MaskVertexonwaterEnum;
-	else if (strcmp(name,"MaterialsBeta")==0) return MaterialsBetaEnum;
-	else if (strcmp(name,"MaterialsHeatcapacity")==0) return MaterialsHeatcapacityEnum;
-	else if (strcmp(name,"MaterialsLatentheat")==0) return MaterialsLatentheatEnum;
-	else if (strcmp(name,"MaterialsMeltingpoint")==0) return MaterialsMeltingpointEnum;
-	else if (strcmp(name,"MaterialsMixedLayerCapacity")==0) return MaterialsMixedLayerCapacityEnum;
-	else if (strcmp(name,"MaterialsRheologyB")==0) return MaterialsRheologyBEnum;
-	else if (strcmp(name,"MaterialsRheologyBbar")==0) return MaterialsRheologyBbarEnum;
-	else if (strcmp(name,"MaterialsRheologyLaw")==0) return MaterialsRheologyLawEnum;
-	else if (strcmp(name,"MaterialsRheologyN")==0) return MaterialsRheologyNEnum;
-	else if (strcmp(name,"MaterialsRhoIce")==0) return MaterialsRhoIceEnum;
-	else if (strcmp(name,"MaterialsRhoWater")==0) return MaterialsRhoWaterEnum;
-	else if (strcmp(name,"MaterialsMuWater")==0) return MaterialsMuWaterEnum;
-	else if (strcmp(name,"MaterialsThermalExchangeVelocity")==0) return MaterialsThermalExchangeVelocityEnum;
-	else if (strcmp(name,"MaterialsThermalconductivity")==0) return MaterialsThermalconductivityEnum;
-	else if (strcmp(name,"MeshAverageVertexConnectivity")==0) return MeshAverageVertexConnectivityEnum;
-	else if (strcmp(name,"MeshDimension")==0) return MeshDimensionEnum;
-	else if (strcmp(name,"MeshEdges")==0) return MeshEdgesEnum;
-	else if (strcmp(name,"MeshElementconnectivity")==0) return MeshElementconnectivityEnum;
-	else if (strcmp(name,"MeshElementonbed")==0) return MeshElementonbedEnum;
-	else if (strcmp(name,"MeshElementonsurface")==0) return MeshElementonsurfaceEnum;
-	else if (strcmp(name,"MeshElements2d")==0) return MeshElements2dEnum;
-	else if (strcmp(name,"MeshElements")==0) return MeshElementsEnum;
-	else if (strcmp(name,"MeshLowerelements")==0) return MeshLowerelementsEnum;
-	else if (strcmp(name,"MeshNumberofedges")==0) return MeshNumberofedgesEnum;
-	else if (strcmp(name,"MeshNumberofelements2d")==0) return MeshNumberofelements2dEnum;
-	else if (strcmp(name,"MeshNumberofelements")==0) return MeshNumberofelementsEnum;
-	else if (strcmp(name,"MeshNumberoflayers")==0) return MeshNumberoflayersEnum;
-	else if (strcmp(name,"MeshNumberofvertices2d")==0) return MeshNumberofvertices2dEnum;
-	else if (strcmp(name,"MeshNumberofvertices")==0) return MeshNumberofverticesEnum;
-	else if (strcmp(name,"MeshUpperelements")==0) return MeshUpperelementsEnum;
-	else if (strcmp(name,"MeshVertexonbed")==0) return MeshVertexonbedEnum;
-	else if (strcmp(name,"MeshVertexonsurface")==0) return MeshVertexonsurfaceEnum;
-	else if (strcmp(name,"MeshX")==0) return MeshXEnum;
-	else if (strcmp(name,"MeshY")==0) return MeshYEnum;
-	else if (strcmp(name,"MeshZ")==0) return MeshZEnum;
-	else if (strcmp(name,"MiscellaneousName")==0) return MiscellaneousNameEnum;
-	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 if (strcmp(name,"PrognosticStabilization")==0) return PrognosticStabilizationEnum;
-	else if (strcmp(name,"PrognosticVertexPairing")==0) return PrognosticVertexPairingEnum;
-	else if (strcmp(name,"QmuIsdakota")==0) return QmuIsdakotaEnum;
-	else if (strcmp(name,"QmuMassFluxSegments")==0) return QmuMassFluxSegmentsEnum;
-	else if (strcmp(name,"QmuNumberofpartitions")==0) return QmuNumberofpartitionsEnum;
-	else if (strcmp(name,"QmuNumberofresponses")==0) return QmuNumberofresponsesEnum;
-	else if (strcmp(name,"QmuPartition")==0) return QmuPartitionEnum;
-	else if (strcmp(name,"QmuResponsedescriptors")==0) return QmuResponsedescriptorsEnum;
-	else if (strcmp(name,"QmuVariabledescriptors")==0) return QmuVariabledescriptorsEnum;
-	else if (strcmp(name,"RiftsNumrifts")==0) return RiftsNumriftsEnum;
-	else if (strcmp(name,"RiftsRiftstruct")==0) return RiftsRiftstructEnum;
-	else if (strcmp(name,"SettingsIoGather")==0) return SettingsIoGatherEnum;
-	else if (strcmp(name,"SettingsLowmem")==0) return SettingsLowmemEnum;
-	else if (strcmp(name,"SettingsOutputFrequency")==0) return SettingsOutputFrequencyEnum;
-	else if (strcmp(name,"SettingsResultsAsPatches")==0) return SettingsResultsAsPatchesEnum;
-	else if (strcmp(name,"SettingsWaitonlock")==0) return SettingsWaitonlockEnum;
-	else if (strcmp(name,"SteadystateMaxiter")==0) return SteadystateMaxiterEnum;
-	else if (strcmp(name,"SteadystateNumRequestedOutputs")==0) return SteadystateNumRequestedOutputsEnum;
-	else if (strcmp(name,"SteadystateReltol")==0) return SteadystateReltolEnum;
-	else if (strcmp(name,"SteadystateRequestedOutputs")==0) return SteadystateRequestedOutputsEnum;
-	else if (strcmp(name,"Surface")==0) return SurfaceEnum;
-	else if (strcmp(name,"SurfaceforcingsAblationRate")==0) return SurfaceforcingsAblationRateEnum;
-	else if (strcmp(name,"SurfaceforcingsAccumulationRate")==0) return SurfaceforcingsAccumulationRateEnum;
-	else if (strcmp(name,"SurfaceforcingsMassBalance")==0) return SurfaceforcingsMassBalanceEnum;
-	else if (strcmp(name,"ThermalMaxiter")==0) return ThermalMaxiterEnum;
-	else if (strcmp(name,"ThermalPenaltyFactor")==0) return ThermalPenaltyFactorEnum;
-	else if (strcmp(name,"ThermalPenaltyLock")==0) return ThermalPenaltyLockEnum;
-	else if (strcmp(name,"ThermalPenaltyThreshold")==0) return ThermalPenaltyThresholdEnum;
-	else if (strcmp(name,"ThermalSpctemperature")==0) return ThermalSpctemperatureEnum;
-	else if (strcmp(name,"ThermalStabilization")==0) return ThermalStabilizationEnum;
-	else if (strcmp(name,"Thickness")==0) return ThicknessEnum;
-	else if (strcmp(name,"TimesteppingCflCoefficient")==0) return TimesteppingCflCoefficientEnum;
-	else if (strcmp(name,"TimesteppingFinalTime")==0) return TimesteppingFinalTimeEnum;
-	else if (strcmp(name,"TimesteppingTimeAdapt")==0) return TimesteppingTimeAdaptEnum;
-	else if (strcmp(name,"TimesteppingTimeStep")==0) return TimesteppingTimeStepEnum;
-	else if (strcmp(name,"TransientIsdiagnostic")==0) return TransientIsdiagnosticEnum;
-	else if (strcmp(name,"TransientIsgroundingline")==0) return TransientIsgroundinglineEnum;
-	else if (strcmp(name,"TransientIsprognostic")==0) return TransientIsprognosticEnum;
-	else if (strcmp(name,"TransientIsthermal")==0) return TransientIsthermalEnum;
-	else if (strcmp(name,"TransientNumRequestedOutputs")==0) return TransientNumRequestedOutputsEnum;
-	else if (strcmp(name,"TransientRequestedOutputs")==0) return TransientRequestedOutputsEnum;
-	else if (strcmp(name,"SolutionType")==0) return SolutionTypeEnum;
-	else if (strcmp(name,"AnalysisType")==0) return AnalysisTypeEnum;
-	else if (strcmp(name,"ConfigurationType")==0) return ConfigurationTypeEnum;
-	else if (strcmp(name,"AdjointBalancethicknessAnalysis")==0) return AdjointBalancethicknessAnalysisEnum;
-	else if (strcmp(name,"AdjointHorizAnalysis")==0) return AdjointHorizAnalysisEnum;
-	else if (strcmp(name,"AdjointSolution")==0) return AdjointSolutionEnum;
-	else if (strcmp(name,"AnalysisCounter")==0) return AnalysisCounterEnum;
-	else if (strcmp(name,"BalancethicknessAnalysis")==0) return BalancethicknessAnalysisEnum;
-	else if (strcmp(name,"BalancethicknessSolution")==0) return BalancethicknessSolutionEnum;
-	else if (strcmp(name,"BedSlopeAnalysis")==0) return BedSlopeAnalysisEnum;
-	else if (strcmp(name,"BedSlopeSolution")==0) return BedSlopeSolutionEnum;
-	else if (strcmp(name,"BedSlopeXAnalysis")==0) return BedSlopeXAnalysisEnum;
-	else if (strcmp(name,"BedSlopeYAnalysis")==0) return BedSlopeYAnalysisEnum;
-	else if (strcmp(name,"DiagnosticHorizAnalysis")==0) return DiagnosticHorizAnalysisEnum;
-	else if (strcmp(name,"DiagnosticHutterAnalysis")==0) return DiagnosticHutterAnalysisEnum;
-	else if (strcmp(name,"DiagnosticSolution")==0) return DiagnosticSolutionEnum;
-	else if (strcmp(name,"DiagnosticVertAnalysis")==0) return DiagnosticVertAnalysisEnum;
-	else if (strcmp(name,"EnthalpyAnalysis")==0) return EnthalpyAnalysisEnum;
-	else if (strcmp(name,"EnthalpySolution")==0) return EnthalpySolutionEnum;
-	else if (strcmp(name,"FlaimAnalysis")==0) return FlaimAnalysisEnum;
-	else if (strcmp(name,"FlaimSolution")==0) return FlaimSolutionEnum;
-	else if (strcmp(name,"HydrologyAnalysis")==0) return HydrologyAnalysisEnum;
-	else if (strcmp(name,"HydrologySolution")==0) return HydrologySolutionEnum;
-	else if (strcmp(name,"MeltingAnalysis")==0) return MeltingAnalysisEnum;
-	else if (strcmp(name,"NoneAnalysis")==0) return NoneAnalysisEnum;
-	else if (strcmp(name,"PrognosticAnalysis")==0) return PrognosticAnalysisEnum;
-	else if (strcmp(name,"PrognosticSolution")==0) return PrognosticSolutionEnum;
-	else if (strcmp(name,"SteadystateSolution")==0) return SteadystateSolutionEnum;
-	else if (strcmp(name,"SurfaceSlopeAnalysis")==0) return SurfaceSlopeAnalysisEnum;
-	else if (strcmp(name,"SurfaceSlopeSolution")==0) return SurfaceSlopeSolutionEnum;
-	else if (strcmp(name,"SurfaceSlopeXAnalysis")==0) return SurfaceSlopeXAnalysisEnum;
-	else if (strcmp(name,"SurfaceSlopeYAnalysis")==0) return SurfaceSlopeYAnalysisEnum;
-	else if (strcmp(name,"ThermalAnalysis")==0) return ThermalAnalysisEnum;
-	else if (strcmp(name,"ThermalSolution")==0) return ThermalSolutionEnum;
-	else if (strcmp(name,"TransientSolution")==0) return TransientSolutionEnum;
-	else if (strcmp(name,"Approximation")==0) return ApproximationEnum;
-	else if (strcmp(name,"HutterApproximation")==0) return HutterApproximationEnum;
-	else if (strcmp(name,"MacAyealApproximation")==0) return MacAyealApproximationEnum;
-	else if (strcmp(name,"MacAyealPattynApproximation")==0) return MacAyealPattynApproximationEnum;
-	else if (strcmp(name,"MacAyealStokesApproximation")==0) return MacAyealStokesApproximationEnum;
-	else if (strcmp(name,"NoneApproximation")==0) return NoneApproximationEnum;
-	else if (strcmp(name,"PattynApproximation")==0) return PattynApproximationEnum;
-	else if (strcmp(name,"PattynStokesApproximation")==0) return PattynStokesApproximationEnum;
-	else if (strcmp(name,"StokesApproximation")==0) return StokesApproximationEnum;
-	else if (strcmp(name,"Constraints")==0) return ConstraintsEnum;
-	else if (strcmp(name,"Loads")==0) return LoadsEnum;
-	else if (strcmp(name,"Materials")==0) return MaterialsEnum;
-	else if (strcmp(name,"Nodes")==0) return NodesEnum;
-	else if (strcmp(name,"Parameters")==0) return ParametersEnum;
-	else if (strcmp(name,"Vertices")==0) return VerticesEnum;
-	else if (strcmp(name,"Results")==0) return ResultsEnum;
-	else if (strcmp(name,"BoolInput")==0) return BoolInputEnum;
-	else if (strcmp(name,"BoolParam")==0) return BoolParamEnum;
-	else if (strcmp(name,"ControlInput")==0) return ControlInputEnum;
-	else if (strcmp(name,"DatasetInput")==0) return DatasetInputEnum;
-	else if (strcmp(name,"DofIndexing")==0) return DofIndexingEnum;
-	else if (strcmp(name,"DoubleInput")==0) return DoubleInputEnum;
-	else if (strcmp(name,"DoubleMatArrayParam")==0) return DoubleMatArrayParamEnum;
-	else if (strcmp(name,"DoubleMatParam")==0) return DoubleMatParamEnum;
-	else if (strcmp(name,"DoubleParam")==0) return DoubleParamEnum;
-	else if (strcmp(name,"DoubleVecParam")==0) return DoubleVecParamEnum;
-	else if (strcmp(name,"Element")==0) return ElementEnum;
-	else if (strcmp(name,"ElementResult")==0) return ElementResultEnum;
-	else if (strcmp(name,"ExternalResult")==0) return ExternalResultEnum;
-	else if (strcmp(name,"FileParam")==0) return FileParamEnum;
-	else if (strcmp(name,"Hook")==0) return HookEnum;
-	else if (strcmp(name,"Icefront")==0) return IcefrontEnum;
-	else if (strcmp(name,"Input")==0) return InputEnum;
-	else if (strcmp(name,"IntInput")==0) return IntInputEnum;
-	else if (strcmp(name,"IntParam")==0) return IntParamEnum;
-	else if (strcmp(name,"IntVecParam")==0) return IntVecParamEnum;
-	else if (strcmp(name,"MacAyeal2dIceFront")==0) return MacAyeal2dIceFrontEnum;
-	else if (strcmp(name,"MacAyeal3dIceFront")==0) return MacAyeal3dIceFrontEnum;
-	else if (strcmp(name,"Matice")==0) return MaticeEnum;
-	else if (strcmp(name,"Matpar")==0) return MatparEnum;
-	else if (strcmp(name,"Node")==0) return NodeEnum;
-	else if (strcmp(name,"Numericalflux")==0) return NumericalfluxEnum;
-	else if (strcmp(name,"Param")==0) return ParamEnum;
-	else if (strcmp(name,"PattynIceFront")==0) return PattynIceFrontEnum;
-	else if (strcmp(name,"Pengrid")==0) return PengridEnum;
-	else if (strcmp(name,"Penpair")==0) return PenpairEnum;
-	else if (strcmp(name,"Penta")==0) return PentaEnum;
-	else if (strcmp(name,"PentaVertexInput")==0) return PentaVertexInputEnum;
-	else if (strcmp(name,"PetscMatParam")==0) return PetscMatParamEnum;
-	else if (strcmp(name,"PetscVecParam")==0) return PetscVecParamEnum;
-	else if (strcmp(name,"Riftfront")==0) return RiftfrontEnum;
-	else if (strcmp(name,"Segment")==0) return SegmentEnum;
-	else if (strcmp(name,"SegmentRiftfront")==0) return SegmentRiftfrontEnum;
-	else if (strcmp(name,"SpcDynamic")==0) return SpcDynamicEnum;
-	else if (strcmp(name,"SpcStatic")==0) return SpcStaticEnum;
-	else if (strcmp(name,"SpcTransient")==0) return SpcTransientEnum;
-	else if (strcmp(name,"StokesIceFront")==0) return StokesIceFrontEnum;
-	else if (strcmp(name,"StringArrayParam")==0) return StringArrayParamEnum;
-	else if (strcmp(name,"StringParam")==0) return StringParamEnum;
-	else if (strcmp(name,"Tria")==0) return TriaEnum;
-	else if (strcmp(name,"TriaVertexInput")==0) return TriaVertexInputEnum;
-	else if (strcmp(name,"Vertex")==0) return VertexEnum;
-	else if (strcmp(name,"Air")==0) return AirEnum;
-	else if (strcmp(name,"Ice")==0) return IceEnum;
-	else if (strcmp(name,"Melange")==0) return MelangeEnum;
-	else if (strcmp(name,"Water")==0) return WaterEnum;
-	else if (strcmp(name,"Closed")==0) return ClosedEnum;
-	else if (strcmp(name,"Free")==0) return FreeEnum;
-	else if (strcmp(name,"Open")==0) return OpenEnum;
-	else if (strcmp(name,"Adjointp")==0) return AdjointpEnum;
-	else if (strcmp(name,"Adjointx")==0) return AdjointxEnum;
-	else if (strcmp(name,"Adjointy")==0) return AdjointyEnum;
-	else if (strcmp(name,"Adjointz")==0) return AdjointzEnum;
-	else if (strcmp(name,"BedSlopeX")==0) return BedSlopeXEnum;
-	else if (strcmp(name,"BedSlopeY")==0) return BedSlopeYEnum;
-	else if (strcmp(name,"Boundary")==0) return BoundaryEnum;
-	else if (strcmp(name,"Constant")==0) return ConstantEnum;
-	else if (strcmp(name,"Converged")==0) return ConvergedEnum;
-	else if (strcmp(name,"ExtToIu")==0) return ExtToIuEnum;
-	else if (strcmp(name,"Fill")==0) return FillEnum;
-	else if (strcmp(name,"FractionIncrement")==0) return FractionIncrementEnum;
-	else if (strcmp(name,"Friction")==0) return FrictionEnum;
-	else if (strcmp(name,"GroundinglineMeltingRate")==0) return GroundinglineMeltingRateEnum;
-	else if (strcmp(name,"Internal")==0) return InternalEnum;
-	else if (strcmp(name,"IuToExt")==0) return IuToExtEnum;
-	else if (strcmp(name,"MassFlux")==0) return MassFluxEnum;
-	else if (strcmp(name,"MaxPenetration")==0) return MaxPenetrationEnum;
-	else if (strcmp(name,"MeltingOffset")==0) return MeltingOffsetEnum;
-	else if (strcmp(name,"Misfit")==0) return MisfitEnum;
-	else if (strcmp(name,"NumberNodeToElementConnectivity")==0) return NumberNodeToElementConnectivityEnum;
-	else if (strcmp(name,"Pressure")==0) return PressureEnum;
-	else if (strcmp(name,"PressurePicard")==0) return PressurePicardEnum;
-	else if (strcmp(name,"QmuPressure")==0) return QmuPressureEnum;
-	else if (strcmp(name,"QmuVx")==0) return QmuVxEnum;
-	else if (strcmp(name,"QmuVy")==0) return QmuVyEnum;
-	else if (strcmp(name,"QmuVz")==0) return QmuVzEnum;
-	else if (strcmp(name,"QmuThickness")==0) return QmuThicknessEnum;
-	else if (strcmp(name,"QmuBed")==0) return QmuBedEnum;
-	else if (strcmp(name,"QmuSurface")==0) return QmuSurfaceEnum;
-	else if (strcmp(name,"QmuMelting")==0) return QmuMeltingEnum;
-	else if (strcmp(name,"ResetPenalties")==0) return ResetPenaltiesEnum;
-	else if (strcmp(name,"SegmentOnIceShelf")==0) return SegmentOnIceShelfEnum;
-	else if (strcmp(name,"SurfaceAbsVelMisfit")==0) return SurfaceAbsVelMisfitEnum;
-	else if (strcmp(name,"SurfaceArea")==0) return SurfaceAreaEnum;
-	else if (strcmp(name,"SurfaceAverageVelMisfit")==0) return SurfaceAverageVelMisfitEnum;
-	else if (strcmp(name,"SurfaceLogVelMisfit")==0) return SurfaceLogVelMisfitEnum;
-	else if (strcmp(name,"SurfaceLogVxVyMisfit")==0) return SurfaceLogVxVyMisfitEnum;
-	else if (strcmp(name,"SurfaceRelVelMisfit")==0) return SurfaceRelVelMisfitEnum;
-	else if (strcmp(name,"SurfaceSlopeX")==0) return SurfaceSlopeXEnum;
-	else if (strcmp(name,"SurfaceSlopeY")==0) return SurfaceSlopeYEnum;
-	else if (strcmp(name,"Temperature")==0) return TemperatureEnum;
-	else if (strcmp(name,"TemperatureOld")==0) return TemperatureOldEnum;
-	else if (strcmp(name,"TemperaturePicard")==0) return TemperaturePicardEnum;
-	else if (strcmp(name,"ThicknessAbsMisfit")==0) return ThicknessAbsMisfitEnum;
-	else if (strcmp(name,"Type")==0) return TypeEnum;
-	else if (strcmp(name,"Vel")==0) return VelEnum;
-	else if (strcmp(name,"Velocity")==0) return VelocityEnum;
-	else if (strcmp(name,"VxAverage")==0) return VxAverageEnum;
-	else if (strcmp(name,"Vx")==0) return VxEnum;
-	else if (strcmp(name,"VxPicard")==0) return VxPicardEnum;
-	else if (strcmp(name,"VyAverage")==0) return VyAverageEnum;
-	else if (strcmp(name,"Vy")==0) return VyEnum;
-	else if (strcmp(name,"VyPicard")==0) return VyPicardEnum;
-	else if (strcmp(name,"Vz")==0) return VzEnum;
-	else if (strcmp(name,"VzMacAyeal")==0) return VzMacAyealEnum;
-	else if (strcmp(name,"VzPattyn")==0) return VzPattynEnum;
-	else if (strcmp(name,"VzPicard")==0) return VzPicardEnum;
-	else if (strcmp(name,"VzStokes")==0) return VzStokesEnum;
-	else if (strcmp(name,"VxMesh")==0) return VxMeshEnum;
-	else if (strcmp(name,"VyMesh")==0) return VyMeshEnum;
-	else if (strcmp(name,"VzMesh")==0) return VzMeshEnum;
-	else if (strcmp(name,"Enthalpy")==0) return EnthalpyEnum;
-	else if (strcmp(name,"EnthalpyPicard")==0) return EnthalpyPicardEnum;
-	else if (strcmp(name,"ThicknessAbsGradient")==0) return ThicknessAbsGradientEnum;
-	else if (strcmp(name,"StepResponses")==0) return StepResponsesEnum;
-	else if (strcmp(name,"IntMatParam")==0) return IntMatParamEnum;
-	else if (strcmp(name,"RheologyBbarAbsGradient")==0) return RheologyBbarAbsGradientEnum;
-	else if (strcmp(name,"DragCoefficientAbsGradient")==0) return DragCoefficientAbsGradientEnum;
-	else if (strcmp(name,"TransientInput")==0) return TransientInputEnum;
-	else if (strcmp(name,"Outputfilename")==0) return OutputfilenameEnum;
-	else if (strcmp(name,"Waterfraction")==0) return WaterfractionEnum;
-	else if (strcmp(name,"Watercolumn")==0) return WatercolumnEnum;
-	else if (strcmp(name,"BasalFriction")==0) return BasalFrictionEnum;
-	else if (strcmp(name,"ViscousHeating")==0) return ViscousHeatingEnum;
-	else if (strcmp(name,"QmuTemperature")==0) return QmuTemperatureEnum;
-	else if (strcmp(name,"HydrologyWaterVx")==0) return HydrologyWaterVxEnum;
-	else if (strcmp(name,"HydrologyWaterVy")==0) return HydrologyWaterVyEnum;
-	else if (strcmp(name,"StressTensor")==0) return StressTensorEnum;
-	else if (strcmp(name,"StressTensorxx")==0) return StressTensorxxEnum;
-	else if (strcmp(name,"StressTensorxy")==0) return StressTensorxyEnum;
-	else if (strcmp(name,"StressTensorxz")==0) return StressTensorxzEnum;
-	else if (strcmp(name,"StressTensoryy")==0) return StressTensoryyEnum;
-	else if (strcmp(name,"StressTensoryz")==0) return StressTensoryzEnum;
-	else if (strcmp(name,"StressTensorzz")==0) return StressTensorzzEnum;
-	else if (strcmp(name,"IceVolume")==0) return IceVolumeEnum;
-	else if (strcmp(name,"P0")==0) return P0Enum;
-	else if (strcmp(name,"P1")==0) return P1Enum;
-	else if (strcmp(name,"P1DG")==0) return P1DGEnum;
-	else if (strcmp(name,"BoolElementResult")==0) return BoolElementResultEnum;
-	else if (strcmp(name,"BoolExternalResult")==0) return BoolExternalResultEnum;
-	else if (strcmp(name,"DoubleElementResult")==0) return DoubleElementResultEnum;
-	else if (strcmp(name,"DoubleExternalResult")==0) return DoubleExternalResultEnum;
-	else if (strcmp(name,"DoubleMatExternalResult")==0) return DoubleMatExternalResultEnum;
-	else if (strcmp(name,"DoubleVecExternalResult")==0) return DoubleVecExternalResultEnum;
-	else if (strcmp(name,"IntExternalResult")==0) return IntExternalResultEnum;
-	else if (strcmp(name,"J")==0) return JEnum;
-	else if (strcmp(name,"Patch")==0) return PatchEnum;
-	else if (strcmp(name,"PatchNodes")==0) return PatchNodesEnum;
-	else if (strcmp(name,"PatchVertices")==0) return PatchVerticesEnum;
-	else if (strcmp(name,"PentaVertexElementResult")==0) return PentaVertexElementResultEnum;
-	else if (strcmp(name,"PetscVecExternalResult")==0) return PetscVecExternalResultEnum;
-	else if (strcmp(name,"StringExternalResult")==0) return StringExternalResultEnum;
-	else if (strcmp(name,"Time")==0) return TimeEnum;
-	else if (strcmp(name,"TriaVertexElementResult")==0) return TriaVertexElementResultEnum;
-	else if (strcmp(name,"WaterColumnOld")==0) return WaterColumnOldEnum;
-	else if (strcmp(name,"MinVel")==0) return MinVelEnum;
-	else if (strcmp(name,"MaxVel")==0) return MaxVelEnum;
-	else if (strcmp(name,"MinVx")==0) return MinVxEnum;
-	else if (strcmp(name,"MaxVx")==0) return MaxVxEnum;
-	else if (strcmp(name,"MaxAbsVx")==0) return MaxAbsVxEnum;
-	else if (strcmp(name,"MinVy")==0) return MinVyEnum;
-	else if (strcmp(name,"MaxVy")==0) return MaxVyEnum;
-	else if (strcmp(name,"MaxAbsVy")==0) return MaxAbsVyEnum;
-	else if (strcmp(name,"MinVz")==0) return MinVzEnum;
-	else if (strcmp(name,"MaxVz")==0) return MaxVzEnum;
-	else if (strcmp(name,"MaxAbsVz")==0) return MaxAbsVzEnum;
-	else if (strcmp(name,"Relative")==0) return RelativeEnum;
-	else if (strcmp(name,"Absolute")==0) return AbsoluteEnum;
-	else if (strcmp(name,"Incremental")==0) return IncrementalEnum;
-	else if (strcmp(name,"AgressiveMigration")==0) return AgressiveMigrationEnum;
-	else if (strcmp(name,"None")==0) return NoneEnum;
-	else if (strcmp(name,"SoftMigration")==0) return SoftMigrationEnum;
-	else if (strcmp(name,"StokesSolver")==0) return StokesSolverEnum;
-	else if (strcmp(name,"Adjoint")==0) return AdjointEnum;
-	else if (strcmp(name,"Colinear")==0) return ColinearEnum;
-	else if (strcmp(name,"ControlSteady")==0) return ControlSteadyEnum;
-	else if (strcmp(name,"Fset")==0) return FsetEnum;
-	else if (strcmp(name,"Gradient1")==0) return Gradient1Enum;
-	else if (strcmp(name,"Gradient2")==0) return Gradient2Enum;
-	else if (strcmp(name,"Gradient3")==0) return Gradient3Enum;
-	else if (strcmp(name,"Gradient")==0) return GradientEnum;
-	else if (strcmp(name,"GroundinglineMigration")==0) return GroundinglineMigrationEnum;
-	else if (strcmp(name,"Gset")==0) return GsetEnum;
-	else if (strcmp(name,"Index")==0) return IndexEnum;
-	else if (strcmp(name,"Indexed")==0) return IndexedEnum;
-	else if (strcmp(name,"Intersect")==0) return IntersectEnum;
-	else if (strcmp(name,"Nodal")==0) return NodalEnum;
-	else if (strcmp(name,"OldGradient")==0) return OldGradientEnum;
-	else if (strcmp(name,"OutputFilePointer")==0) return OutputFilePointerEnum;
-	else if (strcmp(name,"PetscOptionsAnalyses")==0) return PetscOptionsAnalysesEnum;
-	else if (strcmp(name,"PetscOptionsStrings")==0) return PetscOptionsStringsEnum;
-	else if (strcmp(name,"QmuErrName")==0) return QmuErrNameEnum;
-	else if (strcmp(name,"QmuInName")==0) return QmuInNameEnum;
-	else if (strcmp(name,"QmuOutName")==0) return QmuOutNameEnum;
-	else if (strcmp(name,"Regular")==0) return RegularEnum;
-	else if (strcmp(name,"Scaled")==0) return ScaledEnum;
-	else if (strcmp(name,"Separate")==0) return SeparateEnum;
-	else if (strcmp(name,"Sset")==0) return SsetEnum;
-	else if (strcmp(name,"Verbose")==0) return VerboseEnum;
-	else if (strcmp(name,"TriangleInterp")==0) return TriangleInterpEnum;
-	else if (strcmp(name,"BilinearInterp")==0) return BilinearInterpEnum;
-	else if (strcmp(name,"NearestInterp")==0) return NearestInterpEnum;
-	else if (strcmp(name,"XY")==0) return XYEnum;
-	else if (strcmp(name,"XYZP")==0) return XYZPEnum;
-	else if (strcmp(name,"Option")==0) return OptionEnum;
-	else if (strcmp(name,"OptionCell")==0) return OptionCellEnum;
-	else if (strcmp(name,"OptionChar")==0) return OptionCharEnum;
-	else if (strcmp(name,"OptionStruct")==0) return OptionStructEnum;
-	else if (strcmp(name,"OptionDouble")==0) return OptionDoubleEnum;
-	else if (strcmp(name,"OptionLogical")==0) return OptionLogicalEnum;
-	else if (strcmp(name,"Paterson")==0) return PatersonEnum;
-	else if (strcmp(name,"Arrhenius")==0) return ArrheniusEnum;
-	else _error_("Enum %s not found",name);
+   int  stage=1;
 
+   if(stage==1){
+	      if (strcmp(name,"AutodiffForward")==0) return AutodiffForwardEnum;
+	      else if (strcmp(name,"AutodiffIsautodiff")==0) return AutodiffIsautodiffEnum;
+	      else if (strcmp(name,"AutodiffReverse")==0) return AutodiffReverseEnum;
+	      else if (strcmp(name,"BalancethicknessSpcthickness")==0) return BalancethicknessSpcthicknessEnum;
+	      else if (strcmp(name,"BalancethicknessStabilization")==0) return BalancethicknessStabilizationEnum;
+	      else if (strcmp(name,"BalancethicknessThickeningRate")==0) return BalancethicknessThickeningRateEnum;
+	      else if (strcmp(name,"BasalforcingsGeothermalflux")==0) return BasalforcingsGeothermalfluxEnum;
+	      else if (strcmp(name,"BasalforcingsMeltingRateCorrection")==0) return BasalforcingsMeltingRateCorrectionEnum;
+	      else if (strcmp(name,"BasalforcingsMeltingRate")==0) return BasalforcingsMeltingRateEnum;
+	      else if (strcmp(name,"Bathymetry")==0) return BathymetryEnum;
+	      else if (strcmp(name,"Bed")==0) return BedEnum;
+	      else if (strcmp(name,"ConstantsG")==0) return ConstantsGEnum;
+	      else if (strcmp(name,"ConstantsReferencetemperature")==0) return ConstantsReferencetemperatureEnum;
+	      else if (strcmp(name,"ConstantsYts")==0) return ConstantsYtsEnum;
+	      else if (strcmp(name,"DiagnosticAbstol")==0) return DiagnosticAbstolEnum;
+	      else if (strcmp(name,"DiagnosticIcefront")==0) return DiagnosticIcefrontEnum;
+	      else if (strcmp(name,"DiagnosticIsnewton")==0) return DiagnosticIsnewtonEnum;
+	      else if (strcmp(name,"DiagnosticMaxiter")==0) return DiagnosticMaxiterEnum;
+	      else if (strcmp(name,"DiagnosticNumRequestedOutputs")==0) return DiagnosticNumRequestedOutputsEnum;
+	      else if (strcmp(name,"DiagnosticPenaltyFactor")==0) return DiagnosticPenaltyFactorEnum;
+	      else if (strcmp(name,"DiagnosticReferential")==0) return DiagnosticReferentialEnum;
+	      else if (strcmp(name,"DiagnosticReltol")==0) return DiagnosticReltolEnum;
+	      else if (strcmp(name,"DiagnosticRequestedOutputs")==0) return DiagnosticRequestedOutputsEnum;
+	      else if (strcmp(name,"DiagnosticRestol")==0) return DiagnosticRestolEnum;
+	      else if (strcmp(name,"DiagnosticRiftPenaltyLock")==0) return DiagnosticRiftPenaltyLockEnum;
+	      else if (strcmp(name,"DiagnosticRiftPenaltyThreshold")==0) return DiagnosticRiftPenaltyThresholdEnum;
+	      else if (strcmp(name,"DiagnosticShelfDampening")==0) return DiagnosticShelfDampeningEnum;
+	      else if (strcmp(name,"DiagnosticSpcvx")==0) return DiagnosticSpcvxEnum;
+	      else if (strcmp(name,"DiagnosticSpcvy")==0) return DiagnosticSpcvyEnum;
+	      else if (strcmp(name,"DiagnosticSpcvz")==0) return DiagnosticSpcvzEnum;
+	      else if (strcmp(name,"DiagnosticStokesreconditioning")==0) return DiagnosticStokesreconditioningEnum;
+	      else if (strcmp(name,"DiagnosticVertexPairing")==0) return DiagnosticVertexPairingEnum;
+	      else if (strcmp(name,"DiagnosticViscosityOvershoot")==0) return DiagnosticViscosityOvershootEnum;
+	      else if (strcmp(name,"FlowequationBordermacayeal")==0) return FlowequationBordermacayealEnum;
+	      else if (strcmp(name,"FlowequationBorderpattyn")==0) return FlowequationBorderpattynEnum;
+	      else if (strcmp(name,"FlowequationBorderstokes")==0) return FlowequationBorderstokesEnum;
+	      else if (strcmp(name,"FlowequationElementEquation")==0) return FlowequationElementEquationEnum;
+	      else if (strcmp(name,"FlowequationIshutter")==0) return FlowequationIshutterEnum;
+	      else if (strcmp(name,"FlowequationIsmacayealpattyn")==0) return FlowequationIsmacayealpattynEnum;
+	      else if (strcmp(name,"FlowequationIsstokes")==0) return FlowequationIsstokesEnum;
+	      else if (strcmp(name,"FlowequationVertexEquation")==0) return FlowequationVertexEquationEnum;
+	      else if (strcmp(name,"FrictionCoefficient")==0) return FrictionCoefficientEnum;
+	      else if (strcmp(name,"FrictionP")==0) return FrictionPEnum;
+	      else if (strcmp(name,"FrictionQ")==0) return FrictionQEnum;
+	      else if (strcmp(name,"GeometryHydrostaticRatio")==0) return GeometryHydrostaticRatioEnum;
+	      else if (strcmp(name,"HydrologyCR")==0) return HydrologyCREnum;
+	      else if (strcmp(name,"HydrologyKn")==0) return HydrologyKnEnum;
+	      else if (strcmp(name,"HydrologyN")==0) return HydrologyNEnum;
+	      else if (strcmp(name,"HydrologyP")==0) return HydrologyPEnum;
+	      else if (strcmp(name,"HydrologyQ")==0) return HydrologyQEnum;
+	      else if (strcmp(name,"HydrologySpcwatercolumn")==0) return HydrologySpcwatercolumnEnum;
+	      else if (strcmp(name,"HydrologyStabilization")==0) return HydrologyStabilizationEnum;
+	      else if (strcmp(name,"InversionControlParameters")==0) return InversionControlParametersEnum;
+	      else if (strcmp(name,"InversionCostFunction")==0) return InversionCostFunctionEnum;
+	      else if (strcmp(name,"InversionCostFunctionThreshold")==0) return InversionCostFunctionThresholdEnum;
+	      else if (strcmp(name,"InversionCostFunctionsCoefficients")==0) return InversionCostFunctionsCoefficientsEnum;
+	      else if (strcmp(name,"InversionCostFunctions")==0) return InversionCostFunctionsEnum;
+	      else if (strcmp(name,"InversionGradientOnly")==0) return InversionGradientOnlyEnum;
+	      else if (strcmp(name,"InversionGradientScaling")==0) return InversionGradientScalingEnum;
+	      else if (strcmp(name,"InversionIscontrol")==0) return InversionIscontrolEnum;
+	      else if (strcmp(name,"InversionTao")==0) return InversionTaoEnum;
+	      else if (strcmp(name,"InversionIncompleteAdjoint")==0) return InversionIncompleteAdjointEnum;
+	      else if (strcmp(name,"InversionMaxParameters")==0) return InversionMaxParametersEnum;
+	      else if (strcmp(name,"InversionMaxiterPerStep")==0) return InversionMaxiterPerStepEnum;
+	      else if (strcmp(name,"InversionMinParameters")==0) return InversionMinParametersEnum;
+	      else if (strcmp(name,"InversionNsteps")==0) return InversionNstepsEnum;
+	      else if (strcmp(name,"InversionNumControlParameters")==0) return InversionNumControlParametersEnum;
+	      else if (strcmp(name,"InversionNumCostFunctions")==0) return InversionNumCostFunctionsEnum;
+	      else if (strcmp(name,"InversionStepThreshold")==0) return InversionStepThresholdEnum;
+	      else if (strcmp(name,"InversionThicknessObs")==0) return InversionThicknessObsEnum;
+	      else if (strcmp(name,"InversionVelObs")==0) return InversionVelObsEnum;
+	      else if (strcmp(name,"InversionVxObs")==0) return InversionVxObsEnum;
+	      else if (strcmp(name,"InversionVyObs")==0) return InversionVyObsEnum;
+	      else if (strcmp(name,"InversionVzObs")==0) return InversionVzObsEnum;
+	      else if (strcmp(name,"MaskElementonfloatingice")==0) return MaskElementonfloatingiceEnum;
+	      else if (strcmp(name,"MaskElementongroundedice")==0) return MaskElementongroundediceEnum;
+	      else if (strcmp(name,"MaskElementonwater")==0) return MaskElementonwaterEnum;
+	      else if (strcmp(name,"MaskVertexonfloatingice")==0) return MaskVertexonfloatingiceEnum;
+	      else if (strcmp(name,"MaskVertexongroundedice")==0) return MaskVertexongroundediceEnum;
+	      else if (strcmp(name,"MaskVertexonwater")==0) return MaskVertexonwaterEnum;
+	      else if (strcmp(name,"MaterialsBeta")==0) return MaterialsBetaEnum;
+	      else if (strcmp(name,"MaterialsHeatcapacity")==0) return MaterialsHeatcapacityEnum;
+	      else if (strcmp(name,"MaterialsLatentheat")==0) return MaterialsLatentheatEnum;
+	      else if (strcmp(name,"MaterialsMeltingpoint")==0) return MaterialsMeltingpointEnum;
+	      else if (strcmp(name,"MaterialsMixedLayerCapacity")==0) return MaterialsMixedLayerCapacityEnum;
+	      else if (strcmp(name,"MaterialsRheologyB")==0) return MaterialsRheologyBEnum;
+	      else if (strcmp(name,"MaterialsRheologyBbar")==0) return MaterialsRheologyBbarEnum;
+	      else if (strcmp(name,"MaterialsRheologyLaw")==0) return MaterialsRheologyLawEnum;
+	      else if (strcmp(name,"MaterialsRheologyN")==0) return MaterialsRheologyNEnum;
+	      else if (strcmp(name,"MaterialsRhoIce")==0) return MaterialsRhoIceEnum;
+	      else if (strcmp(name,"MaterialsRhoWater")==0) return MaterialsRhoWaterEnum;
+	      else if (strcmp(name,"MaterialsMuWater")==0) return MaterialsMuWaterEnum;
+	      else if (strcmp(name,"MaterialsThermalExchangeVelocity")==0) return MaterialsThermalExchangeVelocityEnum;
+	      else if (strcmp(name,"MaterialsThermalconductivity")==0) return MaterialsThermalconductivityEnum;
+	      else if (strcmp(name,"MeshAverageVertexConnectivity")==0) return MeshAverageVertexConnectivityEnum;
+	      else if (strcmp(name,"MeshDimension")==0) return MeshDimensionEnum;
+	      else if (strcmp(name,"MeshEdges")==0) return MeshEdgesEnum;
+	      else if (strcmp(name,"MeshElementconnectivity")==0) return MeshElementconnectivityEnum;
+	      else if (strcmp(name,"MeshElementonbed")==0) return MeshElementonbedEnum;
+	      else if (strcmp(name,"MeshElementonsurface")==0) return MeshElementonsurfaceEnum;
+	      else if (strcmp(name,"MeshElements2d")==0) return MeshElements2dEnum;
+	      else if (strcmp(name,"MeshElements")==0) return MeshElementsEnum;
+	      else if (strcmp(name,"MeshLowerelements")==0) return MeshLowerelementsEnum;
+	      else if (strcmp(name,"MeshNumberofedges")==0) return MeshNumberofedgesEnum;
+	      else if (strcmp(name,"MeshNumberofelements2d")==0) return MeshNumberofelements2dEnum;
+	      else if (strcmp(name,"MeshNumberofelements")==0) return MeshNumberofelementsEnum;
+	      else if (strcmp(name,"MeshNumberoflayers")==0) return MeshNumberoflayersEnum;
+	      else if (strcmp(name,"MeshNumberofvertices2d")==0) return MeshNumberofvertices2dEnum;
+	      else if (strcmp(name,"MeshNumberofvertices")==0) return MeshNumberofverticesEnum;
+	      else if (strcmp(name,"MeshUpperelements")==0) return MeshUpperelementsEnum;
+	      else if (strcmp(name,"MeshVertexonbed")==0) return MeshVertexonbedEnum;
+	      else if (strcmp(name,"MeshVertexonsurface")==0) return MeshVertexonsurfaceEnum;
+	      else if (strcmp(name,"MeshX")==0) return MeshXEnum;
+	      else if (strcmp(name,"MeshY")==0) return MeshYEnum;
+	      else if (strcmp(name,"MeshZ")==0) return MeshZEnum;
+	      else if (strcmp(name,"MiscellaneousName")==0) return MiscellaneousNameEnum;
+	      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,"PrognosticStabilization")==0) return PrognosticStabilizationEnum;
+	      else if (strcmp(name,"PrognosticVertexPairing")==0) return PrognosticVertexPairingEnum;
+	      else if (strcmp(name,"QmuIsdakota")==0) return QmuIsdakotaEnum;
+	      else if (strcmp(name,"QmuMassFluxSegments")==0) return QmuMassFluxSegmentsEnum;
+	      else if (strcmp(name,"QmuNumberofpartitions")==0) return QmuNumberofpartitionsEnum;
+	      else if (strcmp(name,"QmuNumberofresponses")==0) return QmuNumberofresponsesEnum;
+	      else if (strcmp(name,"QmuPartition")==0) return QmuPartitionEnum;
+	      else if (strcmp(name,"QmuResponsedescriptors")==0) return QmuResponsedescriptorsEnum;
+	      else if (strcmp(name,"QmuVariabledescriptors")==0) return QmuVariabledescriptorsEnum;
+	      else if (strcmp(name,"RiftsNumrifts")==0) return RiftsNumriftsEnum;
+	      else if (strcmp(name,"RiftsRiftstruct")==0) return RiftsRiftstructEnum;
+	      else if (strcmp(name,"SettingsIoGather")==0) return SettingsIoGatherEnum;
+	      else if (strcmp(name,"SettingsLowmem")==0) return SettingsLowmemEnum;
+	      else if (strcmp(name,"SettingsOutputFrequency")==0) return SettingsOutputFrequencyEnum;
+	      else if (strcmp(name,"SettingsResultsAsPatches")==0) return SettingsResultsAsPatchesEnum;
+	      else if (strcmp(name,"SettingsWaitonlock")==0) return SettingsWaitonlockEnum;
+	      else if (strcmp(name,"SteadystateMaxiter")==0) return SteadystateMaxiterEnum;
+	      else if (strcmp(name,"SteadystateNumRequestedOutputs")==0) return SteadystateNumRequestedOutputsEnum;
+	      else if (strcmp(name,"SteadystateReltol")==0) return SteadystateReltolEnum;
+	      else if (strcmp(name,"SteadystateRequestedOutputs")==0) return SteadystateRequestedOutputsEnum;
+	      else if (strcmp(name,"Surface")==0) return SurfaceEnum;
+	      else if (strcmp(name,"SurfaceforcingsPrecipitation")==0) return SurfaceforcingsPrecipitationEnum;
+	      else if (strcmp(name,"SurfaceforcingsMassBalance")==0) return SurfaceforcingsMassBalanceEnum;
+	      else if (strcmp(name,"ThermalMaxiter")==0) return ThermalMaxiterEnum;
+	      else if (strcmp(name,"ThermalPenaltyFactor")==0) return ThermalPenaltyFactorEnum;
+	      else if (strcmp(name,"ThermalPenaltyLock")==0) return ThermalPenaltyLockEnum;
+	      else if (strcmp(name,"ThermalPenaltyThreshold")==0) return ThermalPenaltyThresholdEnum;
+	      else if (strcmp(name,"ThermalSpctemperature")==0) return ThermalSpctemperatureEnum;
+	      else if (strcmp(name,"ThermalStabilization")==0) return ThermalStabilizationEnum;
+	      else if (strcmp(name,"ThermalIsenthalpy")==0) return ThermalIsenthalpyEnum;
+	      else if (strcmp(name,"Thickness")==0) return ThicknessEnum;
+	      else if (strcmp(name,"TimesteppingCflCoefficient")==0) return TimesteppingCflCoefficientEnum;
+	      else if (strcmp(name,"TimesteppingFinalTime")==0) return TimesteppingFinalTimeEnum;
+	      else if (strcmp(name,"TimesteppingTimeAdapt")==0) return TimesteppingTimeAdaptEnum;
+	      else if (strcmp(name,"TimesteppingTimeStep")==0) return TimesteppingTimeStepEnum;
+	      else if (strcmp(name,"TransientIsdiagnostic")==0) return TransientIsdiagnosticEnum;
+	      else if (strcmp(name,"TransientIsgroundingline")==0) return TransientIsgroundinglineEnum;
+	      else if (strcmp(name,"TransientIsprognostic")==0) return TransientIsprognosticEnum;
+	      else if (strcmp(name,"TransientIsthermal")==0) return TransientIsthermalEnum;
+	      else if (strcmp(name,"TransientNumRequestedOutputs")==0) return TransientNumRequestedOutputsEnum;
+	      else if (strcmp(name,"TransientRequestedOutputs")==0) return TransientRequestedOutputsEnum;
+	      else if (strcmp(name,"SolutionType")==0) return SolutionTypeEnum;
+	      else if (strcmp(name,"AnalysisType")==0) return AnalysisTypeEnum;
+	      else if (strcmp(name,"ConfigurationType")==0) return ConfigurationTypeEnum;
+	      else if (strcmp(name,"AdjointBalancethicknessAnalysis")==0) return AdjointBalancethicknessAnalysisEnum;
+	      else if (strcmp(name,"AdjointHorizAnalysis")==0) return AdjointHorizAnalysisEnum;
+	      else if (strcmp(name,"AdjointSolution")==0) return AdjointSolutionEnum;
+	      else if (strcmp(name,"AnalysisCounter")==0) return AnalysisCounterEnum;
+	      else if (strcmp(name,"BalancethicknessAnalysis")==0) return BalancethicknessAnalysisEnum;
+	      else if (strcmp(name,"BalancethicknessSolution")==0) return BalancethicknessSolutionEnum;
+	      else if (strcmp(name,"BedSlopeAnalysis")==0) return BedSlopeAnalysisEnum;
+	      else if (strcmp(name,"BedSlopeSolution")==0) return BedSlopeSolutionEnum;
+	      else if (strcmp(name,"BedSlopeXAnalysis")==0) return BedSlopeXAnalysisEnum;
+	      else if (strcmp(name,"BedSlopeYAnalysis")==0) return BedSlopeYAnalysisEnum;
+	      else if (strcmp(name,"DiagnosticHorizAnalysis")==0) return DiagnosticHorizAnalysisEnum;
+	      else if (strcmp(name,"DiagnosticHutterAnalysis")==0) return DiagnosticHutterAnalysisEnum;
+	      else if (strcmp(name,"DiagnosticSolution")==0) return DiagnosticSolutionEnum;
+	      else if (strcmp(name,"DiagnosticVertAnalysis")==0) return DiagnosticVertAnalysisEnum;
+	      else if (strcmp(name,"EnthalpyAnalysis")==0) return EnthalpyAnalysisEnum;
+	      else if (strcmp(name,"EnthalpySolution")==0) return EnthalpySolutionEnum;
+	      else if (strcmp(name,"FlaimAnalysis")==0) return FlaimAnalysisEnum;
+	      else if (strcmp(name,"FlaimSolution")==0) return FlaimSolutionEnum;
+	      else if (strcmp(name,"HydrologyAnalysis")==0) return HydrologyAnalysisEnum;
+	      else if (strcmp(name,"HydrologySolution")==0) return HydrologySolutionEnum;
+	      else if (strcmp(name,"MeltingAnalysis")==0) return MeltingAnalysisEnum;
+	      else if (strcmp(name,"NoneAnalysis")==0) return NoneAnalysisEnum;
+	      else if (strcmp(name,"PrognosticAnalysis")==0) return PrognosticAnalysisEnum;
+	      else if (strcmp(name,"PrognosticSolution")==0) return PrognosticSolutionEnum;
+	      else if (strcmp(name,"SteadystateSolution")==0) return SteadystateSolutionEnum;
+	      else if (strcmp(name,"SurfaceSlopeAnalysis")==0) return SurfaceSlopeAnalysisEnum;
+	      else if (strcmp(name,"SurfaceSlopeSolution")==0) return SurfaceSlopeSolutionEnum;
+	      else if (strcmp(name,"SurfaceSlopeXAnalysis")==0) return SurfaceSlopeXAnalysisEnum;
+	      else if (strcmp(name,"SurfaceSlopeYAnalysis")==0) return SurfaceSlopeYAnalysisEnum;
+	      else if (strcmp(name,"ThermalAnalysis")==0) return ThermalAnalysisEnum;
+	      else if (strcmp(name,"ThermalSolution")==0) return ThermalSolutionEnum;
+	      else if (strcmp(name,"TransientSolution")==0) return TransientSolutionEnum;
+	      else if (strcmp(name,"Approximation")==0) return ApproximationEnum;
+	      else if (strcmp(name,"HutterApproximation")==0) return HutterApproximationEnum;
+	      else if (strcmp(name,"MacAyealApproximation")==0) return MacAyealApproximationEnum;
+	      else if (strcmp(name,"MacAyealPattynApproximation")==0) return MacAyealPattynApproximationEnum;
+	      else if (strcmp(name,"MacAyealStokesApproximation")==0) return MacAyealStokesApproximationEnum;
+	      else if (strcmp(name,"NoneApproximation")==0) return NoneApproximationEnum;
+	      else if (strcmp(name,"PattynApproximation")==0) return PattynApproximationEnum;
+	      else if (strcmp(name,"PattynStokesApproximation")==0) return PattynStokesApproximationEnum;
+	      else if (strcmp(name,"StokesApproximation")==0) return StokesApproximationEnum;
+	      else if (strcmp(name,"Constraints")==0) return ConstraintsEnum;
+	      else if (strcmp(name,"Loads")==0) return LoadsEnum;
+	      else if (strcmp(name,"Materials")==0) return MaterialsEnum;
+	      else if (strcmp(name,"Nodes")==0) return NodesEnum;
+	      else if (strcmp(name,"Parameters")==0) return ParametersEnum;
+	      else if (strcmp(name,"Vertices")==0) return VerticesEnum;
+	      else if (strcmp(name,"Results")==0) return ResultsEnum;
+	      else if (strcmp(name,"BoolInput")==0) return BoolInputEnum;
+	      else if (strcmp(name,"BoolParam")==0) return BoolParamEnum;
+	      else if (strcmp(name,"ControlInput")==0) return ControlInputEnum;
+	      else if (strcmp(name,"DatasetInput")==0) return DatasetInputEnum;
+	      else if (strcmp(name,"DofIndexing")==0) return DofIndexingEnum;
+	      else if (strcmp(name,"DoubleInput")==0) return DoubleInputEnum;
+	      else if (strcmp(name,"DoubleMatArrayParam")==0) return DoubleMatArrayParamEnum;
+	      else if (strcmp(name,"DoubleMatParam")==0) return DoubleMatParamEnum;
+	      else if (strcmp(name,"DoubleParam")==0) return DoubleParamEnum;
+	      else if (strcmp(name,"DoubleVecParam")==0) return DoubleVecParamEnum;
+	      else if (strcmp(name,"Element")==0) return ElementEnum;
+	      else if (strcmp(name,"ElementResult")==0) return ElementResultEnum;
+	      else if (strcmp(name,"ExternalResult")==0) return ExternalResultEnum;
+	      else if (strcmp(name,"FileParam")==0) return FileParamEnum;
+	      else if (strcmp(name,"Hook")==0) return HookEnum;
+	      else if (strcmp(name,"Icefront")==0) return IcefrontEnum;
+	      else if (strcmp(name,"Input")==0) return InputEnum;
+	      else if (strcmp(name,"IntInput")==0) return IntInputEnum;
+	      else if (strcmp(name,"IntParam")==0) return IntParamEnum;
+	      else if (strcmp(name,"IntVecParam")==0) return IntVecParamEnum;
+	      else if (strcmp(name,"MacAyeal2dIceFront")==0) return MacAyeal2dIceFrontEnum;
+	      else if (strcmp(name,"MacAyeal3dIceFront")==0) return MacAyeal3dIceFrontEnum;
+	      else if (strcmp(name,"Matice")==0) return MaticeEnum;
+	      else if (strcmp(name,"Matpar")==0) return MatparEnum;
+	      else if (strcmp(name,"Node")==0) return NodeEnum;
+	      else if (strcmp(name,"Numericalflux")==0) return NumericalfluxEnum;
+	      else if (strcmp(name,"Param")==0) return ParamEnum;
+	      else if (strcmp(name,"PattynIceFront")==0) return PattynIceFrontEnum;
+         else stage=3;
+   }
+   if(stage==3){
+	      if (strcmp(name,"Pengrid")==0) return PengridEnum;
+	      else if (strcmp(name,"Penpair")==0) return PenpairEnum;
+	      else if (strcmp(name,"Penta")==0) return PentaEnum;
+	      else if (strcmp(name,"PentaP1Input")==0) return PentaP1InputEnum;
+	      else if (strcmp(name,"PetscMatParam")==0) return PetscMatParamEnum;
+	      else if (strcmp(name,"PetscVecParam")==0) return PetscVecParamEnum;
+	      else if (strcmp(name,"Riftfront")==0) return RiftfrontEnum;
+	      else if (strcmp(name,"Segment")==0) return SegmentEnum;
+	      else if (strcmp(name,"SegmentRiftfront")==0) return SegmentRiftfrontEnum;
+	      else if (strcmp(name,"SpcDynamic")==0) return SpcDynamicEnum;
+	      else if (strcmp(name,"SpcStatic")==0) return SpcStaticEnum;
+	      else if (strcmp(name,"SpcTransient")==0) return SpcTransientEnum;
+	      else if (strcmp(name,"StokesIceFront")==0) return StokesIceFrontEnum;
+	      else if (strcmp(name,"StringArrayParam")==0) return StringArrayParamEnum;
+	      else if (strcmp(name,"StringParam")==0) return StringParamEnum;
+	      else if (strcmp(name,"Tria")==0) return TriaEnum;
+	      else if (strcmp(name,"TriaP1Input")==0) return TriaP1InputEnum;
+	      else if (strcmp(name,"Vertex")==0) return VertexEnum;
+	      else if (strcmp(name,"Air")==0) return AirEnum;
+	      else if (strcmp(name,"Ice")==0) return IceEnum;
+	      else if (strcmp(name,"Melange")==0) return MelangeEnum;
+	      else if (strcmp(name,"Water")==0) return WaterEnum;
+	      else if (strcmp(name,"Closed")==0) return ClosedEnum;
+	      else if (strcmp(name,"Free")==0) return FreeEnum;
+	      else if (strcmp(name,"Open")==0) return OpenEnum;
+	      else if (strcmp(name,"Adjointp")==0) return AdjointpEnum;
+	      else if (strcmp(name,"Adjointx")==0) return AdjointxEnum;
+	      else if (strcmp(name,"Adjointy")==0) return AdjointyEnum;
+	      else if (strcmp(name,"Adjointz")==0) return AdjointzEnum;
+	      else if (strcmp(name,"BedSlopeX")==0) return BedSlopeXEnum;
+	      else if (strcmp(name,"BedSlopeY")==0) return BedSlopeYEnum;
+	      else if (strcmp(name,"Boundary")==0) return BoundaryEnum;
+	      else if (strcmp(name,"Constant")==0) return ConstantEnum;
+	      else if (strcmp(name,"Converged")==0) return ConvergedEnum;
+	      else if (strcmp(name,"ExtToIu")==0) return ExtToIuEnum;
+	      else if (strcmp(name,"Fill")==0) return FillEnum;
+	      else if (strcmp(name,"FractionIncrement")==0) return FractionIncrementEnum;
+	      else if (strcmp(name,"Friction")==0) return FrictionEnum;
+	      else if (strcmp(name,"GroundinglineMeltingRate")==0) return GroundinglineMeltingRateEnum;
+	      else if (strcmp(name,"Internal")==0) return InternalEnum;
+	      else if (strcmp(name,"IuToExt")==0) return IuToExtEnum;
+	      else if (strcmp(name,"MassFlux")==0) return MassFluxEnum;
+	      else if (strcmp(name,"MaxPenetration")==0) return MaxPenetrationEnum;
+	      else if (strcmp(name,"MeltingOffset")==0) return MeltingOffsetEnum;
+	      else if (strcmp(name,"Misfit")==0) return MisfitEnum;
+	      else if (strcmp(name,"NumberNodeToElementConnectivity")==0) return NumberNodeToElementConnectivityEnum;
+	      else if (strcmp(name,"Pressure")==0) return PressureEnum;
+	      else if (strcmp(name,"PressurePicard")==0) return PressurePicardEnum;
+	      else if (strcmp(name,"QmuPressure")==0) return QmuPressureEnum;
+	      else if (strcmp(name,"QmuVx")==0) return QmuVxEnum;
+	      else if (strcmp(name,"QmuVy")==0) return QmuVyEnum;
+	      else if (strcmp(name,"QmuVz")==0) return QmuVzEnum;
+	      else if (strcmp(name,"QmuThickness")==0) return QmuThicknessEnum;
+	      else if (strcmp(name,"QmuBed")==0) return QmuBedEnum;
+	      else if (strcmp(name,"QmuSurface")==0) return QmuSurfaceEnum;
+	      else if (strcmp(name,"QmuMelting")==0) return QmuMeltingEnum;
+	      else if (strcmp(name,"ResetPenalties")==0) return ResetPenaltiesEnum;
+	      else if (strcmp(name,"SegmentOnIceShelf")==0) return SegmentOnIceShelfEnum;
+	      else if (strcmp(name,"SurfaceAbsVelMisfit")==0) return SurfaceAbsVelMisfitEnum;
+	      else if (strcmp(name,"SurfaceArea")==0) return SurfaceAreaEnum;
+	      else if (strcmp(name,"SurfaceAverageVelMisfit")==0) return SurfaceAverageVelMisfitEnum;
+	      else if (strcmp(name,"SurfaceLogVelMisfit")==0) return SurfaceLogVelMisfitEnum;
+	      else if (strcmp(name,"SurfaceLogVxVyMisfit")==0) return SurfaceLogVxVyMisfitEnum;
+	      else if (strcmp(name,"SurfaceRelVelMisfit")==0) return SurfaceRelVelMisfitEnum;
+	      else if (strcmp(name,"SurfaceSlopeX")==0) return SurfaceSlopeXEnum;
+	      else if (strcmp(name,"SurfaceSlopeY")==0) return SurfaceSlopeYEnum;
+	      else if (strcmp(name,"Temperature")==0) return TemperatureEnum;
+	      else if (strcmp(name,"TemperatureOld")==0) return TemperatureOldEnum;
+	      else if (strcmp(name,"TemperaturePicard")==0) return TemperaturePicardEnum;
+	      else if (strcmp(name,"ThicknessAbsMisfit")==0) return ThicknessAbsMisfitEnum;
+	      else if (strcmp(name,"Type")==0) return TypeEnum;
+	      else if (strcmp(name,"Vel")==0) return VelEnum;
+	      else if (strcmp(name,"Velocity")==0) return VelocityEnum;
+	      else if (strcmp(name,"VxAverage")==0) return VxAverageEnum;
+	      else if (strcmp(name,"Vx")==0) return VxEnum;
+	      else if (strcmp(name,"VxPicard")==0) return VxPicardEnum;
+	      else if (strcmp(name,"VyAverage")==0) return VyAverageEnum;
+	      else if (strcmp(name,"Vy")==0) return VyEnum;
+	      else if (strcmp(name,"VyPicard")==0) return VyPicardEnum;
+	      else if (strcmp(name,"Vz")==0) return VzEnum;
+	      else if (strcmp(name,"VzMacAyeal")==0) return VzMacAyealEnum;
+	      else if (strcmp(name,"VzPattyn")==0) return VzPattynEnum;
+	      else if (strcmp(name,"VzPicard")==0) return VzPicardEnum;
+	      else if (strcmp(name,"VzStokes")==0) return VzStokesEnum;
+	      else if (strcmp(name,"VxMesh")==0) return VxMeshEnum;
+	      else if (strcmp(name,"VyMesh")==0) return VyMeshEnum;
+	      else if (strcmp(name,"VzMesh")==0) return VzMeshEnum;
+	      else if (strcmp(name,"Enthalpy")==0) return EnthalpyEnum;
+	      else if (strcmp(name,"EnthalpyPicard")==0) return EnthalpyPicardEnum;
+	      else if (strcmp(name,"ThicknessAbsGradient")==0) return ThicknessAbsGradientEnum;
+	      else if (strcmp(name,"StepResponses")==0) return StepResponsesEnum;
+	      else if (strcmp(name,"IntMatParam")==0) return IntMatParamEnum;
+	      else if (strcmp(name,"RheologyBbarAbsGradient")==0) return RheologyBbarAbsGradientEnum;
+	      else if (strcmp(name,"DragCoefficientAbsGradient")==0) return DragCoefficientAbsGradientEnum;
+	      else if (strcmp(name,"TransientInput")==0) return TransientInputEnum;
+	      else if (strcmp(name,"Outputfilename")==0) return OutputfilenameEnum;
+	      else if (strcmp(name,"Waterfraction")==0) return WaterfractionEnum;
+	      else if (strcmp(name,"Watercolumn")==0) return WatercolumnEnum;
+	      else if (strcmp(name,"BasalFriction")==0) return BasalFrictionEnum;
+	      else if (strcmp(name,"ViscousHeating")==0) return ViscousHeatingEnum;
+	      else if (strcmp(name,"QmuTemperature")==0) return QmuTemperatureEnum;
+	      else if (strcmp(name,"HydrologyWaterVx")==0) return HydrologyWaterVxEnum;
+	      else if (strcmp(name,"HydrologyWaterVy")==0) return HydrologyWaterVyEnum;
+	      else if (strcmp(name,"StressTensor")==0) return StressTensorEnum;
+	      else if (strcmp(name,"StressTensorxx")==0) return StressTensorxxEnum;
+	      else if (strcmp(name,"StressTensorxy")==0) return StressTensorxyEnum;
+	      else if (strcmp(name,"StressTensorxz")==0) return StressTensorxzEnum;
+	      else if (strcmp(name,"StressTensoryy")==0) return StressTensoryyEnum;
+	      else if (strcmp(name,"StressTensoryz")==0) return StressTensoryzEnum;
+	      else if (strcmp(name,"StressTensorzz")==0) return StressTensorzzEnum;
+	      else if (strcmp(name,"IceVolume")==0) return IceVolumeEnum;
+	      else if (strcmp(name,"P0")==0) return P0Enum;
+	      else if (strcmp(name,"P1")==0) return P1Enum;
+	      else if (strcmp(name,"P1DG")==0) return P1DGEnum;
+	      else if (strcmp(name,"BoolElementResult")==0) return BoolElementResultEnum;
+	      else if (strcmp(name,"BoolExternalResult")==0) return BoolExternalResultEnum;
+	      else if (strcmp(name,"DoubleElementResult")==0) return DoubleElementResultEnum;
+	      else if (strcmp(name,"DoubleExternalResult")==0) return DoubleExternalResultEnum;
+	      else if (strcmp(name,"DoubleMatExternalResult")==0) return DoubleMatExternalResultEnum;
+	      else if (strcmp(name,"DoubleVecExternalResult")==0) return DoubleVecExternalResultEnum;
+         else stage=4;
+   }
+   if(stage==4){
+	      if (strcmp(name,"IntExternalResult")==0) return IntExternalResultEnum;
+	      else if (strcmp(name,"J")==0) return JEnum;
+	      else if (strcmp(name,"Patch")==0) return PatchEnum;
+	      else if (strcmp(name,"PatchNodes")==0) return PatchNodesEnum;
+	      else if (strcmp(name,"PatchVertices")==0) return PatchVerticesEnum;
+	      else if (strcmp(name,"PentaP1ElementResult")==0) return PentaP1ElementResultEnum;
+	      else if (strcmp(name,"PetscVecExternalResult")==0) return PetscVecExternalResultEnum;
+	      else if (strcmp(name,"StringExternalResult")==0) return StringExternalResultEnum;
+	      else if (strcmp(name,"Time")==0) return TimeEnum;
+	      else if (strcmp(name,"TriaP1ElementResult")==0) return TriaP1ElementResultEnum;
+	      else if (strcmp(name,"WaterColumnOld")==0) return WaterColumnOldEnum;
+	      else if (strcmp(name,"MinVel")==0) return MinVelEnum;
+	      else if (strcmp(name,"MaxVel")==0) return MaxVelEnum;
+	      else if (strcmp(name,"MinVx")==0) return MinVxEnum;
+	      else if (strcmp(name,"MaxVx")==0) return MaxVxEnum;
+	      else if (strcmp(name,"MaxAbsVx")==0) return MaxAbsVxEnum;
+	      else if (strcmp(name,"MinVy")==0) return MinVyEnum;
+	      else if (strcmp(name,"MaxVy")==0) return MaxVyEnum;
+	      else if (strcmp(name,"MaxAbsVy")==0) return MaxAbsVyEnum;
+	      else if (strcmp(name,"MinVz")==0) return MinVzEnum;
+	      else if (strcmp(name,"MaxVz")==0) return MaxVzEnum;
+	      else if (strcmp(name,"MaxAbsVz")==0) return MaxAbsVzEnum;
+	      else if (strcmp(name,"Relative")==0) return RelativeEnum;
+	      else if (strcmp(name,"Absolute")==0) return AbsoluteEnum;
+	      else if (strcmp(name,"Incremental")==0) return IncrementalEnum;
+	      else if (strcmp(name,"AgressiveMigration")==0) return AgressiveMigrationEnum;
+	      else if (strcmp(name,"None")==0) return NoneEnum;
+	      else if (strcmp(name,"SoftMigration")==0) return SoftMigrationEnum;
+	      else if (strcmp(name,"StokesSolver")==0) return StokesSolverEnum;
+	      else if (strcmp(name,"Adjoint")==0) return AdjointEnum;
+	      else if (strcmp(name,"Colinear")==0) return ColinearEnum;
+	      else if (strcmp(name,"ControlSteady")==0) return ControlSteadyEnum;
+	      else if (strcmp(name,"Fset")==0) return FsetEnum;
+	      else if (strcmp(name,"Gradient1")==0) return Gradient1Enum;
+	      else if (strcmp(name,"Gradient2")==0) return Gradient2Enum;
+	      else if (strcmp(name,"Gradient3")==0) return Gradient3Enum;
+	      else if (strcmp(name,"Gradient")==0) return GradientEnum;
+	      else if (strcmp(name,"GroundinglineMigration")==0) return GroundinglineMigrationEnum;
+	      else if (strcmp(name,"Gset")==0) return GsetEnum;
+	      else if (strcmp(name,"Index")==0) return IndexEnum;
+	      else if (strcmp(name,"Indexed")==0) return IndexedEnum;
+	      else if (strcmp(name,"Intersect")==0) return IntersectEnum;
+	      else if (strcmp(name,"Nodal")==0) return NodalEnum;
+	      else if (strcmp(name,"OldGradient")==0) return OldGradientEnum;
+	      else if (strcmp(name,"OutputFilePointer")==0) return OutputFilePointerEnum;
+	      else if (strcmp(name,"PetscOptionsAnalyses")==0) return PetscOptionsAnalysesEnum;
+	      else if (strcmp(name,"PetscOptionsStrings")==0) return PetscOptionsStringsEnum;
+	      else if (strcmp(name,"QmuErrName")==0) return QmuErrNameEnum;
+	      else if (strcmp(name,"QmuInName")==0) return QmuInNameEnum;
+	      else if (strcmp(name,"QmuOutName")==0) return QmuOutNameEnum;
+	      else if (strcmp(name,"Regular")==0) return RegularEnum;
+	      else if (strcmp(name,"Scaled")==0) return ScaledEnum;
+	      else if (strcmp(name,"Separate")==0) return SeparateEnum;
+	      else if (strcmp(name,"Sset")==0) return SsetEnum;
+	      else if (strcmp(name,"Verbose")==0) return VerboseEnum;
+	      else if (strcmp(name,"TriangleInterp")==0) return TriangleInterpEnum;
+	      else if (strcmp(name,"BilinearInterp")==0) return BilinearInterpEnum;
+	      else if (strcmp(name,"NearestInterp")==0) return NearestInterpEnum;
+	      else if (strcmp(name,"XY")==0) return XYEnum;
+	      else if (strcmp(name,"XYZP")==0) return XYZPEnum;
+	      else if (strcmp(name,"Option")==0) return OptionEnum;
+	      else if (strcmp(name,"OptionCell")==0) return OptionCellEnum;
+	      else if (strcmp(name,"OptionChar")==0) return OptionCharEnum;
+	      else if (strcmp(name,"OptionStruct")==0) return OptionStructEnum;
+	      else if (strcmp(name,"OptionDouble")==0) return OptionDoubleEnum;
+	      else if (strcmp(name,"OptionLogical")==0) return OptionLogicalEnum;
+	      else if (strcmp(name,"Paterson")==0) return PatersonEnum;
+	      else if (strcmp(name,"Arrhenius")==0) return ArrheniusEnum;
+         else stage=5;
+   }
+	/*If we reach this point, the string provided has not been found*/
+   _error_("Enum %s not found",name);
 }
Index: /issm/trunk/src/c/modules/SystemMatricesx/SystemMatricesx.cpp
===================================================================
--- /issm/trunk/src/c/modules/SystemMatricesx/SystemMatricesx.cpp	(revision 11526)
+++ /issm/trunk/src/c/modules/SystemMatricesx/SystemMatricesx.cpp	(revision 11527)
@@ -143,7 +143,11 @@
 	/*Assign output pointers: */
 	if(pKff) *pKff=Kff;
+	else      MatFree(&Kff);
 	if(pKfs) *pKfs=Kfs;
+	else      MatFree(&Kfs);
 	if(ppf)  *ppf=pf;
+	else      VecFree(&pf);
 	if(pdf)  *pdf=df;
+	else      VecFree(&df);
 	if(pkmax) *pkmax=kmax;
 }
Index: /issm/trunk/src/c/modules/UpdateVertexPositionsx/UpdateVertexPositionsx.cpp
===================================================================
--- /issm/trunk/src/c/modules/UpdateVertexPositionsx/UpdateVertexPositionsx.cpp	(revision 11526)
+++ /issm/trunk/src/c/modules/UpdateVertexPositionsx/UpdateVertexPositionsx.cpp	(revision 11527)
@@ -12,22 +12,34 @@
 int UpdateVertexPositionsx(Elements* elements,Nodes* nodes,Vertices* vertices,Loads* loads,Materials* materials,Parameters* parameters){
 
-	int i;
-	Vertex* vertex=NULL;
-	double* thickness=NULL;
-	double* bed=NULL;
+	int     i;
+	Vec     vz        = NULL;
+	Vertex *vertex    = NULL;
+	double *thickness = NULL;
+	double *bed       = NULL;
 
 	/*get vertex vectors for bed and thickness: */
-	GetVectorFromInputsx( &thickness,elements,nodes, vertices, loads, materials, parameters, ThicknessEnum,VertexEnum);
-	GetVectorFromInputsx( &bed      ,elements,nodes, vertices, loads, materials, parameters, BedEnum,      VertexEnum);
+	GetVectorFromInputsx(&thickness,elements,nodes, vertices, loads, materials, parameters, ThicknessEnum,VertexEnum);
+	GetVectorFromInputsx(&bed      ,elements,nodes, vertices, loads, materials, parameters, BedEnum,      VertexEnum);
+
+	/*Allocate vector*/
+	vz=NewVec(vertices->NumberOfVertices());
 
 	/*Update verices new geometry: */
 	for (i=0;i<vertices->Size();i++){
 		vertex=(Vertex*)vertices->GetObjectByOffset(i);
-		vertex->UpdatePosition(thickness,bed);
+		vertex->UpdatePosition(vz,parameters,thickness,bed);
 	}
+
+	/*Assemble mesh velocity*/
+	VecAssemblyBegin(vz);
+	VecAssemblyEnd(vz);
+
+	/*Update element inputs*/
+	InputUpdateFromVectorx(elements,nodes,vertices,loads,materials,parameters,vz,VzMeshEnum,VertexEnum);
 
 	/*Free ressources:*/
 	xfree((void**)&thickness);
 	xfree((void**)&bed);
+	VecFree(&vz);
 	return 1;
 }
Index: /issm/trunk/src/c/modules/modules.h
===================================================================
--- /issm/trunk/src/c/modules/modules.h	(revision 11526)
+++ /issm/trunk/src/c/modules/modules.h	(revision 11527)
@@ -31,4 +31,6 @@
 #include "./GetSolutionFromInputsx/GetSolutionFromInputsx.h"
 #include "./GetVectorFromInputsx/GetVectorFromInputsx.h"
+#include "./GetVectorFromControlInputsx/GetVectorFromControlInputsx.h"
+#include "./SetControlInputsFromVectorx/SetControlInputsFromVectorx.h"
 #include "./Gradjx/Gradjx.h"
 #include "./GroundinglineMigrationx/GroundinglineMigrationx.h"
@@ -53,5 +55,5 @@
 #include "./InputArtificialNoisex/InputArtificialNoisex.h"
 #include "./IoModelToConstraintsx/IoModelToConstraintsx.h"
-#include "./KMLMeshWritex/KMLFileReadx.h"
+#include "./KMLFileReadx/KMLFileReadx.h"
 #include "./KMLMeshWritex/KMLMeshWritex.h"
 #include "./KMLOverlayx/KMLOverlayx.h"
@@ -106,4 +108,5 @@
 #include "./SurfaceAreax/SurfaceAreax.h"
 #include "./SystemMatricesx/SystemMatricesx.h"
+#include "./CreateJacobianMatrixx/CreateJacobianMatrixx.h"
 #include "./TimeAdaptx/TimeAdaptx.h"
 #include "./TriaSearchx/TriaSearchx.h"
Index: /issm/trunk/src/c/objects/ElementResults/PentaP1ElementResult.cpp
===================================================================
--- /issm/trunk/src/c/objects/ElementResults/PentaP1ElementResult.cpp	(revision 11527)
+++ /issm/trunk/src/c/objects/ElementResults/PentaP1ElementResult.cpp	(revision 11527)
@@ -0,0 +1,210 @@
+/*!\file PentaP1ElementResult.c
+ * \brief: implementation of the PentaP1ElementResult object
+ */
+
+#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 "./ElementResultLocal.h"
+#include "../objects.h"
+#include "../../EnumDefinitions/EnumDefinitions.h"
+#include "../../shared/shared.h"
+#include "../../Container/Container.h"
+#include "../../include/include.h"
+
+/*PentaP1ElementResult constructors and destructor*/
+/*FUNCTION PentaP1ElementResult::PentaP1ElementResult(){{{1*/
+PentaP1ElementResult::PentaP1ElementResult(){
+	return;
+}
+/*}}}*/
+/*FUNCTION PentaP1ElementResult::PentaP1ElementResult(int in_enum_type,double* in_values,int in_step, double in_time){{{1*/
+PentaP1ElementResult::PentaP1ElementResult(int in_enum_type,double* in_values,int in_step, double in_time){
+
+	int i;
+
+	enum_type=in_enum_type;
+	for(i=0;i<6;i++)values[i]=in_values[i];
+	step=in_step;
+	time=in_time;
+}
+/*}}}*/
+/*FUNCTION PentaP1ElementResult::~PentaP1ElementResult(){{{1*/
+PentaP1ElementResult::~PentaP1ElementResult(){
+	return;
+}
+/*}}}*/
+
+/*Object virtual functions definitions:*/
+/*FUNCTION PentaP1ElementResult::Echo {{{1*/
+void PentaP1ElementResult::Echo(void){
+	this->DeepEcho();
+}
+/*}}}*/
+/*FUNCTION PentaP1ElementResult::DeepEcho{{{1*/
+void PentaP1ElementResult::DeepEcho(void){
+
+	printf("PentaP1ElementResult:\n");
+	printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
+	printf("   values: [%g %g %g %g %g %g]\n",this->values[0],this->values[1],this->values[2],this->values[3],this->values[4],this->values[5]);
+	printf("   step: %i\n",this->step);
+	printf("   time: %g\n",this->time);
+
+}
+/*}}}*/
+/*FUNCTION PentaP1ElementResult::Id{{{1*/
+int    PentaP1ElementResult::Id(void){ return -1; }
+/*}}}*/
+/*FUNCTION PentaP1ElementResult::MyRank{{{1*/
+int    PentaP1ElementResult::MyRank(void){ 
+	extern int my_rank;
+	return my_rank; 
+}
+/*}}}*/
+#ifdef _SERIAL_
+/*FUNCTION PentaP1ElementResult::Marshall{{{1*/
+void  PentaP1ElementResult::Marshall(char** pmarshalled_dataset){
+
+	char* marshalled_dataset=NULL;
+	int   enum_value=0;
+
+	/*recover marshalled_dataset: */
+	marshalled_dataset=*pmarshalled_dataset;
+
+	/*get enum value of PentaP1ElementResult: */
+	enum_value=PentaP1ElementResultEnum;
+	
+	/*marshall enum: */
+	memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);
+	
+	/*marshall PentaP1ElementResult data: */
+	memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
+	memcpy(marshalled_dataset,&values,sizeof(values));marshalled_dataset+=sizeof(values);
+	memcpy(marshalled_dataset,&time,sizeof(time));marshalled_dataset+=sizeof(time);
+	memcpy(marshalled_dataset,&step,sizeof(step));marshalled_dataset+=sizeof(step);
+
+	*pmarshalled_dataset=marshalled_dataset;
+}
+/*}}}*/
+/*FUNCTION PentaP1ElementResult::MarshallSize{{{1*/
+int   PentaP1ElementResult::MarshallSize(){
+	
+	return sizeof(values)+
+		+sizeof(enum_type)
+		+sizeof(time)
+		+sizeof(step)
+		+sizeof(int); //sizeof(int) for enum value
+}
+/*}}}*/
+/*FUNCTION PentaP1ElementResult::Demarshall{{{1*/
+void  PentaP1ElementResult::Demarshall(char** pmarshalled_dataset){
+
+	char* marshalled_dataset=NULL;
+	int   i;
+
+	/*recover marshalled_dataset: */
+	marshalled_dataset=*pmarshalled_dataset;
+
+	/*this time, no need to get enum type, the pointer directly points to the beginning of the 
+	 *object data (thanks to DataSet::Demarshall):*/
+	memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
+	memcpy(&values,marshalled_dataset,sizeof(values));marshalled_dataset+=sizeof(values);
+	memcpy(&time,marshalled_dataset,sizeof(time));marshalled_dataset+=sizeof(time);
+	memcpy(&step,marshalled_dataset,sizeof(step));marshalled_dataset+=sizeof(step);
+
+	/*return: */
+	*pmarshalled_dataset=marshalled_dataset;
+	return;
+}
+/*}}}*/
+#endif
+/*FUNCTION PentaP1ElementResult::ObjectEnum{{{1*/
+int PentaP1ElementResult::ObjectEnum(void){
+
+	return PentaP1ElementResultEnum;
+
+}
+/*}}}*/
+/*FUNCTION PentaP1ElementResult::copy{{{1*/
+Object* PentaP1ElementResult::copy() {
+	
+	return new PentaP1ElementResult(this->enum_type,this->values,this->step,this->time);
+
+}
+/*}}}*/
+
+/*ElementResult management*/
+/*FUNCTION PentaP1ElementResult::InstanceEnum{{{1*/
+int PentaP1ElementResult::InstanceEnum(void){
+
+	return this->enum_type;
+
+}
+/*}}}*/
+/*FUNCTION PentaP1ElementResult::SpawnTriaElementResult{{{1*/
+ElementResult* PentaP1ElementResult::SpawnTriaElementResult(int* indices){
+
+	/*output*/
+	TriaP1ElementResult* outresult=NULL;
+	double newvalues[3];
+
+	/*Loop over the new indices*/
+	for(int i=0;i<3;i++){
+
+		/*Check index value*/
+		_assert_(indices[i]>=0 && indices[i]<6);
+
+		/*Assign value to new result*/
+		newvalues[i]=this->values[indices[i]];
+	}
+
+	/*Create new Tria result*/
+	outresult=new TriaP1ElementResult(this->enum_type,&newvalues[0],this->step,this->time);
+
+	/*Assign output*/
+	return outresult;
+
+}
+/*}}}*/
+/*FUNCTION PentaP1ElementResult::ProcessUnits{{{1*/
+void PentaP1ElementResult::ProcessUnits(Parameters* parameters){
+	
+	UnitConversion(this->values,6,IuToExtEnum,this->enum_type);
+
+}
+/*}}}*/
+/*FUNCTION PentaP1ElementResult::NumberOfNodalValues{{{1*/
+int PentaP1ElementResult::NumberOfNodalValues(void){
+	return 6;
+}
+/*}}}*/
+/*FUNCTION PentaP1ElementResult::PatchFill{{{1*/
+void PentaP1ElementResult::PatchFill(int row, Patch* patch){
+	
+	 /*Here, we fill the result information into the patch object. First, let's remember what is in a row 
+	  * of the patch object: enum_type step time element_id interpolation vertices_ids nodal_values
+	  * Here, we will supply the enum_type, step, time, interpolation and nodal_values: */
+	patch->fillresultinfo(row,this->enum_type,this->step,this->time,P1Enum,this->values,6);
+
+}
+/*}}}*/
+/*FUNCTION PentaP1ElementResult::GetVectorFromResults{{{1*/
+void PentaP1ElementResult::GetVectorFromResults(Vec vector,int* doflist,int* connectivitylist,int numdofs){
+
+	double data[6];
+
+	if(numdofs!=6)_error_("Result %s is a PentaP1ElementResult and cannot write vector of %i dofs",numdofs);
+	for(int i=0;i<6;i++) data[i]=this->values[i]/(double)connectivitylist[i];
+	VecSetValues(vector,numdofs,doflist,(const double*)&data,ADD_VALUES);
+
+} /*}}}*/
+/*FUNCTION PentaP1ElementResult::GetElementVectorFromResults{{{1*/
+void PentaP1ElementResult::GetElementVectorFromResults(Vec vector,int dof){
+
+	_error_("Result %s is a PentaP1ElementResult and should not write vector of size numberofelemenrs",EnumToStringx(enum_type));
+} /*}}}*/
Index: /issm/trunk/src/c/objects/ElementResults/PentaP1ElementResult.h
===================================================================
--- /issm/trunk/src/c/objects/ElementResults/PentaP1ElementResult.h	(revision 11527)
+++ /issm/trunk/src/c/objects/ElementResults/PentaP1ElementResult.h	(revision 11527)
@@ -0,0 +1,59 @@
+/*! \file PentaP1ElementResult.h 
+ *  \brief: header file for PentaP1ElementResult object
+ *  this object is just a PentaP1Input with additional time and step info.
+ */
+
+
+#ifndef _PENTAP1ELEMENTRESULT_H_
+#define _PENTAP1ELEMENTRESULT_H_
+
+/*Headers:*/
+/*{{{1*/
+#include "../Inputs/Input.h"
+#include "../../include/include.h"
+/*}}}*/
+
+class PentaP1ElementResult: public ElementResult{
+
+	private: 
+		int    enum_type;
+		double values[6];
+		int    step;
+		double time;
+
+	public:
+
+		/*PentaP1ElementResult constructors, destructors: {{{1*/
+		PentaP1ElementResult();
+		PentaP1ElementResult(int enum_type,double* values,int step, double time);
+		~PentaP1ElementResult();
+		/*}}}*/
+		/*Object virtual functions definitions:{{{1 */
+		void  Echo();
+		void  DeepEcho();
+		int   Id(); 
+		int   MyRank();
+		#ifdef _SERIAL_
+		void  Marshall(char** pmarshalled_dataset);
+		int   MarshallSize();
+		void  Demarshall(char** pmarshalled_dataset);
+		#endif
+		int   ObjectEnum();
+		Object* copy();
+		/*}}}*/
+		/*ElementResult virtual functions definitions: {{{1*/
+		ElementResult* SpawnTriaElementResult(int* indices);
+		double  GetTime(void){return time;};
+		int     GetStep(void){return step;};
+		void    ProcessUnits(Parameters* parameters);
+		int     NumberOfNodalValues(void);
+		void    PatchFill(int row, Patch* patch);
+		/*}}}*/
+		/*PentaP1ElementResult management: {{{1*/
+		int   InstanceEnum();
+		void GetVectorFromResults(Vec vector,int* doflist,int* connectivitylist,int numdofs);
+		void GetElementVectorFromResults(Vec vector,int dof);
+		/*}}}*/
+
+};
+#endif  /* _PENTAP1ELEMENTRESULT_H */
Index: sm/trunk/src/c/objects/ElementResults/PentaVertexElementResult.cpp
===================================================================
--- /issm/trunk/src/c/objects/ElementResults/PentaVertexElementResult.cpp	(revision 11526)
+++ 	(revision )
@@ -1,210 +1,0 @@
-/*!\file PentaVertexElementResult.c
- * \brief: implementation of the PentaVertexElementResult object
- */
-
-#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 "./ElementResultLocal.h"
-#include "../objects.h"
-#include "../../EnumDefinitions/EnumDefinitions.h"
-#include "../../shared/shared.h"
-#include "../../Container/Container.h"
-#include "../../include/include.h"
-
-/*PentaVertexElementResult constructors and destructor*/
-/*FUNCTION PentaVertexElementResult::PentaVertexElementResult(){{{1*/
-PentaVertexElementResult::PentaVertexElementResult(){
-	return;
-}
-/*}}}*/
-/*FUNCTION PentaVertexElementResult::PentaVertexElementResult(int in_enum_type,double* in_values,int in_step, double in_time){{{1*/
-PentaVertexElementResult::PentaVertexElementResult(int in_enum_type,double* in_values,int in_step, double in_time){
-
-	int i;
-
-	enum_type=in_enum_type;
-	for(i=0;i<6;i++)values[i]=in_values[i];
-	step=in_step;
-	time=in_time;
-}
-/*}}}*/
-/*FUNCTION PentaVertexElementResult::~PentaVertexElementResult(){{{1*/
-PentaVertexElementResult::~PentaVertexElementResult(){
-	return;
-}
-/*}}}*/
-
-/*Object virtual functions definitions:*/
-/*FUNCTION PentaVertexElementResult::Echo {{{1*/
-void PentaVertexElementResult::Echo(void){
-	this->DeepEcho();
-}
-/*}}}*/
-/*FUNCTION PentaVertexElementResult::DeepEcho{{{1*/
-void PentaVertexElementResult::DeepEcho(void){
-
-	printf("PentaVertexElementResult:\n");
-	printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
-	printf("   values: [%g %g %g %g %g %g]\n",this->values[0],this->values[1],this->values[2],this->values[3],this->values[4],this->values[5]);
-	printf("   step: %i\n",this->step);
-	printf("   time: %g\n",this->time);
-
-}
-/*}}}*/
-/*FUNCTION PentaVertexElementResult::Id{{{1*/
-int    PentaVertexElementResult::Id(void){ return -1; }
-/*}}}*/
-/*FUNCTION PentaVertexElementResult::MyRank{{{1*/
-int    PentaVertexElementResult::MyRank(void){ 
-	extern int my_rank;
-	return my_rank; 
-}
-/*}}}*/
-#ifdef _SERIAL_
-/*FUNCTION PentaVertexElementResult::Marshall{{{1*/
-void  PentaVertexElementResult::Marshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   enum_value=0;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*get enum value of PentaVertexElementResult: */
-	enum_value=PentaVertexElementResultEnum;
-	
-	/*marshall enum: */
-	memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);
-	
-	/*marshall PentaVertexElementResult data: */
-	memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-	memcpy(marshalled_dataset,&values,sizeof(values));marshalled_dataset+=sizeof(values);
-	memcpy(marshalled_dataset,&time,sizeof(time));marshalled_dataset+=sizeof(time);
-	memcpy(marshalled_dataset,&step,sizeof(step));marshalled_dataset+=sizeof(step);
-
-	*pmarshalled_dataset=marshalled_dataset;
-}
-/*}}}*/
-/*FUNCTION PentaVertexElementResult::MarshallSize{{{1*/
-int   PentaVertexElementResult::MarshallSize(){
-	
-	return sizeof(values)+
-		+sizeof(enum_type)
-		+sizeof(time)
-		+sizeof(step)
-		+sizeof(int); //sizeof(int) for enum value
-}
-/*}}}*/
-/*FUNCTION PentaVertexElementResult::Demarshall{{{1*/
-void  PentaVertexElementResult::Demarshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   i;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*this time, no need to get enum type, the pointer directly points to the beginning of the 
-	 *object data (thanks to DataSet::Demarshall):*/
-	memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-	memcpy(&values,marshalled_dataset,sizeof(values));marshalled_dataset+=sizeof(values);
-	memcpy(&time,marshalled_dataset,sizeof(time));marshalled_dataset+=sizeof(time);
-	memcpy(&step,marshalled_dataset,sizeof(step));marshalled_dataset+=sizeof(step);
-
-	/*return: */
-	*pmarshalled_dataset=marshalled_dataset;
-	return;
-}
-/*}}}*/
-#endif
-/*FUNCTION PentaVertexElementResult::ObjectEnum{{{1*/
-int PentaVertexElementResult::ObjectEnum(void){
-
-	return PentaVertexElementResultEnum;
-
-}
-/*}}}*/
-/*FUNCTION PentaVertexElementResult::copy{{{1*/
-Object* PentaVertexElementResult::copy() {
-	
-	return new PentaVertexElementResult(this->enum_type,this->values,this->step,this->time);
-
-}
-/*}}}*/
-
-/*ElementResult management*/
-/*FUNCTION PentaVertexElementResult::InstanceEnum{{{1*/
-int PentaVertexElementResult::InstanceEnum(void){
-
-	return this->enum_type;
-
-}
-/*}}}*/
-/*FUNCTION PentaVertexElementResult::SpawnTriaElementResult{{{1*/
-ElementResult* PentaVertexElementResult::SpawnTriaElementResult(int* indices){
-
-	/*output*/
-	TriaVertexElementResult* outresult=NULL;
-	double newvalues[3];
-
-	/*Loop over the new indices*/
-	for(int i=0;i<3;i++){
-
-		/*Check index value*/
-		_assert_(indices[i]>=0 && indices[i]<6);
-
-		/*Assign value to new result*/
-		newvalues[i]=this->values[indices[i]];
-	}
-
-	/*Create new Tria result*/
-	outresult=new TriaVertexElementResult(this->enum_type,&newvalues[0],this->step,this->time);
-
-	/*Assign output*/
-	return outresult;
-
-}
-/*}}}*/
-/*FUNCTION PentaVertexElementResult::ProcessUnits{{{1*/
-void PentaVertexElementResult::ProcessUnits(Parameters* parameters){
-	
-	UnitConversion(this->values,6,IuToExtEnum,this->enum_type);
-
-}
-/*}}}*/
-/*FUNCTION PentaVertexElementResult::NumberOfNodalValues{{{1*/
-int PentaVertexElementResult::NumberOfNodalValues(void){
-	return 6;
-}
-/*}}}*/
-/*FUNCTION PentaVertexElementResult::PatchFill{{{1*/
-void PentaVertexElementResult::PatchFill(int row, Patch* patch){
-	
-	 /*Here, we fill the result information into the patch object. First, let's remember what is in a row 
-	  * of the patch object: enum_type step time element_id interpolation vertices_ids nodal_values
-	  * Here, we will supply the enum_type, step, time, interpolation and nodal_values: */
-	patch->fillresultinfo(row,this->enum_type,this->step,this->time,P1Enum,this->values,6);
-
-}
-/*}}}*/
-/*FUNCTION PentaVertexElementResult::GetVectorFromResults{{{1*/
-void PentaVertexElementResult::GetVectorFromResults(Vec vector,int* doflist,int* connectivitylist,int numdofs){
-
-	double data[6];
-
-	if(numdofs!=6)_error_("Result %s is a PentaVertexElementResult and cannot write vector of %i dofs",numdofs);
-	for(int i=0;i<6;i++) data[i]=this->values[i]/(double)connectivitylist[i];
-	VecSetValues(vector,numdofs,doflist,(const double*)&data,ADD_VALUES);
-
-} /*}}}*/
-/*FUNCTION PentaVertexElementResult::GetElementVectorFromResults{{{1*/
-void PentaVertexElementResult::GetElementVectorFromResults(Vec vector,int dof){
-
-	_error_("Result %s is a PentaVertexElementResult and should not write vector of size numberofelemenrs",EnumToStringx(enum_type));
-} /*}}}*/
Index: sm/trunk/src/c/objects/ElementResults/PentaVertexElementResult.h
===================================================================
--- /issm/trunk/src/c/objects/ElementResults/PentaVertexElementResult.h	(revision 11526)
+++ 	(revision )
@@ -1,59 +1,0 @@
-/*! \file PentaVertexElementResult.h 
- *  \brief: header file for penta vertex result  object. 
- *  this object is just a PentaVertexInput with additional time and step info.
- */
-
-
-#ifndef _PENTAVERTEXELEMENTRESULT_H_
-#define _PENTAVERTEXELEMENTRESULT_H_
-
-/*Headers:*/
-/*{{{1*/
-#include "../Inputs/Input.h"
-#include "../../include/include.h"
-/*}}}*/
-
-class PentaVertexElementResult: public ElementResult{
-
-	private: 
-		int    enum_type;
-		double values[6];
-		int    step;
-		double time;
-
-	public:
-
-		/*PentaVertexElementResult constructors, destructors: {{{1*/
-		PentaVertexElementResult();
-		PentaVertexElementResult(int enum_type,double* values,int step, double time);
-		~PentaVertexElementResult();
-		/*}}}*/
-		/*Object virtual functions definitions:{{{1 */
-		void  Echo();
-		void  DeepEcho();
-		int   Id(); 
-		int   MyRank();
-		#ifdef _SERIAL_
-		void  Marshall(char** pmarshalled_dataset);
-		int   MarshallSize();
-		void  Demarshall(char** pmarshalled_dataset);
-		#endif
-		int   ObjectEnum();
-		Object* copy();
-		/*}}}*/
-		/*ElementResult virtual functions definitions: {{{1*/
-		ElementResult* SpawnTriaElementResult(int* indices);
-		double  GetTime(void){return time;};
-		int     GetStep(void){return step;};
-		void    ProcessUnits(Parameters* parameters);
-		int     NumberOfNodalValues(void);
-		void    PatchFill(int row, Patch* patch);
-		/*}}}*/
-		/*PentaVertexElementResult management: {{{1*/
-		int   InstanceEnum();
-		void GetVectorFromResults(Vec vector,int* doflist,int* connectivitylist,int numdofs);
-		void GetElementVectorFromResults(Vec vector,int dof);
-		/*}}}*/
-
-};
-#endif  /* _PENTAVERTEXELEMENTRESULT_H */
Index: /issm/trunk/src/c/objects/ElementResults/TriaP1ElementResult.cpp
===================================================================
--- /issm/trunk/src/c/objects/ElementResults/TriaP1ElementResult.cpp	(revision 11527)
+++ /issm/trunk/src/c/objects/ElementResults/TriaP1ElementResult.cpp	(revision 11527)
@@ -0,0 +1,199 @@
+/*!\file TriaP1ElementResult.c
+ * \brief: implementation of the TriaP1ElementResult object
+ */
+
+#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 "./ElementResultLocal.h"
+#include "../objects.h"
+#include "../../EnumDefinitions/EnumDefinitions.h"
+#include "../../shared/shared.h"
+#include "../../Container/Container.h"
+#include "../../include/include.h"
+
+/*TriaP1ElementResult constructors and destructor*/
+/*FUNCTION TriaP1ElementResult::TriaP1ElementResult(){{{1*/
+TriaP1ElementResult::TriaP1ElementResult(){
+	return;
+}
+/*}}}*/
+/*FUNCTION TriaP1ElementResult::TriaP1ElementResult(int in_enum_type,double* in_values,int in_step, double in_time){{{1*/
+TriaP1ElementResult::TriaP1ElementResult(int in_enum_type,double* in_values,int in_step, double in_time){
+
+	enum_type=in_enum_type;
+	values[0]=in_values[0];
+	values[1]=in_values[1];
+	values[2]=in_values[2];
+	step=in_step;
+	time=in_time;
+}
+/*}}}*/
+/*FUNCTION TriaP1ElementResult::~TriaP1ElementResult(){{{1*/
+TriaP1ElementResult::~TriaP1ElementResult(){
+	return;
+}
+/*}}}*/
+
+/*Object virtual functions definitions:*/
+/*FUNCTION TriaP1ElementResult::Echo {{{1*/
+void TriaP1ElementResult::Echo(void){
+	this->DeepEcho();
+}
+/*}}}*/
+/*FUNCTION TriaP1ElementResult::DeepEcho{{{1*/
+void TriaP1ElementResult::DeepEcho(void){
+		
+	printf("TriaP1ElementResult:\n");
+	printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
+	printf("   values: [%g %g %g]\n",this->values[0],this->values[1],this->values[2]);
+	printf("   step: %i\n",this->step);
+	printf("   time: %g\n",this->time);
+}
+/*}}}*/
+/*FUNCTION TriaP1ElementResult::Id{{{1*/
+int    TriaP1ElementResult::Id(void){ return -1; }
+/*}}}*/
+/*FUNCTION TriaP1ElementResult::MyRank{{{1*/
+int    TriaP1ElementResult::MyRank(void){ 
+	extern int my_rank;
+	return my_rank; 
+}
+/*}}}*/
+#ifdef _SERIAL_
+/*FUNCTION TriaP1ElementResult::Marshall{{{1*/
+void  TriaP1ElementResult::Marshall(char** pmarshalled_dataset){
+
+	char* marshalled_dataset=NULL;
+	int   enum_value=0;
+
+
+	/*recover marshalled_dataset: */
+	marshalled_dataset=*pmarshalled_dataset;
+
+	/*get enum value of TriaP1ElementResult: */
+	enum_value=TriaP1ElementResultEnum;
+	
+	/*marshall enum: */
+	memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);
+	
+	/*marshall TriaP1ElementResult data: */
+	memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
+	memcpy(marshalled_dataset,&values,sizeof(values));marshalled_dataset+=sizeof(values);
+	memcpy(marshalled_dataset,&time,sizeof(time));marshalled_dataset+=sizeof(time);
+	memcpy(marshalled_dataset,&step,sizeof(step));marshalled_dataset+=sizeof(step);
+
+	*pmarshalled_dataset=marshalled_dataset;
+}
+/*}}}*/
+/*FUNCTION TriaP1ElementResult::MarshallSize{{{1*/
+int   TriaP1ElementResult::MarshallSize(){
+	
+	return sizeof(values)
+		+sizeof(enum_type)
+		+sizeof(time)
+		+sizeof(step)
+		+sizeof(int); //sizeof(int) for enum value
+}
+/*}}}*/
+/*FUNCTION TriaP1ElementResult::Demarshall{{{1*/
+void  TriaP1ElementResult::Demarshall(char** pmarshalled_dataset){
+
+	char* marshalled_dataset=NULL;
+	int   i;
+
+	/*recover marshalled_dataset: */
+	marshalled_dataset=*pmarshalled_dataset;
+
+	/*this time, no need to get enum type, the pointer directly points to the beginning of the 
+	 *object data (thanks to DataSet::Demarshall):*/
+	memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
+	memcpy(&values,marshalled_dataset,sizeof(values));marshalled_dataset+=sizeof(values);
+	memcpy(&time,marshalled_dataset,sizeof(time));marshalled_dataset+=sizeof(time);
+	memcpy(&step,marshalled_dataset,sizeof(step));marshalled_dataset+=sizeof(step);
+
+	/*return: */
+	*pmarshalled_dataset=marshalled_dataset;
+	return;
+}
+/*}}}*/
+#endif
+/*FUNCTION TriaP1ElementResult::ObjectEnum{{{1*/
+int TriaP1ElementResult::ObjectEnum(void){
+
+	return TriaP1ElementResultEnum;
+
+}
+/*}}}*/
+/*FUNCTION TriaP1ElementResult::copy{{{1*/
+Object* TriaP1ElementResult::copy() {
+	
+	return new TriaP1ElementResult(this->enum_type,this->values,this->step,this->time);
+
+}
+/*}}}*/
+
+/*ElementResult management*/
+/*FUNCTION TriaP1ElementResult::InstanceEnum{{{1*/
+int TriaP1ElementResult::InstanceEnum(void){
+
+	return this->enum_type;
+
+}
+/*}}}*/
+/*FUNCTION TriaP1ElementResult::SpawnTriaElementResult{{{1*/
+ElementResult* TriaP1ElementResult::SpawnTriaElementResult(int* indices){
+
+	/*output*/
+	TriaP1ElementResult* outresult=NULL;
+
+	/*Create new Tria result (copy of current result)*/
+	outresult=new TriaP1ElementResult(this->enum_type,&this->values[0],this->step,this->time);
+
+	/*Assign output*/
+	return outresult;
+
+}
+/*}}}*/
+/*FUNCTION TriaP1ElementResult::ProcessUnits{{{1*/
+void TriaP1ElementResult::ProcessUnits(Parameters* parameters){
+	
+	UnitConversion(this->values,3,IuToExtEnum,this->enum_type);
+
+}
+/*}}}*/
+/*FUNCTION TriaP1ElementResult::NumberOfNodalValues{{{1*/
+int TriaP1ElementResult::NumberOfNodalValues(void){
+	return 3;
+}
+/*}}}*/
+/*FUNCTION TriaP1ElementResult::PatchFill{{{1*/
+void TriaP1ElementResult::PatchFill(int row, Patch* patch){
+	
+	 /*Here, we fill the result information into the patch object. First, let's remember what is in a row 
+	  * of the patch object: enum_type step time element_id interpolation vertices_ids nodal_values
+	  * Here, we will supply the enum_type, step, time, interpolation and nodal_values: */
+	patch->fillresultinfo(row,this->enum_type,this->step,this->time,P1Enum,this->values,3);
+
+}
+/*}}}*/
+/*FUNCTION TriaP1ElementResult::GetVectorFromResults{{{1*/
+void TriaP1ElementResult::GetVectorFromResults(Vec vector,int* doflist,int* connectivitylist,int numdofs){
+
+	double data[3];
+
+	if(numdofs!=3)_error_("Result %s is a TriaP1ElementResult and cannot write vector of %i dofs",numdofs);
+	for(int i=0;i<3;i++) data[i]=this->values[i]/(double)connectivitylist[i];
+	VecSetValues(vector,numdofs,doflist,(const double*)&data,ADD_VALUES);
+
+} /*}}}*/
+/*FUNCTION TriaP1ElementResult::GetElementVectorFromResults{{{1*/
+void TriaP1ElementResult::GetElementVectorFromResults(Vec vector,int dof){
+
+	_error_("Result %s is a TriaP1ElementResult and should not write vector of size numberofelemenrs",EnumToStringx(enum_type));
+} /*}}}*/
Index: /issm/trunk/src/c/objects/ElementResults/TriaP1ElementResult.h
===================================================================
--- /issm/trunk/src/c/objects/ElementResults/TriaP1ElementResult.h	(revision 11527)
+++ /issm/trunk/src/c/objects/ElementResults/TriaP1ElementResult.h	(revision 11527)
@@ -0,0 +1,58 @@
+/*! \file TriaP1ElementResult.h 
+ *  \brief: header file for TriaP1ElementResult object
+ */
+
+
+#ifndef _TRIAP1ELEMENTRESULT_H_
+#define _TRIAP1ELEMENTRESULT_H_
+
+/*Headers:*/
+/*{{{1*/
+#include "../Inputs/Input.h"
+#include "../../include/include.h"
+/*}}}*/
+
+class TriaP1ElementResult: public ElementResult{
+
+	private: 
+		int    enum_type;
+		double values[3];
+		int    step;
+		double time;
+
+	public:
+
+		/*TriaP1ElementResult constructors, destructors: {{{1*/
+		TriaP1ElementResult();
+		TriaP1ElementResult(int enum_type,double* values,int step,double time);
+		~TriaP1ElementResult();
+		/*}}}*/
+		/*Object virtual functions definitions:{{{1 */
+		void  Echo();
+		void  DeepEcho();
+		int   Id(); 
+		int   MyRank();
+		#ifdef _SERIAL_
+		void  Marshall(char** pmarshalled_dataset);
+		int   MarshallSize();
+		void  Demarshall(char** pmarshalled_dataset);
+		#endif
+		int   ObjectEnum();
+		Object* copy();
+		/*}}}*/
+		/*ElementResult virtual functions definitions: {{{1*/
+		ElementResult* SpawnTriaElementResult(int* indices);
+		double  GetTime(void){return time;};
+		int     GetStep(void){return step;};
+		void    ProcessUnits(Parameters* parameters);
+		int     NumberOfNodalValues(void);
+		void    PatchFill(int row, Patch* patch);
+		/*}}}*/
+		/*TriaP1ElementResult management: {{{1*/
+		int   InstanceEnum();
+		void GetVectorFromResults(Vec vector,int* doflist,int* connectivitylist,int numdofs);
+		void GetElementVectorFromResults(Vec vector,int dof);
+		/*}}}*/
+
+};
+#endif  /* _TRIAP1ELEMENTRESULT_H */
Index: sm/trunk/src/c/objects/ElementResults/TriaVertexElementResult.cpp
===================================================================
--- /issm/trunk/src/c/objects/ElementResults/TriaVertexElementResult.cpp	(revision 11526)
+++ 	(revision )
@@ -1,199 +1,0 @@
-/*!\file TriaVertexElementResult.c
- * \brief: implementation of the TriaVertexElementResult object
- */
-
-#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 "./ElementResultLocal.h"
-#include "../objects.h"
-#include "../../EnumDefinitions/EnumDefinitions.h"
-#include "../../shared/shared.h"
-#include "../../Container/Container.h"
-#include "../../include/include.h"
-
-/*TriaVertexElementResult constructors and destructor*/
-/*FUNCTION TriaVertexElementResult::TriaVertexElementResult(){{{1*/
-TriaVertexElementResult::TriaVertexElementResult(){
-	return;
-}
-/*}}}*/
-/*FUNCTION TriaVertexElementResult::TriaVertexElementResult(int in_enum_type,double* in_values,int in_step, double in_time){{{1*/
-TriaVertexElementResult::TriaVertexElementResult(int in_enum_type,double* in_values,int in_step, double in_time){
-
-	enum_type=in_enum_type;
-	values[0]=in_values[0];
-	values[1]=in_values[1];
-	values[2]=in_values[2];
-	step=in_step;
-	time=in_time;
-}
-/*}}}*/
-/*FUNCTION TriaVertexElementResult::~TriaVertexElementResult(){{{1*/
-TriaVertexElementResult::~TriaVertexElementResult(){
-	return;
-}
-/*}}}*/
-
-/*Object virtual functions definitions:*/
-/*FUNCTION TriaVertexElementResult::Echo {{{1*/
-void TriaVertexElementResult::Echo(void){
-	this->DeepEcho();
-}
-/*}}}*/
-/*FUNCTION TriaVertexElementResult::DeepEcho{{{1*/
-void TriaVertexElementResult::DeepEcho(void){
-		
-	printf("TriaVertexElementResult:\n");
-	printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
-	printf("   values: [%g %g %g]\n",this->values[0],this->values[1],this->values[2]);
-	printf("   step: %i\n",this->step);
-	printf("   time: %g\n",this->time);
-}
-/*}}}*/
-/*FUNCTION TriaVertexElementResult::Id{{{1*/
-int    TriaVertexElementResult::Id(void){ return -1; }
-/*}}}*/
-/*FUNCTION TriaVertexElementResult::MyRank{{{1*/
-int    TriaVertexElementResult::MyRank(void){ 
-	extern int my_rank;
-	return my_rank; 
-}
-/*}}}*/
-#ifdef _SERIAL_
-/*FUNCTION TriaVertexElementResult::Marshall{{{1*/
-void  TriaVertexElementResult::Marshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   enum_value=0;
-
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*get enum value of TriaVertexElementResult: */
-	enum_value=TriaVertexElementResultEnum;
-	
-	/*marshall enum: */
-	memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);
-	
-	/*marshall TriaVertexElementResult data: */
-	memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-	memcpy(marshalled_dataset,&values,sizeof(values));marshalled_dataset+=sizeof(values);
-	memcpy(marshalled_dataset,&time,sizeof(time));marshalled_dataset+=sizeof(time);
-	memcpy(marshalled_dataset,&step,sizeof(step));marshalled_dataset+=sizeof(step);
-
-	*pmarshalled_dataset=marshalled_dataset;
-}
-/*}}}*/
-/*FUNCTION TriaVertexElementResult::MarshallSize{{{1*/
-int   TriaVertexElementResult::MarshallSize(){
-	
-	return sizeof(values)
-		+sizeof(enum_type)
-		+sizeof(time)
-		+sizeof(step)
-		+sizeof(int); //sizeof(int) for enum value
-}
-/*}}}*/
-/*FUNCTION TriaVertexElementResult::Demarshall{{{1*/
-void  TriaVertexElementResult::Demarshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   i;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*this time, no need to get enum type, the pointer directly points to the beginning of the 
-	 *object data (thanks to DataSet::Demarshall):*/
-	memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-	memcpy(&values,marshalled_dataset,sizeof(values));marshalled_dataset+=sizeof(values);
-	memcpy(&time,marshalled_dataset,sizeof(time));marshalled_dataset+=sizeof(time);
-	memcpy(&step,marshalled_dataset,sizeof(step));marshalled_dataset+=sizeof(step);
-
-	/*return: */
-	*pmarshalled_dataset=marshalled_dataset;
-	return;
-}
-/*}}}*/
-#endif
-/*FUNCTION TriaVertexElementResult::ObjectEnum{{{1*/
-int TriaVertexElementResult::ObjectEnum(void){
-
-	return TriaVertexElementResultEnum;
-
-}
-/*}}}*/
-/*FUNCTION TriaVertexElementResult::copy{{{1*/
-Object* TriaVertexElementResult::copy() {
-	
-	return new TriaVertexElementResult(this->enum_type,this->values,this->step,this->time);
-
-}
-/*}}}*/
-
-/*ElementResult management*/
-/*FUNCTION TriaVertexElementResult::InstanceEnum{{{1*/
-int TriaVertexElementResult::InstanceEnum(void){
-
-	return this->enum_type;
-
-}
-/*}}}*/
-/*FUNCTION TriaVertexElementResult::SpawnTriaElementResult{{{1*/
-ElementResult* TriaVertexElementResult::SpawnTriaElementResult(int* indices){
-
-	/*output*/
-	TriaVertexElementResult* outresult=NULL;
-
-	/*Create new Tria result (copy of current result)*/
-	outresult=new TriaVertexElementResult(this->enum_type,&this->values[0],this->step,this->time);
-
-	/*Assign output*/
-	return outresult;
-
-}
-/*}}}*/
-/*FUNCTION TriaVertexElementResult::ProcessUnits{{{1*/
-void TriaVertexElementResult::ProcessUnits(Parameters* parameters){
-	
-	UnitConversion(this->values,3,IuToExtEnum,this->enum_type);
-
-}
-/*}}}*/
-/*FUNCTION TriaVertexElementResult::NumberOfNodalValues{{{1*/
-int TriaVertexElementResult::NumberOfNodalValues(void){
-	return 3;
-}
-/*}}}*/
-/*FUNCTION TriaVertexElementResult::PatchFill{{{1*/
-void TriaVertexElementResult::PatchFill(int row, Patch* patch){
-	
-	 /*Here, we fill the result information into the patch object. First, let's remember what is in a row 
-	  * of the patch object: enum_type step time element_id interpolation vertices_ids nodal_values
-	  * Here, we will supply the enum_type, step, time, interpolation and nodal_values: */
-	patch->fillresultinfo(row,this->enum_type,this->step,this->time,P1Enum,this->values,3);
-
-}
-/*}}}*/
-/*FUNCTION TriaVertexElementResult::GetVectorFromResults{{{1*/
-void TriaVertexElementResult::GetVectorFromResults(Vec vector,int* doflist,int* connectivitylist,int numdofs){
-
-	double data[3];
-
-	if(numdofs!=3)_error_("Result %s is a TriaVertexElementResult and cannot write vector of %i dofs",numdofs);
-	for(int i=0;i<3;i++) data[i]=this->values[i]/(double)connectivitylist[i];
-	VecSetValues(vector,numdofs,doflist,(const double*)&data,ADD_VALUES);
-
-} /*}}}*/
-/*FUNCTION TriaVertexElementResult::GetElementVectorFromResults{{{1*/
-void TriaVertexElementResult::GetElementVectorFromResults(Vec vector,int dof){
-
-	_error_("Result %s is a TriaVertexElementResult and should not write vector of size numberofelemenrs",EnumToStringx(enum_type));
-} /*}}}*/
Index: sm/trunk/src/c/objects/ElementResults/TriaVertexElementResult.h
===================================================================
--- /issm/trunk/src/c/objects/ElementResults/TriaVertexElementResult.h	(revision 11526)
+++ 	(revision )
@@ -1,58 +1,0 @@
-/*! \file TriaVertexElementResult.h 
- *  \brief: header file for triavertexresult object
- */
-
-
-#ifndef _TRIAVERTEXELEMENTRESULT_H_
-#define _TRIAVERTEXELEMENTRESULT_H_
-
-/*Headers:*/
-/*{{{1*/
-#include "../Inputs/Input.h"
-#include "../../include/include.h"
-/*}}}*/
-
-class TriaVertexElementResult: public ElementResult{
-
-	private: 
-		int    enum_type;
-		double values[3];
-		int    step;
-		double time;
-
-	public:
-
-		/*TriaVertexElementResult constructors, destructors: {{{1*/
-		TriaVertexElementResult();
-		TriaVertexElementResult(int enum_type,double* values,int step,double time);
-		~TriaVertexElementResult();
-		/*}}}*/
-		/*Object virtual functions definitions:{{{1 */
-		void  Echo();
-		void  DeepEcho();
-		int   Id(); 
-		int   MyRank();
-		#ifdef _SERIAL_
-		void  Marshall(char** pmarshalled_dataset);
-		int   MarshallSize();
-		void  Demarshall(char** pmarshalled_dataset);
-		#endif
-		int   ObjectEnum();
-		Object* copy();
-		/*}}}*/
-		/*ElementResult virtual functions definitions: {{{1*/
-		ElementResult* SpawnTriaElementResult(int* indices);
-		double  GetTime(void){return time;};
-		int     GetStep(void){return step;};
-		void    ProcessUnits(Parameters* parameters);
-		int     NumberOfNodalValues(void);
-		void    PatchFill(int row, Patch* patch);
-		/*}}}*/
-		/*TriaVertexElementResult management: {{{1*/
-		int   InstanceEnum();
-		void GetVectorFromResults(Vec vector,int* doflist,int* connectivitylist,int numdofs);
-		void GetElementVectorFromResults(Vec vector,int dof);
-		/*}}}*/
-
-};
-#endif  /* _TRIAVERTEXELEMENTRESULT_H */
Index: /issm/trunk/src/c/objects/Elements/Element.h
===================================================================
--- /issm/trunk/src/c/objects/Elements/Element.h	(revision 11526)
+++ /issm/trunk/src/c/objects/Elements/Element.h	(revision 11527)
@@ -30,4 +30,5 @@
 		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 int    GetNodeIndex(Node* node)=0;
@@ -67,6 +68,8 @@
 		virtual void   MigrateGroundingLine(double* old_floating_ice,double* sheet_ungrounding)=0;
 		virtual void   PotentialSheetUngrounding(Vec potential_sheet_ungrounding)=0;
+		virtual void   PositiveDegreeDay(void)=0;
 		virtual int    UpdatePotentialSheetUngrounding(double* potential_sheet_ungrounding,Vec vec_nodes_on_iceshelf,double* nodes_on_iceshelf)=0;
 		virtual void   ResetCoordinateSystem()=0;
+		virtual void   SmearFunction(Vec smearedvector,double (*WeightFunction)(double distance,double radius),double radius)=0;
 
 		#ifdef _HAVE_RESPONSES_
@@ -89,5 +92,5 @@
 
 		#ifdef _HAVE_CONTROL_
-		virtual void   Gradj(Vec gradient,int control_type)=0;
+		virtual void   Gradj(Vec gradient,int control_type,int control_index)=0;
 		virtual double ThicknessAbsMisfit(bool process_units  ,int weight_index)=0;
 		virtual double SurfaceAbsVelMisfit(bool process_units ,int weight_index)=0;
@@ -99,7 +102,9 @@
 		virtual double RheologyBbarAbsGradient(bool process_units,int weight_index)=0;
 		virtual double DragCoefficientAbsGradient(bool process_units,int weight_index)=0;
-		virtual void   ControlInputGetGradient(Vec gradient,int enum_type)=0;
-		virtual void   ControlInputSetGradient(double* gradient,int enum_type)=0;
+		virtual void   ControlInputGetGradient(Vec gradient,int enum_type,int control_index)=0;
+		virtual void   ControlInputSetGradient(double* gradient,int enum_type,int control_index)=0;
 		virtual void   ControlInputScaleGradient(int enum_type, double scale)=0;
+		virtual void   GetVectorFromControlInputs(Vec gradient,int control_enum,int control_index,const char* data)=0;
+		virtual void   SetControlInputsFromVector(double* vector,int control_enum,int control_index)=0;
 		virtual void   InputControlUpdate(double scalar,bool save_parameter)=0;
 		#endif
Index: /issm/trunk/src/c/objects/Elements/Penta.cpp
===================================================================
--- /issm/trunk/src/c/objects/Elements/Penta.cpp	(revision 11526)
+++ /issm/trunk/src/c/objects/Elements/Penta.cpp	(revision 11527)
@@ -347,5 +347,5 @@
 	if (!IsOnBed() || IsFloating()){
 		//empty friction: 
-		this->inputs->AddInput(new PentaVertexInput(BasalFrictionEnum,&basalfriction[0]));
+		this->inputs->AddInput(new PentaP1Input(BasalFrictionEnum,&basalfriction[0]));
 		return;
 	}
@@ -375,5 +375,5 @@
 	
 	/*Create PentaVertex input, which will hold the basal friction:*/
-	this->inputs->AddInput(new PentaVertexInput(BasalFrictionEnum,&basalfriction[0]));
+	this->inputs->AddInput(new PentaP1Input(BasalFrictionEnum,&basalfriction[0]));
 
 	/*Clean up and return*/
@@ -523,10 +523,10 @@
 	
 	/*Add Stress tensor components into inputs*/
-	this->inputs->AddInput(new PentaVertexInput(StressTensorxxEnum,&sigma_xx[0]));
-	this->inputs->AddInput(new PentaVertexInput(StressTensorxyEnum,&sigma_xy[0]));
-	this->inputs->AddInput(new PentaVertexInput(StressTensorxzEnum,&sigma_xz[0]));
-	this->inputs->AddInput(new PentaVertexInput(StressTensoryyEnum,&sigma_yy[0]));
-	this->inputs->AddInput(new PentaVertexInput(StressTensoryzEnum,&sigma_yz[0]));
-	this->inputs->AddInput(new PentaVertexInput(StressTensorzzEnum,&sigma_zz[0]));
+	this->inputs->AddInput(new PentaP1Input(StressTensorxxEnum,&sigma_xx[0]));
+	this->inputs->AddInput(new PentaP1Input(StressTensorxyEnum,&sigma_xy[0]));
+	this->inputs->AddInput(new PentaP1Input(StressTensorxzEnum,&sigma_xz[0]));
+	this->inputs->AddInput(new PentaP1Input(StressTensoryyEnum,&sigma_yy[0]));
+	this->inputs->AddInput(new PentaP1Input(StressTensoryzEnum,&sigma_yz[0]));
+	this->inputs->AddInput(new PentaP1Input(StressTensorzzEnum,&sigma_zz[0]));
 
 	/*Clean up and return*/
@@ -585,6 +585,9 @@
 	switch(analysis_type){
 		#ifdef _HAVE_DIAGNOSTIC_
-		case DiagnosticHorizAnalysisEnum: case AdjointHorizAnalysisEnum:
+		case DiagnosticHorizAnalysisEnum:
 			Ke=CreateKMatrixDiagnosticHoriz(); De=CreateDVectorDiagnosticHoriz();
+			break;
+		case AdjointHorizAnalysisEnum:
+			Ke=CreateKMatrixAdjointHoriz();
 			break;
 		case DiagnosticHutterAnalysisEnum:
@@ -769,4 +772,37 @@
 }
 /*}}}*/
+/*FUNCTION Penta::CreateJacobianMatrix{{{1*/
+void  Penta::CreateJacobianMatrix(Mat Jff){
+
+	/*retrieve parameters: */
+	ElementMatrix* Ke=NULL;
+	int analysis_type;
+	parameters->FindParam(&analysis_type,AnalysisTypeEnum);
+
+	/*Checks in debugging {{{2*/
+	_assert_(this->nodes && this->matice && this->matpar && this->verticalneighbors && this->parameters && this->inputs);
+	/*}}}*/
+
+	/*Skip if water element*/
+	if(IsOnWater()) return;
+
+	/*Just branch to the correct element stiffness matrix generator, according to the type of analysis we are carrying out: */
+	switch(analysis_type){
+#ifdef _HAVE_DIAGNOSTIC_
+		case DiagnosticHorizAnalysisEnum:
+			Ke=CreateJacobianDiagnosticHoriz();
+			break;
+#endif
+		default:
+			_error_("analysis %i (%s) not supported yet",analysis_type,EnumToStringx(analysis_type));
+	}
+
+	/*Add to global matrix*/
+	if(Ke){
+		Ke->AddToGlobal(Jff);
+		delete Ke;
+	}
+}
+/*}}}*/
 /*FUNCTION Penta::DeepEcho{{{1*/
 void Penta::DeepEcho(void){
@@ -1099,6 +1135,8 @@
 /*}}}*/
 /*FUNCTION Penta::GetStabilizationParameter {{{1*/
-double Penta::GetStabilizationParameter(double u, double v, double w, double diameter, double rho_ice, double heatcapacity, double thermalconductivity){
+double Penta::GetStabilizationParameter(double u, double v, double w, double diameter, double kappa){
 	/*Compute stabilization parameter*/
+	/*kappa=thermalconductivity/(rho_ice*hearcapacity) for thermal model*/
+	/*kappa=enthalpydiffusionparameter for enthalpy model*/
 
 	double normu;
@@ -1106,6 +1144,6 @@
 
 	normu=pow(pow(u,2)+pow(v,2)+pow(w,2),0.5);
-	if(normu*diameter/(3*2*thermalconductivity/(rho_ice*heatcapacity))<1){
-		tau_parameter=pow(diameter,2)/(3*2*2*thermalconductivity/(rho_ice*heatcapacity));
+	if(normu*diameter/(3*2*kappa)<1){ 
+		tau_parameter=pow(diameter,2)/(3*2*2*kappa);
 	}
 	else tau_parameter=diameter/(2*normu);
@@ -1347,5 +1385,5 @@
 
 			/*create static input: */
-			this->inputs->AddInput(new PentaVertexInput(vector_enum,nodeinputs));
+			this->inputs->AddInput(new PentaP1Input(vector_enum,nodeinputs));
 		}
 		else if(M==numberofvertices+1){
@@ -1366,5 +1404,5 @@
 
 				if(t==0)transientinput=new TransientInput(vector_enum);
-				transientinput->AddTimeInput(new PentaVertexInput(vector_enum,nodeinputs),time);
+				transientinput->AddTimeInput(new PentaP1Input(vector_enum,nodeinputs),time);
 			}
 			this->inputs->AddInput(transientinput);
@@ -1420,5 +1458,5 @@
 
 	/*OK, we are on bed. Initialize global inputs as 0*/
-	total_thickness_input =new PentaVertexInput(ThicknessEnum,zeros_list);
+	total_thickness_input =new PentaP1Input(ThicknessEnum,zeros_list);
 
 	/*Now follow all the upper element from the base to the surface to integrate the input*/
@@ -1438,8 +1476,8 @@
 		/*If first time, initialize total_integrated_input*/
 		if (step==0){
-			if (original_input->ObjectEnum()==PentaVertexInputEnum)
-			 total_integrated_input=new PentaVertexInput(average_enum_type,zeros_list);
+			if (original_input->ObjectEnum()==PentaP1InputEnum)
+			 total_integrated_input=new PentaP1Input(average_enum_type,zeros_list);
 			else if (original_input->ObjectEnum()==ControlInputEnum)
-			 total_integrated_input=new PentaVertexInput(average_enum_type,zeros_list);
+			 total_integrated_input=new PentaP1Input(average_enum_type,zeros_list);
 			else if (original_input->ObjectEnum()==DoubleInputEnum)
 			 total_integrated_input=new DoubleInput(average_enum_type,0.0);
@@ -1454,5 +1492,5 @@
 			Helem_list[i+3]=Helem_list[i];
 		}
-		element_thickness_input=new PentaVertexInput(ThicknessEnum,Helem_list);
+		element_thickness_input=new PentaP1Input(ThicknessEnum,Helem_list);
 
 		/*Step3: Vertically integrate A COPY of the original*/
@@ -1607,5 +1645,7 @@
 	this->results->AddObject((Object*)input->SpawnResult(step,time));
 	#ifdef _HAVE_CONTROL_
-	if(input->ObjectEnum()==ControlInputEnum) this->results->AddObject((Object*)((ControlInput*)input)->SpawnGradient(step,time));
+	if(input->ObjectEnum()==ControlInputEnum){
+		if(((ControlInput*)input)->gradient!=NULL) this->results->AddObject((Object*)((ControlInput*)input)->SpawnGradient(step,time));
+	}
 	#endif
 
@@ -1681,5 +1721,5 @@
 						for(j=0;j<6;j++)cmmininputs[j]=iomodel->Data(InversionMinParametersEnum)[(penta_vertex_ids[j]-1)*num_control_type+i]/yts;
 						for(j=0;j<6;j++)cmmaxinputs[j]=iomodel->Data(InversionMaxParametersEnum)[(penta_vertex_ids[j]-1)*num_control_type+i]/yts;
-						this->inputs->AddInput(new ControlInput(BalancethicknessThickeningRateEnum,PentaVertexInputEnum,nodeinputs,cmmininputs,cmmaxinputs,i+1));
+						this->inputs->AddInput(new ControlInput(BalancethicknessThickeningRateEnum,PentaP1InputEnum,nodeinputs,cmmininputs,cmmaxinputs,i+1));
 					}
 					break;
@@ -1689,5 +1729,5 @@
 						for(j=0;j<6;j++)cmmininputs[j]=iomodel->Data(InversionMinParametersEnum)[(penta_vertex_ids[j]-1)*num_control_type+i]/yts;
 						for(j=0;j<6;j++)cmmaxinputs[j]=iomodel->Data(InversionMaxParametersEnum)[(penta_vertex_ids[j]-1)*num_control_type+i]/yts;
-						this->inputs->AddInput(new ControlInput(VxEnum,PentaVertexInputEnum,nodeinputs,cmmininputs,cmmaxinputs,i+1));
+						this->inputs->AddInput(new ControlInput(VxEnum,PentaP1InputEnum,nodeinputs,cmmininputs,cmmaxinputs,i+1));
 					}
 					break;
@@ -1697,5 +1737,5 @@
 						for(j=0;j<6;j++)cmmininputs[j]=iomodel->Data(InversionMinParametersEnum)[(penta_vertex_ids[j]-1)*num_control_type+i]/yts;
 						for(j=0;j<6;j++)cmmaxinputs[j]=iomodel->Data(InversionMaxParametersEnum)[(penta_vertex_ids[j]-1)*num_control_type+i]/yts;
-						this->inputs->AddInput(new ControlInput(VyEnum,PentaVertexInputEnum,nodeinputs,cmmininputs,cmmaxinputs,i+1));
+						this->inputs->AddInput(new ControlInput(VyEnum,PentaP1InputEnum,nodeinputs,cmmininputs,cmmaxinputs,i+1));
 					}
 					break;
@@ -1705,5 +1745,5 @@
 						for(j=0;j<6;j++)cmmininputs[j]=iomodel->Data(InversionMinParametersEnum)[(penta_vertex_ids[j]-1)*num_control_type+i];
 						for(j=0;j<6;j++)cmmaxinputs[j]=iomodel->Data(InversionMaxParametersEnum)[(penta_vertex_ids[j]-1)*num_control_type+i];
-						this->inputs->AddInput(new ControlInput(FrictionCoefficientEnum,PentaVertexInputEnum,nodeinputs,cmmininputs,cmmaxinputs,i+1));
+						this->inputs->AddInput(new ControlInput(FrictionCoefficientEnum,PentaP1InputEnum,nodeinputs,cmmininputs,cmmaxinputs,i+1));
 					}
 					break;
@@ -1755,5 +1795,5 @@
 		for(i=0;i<num_cm_responses;i++){
 			for(j=0;j<6;j++)nodeinputs[j]=iomodel->Data(InversionCostFunctionsCoefficientsEnum)[(penta_vertex_ids[j]-1)*num_cm_responses+i];
-			datasetinput->inputs->AddObject(new PentaVertexInput(InversionCostFunctionsCoefficientsEnum,nodeinputs));
+			datasetinput->inputs->AddObject(new PentaP1Input(InversionCostFunctionsCoefficientsEnum,nodeinputs));
 		}
 
@@ -1900,7 +1940,7 @@
 	for(;;){
 		/*Add input to the element: */
-		penta->inputs->AddInput(new PentaVertexInput(ThicknessEnum,newthickness));
-		penta->inputs->AddInput(new PentaVertexInput(SurfaceEnum,newsurface));
-		penta->inputs->AddInput(new PentaVertexInput(BedEnum,newbed));
+		penta->inputs->AddInput(new PentaP1Input(ThicknessEnum,newthickness));
+		penta->inputs->AddInput(new PentaP1Input(SurfaceEnum,newsurface));
+		penta->inputs->AddInput(new PentaP1Input(BedEnum,newbed));
 
 		/*Stop if we have reached the surface*/
@@ -1933,5 +1973,5 @@
 
 	/*Add input to the element: */
-	this->inputs->AddInput(new PentaVertexInput(enum_type,values));
+	this->inputs->AddInput(new PentaP1Input(enum_type,values));
 	
 	/*Free ressources:*/
@@ -1966,5 +2006,5 @@
 	for(;;){
 		/*Add input to the element: */
-		penta->inputs->AddInput(new PentaVertexInput(enum_type,values));
+		penta->inputs->AddInput(new PentaP1Input(enum_type,values));
 
 		/*Stop if we have reached the surface*/
@@ -2000,5 +2040,5 @@
 
 			/*update input*/
-			this->inputs->AddInput(new PentaVertexInput(name,values));
+			this->inputs->AddInput(new PentaP1Input(name,values));
 			return;
 
@@ -2043,8 +2083,14 @@
 				name==VyEnum ||
 				name==VzEnum ||
+				name==VxMeshEnum ||
+				name==VyMeshEnum ||
+				name==VzMeshEnum ||
 				name==InversionVxObsEnum ||
 				name==InversionVyObsEnum ||
 				name==InversionVzObsEnum ||
 				name==TemperatureEnum ||
+				name==EnthalpyEnum ||
+				name==EnthalpyPicardEnum ||
+				name==WaterfractionEnum||
 				name==FrictionCoefficientEnum ||
 				name==GradientEnum ||
@@ -2153,5 +2199,5 @@
 			resultstimes[i]=elementresult->GetTime();
 			resultssteps[i]=elementresult->GetStep();
-			if(elementresult->ObjectEnum()==PentaVertexElementResultEnum){
+			if(elementresult->ObjectEnum()==PentaP1ElementResultEnum){
 				resultssizes[i]=P1Enum;
 			}
@@ -2237,10 +2283,10 @@
 	if(!this->IsFloating() && elementonshelf==true){
 		for(i=0;i<NUMVERTICES;i++)melting[i]=gl_melting_rate/yts;
-		this->inputs->AddInput(new PentaVertexInput(BasalforcingsMeltingRateEnum,&melting[0]));
+		this->inputs->AddInput(new PentaP1Input(BasalforcingsMeltingRateEnum,&melting[0]));
 	} 
 
 	/*Update inputs*/
-	this->inputs->AddInput(new PentaVertexInput(SurfaceEnum,&s[0]));
-	this->inputs->AddInput(new PentaVertexInput(BedEnum,&b[0]));
+	this->inputs->AddInput(new PentaP1Input(SurfaceEnum,&s[0]));
+	this->inputs->AddInput(new PentaP1Input(BedEnum,&b[0]));
    this->inputs->AddInput(new BoolInput(MaskElementonfloatingiceEnum,elementonshelf));
 
@@ -2330,4 +2376,10 @@
 	*pnumvertices=NUMVERTICES;
 	*pnumnodes=numnodes;
+}
+/*}}}*/
+/*FUNCTION Penta::PositiveDegreeDay{{{1*/
+void  Penta::PositiveDegreeDay(){
+
+	_error_("Not implemented yet");
 }
 /*}}}*/
@@ -2764,26 +2816,26 @@
 			if(!iomodel->Data(VxEnum)){
 				for(i=0;i<6;i++)nodeinputs[i]=0;
-				this->inputs->AddInput(new PentaVertexInput(VxEnum,nodeinputs));
-				if(dakota_analysis) this->inputs->AddInput(new PentaVertexInput(QmuVxEnum,nodeinputs));
+				this->inputs->AddInput(new PentaP1Input(VxEnum,nodeinputs));
+				if(dakota_analysis) this->inputs->AddInput(new PentaP1Input(QmuVxEnum,nodeinputs));
 			}
 			if(!iomodel->Data(VyEnum)){
 				for(i=0;i<6;i++)nodeinputs[i]=0;
-				this->inputs->AddInput(new PentaVertexInput(VyEnum,nodeinputs));
-				if(dakota_analysis) this->inputs->AddInput(new PentaVertexInput(QmuVyEnum,nodeinputs));
+				this->inputs->AddInput(new PentaP1Input(VyEnum,nodeinputs));
+				if(dakota_analysis) this->inputs->AddInput(new PentaP1Input(QmuVyEnum,nodeinputs));
 			}
 			if(!iomodel->Data(VzEnum)){
 				for(i=0;i<6;i++)nodeinputs[i]=0;
-				this->inputs->AddInput(new PentaVertexInput(VzEnum,nodeinputs));
-				if(dakota_analysis) this->inputs->AddInput(new PentaVertexInput(QmuVzEnum,nodeinputs));
+				this->inputs->AddInput(new PentaP1Input(VzEnum,nodeinputs));
+				if(dakota_analysis) this->inputs->AddInput(new PentaP1Input(QmuVzEnum,nodeinputs));
 			}
 			if(!iomodel->Data(PressureEnum)){
 				for(i=0;i<6;i++)nodeinputs[i]=0;
 				if(dakota_analysis){
-					this->inputs->AddInput(new PentaVertexInput(PressureEnum,nodeinputs));
-					this->inputs->AddInput(new PentaVertexInput(QmuPressureEnum,nodeinputs));
+					this->inputs->AddInput(new PentaP1Input(PressureEnum,nodeinputs));
+					this->inputs->AddInput(new PentaP1Input(QmuPressureEnum,nodeinputs));
 				}
 				if(isstokes){
-					this->inputs->AddInput(new PentaVertexInput(PressureEnum,nodeinputs));
-					this->inputs->AddInput(new PentaVertexInput(PressurePicardEnum,nodeinputs));
+					this->inputs->AddInput(new PentaP1Input(PressureEnum,nodeinputs));
+					this->inputs->AddInput(new PentaP1Input(PressurePicardEnum,nodeinputs));
 				}
 			}
@@ -2792,12 +2844,12 @@
 				if(iomodel->Data(VzEnum) && iomodel->Data(FlowequationBorderstokesEnum)){
 					for(i=0;i<6;i++) nodeinputs[i]=iomodel->Data(VzEnum)[penta_vertex_ids[i]-1]/yts*iomodel->Data(FlowequationBorderstokesEnum)[penta_vertex_ids[i]-1];
-					this->inputs->AddInput(new PentaVertexInput(VzStokesEnum,nodeinputs));
+					this->inputs->AddInput(new PentaP1Input(VzStokesEnum,nodeinputs));
 					for(i=0;i<6;i++) nodeinputs[i]=iomodel->Data(VzEnum)[penta_vertex_ids[i]-1]/yts*(1-iomodel->Data(FlowequationBorderstokesEnum)[penta_vertex_ids[i]-1]);
-					this->inputs->AddInput(new PentaVertexInput(VzPattynEnum,nodeinputs));
+					this->inputs->AddInput(new PentaP1Input(VzPattynEnum,nodeinputs));
 				}
 				else{
 					for(i=0;i<6;i++)nodeinputs[i]=0;
-					this->inputs->AddInput(new PentaVertexInput(VzStokesEnum,nodeinputs));
-					this->inputs->AddInput(new PentaVertexInput(VzPattynEnum,nodeinputs));
+					this->inputs->AddInput(new PentaP1Input(VzStokesEnum,nodeinputs));
+					this->inputs->AddInput(new PentaP1Input(VzPattynEnum,nodeinputs));
 				}
 			}
@@ -2806,12 +2858,12 @@
 				if(iomodel->Data(VzEnum) && iomodel->Data(FlowequationBorderstokesEnum)){
 					for(i=0;i<6;i++) nodeinputs[i]=iomodel->Data(VzEnum)[penta_vertex_ids[i]-1]/yts*iomodel->Data(FlowequationBorderstokesEnum)[penta_vertex_ids[i]-1];
-					this->inputs->AddInput(new PentaVertexInput(VzStokesEnum,nodeinputs));
+					this->inputs->AddInput(new PentaP1Input(VzStokesEnum,nodeinputs));
 					for(i=0;i<6;i++) nodeinputs[i]=iomodel->Data(VzEnum)[penta_vertex_ids[i]-1]/yts*(1-iomodel->Data(FlowequationBorderstokesEnum)[penta_vertex_ids[i]-1]);
-					this->inputs->AddInput(new PentaVertexInput(VzMacAyealEnum,nodeinputs));
+					this->inputs->AddInput(new PentaP1Input(VzMacAyealEnum,nodeinputs));
 				}
 				else{
 					for(i=0;i<6;i++)nodeinputs[i]=0;
-					this->inputs->AddInput(new PentaVertexInput(VzStokesEnum,nodeinputs));
-					this->inputs->AddInput(new PentaVertexInput(VzMacAyealEnum,nodeinputs));
+					this->inputs->AddInput(new PentaP1Input(VzStokesEnum,nodeinputs));
+					this->inputs->AddInput(new PentaP1Input(VzMacAyealEnum,nodeinputs));
 				}
 			}
@@ -2821,7 +2873,7 @@
 			/*Initialize mesh velocity*/
 			for(i=0;i<6;i++)nodeinputs[i]=0;
-			this->inputs->AddInput(new PentaVertexInput(VxMeshEnum,nodeinputs));
-			this->inputs->AddInput(new PentaVertexInput(VyMeshEnum,nodeinputs));
-			this->inputs->AddInput(new PentaVertexInput(VzMeshEnum,nodeinputs));
+			this->inputs->AddInput(new PentaP1Input(VxMeshEnum,nodeinputs));
+			this->inputs->AddInput(new PentaP1Input(VyMeshEnum,nodeinputs));
+			this->inputs->AddInput(new PentaP1Input(VzMeshEnum,nodeinputs));
 			break;
 
@@ -2829,8 +2881,8 @@
 			/*Initialize mesh velocity*/
 			for(i=0;i<6;i++)nodeinputs[i]=0;
-			this->inputs->AddInput(new PentaVertexInput(VxMeshEnum,nodeinputs));
-			this->inputs->AddInput(new PentaVertexInput(VyMeshEnum,nodeinputs));
-			this->inputs->AddInput(new PentaVertexInput(VzMeshEnum,nodeinputs));
-			if (iomodel->Data(TemperatureEnum) && iomodel->Data(WaterfractionEnum)) {
+			this->inputs->AddInput(new PentaP1Input(VxMeshEnum,nodeinputs));
+			this->inputs->AddInput(new PentaP1Input(VyMeshEnum,nodeinputs));
+			this->inputs->AddInput(new PentaP1Input(VzMeshEnum,nodeinputs));
+			if (iomodel->Data(TemperatureEnum) && iomodel->Data(WaterfractionEnum) && iomodel->Data(PressureEnum)) {
 				for(i=0;i<6;i++){
 					if(iomodel->Data(TemperatureEnum)[penta_vertex_ids[i]-1] < meltingpoint-beta*iomodel->Data(PressureEnum)[penta_vertex_ids[i]-1]){
@@ -2841,5 +2893,5 @@
 						+latentheat*iomodel->Data(WaterfractionEnum)[penta_vertex_ids[i]-1];
 				}
-				this->inputs->AddInput(new PentaVertexInput(EnthalpyEnum,nodeinputs));
+				this->inputs->AddInput(new PentaP1Input(EnthalpyEnum,nodeinputs));
 			}
 			else _error_("temperature and waterfraction required for the enthalpy solution");
@@ -2914,5 +2966,5 @@
 
 	/*Create PentaVertex input, which will hold the basal friction:*/
-	this->inputs->AddInput(new PentaVertexInput(ViscousHeatingEnum,&viscousheating[0]));
+	this->inputs->AddInput(new PentaP1Input(ViscousHeatingEnum,&viscousheating[0]));
 
 	/*Clean up and return*/
@@ -2920,4 +2972,9 @@
 }
 /*}}}*/
+/*FUNCTION Penta::SmearFunction {{{1*/
+void  Penta::SmearFunction(Vec smearedvector,double (*WeightFunction)(double distance,double radius),double radius){
+	_error_("not implemented yet");
+}
+/*}}}1*/
 
 #ifdef _HAVE_RESPONSES_
@@ -3198,4 +3255,5 @@
 	int        i,j,ig,found=0;
 	double     Jdet,u,v,w,um,vm,wm;
+	double     h,hx,hy,hz,vx,vy,vz,vel;
 	double     gravity,rho_ice,rho_water;
 	double     epsvel=2.220446049250313e-16;
@@ -3205,9 +3263,6 @@
 	double     tau_parameter,diameter;
 	double     xyz_list[NUMVERTICES][3];
-	double     B[3][numdof];
-	double     Bprime[3][numdof];
 	double     B_conduct[3][numdof];
 	double     B_advec[3][numdof];
-	double     B_stab[2][numdof];
 	double     Bprime_advec[3][numdof];
 	double     L[numdof];
@@ -3216,5 +3271,5 @@
 	double     D_scalar_trans,D_scalar_stab;
 	double     D[3][3];
-	double     K[2][2]={0.0};
+	double     K[3][3]={0.0};
 	Tria*      tria=NULL;
 	GaussPenta *gauss=NULL;
@@ -3234,5 +3289,5 @@
 	this->parameters->FindParam(&stabilization,ThermalStabilizationEnum);
 	Input* pressure_input=inputs->GetInput(PressureEnum);      _assert_(pressure_input);
-	Input* enthalpy_input=inputs->GetInput(EnthalpyEnum);      _assert_(enthalpy_input);
+	Input* enthalpy_input=inputs->GetInput(EnthalpyPicardEnum);_assert_(enthalpy_input); //for this iteration of the step
 	Input* vx_input=inputs->GetInput(VxEnum);                  _assert_(vx_input);
 	Input* vy_input=inputs->GetInput(VyEnum);                  _assert_(vy_input);
@@ -3253,5 +3308,4 @@
 		/*Conduction: */  
 		/*Need to change that depending on enthalpy value -> cold or temperate ice: */  
-
 		GetBConduct(&B_conduct[0][0],&xyz_list[0][0],gauss); 
 
@@ -3272,21 +3326,17 @@
 
 		/*Advection: */
-
 		GetBAdvec(&B_advec[0][0],&xyz_list[0][0],gauss); 
 		GetBprimeAdvec(&Bprime_advec[0][0],&xyz_list[0][0],gauss); 
 
-		vx_input->GetInputValue(&u, gauss);
-		vy_input->GetInputValue(&v, gauss);
-		vz_input->GetInputValue(&w, gauss);
-		vxm_input->GetInputValue(&um,gauss);
-		vym_input->GetInputValue(&vm,gauss);
-		vzm_input->GetInputValue(&wm,gauss);
+		vx_input->GetInputValue(&u, gauss); vxm_input->GetInputValue(&um,gauss); vx=u-um; 
+		vy_input->GetInputValue(&v, gauss); vym_input->GetInputValue(&vm,gauss); vy=v-vm; 
+		vz_input->GetInputValue(&w, gauss); vzm_input->GetInputValue(&wm,gauss); vz=w-wm;
 
 		D_scalar_advec=gauss->weight*Jdet;
 		if(dt) D_scalar_advec=D_scalar_advec*dt;
 
-		D[0][0]=D_scalar_advec*(u-um);D[0][1]=0;                    D[0][2]=0;
-		D[1][0]=0;                    D[1][1]=D_scalar_advec*(v-vm);D[1][2]=0;
-		D[2][0]=0;                    D[2][1]=0;                    D[2][2]=D_scalar_advec*(w-wm);
+		D[0][0]=D_scalar_advec*vx;D[0][1]=0;                D[0][2]=0;
+		D[1][0]=0;                D[1][1]=D_scalar_advec*vy;D[1][2]=0;
+		D[2][0]=0;                D[2][1]=0;                D[2][2]=D_scalar_advec*vz;
 
 		TripleMultiply(&B_advec[0][0],3,numdof,1,
@@ -3296,5 +3346,4 @@
 
 		/*Transient: */
-
 		if(dt){
 			GetNodalFunctionsP1(&L[0], gauss);
@@ -3309,25 +3358,26 @@
 
 		/*Artifficial diffusivity*/
-
 		if(stabilization==1){
 			/*Build K: */
-			D_scalar_stab=gauss->weight*Jdet/(pow(u-um,2)+pow(v-vm,2)+epsvel);
+			GetElementSizes(&hx,&hy,&hz);
+			vel=sqrt(pow(vx,2.)+pow(vy,2.)+pow(vz,2.))+1.e-14;
+			h=sqrt( pow(hx*vx/vel,2.) + pow(hy*vy/vel,2.) + pow(hz*vz/vel,2.));
+			K[0][0]=h/(2*vel)*vx*vx;  K[0][1]=h/(2*vel)*vx*vy; K[0][2]=h/(2*vel)*vx*vz;
+			K[1][0]=h/(2*vel)*vy*vx;  K[1][1]=h/(2*vel)*vy*vy; K[1][2]=h/(2*vel)*vy*vz;
+			K[2][0]=h/(2*vel)*vz*vx;  K[2][1]=h/(2*vel)*vz*vy; K[2][2]=h/(2*vel)*vz*vz;
+			D_scalar_stab=gauss->weight*Jdet;
 			if(dt) D_scalar_stab=D_scalar_stab*dt;
-			K[0][0]=D_scalar_stab*pow(u,2);       K[0][1]=D_scalar_stab*fabs(u)*fabs(v);
-			K[1][0]=D_scalar_stab*fabs(u)*fabs(v);K[1][1]=D_scalar_stab*pow(v,2);
-			_error_("TO BE RECODED");
-
-			//GetBArtdiff(&B_stab[0][0],&xyz_list[0][0],gauss); 
-
-			TripleMultiply(&B_stab[0][0],2,numdof,1,
-						&K[0][0],2,2,0,
-						&B_stab[0][0],2,numdof,0,
+			for(i=0;i<3;i++) for(j=0;j<3;j++) K[i][j] = D_scalar_stab*K[i][j];
+
+			GetBprimeAdvec(&Bprime_advec[0][0],&xyz_list[0][0],gauss); 
+
+			TripleMultiply(&Bprime_advec[0][0],3,numdof,1,
+						&K[0][0],3,3,0,
+						&Bprime_advec[0][0],3,numdof,0,
 						&Ke->values[0],1);
 		}
 		else if(stabilization==2){
-
 			GetNodalFunctionsP1Derivatives(&dbasis[0][0],&xyz_list[0][0], gauss);
-
-			tau_parameter=GetStabilizationParameter(u-um,v-vm,w-wm,diameter,rho_ice,heatcapacity,thermalconductivity);
+			tau_parameter=GetStabilizationParameter(u-um,v-vm,w-wm,diameter,kappa);
 
 			for(i=0;i<numdof;i++){
@@ -3443,13 +3493,10 @@
 	double     Jdet,u,v,w,um,vm,wm,vel;
 	double     h,hx,hy,hz,vx,vy,vz;
-	double     gravity,rho_ice,rho_water;
+	double     gravity,rho_ice,rho_water,kappa;
 	double     heatcapacity,thermalconductivity,dt;
 	double     tau_parameter,diameter;
 	double     xyz_list[NUMVERTICES][3];
-	double     B[3][numdof];
-	double     Bprime[3][numdof];
 	double     B_conduct[3][numdof];
 	double     B_advec[3][numdof];
-	double     B_stab[2][numdof];
 	double     Bprime_advec[3][numdof];
 	double     L[numdof];
@@ -3472,4 +3519,5 @@
 	heatcapacity=matpar->GetHeatCapacity();
 	thermalconductivity=matpar->GetThermalConductivity();
+	kappa=thermalconductivity/(rho_ice*heatcapacity);
 	this->parameters->FindParam(&dt,TimesteppingTimeStepEnum);
 	this->parameters->FindParam(&stabilization,ThermalStabilizationEnum);
@@ -3494,5 +3542,5 @@
 		GetBConduct(&B_conduct[0][0],&xyz_list[0][0],gauss); 
 
-		D_scalar_conduct=gauss->weight*Jdet*(thermalconductivity/(rho_ice*heatcapacity));
+		D_scalar_conduct=gauss->weight*Jdet*kappa;
 		if(dt) D_scalar_conduct=D_scalar_conduct*dt;
 
@@ -3528,5 +3576,4 @@
 
 		/*Transient: */
-
 		if(dt){
 			GetNodalFunctionsP1(&L[0], gauss);
@@ -3541,5 +3588,4 @@
 
 		/*Artifficial diffusivity*/
-
 		if(stabilization==1){
 			/*Build K: */
@@ -3565,5 +3611,5 @@
 		else if(stabilization==2){
 			GetNodalFunctionsP1Derivatives(&dbasis[0][0],&xyz_list[0][0], gauss);
-			tau_parameter=GetStabilizationParameter(u-um,v-vm,w-wm,diameter,rho_ice,heatcapacity,thermalconductivity);
+			tau_parameter=GetStabilizationParameter(u-um,v-vm,w-wm,diameter,kappa);
 
 			for(i=0;i<numdof;i++){
@@ -3670,5 +3716,268 @@
 	double Jdet,phi,dt;
 	double rho_ice,heatcapacity;
-	double thermalconductivity;
+	double thermalconductivity,kappa;
+	double viscosity,pressure;
+	double enthalpy,enthalpypicard;
+	double tau_parameter,diameter;
+	double u,v,w;
+	double scalar_def,scalar_transient;
+	double temperature_list[NUMVERTICES];
+	double xyz_list[NUMVERTICES][3];
+	double L[numdof];
+	double dbasis[3][6];
+	double epsilon[6];
+	GaussPenta *gauss=NULL;
+
+	/*Initialize Element vector*/
+	ElementVector* pe=new ElementVector(nodes,NUMVERTICES,this->parameters);
+
+	/*Retrieve all inputs and parameters*/
+	GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES);
+	rho_ice=matpar->GetRhoIce();
+	heatcapacity=matpar->GetHeatCapacity();
+	thermalconductivity=matpar->GetThermalConductivity();
+	this->parameters->FindParam(&dt,TimesteppingTimeStepEnum);
+	this->parameters->FindParam(&stabilization,ThermalStabilizationEnum);
+	Input* vx_input=inputs->GetInput(VxEnum);                                  _assert_(vx_input);
+	Input* vy_input=inputs->GetInput(VyEnum);                                  _assert_(vy_input);
+	Input* vz_input=inputs->GetInput(VzEnum);                                  _assert_(vz_input);
+	Input* pressure_input=inputs->GetInput(PressureEnum);                      _assert_(pressure_input);
+	Input* enthalpy_input=NULL; 
+	Input* enthalpypicard_input=NULL; 
+	if(dt){
+		enthalpy_input=inputs->GetInput(EnthalpyEnum); _assert_(enthalpy_input);
+	}
+	if (stabilization==2){
+		diameter=MinEdgeLength(xyz_list);
+		enthalpypicard_input=inputs->GetInput(EnthalpyPicardEnum); _assert_(enthalpypicard_input);
+	}
+
+	/* Start  looping on the number of gaussian points: */
+	gauss=new GaussPenta(2,3);
+	for (ig=gauss->begin();ig<gauss->end();ig++){
+
+		gauss->GaussPoint(ig);
+
+		GetJacobianDeterminant(&Jdet, &xyz_list[0][0],gauss);
+		GetNodalFunctionsP1(&L[0], gauss);
+
+		this->GetStrainRate3d(&epsilon[0],&xyz_list[0][0],gauss,vx_input,vy_input,vz_input);
+		matice->GetViscosity3dStokes(&viscosity,&epsilon[0]);
+		GetPhi(&phi, &epsilon[0], viscosity);
+
+		scalar_def=phi/rho_ice*Jdet*gauss->weight;
+		if(dt) scalar_def=scalar_def*dt;
+
+		for(i=0;i<NUMVERTICES;i++)  pe->values[i]+=scalar_def*L[i];
+
+		/* Build transient now */
+		if(dt){
+			enthalpy_input->GetInputValue(&enthalpy, gauss);
+			scalar_transient=enthalpy*Jdet*gauss->weight;
+			for(i=0;i<NUMVERTICES;i++)  pe->values[i]+=scalar_transient*L[i];
+		}
+
+		if(stabilization==2){
+			GetNodalFunctionsP1Derivatives(&dbasis[0][0],&xyz_list[0][0], gauss);
+
+			vx_input->GetInputValue(&u, gauss);
+			vy_input->GetInputValue(&v, gauss);
+			vz_input->GetInputValue(&w, gauss);
+			pressure_input->GetInputValue(&pressure, gauss);
+			enthalpypicard_input->GetInputValue(&enthalpypicard, gauss);
+			kappa=matpar->GetEnthalpyDiffusionParameter(enthalpy,pressure);
+			tau_parameter=GetStabilizationParameter(u,v,w,diameter,kappa);
+
+			for(i=0;i<NUMVERTICES;i++)  pe->values[i]+=tau_parameter*scalar_def*(u*dbasis[0][i]+v*dbasis[1][i]+w*dbasis[2][i]);
+			if(dt){
+				for(i=0;i<NUMVERTICES;i++)  pe->values[i]+=tau_parameter*scalar_transient*(u*dbasis[0][i]+v*dbasis[1][i]+w*dbasis[2][i]);
+			}
+		}
+	}
+
+	/*Clean up and return*/
+	delete gauss;
+	return pe;
+}
+/*}}}*/
+/*FUNCTION Penta::CreatePVectorEnthalpyShelf {{{1*/
+ElementVector* Penta::CreatePVectorEnthalpyShelf(void){
+
+	/*Constants*/
+	const int  numdof=NUMVERTICES*NDOF1;
+
+	/*Intermediaries */
+	int        i,j,ig;
+	double     Jdet2d;
+	double     heatcapacity,h_pmp;
+	double     mixed_layer_capacity,thermal_exchange_velocity;
+	double     rho_ice,rho_water,pressure,dt,scalar_ocean;
+	double     xyz_list[NUMVERTICES][3];
+	double     xyz_list_tria[NUMVERTICES2D][3];
+	double     basis[NUMVERTICES];
+	GaussPenta* gauss=NULL;
+
+	/* Ice/ocean heat exchange flux on ice shelf base */
+	if (!IsOnBed() || !IsFloating()) return NULL;
+
+	/*Initialize Element vector*/
+	ElementVector* pe=new ElementVector(nodes,NUMVERTICES,this->parameters);
+
+	/*Retrieve all inputs and parameters*/
+	GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES);
+	for(i=0;i<NUMVERTICES2D;i++) for(j=0;j<3;j++) xyz_list_tria[i][j]=xyz_list[i][j];
+	mixed_layer_capacity=matpar->GetMixedLayerCapacity();
+	thermal_exchange_velocity=matpar->GetThermalExchangeVelocity();
+	rho_water=matpar->GetRhoWater();
+	rho_ice=matpar->GetRhoIce();
+	heatcapacity=matpar->GetHeatCapacity();
+	this->parameters->FindParam(&dt,TimesteppingTimeStepEnum);
+	Input* pressure_input=inputs->GetInput(PressureEnum); _assert_(pressure_input);
+
+	/* Start looping on the number of gauss 2d (nodes on the bedrock) */
+	gauss=new GaussPenta(0,1,2,2);
+	for(ig=gauss->begin();ig<gauss->end();ig++){
+
+		gauss->GaussPoint(ig);
+
+		GetTriaJacobianDeterminant(&Jdet2d, &xyz_list_tria[0][0], gauss);
+		GetNodalFunctionsP1(&basis[0], gauss);
+
+		pressure_input->GetInputValue(&pressure,gauss);
+		h_pmp=matpar->PureIceEnthalpy(pressure);
+
+		scalar_ocean=gauss->weight*Jdet2d*rho_water*mixed_layer_capacity*thermal_exchange_velocity*(h_pmp)/(rho_ice*heatcapacity);
+		if(dt) scalar_ocean=dt*scalar_ocean;
+
+		for(i=0;i<numdof;i++) pe->values[i]+=scalar_ocean*basis[i];
+	}
+
+	/*Clean up and return*/
+	delete gauss;
+	return pe;
+}
+/*}}}*/
+/*FUNCTION Penta::CreatePVectorEnthalpySheet {{{1*/
+ElementVector* Penta::CreatePVectorEnthalpySheet(void){
+
+	/*Constants*/
+	const int  numdof=NUMVERTICES*NDOF1;
+
+	/*Intermediaries */
+	int        i,j,ig;
+	int        analysis_type;
+	double     xyz_list[NUMVERTICES][3];
+	double     xyz_list_tria[NUMVERTICES2D][3]={0.0};
+	double     Jdet2d,dt;
+	double     rho_ice,heatcapacity,geothermalflux_value;
+	double     basalfriction,alpha2,vx,vy;
+	double     scalar,enthalpy,enthalpyup;
+	double     pressure,pressureup;
+	double     basis[NUMVERTICES];
+	Friction*  friction=NULL;
+	GaussPenta* gauss=NULL;
+	GaussPenta* gaussup=NULL;
+
+	/* Geothermal flux on ice sheet base and basal friction */
+	if (!IsOnBed() || IsFloating()) return NULL;
+
+	/*Initialize Element vector*/
+	ElementVector* pe=new ElementVector(nodes,NUMVERTICES,this->parameters);
+
+	/*Retrieve all inputs and parameters*/
+	GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES);
+	for(i=0;i<NUMVERTICES2D;i++) for(j=0;j<2;j++) xyz_list_tria[i][j]=xyz_list[i][j];
+	parameters->FindParam(&analysis_type,AnalysisTypeEnum);
+	rho_ice=matpar->GetRhoIce();
+	heatcapacity=matpar->GetHeatCapacity();
+	this->parameters->FindParam(&dt,TimesteppingTimeStepEnum);
+	Input* vx_input=inputs->GetInput(VxEnum);                         _assert_(vx_input);
+	Input* vy_input=inputs->GetInput(VyEnum);                         _assert_(vy_input);
+	Input* vz_input=inputs->GetInput(VzEnum);                         _assert_(vz_input);
+	Input* enthalpy_input=inputs->GetInput(EnthalpyEnum);             _assert_(enthalpy_input);
+	Input* pressure_input=inputs->GetInput(PressureEnum);             _assert_(pressure_input);
+	Input* geothermalflux_input=inputs->GetInput(BasalforcingsGeothermalfluxEnum); _assert_(geothermalflux_input);
+
+	/*Build frictoin element, needed later: */
+	friction=new Friction("3d",inputs,matpar,analysis_type);
+
+	/* Start looping on the number of gauss 2d (nodes on the bedrock) */
+	gauss=new GaussPenta(0,1,2,2);
+	gaussup=new GaussPenta(3,4,5,2);
+	for(ig=gauss->begin();ig<gauss->end();ig++){
+
+		gauss->GaussPoint(ig);
+		gaussup->GaussPoint(ig);
+
+		GetTriaJacobianDeterminant(&Jdet2d, &xyz_list_tria[0][0], gauss);
+		GetNodalFunctionsP1(&basis[0], gauss);
+
+		enthalpy_input->GetInputValue(&enthalpy,gauss);
+		pressure_input->GetInputValue(&pressure,gauss);
+//		if(enthalpy>matpar->PureIceEnthalpy(pressure)){
+//			enthalpy_input->GetInputValue(&enthalpyup,gaussup);
+//			pressure_input->GetInputValue(&pressureup,gaussup);
+//			if(enthalpyup>matpar->PureIceEnthalpy(pressureup)){
+//				//do nothing, don't add heatflux
+//			}
+//			else{
+//				//need to change spcenthalpy according to Aschwanden 
+//				//NEED TO UPDATE
+//			}
+//		}
+//		else{
+			geothermalflux_input->GetInputValue(&geothermalflux_value,gauss);
+			friction->GetAlpha2(&alpha2,gauss,VxEnum,VyEnum,VzEnum);
+			vx_input->GetInputValue(&vx,gauss);
+			vy_input->GetInputValue(&vy,gauss);
+			basalfriction=alpha2*(pow(vx,2.0)+pow(vy,2.0));
+
+			scalar=gauss->weight*Jdet2d*(basalfriction+geothermalflux_value)/(rho_ice);
+			if(dt) scalar=dt*scalar;
+
+			for(i=0;i<numdof;i++) pe->values[i]+=scalar*basis[i];
+//		}
+	}
+
+	/*Clean up and return*/
+	delete gauss;
+	delete gaussup;
+	delete friction;
+	return pe;
+}
+/*}}}*/
+/*FUNCTION Penta::CreatePVectorMelting {{{1*/
+ElementVector* Penta::CreatePVectorMelting(void){
+	return NULL;
+}
+/*}}}*/
+/*FUNCTION Penta::CreatePVectorThermal {{{1*/
+ElementVector* Penta::CreatePVectorThermal(void){
+
+	/*compute all load vectors for this element*/
+	ElementVector* pe1=CreatePVectorThermalVolume();
+	ElementVector* pe2=CreatePVectorThermalSheet();
+	ElementVector* pe3=CreatePVectorThermalShelf();
+	ElementVector* pe =new ElementVector(pe1,pe2,pe3);
+
+	/*clean-up and return*/
+	delete pe1;
+	delete pe2;
+	delete pe3;
+	return pe;
+}
+/*}}}*/
+/*FUNCTION Penta::CreatePVectorThermalVolume {{{1*/
+ElementVector* Penta::CreatePVectorThermalVolume(void){
+
+	/*Constants*/
+	const int  numdof=NUMVERTICES*NDOF1;
+
+	/*Intermediaries*/
+	int    i,j,ig,found=0;
+	int    friction_type,stabilization;
+	double Jdet,phi,dt;
+	double rho_ice,heatcapacity;
+	double thermalconductivity,kappa;
 	double viscosity,temperature;
 	double tau_parameter,diameter;
@@ -3690,4 +3999,5 @@
 	heatcapacity=matpar->GetHeatCapacity();
 	thermalconductivity=matpar->GetThermalConductivity();
+	kappa=thermalconductivity/(rho_ice*heatcapacity);
 	this->parameters->FindParam(&dt,TimesteppingTimeStepEnum);
 	this->parameters->FindParam(&stabilization,ThermalStabilizationEnum);
@@ -3712,5 +4022,5 @@
 		GetPhi(&phi, &epsilon[0], viscosity);
 
-		scalar_def=phi/(rho_ice)*Jdet*gauss->weight;
+		scalar_def=phi/(rho_ice*heatcapacity)*Jdet*gauss->weight;
 		if(dt) scalar_def=scalar_def*dt;
 
@@ -3731,5 +4041,5 @@
 			vz_input->GetInputValue(&w, gauss);
 
-			tau_parameter=GetStabilizationParameter(u,v,w,diameter,rho_ice,heatcapacity,thermalconductivity);
+			tau_parameter=GetStabilizationParameter(u,v,w,diameter,kappa);
 
 			for(i=0;i<NUMVERTICES;i++)  pe->values[i]+=tau_parameter*scalar_def*(u*dbasis[0][i]+v*dbasis[1][i]+w*dbasis[2][i]);
@@ -3745,6 +4055,6 @@
 }
 /*}}}*/
-/*FUNCTION Penta::CreatePVectorEnthalpyShelf {{{1*/
-ElementVector* Penta::CreatePVectorEnthalpyShelf(void){
+/*FUNCTION Penta::CreatePVectorThermalShelf {{{1*/
+ElementVector* Penta::CreatePVectorThermalShelf(void){
 
 	/*Constants*/
@@ -3754,7 +4064,7 @@
 	int        i,j,ig;
 	double     Jdet2d;
-	double     heatcapacity,h_pmp;
 	double     mixed_layer_capacity,thermal_exchange_velocity;
 	double     rho_ice,rho_water,pressure,dt,scalar_ocean;
+	double     heatcapacity,t_pmp;
 	double     xyz_list[NUMVERTICES][3];
 	double     xyz_list_tria[NUMVERTICES2D][3];
@@ -3762,9 +4072,9 @@
 	GaussPenta* gauss=NULL;
 
+	/* Ice/ocean heat exchange flux on ice shelf base */
+	if (!IsOnBed() || !IsFloating()) return NULL;
+
 	/*Initialize Element vector*/
 	ElementVector* pe=new ElementVector(nodes,NUMVERTICES,this->parameters);
-
-	/* Ice/ocean heat exchange flux on ice shelf base */
-	if (!IsOnBed() || !IsFloating()) return NULL;
 
 	/*Retrieve all inputs and parameters*/
@@ -3789,7 +4099,7 @@
 
 		pressure_input->GetInputValue(&pressure,gauss);
-		h_pmp=matpar->PureIceEnthalpy(pressure);
-
-		scalar_ocean=gauss->weight*Jdet2d*rho_water*mixed_layer_capacity*thermal_exchange_velocity*(h_pmp)/(rho_ice*heatcapacity);
+		t_pmp=matpar->TMeltingPoint(pressure);
+
+		scalar_ocean=gauss->weight*Jdet2d*rho_water*mixed_layer_capacity*thermal_exchange_velocity*(t_pmp)/(heatcapacity*rho_ice);
 		if(dt) scalar_ocean=dt*scalar_ocean;
 
@@ -3802,6 +4112,6 @@
 }
 /*}}}*/
-/*FUNCTION Penta::CreatePVectorEnthalpySheet {{{1*/
-ElementVector* Penta::CreatePVectorEnthalpySheet(void){
+/*FUNCTION Penta::CreatePVectorThermalSheet {{{1*/
+ElementVector* Penta::CreatePVectorThermalSheet(void){
 
 	/*Constants*/
@@ -3816,6 +4126,6 @@
 	double     rho_ice,heatcapacity,geothermalflux_value;
 	double     basalfriction,alpha2,vx,vy;
+	double     basis[NUMVERTICES];
 	double     scalar;
-	double     basis[NUMVERTICES];
 	Friction*  friction=NULL;
 	GaussPenta* gauss=NULL;
@@ -3851,245 +4161,14 @@
 		GetNodalFunctionsP1(&basis[0], gauss);
 
-		geothermalflux_input->GetInputValue(&geothermalflux_value,gauss);
-		friction->GetAlpha2(&alpha2,gauss,VxEnum,VyEnum,VzEnum);
-		vx_input->GetInputValue(&vx,gauss);
-		vy_input->GetInputValue(&vy,gauss);
-		basalfriction=alpha2*(pow(vx,2.0)+pow(vy,2.0));
-		
-		scalar=gauss->weight*Jdet2d*(basalfriction+geothermalflux_value)/(rho_ice);
-		if(dt) scalar=dt*scalar;
-
-		for(i=0;i<numdof;i++) pe->values[i]+=scalar*basis[i];
-	}
-
-	/*Clean up and return*/
-	delete gauss;
-	delete friction;
-	return pe;
-}
-/*}}}*/
-/*FUNCTION Penta::CreatePVectorMelting {{{1*/
-ElementVector* Penta::CreatePVectorMelting(void){
-	return NULL;
-}
-/*}}}*/
-/*FUNCTION Penta::CreatePVectorThermal {{{1*/
-ElementVector* Penta::CreatePVectorThermal(void){
-
-	/*compute all load vectors for this element*/
-	ElementVector* pe1=CreatePVectorThermalVolume();
-	ElementVector* pe2=CreatePVectorThermalSheet();
-	ElementVector* pe3=CreatePVectorThermalShelf();
-	ElementVector* pe =new ElementVector(pe1,pe2,pe3);
-
-	/*clean-up and return*/
-	delete pe1;
-	delete pe2;
-	delete pe3;
-	return pe;
-}
-/*}}}*/
-/*FUNCTION Penta::CreatePVectorThermalVolume {{{1*/
-ElementVector* Penta::CreatePVectorThermalVolume(void){
-
-	/*Constants*/
-	const int  numdof=NUMVERTICES*NDOF1;
-
-	/*Intermediaries*/
-	int    i,j,ig,found=0;
-	int    friction_type,stabilization;
-	double Jdet,phi,dt;
-	double rho_ice,heatcapacity;
-	double thermalconductivity;
-	double viscosity,temperature;
-	double tau_parameter,diameter;
-	double u,v,w;
-	double scalar_def,scalar_transient;
-	double temperature_list[NUMVERTICES];
-	double xyz_list[NUMVERTICES][3];
-	double L[numdof];
-	double dbasis[3][6];
-	double epsilon[6];
-	GaussPenta *gauss=NULL;
-
-	/*Initialize Element vector*/
-	ElementVector* pe=new ElementVector(nodes,NUMVERTICES,this->parameters);
-
-	/*Retrieve all inputs and parameters*/
-	GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES);
-	rho_ice=matpar->GetRhoIce();
-	heatcapacity=matpar->GetHeatCapacity();
-	thermalconductivity=matpar->GetThermalConductivity();
-	this->parameters->FindParam(&dt,TimesteppingTimeStepEnum);
-	this->parameters->FindParam(&stabilization,ThermalStabilizationEnum);
-	Input* vx_input=inputs->GetInput(VxEnum); _assert_(vx_input);
-	Input* vy_input=inputs->GetInput(VyEnum); _assert_(vy_input);
-	Input* vz_input=inputs->GetInput(VzEnum); _assert_(vz_input);
-	Input* temperature_input=NULL;
-	if (dt) temperature_input=inputs->GetInput(TemperatureEnum); _assert_(inputs);
-	if (stabilization==2) diameter=MinEdgeLength(xyz_list);
-
-	/* Start  looping on the number of gaussian points: */
-	gauss=new GaussPenta(2,3);
-	for (ig=gauss->begin();ig<gauss->end();ig++){
-
-		gauss->GaussPoint(ig);
-
-		GetJacobianDeterminant(&Jdet, &xyz_list[0][0],gauss);
-		GetNodalFunctionsP1(&L[0], gauss);
-
-		this->GetStrainRate3d(&epsilon[0],&xyz_list[0][0],gauss,vx_input,vy_input,vz_input);
-		matice->GetViscosity3dStokes(&viscosity,&epsilon[0]);
-		GetPhi(&phi, &epsilon[0], viscosity);
-
-		scalar_def=phi/(rho_ice*heatcapacity)*Jdet*gauss->weight;
-		if(dt) scalar_def=scalar_def*dt;
-
-		for(i=0;i<NUMVERTICES;i++)  pe->values[i]+=scalar_def*L[i];
-
-		/* Build transient now */
-		if(dt){
-			temperature_input->GetInputValue(&temperature, gauss);
-			scalar_transient=temperature*Jdet*gauss->weight;
-			for(i=0;i<NUMVERTICES;i++)  pe->values[i]+=scalar_transient*L[i];
-		}
-
-		if(stabilization==2){
-			GetNodalFunctionsP1Derivatives(&dbasis[0][0],&xyz_list[0][0], gauss);
-
-			vx_input->GetInputValue(&u, gauss);
-			vy_input->GetInputValue(&v, gauss);
-			vz_input->GetInputValue(&w, gauss);
-
-			tau_parameter=GetStabilizationParameter(u,v,w,diameter,rho_ice,heatcapacity,thermalconductivity);
-
-			for(i=0;i<NUMVERTICES;i++)  pe->values[i]+=tau_parameter*scalar_def*(u*dbasis[0][i]+v*dbasis[1][i]+w*dbasis[2][i]);
-			if(dt){
-				for(i=0;i<NUMVERTICES;i++)  pe->values[i]+=tau_parameter*scalar_transient*(u*dbasis[0][i]+v*dbasis[1][i]+w*dbasis[2][i]);
-			}
-		}
-	}
-
-	/*Clean up and return*/
-	delete gauss;
-	return pe;
-}
-/*}}}*/
-/*FUNCTION Penta::CreatePVectorThermalShelf {{{1*/
-ElementVector* Penta::CreatePVectorThermalShelf(void){
-
-	/*Constants*/
-	const int  numdof=NUMVERTICES*NDOF1;
-
-	/*Intermediaries */
-	int        i,j,ig;
-	double     Jdet2d;
-	double     mixed_layer_capacity,thermal_exchange_velocity;
-	double     rho_ice,rho_water,pressure,dt,scalar_ocean;
-	double     heatcapacity,t_pmp;
-	double     xyz_list[NUMVERTICES][3];
-	double     xyz_list_tria[NUMVERTICES2D][3];
-	double     basis[NUMVERTICES];
-	GaussPenta* gauss=NULL;
-
-	/* Ice/ocean heat exchange flux on ice shelf base */
-	if (!IsOnBed() || !IsFloating()) return NULL;
-
-	/*Initialize Element vector*/
-	ElementVector* pe=new ElementVector(nodes,NUMVERTICES,this->parameters);
-
-	/*Retrieve all inputs and parameters*/
-	GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES);
-	for(i=0;i<NUMVERTICES2D;i++) for(j=0;j<3;j++) xyz_list_tria[i][j]=xyz_list[i][j];
-	mixed_layer_capacity=matpar->GetMixedLayerCapacity();
-	thermal_exchange_velocity=matpar->GetThermalExchangeVelocity();
-	rho_water=matpar->GetRhoWater();
-	rho_ice=matpar->GetRhoIce();
-	heatcapacity=matpar->GetHeatCapacity();
-	this->parameters->FindParam(&dt,TimesteppingTimeStepEnum);
-	Input* pressure_input=inputs->GetInput(PressureEnum); _assert_(pressure_input);
-
-	/* Start looping on the number of gauss 2d (nodes on the bedrock) */
-	gauss=new GaussPenta(0,1,2,2);
-	for(ig=gauss->begin();ig<gauss->end();ig++){
-
-		gauss->GaussPoint(ig);
-
-		GetTriaJacobianDeterminant(&Jdet2d, &xyz_list_tria[0][0], gauss);
-		GetNodalFunctionsP1(&basis[0], gauss);
-
-		pressure_input->GetInputValue(&pressure,gauss);
-		t_pmp=matpar->TMeltingPoint(pressure);
-
-		scalar_ocean=gauss->weight*Jdet2d*rho_water*mixed_layer_capacity*thermal_exchange_velocity*(t_pmp)/(heatcapacity*rho_ice);
-		if(dt) scalar_ocean=dt*scalar_ocean;
-
-		for(i=0;i<numdof;i++) pe->values[i]+=scalar_ocean*basis[i];
-	}
-
-	/*Clean up and return*/
-	delete gauss;
-	return pe;
-}
-/*}}}*/
-/*FUNCTION Penta::CreatePVectorThermalSheet {{{1*/
-ElementVector* Penta::CreatePVectorThermalSheet(void){
-
-	/*Constants*/
-	const int  numdof=NUMVERTICES*NDOF1;
-
-	/*Intermediaries */
-	int        i,j,ig;
-	int        analysis_type;
-	double     xyz_list[NUMVERTICES][3];
-	double     xyz_list_tria[NUMVERTICES2D][3]={0.0};
-	double     Jdet2d,dt;
-	double     rho_ice,heatcapacity,geothermalflux_value;
-	double     basalfriction,alpha2,vx,vy;
-	double     scalar;
-	double     basis[NUMVERTICES];
-	Friction*  friction=NULL;
-	GaussPenta* gauss=NULL;
-
-	/* Geothermal flux on ice sheet base and basal friction */
-	if (!IsOnBed() || IsFloating()) return NULL;
-
-	/*Initialize Element vector*/
-	ElementVector* pe=new ElementVector(nodes,NUMVERTICES,this->parameters);
-
-	/*Retrieve all inputs and parameters*/
-	GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES);
-	for(i=0;i<NUMVERTICES2D;i++) for(j=0;j<2;j++) xyz_list_tria[i][j]=xyz_list[i][j];
-	parameters->FindParam(&analysis_type,AnalysisTypeEnum);
-	rho_ice=matpar->GetRhoIce();
-	heatcapacity=matpar->GetHeatCapacity();
-	this->parameters->FindParam(&dt,TimesteppingTimeStepEnum);
-	Input* vx_input=inputs->GetInput(VxEnum);                         _assert_(vx_input);
-	Input* vy_input=inputs->GetInput(VyEnum);                         _assert_(vy_input);
-	Input* vz_input=inputs->GetInput(VzEnum);                         _assert_(vz_input);
-	Input* geothermalflux_input=inputs->GetInput(BasalforcingsGeothermalfluxEnum); _assert_(geothermalflux_input);
-
-	/*Build frictoin element, needed later: */
-	friction=new Friction("3d",inputs,matpar,analysis_type);
-
-	/* Start looping on the number of gauss 2d (nodes on the bedrock) */
-	gauss=new GaussPenta(0,1,2,2);
-	for(ig=gauss->begin();ig<gauss->end();ig++){
-
-		gauss->GaussPoint(ig);
-
-		GetTriaJacobianDeterminant(&Jdet2d, &xyz_list_tria[0][0], gauss);
-		GetNodalFunctionsP1(&basis[0], gauss);
-
-		geothermalflux_input->GetInputValue(&geothermalflux_value,gauss);
-		friction->GetAlpha2(&alpha2,gauss,VxEnum,VyEnum,VzEnum);
-		vx_input->GetInputValue(&vx,gauss);
-		vy_input->GetInputValue(&vy,gauss);
-		basalfriction=alpha2*(pow(vx,2.0)+pow(vy,2.0));
-		
-		scalar=gauss->weight*Jdet2d*(basalfriction+geothermalflux_value)/(heatcapacity*rho_ice);
-		if(dt) scalar=dt*scalar;
-
-		for(i=0;i<numdof;i++) pe->values[i]+=scalar*basis[i];
+			geothermalflux_input->GetInputValue(&geothermalflux_value,gauss);
+			friction->GetAlpha2(&alpha2,gauss,VxEnum,VyEnum,VzEnum);
+			vx_input->GetInputValue(&vx,gauss);
+			vy_input->GetInputValue(&vy,gauss);
+			basalfriction=alpha2*(pow(vx,2.0)+pow(vy,2.0));
+
+			scalar=gauss->weight*Jdet2d*(basalfriction+geothermalflux_value)/(heatcapacity*rho_ice);
+			if(dt) scalar=dt*scalar;
+
+			for(i=0;i<numdof;i++) pe->values[i]+=scalar*basis[i];
 	}
 
@@ -4198,5 +4277,5 @@
 	this->inputs->GetInputValue(&converged,ConvergedEnum);
 	if(converged){
-		this->inputs->AddInput(new PentaVertexInput(TemperatureEnum,values));
+		this->inputs->AddInput(new PentaP1Input(TemperatureEnum,values));
 
 		/*Update Rheology only if converged (we must make sure that the temperature is below melting point
@@ -4210,5 +4289,5 @@
 				B_average=Paterson((values[0]+values[1]+values[2]+values[3]+values[4]+values[5])/6.0);
 				for(i=0;i<numdof;i++) B[i]=B_average;
-				this->matice->inputs->AddInput(new PentaVertexInput(MaterialsRheologyBEnum,B));
+				this->matice->inputs->AddInput(new PentaP1Input(MaterialsRheologyBEnum,B));
 				break;
 			case ArrheniusEnum:
@@ -4218,5 +4297,5 @@
 							matice->GetN());
 				for(i=0;i<numdof;i++) B[i]=B_average;
-				this->matice->inputs->AddInput(new PentaVertexInput(MaterialsRheologyBEnum,B));
+				this->matice->inputs->AddInput(new PentaP1Input(MaterialsRheologyBEnum,B));
 				break;
 			default:
@@ -4226,5 +4305,5 @@
 	}
 	else{
-		this->inputs->AddInput(new PentaVertexInput(TemperaturePicardEnum,values));
+		this->inputs->AddInput(new PentaP1Input(TemperaturePicardEnum,values));
 	}
 
@@ -4238,5 +4317,5 @@
 	const int    numdof=NDOF1*NUMVERTICES;
 
-	bool   converged;
+	bool   converged=false;
 	int    i,rheology_law;
 	double xyz_list[NUMVERTICES][3];
@@ -4265,13 +4344,16 @@
 	Input* surface_input=inputs->GetInput(SurfaceEnum); _assert_(surface_input);
 	
-
-//	this->inputs->GetInputValue(&converged,ConvergedEnum);
-//	if(converged){
+	this->inputs->GetInputValue(&converged,ConvergedEnum);
+	if(converged){
 		/*Convert enthalpy into temperature and water fraction*/
-		for(i=0;i<numdof;i++) matpar->EnthalpyToThermal(&temperatures[i],&waterfraction[i],values[i],pressure[i]);
+		for(i=0;i<numdof;i++){
+			matpar->EnthalpyToThermal(&temperatures[i],&waterfraction[i],values[i],pressure[i]);
+			if(waterfraction[i]<0) _error_("Negative water fraction found in solution vector");
+			//if(waterfraction[i]>1) _error_("Water fraction >1 found in solution vector");
+		}
 			
-		this->inputs->AddInput(new PentaVertexInput(EnthalpyEnum,values));
-		this->inputs->AddInput(new PentaVertexInput(WaterfractionEnum,waterfraction));
-		this->inputs->AddInput(new PentaVertexInput(TemperatureEnum,temperatures));
+		this->inputs->AddInput(new PentaP1Input(EnthalpyEnum,values));
+		this->inputs->AddInput(new PentaP1Input(WaterfractionEnum,waterfraction));
+		this->inputs->AddInput(new PentaP1Input(TemperatureEnum,temperatures));
 
 		/*Update Rheology only if converged (we must make sure that the temperature is below melting point
@@ -4285,5 +4367,5 @@
 				B_average=Paterson((temperatures[0]+temperatures[1]+temperatures[2]+temperatures[3]+temperatures[4]+temperatures[5])/6.0);
 				for(i=0;i<numdof;i++) B[i]=B_average;
-				this->matice->inputs->AddInput(new PentaVertexInput(MaterialsRheologyBEnum,B));
+				this->matice->inputs->AddInput(new PentaP1Input(MaterialsRheologyBEnum,B));
 				break;
 			case ArrheniusEnum:
@@ -4293,5 +4375,5 @@
 							matice->GetN());
 				for(i=0;i<numdof;i++) B[i]=B_average;
-				this->matice->inputs->AddInput(new PentaVertexInput(MaterialsRheologyBEnum,B));
+				this->matice->inputs->AddInput(new PentaP1Input(MaterialsRheologyBEnum,B));
 				break;
 			default:
@@ -4299,8 +4381,8 @@
 
 		}
-//	}
-//	else{
-//		this->inputs->AddInput(new PentaVertexInput(EnthalpyPicardEnum,values));
-//	}
+	}
+	else{
+		this->inputs->AddInput(new PentaP1Input(EnthalpyPicardEnum,values));
+	}
 
 	/*Free ressources:*/
@@ -4312,5 +4394,5 @@
 #ifdef _HAVE_CONTROL_
 /*FUNCTION Penta::ControlInputGetGradient{{{1*/
-void Penta::ControlInputGetGradient(Vec gradient,int enum_type){
+void Penta::ControlInputGetGradient(Vec gradient,int enum_type,int control_index){
 
 	int doflist1[NUMVERTICES];
@@ -4327,5 +4409,5 @@
 	if (input->ObjectEnum()!=ControlInputEnum) _error_("Input %s is not a ControlInput",EnumToStringx(enum_type));
 
-	this->GetDofList1(&doflist1[0]);
+	GradientIndexing(&doflist1[0],control_index);
 	((ControlInput*)input)->GetGradient(gradient,&doflist1[0]);
 
@@ -4348,5 +4430,5 @@
 }/*}}}*/
 /*FUNCTION Penta::ControlInputSetGradient{{{1*/
-void Penta::ControlInputSetGradient(double* gradient,int enum_type){
+void Penta::ControlInputSetGradient(double* gradient,int enum_type,int control_index){
 
 	int    doflist1[NUMVERTICES];
@@ -4364,10 +4446,200 @@
 	if (input->ObjectEnum()!=ControlInputEnum) _error_("Input %s is not a ControlInput",EnumToStringx(enum_type));
 
-	this->GetDofList1(&doflist1[0]);
+	GradientIndexing(&doflist1[0],control_index);
 	for(int i=0;i<NUMVERTICES;i++) grad_list[i]=gradient[doflist1[i]];
-	grad_input=new PentaVertexInput(GradientEnum,grad_list);
+	grad_input=new PentaP1Input(GradientEnum,grad_list);
 	((ControlInput*)input)->SetGradient(grad_input);
 
 }/*}}}*/
+/*FUNCTION Penta::CreateKMatrixAdjointHoriz{{{1*/
+ElementMatrix* Penta::CreateKMatrixAdjointHoriz(void){
+
+	int approximation;
+	inputs->GetInputValue(&approximation,ApproximationEnum);
+
+	switch(approximation){
+		case MacAyealApproximationEnum:
+			return CreateKMatrixAdjointMacAyeal2d();
+		case PattynApproximationEnum:
+			return CreateKMatrixAdjointPattyn();
+		case StokesApproximationEnum:
+			return CreateKMatrixAdjointStokes();
+		case NoneApproximationEnum:
+			return NULL;
+		default:
+			_error_("Approximation %s not supported yet",EnumToStringx(approximation));
+	}
+}
+/*}}}*/
+/*FUNCTION Penta::CreateKMatrixAdjointMacAyeal2d{{{1*/
+ElementMatrix* Penta::CreateKMatrixAdjointMacAyeal2d(void){
+
+	/*Figure out if this penta is collapsed. If so, then bailout, except if it is at the 
+	  bedrock, in which case we spawn a tria element using the 3 first nodes, and use it to build 
+	  the stiffness matrix. */
+	if (!IsOnBed()) return NULL;
+
+	/*Depth Averaging B*/
+	this->InputDepthAverageAtBase(MaterialsRheologyBEnum,MaterialsRheologyBbarEnum,MaterialsEnum);
+
+	/*Call Tria function*/
+	Tria* tria=(Tria*)SpawnTria(0,1,2); //nodes 0, 1 and 2 make the new tria.
+	ElementMatrix* Ke=tria->CreateKMatrixAdjointMacAyeal();
+	delete tria->matice; delete tria;
+
+	/*Delete B averaged*/
+	this->matice->inputs->DeleteInput(MaterialsRheologyBbarEnum);
+
+	/*clean up and return*/
+	return Ke;
+}
+/*}}}*/
+/*FUNCTION Penta::CreateKMatrixAdjointPattyn{{{1*/
+ElementMatrix* Penta::CreateKMatrixAdjointPattyn(void){
+
+	/*Constants*/
+	const int    numdof=NDOF2*NUMVERTICES;
+
+	/*Intermediaries */
+	int        i,j,ig;
+	bool       incomplete_adjoint;
+	double     xyz_list[NUMVERTICES][3];
+	double     Jdet;
+	double     eps1dotdphii,eps1dotdphij;
+	double     eps2dotdphii,eps2dotdphij;
+	double     mu_prime;
+	double     epsilon[5]; /* epsilon=[exx,eyy,exy,exz,eyz];*/
+	double     eps1[3],eps2[3];
+	double     phi[NUMVERTICES];
+	double     dphi[3][NUMVERTICES];
+	GaussPenta *gauss=NULL;
+
+	/*Initialize Jacobian with regular Pattyn (first part of the Gateau derivative)*/
+	parameters->FindParam(&incomplete_adjoint,InversionIncompleteAdjointEnum);
+	ElementMatrix* Ke=CreateKMatrixDiagnosticPattyn();
+	if(incomplete_adjoint) return Ke;
+
+	/*Retrieve all inputs and parameters*/
+	GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES);
+	Input* vx_input=inputs->GetInput(VxEnum);       _assert_(vx_input);
+	Input* vy_input=inputs->GetInput(VyEnum);       _assert_(vy_input);
+
+	/* Start  looping on the number of gaussian points: */
+	gauss=new GaussPenta(5,5);
+	for (ig=gauss->begin();ig<gauss->end();ig++){
+
+		gauss->GaussPoint(ig);
+
+		GetJacobianDeterminant(&Jdet, &xyz_list[0][0],gauss);
+		GetNodalFunctionsP1Derivatives(&dphi[0][0],&xyz_list[0][0],gauss);
+
+		this->GetStrainRate3dPattyn(&epsilon[0],&xyz_list[0][0],gauss,vx_input,vy_input);
+		matice->GetViscosityDerivativeEpsSquare(&mu_prime,&epsilon[0]);
+		eps1[0]=2*epsilon[0]+epsilon[1];   eps2[0]=epsilon[2];
+		eps1[1]=epsilon[2];                eps2[1]=epsilon[0]+2*epsilon[1];
+		eps1[2]=epsilon[3];                eps2[2]=epsilon[4];
+
+		for(i=0;i<6;i++){
+			for(j=0;j<6;j++){
+				eps1dotdphii=eps1[0]*dphi[0][i]+eps1[1]*dphi[1][i]+eps1[2]*dphi[2][i];
+				eps1dotdphij=eps1[0]*dphi[0][j]+eps1[1]*dphi[1][j]+eps1[2]*dphi[2][j];
+				eps2dotdphii=eps2[0]*dphi[0][i]+eps2[1]*dphi[1][i]+eps2[2]*dphi[2][i];
+				eps2dotdphij=eps2[0]*dphi[0][j]+eps2[1]*dphi[1][j]+eps2[2]*dphi[2][j];
+
+				Ke->values[12*(2*i+0)+2*j+0]+=gauss->weight*Jdet*2*mu_prime*eps1dotdphij*eps1dotdphii;
+				Ke->values[12*(2*i+0)+2*j+1]+=gauss->weight*Jdet*2*mu_prime*eps2dotdphij*eps1dotdphii;
+				Ke->values[12*(2*i+1)+2*j+0]+=gauss->weight*Jdet*2*mu_prime*eps1dotdphij*eps2dotdphii;
+				Ke->values[12*(2*i+1)+2*j+1]+=gauss->weight*Jdet*2*mu_prime*eps2dotdphij*eps2dotdphii;
+			}
+		}
+	}
+
+	/*Transform Coordinate System*/
+	TransformStiffnessMatrixCoord(Ke,nodes,NUMVERTICES,XYEnum);
+
+	/*Clean up and return*/
+	delete gauss;
+	return Ke;
+}
+/*}}}*/
+/*FUNCTION Penta::CreateKMatrixAdjointStokes{{{1*/
+ElementMatrix* Penta::CreateKMatrixAdjointStokes(void){
+
+	/*Constants*/
+	const int    numdof=NDOF4*NUMVERTICES;
+
+	/*Intermediaries */
+	int        i,j,ig;
+	bool       incomplete_adjoint;
+	double     xyz_list[NUMVERTICES][3];
+	double     Jdet;
+	double     eps1dotdphii,eps1dotdphij;
+	double     eps2dotdphii,eps2dotdphij;
+	double     eps3dotdphii,eps3dotdphij;
+	double     mu_prime;
+	double     epsilon[5]; /* epsilon=[exx,eyy,exy,exz,eyz];*/
+	double     eps1[3],eps2[3],eps3[3];
+	double     phi[NUMVERTICES];
+	double     dphi[3][NUMVERTICES];
+	GaussPenta *gauss=NULL;
+
+	/*Initialize Jacobian with regular Stokes (first part of the Gateau derivative)*/
+	parameters->FindParam(&incomplete_adjoint,InversionIncompleteAdjointEnum);
+	ElementMatrix* Ke=CreateKMatrixDiagnosticStokes();
+	if(incomplete_adjoint) return Ke;
+
+	/*Retrieve all inputs and parameters*/
+	GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES);
+	Input* vx_input=inputs->GetInput(VxEnum);       _assert_(vx_input);
+	Input* vy_input=inputs->GetInput(VyEnum);       _assert_(vy_input);
+	Input* vz_input=inputs->GetInput(VzEnum);       _assert_(vz_input);
+
+	/* Start  looping on the number of gaussian points: */
+	gauss=new GaussPenta(5,5);
+	for (ig=gauss->begin();ig<gauss->end();ig++){
+
+		gauss->GaussPoint(ig);
+
+		GetJacobianDeterminant(&Jdet, &xyz_list[0][0],gauss);
+		GetNodalFunctionsP1Derivatives(&dphi[0][0],&xyz_list[0][0],gauss);
+
+		this->GetStrainRate3dPattyn(&epsilon[0],&xyz_list[0][0],gauss,vx_input,vy_input);
+		matice->GetViscosityDerivativeEpsSquare(&mu_prime,&epsilon[0]);
+		eps1[0]=epsilon[0];   eps2[0]=epsilon[2];   eps3[0]=epsilon[3];
+		eps1[1]=epsilon[2];   eps2[1]=epsilon[1];   eps3[1]=epsilon[4];
+		eps1[2]=epsilon[3];   eps2[2]=epsilon[4];   eps3[2]= -epsilon[0] -epsilon[1];
+
+		for(i=0;i<6;i++){
+			for(j=0;j<6;j++){
+				eps1dotdphii=eps1[0]*dphi[0][i]+eps1[1]*dphi[1][i]+eps1[2]*dphi[2][i];
+				eps1dotdphij=eps1[0]*dphi[0][j]+eps1[1]*dphi[1][j]+eps1[2]*dphi[2][j];
+				eps2dotdphii=eps2[0]*dphi[0][i]+eps2[1]*dphi[1][i]+eps2[2]*dphi[2][i];
+				eps2dotdphij=eps2[0]*dphi[0][j]+eps2[1]*dphi[1][j]+eps2[2]*dphi[2][j];
+				eps3dotdphii=eps3[0]*dphi[0][i]+eps3[1]*dphi[1][i]+eps3[2]*dphi[2][i];
+				eps3dotdphij=eps3[0]*dphi[0][j]+eps3[1]*dphi[1][j]+eps3[2]*dphi[2][j];
+
+				Ke->values[numdof*(4*i+0)+4*j+0]+=gauss->weight*Jdet*2*mu_prime*eps1dotdphij*eps1dotdphii;
+				Ke->values[numdof*(4*i+0)+4*j+1]+=gauss->weight*Jdet*2*mu_prime*eps2dotdphij*eps1dotdphii;
+				Ke->values[numdof*(4*i+0)+4*j+2]+=gauss->weight*Jdet*2*mu_prime*eps3dotdphij*eps1dotdphii;
+
+				Ke->values[numdof*(4*i+1)+4*j+0]+=gauss->weight*Jdet*2*mu_prime*eps1dotdphij*eps2dotdphii;
+				Ke->values[numdof*(4*i+1)+4*j+1]+=gauss->weight*Jdet*2*mu_prime*eps2dotdphij*eps2dotdphii;
+				Ke->values[numdof*(4*i+1)+4*j+2]+=gauss->weight*Jdet*2*mu_prime*eps3dotdphij*eps2dotdphii;
+
+				Ke->values[numdof*(4*i+2)+4*j+0]+=gauss->weight*Jdet*2*mu_prime*eps1dotdphij*eps3dotdphii;
+				Ke->values[numdof*(4*i+2)+4*j+1]+=gauss->weight*Jdet*2*mu_prime*eps2dotdphij*eps3dotdphii;
+				Ke->values[numdof*(4*i+2)+4*j+2]+=gauss->weight*Jdet*2*mu_prime*eps3dotdphij*eps3dotdphii;
+			}
+		}
+	}
+
+	/*Transform Coordinate System*/
+	TransformStiffnessMatrixCoord(Ke,nodes,NUMVERTICES,XYZPEnum);
+
+	/*Clean up and return*/
+	delete gauss;
+	return Ke;
+}
+/*}}}*/
 /*FUNCTION Penta::CreatePVectorAdjointHoriz{{{1*/
 ElementVector* Penta::CreatePVectorAdjointHoriz(void){
@@ -4432,6 +4704,20 @@
 }
 /*}}}*/
+/*FUNCTION Penta::GradientIndexing{{{1*/
+void Penta::GradientIndexing(int* indexing,int control_index){
+
+	/*Get some parameters*/
+	int num_controls;
+	parameters->FindParam(&num_controls,InversionNumControlParametersEnum);
+
+	/*get gradient indices*/
+	for(int i=0;i<NUMVERTICES;i++){
+		indexing[i]=num_controls*this->nodes[i]->GetVertexDof() + control_index;
+	}
+
+}
+/*}}}*/
 /*FUNCTION Penta::Gradj {{{1*/
-void  Penta::Gradj(Vec gradient,int control_type){
+void  Penta::Gradj(Vec gradient,int control_type,int control_index){
 	/*dJ/dalpha = ∂L/∂alpha = ∂J/∂alpha + ∂/∂alpha(KU-F)*/
 
@@ -4449,11 +4735,11 @@
 			switch(approximation){
 				case MacAyealApproximationEnum:
-					GradjDragMacAyeal(gradient);
+					GradjDragMacAyeal(gradient,control_index);
 					break;
 				case PattynApproximationEnum:
-					GradjDragPattyn(gradient);
+					GradjDragPattyn(gradient,control_index);
 					break;
 				case StokesApproximationEnum:
-					GradjDragStokes(gradient);
+					GradjDragStokes(gradient,control_index);
 					break;
 				case NoneApproximationEnum:
@@ -4469,11 +4755,11 @@
 			switch(approximation){
 				case MacAyealApproximationEnum:
-					GradjBbarMacAyeal(gradient);
+					GradjBbarMacAyeal(gradient,control_index);
 					break;
 				case PattynApproximationEnum:
-					GradjBbarPattyn(gradient);
+					GradjBbarPattyn(gradient,control_index);
 					break;
 				case StokesApproximationEnum:
-					GradjBbarStokes(gradient);
+					GradjBbarStokes(gradient,control_index);
 					break;
 				case NoneApproximationEnum:
@@ -4508,5 +4794,5 @@
 			if (!IsOnBed()) return;
 			tria=(Tria*)SpawnTria(0,1,2); //nodes 0, 1 and 2 make the new tria.
-			tria->GradjDragGradient(gradient,resp);
+			tria->GradjDragGradient(gradient,resp,control_index);
 			delete tria->matice; delete tria;
 			break;
@@ -4514,5 +4800,5 @@
 			if (!IsOnBed()) return;
 			tria=(Tria*)SpawnTria(0,1,2); //nodes 0, 1 and 2 make the new tria.
-			tria->GradjBGradient(gradient,resp);
+			tria->GradjBGradient(gradient,resp,control_index);
 			delete tria->matice; delete tria;
 			break;
@@ -4524,5 +4810,5 @@
 /*}}}*/
 /*FUNCTION Penta::GradjDragMacAyeal {{{1*/
-void  Penta::GradjDragMacAyeal(Vec gradient){
+void  Penta::GradjDragMacAyeal(Vec gradient,int control_index){
 
 	/*Gradient is 0 if on shelf or not on bed*/
@@ -4531,10 +4817,10 @@
 	/*Spawn tria*/
 	Tria* tria=(Tria*)SpawnTria(0,1,2); //nodes 0, 1 and 2 make the new tria.
-	tria->GradjDragMacAyeal(gradient);
+	tria->GradjDragMacAyeal(gradient,control_index);
 	delete tria->matice; delete tria;
 
 } /*}}}*/
 /*FUNCTION Penta::GradjDragPattyn {{{1*/
-void  Penta::GradjDragPattyn(Vec gradient){
+void  Penta::GradjDragPattyn(Vec gradient,int control_index){
 
 	int        i,j,ig;
@@ -4557,7 +4843,7 @@
 	/*Retrieve all inputs and parameters*/
 	parameters->FindParam(&analysis_type,AnalysisTypeEnum);
+	GradientIndexing(&doflist1[0],control_index);
 	GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES);
 	for(i=0;i<NUMVERTICES2D;i++) for(j=0;j<2;j++) xyz_list_tria[i][j]=xyz_list[i][j];
-	GetDofList1(&doflist1[0]);
 	Input* adjointx_input=inputs->GetInput(AdjointxEnum);               _assert_(adjointx_input);
 	Input* adjointy_input=inputs->GetInput(AdjointyEnum);               _assert_(adjointy_input);
@@ -4607,5 +4893,5 @@
 /*}}}*/
 /*FUNCTION Penta::GradjDragStokes {{{1*/
-void  Penta::GradjDragStokes(Vec gradient){
+void  Penta::GradjDragStokes(Vec gradient,int control_index){
 
 	int        i,j,ig;
@@ -4632,12 +4918,12 @@
 	GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES);
 	for(i=0;i<NUMVERTICES2D;i++) for(j=0;j<2;j++) xyz_list_tria[i][j]=xyz_list[i][j];
-	GetDofList1(&doflist1[0]);
+	GradientIndexing(&doflist1[0],control_index);
 	Input* drag_input    =inputs->GetInput(FrictionCoefficientEnum); _assert_(drag_input);
-	Input* vx_input      =inputs->GetInput(VxEnum);              _assert_(vx_input);
-	Input* vy_input      =inputs->GetInput(VyEnum);              _assert_(vy_input);
-	Input* vz_input      =inputs->GetInput(VzEnum);              _assert_(vz_input);
-	Input* adjointx_input=inputs->GetInput(AdjointxEnum);        _assert_(adjointx_input);
-	Input* adjointy_input=inputs->GetInput(AdjointyEnum);        _assert_(adjointy_input);
-	Input* adjointz_input=inputs->GetInput(AdjointzEnum);        _assert_(adjointz_input);
+	Input* vx_input      =inputs->GetInput(VxEnum);                  _assert_(vx_input);
+	Input* vy_input      =inputs->GetInput(VyEnum);                  _assert_(vy_input);
+	Input* vz_input      =inputs->GetInput(VzEnum);                  _assert_(vz_input);
+	Input* adjointx_input=inputs->GetInput(AdjointxEnum);            _assert_(adjointx_input);
+	Input* adjointy_input=inputs->GetInput(AdjointyEnum);            _assert_(adjointy_input);
+	Input* adjointz_input=inputs->GetInput(AdjointzEnum);            _assert_(adjointz_input);
 
 	/*Build frictoin element, needed later: */
@@ -4699,5 +4985,5 @@
 /*}}}*/
 /*FUNCTION Penta::GradjBbarMacAyeal {{{1*/
-void  Penta::GradjBbarMacAyeal(Vec gradient){
+void  Penta::GradjBbarMacAyeal(Vec gradient,int control_index){
 
 	/*This element should be collapsed into a tria element at its base*/
@@ -4709,5 +4995,5 @@
 	/*Collapse element to the base*/
 	Tria* tria=(Tria*)SpawnTria(0,1,2); //nodes 0, 1 and 2 make the new tria (lower face).
-	tria->GradjBMacAyeal(gradient);
+	tria->GradjBMacAyeal(gradient,control_index);
 	delete tria->matice; delete tria;
 
@@ -4717,5 +5003,5 @@
 } /*}}}*/
 /*FUNCTION Penta::GradjBbarPattyn {{{1*/
-void  Penta::GradjBbarPattyn(Vec gradient){
+void  Penta::GradjBbarPattyn(Vec gradient,int control_index){
 
 	/*Gradient is computed on bed only (Bbar)*/
@@ -4727,5 +5013,5 @@
 	/*Collapse element to the base*/
 	Tria* tria=(Tria*)SpawnTria(0,1,2);
-	tria->GradjBMacAyeal(gradient);    //We use MacAyeal as an estimate for now
+	tria->GradjBMacAyeal(gradient,control_index);    //We use MacAyeal as an estimate for now
 	delete tria->matice; delete tria;
 
@@ -4734,5 +5020,5 @@
 } /*}}}*/
 /*FUNCTION Penta::GradjBbarStokes {{{1*/
-void  Penta::GradjBbarStokes(Vec gradient){
+void  Penta::GradjBbarStokes(Vec gradient,int control_index){
 
 	/*Gradient is computed on bed only (Bbar)*/
@@ -4744,5 +5030,5 @@
 	/*Collapse element to the base*/
 	Tria* tria=(Tria*)SpawnTria(0,1,2);
-	tria->GradjBMacAyeal(gradient);    //We use MacAyeal as an estimate for now
+	tria->GradjBMacAyeal(gradient,control_index);    //We use MacAyeal as an estimate for now
 	delete tria->matice; delete tria;
 
@@ -4822,8 +5108,8 @@
 
 	/*Add vx and vy as inputs to the tria element: */
-	this->inputs->AddInput(new PentaVertexInput(AdjointxEnum,lambdax));
-	this->inputs->AddInput(new PentaVertexInput(AdjointyEnum,lambday));
-	this->inputs->AddInput(new PentaVertexInput(AdjointzEnum,lambdaz));
-	this->inputs->AddInput(new PentaVertexInput(AdjointpEnum,lambdap));
+	this->inputs->AddInput(new PentaP1Input(AdjointxEnum,lambdax));
+	this->inputs->AddInput(new PentaP1Input(AdjointyEnum,lambday));
+	this->inputs->AddInput(new PentaP1Input(AdjointzEnum,lambdaz));
+	this->inputs->AddInput(new PentaP1Input(AdjointpEnum,lambdap));
 
 	/*Free ressources:*/
@@ -4859,6 +5145,6 @@
 
 	/*Add vx and vy as inputs to the tria element: */
-	this->inputs->AddInput(new PentaVertexInput(AdjointxEnum,lambdax));
-	this->inputs->AddInput(new PentaVertexInput(AdjointyEnum,lambday));
+	this->inputs->AddInput(new PentaP1Input(AdjointxEnum,lambdax));
+	this->inputs->AddInput(new PentaP1Input(AdjointyEnum,lambday));
 
 	/*Free ressources:*/
@@ -5109,4 +5395,62 @@
 }
 /*}}}*/
+/*FUNCTION Penta::GetVectorFromControlInputs{{{1*/
+void  Penta::GetVectorFromControlInputs(Vec vector,int control_enum,int control_index,const char* data){
+
+	int doflist1[NUMVERTICES];
+
+	/*Get out if this is not an element input*/
+	if(!IsInput(control_enum)) return;
+
+	/*Prepare index list*/
+	GradientIndexing(&doflist1[0],control_index);
+
+	/*Get input (either in element or material)*/
+	Input* input=inputs->GetInput(control_enum);
+	if(!input) _error_("Input %s not found in element",EnumToStringx(control_enum));
+
+	/*Check that it is a ControlInput*/
+	if (input->ObjectEnum()!=ControlInputEnum){
+		_error_("input %s is not a ControlInput",EnumToStringx(control_enum));
+	}
+
+	((ControlInput*)input)->GetVectorFromInputs(vector,&doflist1[0],data);
+}
+/*}}}*/
+/*FUNCTION Penta::SetControlInputsFromVector{{{1*/
+void  Penta::SetControlInputsFromVector(double* vector,int control_enum,int control_index){
+
+	double  values[NUMVERTICES];
+	int     doflist1[NUMVERTICES];
+	Input  *input     = NULL;
+	Input  *new_input = NULL;
+
+	/*Get out if this is not an element input*/
+	if(!IsInput(control_enum)) return;
+
+	/*Prepare index list*/
+	GradientIndexing(&doflist1[0],control_index);
+
+	/*Get values on vertices*/
+	for (int i=0;i<NUMVERTICES;i++){
+		values[i]=vector[doflist1[i]];
+	}
+	new_input = new PentaP1Input(control_enum,values);
+
+
+	if(control_enum==MaterialsRheologyBbarEnum){
+		input=(Input*)matice->inputs->GetInput(control_enum); _assert_(input);
+	}
+	else{
+		input=(Input*)this->inputs->GetInput(control_enum);   _assert_(input);
+	}
+
+	if (input->ObjectEnum()!=ControlInputEnum){
+		_error_("input %s is not a ControlInput",EnumToStringx(control_enum));
+	}
+
+	((ControlInput*)input)->SetInput(new_input);
+}
+/*}}}*/
 #endif
 
@@ -5124,5 +5468,5 @@
 		case VertexEnum:
 
-			/*New PentaVertexInput*/
+			/*New PentaP1Input*/
 			double values[6];
 
@@ -5197,12 +5541,12 @@
 
 					/*Add new inputs: */
-					this->inputs->AddInput(new PentaVertexInput(ThicknessEnum,thickness));
-					this->inputs->AddInput(new PentaVertexInput(BedEnum,bed));
-					this->inputs->AddInput(new PentaVertexInput(SurfaceEnum,surface));
+					this->inputs->AddInput(new PentaP1Input(ThicknessEnum,thickness));
+					this->inputs->AddInput(new PentaP1Input(BedEnum,bed));
+					this->inputs->AddInput(new PentaP1Input(SurfaceEnum,surface));
 
 					/*}}}*/
 					break;
 				default:
-					this->inputs->AddInput(new PentaVertexInput(name,values));
+					this->inputs->AddInput(new PentaP1Input(name,values));
 			}
 			break;
@@ -5257,5 +5601,5 @@
 
 				if(t==0) transientinput=new TransientInput(name);
-				transientinput->AddTimeInput(new PentaVertexInput(name,values),time);
+				transientinput->AddTimeInput(new PentaP1Input(name,values),time);
 				transientinput->Configure(parameters);
 			}
@@ -7311,4 +7655,188 @@
 }
 /*}}}*/
+/*FUNCTION Penta::CreateJacobianDiagnosticHoriz{{{1*/
+ElementMatrix* Penta::CreateJacobianDiagnosticHoriz(void){
+
+	int approximation;
+	inputs->GetInputValue(&approximation,ApproximationEnum);
+
+	switch(approximation){
+		case MacAyealApproximationEnum:
+			return CreateJacobianDiagnosticMacayeal2d();
+		case PattynApproximationEnum:
+			return CreateJacobianDiagnosticPattyn();
+		case StokesApproximationEnum:
+			return CreateJacobianDiagnosticStokes();
+		case NoneApproximationEnum:
+			return NULL;
+		default:
+			_error_("Approximation %s not supported yet",EnumToStringx(approximation));
+	}
+}
+/*}}}*/
+/*FUNCTION Penta::CreateJacobianDiagnosticMacayeal2d{{{1*/
+ElementMatrix* Penta::CreateJacobianDiagnosticMacayeal2d(void){
+
+	/*Figure out if this penta is collapsed. If so, then bailout, except if it is at the 
+	  bedrock, in which case we spawn a tria element using the 3 first nodes, and use it to build 
+	  the stiffness matrix. */
+	if (!IsOnBed()) return NULL;
+
+	/*Depth Averaging B*/
+	this->InputDepthAverageAtBase(MaterialsRheologyBEnum,MaterialsRheologyBbarEnum,MaterialsEnum);
+
+	/*Call Tria function*/
+	Tria* tria=(Tria*)SpawnTria(0,1,2); //nodes 0, 1 and 2 make the new tria.
+	ElementMatrix* Ke=tria->CreateJacobianDiagnosticMacayeal();
+	delete tria->matice; delete tria;
+
+	/*Delete B averaged*/
+	this->matice->inputs->DeleteInput(MaterialsRheologyBbarEnum);
+
+	/*clean up and return*/
+	return Ke;
+}
+/*}}}*/
+/*FUNCTION Penta::CreateJacobianDiagnosticPattyn{{{1*/
+ElementMatrix* Penta::CreateJacobianDiagnosticPattyn(void){
+
+	/*Constants*/
+	const int    numdof=NDOF2*NUMVERTICES;
+
+	/*Intermediaries */
+	int        i,j,ig;
+	double     xyz_list[NUMVERTICES][3];
+	double     Jdet;
+	double     eps1dotdphii,eps1dotdphij;
+	double     eps2dotdphii,eps2dotdphij;
+	double     mu_prime;
+	double     epsilon[5]; /* epsilon=[exx,eyy,exy,exz,eyz];*/
+	double     eps1[3],eps2[3];
+	double     phi[NUMVERTICES];
+	double     dphi[3][NUMVERTICES];
+	GaussPenta *gauss=NULL;
+
+	/*Initialize Jacobian with regular Pattyn (first part of the Gateau derivative)*/
+	ElementMatrix* Ke=CreateKMatrixDiagnosticPattyn();
+
+	/*Retrieve all inputs and parameters*/
+	GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES);
+	Input* vx_input=inputs->GetInput(VxEnum);       _assert_(vx_input);
+	Input* vy_input=inputs->GetInput(VyEnum);       _assert_(vy_input);
+
+	/* Start  looping on the number of gaussian points: */
+	gauss=new GaussPenta(5,5);
+	for (ig=gauss->begin();ig<gauss->end();ig++){
+
+		gauss->GaussPoint(ig);
+
+		GetJacobianDeterminant(&Jdet, &xyz_list[0][0],gauss);
+		GetNodalFunctionsP1Derivatives(&dphi[0][0],&xyz_list[0][0],gauss);
+
+		this->GetStrainRate3dPattyn(&epsilon[0],&xyz_list[0][0],gauss,vx_input,vy_input);
+		matice->GetViscosityDerivativeEpsSquare(&mu_prime,&epsilon[0]);
+		eps1[0]=2*epsilon[0]+epsilon[1];   eps2[0]=epsilon[2];
+		eps1[1]=epsilon[2];                eps2[1]=epsilon[0]+2*epsilon[1];
+		eps1[2]=epsilon[3];                eps2[2]=epsilon[4];
+
+		for(i=0;i<6;i++){
+			for(j=0;j<6;j++){
+				eps1dotdphii=eps1[0]*dphi[0][i]+eps1[1]*dphi[1][i]+eps1[2]*dphi[2][i];
+				eps1dotdphij=eps1[0]*dphi[0][j]+eps1[1]*dphi[1][j]+eps1[2]*dphi[2][j];
+				eps2dotdphii=eps2[0]*dphi[0][i]+eps2[1]*dphi[1][i]+eps2[2]*dphi[2][i];
+				eps2dotdphij=eps2[0]*dphi[0][j]+eps2[1]*dphi[1][j]+eps2[2]*dphi[2][j];
+
+				Ke->values[12*(2*i+0)+2*j+0]+=gauss->weight*Jdet*2*mu_prime*eps1dotdphij*eps1dotdphii;
+				Ke->values[12*(2*i+0)+2*j+1]+=gauss->weight*Jdet*2*mu_prime*eps2dotdphij*eps1dotdphii;
+				Ke->values[12*(2*i+1)+2*j+0]+=gauss->weight*Jdet*2*mu_prime*eps1dotdphij*eps2dotdphii;
+				Ke->values[12*(2*i+1)+2*j+1]+=gauss->weight*Jdet*2*mu_prime*eps2dotdphij*eps2dotdphii;
+			}
+		}
+	}
+
+	/*Transform Coordinate System*/
+	TransformStiffnessMatrixCoord(Ke,nodes,NUMVERTICES,XYEnum);
+
+	/*Clean up and return*/
+	delete gauss;
+	return Ke;
+}
+/*}}}*/
+/*FUNCTION Penta::CreateJacobianDiagnosticStokes{{{1*/
+ElementMatrix* Penta::CreateJacobianDiagnosticStokes(void){
+
+	/*Constants*/
+	const int    numdof=NDOF4*NUMVERTICES;
+
+	/*Intermediaries */
+	int        i,j,ig;
+	double     xyz_list[NUMVERTICES][3];
+	double     Jdet;
+	double     eps1dotdphii,eps1dotdphij;
+	double     eps2dotdphii,eps2dotdphij;
+	double     eps3dotdphii,eps3dotdphij;
+	double     mu_prime;
+	double     epsilon[5]; /* epsilon=[exx,eyy,exy,exz,eyz];*/
+	double     eps1[3],eps2[3],eps3[3];
+	double     phi[NUMVERTICES];
+	double     dphi[3][NUMVERTICES];
+	GaussPenta *gauss=NULL;
+
+	/*Initialize Jacobian with regular Stokes (first part of the Gateau derivative)*/
+	ElementMatrix* Ke=CreateKMatrixDiagnosticStokes();
+
+	/*Retrieve all inputs and parameters*/
+	GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES);
+	Input* vx_input=inputs->GetInput(VxEnum);       _assert_(vx_input);
+	Input* vy_input=inputs->GetInput(VyEnum);       _assert_(vy_input);
+	Input* vz_input=inputs->GetInput(VzEnum);       _assert_(vz_input);
+
+	/* Start  looping on the number of gaussian points: */
+	gauss=new GaussPenta(5,5);
+	for (ig=gauss->begin();ig<gauss->end();ig++){
+
+		gauss->GaussPoint(ig);
+
+		GetJacobianDeterminant(&Jdet, &xyz_list[0][0],gauss);
+		GetNodalFunctionsP1Derivatives(&dphi[0][0],&xyz_list[0][0],gauss);
+
+		this->GetStrainRate3dPattyn(&epsilon[0],&xyz_list[0][0],gauss,vx_input,vy_input);
+		matice->GetViscosityDerivativeEpsSquare(&mu_prime,&epsilon[0]);
+		eps1[0]=epsilon[0];   eps2[0]=epsilon[2];   eps3[0]=epsilon[3];
+		eps1[1]=epsilon[2];   eps2[1]=epsilon[1];   eps3[1]=epsilon[4];
+		eps1[2]=epsilon[3];   eps2[2]=epsilon[4];   eps3[2]= -epsilon[0] -epsilon[1];
+
+		for(i=0;i<6;i++){
+			for(j=0;j<6;j++){
+				eps1dotdphii=eps1[0]*dphi[0][i]+eps1[1]*dphi[1][i]+eps1[2]*dphi[2][i];
+				eps1dotdphij=eps1[0]*dphi[0][j]+eps1[1]*dphi[1][j]+eps1[2]*dphi[2][j];
+				eps2dotdphii=eps2[0]*dphi[0][i]+eps2[1]*dphi[1][i]+eps2[2]*dphi[2][i];
+				eps2dotdphij=eps2[0]*dphi[0][j]+eps2[1]*dphi[1][j]+eps2[2]*dphi[2][j];
+				eps3dotdphii=eps3[0]*dphi[0][i]+eps3[1]*dphi[1][i]+eps3[2]*dphi[2][i];
+				eps3dotdphij=eps3[0]*dphi[0][j]+eps3[1]*dphi[1][j]+eps3[2]*dphi[2][j];
+
+				Ke->values[numdof*(4*i+0)+4*j+0]+=gauss->weight*Jdet*2*mu_prime*eps1dotdphij*eps1dotdphii;
+				Ke->values[numdof*(4*i+0)+4*j+1]+=gauss->weight*Jdet*2*mu_prime*eps2dotdphij*eps1dotdphii;
+				Ke->values[numdof*(4*i+0)+4*j+2]+=gauss->weight*Jdet*2*mu_prime*eps3dotdphij*eps1dotdphii;
+
+				Ke->values[numdof*(4*i+1)+4*j+0]+=gauss->weight*Jdet*2*mu_prime*eps1dotdphij*eps2dotdphii;
+				Ke->values[numdof*(4*i+1)+4*j+1]+=gauss->weight*Jdet*2*mu_prime*eps2dotdphij*eps2dotdphii;
+				Ke->values[numdof*(4*i+1)+4*j+2]+=gauss->weight*Jdet*2*mu_prime*eps3dotdphij*eps2dotdphii;
+
+				Ke->values[numdof*(4*i+2)+4*j+0]+=gauss->weight*Jdet*2*mu_prime*eps1dotdphij*eps3dotdphii;
+				Ke->values[numdof*(4*i+2)+4*j+1]+=gauss->weight*Jdet*2*mu_prime*eps2dotdphij*eps3dotdphii;
+				Ke->values[numdof*(4*i+2)+4*j+2]+=gauss->weight*Jdet*2*mu_prime*eps3dotdphij*eps3dotdphii;
+			}
+		}
+	}
+
+	/*Transform Coordinate System*/
+	TransformStiffnessMatrixCoord(Ke,nodes,NUMVERTICES,XYZPEnum);
+
+	/*Clean up and return*/
+	delete gauss;
+	return Ke;
+}
+/*}}}*/
 /*FUNCTION Penta::GetSolutionFromInputsDiagnosticHoriz{{{1*/
 void  Penta::GetSolutionFromInputsDiagnosticHoriz(Vec solution){
@@ -7568,8 +8096,8 @@
 
 		/*Add vx and vy as inputs to the tria element: */
-		penta->inputs->AddInput(new PentaVertexInput(VxEnum,vx));
-		penta->inputs->AddInput(new PentaVertexInput(VyEnum,vy));
-		penta->inputs->AddInput(new PentaVertexInput(VelEnum,vel));
-		penta->inputs->AddInput(new PentaVertexInput(PressureEnum,pressure));
+		penta->inputs->AddInput(new PentaP1Input(VxEnum,vx));
+		penta->inputs->AddInput(new PentaP1Input(VyEnum,vy));
+		penta->inputs->AddInput(new PentaP1Input(VelEnum,vel));
+		penta->inputs->AddInput(new PentaP1Input(PressureEnum,pressure));
 
 		/*Stop if we have reached the surface*/
@@ -7658,8 +8186,8 @@
 
 	/*Add vx and vy as inputs to the tria element: */
-	this->inputs->AddInput(new PentaVertexInput(VxEnum,vx));
-	this->inputs->AddInput(new PentaVertexInput(VyEnum,vy));
-	this->inputs->AddInput(new PentaVertexInput(VelEnum,vel));
-	this->inputs->AddInput(new PentaVertexInput(PressureEnum,pressure));
+	this->inputs->AddInput(new PentaP1Input(VxEnum,vx));
+	this->inputs->AddInput(new PentaP1Input(VyEnum,vy));
+	this->inputs->AddInput(new PentaP1Input(VelEnum,vel));
+	this->inputs->AddInput(new PentaP1Input(PressureEnum,pressure));
 
 	/*Free ressources:*/
@@ -7733,5 +8261,5 @@
 	Input* vzmacayeal_input=inputs->GetInput(VzMacAyealEnum);
 	if (vzmacayeal_input){
-		if (vzmacayeal_input->ObjectEnum()!=PentaVertexInputEnum){
+		if (vzmacayeal_input->ObjectEnum()!=PentaP1InputEnum){
 			_error_("Cannot compute Vel as VzMacAyeal is of type %s",EnumToStringx(vzmacayeal_input->ObjectEnum()));
 		}
@@ -7756,10 +8284,10 @@
 
 	/*Add vx and vy as inputs to the tria element: */
-	this->inputs->AddInput(new PentaVertexInput(VxEnum,vx));
-	this->inputs->AddInput(new PentaVertexInput(VyEnum,vy));
-	this->inputs->AddInput(new PentaVertexInput(VzEnum,vz));
-	this->inputs->AddInput(new PentaVertexInput(VzStokesEnum,vzstokes));
-	this->inputs->AddInput(new PentaVertexInput(VelEnum,vel));
-	this->inputs->AddInput(new PentaVertexInput(PressureEnum,pressure));
+	this->inputs->AddInput(new PentaP1Input(VxEnum,vx));
+	this->inputs->AddInput(new PentaP1Input(VyEnum,vy));
+	this->inputs->AddInput(new PentaP1Input(VzEnum,vz));
+	this->inputs->AddInput(new PentaP1Input(VzStokesEnum,vzstokes));
+	this->inputs->AddInput(new PentaP1Input(VelEnum,vel));
+	this->inputs->AddInput(new PentaP1Input(PressureEnum,pressure));
 
 	/*Free ressources:*/
@@ -7833,8 +8361,8 @@
 
 	/*Add vx and vy as inputs to the tria element: */
-	this->inputs->AddInput(new PentaVertexInput(VxEnum,vx));
-	this->inputs->AddInput(new PentaVertexInput(VyEnum,vy));
-	this->inputs->AddInput(new PentaVertexInput(VelEnum,vel));
-	this->inputs->AddInput(new PentaVertexInput(PressureEnum,pressure));
+	this->inputs->AddInput(new PentaP1Input(VxEnum,vx));
+	this->inputs->AddInput(new PentaP1Input(VyEnum,vy));
+	this->inputs->AddInput(new PentaP1Input(VelEnum,vel));
+	this->inputs->AddInput(new PentaP1Input(PressureEnum,pressure));
 
 	/*Free ressources:*/
@@ -7901,5 +8429,5 @@
 	Input* vzpattyn_input=inputs->GetInput(VzPattynEnum);
 	if (vzpattyn_input){
-		if (vzpattyn_input->ObjectEnum()!=PentaVertexInputEnum){
+		if (vzpattyn_input->ObjectEnum()!=PentaP1InputEnum){
 			_error_("Cannot compute Vel as VzPattyn is of type %s",EnumToStringx(vzpattyn_input->ObjectEnum()));
 		}
@@ -7924,10 +8452,10 @@
 
 	/*Add vx and vy as inputs to the tria element: */
-	this->inputs->AddInput(new PentaVertexInput(VxEnum,vx));
-	this->inputs->AddInput(new PentaVertexInput(VyEnum,vy));
-	this->inputs->AddInput(new PentaVertexInput(VzEnum,vz));
-	this->inputs->AddInput(new PentaVertexInput(VzStokesEnum,vzstokes));
-	this->inputs->AddInput(new PentaVertexInput(VelEnum,vel));
-	this->inputs->AddInput(new PentaVertexInput(PressureEnum,pressure));
+	this->inputs->AddInput(new PentaP1Input(VxEnum,vx));
+	this->inputs->AddInput(new PentaP1Input(VyEnum,vy));
+	this->inputs->AddInput(new PentaP1Input(VzEnum,vz));
+	this->inputs->AddInput(new PentaP1Input(VzStokesEnum,vzstokes));
+	this->inputs->AddInput(new PentaP1Input(VelEnum,vel));
+	this->inputs->AddInput(new PentaP1Input(PressureEnum,pressure));
 
 	/*Free ressources:*/
@@ -7990,8 +8518,8 @@
 
 	/*Add vx and vy as inputs to the tria element: */
-	this->inputs->AddInput(new PentaVertexInput(VxEnum,vx));
-	this->inputs->AddInput(new PentaVertexInput(VyEnum,vy));
-	this->inputs->AddInput(new PentaVertexInput(VelEnum,vel));
-	this->inputs->AddInput(new PentaVertexInput(PressureEnum,pressure));
+	this->inputs->AddInput(new PentaP1Input(VxEnum,vx));
+	this->inputs->AddInput(new PentaP1Input(VyEnum,vy));
+	this->inputs->AddInput(new PentaP1Input(VelEnum,vel));
+	this->inputs->AddInput(new PentaP1Input(PressureEnum,pressure));
 
 	/*Free ressources:*/
@@ -8048,5 +8576,5 @@
 		Input* vzstokes_input=inputs->GetInput(VzStokesEnum);
 		if (vzstokes_input){
-			if (vzstokes_input->ObjectEnum()!=PentaVertexInputEnum) _error_("Cannot compute Vel as VzStokes is of type %s",EnumToStringx(vzstokes_input->ObjectEnum()));
+			if (vzstokes_input->ObjectEnum()!=PentaP1InputEnum) _error_("Cannot compute Vel as VzStokes is of type %s",EnumToStringx(vzstokes_input->ObjectEnum()));
 			GetInputListOnVertices(&vzstokes[0],VzStokesEnum);
 		}
@@ -8060,5 +8588,5 @@
 		Input* vzstokes_input=inputs->GetInput(VzStokesEnum);
 		if (vzstokes_input){
-			if (vzstokes_input->ObjectEnum()!=PentaVertexInputEnum) _error_("Cannot compute Vel as VzStokes is of type %s",EnumToStringx(vzstokes_input->ObjectEnum()));
+			if (vzstokes_input->ObjectEnum()!=PentaP1InputEnum) _error_("Cannot compute Vel as VzStokes is of type %s",EnumToStringx(vzstokes_input->ObjectEnum()));
 			GetInputListOnVertices(&vzstokes[0],VzStokesEnum);
 		}
@@ -8088,14 +8616,14 @@
 	if(approximation!=PattynStokesApproximationEnum && approximation!=MacAyealStokesApproximationEnum){
 		this->inputs->ChangeEnum(PressureEnum,PressurePicardEnum);
-		this->inputs->AddInput(new PentaVertexInput(PressureEnum,pressure));
+		this->inputs->AddInput(new PentaP1Input(PressureEnum,pressure));
 	}
 	else if(approximation==PattynStokesApproximationEnum){
-		this->inputs->AddInput(new PentaVertexInput(VzPattynEnum,vzpattyn));
+		this->inputs->AddInput(new PentaP1Input(VzPattynEnum,vzpattyn));
 	}
 	else if(approximation==MacAyealStokesApproximationEnum){
-		this->inputs->AddInput(new PentaVertexInput(VzMacAyealEnum,vzmacayeal));
-	}
-	this->inputs->AddInput(new PentaVertexInput(VzEnum,vz));
-	this->inputs->AddInput(new PentaVertexInput(VelEnum,vel));
+		this->inputs->AddInput(new PentaP1Input(VzMacAyealEnum,vzmacayeal));
+	}
+	this->inputs->AddInput(new PentaP1Input(VzEnum,vz));
+	this->inputs->AddInput(new PentaP1Input(VelEnum,vel));
 
 	/*Free ressources:*/
@@ -8154,9 +8682,9 @@
 
 	/*Add vx and vy as inputs to the tria element: */
-	this->inputs->AddInput(new PentaVertexInput(VxEnum,vx));
-	this->inputs->AddInput(new PentaVertexInput(VyEnum,vy));
-	this->inputs->AddInput(new PentaVertexInput(VzEnum,vz));
-	this->inputs->AddInput(new PentaVertexInput(VelEnum,vel));
-	this->inputs->AddInput(new PentaVertexInput(PressureEnum,pressure));
+	this->inputs->AddInput(new PentaP1Input(VxEnum,vx));
+	this->inputs->AddInput(new PentaP1Input(VyEnum,vy));
+	this->inputs->AddInput(new PentaP1Input(VzEnum,vz));
+	this->inputs->AddInput(new PentaP1Input(VelEnum,vel));
+	this->inputs->AddInput(new PentaP1Input(PressureEnum,pressure));
 
 	/*Free ressources:*/
Index: /issm/trunk/src/c/objects/Elements/Penta.h
===================================================================
--- /issm/trunk/src/c/objects/Elements/Penta.h	(revision 11526)
+++ /issm/trunk/src/c/objects/Elements/Penta.h	(revision 11527)
@@ -88,4 +88,5 @@
 		void   CreateKMatrix(Mat Kff, Mat Kfs,Vec df);
 		void   CreatePVector(Vec pf);
+		void   CreateJacobianMatrix(Mat Jff);
 		void   DeleteResults(void);
 		int    GetNodeIndex(Node* node);
@@ -111,4 +112,5 @@
 		void   PatchFill(int* pcount, Patch* patch);
 		void   PatchSize(int* pnumrows, int* pnumvertices,int* pnumnodes);
+		void   PositiveDegreeDay(void);
 		void   ProcessResultsUnits(void);
 		void   ResetCoordinateSystem(void);
@@ -119,4 +121,5 @@
 		int*   GetHorizontalNeighboorSids(void);
 		void   ViscousHeatingCreateInput(void);
+		void   SmearFunction(Vec smearedvector,double (*WeightFunction)(double distance,double radius),double radius);
 
 		 #ifdef _HAVE_RESPONSES_
@@ -140,14 +143,17 @@
 		#ifdef _HAVE_CONTROL_
 		double DragCoefficientAbsGradient(bool process_units,int weight_index);
-		void   Gradj(Vec gradient,int control_type);
-		void   GradjDragMacAyeal(Vec gradient);
-		void   GradjDragPattyn(Vec gradient);
-		void   GradjDragStokes(Vec gradient);
-		void   GradjBbarMacAyeal(Vec gradient);
-		void   GradjBbarPattyn(Vec gradient);
-		void   GradjBbarStokes(Vec gradient);
-		void   ControlInputGetGradient(Vec gradient,int enum_type);
+		void   GradientIndexing(int* indexing,int control_index);
+		void   Gradj(Vec gradient,int control_type,int control_index);
+		void   GradjDragMacAyeal(Vec gradient,int control_index);
+		void   GradjDragPattyn(Vec gradient,int control_index);
+		void   GradjDragStokes(Vec gradient,int control_index);
+		void   GradjBbarMacAyeal(Vec gradient,int control_index);
+		void   GradjBbarPattyn(Vec gradient,int control_index);
+		void   GradjBbarStokes(Vec gradient,int control_index);
+		void   GetVectorFromControlInputs(Vec gradient,int control_enum,int control_index,const char* data);
+		void   SetControlInputsFromVector(double* vector,int control_enum,int control_index);
+		void   ControlInputGetGradient(Vec gradient,int enum_type,int control_index);
 		void   ControlInputScaleGradient(int enum_type,double scale);
-		void   ControlInputSetGradient(double* gradient,int enum_type);
+		void   ControlInputSetGradient(double* gradient,int enum_type,int control_index);
 		double RheologyBbarAbsGradient(bool process_units,int weight_index);
 		double ThicknessAbsMisfit(     bool process_units,int weight_index);
@@ -178,5 +184,5 @@
 		void	  GetPhi(double* phi, double*  epsilon, double viscosity);
 		void	  GetSolutionFromInputsEnthalpy(Vec solutiong);
-		double  GetStabilizationParameter(double u, double v, double w, double diameter, double rho_ice, double heatcapacity, double thermalconductivity);
+		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);
 		void    GetStrainRate3d(double* epsilon,double* xyz_list, GaussPenta* gauss, Input* vx_input, Input* vy_input, Input* vz_input);
@@ -211,4 +217,5 @@
 		ElementMatrix* CreateKMatrixCouplingPattynStokes(void);
 		ElementMatrix* CreateKMatrixDiagnosticHoriz(void);
+		ElementMatrix* CreateKMatrixAdjointHoriz(void);
 		ElementVector* CreateDVectorDiagnosticHoriz(void);
 		ElementVector* CreateDVectorDiagnosticStokes(void);
@@ -230,4 +237,8 @@
 		ElementMatrix* CreateKMatrixDiagnosticVertVolume(void);
 		ElementMatrix* CreateKMatrixDiagnosticVertSurface(void);
+		ElementMatrix* CreateJacobianDiagnosticHoriz(void);
+		ElementMatrix* CreateJacobianDiagnosticMacayeal2d(void);
+		ElementMatrix* CreateJacobianDiagnosticPattyn(void);
+		ElementMatrix* CreateJacobianDiagnosticStokes(void);
 		void           InputUpdateFromSolutionDiagnosticHoriz( double* solutiong);
 		void           InputUpdateFromSolutionDiagnosticMacAyeal( double* solutiong);
@@ -266,4 +277,7 @@
 		#ifdef _HAVE_CONTROL_
 		ElementVector* CreatePVectorAdjointHoriz(void);
+		ElementMatrix* CreateKMatrixAdjointMacAyeal2d(void);
+		ElementMatrix* CreateKMatrixAdjointPattyn(void);
+		ElementMatrix* CreateKMatrixAdjointStokes(void);
 		ElementVector* CreatePVectorAdjointMacAyeal(void);
 		ElementVector* CreatePVectorAdjointPattyn(void);
Index: /issm/trunk/src/c/objects/Elements/Tria.cpp
===================================================================
--- /issm/trunk/src/c/objects/Elements/Tria.cpp	(revision 11526)
+++ /issm/trunk/src/c/objects/Elements/Tria.cpp	(revision 11527)
@@ -336,6 +336,9 @@
 	switch(analysis_type){
 		#ifdef _HAVE_DIAGNOSTIC_
-		case DiagnosticHorizAnalysisEnum: case AdjointHorizAnalysisEnum:
+		case DiagnosticHorizAnalysisEnum:
 			Ke=CreateKMatrixDiagnosticMacAyeal();
+			break;
+		case AdjointHorizAnalysisEnum:
+			Ke=CreateKMatrixAdjointMacAyeal();
 			break;
 		case DiagnosticHutterAnalysisEnum:
@@ -888,4 +891,37 @@
 }
 /*}}}*/
+/*FUNCTION Tria::CreateJacobianMatrix{{{1*/
+void  Tria::CreateJacobianMatrix(Mat Jff){
+
+	/*retrieve parameters: */
+	ElementMatrix* Ke=NULL;
+	int analysis_type;
+	parameters->FindParam(&analysis_type,AnalysisTypeEnum);
+
+	/*Checks in debugging {{{2*/
+	_assert_(this->nodes && this->matice && this->matpar && this->parameters && this->inputs);
+	/*}}}*/
+
+	/*Skip if water element*/
+	if(IsOnWater()) return;
+
+	/*Just branch to the correct element stiffness matrix generator, according to the type of analysis we are carrying out: */
+	switch(analysis_type){
+#ifdef _HAVE_DIAGNOSTIC_
+		case DiagnosticHorizAnalysisEnum:
+			Ke=CreateJacobianDiagnosticMacayeal();
+			break;
+#endif
+		default:
+			_error_("analysis %i (%s) not supported yet",analysis_type,EnumToStringx(analysis_type));
+	}
+
+	/*Add to global matrix*/
+	if(Ke){
+		Ke->AddToGlobal(Jff);
+		delete Ke;
+	}
+}
+/*}}}*/
 /*FUNCTION Tria::ComputeBasalStress {{{1*/
 void  Tria::ComputeBasalStress(Vec eps){
@@ -938,10 +974,10 @@
 	
 	/*Add Stress tensor components into inputs*/
-	this->inputs->AddInput(new TriaVertexInput(StressTensorxxEnum,&sigma_xx[0]));
-	this->inputs->AddInput(new TriaVertexInput(StressTensorxyEnum,&sigma_xy[0]));
-	this->inputs->AddInput(new TriaVertexInput(StressTensorxzEnum,&sigma_xz[0]));
-	this->inputs->AddInput(new TriaVertexInput(StressTensoryyEnum,&sigma_yy[0]));
-	this->inputs->AddInput(new TriaVertexInput(StressTensoryzEnum,&sigma_yz[0]));
-	this->inputs->AddInput(new TriaVertexInput(StressTensorzzEnum,&sigma_zz[0]));
+	this->inputs->AddInput(new TriaP1Input(StressTensorxxEnum,&sigma_xx[0]));
+	this->inputs->AddInput(new TriaP1Input(StressTensorxyEnum,&sigma_xy[0]));
+	this->inputs->AddInput(new TriaP1Input(StressTensorxzEnum,&sigma_xz[0]));
+	this->inputs->AddInput(new TriaP1Input(StressTensoryyEnum,&sigma_yy[0]));
+	this->inputs->AddInput(new TriaP1Input(StressTensoryzEnum,&sigma_yz[0]));
+	this->inputs->AddInput(new TriaP1Input(StressTensorzzEnum,&sigma_zz[0]));
 
 	/*Clean up and return*/
@@ -1450,5 +1486,7 @@
 	
 	#ifdef _HAVE_CONTROL_
-	if(input->ObjectEnum()==ControlInputEnum) this->results->AddObject((Object*)((ControlInput*)input)->SpawnGradient(step,time));
+	if(input->ObjectEnum()==ControlInputEnum){
+		if(((ControlInput*)input)->gradient!=NULL) this->results->AddObject((Object*)((ControlInput*)input)->SpawnGradient(step,time));
+	}
 	#endif
 }
@@ -1516,5 +1554,5 @@
 						for(j=0;j<3;j++)cmmininputs[j]=iomodel->Data(InversionMinParametersEnum)[(tria_vertex_ids[j]-1)*num_control_type+i]/yts;
 						for(j=0;j<3;j++)cmmaxinputs[j]=iomodel->Data(InversionMaxParametersEnum)[(tria_vertex_ids[j]-1)*num_control_type+i]/yts;
-						this->inputs->AddInput(new ControlInput(BalancethicknessThickeningRateEnum,TriaVertexInputEnum,nodeinputs,cmmininputs,cmmaxinputs,i+1));
+						this->inputs->AddInput(new ControlInput(BalancethicknessThickeningRateEnum,TriaP1InputEnum,nodeinputs,cmmininputs,cmmaxinputs,i+1));
 					}
 					break;
@@ -1524,5 +1562,5 @@
 						for(j=0;j<3;j++)cmmininputs[j]=iomodel->Data(InversionMinParametersEnum)[(tria_vertex_ids[j]-1)*num_control_type+i]/yts;
 						for(j=0;j<3;j++)cmmaxinputs[j]=iomodel->Data(InversionMaxParametersEnum)[(tria_vertex_ids[j]-1)*num_control_type+i]/yts;
-						this->inputs->AddInput(new ControlInput(VxEnum,TriaVertexInputEnum,nodeinputs,cmmininputs,cmmaxinputs,i+1));
+						this->inputs->AddInput(new ControlInput(VxEnum,TriaP1InputEnum,nodeinputs,cmmininputs,cmmaxinputs,i+1));
 					}
 					break;
@@ -1532,5 +1570,5 @@
 						for(j=0;j<3;j++)cmmininputs[j]=iomodel->Data(InversionMinParametersEnum)[(tria_vertex_ids[j]-1)*num_control_type+i]/yts;
 						for(j=0;j<3;j++)cmmaxinputs[j]=iomodel->Data(InversionMaxParametersEnum)[(tria_vertex_ids[j]-1)*num_control_type+i]/yts;
-						this->inputs->AddInput(new ControlInput(VyEnum,TriaVertexInputEnum,nodeinputs,cmmininputs,cmmaxinputs,i+1));
+						this->inputs->AddInput(new ControlInput(VyEnum,TriaP1InputEnum,nodeinputs,cmmininputs,cmmaxinputs,i+1));
 					}
 					break;
@@ -1540,5 +1578,5 @@
 						for(j=0;j<3;j++)cmmininputs[j]=iomodel->Data(InversionMinParametersEnum)[(tria_vertex_ids[j]-1)*num_control_type+i];
 						for(j=0;j<3;j++)cmmaxinputs[j]=iomodel->Data(InversionMaxParametersEnum)[(tria_vertex_ids[j]-1)*num_control_type+i];
-						this->inputs->AddInput(new ControlInput(FrictionCoefficientEnum,TriaVertexInputEnum,nodeinputs,cmmininputs,cmmaxinputs,i+1));
+						this->inputs->AddInput(new ControlInput(FrictionCoefficientEnum,TriaP1InputEnum,nodeinputs,cmmininputs,cmmaxinputs,i+1));
 					}
 					break;
@@ -1559,5 +1597,5 @@
 		for(i=0;i<num_cm_responses;i++){
 			for(j=0;j<3;j++)nodeinputs[j]=iomodel->Data(InversionCostFunctionsCoefficientsEnum)[(tria_vertex_ids[j]-1)*num_cm_responses+i];
-			datasetinput->inputs->AddObject(new TriaVertexInput(InversionCostFunctionsCoefficientsEnum,nodeinputs));
+			datasetinput->inputs->AddObject(new TriaP1Input(InversionCostFunctionsCoefficientsEnum,nodeinputs));
 		}
 
@@ -1640,5 +1678,5 @@
 
 	/*Add input to the element: */
-	this->inputs->AddInput(new TriaVertexInput(enum_type,values));
+	this->inputs->AddInput(new TriaP1Input(enum_type,values));
 
 	/*Free ressources:*/
@@ -1705,7 +1743,7 @@
 
 	/*Add input to the element: */
-	this->inputs->AddInput(new TriaVertexInput(ThicknessEnum,newthickness));
-	this->inputs->AddInput(new TriaVertexInput(SurfaceEnum,newsurface));
-	this->inputs->AddInput(new TriaVertexInput(BedEnum,newbed));
+	this->inputs->AddInput(new TriaP1Input(ThicknessEnum,newthickness));
+	this->inputs->AddInput(new TriaP1Input(SurfaceEnum,newsurface));
+	this->inputs->AddInput(new TriaP1Input(BedEnum,newbed));
 
 	/*Free ressources:*/
@@ -1723,5 +1761,5 @@
 		case VertexEnum:
 
-			/*New TriaVertexInput*/
+			/*New TriaP1Input*/
 			double values[3];
 
@@ -1733,8 +1771,8 @@
 			/*update input*/
 			if (name==MaterialsRheologyBbarEnum || name==MaterialsRheologyBEnum){
-				matice->inputs->AddInput(new TriaVertexInput(name,values));
+				matice->inputs->AddInput(new TriaP1Input(name,values));
 			}
 			else{
-				this->inputs->AddInput(new TriaVertexInput(name,values));
+				this->inputs->AddInput(new TriaP1Input(name,values));
 			}
 			return;
@@ -1812,5 +1850,5 @@
 
 			/*create static input: */
-			this->inputs->AddInput(new TriaVertexInput(vector_enum,nodeinputs));
+			this->inputs->AddInput(new TriaP1Input(vector_enum,nodeinputs));
 		}
 		else if(M==numberofvertices+1){
@@ -1831,5 +1869,5 @@
 
 				if(t==0) transientinput=new TransientInput(vector_enum);
-				transientinput->AddTimeInput(new TriaVertexInput(vector_enum,nodeinputs),time);
+				transientinput->AddTimeInput(new TriaP1Input(vector_enum,nodeinputs),time);
 			}
 			this->inputs->AddInput(transientinput);
@@ -1881,4 +1919,5 @@
 				name==InversionVyObsEnum ||
 				name==FrictionCoefficientEnum ||
+				name==MaterialsRheologyBbarEnum ||
 				name==GradientEnum ||
 				name==OldGradientEnum ||
@@ -1985,5 +2024,5 @@
 			resultstimes[i]=elementresult->GetTime();
 			resultssteps[i]=elementresult->GetStep();
-			if(elementresult->ObjectEnum()==TriaVertexElementResultEnum){
+			if(elementresult->ObjectEnum()==TriaP1ElementResultEnum){
 				resultssizes[i]=P1Enum;
 			}
@@ -2067,5 +2106,5 @@
 	if(!this->IsFloating() && elementonshelf==true){
 		for(i=0;i<NUMVERTICES;i++)melting[i]=gl_melting_rate/yts;
-		this->inputs->AddInput(new TriaVertexInput(BasalforcingsMeltingRateEnum,&melting[0]));
+		this->inputs->AddInput(new TriaP1Input(BasalforcingsMeltingRateEnum,&melting[0]));
 	} 
 
@@ -2074,6 +2113,6 @@
 
 	/*Update inputs*/    
-	this->inputs->AddInput(new TriaVertexInput(SurfaceEnum,&s[0]));
-	this->inputs->AddInput(new TriaVertexInput(BedEnum,&b[0]));
+	this->inputs->AddInput(new TriaP1Input(SurfaceEnum,&s[0]));
+	this->inputs->AddInput(new TriaP1Input(BedEnum,&b[0]));
 }
 /*}}}*/
@@ -2162,4 +2201,10 @@
 		}
 	}
+}
+/*}}}*/
+/*FUNCTION Tria::PositiveDegreeDay{{{1*/
+void  Tria::PositiveDegreeDay(){
+
+	_error_("Not implemented yet");
 }
 /*}}}*/
@@ -2209,4 +2254,10 @@
 }
 /*}}}1*/
+/*FUNCTION Tria::SmearFunction {{{1*/
+void  Tria::SmearFunction(Vec smearedvector,double (*WeightFunction)(double distance,double radius),double radius){
+	_error_("not implemented yet");
+
+}
+/*}}}1*/
 /*FUNCTION Tria::SetCurrentConfiguration {{{1*/
 void  Tria::SetCurrentConfiguration(Elements* elementsin, Loads* loadsin, DataSet* nodesin, Materials* materialsin, Parameters* parametersin){
@@ -2392,22 +2443,22 @@
 			if(!iomodel->Data(VxEnum)){
 				for(i=0;i<3;i++)nodeinputs[i]=0;
-				this->inputs->AddInput(new TriaVertexInput(VxEnum,nodeinputs));
-				if(dakota_analysis) this->inputs->AddInput(new TriaVertexInput(QmuVxEnum,nodeinputs));
+				this->inputs->AddInput(new TriaP1Input(VxEnum,nodeinputs));
+				if(dakota_analysis) this->inputs->AddInput(new TriaP1Input(QmuVxEnum,nodeinputs));
 			}
 			if(!iomodel->Data(VyEnum)){
 				for(i=0;i<3;i++)nodeinputs[i]=0;
-				this->inputs->AddInput(new TriaVertexInput(VyEnum,nodeinputs));
-				if(dakota_analysis) this->inputs->AddInput(new TriaVertexInput(QmuVyEnum,nodeinputs));
+				this->inputs->AddInput(new TriaP1Input(VyEnum,nodeinputs));
+				if(dakota_analysis) this->inputs->AddInput(new TriaP1Input(QmuVyEnum,nodeinputs));
 			}
 			if(!iomodel->Data(VzEnum)){
 				for(i=0;i<3;i++)nodeinputs[i]=0;
-				this->inputs->AddInput(new TriaVertexInput(VzEnum,nodeinputs));
-				if(dakota_analysis) this->inputs->AddInput(new TriaVertexInput(QmuVzEnum,nodeinputs));
+				this->inputs->AddInput(new TriaP1Input(VzEnum,nodeinputs));
+				if(dakota_analysis) this->inputs->AddInput(new TriaP1Input(QmuVzEnum,nodeinputs));
 			}
 			if(!iomodel->Data(PressureEnum)){
 				for(i=0;i<3;i++)nodeinputs[i]=0;
 				if(dakota_analysis){
-					this->inputs->AddInput(new TriaVertexInput(PressureEnum,nodeinputs));
-					this->inputs->AddInput(new TriaVertexInput(QmuPressureEnum,nodeinputs));
+					this->inputs->AddInput(new TriaP1Input(PressureEnum,nodeinputs));
+					this->inputs->AddInput(new TriaP1Input(QmuPressureEnum,nodeinputs));
 				}
 			}
@@ -3021,4 +3072,70 @@
 }
 /*}}}*/
+/*FUNCTION Tria::CreateJacobianDiagnosticMacayeal{{{1*/
+ElementMatrix* Tria::CreateJacobianDiagnosticMacayeal(void){
+
+	/*Constants*/
+	const int    numdof=NDOF2*NUMVERTICES;
+
+	/*Intermediaries */
+	int        i,j,ig;
+	double     xyz_list[NUMVERTICES][3];
+	double     Jdet,thickness;
+	double     eps1dotdphii,eps1dotdphij;
+	double     eps2dotdphii,eps2dotdphij;
+	double     mu_prime;
+	double     epsilon[3];/* epsilon=[exx,eyy,exy];*/
+	double     eps1[2],eps2[2];
+	double     phi[NUMVERTICES];
+	double     dphi[2][NUMVERTICES];
+	GaussTria *gauss=NULL;
+
+	/*Initialize Jacobian with regular MacAyeal (first part of the Gateau derivative)*/
+	ElementMatrix* Ke=CreateKMatrixDiagnosticMacAyeal();
+
+	/*Retrieve all inputs and parameters*/
+	GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES);
+	Input* vx_input=inputs->GetInput(VxEnum);       _assert_(vx_input);
+	Input* vy_input=inputs->GetInput(VyEnum);       _assert_(vy_input);
+	Input* thickness_input=inputs->GetInput(ThicknessEnum); _assert_(thickness_input);
+
+	/* Start  looping on the number of gaussian points: */
+	gauss=new GaussTria(2);
+	for (ig=gauss->begin();ig<gauss->end();ig++){
+
+		gauss->GaussPoint(ig);
+
+		GetJacobianDeterminant2d(&Jdet, &xyz_list[0][0],gauss);
+		GetNodalFunctionsDerivatives(&dphi[0][0],&xyz_list[0][0],gauss);
+
+		thickness_input->GetInputValue(&thickness, gauss);
+		this->GetStrainRate2d(&epsilon[0],&xyz_list[0][0],gauss,vx_input,vy_input);
+		matice->GetViscosity2dDerivativeEpsSquare(&mu_prime,&epsilon[0]);
+		eps1[0]=2*epsilon[0]+epsilon[1];   eps2[0]=epsilon[2];
+		eps1[1]=epsilon[2];                eps2[1]=epsilon[0]+2*epsilon[1];
+
+		for(i=0;i<3;i++){
+			for(j=0;j<3;j++){
+				eps1dotdphii=eps1[0]*dphi[0][i]+eps1[1]*dphi[1][i];
+				eps1dotdphij=eps1[0]*dphi[0][j]+eps1[1]*dphi[1][j];
+				eps2dotdphii=eps2[0]*dphi[0][i]+eps2[1]*dphi[1][i];
+				eps2dotdphij=eps2[0]*dphi[0][j]+eps2[1]*dphi[1][j];
+
+				Ke->values[6*(2*i+0)+2*j+0]+=gauss->weight*Jdet*2*mu_prime*thickness*eps1dotdphij*eps1dotdphii;
+				Ke->values[6*(2*i+0)+2*j+1]+=gauss->weight*Jdet*2*mu_prime*thickness*eps2dotdphij*eps1dotdphii;
+				Ke->values[6*(2*i+1)+2*j+0]+=gauss->weight*Jdet*2*mu_prime*thickness*eps1dotdphij*eps2dotdphii;
+				Ke->values[6*(2*i+1)+2*j+1]+=gauss->weight*Jdet*2*mu_prime*thickness*eps2dotdphij*eps2dotdphii;
+			}
+		}
+	}
+
+	/*Transform Coordinate System*/
+	TransformStiffnessMatrixCoord(Ke,nodes,NUMVERTICES,XYEnum);
+
+	/*Clean up and return*/
+	delete gauss;
+	return Ke;
+}
+/*}}}*/
 /*FUNCTION Tria::GetSolutionFromInputsDiagnosticHoriz{{{1*/
 void  Tria::GetSolutionFromInputsDiagnosticHoriz(Vec solution){
@@ -3152,8 +3269,8 @@
 
 	/*Add vx and vy as inputs to the tria element: */
-	this->inputs->AddInput(new TriaVertexInput(VxEnum,vx));
-	this->inputs->AddInput(new TriaVertexInput(VyEnum,vy));
-	this->inputs->AddInput(new TriaVertexInput(VelEnum,vel));
-	this->inputs->AddInput(new TriaVertexInput(PressureEnum,pressure));
+	this->inputs->AddInput(new TriaP1Input(VxEnum,vx));
+	this->inputs->AddInput(new TriaP1Input(VyEnum,vy));
+	this->inputs->AddInput(new TriaP1Input(VelEnum,vel));
+	this->inputs->AddInput(new TriaP1Input(PressureEnum,pressure));
 
 	/*Free ressources:*/
@@ -3212,8 +3329,8 @@
 
 	/*Add vx and vy as inputs to the tria element: */
-	this->inputs->AddInput(new TriaVertexInput(VxEnum,vx));
-	this->inputs->AddInput(new TriaVertexInput(VyEnum,vy));
-	this->inputs->AddInput(new TriaVertexInput(VelEnum,vel));
-	this->inputs->AddInput(new TriaVertexInput(PressureEnum,pressure));
+	this->inputs->AddInput(new TriaP1Input(VxEnum,vx));
+	this->inputs->AddInput(new TriaP1Input(VyEnum,vy));
+	this->inputs->AddInput(new TriaP1Input(VelEnum,vel));
+	this->inputs->AddInput(new TriaP1Input(PressureEnum,pressure));
 
 	/*Free ressources:*/
@@ -3260,5 +3377,5 @@
 /*}}}*/
 /*FUNCTION Tria::ControlInputGetGradient{{{1*/
-void Tria::ControlInputGetGradient(Vec gradient,int enum_type){
+void Tria::ControlInputGetGradient(Vec gradient,int enum_type,int control_index){
 
 	int doflist1[NUMVERTICES];
@@ -3274,5 +3391,5 @@
 	if (input->ObjectEnum()!=ControlInputEnum) _error_("Input %s is not a ControlInput",EnumToStringx(enum_type));
 
-	this->GetDofList1(&doflist1[0]);
+	GradientIndexing(&doflist1[0],control_index);
 	((ControlInput*)input)->GetGradient(gradient,&doflist1[0]);
 
@@ -3295,5 +3412,5 @@
 }/*}}}*/
 /*FUNCTION Tria::ControlInputSetGradient{{{1*/
-void Tria::ControlInputSetGradient(double* gradient,int enum_type){
+void Tria::ControlInputSetGradient(double* gradient,int enum_type,int control_index){
 
 	int    doflist1[NUMVERTICES];
@@ -3311,7 +3428,7 @@
 	if (input->ObjectEnum()!=ControlInputEnum) _error_("Input %s is not a ControlInput",EnumToStringx(enum_type));
 
-	this->GetDofList1(&doflist1[0]);
+	GradientIndexing(&doflist1[0],control_index);
 	for(int i=0;i<NUMVERTICES;i++) grad_list[i]=gradient[doflist1[i]];
-	grad_input=new TriaVertexInput(GradientEnum,grad_list);
+	grad_input=new TriaP1Input(GradientEnum,grad_list);
 
 	((ControlInput*)input)->SetGradient(grad_input);
@@ -3319,5 +3436,5 @@
 }/*}}}*/
 /*FUNCTION Tria::Gradj {{{1*/
-void  Tria::Gradj(Vec gradient,int control_type){
+void  Tria::Gradj(Vec gradient,int control_type,int control_index){
 	/*dJ/dalpha = ∂L/∂alpha = ∂J/∂alpha + ∂/∂alpha(KU-F)*/
 
@@ -3328,17 +3445,17 @@
 	switch(control_type){
 		case FrictionCoefficientEnum:
-			GradjDragMacAyeal(gradient);
+			GradjDragMacAyeal(gradient,control_index);
 			break;
 		case MaterialsRheologyBbarEnum:
-			GradjBMacAyeal(gradient);
+			GradjBMacAyeal(gradient,control_index);
 			break;
 		case BalancethicknessThickeningRateEnum:
-			GradjDhDtBalancedthickness(gradient);
+			GradjDhDtBalancedthickness(gradient,control_index);
 			break;
 		case VxEnum:
-			GradjVxBalancedthickness(gradient);
+			GradjVxBalancedthickness(gradient,control_index);
 			break;
 		case VyEnum:
-			GradjVyBalancedthickness(gradient);
+			GradjVyBalancedthickness(gradient,control_index);
 			break;
 		default:
@@ -3365,8 +3482,8 @@
 			break;
 		case DragCoefficientAbsGradientEnum:
-			GradjDragGradient(gradient,resp);
+			GradjDragGradient(gradient,resp,control_index);
 			break;
 		case RheologyBbarAbsGradientEnum:
-			GradjBGradient(gradient,resp);
+			GradjBGradient(gradient,resp,control_index);
 			break;
 		default:
@@ -3378,5 +3495,5 @@
 /*}}}*/
 /*FUNCTION Tria::GradjBGradient{{{1*/
-void  Tria::GradjBGradient(Vec gradient, int weight_index){
+void  Tria::GradjBGradient(Vec gradient,int weight_index,int control_index){
 
 	int        i,ig;
@@ -3391,5 +3508,5 @@
 	/*Retrieve all inputs we will be needing: */
 	GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES);
-	GetDofList1(&doflist1[0]);
+	GradientIndexing(&doflist1[0],control_index);
 	Input* rheologyb_input=matice->inputs->GetInput(MaterialsRheologyBbarEnum); _assert_(rheologyb_input);
 	Input* weights_input=inputs->GetInput(InversionCostFunctionsCoefficientsEnum);                _assert_(weights_input);
@@ -3418,5 +3535,5 @@
 /*}}}*/
 /*FUNCTION Tria::GradjBMacAyeal{{{1*/
-void  Tria::GradjBMacAyeal(Vec gradient){
+void  Tria::GradjBMacAyeal(Vec gradient,int control_index){
 
 	/*Intermediaries*/
@@ -3433,12 +3550,12 @@
 	/* Get node coordinates and dof list: */
 	GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES);
-	GetDofList1(&doflist[0]);
+	GradientIndexing(&doflist[0],control_index);
 
 	/*Retrieve all inputs*/
-	Input* thickness_input=inputs->GetInput(ThicknessEnum);            _assert_(thickness_input);
-	Input* vx_input=inputs->GetInput(VxEnum);                          _assert_(vx_input);
-	Input* vy_input=inputs->GetInput(VyEnum);                          _assert_(vy_input);
-	Input* adjointx_input=inputs->GetInput(AdjointxEnum);              _assert_(adjointx_input);
-	Input* adjointy_input=inputs->GetInput(AdjointyEnum);              _assert_(adjointy_input);
+	Input* thickness_input=inputs->GetInput(ThicknessEnum);                     _assert_(thickness_input);
+	Input* vx_input=inputs->GetInput(VxEnum);                                   _assert_(vx_input);
+	Input* vy_input=inputs->GetInput(VyEnum);                                   _assert_(vy_input);
+	Input* adjointx_input=inputs->GetInput(AdjointxEnum);                       _assert_(adjointx_input);
+	Input* adjointy_input=inputs->GetInput(AdjointyEnum);                       _assert_(adjointy_input);
 	Input* rheologyb_input=matice->inputs->GetInput(MaterialsRheologyBbarEnum); _assert_(rheologyb_input);
 
@@ -3475,5 +3592,5 @@
 /*}}}*/
 /*FUNCTION Tria::GradjDragMacAyeal {{{1*/
-void  Tria::GradjDragMacAyeal(Vec gradient){
+void  Tria::GradjDragMacAyeal(Vec gradient,int control_index){
 
 	int        i,ig;
@@ -3496,5 +3613,5 @@
 	parameters->FindParam(&analysis_type,AnalysisTypeEnum);
 	GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES);
-	GetDofList1(&doflist1[0]);
+	GradientIndexing(&doflist1[0],control_index);
 
 	/*Build frictoin element, needed later: */
@@ -3502,8 +3619,8 @@
 
 	/*Retrieve all inputs we will be needing: */
-	Input* adjointx_input=inputs->GetInput(AdjointxEnum);               _assert_(adjointx_input);
-	Input* adjointy_input=inputs->GetInput(AdjointyEnum);               _assert_(adjointy_input);
-	Input* vx_input=inputs->GetInput(VxEnum);                           _assert_(vx_input);
-	Input* vy_input=inputs->GetInput(VyEnum);                           _assert_(vy_input);
+	Input* adjointx_input=inputs->GetInput(AdjointxEnum);                   _assert_(adjointx_input);
+	Input* adjointy_input=inputs->GetInput(AdjointyEnum);                   _assert_(adjointy_input);
+	Input* vx_input=inputs->GetInput(VxEnum);                               _assert_(vx_input);
+	Input* vy_input=inputs->GetInput(VyEnum);                               _assert_(vy_input);
 	Input* dragcoefficient_input=inputs->GetInput(FrictionCoefficientEnum); _assert_(dragcoefficient_input);
 
@@ -3562,5 +3679,5 @@
 /*}}}*/
 /*FUNCTION Tria::GradjDragGradient{{{1*/
-void  Tria::GradjDragGradient(Vec gradient, int weight_index){
+void  Tria::GradjDragGradient(Vec gradient, int weight_index,int control_index){
 
 	int        i,ig;
@@ -3576,5 +3693,5 @@
 	if(IsFloating())return;
 	GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES);
-	GetDofList1(&doflist1[0]);
+	GradientIndexing(&doflist1[0],control_index);
 	Input* dragcoefficient_input=inputs->GetInput(FrictionCoefficientEnum); _assert_(dragcoefficient_input);
 	Input* weights_input=inputs->GetInput(InversionCostFunctionsCoefficientsEnum);                 _assert_(weights_input);
@@ -3606,5 +3723,5 @@
 /*}}}*/
 /*FUNCTION Tria::GradjDhDtBalancedthickness{{{1*/
-void  Tria::GradjDhDtBalancedthickness(Vec gradient){
+void  Tria::GradjDhDtBalancedthickness(Vec gradient,int control_index){
 
 	/*Intermediaries*/
@@ -3613,7 +3730,6 @@
 	double gradient_g[NUMVERTICES];
 
-	GetDofList1(&doflist1[0]);
-
 	/*Compute Gradient*/
+	GradientIndexing(&doflist1[0],control_index);
 	GetInputListOnVertices(&lambda[0],AdjointEnum);
 	for(int i=0;i<NUMVERTICES;i++) gradient_g[i]=-lambda[i];
@@ -3623,5 +3739,5 @@
 /*}}}*/
 /*FUNCTION Tria::GradjVxBalancedthickness{{{1*/
-void  Tria::GradjVxBalancedthickness(Vec gradient){
+void  Tria::GradjVxBalancedthickness(Vec gradient,int control_index){
 
 	/*Intermediaries*/
@@ -3637,5 +3753,5 @@
 	/* Get node coordinates and dof list: */
 	GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES);
-	GetDofList1(&doflist1[0]);
+	GradientIndexing(&doflist1[0],control_index);
 
 	/*Retrieve all inputs we will be needing: */
@@ -3666,5 +3782,5 @@
 /*}}}*/
 /*FUNCTION Tria::GradjVyBalancedthickness{{{1*/
-void  Tria::GradjVyBalancedthickness(Vec gradient){
+void  Tria::GradjVyBalancedthickness(Vec gradient,int control_index){
 
 	/*Intermediaries*/
@@ -3680,5 +3796,5 @@
 	/* Get node coordinates and dof list: */
 	GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES);
-	GetDofList1(&doflist1[0]);
+	GradientIndexing(&doflist1[0],control_index);
 
 	/*Retrieve all inputs we will be needing: */
@@ -3705,4 +3821,18 @@
 	/*Clean up and return*/
 	delete gauss;
+}
+/*}}}*/
+/*FUNCTION Tria::GradientIndexing{{{1*/
+void  Tria::GradientIndexing(int* indexing,int control_index){
+
+	/*Get some parameters*/
+	int num_controls;
+	parameters->FindParam(&num_controls,InversionNumControlParametersEnum);
+
+	/*get gradient indices*/
+	for(int i=0;i<NUMVERTICES;i++){
+		indexing[i]=num_controls*this->nodes[i]->GetVertexDof() + control_index;
+	}
+
 }
 /*}}}*/
@@ -3743,5 +3873,5 @@
 
 		/*Tikhonov regularization: J = 1/2 ((dp/dx)^2 + (dp/dy)^2) */ 
-		//Jelem+=weight*1/2*(pow(dp[0],2.)+pow(dp[1],2.))*Jdet*gauss->weight;
+		Jelem+=weight*1/2*(pow(dp[0],2.)+pow(dp[1],2.))*Jdet*gauss->weight;
 	}
 
@@ -4219,4 +4349,5 @@
 	/*Clean up and return*/
 	delete gauss;
+	xfree((void**)&responses);
 	return pe;
 }
@@ -4614,5 +4745,5 @@
 
 		/*Tikhonov regularization: J = 1/2 ((dp/dx)^2 + (dp/dy)^2) */ 
-		//Jelem+=weight*1/2*(pow(dp[0],2.)+pow(dp[1],2.))*Jdet*gauss->weight;
+		Jelem+=weight*1/2*(pow(dp[0],2.)+pow(dp[1],2.))*Jdet*gauss->weight;
 	}
 
@@ -4644,4 +4775,74 @@
 }
 /*}}}*/
+/*FUNCTION Tria::CreateKMatrixAdjointMacAyeal{{{1*/
+ElementMatrix* Tria::CreateKMatrixAdjointMacAyeal(void){
+
+	/*Constants*/
+	const int    numdof=NDOF2*NUMVERTICES;
+
+	/*Intermediaries */
+	int        i,j,ig;
+	bool       incomplete_adjoint;
+	double     xyz_list[NUMVERTICES][3];
+	double     Jdet,thickness;
+	double     eps1dotdphii,eps1dotdphij;
+	double     eps2dotdphii,eps2dotdphij;
+	double     mu_prime;
+	double     epsilon[3];/* epsilon=[exx,eyy,exy];*/
+	double     eps1[2],eps2[2];
+	double     phi[NUMVERTICES];
+	double     dphi[2][NUMVERTICES];
+	GaussTria *gauss=NULL;
+
+	/*Initialize Jacobian with regular MacAyeal (first part of the Gateau derivative)*/
+	parameters->FindParam(&incomplete_adjoint,InversionIncompleteAdjointEnum);
+	ElementMatrix* Ke=CreateKMatrixDiagnosticMacAyeal();
+	if(incomplete_adjoint) return Ke;
+
+	/*Retrieve all inputs and parameters*/
+	GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES);
+	Input* vx_input=inputs->GetInput(VxEnum);       _assert_(vx_input);
+	Input* vy_input=inputs->GetInput(VyEnum);       _assert_(vy_input);
+	Input* thickness_input=inputs->GetInput(ThicknessEnum); _assert_(thickness_input);
+
+	/* Start  looping on the number of gaussian points: */
+	gauss=new GaussTria(2);
+	for (ig=gauss->begin();ig<gauss->end();ig++){
+
+		gauss->GaussPoint(ig);
+
+		GetJacobianDeterminant2d(&Jdet, &xyz_list[0][0],gauss);
+		GetNodalFunctionsDerivatives(&dphi[0][0],&xyz_list[0][0],gauss);
+
+		thickness_input->GetInputValue(&thickness, gauss);
+		this->GetStrainRate2d(&epsilon[0],&xyz_list[0][0],gauss,vx_input,vy_input);
+		matice->GetViscosity2dDerivativeEpsSquare(&mu_prime,&epsilon[0]);
+		eps1[0]=2*epsilon[0]+epsilon[1];   eps2[0]=epsilon[2];
+		eps1[1]=epsilon[2];                eps2[1]=epsilon[0]+2*epsilon[1];
+
+		for(i=0;i<3;i++){
+			for(j=0;j<3;j++){
+				eps1dotdphii=eps1[0]*dphi[0][i]+eps1[1]*dphi[1][i];
+				eps1dotdphij=eps1[0]*dphi[0][j]+eps1[1]*dphi[1][j];
+				eps2dotdphii=eps2[0]*dphi[0][i]+eps2[1]*dphi[1][i];
+				eps2dotdphij=eps2[0]*dphi[0][j]+eps2[1]*dphi[1][j];
+
+				Ke->values[6*(2*i+0)+2*j+0]+=gauss->weight*Jdet*2*mu_prime*thickness*eps1dotdphij*eps1dotdphii;
+				Ke->values[6*(2*i+0)+2*j+1]+=gauss->weight*Jdet*2*mu_prime*thickness*eps2dotdphij*eps1dotdphii;
+				Ke->values[6*(2*i+1)+2*j+0]+=gauss->weight*Jdet*2*mu_prime*thickness*eps1dotdphij*eps2dotdphii;
+				Ke->values[6*(2*i+1)+2*j+1]+=gauss->weight*Jdet*2*mu_prime*thickness*eps2dotdphij*eps2dotdphii;
+			}
+		}
+	}
+
+	/*Transform Coordinate System*/
+	TransformStiffnessMatrixCoord(Ke,nodes,NUMVERTICES,XYEnum);
+
+	/*Clean up and return*/
+	delete gauss;
+	//Ke->Transpose();
+	return Ke;
+}
+/*}}}*/
 /*FUNCTION Tria::InputUpdateFromSolutionAdjointHoriz {{{1*/
 void  Tria::InputUpdateFromSolutionAdjointHoriz(double* solution){
@@ -4672,6 +4873,6 @@
 
 	/*Add vx and vy as inputs to the tria element: */
-	this->inputs->AddInput(new TriaVertexInput(AdjointxEnum,lambdax));
-	this->inputs->AddInput(new TriaVertexInput(AdjointyEnum,lambday));
+	this->inputs->AddInput(new TriaP1Input(AdjointxEnum,lambdax));
+	this->inputs->AddInput(new TriaP1Input(AdjointyEnum,lambday));
 
 	/*Free ressources:*/
@@ -4702,8 +4903,70 @@
 
 	/*Add vx and vy as inputs to the tria element: */
-	this->inputs->AddInput(new TriaVertexInput(AdjointEnum,lambda));
+	this->inputs->AddInput(new TriaP1Input(AdjointEnum,lambda));
 
 	/*Free ressources:*/
 	xfree((void**)&doflist);
+}
+/*}}}*/
+/*FUNCTION Tria::GetVectorFromControlInputs{{{1*/
+void  Tria::GetVectorFromControlInputs(Vec vector,int control_enum,int control_index,const char* data){
+
+	int doflist1[NUMVERTICES];
+	Input *input=NULL;
+
+	/*Get out if this is not an element input*/
+	if(!IsInput(control_enum)) return;
+
+	/*Prepare index list*/
+	GradientIndexing(&doflist1[0],control_index);
+
+	/*Get input (either in element or material)*/
+	if(control_enum==MaterialsRheologyBbarEnum){
+		input=(Input*)matice->inputs->GetInput(control_enum); _assert_(input);
+	}
+	else{
+		input=(Input*)this->inputs->GetInput(control_enum);   _assert_(input);
+	}
+
+	/*Check that it is a ControlInput*/
+	if (input->ObjectEnum()!=ControlInputEnum){
+		_error_("input %s is not a ControlInput",EnumToStringx(control_enum));
+	}
+
+	((ControlInput*)input)->GetVectorFromInputs(vector,&doflist1[0],data);
+}
+/*}}}*/
+/*FUNCTION Tria::SetControlInputsFromVector{{{1*/
+void  Tria::SetControlInputsFromVector(double* vector,int control_enum,int control_index){
+
+	double  values[NUMVERTICES];
+	int     doflist1[NUMVERTICES];
+	Input  *input     = NULL;
+	Input  *new_input = NULL;
+
+	/*Get out if this is not an element input*/
+	if(!IsInput(control_enum)) return;
+
+	/*Prepare index list*/
+	GradientIndexing(&doflist1[0],control_index);
+
+	/*Get values on vertices*/
+	for (int i=0;i<NUMVERTICES;i++){
+		values[i]=vector[doflist1[i]];
+	}
+	new_input = new TriaP1Input(control_enum,values);
+
+	if(control_enum==MaterialsRheologyBbarEnum){
+		input=(Input*)matice->inputs->GetInput(control_enum); _assert_(input);
+	}
+	else{
+		input=(Input*)this->inputs->GetInput(control_enum);   _assert_(input);
+	}
+
+	if (input->ObjectEnum()!=ControlInputEnum){
+		_error_("input %s is not a ControlInput",EnumToStringx(control_enum));
+	}
+
+	((ControlInput*)input)->SetInput(new_input);
 }
 /*}}}*/
@@ -4762,6 +5025,6 @@
 
 	/*Add to inputs*/
-	this->inputs->AddInput(new TriaVertexInput(HydrologyWaterVxEnum,vx));
-	this->inputs->AddInput(new TriaVertexInput(HydrologyWaterVyEnum,vy));
+	this->inputs->AddInput(new TriaP1Input(HydrologyWaterVxEnum,vx));
+	this->inputs->AddInput(new TriaP1Input(HydrologyWaterVyEnum,vy));
 }
 /*}}}*/
@@ -4978,5 +5241,5 @@
 
 	/*Add input to the element: */
-	this->inputs->AddInput(new TriaVertexInput(WatercolumnEnum,values));
+	this->inputs->AddInput(new TriaP1Input(WatercolumnEnum,values));
 
 	/*Free ressources:*/
@@ -4999,5 +5262,5 @@
 		case VertexEnum:
 
-			/*New TriaVertexInput*/
+			/*New TriaP1Input*/
 			double values[3];
 
@@ -5072,12 +5335,12 @@
 
 					/*Add new inputs: */
-					this->inputs->AddInput(new TriaVertexInput(ThicknessEnum,thickness));
-					this->inputs->AddInput(new TriaVertexInput(BedEnum,bed));
-					this->inputs->AddInput(new TriaVertexInput(SurfaceEnum,surface));
+					this->inputs->AddInput(new TriaP1Input(ThicknessEnum,thickness));
+					this->inputs->AddInput(new TriaP1Input(BedEnum,bed));
+					this->inputs->AddInput(new TriaP1Input(SurfaceEnum,surface));
 
 					/*}}}*/
 					break;
 				default:
-					this->inputs->AddInput(new TriaVertexInput(name,values));
+					this->inputs->AddInput(new TriaP1Input(name,values));
 			}
 			break;
@@ -5131,5 +5394,5 @@
 
 				if(t==0) transientinput=new TransientInput(name);
-				transientinput->AddTimeInput(new TriaVertexInput(name,values),time);
+				transientinput->AddTimeInput(new TriaP1Input(name,values),time);
 				transientinput->Configure(parameters);
 			}
Index: /issm/trunk/src/c/objects/Elements/Tria.h
===================================================================
--- /issm/trunk/src/c/objects/Elements/Tria.h	(revision 11526)
+++ /issm/trunk/src/c/objects/Elements/Tria.h	(revision 11527)
@@ -84,4 +84,5 @@
 		void   CreateKMatrix(Mat Kff, Mat Kfs,Vec df);
 		void   CreatePVector(Vec pf);
+		void   CreateJacobianMatrix(Mat Jff);
 		int    GetNodeIndex(Node* node);
 		int    Sid();
@@ -106,4 +107,5 @@
 		void   MigrateGroundingLine(double* oldfloating,double* sheet_ungrounding);
 		void   PotentialSheetUngrounding(Vec potential_sheet_ungrounding);
+		void   PositiveDegreeDay(void);
 		void   RequestedOutput(int output_enum,int step,double time);
 		void   ListResultsInfo(int** results_enums,int** results_size,double** results_times,int** results_steps,int* num_results);
@@ -117,4 +119,5 @@
 		double TimeAdapt();
 		int*   GetHorizontalNeighboorSids(void);
+		void   SmearFunction(Vec smearedvector,double (*WeightFunction)(double distance,double radius),double radius);
 
 		#ifdef _HAVE_RESPONSES_
@@ -139,16 +142,19 @@
 		#ifdef _HAVE_CONTROL_
 		double DragCoefficientAbsGradient(bool process_units,int weight_index);
-		void   Gradj(Vec gradient,int control_type);
-		void   GradjBGradient(Vec gradient,int weight_index);
-		void   GradjBMacAyeal(Vec gradient);
-		void   GradjDragMacAyeal(Vec gradient);
-		void   GradjDragStokes(Vec gradient);
-		void   GradjDragGradient(Vec gradient,int weight_index);
-		void   GradjDhDtBalancedthickness(Vec gradient);
-		void   GradjVxBalancedthickness(Vec gradient);
-		void   GradjVyBalancedthickness(Vec gradient);
-		void   ControlInputGetGradient(Vec gradient,int enum_type);
+		void   GradientIndexing(int* indexing,int control_index);
+		void   Gradj(Vec gradient,int control_type,int control_index);
+		void   GradjBGradient(Vec gradient,int weight_index,int control_index);
+		void   GradjBMacAyeal(Vec gradient,int control_index);
+		void   GradjDragMacAyeal(Vec gradient,int control_index);
+		void   GradjDragStokes(Vec gradient,int control_index);
+		void   GradjDragGradient(Vec gradient,int weight_index,int control_index);
+		void   GradjDhDtBalancedthickness(Vec gradient,int control_index);
+		void   GradjVxBalancedthickness(Vec gradient,int control_index);
+		void   GradjVyBalancedthickness(Vec gradient,int control_index);
+		void   GetVectorFromControlInputs(Vec gradient,int control_enum,int control_index,const char* data);
+		void   SetControlInputsFromVector(double* vector,int control_enum,int control_index);
+		void   ControlInputGetGradient(Vec gradient,int enum_type,int control_index);
 		void   ControlInputScaleGradient(int enum_type,double scale);
-		void   ControlInputSetGradient(double* gradient,int enum_type);
+		void   ControlInputSetGradient(double* gradient,int enum_type,int control_index);
 		double RheologyBbarAbsGradient(bool process_units,int weight_index);
 		double ThicknessAbsMisfit(     bool process_units,int weight_index);
@@ -203,4 +209,5 @@
 		ElementVector* CreatePVectorDiagnosticMacAyeal(void);
 		ElementVector* CreatePVectorDiagnosticHutter(void);
+		ElementMatrix* CreateJacobianDiagnosticMacayeal(void);
 		void	  GetSolutionFromInputsDiagnosticHoriz(Vec solution);
 		void	  GetSolutionFromInputsDiagnosticHutter(Vec solution);
@@ -211,4 +218,5 @@
 		#ifdef _HAVE_CONTROL_
 		ElementMatrix* CreateKMatrixAdjointBalancethickness(void);
+		ElementMatrix* CreateKMatrixAdjointMacAyeal(void);
 		ElementVector* CreatePVectorAdjointHoriz(void);
 		ElementVector* CreatePVectorAdjointStokes(void);
Index: /issm/trunk/src/c/objects/Inputs/ControlInput.cpp
===================================================================
--- /issm/trunk/src/c/objects/Inputs/ControlInput.cpp	(revision 11526)
+++ /issm/trunk/src/c/objects/Inputs/ControlInput.cpp	(revision 11527)
@@ -35,15 +35,15 @@
 
 	switch(enum_input){
-		case TriaVertexInputEnum:
-			values     =new TriaVertexInput(enum_type,pvalues);
-			savedvalues=new TriaVertexInput(enum_type,pvalues);
-			minvalues  =new TriaVertexInput(enum_type,pmin);
-			maxvalues  =new TriaVertexInput(enum_type,pmax);
+		case TriaP1InputEnum:
+			values     =new TriaP1Input(enum_type,pvalues);
+			savedvalues=new TriaP1Input(enum_type,pvalues);
+			minvalues  =new TriaP1Input(enum_type,pmin);
+			maxvalues  =new TriaP1Input(enum_type,pmax);
 			break;
-		case PentaVertexInputEnum:
-			values     =new PentaVertexInput(enum_type,pvalues);
-			savedvalues=new PentaVertexInput(enum_type,pvalues);
-			minvalues  =new PentaVertexInput(enum_type,pmin);
-			maxvalues  =new PentaVertexInput(enum_type,pmax);
+		case PentaP1InputEnum:
+			values     =new PentaP1Input(enum_type,pvalues);
+			savedvalues=new PentaP1Input(enum_type,pvalues);
+			minvalues  =new PentaP1Input(enum_type,pmin);
+			maxvalues  =new PentaP1Input(enum_type,pmax);
 			break;
 		default:
@@ -206,10 +206,10 @@
 	if(flag){
 		memcpy(&input_enum_type,marshalled_dataset,sizeof(int)); marshalled_dataset+=sizeof(int);
-		if(input_enum_type==PentaVertexInputEnum){
-			values=new PentaVertexInput();
+		if(input_enum_type==PentaP1InputEnum){
+			values=new PentaP1Input();
 			values->Demarshall(&marshalled_dataset);
 		}
-		else if(input_enum_type==TriaVertexInputEnum){
-			values=new TriaVertexInput();
+		else if(input_enum_type==TriaP1InputEnum){
+			values=new TriaP1Input();
 			values->Demarshall(&marshalled_dataset);
 		}
@@ -224,10 +224,10 @@
 	if(flag){
 		memcpy(&input_enum_type,marshalled_dataset,sizeof(int)); marshalled_dataset+=sizeof(int);
-		if(input_enum_type==PentaVertexInputEnum){
-			savedvalues=new PentaVertexInput();
+		if(input_enum_type==PentaP1InputEnum){
+			savedvalues=new PentaP1Input();
 			savedvalues->Demarshall(&marshalled_dataset);
 		}
-		else if(input_enum_type==TriaVertexInputEnum){
-			savedvalues=new TriaVertexInput();
+		else if(input_enum_type==TriaP1InputEnum){
+			savedvalues=new TriaP1Input();
 			savedvalues->Demarshall(&marshalled_dataset);
 		}
@@ -242,10 +242,10 @@
 	if(flag){
 		memcpy(&input_enum_type,marshalled_dataset,sizeof(int)); marshalled_dataset+=sizeof(int);
-		if(input_enum_type==PentaVertexInputEnum){
-			minvalues=new PentaVertexInput();
+		if(input_enum_type==PentaP1InputEnum){
+			minvalues=new PentaP1Input();
 			minvalues->Demarshall(&marshalled_dataset);
 		}
-		else if(input_enum_type==TriaVertexInputEnum){
-			minvalues=new TriaVertexInput();
+		else if(input_enum_type==TriaP1InputEnum){
+			minvalues=new TriaP1Input();
 			minvalues->Demarshall(&marshalled_dataset);
 		}
@@ -260,10 +260,10 @@
 	if(flag){
 		memcpy(&input_enum_type,marshalled_dataset,sizeof(int)); marshalled_dataset+=sizeof(int);
-		if(input_enum_type==PentaVertexInputEnum){
-			maxvalues=new PentaVertexInput();
+		if(input_enum_type==PentaP1InputEnum){
+			maxvalues=new PentaP1Input();
 			maxvalues->Demarshall(&marshalled_dataset);
 		}
-		else if(input_enum_type==TriaVertexInputEnum){
-			maxvalues=new TriaVertexInput();
+		else if(input_enum_type==TriaP1InputEnum){
+			maxvalues=new TriaP1Input();
 			maxvalues->Demarshall(&marshalled_dataset);
 		}
@@ -278,10 +278,10 @@
 	if(flag){
 		memcpy(&input_enum_type,marshalled_dataset,sizeof(int)); marshalled_dataset+=sizeof(int);
-		if(input_enum_type==PentaVertexInputEnum){
-			gradient=new PentaVertexInput();
+		if(input_enum_type==PentaP1InputEnum){
+			gradient=new PentaP1Input();
 			gradient->Demarshall(&marshalled_dataset);
 		}
-		else if(input_enum_type==TriaVertexInputEnum){
-			gradient=new TriaVertexInput();
+		else if(input_enum_type==TriaP1InputEnum){
+			gradient=new TriaP1Input();
 			gradient->Demarshall(&marshalled_dataset);
 		}
@@ -386,4 +386,11 @@
 
 }/*}}}*/
+/*FUNCTION ControlInput::SetInput{{{1*/
+void ControlInput::SetInput(Input* in_input){
+
+	delete values; this->values=in_input;
+	this->SaveValue(); //because this is what SpawnResult saves FIXME
+
+}/*}}}*/
 /*FUNCTION ControlInput::SpawnResult{{{1*/
 ElementResult* ControlInput::SpawnResult(int step, double time){
@@ -396,9 +403,32 @@
 /*FUNCTION ControlInput::SpawnGradient{{{1*/
 ElementResult* ControlInput::SpawnGradient(int step, double time){
+	_assert_(gradient);
 	return gradient->SpawnResult(step,time);
 }/*}}}*/
-/*FUNCTION ControlInput::GetInputValue(bool* pvalue){{{1*/
+/*FUNCTION ControlInput::GetVectorFromInputs(Vec vector,int* doflist){{{1*/
 void ControlInput::GetVectorFromInputs(Vec vector,int* doflist){
 	values->GetVectorFromInputs(vector,doflist);
+}/*}}}*/
+/*FUNCTION ControlInput::GetVectorFromInputs(Vec vector,int* doflist,const char* data){{{1*/
+void ControlInput::GetVectorFromInputs(Vec vector,int* doflist,const char* data){
+	 if(strcmp(data,"value")==0){
+		 _assert_(values);
+		 values->GetVectorFromInputs(vector,doflist);
+	 }
+	 else if (strcmp(data,"lowerbound")==0){
+		 _assert_(minvalues);
+		 minvalues->GetVectorFromInputs(vector,doflist);
+	 }
+	 else if (strcmp(data,"upperbound")==0){
+		 _assert_(maxvalues);
+		 maxvalues->GetVectorFromInputs(vector,doflist);
+	 }
+	 else if (strcmp(data,"gradient")==0){
+		 _assert_(gradient);
+		 gradient->GetVectorFromInputs(vector,doflist);
+	 }
+	 else{
+		 _error_("Data %s not supported yet",data);
+	 }
 }/*}}}*/
 /*FUNCTION ControlInput::GetInputAverage(double* pvalue){{{1*/
Index: /issm/trunk/src/c/objects/Inputs/ControlInput.h
===================================================================
--- /issm/trunk/src/c/objects/Inputs/ControlInput.h	(revision 11526)
+++ /issm/trunk/src/c/objects/Inputs/ControlInput.h	(revision 11527)
@@ -54,4 +54,5 @@
 		/*}}}*/
 		/*numerics: {{{1*/
+		void SetInput(Input* in_input);
 		void GetInputValue(bool* pvalue);
 		void GetInputValue(int* pvalue);
@@ -86,4 +87,5 @@
 		void Extrude(void);
 		void VerticallyIntegrate(Input* thickness_input);
+		void GetVectorFromInputs(Vec vector,int* doflist,const char* data);
 		void GetVectorFromInputs(Vec vector,int* doflist);
 		void GetValuesPtr(double** pvalues,int* pnum_values){_error_("not implemented yet");};
Index: /issm/trunk/src/c/objects/Inputs/DoubleInput.cpp
===================================================================
--- /issm/trunk/src/c/objects/Inputs/DoubleInput.cpp	(revision 11526)
+++ /issm/trunk/src/c/objects/Inputs/DoubleInput.cpp	(revision 11527)
@@ -340,5 +340,5 @@
 	switch(thickness_input->ObjectEnum()){
 
-		case PentaVertexInputEnum:
+		case PentaP1InputEnum:
 			thickness_input->GetInputAverage(&thickness_value);
 			this->value=this->value*thickness_value;
Index: /issm/trunk/src/c/objects/Inputs/PentaP1Input.cpp
===================================================================
--- /issm/trunk/src/c/objects/Inputs/PentaP1Input.cpp	(revision 11527)
+++ /issm/trunk/src/c/objects/Inputs/PentaP1Input.cpp	(revision 11527)
@@ -0,0 +1,680 @@
+/*!\file PentaP1Input.c
+ * \brief: implementation of the PentaP1Input object
+ */
+
+#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 "../../EnumDefinitions/EnumDefinitions.h"
+#include "../../shared/shared.h"
+#include "../../Container/Container.h"
+#include "../../include/include.h"
+
+/*PentaP1Input constructors and destructor*/
+/*FUNCTION PentaP1Input::PentaP1Input(){{{1*/
+PentaP1Input::PentaP1Input(){
+	return;
+}
+/*}}}*/
+/*FUNCTION PentaP1Input::PentaP1Input(int in_enum_type,double* values){{{1*/
+PentaP1Input::PentaP1Input(int in_enum_type,double* in_values)
+		:PentaRef(1)
+{
+
+	/*Set PentaRef*/
+	this->SetElementType(P1Enum,0);
+	this->element_type=P1Enum;
+
+	enum_type=in_enum_type;
+	values[0]=in_values[0];
+	values[1]=in_values[1];
+	values[2]=in_values[2];
+	values[3]=in_values[3];
+	values[4]=in_values[4];
+	values[5]=in_values[5];
+}
+/*}}}*/
+/*FUNCTION PentaP1Input::~PentaP1Input(){{{1*/
+PentaP1Input::~PentaP1Input(){
+	return;
+}
+/*}}}*/
+
+/*Object virtual functions definitions:*/
+/*FUNCTION PentaP1Input::Echo {{{1*/
+void PentaP1Input::Echo(void){
+	this->DeepEcho();
+}
+/*}}}*/
+/*FUNCTION PentaP1Input::DeepEcho{{{1*/
+void PentaP1Input::DeepEcho(void){
+
+	printf("PentaP1Input:\n");
+	printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
+	printf("   values: [%g %g %g %g %g %g]\n",this->values[0],this->values[1],this->values[2],this->values[3],this->values[4],this->values[5]);
+}
+/*}}}*/
+/*FUNCTION PentaP1Input::Id{{{1*/
+int    PentaP1Input::Id(void){ return -1; }
+/*}}}*/
+/*FUNCTION PentaP1Input::MyRank{{{1*/
+int    PentaP1Input::MyRank(void){ 
+	extern int my_rank;
+	return my_rank; 
+}
+/*}}}*/
+#ifdef _SERIAL_
+/*FUNCTION PentaP1Input::Marshall{{{1*/
+void  PentaP1Input::Marshall(char** pmarshalled_dataset){
+
+	char* marshalled_dataset=NULL;
+	int   enum_value=0;
+
+	/*recover marshalled_dataset: */
+	marshalled_dataset=*pmarshalled_dataset;
+
+	/*get enum value of PentaP1Input: */
+	enum_value=PentaP1InputEnum;
+	
+	/*marshall enum: */
+	memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);
+	
+	/*marshall PentaP1Input data: */
+	memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
+	memcpy(marshalled_dataset,&values,sizeof(values));marshalled_dataset+=sizeof(values);
+
+	*pmarshalled_dataset=marshalled_dataset;
+}
+/*}}}*/
+/*FUNCTION PentaP1Input::MarshallSize{{{1*/
+int   PentaP1Input::MarshallSize(){
+	
+	return sizeof(values)+
+		+sizeof(enum_type)+
+		+sizeof(int); //sizeof(int) for enum value
+}
+/*}}}*/
+/*FUNCTION PentaP1Input::Demarshall{{{1*/
+void  PentaP1Input::Demarshall(char** pmarshalled_dataset){
+
+	char* marshalled_dataset=NULL;
+	int   i;
+
+	/*recover marshalled_dataset: */
+	marshalled_dataset=*pmarshalled_dataset;
+
+	/*this time, no need to get enum type, the pointer directly points to the beginning of the 
+	 *object data (thanks to DataSet::Demarshall):*/
+	memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
+	memcpy(&values,marshalled_dataset,sizeof(values));marshalled_dataset+=sizeof(values);
+
+	/*return: */
+	*pmarshalled_dataset=marshalled_dataset;
+	return;
+}
+/*}}}*/
+#endif
+/*FUNCTION PentaP1Input::ObjectEnum{{{1*/
+int PentaP1Input::ObjectEnum(void){
+
+	return PentaP1InputEnum;
+
+}
+/*}}}*/
+	
+/*PentaP1Input management*/
+/*FUNCTION PentaP1Input::copy{{{1*/
+Object* PentaP1Input::copy() {
+	
+	return new PentaP1Input(this->enum_type,this->values);
+
+}
+/*}}}*/
+/*FUNCTION PentaP1Input::InstanceEnum{{{1*/
+int PentaP1Input::InstanceEnum(void){
+
+	return this->enum_type;
+
+}
+/*}}}*/
+/*FUNCTION PentaP1Input::SpawnTriaInput{{{1*/
+Input* PentaP1Input::SpawnTriaInput(int* indices){
+
+	/*output*/
+	TriaP1Input* outinput=NULL;
+	double newvalues[3];
+
+	/*Loop over the new indices*/
+	for(int i=0;i<3;i++){
+
+		/*Check index value*/
+		_assert_(indices[i]>=0 && indices[i]<6);
+
+		/*Assign value to new input*/
+		newvalues[i]=this->values[indices[i]];
+	}
+
+	/*Create new Tria input*/
+	outinput=new TriaP1Input(this->enum_type,&newvalues[0]);
+
+	/*Assign output*/
+	return outinput;
+
+}
+/*}}}*/
+/*FUNCTION PentaP1Input::SpawnResult{{{1*/
+ElementResult* PentaP1Input::SpawnResult(int step, double time){
+
+	return new PentaP1ElementResult(this->enum_type,this->values,step,time);
+
+}
+/*}}}*/
+
+/*Object functions*/
+/*FUNCTION PentaP1Input::GetInputValue(double* pvalue,GaussPenta* gauss){{{1*/
+void PentaP1Input::GetInputValue(double* pvalue,GaussPenta* gauss){
+
+	/*Call PentaRef function*/
+	PentaRef::GetInputValue(pvalue,&values[0],gauss);
+
+}
+/*}}}*/
+/*FUNCTION PentaP1Input::GetInputDerivativeValue(double* p, double* xyz_list, GaussPenta* gauss){{{1*/
+void PentaP1Input::GetInputDerivativeValue(double* p, double* xyz_list, GaussPenta* gauss){
+
+	/*Call PentaRef function*/
+	PentaRef::GetInputDerivativeValue(p,&values[0],xyz_list,gauss);
+}
+/*}}}*/
+/*FUNCTION PentaP1Input::GetVxStrainRate3d{{{1*/
+void PentaP1Input::GetVxStrainRate3d(double* epsilonvx,double* xyz_list, GaussPenta* gauss){
+	int i,j;
+
+	const int numnodes=6;
+	const int DOFVELOCITY=3;
+	double B[8][27];
+	double B_reduced[6][DOFVELOCITY*numnodes];
+	double velocity[numnodes][DOFVELOCITY];
+
+	/*Get B matrix: */
+	GetBStokes(&B[0][0], xyz_list, gauss);
+	/*Create a reduced matrix of B to get rid of pressure */
+	for (i=0;i<6;i++){
+		for (j=0;j<3;j++){
+			B_reduced[i][j]=B[i][j];
+		}
+		for (j=4;j<7;j++){
+			B_reduced[i][j-1]=B[i][j];
+		}
+		for (j=8;j<11;j++){
+			B_reduced[i][j-2]=B[i][j];
+		}
+		for (j=12;j<15;j++){
+			B_reduced[i][j-3]=B[i][j];
+		}
+		for (j=16;j<19;j++){
+			B_reduced[i][j-4]=B[i][j];
+		}
+		for (j=20;j<23;j++){
+			B_reduced[i][j-5]=B[i][j];
+		}
+	}
+
+	/*Here, we are computing the strain rate of (vx,0,0)*/
+	for(i=0;i<numnodes;i++){
+		velocity[i][0]=this->values[i];
+		velocity[i][1]=0.0;
+		velocity[i][2]=0.0;
+	}
+	/*Multiply B by velocity, to get strain rate: */
+	MatrixMultiply(&B_reduced[0][0],6,DOFVELOCITY*numnodes,0,&velocity[0][0],DOFVELOCITY*numnodes,1,0,epsilonvx,0);
+
+}
+/*}}}*/
+/*FUNCTION PentaP1Input::GetVyStrainRate3d{{{1*/
+void PentaP1Input::GetVyStrainRate3d(double* epsilonvy,double* xyz_list, GaussPenta* gauss){
+	int i,j;
+
+	const int numnodes=6;
+	const int DOFVELOCITY=3;
+	double B[8][27];
+	double B_reduced[6][DOFVELOCITY*numnodes];
+	double velocity[numnodes][DOFVELOCITY];
+
+	/*Get B matrix: */
+	GetBStokes(&B[0][0], xyz_list, gauss);
+	/*Create a reduced matrix of B to get rid of pressure */
+	for (i=0;i<6;i++){
+		for (j=0;j<3;j++){
+			B_reduced[i][j]=B[i][j];
+		}
+		for (j=4;j<7;j++){
+			B_reduced[i][j-1]=B[i][j];
+		}
+		for (j=8;j<11;j++){
+			B_reduced[i][j-2]=B[i][j];
+		}
+		for (j=12;j<15;j++){
+			B_reduced[i][j-3]=B[i][j];
+		}
+		for (j=16;j<19;j++){
+			B_reduced[i][j-4]=B[i][j];
+		}
+		for (j=20;j<23;j++){
+			B_reduced[i][j-5]=B[i][j];
+		}
+	}
+
+	/*Here, we are computing the strain rate of (0,vy,0)*/
+	for(i=0;i<numnodes;i++){
+		velocity[i][0]=0.0;
+		velocity[i][1]=this->values[i];
+		velocity[i][2]=0.0;
+	}
+	/*Multiply B by velocity, to get strain rate: */
+	MatrixMultiply(&B_reduced[0][0],6,DOFVELOCITY*numnodes,0,&velocity[0][0],DOFVELOCITY*numnodes,1,0,epsilonvy,0);
+
+}
+/*}}}*/
+/*FUNCTION PentaP1Input::GetVzStrainRate3d{{{1*/
+void PentaP1Input::GetVzStrainRate3d(double* epsilonvz,double* xyz_list, GaussPenta* gauss){
+	int i,j;
+
+	const int numnodes=6;
+	const int DOFVELOCITY=3;
+	double B[8][27];
+	double B_reduced[6][DOFVELOCITY*numnodes];
+	double velocity[numnodes][DOFVELOCITY];
+
+	/*Get B matrix: */
+	GetBStokes(&B[0][0], xyz_list, gauss);
+	/*Create a reduced matrix of B to get rid of pressure */
+	for (i=0;i<6;i++){
+		for (j=0;j<3;j++){
+			B_reduced[i][j]=B[i][j];
+		}
+		for (j=4;j<7;j++){
+			B_reduced[i][j-1]=B[i][j];
+		}
+		for (j=8;j<11;j++){
+			B_reduced[i][j-2]=B[i][j];
+		}
+		for (j=12;j<15;j++){
+			B_reduced[i][j-3]=B[i][j];
+		}
+		for (j=16;j<19;j++){
+			B_reduced[i][j-4]=B[i][j];
+		}
+		for (j=20;j<23;j++){
+			B_reduced[i][j-5]=B[i][j];
+		}
+	}
+
+	/*Here, we are computing the strain rate of (0,0,vz)*/
+	for(i=0;i<numnodes;i++){
+		velocity[i][0]=0.0;
+		velocity[i][1]=0.0;
+		velocity[i][2]=this->values[i];
+	}
+
+	/*Multiply B by velocity, to get strain rate: */
+	MatrixMultiply(&B_reduced[0][0],6,DOFVELOCITY*numnodes,0,&velocity[0][0],DOFVELOCITY*numnodes,1,0,epsilonvz,0);
+
+}
+/*}}}*/
+/*FUNCTION PentaP1Input::GetVxStrainRate3dPattyn{{{1*/
+void PentaP1Input::GetVxStrainRate3dPattyn(double* epsilonvx,double* xyz_list, GaussPenta* gauss){
+
+	int i;
+	const int numnodes=6;
+	double B[5][NDOF2*numnodes];
+	double velocity[numnodes][NDOF2];
+
+	/*Get B matrix: */
+	GetBPattyn(&B[0][0], xyz_list, gauss);
+
+	/*Here, we are computing the strain rate of (vx,0)*/
+	for(i=0;i<numnodes;i++){
+		velocity[i][0]=this->values[i];
+		velocity[i][1]=0.0;
+	}
+
+	/*Multiply B by velocity, to get strain rate: */
+	MatrixMultiply( &B[0][0],5,NDOF2*numnodes,0,
+				&velocity[0][0],NDOF2*numnodes,1,0,
+				epsilonvx,0);
+
+}
+/*}}}*/
+/*FUNCTION PentaP1Input::GetVyStrainRate3dPattyn{{{1*/
+void PentaP1Input::GetVyStrainRate3dPattyn(double* epsilonvy,double* xyz_list, GaussPenta* gauss){
+
+	int i;
+	const int numnodes=6;
+	double B[5][NDOF2*numnodes];
+	double velocity[numnodes][NDOF2];
+
+	/*Get B matrix: */
+	GetBPattyn(&B[0][0], xyz_list, gauss);
+
+	/*Here, we are computing the strain rate of (0,vy)*/
+	for(i=0;i<numnodes;i++){
+		velocity[i][0]=0.0;
+		velocity[i][1]=this->values[i];
+	}
+
+	/*Multiply B by velocity, to get strain rate: */
+	MatrixMultiply( &B[0][0],5,NDOF2*numnodes,0,
+				&velocity[0][0],NDOF2*numnodes,1,0,
+				epsilonvy,0);
+
+}
+/*}}}*/
+/*FUNCTION PentaP1Input::ChangeEnum{{{1*/
+void PentaP1Input::ChangeEnum(int newenumtype){
+	this->enum_type=newenumtype;
+}
+/*}}}*/
+/*FUNCTION PentaP1Input::GetInputAverage{{{1*/
+void PentaP1Input::GetInputAverage(double* pvalue){
+	*pvalue=1./6.*(values[0]+values[1]+values[2]+values[3]+values[4]+values[5]);
+}
+/*}}}*/
+
+/*Intermediary*/
+/*FUNCTION PentaP1Input::SquareMin{{{1*/
+void PentaP1Input::SquareMin(double* psquaremin, bool process_units,Parameters* parameters){
+
+	int i;
+	const int numnodes=6;
+	double valuescopy[numnodes];
+	double squaremin;
+
+	/*First,  copy values, to process units if requested: */
+	for(i=0;i<numnodes;i++)valuescopy[i]=this->values[i];
+
+	/*Process units if requested: */
+	if(process_units)UnitConversion(&valuescopy[0],numnodes,IuToExtEnum,enum_type);
+
+	/*Now, figure out minimum of valuescopy: */
+	squaremin=pow(valuescopy[0],2);
+	for(i=1;i<numnodes;i++){
+		if(pow(valuescopy[i],2)<squaremin)squaremin=pow(valuescopy[i],2);
+	}
+	/*Assign output pointers:*/
+	*psquaremin=squaremin;
+}
+/*}}}*/
+/*FUNCTION PentaP1Input::ConstrainMin{{{1*/
+void PentaP1Input::ConstrainMin(double minimum){
+	
+	int i;
+	const int numnodes=6;
+
+	for(i=0;i<numnodes;i++) if (values[i]<minimum) values[i]=minimum;
+}
+/*}}}*/
+/*FUNCTION PentaP1Input::InfinityNorm{{{1*/
+double PentaP1Input::InfinityNorm(void){
+
+	/*Output*/
+	const int numnodes=6;
+	double norm=0;
+
+	for(int i=0;i<numnodes;i++) if(fabs(values[i])>norm) norm=fabs(values[i]);
+	return norm;
+}
+/*}}}*/
+/*FUNCTION PentaP1Input::Max{{{1*/
+double PentaP1Input::Max(void){
+
+	const int numnodes=6;
+	double    max=values[0];
+
+	for(int i=1;i<numnodes;i++){
+		if(values[i]>max) max=values[i];
+	}
+	return max;
+}
+/*}}}*/
+/*FUNCTION PentaP1Input::MaxAbs{{{1*/
+double PentaP1Input::MaxAbs(void){
+
+	const int numnodes=6;
+	double    max=fabs(values[0]);
+
+	for(int i=1;i<numnodes;i++){
+		if(fabs(values[i])>max) max=fabs(values[i]);
+	}
+	return max;
+}
+/*}}}*/
+/*FUNCTION PentaP1Input::Min{{{1*/
+double PentaP1Input::Min(void){
+
+	const int numnodes=6;
+	double    min=values[0];
+
+	for(int i=1;i<numnodes;i++){
+		if(values[i]<min) min=values[i];
+	}
+	return min;
+}
+/*}}}*/
+/*FUNCTION PentaP1Input::MinAbs{{{1*/
+double PentaP1Input::MinAbs(void){
+
+	const int numnodes=6;
+	double    min=fabs(values[0]);
+
+	for(int i=1;i<numnodes;i++){
+		if(fabs(values[i])<min) min=fabs(values[i]);
+	}
+	return min;
+}
+/*}}}*/
+/*FUNCTION PentaP1Input::Scale{{{1*/
+void PentaP1Input::Scale(double scale_factor){
+	
+	int i;
+	const int numnodes=6;
+
+	for(i=0;i<numnodes;i++)values[i]=values[i]*scale_factor;
+}
+/*}}}*/
+/*FUNCTION PentaP1Input::AXPY{{{1*/
+void PentaP1Input::AXPY(Input* xinput,double scalar){
+
+	int i;
+	const int numnodes=6;
+
+	/*xinput is of the same type, so cast it: */
+
+	/*Carry out the AXPY operation depending on type:*/
+	switch(xinput->ObjectEnum()){
+
+		case PentaP1InputEnum:{
+			PentaP1Input* cast_input=(PentaP1Input*)xinput;
+			for(i=0;i<numnodes;i++)this->values[i]=this->values[i]+scalar*(cast_input->values[i]);}
+			return;
+		case ControlInputEnum:{
+			ControlInput* cont_input=(ControlInput*)xinput;
+			if(cont_input->values->ObjectEnum()!=PentaP1InputEnum) _error_("not supported yet");
+			PentaP1Input* cast_input=(PentaP1Input*)cont_input->values;
+			for(i=0;i<numnodes;i++)this->values[i]=this->values[i]+scalar*(cast_input->values[i]);}
+			return;
+		default:
+			_error_("not implemented yet");
+	}
+
+}
+/*}}}*/
+/*FUNCTION PentaP1Input::Constrain{{{1*/
+void PentaP1Input::Constrain(double cm_min, double cm_max){
+
+	int i;
+	const int numnodes=6;
+		
+	if(!isnan(cm_min)) for(i=0;i<numnodes;i++)if (this->values[i]<cm_min)this->values[i]=cm_min;
+	if(!isnan(cm_max)) for(i=0;i<numnodes;i++)if (this->values[i]>cm_max)this->values[i]=cm_max;
+
+}
+/*}}}*/
+/*FUNCTION PentaP1Input::Extrude{{{1*/
+void PentaP1Input::Extrude(void){
+
+	int i;
+
+	/*First 3 values copied on 3 last values*/
+	for(i=0;i<3;i++) this->values[3+i]=this->values[i];
+}
+/*}}}*/
+/*FUNCTION PentaP1Input::VerticallyIntegrate{{{1*/
+void PentaP1Input::VerticallyIntegrate(Input* thickness_input){
+
+	/*Intermediaries*/
+	int i;
+	const int  numnodes = 6;
+	int        num_thickness_values;
+	double    *thickness_values = NULL;
+
+	/*Check that input provided is a thickness*/
+	if (thickness_input->InstanceEnum()!=ThicknessEnum) _error_("Input provided is not a Thickness (enum_type is %s)",EnumToStringx(thickness_input->InstanceEnum()));
+
+	/*Get Thickness value pointer*/
+	thickness_input->GetValuesPtr(&thickness_values,&num_thickness_values);
+
+	/*vertically integrate depending on type:*/
+	switch(thickness_input->ObjectEnum()){
+
+		case PentaP1InputEnum:
+			for(i=0;i<3;i++){
+				this->values[i]=0.5*(this->values[i]+this->values[i+3]) * thickness_values[i];
+				this->values[i+3]=this->values[i];
+			}
+			return;
+
+		default:
+			_error_("not implemented yet");
+	}
+}
+/*}}}*/
+/*FUNCTION PentaP1Input::PointwiseDivide{{{1*/
+Input* PentaP1Input::PointwiseDivide(Input* inputB){
+
+	/*Ouput*/
+	PentaP1Input* outinput=NULL;
+
+	/*Intermediaries*/
+	int               i;
+	PentaP1Input *xinputB     = NULL;
+	int               B_numvalues;
+	const int         numnodes    = 6;
+	double            AdotBvalues[numnodes];
+
+	/*Check that inputB is of the same type*/
+	if (inputB->ObjectEnum()!=PentaP1InputEnum) _error_("Operation not permitted because inputB is of type %s",EnumToStringx(inputB->ObjectEnum()));
+	xinputB=(PentaP1Input*)inputB;
+
+	/*Create point wise sum*/
+	for(i=0;i<numnodes;i++){
+		_assert_(xinputB->values[i]!=0);
+		AdotBvalues[i]=this->values[i]/xinputB->values[i];
+	}
+
+	/*Create new Penta vertex input (copy of current input)*/
+	outinput=new PentaP1Input(this->enum_type,&AdotBvalues[0]);
+
+	/*Return output pointer*/
+	return outinput;
+
+}
+/*}}}*/
+/*FUNCTION PentaP1Input::PointwiseMin{{{1*/
+Input* PentaP1Input::PointwiseMin(Input* inputB){
+
+	/*Ouput*/
+	PentaP1Input* outinput=NULL;
+
+	/*Intermediaries*/
+	int               i;
+	PentaP1Input *xinputB     = NULL;
+	int               B_numvalues;
+	const int         numnodes    = 6;
+	double            minvalues[numnodes];
+
+	/*Check that inputB is of the same type*/
+	if (inputB->ObjectEnum()!=PentaP1InputEnum) _error_("Operation not permitted because inputB is of type %s",EnumToStringx(inputB->ObjectEnum()));
+	xinputB=(PentaP1Input*)inputB;
+
+	/*Create point wise min*/
+	for(i=0;i<numnodes;i++){
+		if(this->values[i] > xinputB->values[i]) minvalues[i]=xinputB->values[i];
+		else minvalues[i]=this->values[i];
+	}
+
+	/*Create new Penta vertex input (copy of current input)*/
+	outinput=new PentaP1Input(this->enum_type,&minvalues[0]);
+
+	/*Return output pointer*/
+	return outinput;
+
+}
+/*}}}*/
+/*FUNCTION PentaP1Input::PointwiseMax{{{1*/
+Input* PentaP1Input::PointwiseMax(Input* inputB){
+
+	/*Ouput*/
+	PentaP1Input* outinput=NULL;
+
+	/*Intermediaries*/
+	int               i;
+	PentaP1Input *xinputB     = NULL;
+	int               B_numvalues;
+	const int         numnodes    = 6;
+	double            maxvalues[numnodes];
+
+	/*Check that inputB is of the same type*/
+	if (inputB->ObjectEnum()!=PentaP1InputEnum) _error_("Operation not permitted because inputB is of type %s",EnumToStringx(inputB->ObjectEnum()));
+	xinputB=(PentaP1Input*)inputB;
+
+	/*Create point wise max*/
+	for(i=0;i<numnodes;i++){
+		if(this->values[i] < xinputB->values[i]) maxvalues[i]=xinputB->values[i];
+		else maxvalues[i]=this->values[i];
+	}
+
+	/*Create new Penta vertex input (copy of current input)*/
+	outinput=new PentaP1Input(this->enum_type,&maxvalues[0]);
+
+	/*Return output pointer*/
+	return outinput;
+
+}
+/*}}}*/
+/*FUNCTION PentaP1Input::GetVectorFromInputs{{{1*/
+void PentaP1Input::GetVectorFromInputs(Vec vector,int* doflist){
+
+	const int numvertices=6;
+	VecSetValues(vector,numvertices,doflist,(const double*)this->values,INSERT_VALUES);
+
+} /*}}}*/
+/*FUNCTION PentaP1Input::GetValuesPtr{{{1*/
+void PentaP1Input::GetValuesPtr(double** pvalues,int* pnum_values){
+
+	*pvalues=this->values;
+	*pnum_values=6;
+
+}
+/*}}}*/
+/*FUNCTION PentaP1Input::Configure{{{1*/
+void PentaP1Input::Configure(Parameters* parameters){
+	/*do nothing: */
+}
+/*}}}*/
Index: /issm/trunk/src/c/objects/Inputs/PentaP1Input.h
===================================================================
--- /issm/trunk/src/c/objects/Inputs/PentaP1Input.h	(revision 11527)
+++ /issm/trunk/src/c/objects/Inputs/PentaP1Input.h	(revision 11527)
@@ -0,0 +1,89 @@
+/*! \file PentaP1Input.h 
+ *  \brief: header file for PentaP1Input object
+ */
+
+
+#ifndef _PENTAP1INPUT_H_
+#define _PENTAP1INPUT_H_
+
+/*Headers:*/
+/*{{{1*/
+#include "./Input.h"
+#include "../Elements/PentaRef.h"
+class GaussTria;
+/*}}}*/
+
+class PentaP1Input: public Input, public PentaRef{
+
+	public:
+		/*just hold 6 values for 6 vertices: */
+		int    enum_type;
+		double values[6];
+
+		/*PentaP1Input constructors, destructors: {{{1*/
+		PentaP1Input();
+		PentaP1Input(int enum_type,double* values);
+		~PentaP1Input();
+		/*}}}*/
+		/*Object virtual functions definitions:{{{1 */
+		void  Echo();
+		void  DeepEcho();
+		int   Id(); 
+		int   MyRank();
+		#ifdef _SERIAL_
+		void  Marshall(char** pmarshalled_dataset);
+		int   MarshallSize();
+		void  Demarshall(char** pmarshalled_dataset);
+		#endif
+		int   ObjectEnum();
+		Object* copy();
+		/*}}}*/
+		/*PentaP1Input management: {{{1*/
+		int   InstanceEnum();
+		Input* SpawnTriaInput(int* indices);
+		Input* PointwiseDivide(Input* inputB);
+		Input* PointwiseMin(Input* inputB);
+		Input* PointwiseMax(Input* inputB);
+		ElementResult* SpawnResult(int step, double time);
+		void AddTimeValues(double* values,int step,double time){_error_("not supported yet");};
+		void Configure(Parameters* parameters);
+		/*}}}*/
+		/*numerics: {{{1*/
+		void GetInputValue(bool* pvalue){_error_("not implemented yet");};
+		void GetInputValue(int* pvalue){_error_("not implemented yet");};
+		void GetInputValue(double* pvalue){_error_("not implemented yet");};
+		void GetInputValue(double* pvalue,GaussTria* gauss){_error_("not implemented yet");};
+		void GetInputValue(double* pvalue,GaussPenta* gauss);
+		void GetInputValue(double* pvalue,GaussTria* gauss ,int index){_error_("not implemented yet");};
+		void GetInputValue(double* pvalue,GaussPenta* gauss ,int index){_error_("not implemented yet");};
+		void GetInputDerivativeValue(double* derivativevalues, double* xyz_list, GaussTria* gauss){_error_("not implemented yet");};
+		void GetInputDerivativeValue(double* derivativevalues, double* xyz_list, GaussPenta* gauss);
+		void GetInputAverage(double* pvalue);
+		void GetVxStrainRate2d(double* epsilonvx,double* xyz_list, GaussTria* gauss){_error_("not implemented yet");};
+		void GetVyStrainRate2d(double* epsilonvy,double* xyz_list, GaussTria* gauss){_error_("not implemented yet");};
+		void GetVxStrainRate3d(double* epsilonvx,double* xyz_list, GaussPenta* gauss);
+		void GetVyStrainRate3d(double* epsilonvy,double* xyz_list, GaussPenta* gauss);
+		void GetVzStrainRate3d(double* epsilonvz,double* xyz_list, GaussPenta* gauss);
+		void GetVxStrainRate3dPattyn(double* epsilonvx,double* xyz_list, GaussPenta* gauss);
+		void GetVyStrainRate3dPattyn(double* epsilonvy,double* xyz_list, GaussPenta* gauss);
+		void ChangeEnum(int newenumtype);
+
+		void SquareMin(double* psquaremin, bool process_units,Parameters* parameters);
+		void ConstrainMin(double minimum);
+		void Scale(double scale_factor);
+		void ArtificialNoise(double min,double max){_error_("not implemented yet");};
+		void AXPY(Input* xinput,double scalar);
+		void Constrain(double cm_min, double cm_max);
+		double InfinityNorm(void);
+		double Max(void);
+		double MaxAbs(void);
+		double Min(void);
+		double MinAbs(void);
+		void Extrude(void);
+		void VerticallyIntegrate(Input* thickness_input);
+		void GetVectorFromInputs(Vec vector,int* doflist);
+		void GetValuesPtr(double** pvalues,int* pnum_values);
+		/*}}}*/
+
+};
+#endif  /* _PENTAP1INPUT_H */
Index: sm/trunk/src/c/objects/Inputs/PentaVertexInput.cpp
===================================================================
--- /issm/trunk/src/c/objects/Inputs/PentaVertexInput.cpp	(revision 11526)
+++ 	(revision )
@@ -1,680 +1,0 @@
-/*!\file PentaVertexInput.c
- * \brief: implementation of the PentaVertexInput object
- */
-
-#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 "../../EnumDefinitions/EnumDefinitions.h"
-#include "../../shared/shared.h"
-#include "../../Container/Container.h"
-#include "../../include/include.h"
-
-/*PentaVertexInput constructors and destructor*/
-/*FUNCTION PentaVertexInput::PentaVertexInput(){{{1*/
-PentaVertexInput::PentaVertexInput(){
-	return;
-}
-/*}}}*/
-/*FUNCTION PentaVertexInput::PentaVertexInput(int in_enum_type,double* values){{{1*/
-PentaVertexInput::PentaVertexInput(int in_enum_type,double* in_values)
-		:PentaRef(1)
-{
-
-	/*Set PentaRef*/
-	this->SetElementType(P1Enum,0);
-	this->element_type=P1Enum;
-
-	enum_type=in_enum_type;
-	values[0]=in_values[0];
-	values[1]=in_values[1];
-	values[2]=in_values[2];
-	values[3]=in_values[3];
-	values[4]=in_values[4];
-	values[5]=in_values[5];
-}
-/*}}}*/
-/*FUNCTION PentaVertexInput::~PentaVertexInput(){{{1*/
-PentaVertexInput::~PentaVertexInput(){
-	return;
-}
-/*}}}*/
-
-/*Object virtual functions definitions:*/
-/*FUNCTION PentaVertexInput::Echo {{{1*/
-void PentaVertexInput::Echo(void){
-	this->DeepEcho();
-}
-/*}}}*/
-/*FUNCTION PentaVertexInput::DeepEcho{{{1*/
-void PentaVertexInput::DeepEcho(void){
-
-	printf("PentaVertexInput:\n");
-	printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
-	printf("   values: [%g %g %g %g %g %g]\n",this->values[0],this->values[1],this->values[2],this->values[3],this->values[4],this->values[5]);
-}
-/*}}}*/
-/*FUNCTION PentaVertexInput::Id{{{1*/
-int    PentaVertexInput::Id(void){ return -1; }
-/*}}}*/
-/*FUNCTION PentaVertexInput::MyRank{{{1*/
-int    PentaVertexInput::MyRank(void){ 
-	extern int my_rank;
-	return my_rank; 
-}
-/*}}}*/
-#ifdef _SERIAL_
-/*FUNCTION PentaVertexInput::Marshall{{{1*/
-void  PentaVertexInput::Marshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   enum_value=0;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*get enum value of PentaVertexInput: */
-	enum_value=PentaVertexInputEnum;
-	
-	/*marshall enum: */
-	memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);
-	
-	/*marshall PentaVertexInput data: */
-	memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-	memcpy(marshalled_dataset,&values,sizeof(values));marshalled_dataset+=sizeof(values);
-
-	*pmarshalled_dataset=marshalled_dataset;
-}
-/*}}}*/
-/*FUNCTION PentaVertexInput::MarshallSize{{{1*/
-int   PentaVertexInput::MarshallSize(){
-	
-	return sizeof(values)+
-		+sizeof(enum_type)+
-		+sizeof(int); //sizeof(int) for enum value
-}
-/*}}}*/
-/*FUNCTION PentaVertexInput::Demarshall{{{1*/
-void  PentaVertexInput::Demarshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   i;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*this time, no need to get enum type, the pointer directly points to the beginning of the 
-	 *object data (thanks to DataSet::Demarshall):*/
-	memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-	memcpy(&values,marshalled_dataset,sizeof(values));marshalled_dataset+=sizeof(values);
-
-	/*return: */
-	*pmarshalled_dataset=marshalled_dataset;
-	return;
-}
-/*}}}*/
-#endif
-/*FUNCTION PentaVertexInput::ObjectEnum{{{1*/
-int PentaVertexInput::ObjectEnum(void){
-
-	return PentaVertexInputEnum;
-
-}
-/*}}}*/
-	
-/*PentaVertexInput management*/
-/*FUNCTION PentaVertexInput::copy{{{1*/
-Object* PentaVertexInput::copy() {
-	
-	return new PentaVertexInput(this->enum_type,this->values);
-
-}
-/*}}}*/
-/*FUNCTION PentaVertexInput::InstanceEnum{{{1*/
-int PentaVertexInput::InstanceEnum(void){
-
-	return this->enum_type;
-
-}
-/*}}}*/
-/*FUNCTION PentaVertexInput::SpawnTriaInput{{{1*/
-Input* PentaVertexInput::SpawnTriaInput(int* indices){
-
-	/*output*/
-	TriaVertexInput* outinput=NULL;
-	double newvalues[3];
-
-	/*Loop over the new indices*/
-	for(int i=0;i<3;i++){
-
-		/*Check index value*/
-		_assert_(indices[i]>=0 && indices[i]<6);
-
-		/*Assign value to new input*/
-		newvalues[i]=this->values[indices[i]];
-	}
-
-	/*Create new Tria input*/
-	outinput=new TriaVertexInput(this->enum_type,&newvalues[0]);
-
-	/*Assign output*/
-	return outinput;
-
-}
-/*}}}*/
-/*FUNCTION PentaVertexInput::SpawnResult{{{1*/
-ElementResult* PentaVertexInput::SpawnResult(int step, double time){
-
-	return new PentaVertexElementResult(this->enum_type,this->values,step,time);
-
-}
-/*}}}*/
-
-/*Object functions*/
-/*FUNCTION PentaVertexInput::GetInputValue(double* pvalue,GaussPenta* gauss){{{1*/
-void PentaVertexInput::GetInputValue(double* pvalue,GaussPenta* gauss){
-
-	/*Call PentaRef function*/
-	PentaRef::GetInputValue(pvalue,&values[0],gauss);
-
-}
-/*}}}*/
-/*FUNCTION PentaVertexInput::GetInputDerivativeValue(double* p, double* xyz_list, GaussPenta* gauss){{{1*/
-void PentaVertexInput::GetInputDerivativeValue(double* p, double* xyz_list, GaussPenta* gauss){
-
-	/*Call PentaRef function*/
-	PentaRef::GetInputDerivativeValue(p,&values[0],xyz_list,gauss);
-}
-/*}}}*/
-/*FUNCTION PentaVertexInput::GetVxStrainRate3d{{{1*/
-void PentaVertexInput::GetVxStrainRate3d(double* epsilonvx,double* xyz_list, GaussPenta* gauss){
-	int i,j;
-
-	const int numnodes=6;
-	const int DOFVELOCITY=3;
-	double B[8][27];
-	double B_reduced[6][DOFVELOCITY*numnodes];
-	double velocity[numnodes][DOFVELOCITY];
-
-	/*Get B matrix: */
-	GetBStokes(&B[0][0], xyz_list, gauss);
-	/*Create a reduced matrix of B to get rid of pressure */
-	for (i=0;i<6;i++){
-		for (j=0;j<3;j++){
-			B_reduced[i][j]=B[i][j];
-		}
-		for (j=4;j<7;j++){
-			B_reduced[i][j-1]=B[i][j];
-		}
-		for (j=8;j<11;j++){
-			B_reduced[i][j-2]=B[i][j];
-		}
-		for (j=12;j<15;j++){
-			B_reduced[i][j-3]=B[i][j];
-		}
-		for (j=16;j<19;j++){
-			B_reduced[i][j-4]=B[i][j];
-		}
-		for (j=20;j<23;j++){
-			B_reduced[i][j-5]=B[i][j];
-		}
-	}
-
-	/*Here, we are computing the strain rate of (vx,0,0)*/
-	for(i=0;i<numnodes;i++){
-		velocity[i][0]=this->values[i];
-		velocity[i][1]=0.0;
-		velocity[i][2]=0.0;
-	}
-	/*Multiply B by velocity, to get strain rate: */
-	MatrixMultiply(&B_reduced[0][0],6,DOFVELOCITY*numnodes,0,&velocity[0][0],DOFVELOCITY*numnodes,1,0,epsilonvx,0);
-
-}
-/*}}}*/
-/*FUNCTION PentaVertexInput::GetVyStrainRate3d{{{1*/
-void PentaVertexInput::GetVyStrainRate3d(double* epsilonvy,double* xyz_list, GaussPenta* gauss){
-	int i,j;
-
-	const int numnodes=6;
-	const int DOFVELOCITY=3;
-	double B[8][27];
-	double B_reduced[6][DOFVELOCITY*numnodes];
-	double velocity[numnodes][DOFVELOCITY];
-
-	/*Get B matrix: */
-	GetBStokes(&B[0][0], xyz_list, gauss);
-	/*Create a reduced matrix of B to get rid of pressure */
-	for (i=0;i<6;i++){
-		for (j=0;j<3;j++){
-			B_reduced[i][j]=B[i][j];
-		}
-		for (j=4;j<7;j++){
-			B_reduced[i][j-1]=B[i][j];
-		}
-		for (j=8;j<11;j++){
-			B_reduced[i][j-2]=B[i][j];
-		}
-		for (j=12;j<15;j++){
-			B_reduced[i][j-3]=B[i][j];
-		}
-		for (j=16;j<19;j++){
-			B_reduced[i][j-4]=B[i][j];
-		}
-		for (j=20;j<23;j++){
-			B_reduced[i][j-5]=B[i][j];
-		}
-	}
-
-	/*Here, we are computing the strain rate of (0,vy,0)*/
-	for(i=0;i<numnodes;i++){
-		velocity[i][0]=0.0;
-		velocity[i][1]=this->values[i];
-		velocity[i][2]=0.0;
-	}
-	/*Multiply B by velocity, to get strain rate: */
-	MatrixMultiply(&B_reduced[0][0],6,DOFVELOCITY*numnodes,0,&velocity[0][0],DOFVELOCITY*numnodes,1,0,epsilonvy,0);
-
-}
-/*}}}*/
-/*FUNCTION PentaVertexInput::GetVzStrainRate3d{{{1*/
-void PentaVertexInput::GetVzStrainRate3d(double* epsilonvz,double* xyz_list, GaussPenta* gauss){
-	int i,j;
-
-	const int numnodes=6;
-	const int DOFVELOCITY=3;
-	double B[8][27];
-	double B_reduced[6][DOFVELOCITY*numnodes];
-	double velocity[numnodes][DOFVELOCITY];
-
-	/*Get B matrix: */
-	GetBStokes(&B[0][0], xyz_list, gauss);
-	/*Create a reduced matrix of B to get rid of pressure */
-	for (i=0;i<6;i++){
-		for (j=0;j<3;j++){
-			B_reduced[i][j]=B[i][j];
-		}
-		for (j=4;j<7;j++){
-			B_reduced[i][j-1]=B[i][j];
-		}
-		for (j=8;j<11;j++){
-			B_reduced[i][j-2]=B[i][j];
-		}
-		for (j=12;j<15;j++){
-			B_reduced[i][j-3]=B[i][j];
-		}
-		for (j=16;j<19;j++){
-			B_reduced[i][j-4]=B[i][j];
-		}
-		for (j=20;j<23;j++){
-			B_reduced[i][j-5]=B[i][j];
-		}
-	}
-
-	/*Here, we are computing the strain rate of (0,0,vz)*/
-	for(i=0;i<numnodes;i++){
-		velocity[i][0]=0.0;
-		velocity[i][1]=0.0;
-		velocity[i][2]=this->values[i];
-	}
-
-	/*Multiply B by velocity, to get strain rate: */
-	MatrixMultiply(&B_reduced[0][0],6,DOFVELOCITY*numnodes,0,&velocity[0][0],DOFVELOCITY*numnodes,1,0,epsilonvz,0);
-
-}
-/*}}}*/
-/*FUNCTION PentaVertexInput::GetVxStrainRate3dPattyn{{{1*/
-void PentaVertexInput::GetVxStrainRate3dPattyn(double* epsilonvx,double* xyz_list, GaussPenta* gauss){
-
-	int i;
-	const int numnodes=6;
-	double B[5][NDOF2*numnodes];
-	double velocity[numnodes][NDOF2];
-
-	/*Get B matrix: */
-	GetBPattyn(&B[0][0], xyz_list, gauss);
-
-	/*Here, we are computing the strain rate of (vx,0)*/
-	for(i=0;i<numnodes;i++){
-		velocity[i][0]=this->values[i];
-		velocity[i][1]=0.0;
-	}
-
-	/*Multiply B by velocity, to get strain rate: */
-	MatrixMultiply( &B[0][0],5,NDOF2*numnodes,0,
-				&velocity[0][0],NDOF2*numnodes,1,0,
-				epsilonvx,0);
-
-}
-/*}}}*/
-/*FUNCTION PentaVertexInput::GetVyStrainRate3dPattyn{{{1*/
-void PentaVertexInput::GetVyStrainRate3dPattyn(double* epsilonvy,double* xyz_list, GaussPenta* gauss){
-
-	int i;
-	const int numnodes=6;
-	double B[5][NDOF2*numnodes];
-	double velocity[numnodes][NDOF2];
-
-	/*Get B matrix: */
-	GetBPattyn(&B[0][0], xyz_list, gauss);
-
-	/*Here, we are computing the strain rate of (0,vy)*/
-	for(i=0;i<numnodes;i++){
-		velocity[i][0]=0.0;
-		velocity[i][1]=this->values[i];
-	}
-
-	/*Multiply B by velocity, to get strain rate: */
-	MatrixMultiply( &B[0][0],5,NDOF2*numnodes,0,
-				&velocity[0][0],NDOF2*numnodes,1,0,
-				epsilonvy,0);
-
-}
-/*}}}*/
-/*FUNCTION PentaVertexInput::ChangeEnum{{{1*/
-void PentaVertexInput::ChangeEnum(int newenumtype){
-	this->enum_type=newenumtype;
-}
-/*}}}*/
-/*FUNCTION PentaVertexInput::GetInputAverage{{{1*/
-void PentaVertexInput::GetInputAverage(double* pvalue){
-	*pvalue=1./6.*(values[0]+values[1]+values[2]+values[3]+values[4]+values[5]);
-}
-/*}}}*/
-
-/*Intermediary*/
-/*FUNCTION PentaVertexInput::SquareMin{{{1*/
-void PentaVertexInput::SquareMin(double* psquaremin, bool process_units,Parameters* parameters){
-
-	int i;
-	const int numnodes=6;
-	double valuescopy[numnodes];
-	double squaremin;
-
-	/*First,  copy values, to process units if requested: */
-	for(i=0;i<numnodes;i++)valuescopy[i]=this->values[i];
-
-	/*Process units if requested: */
-	if(process_units)UnitConversion(&valuescopy[0],numnodes,IuToExtEnum,enum_type);
-
-	/*Now, figure out minimum of valuescopy: */
-	squaremin=pow(valuescopy[0],2);
-	for(i=1;i<numnodes;i++){
-		if(pow(valuescopy[i],2)<squaremin)squaremin=pow(valuescopy[i],2);
-	}
-	/*Assign output pointers:*/
-	*psquaremin=squaremin;
-}
-/*}}}*/
-/*FUNCTION PentaVertexInput::ConstrainMin{{{1*/
-void PentaVertexInput::ConstrainMin(double minimum){
-	
-	int i;
-	const int numnodes=6;
-
-	for(i=0;i<numnodes;i++) if (values[i]<minimum) values[i]=minimum;
-}
-/*}}}*/
-/*FUNCTION PentaVertexInput::InfinityNorm{{{1*/
-double PentaVertexInput::InfinityNorm(void){
-
-	/*Output*/
-	const int numnodes=6;
-	double norm=0;
-
-	for(int i=0;i<numnodes;i++) if(fabs(values[i])>norm) norm=fabs(values[i]);
-	return norm;
-}
-/*}}}*/
-/*FUNCTION PentaVertexInput::Max{{{1*/
-double PentaVertexInput::Max(void){
-
-	const int numnodes=6;
-	double    max=values[0];
-
-	for(int i=1;i<numnodes;i++){
-		if(values[i]>max) max=values[i];
-	}
-	return max;
-}
-/*}}}*/
-/*FUNCTION PentaVertexInput::MaxAbs{{{1*/
-double PentaVertexInput::MaxAbs(void){
-
-	const int numnodes=6;
-	double    max=fabs(values[0]);
-
-	for(int i=1;i<numnodes;i++){
-		if(fabs(values[i])>max) max=fabs(values[i]);
-	}
-	return max;
-}
-/*}}}*/
-/*FUNCTION PentaVertexInput::Min{{{1*/
-double PentaVertexInput::Min(void){
-
-	const int numnodes=6;
-	double    min=values[0];
-
-	for(int i=1;i<numnodes;i++){
-		if(values[i]<min) min=values[i];
-	}
-	return min;
-}
-/*}}}*/
-/*FUNCTION PentaVertexInput::MinAbs{{{1*/
-double PentaVertexInput::MinAbs(void){
-
-	const int numnodes=6;
-	double    min=fabs(values[0]);
-
-	for(int i=1;i<numnodes;i++){
-		if(fabs(values[i])<min) min=fabs(values[i]);
-	}
-	return min;
-}
-/*}}}*/
-/*FUNCTION PentaVertexInput::Scale{{{1*/
-void PentaVertexInput::Scale(double scale_factor){
-	
-	int i;
-	const int numnodes=6;
-
-	for(i=0;i<numnodes;i++)values[i]=values[i]*scale_factor;
-}
-/*}}}*/
-/*FUNCTION PentaVertexInput::AXPY{{{1*/
-void PentaVertexInput::AXPY(Input* xinput,double scalar){
-
-	int i;
-	const int numnodes=6;
-
-	/*xinput is of the same type, so cast it: */
-
-	/*Carry out the AXPY operation depending on type:*/
-	switch(xinput->ObjectEnum()){
-
-		case PentaVertexInputEnum:{
-			PentaVertexInput* cast_input=(PentaVertexInput*)xinput;
-			for(i=0;i<numnodes;i++)this->values[i]=this->values[i]+scalar*(cast_input->values[i]);}
-			return;
-		case ControlInputEnum:{
-			ControlInput* cont_input=(ControlInput*)xinput;
-			if(cont_input->values->ObjectEnum()!=PentaVertexInputEnum) _error_("not supported yet");
-			PentaVertexInput* cast_input=(PentaVertexInput*)cont_input->values;
-			for(i=0;i<numnodes;i++)this->values[i]=this->values[i]+scalar*(cast_input->values[i]);}
-			return;
-		default:
-			_error_("not implemented yet");
-	}
-
-}
-/*}}}*/
-/*FUNCTION PentaVertexInput::Constrain{{{1*/
-void PentaVertexInput::Constrain(double cm_min, double cm_max){
-
-	int i;
-	const int numnodes=6;
-		
-	if(!isnan(cm_min)) for(i=0;i<numnodes;i++)if (this->values[i]<cm_min)this->values[i]=cm_min;
-	if(!isnan(cm_max)) for(i=0;i<numnodes;i++)if (this->values[i]>cm_max)this->values[i]=cm_max;
-
-}
-/*}}}*/
-/*FUNCTION PentaVertexInput::Extrude{{{1*/
-void PentaVertexInput::Extrude(void){
-
-	int i;
-
-	/*First 3 values copied on 3 last values*/
-	for(i=0;i<3;i++) this->values[3+i]=this->values[i];
-}
-/*}}}*/
-/*FUNCTION PentaVertexInput::VerticallyIntegrate{{{1*/
-void PentaVertexInput::VerticallyIntegrate(Input* thickness_input){
-
-	/*Intermediaries*/
-	int i;
-	const int  numnodes = 6;
-	int        num_thickness_values;
-	double    *thickness_values = NULL;
-
-	/*Check that input provided is a thickness*/
-	if (thickness_input->InstanceEnum()!=ThicknessEnum) _error_("Input provided is not a Thickness (enum_type is %s)",EnumToStringx(thickness_input->InstanceEnum()));
-
-	/*Get Thickness value pointer*/
-	thickness_input->GetValuesPtr(&thickness_values,&num_thickness_values);
-
-	/*vertically integrate depending on type:*/
-	switch(thickness_input->ObjectEnum()){
-
-		case PentaVertexInputEnum:
-			for(i=0;i<3;i++){
-				this->values[i]=0.5*(this->values[i]+this->values[i+3]) * thickness_values[i];
-				this->values[i+3]=this->values[i];
-			}
-			return;
-
-		default:
-			_error_("not implemented yet");
-	}
-}
-/*}}}*/
-/*FUNCTION PentaVertexInput::PointwiseDivide{{{1*/
-Input* PentaVertexInput::PointwiseDivide(Input* inputB){
-
-	/*Ouput*/
-	PentaVertexInput* outinput=NULL;
-
-	/*Intermediaries*/
-	int               i;
-	PentaVertexInput *xinputB     = NULL;
-	int               B_numvalues;
-	const int         numnodes    = 6;
-	double            AdotBvalues[numnodes];
-
-	/*Check that inputB is of the same type*/
-	if (inputB->ObjectEnum()!=PentaVertexInputEnum) _error_("Operation not permitted because inputB is of type %s",EnumToStringx(inputB->ObjectEnum()));
-	xinputB=(PentaVertexInput*)inputB;
-
-	/*Create point wise sum*/
-	for(i=0;i<numnodes;i++){
-		_assert_(xinputB->values[i]!=0);
-		AdotBvalues[i]=this->values[i]/xinputB->values[i];
-	}
-
-	/*Create new Penta vertex input (copy of current input)*/
-	outinput=new PentaVertexInput(this->enum_type,&AdotBvalues[0]);
-
-	/*Return output pointer*/
-	return outinput;
-
-}
-/*}}}*/
-/*FUNCTION PentaVertexInput::PointwiseMin{{{1*/
-Input* PentaVertexInput::PointwiseMin(Input* inputB){
-
-	/*Ouput*/
-	PentaVertexInput* outinput=NULL;
-
-	/*Intermediaries*/
-	int               i;
-	PentaVertexInput *xinputB     = NULL;
-	int               B_numvalues;
-	const int         numnodes    = 6;
-	double            minvalues[numnodes];
-
-	/*Check that inputB is of the same type*/
-	if (inputB->ObjectEnum()!=PentaVertexInputEnum) _error_("Operation not permitted because inputB is of type %s",EnumToStringx(inputB->ObjectEnum()));
-	xinputB=(PentaVertexInput*)inputB;
-
-	/*Create point wise min*/
-	for(i=0;i<numnodes;i++){
-		if(this->values[i] > xinputB->values[i]) minvalues[i]=xinputB->values[i];
-		else minvalues[i]=this->values[i];
-	}
-
-	/*Create new Penta vertex input (copy of current input)*/
-	outinput=new PentaVertexInput(this->enum_type,&minvalues[0]);
-
-	/*Return output pointer*/
-	return outinput;
-
-}
-/*}}}*/
-/*FUNCTION PentaVertexInput::PointwiseMax{{{1*/
-Input* PentaVertexInput::PointwiseMax(Input* inputB){
-
-	/*Ouput*/
-	PentaVertexInput* outinput=NULL;
-
-	/*Intermediaries*/
-	int               i;
-	PentaVertexInput *xinputB     = NULL;
-	int               B_numvalues;
-	const int         numnodes    = 6;
-	double            maxvalues[numnodes];
-
-	/*Check that inputB is of the same type*/
-	if (inputB->ObjectEnum()!=PentaVertexInputEnum) _error_("Operation not permitted because inputB is of type %s",EnumToStringx(inputB->ObjectEnum()));
-	xinputB=(PentaVertexInput*)inputB;
-
-	/*Create point wise max*/
-	for(i=0;i<numnodes;i++){
-		if(this->values[i] < xinputB->values[i]) maxvalues[i]=xinputB->values[i];
-		else maxvalues[i]=this->values[i];
-	}
-
-	/*Create new Penta vertex input (copy of current input)*/
-	outinput=new PentaVertexInput(this->enum_type,&maxvalues[0]);
-
-	/*Return output pointer*/
-	return outinput;
-
-}
-/*}}}*/
-/*FUNCTION PentaVertexInput::GetVectorFromInputs{{{1*/
-void PentaVertexInput::GetVectorFromInputs(Vec vector,int* doflist){
-
-	const int numvertices=6;
-	VecSetValues(vector,numvertices,doflist,(const double*)this->values,INSERT_VALUES);
-
-} /*}}}*/
-/*FUNCTION PentaVertexInput::GetValuesPtr{{{1*/
-void PentaVertexInput::GetValuesPtr(double** pvalues,int* pnum_values){
-
-	*pvalues=this->values;
-	*pnum_values=6;
-
-}
-/*}}}*/
-/*FUNCTION PentaVertexInput::Configure{{{1*/
-void PentaVertexInput::Configure(Parameters* parameters){
-	/*do nothing: */
-}
-/*}}}*/
Index: sm/trunk/src/c/objects/Inputs/PentaVertexInput.h
===================================================================
--- /issm/trunk/src/c/objects/Inputs/PentaVertexInput.h	(revision 11526)
+++ 	(revision )
@@ -1,89 +1,0 @@
-/*! \file PentaVertexInput.h 
- *  \brief: header file for triavertexinput object
- */
-
-
-#ifndef _PENTAVERTEXINPUT_H_
-#define _PENTAVERTEXINPUT_H_
-
-/*Headers:*/
-/*{{{1*/
-#include "./Input.h"
-#include "../Elements/PentaRef.h"
-class GaussTria;
-/*}}}*/
-
-class PentaVertexInput: public Input, public PentaRef{
-
-	public:
-		/*just hold 6 values for 6 vertices: */
-		int    enum_type;
-		double values[6];
-
-		/*PentaVertexInput constructors, destructors: {{{1*/
-		PentaVertexInput();
-		PentaVertexInput(int enum_type,double* values);
-		~PentaVertexInput();
-		/*}}}*/
-		/*Object virtual functions definitions:{{{1 */
-		void  Echo();
-		void  DeepEcho();
-		int   Id(); 
-		int   MyRank();
-		#ifdef _SERIAL_
-		void  Marshall(char** pmarshalled_dataset);
-		int   MarshallSize();
-		void  Demarshall(char** pmarshalled_dataset);
-		#endif
-		int   ObjectEnum();
-		Object* copy();
-		/*}}}*/
-		/*PentaVertexInput management: {{{1*/
-		int   InstanceEnum();
-		Input* SpawnTriaInput(int* indices);
-		Input* PointwiseDivide(Input* inputB);
-		Input* PointwiseMin(Input* inputB);
-		Input* PointwiseMax(Input* inputB);
-		ElementResult* SpawnResult(int step, double time);
-		void AddTimeValues(double* values,int step,double time){_error_("not supported yet");};
-		void Configure(Parameters* parameters);
-		/*}}}*/
-		/*numerics: {{{1*/
-		void GetInputValue(bool* pvalue){_error_("not implemented yet");};
-		void GetInputValue(int* pvalue){_error_("not implemented yet");};
-		void GetInputValue(double* pvalue){_error_("not implemented yet");};
-		void GetInputValue(double* pvalue,GaussTria* gauss){_error_("not implemented yet");};
-		void GetInputValue(double* pvalue,GaussPenta* gauss);
-		void GetInputValue(double* pvalue,GaussTria* gauss ,int index){_error_("not implemented yet");};
-		void GetInputValue(double* pvalue,GaussPenta* gauss ,int index){_error_("not implemented yet");};
-		void GetInputDerivativeValue(double* derivativevalues, double* xyz_list, GaussTria* gauss){_error_("not implemented yet");};
-		void GetInputDerivativeValue(double* derivativevalues, double* xyz_list, GaussPenta* gauss);
-		void GetInputAverage(double* pvalue);
-		void GetVxStrainRate2d(double* epsilonvx,double* xyz_list, GaussTria* gauss){_error_("not implemented yet");};
-		void GetVyStrainRate2d(double* epsilonvy,double* xyz_list, GaussTria* gauss){_error_("not implemented yet");};
-		void GetVxStrainRate3d(double* epsilonvx,double* xyz_list, GaussPenta* gauss);
-		void GetVyStrainRate3d(double* epsilonvy,double* xyz_list, GaussPenta* gauss);
-		void GetVzStrainRate3d(double* epsilonvz,double* xyz_list, GaussPenta* gauss);
-		void GetVxStrainRate3dPattyn(double* epsilonvx,double* xyz_list, GaussPenta* gauss);
-		void GetVyStrainRate3dPattyn(double* epsilonvy,double* xyz_list, GaussPenta* gauss);
-		void ChangeEnum(int newenumtype);
-
-		void SquareMin(double* psquaremin, bool process_units,Parameters* parameters);
-		void ConstrainMin(double minimum);
-		void Scale(double scale_factor);
-		void ArtificialNoise(double min,double max){_error_("not implemented yet");};
-		void AXPY(Input* xinput,double scalar);
-		void Constrain(double cm_min, double cm_max);
-		double InfinityNorm(void);
-		double Max(void);
-		double MaxAbs(void);
-		double Min(void);
-		double MinAbs(void);
-		void Extrude(void);
-		void VerticallyIntegrate(Input* thickness_input);
-		void GetVectorFromInputs(Vec vector,int* doflist);
-		void GetValuesPtr(double** pvalues,int* pnum_values);
-		/*}}}*/
-
-};
-#endif  /* _PENTAVERTEXINPUT_H */
Index: /issm/trunk/src/c/objects/Inputs/TriaP1Input.cpp
===================================================================
--- /issm/trunk/src/c/objects/Inputs/TriaP1Input.cpp	(revision 11527)
+++ /issm/trunk/src/c/objects/Inputs/TriaP1Input.cpp	(revision 11527)
@@ -0,0 +1,473 @@
+/*!\file TriaP1Input.c
+ * \brief: implementation of the TriaP1Input object
+ */
+
+#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 "../../EnumDefinitions/EnumDefinitions.h"
+#include "../../shared/shared.h"
+#include "../../Container/Container.h"
+#include "../../include/include.h"
+
+/*TriaP1Input constructors and destructor*/
+/*FUNCTION TriaP1Input::TriaP1Input(){{{1*/
+TriaP1Input::TriaP1Input(){
+	return;
+}
+/*}}}*/
+/*FUNCTION TriaP1Input::TriaP1Input(int in_enum_type,double* values){{{1*/
+TriaP1Input::TriaP1Input(int in_enum_type,double* in_values)
+	:TriaRef(1)
+{
+
+	/*Set TriaRef*/
+	this->SetElementType(P1Enum,0);
+	this->element_type=P1Enum;
+
+	/*Set Enum*/
+	enum_type=in_enum_type;
+
+	/*Set values*/
+	values[0]=in_values[0];
+	values[1]=in_values[1];
+	values[2]=in_values[2];
+}
+/*}}}*/
+/*FUNCTION TriaP1Input::~TriaP1Input(){{{1*/
+TriaP1Input::~TriaP1Input(){
+	return;
+}
+/*}}}*/
+
+/*Object virtual functions definitions:*/
+/*FUNCTION TriaP1Input::Echo {{{1*/
+void TriaP1Input::Echo(void){
+	this->DeepEcho();
+}
+/*}}}*/
+/*FUNCTION TriaP1Input::DeepEcho{{{1*/
+void TriaP1Input::DeepEcho(void){
+
+	printf("TriaP1Input:\n");
+	printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
+	printf("   values: [%g %g %g]\n",this->values[0],this->values[1],this->values[2]);
+}
+/*}}}*/
+/*FUNCTION TriaP1Input::Id{{{1*/
+int    TriaP1Input::Id(void){ return -1; }
+/*}}}*/
+/*FUNCTION TriaP1Input::MyRank{{{1*/
+int    TriaP1Input::MyRank(void){ 
+	extern int my_rank;
+	return my_rank; 
+}
+/*}}}*/
+#ifdef _SERIAL_
+/*FUNCTION TriaP1Input::Marshall{{{1*/
+void  TriaP1Input::Marshall(char** pmarshalled_dataset){
+
+	char* marshalled_dataset=NULL;
+	int   enum_value=0;
+
+	/*recover marshalled_dataset: */
+	marshalled_dataset=*pmarshalled_dataset;
+
+	/*get enum value of TriaP1Input: */
+	enum_value=TriaP1InputEnum;
+	
+	/*marshall enum: */
+	memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);
+	
+	/*marshall TriaP1Input data: */
+	memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
+	memcpy(marshalled_dataset,&values,sizeof(values));marshalled_dataset+=sizeof(values);
+
+	*pmarshalled_dataset=marshalled_dataset;
+}
+/*}}}*/
+/*FUNCTION TriaP1Input::MarshallSize{{{1*/
+int   TriaP1Input::MarshallSize(){
+	
+	return sizeof(values)+
+		+sizeof(enum_type)+
+		+sizeof(int); //sizeof(int) for enum value
+}
+/*}}}*/
+/*FUNCTION TriaP1Input::Demarshall{{{1*/
+void  TriaP1Input::Demarshall(char** pmarshalled_dataset){
+
+	char* marshalled_dataset=NULL;
+	int   i;
+
+	/*recover marshalled_dataset: */
+	marshalled_dataset=*pmarshalled_dataset;
+
+	/*this time, no need to get enum type, the pointer directly points to the beginning of the 
+	 *object data (thanks to DataSet::Demarshall):*/
+	memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
+	memcpy(&values,marshalled_dataset,sizeof(values));marshalled_dataset+=sizeof(values);
+
+	/*return: */
+	*pmarshalled_dataset=marshalled_dataset;
+	return;
+}
+/*}}}*/
+#endif
+/*FUNCTION TriaP1Input::ObjectEnum{{{1*/
+int TriaP1Input::ObjectEnum(void){
+
+	return TriaP1InputEnum;
+
+}
+/*}}}*/
+/*FUNCTION TriaP1Input::copy{{{1*/
+Object* TriaP1Input::copy() {
+	
+	return new TriaP1Input(this->enum_type,this->values);
+
+}
+/*}}}*/
+	
+/*TriaP1Input management*/
+/*FUNCTION TriaP1Input::InstanceEnum{{{1*/
+int TriaP1Input::InstanceEnum(void){
+
+	return this->enum_type;
+
+}
+/*}}}*/
+/*FUNCTION TriaP1Input::SpawnTriaInput{{{1*/
+Input* TriaP1Input::SpawnTriaInput(int* indices){
+
+	/*output*/
+	TriaP1Input* outinput=NULL;
+
+	/*Create new Tria input (copy of current input)*/
+	outinput=new TriaP1Input(this->enum_type,&this->values[0]);
+
+	/*Assign output*/
+	return outinput;
+
+}
+/*}}}*/
+/*FUNCTION TriaP1Input::SpawnResult{{{1*/
+ElementResult* TriaP1Input::SpawnResult(int step, double time){
+
+	return new TriaP1ElementResult(this->enum_type,this->values,step,time);
+
+}
+/*}}}*/
+
+/*Object functions*/
+/*FUNCTION TriaP1Input::GetInputValue(double* pvalue,GaussTria* gauss){{{1*/
+void TriaP1Input::GetInputValue(double* pvalue,GaussTria* gauss){
+
+	/*Call TriaRef function*/
+	TriaRef::GetInputValue(pvalue,&values[0],gauss);
+
+}
+/*}}}*/
+/*FUNCTION TriaP1Input::GetInputDerivativeValue(double* p, double* xyz_list, GaussTria* gauss){{{1*/
+void TriaP1Input::GetInputDerivativeValue(double* p, double* xyz_list, GaussTria* gauss){
+
+	/*Call TriaRef function*/
+	TriaRef::GetInputDerivativeValue(p,&values[0],xyz_list,gauss);
+}
+/*}}}*/
+/*FUNCTION TriaP1Input::GetVxStrainRate2d{{{1*/
+void TriaP1Input::GetVxStrainRate2d(double* epsilonvx,double* xyz_list, GaussTria* gauss){
+
+	/*Intermediary*/
+	int       i;
+	const int numnodes=3;
+	double B[3][NDOF2*numnodes];
+	double velocity[3][NDOF2];
+
+	/*Get B matrix: */
+	GetBMacAyeal(&B[0][0], xyz_list, gauss);
+
+	/*Here, we are computing the strain rate of (vx,0)*/
+	for(i=0;i<3;i++){
+		velocity[i][0]=this->values[i];
+		velocity[i][1]=0.0;
+	}
+	/*Get epsilon(vx) = B*velocity*/
+	MatrixMultiply( &B[0][0],3,NDOF2*numnodes,0,
+				&velocity[0][0],NDOF2*numnodes,1,0,
+				epsilonvx,0);
+}
+/*}}}*/
+/*FUNCTION TriaP1Input::GetVyStrainRate2d{{{1*/
+void TriaP1Input::GetVyStrainRate2d(double* epsilonvy,double* xyz_list, GaussTria* gauss){
+
+	/*Intermediary*/
+	int       i;
+	const int numnodes=3;
+	double B[3][NDOF2*numnodes];
+	double velocity[3][NDOF2];
+
+	/*Get B matrix: */
+	GetBMacAyeal(&B[0][0], xyz_list, gauss);
+
+	/*Here, we are computing the strain rate of (0,vy)*/
+	for(i=0;i<3;i++){
+		velocity[i][0]=0.0;
+		velocity[i][1]=this->values[i];
+	}
+	/*Get epsilon(vy) = B*velocity*/
+	MatrixMultiply( &B[0][0],3,NDOF2*numnodes,0,
+				&velocity[0][0],NDOF2*numnodes,1,0,
+				epsilonvy,0);
+}
+/*}}}*/
+/*FUNCTION TriaP1Input::ChangeEnum{{{1*/
+void TriaP1Input::ChangeEnum(int newenumtype){
+	this->enum_type=newenumtype;
+}
+/*}}}*/
+/*FUNCTION TriaP1Input::GetInputAverage{{{1*/
+void TriaP1Input::GetInputAverage(double* pvalue){
+	*pvalue=1./3.*(values[0]+values[1]+values[2]);
+}
+/*}}}*/
+
+/*Intermediary*/
+/*FUNCTION TriaP1Input::SquareMin{{{1*/
+void TriaP1Input::SquareMin(double* psquaremin, bool process_units,Parameters* parameters){
+
+	int i;
+	const int numnodes=3;
+	double valuescopy[numnodes];
+	double squaremin;
+
+	/*First,  copy values, to process units if requested: */
+	for(i=0;i<numnodes;i++)valuescopy[i]=this->values[i];
+
+	/*Process units if requested: */
+	if(process_units)UnitConversion(&valuescopy[0],numnodes,IuToExtEnum,enum_type);
+
+	/*Now, figure out minimum of valuescopy: */
+	squaremin=pow(valuescopy[0],2);
+	for(i=1;i<numnodes;i++){
+		if(pow(valuescopy[i],2)<squaremin)squaremin=pow(valuescopy[i],2);
+	}
+	/*Assign output pointers:*/
+	*psquaremin=squaremin;
+}
+/*}}}*/
+/*FUNCTION TriaP1Input::ContrainMin{{{1*/
+void TriaP1Input::ConstrainMin(double minimum){
+	
+	int i;
+	const int numnodes=3;
+
+	for(i=0;i<numnodes;i++) if (values[i]<minimum) values[i]=minimum;
+}
+/*}}}*/
+/*FUNCTION TriaP1Input::InfinityNorm{{{1*/
+double TriaP1Input::InfinityNorm(void){
+
+	/*Output*/
+	double norm=0;
+	const int numnodes=3;
+
+	for(int i=0;i<numnodes;i++) if(fabs(values[i])>norm) norm=fabs(values[i]);
+	return norm;
+}
+/*}}}*/
+/*FUNCTION TriaP1Input::Max{{{1*/
+double TriaP1Input::Max(void){
+
+	const int numnodes=3;
+	double    max=values[0];
+
+	for(int i=1;i<numnodes;i++){
+		if(values[i]>max) max=values[i];
+	}
+	return max;
+}
+/*}}}*/
+/*FUNCTION TriaP1Input::MaxAbs{{{1*/
+double TriaP1Input::MaxAbs(void){
+
+	const int numnodes=3;
+	double    max=fabs(values[0]);
+
+	for(int i=1;i<numnodes;i++){
+		if(fabs(values[i])>max) max=fabs(values[i]);
+	}
+	return max;
+}
+/*}}}*/
+/*FUNCTION TriaP1Input::Min{{{1*/
+double TriaP1Input::Min(void){
+
+	const int numnodes=3;
+	double    min=values[0];
+
+	for(int i=1;i<numnodes;i++){
+		if(values[i]<min) min=values[i];
+	}
+	return min;
+}
+/*}}}*/
+/*FUNCTION TriaP1Input::MinAbs{{{1*/
+double TriaP1Input::MinAbs(void){
+
+	const int numnodes=3;
+	double    min=fabs(values[0]);
+
+	for(int i=1;i<numnodes;i++){
+		if(fabs(values[i])<min) min=fabs(values[i]);
+	}
+	return min;
+}
+/*}}}*/
+/*FUNCTION TriaP1Input::Scale{{{1*/
+void TriaP1Input::Scale(double scale_factor){
+	
+	int i;
+	const int numnodes=3;
+
+	for(i=0;i<numnodes;i++)values[i]=values[i]*scale_factor;
+}
+/*}}}*/
+/*FUNCTION TriaP1Input::ArtificialNoise{{{1*/
+void TriaP1Input::ArtificialNoise(double min,double max){
+
+	int i;
+	const int numnodes=3;
+	double noise;
+
+	/*Compute random number between bounds:
+	 * rand() outputs an integer in [0 RAND_MAX]
+	 * (double)rand()/RAND_MAX is in [0 1]
+	 */
+	 noise=min+(max-min)*(double)rand()/RAND_MAX;
+
+	for(i=0;i<numnodes;i++)values[i]=values[i]+noise;
+}
+/*}}}*/
+/*FUNCTION TriaP1Input::AXPY{{{1*/
+void TriaP1Input::AXPY(Input* xinput,double scalar){
+
+	int i;
+	const int numnodes=3;
+	TriaP1Input*  xtriavertexinput=NULL;
+
+	/*xinput is of the same type, so cast it: */
+	xtriavertexinput=(TriaP1Input*)xinput;
+
+	/*Carry out the AXPY operation depending on type:*/
+	switch(xinput->ObjectEnum()){
+
+		case TriaP1InputEnum :
+			for(i=0;i<numnodes;i++)this->values[i]=this->values[i]+scalar*xtriavertexinput->values[i];
+			return;
+
+		default :
+			_error_("not implemented yet");
+	}
+
+}
+/*}}}*/
+/*FUNCTION TriaP1Input::Constrain{{{1*/
+void TriaP1Input::Constrain(double cm_min, double cm_max){
+
+	int i;
+	const int numnodes=3;
+		
+	if(!isnan(cm_min)) for(i=0;i<numnodes;i++)if (this->values[i]<cm_min)this->values[i]=cm_min;
+	if(!isnan(cm_max)) for(i=0;i<numnodes;i++)if (this->values[i]>cm_max)this->values[i]=cm_max;
+
+}
+/*}}}*/
+/*FUNCTION TriaP1Input::GetVectorFromInputs{{{1*/
+void TriaP1Input::GetVectorFromInputs(Vec vector,int* doflist){
+
+	const int numvertices=3;
+	VecSetValues(vector,numvertices,doflist,(const double*)this->values,INSERT_VALUES);
+
+} /*}}}*/
+/*FUNCTION TriaP1Input::GetValuesPtr{{{1*/
+void TriaP1Input::GetValuesPtr(double** pvalues,int* pnum_values){
+
+	*pvalues=this->values;
+	if(pnum_values)*pnum_values=3;
+
+}
+/*}}}*/
+/*FUNCTION TriaP1Input::PointwiseMin{{{1*/
+Input* TriaP1Input::PointwiseMin(Input* inputB){
+
+	/*Ouput*/
+	TriaP1Input* outinput=NULL;
+
+	/*Intermediaries*/
+	int               i;
+	TriaP1Input *xinputB     = NULL;
+	int               B_numvalues;
+	const int         numnodes    = 3;
+	double            minvalues[numnodes];
+
+	/*Check that inputB is of the same type*/
+	if (inputB->ObjectEnum()!=TriaP1InputEnum) _error_("Operation not permitted because inputB is of type %s",EnumToStringx(inputB->ObjectEnum()));
+	xinputB=(TriaP1Input*)inputB;
+
+	/*Create point wise min*/
+	for(i=0;i<numnodes;i++){
+		if(this->values[i] > xinputB->values[i]) minvalues[i]=xinputB->values[i];
+		else minvalues[i]=this->values[i];
+	}
+
+	/*Create new Tria vertex input (copy of current input)*/
+	outinput=new TriaP1Input(this->enum_type,&minvalues[0]);
+
+	/*Return output pointer*/
+	return outinput;
+
+}
+/*}}}*/
+/*FUNCTION TriaP1Input::PointwiseMax{{{1*/
+Input* TriaP1Input::PointwiseMax(Input* inputB){
+
+	/*Ouput*/
+	TriaP1Input* outinput=NULL;
+
+	/*Intermediaries*/
+	int               i;
+	TriaP1Input *xinputB     = NULL;
+	int               B_numvalues;
+	const int         numnodes    = 3;
+	double            maxvalues[numnodes];
+
+	/*Check that inputB is of the same type*/
+	if (inputB->ObjectEnum()!=TriaP1InputEnum) _error_("Operation not permitted because inputB is of type %s",EnumToStringx(inputB->ObjectEnum()));
+	xinputB=(TriaP1Input*)inputB;
+
+	/*Create point wise max*/
+	for(i=0;i<numnodes;i++){
+		if(this->values[i] < xinputB->values[i]) maxvalues[i]=xinputB->values[i];
+		else maxvalues[i]=this->values[i];
+	}
+
+	/*Create new Tria vertex input (copy of current input)*/
+	outinput=new TriaP1Input(this->enum_type,&maxvalues[0]);
+
+	/*Return output pointer*/
+	return outinput;
+
+}
+/*}}}*/
+/*FUNCTION TriaP1Input::Configure{{{1*/
+void TriaP1Input::Configure(Parameters* parameters){
+	/*do nothing: */
+}
+/*}}}*/
Index: /issm/trunk/src/c/objects/Inputs/TriaP1Input.h
===================================================================
--- /issm/trunk/src/c/objects/Inputs/TriaP1Input.h	(revision 11527)
+++ /issm/trunk/src/c/objects/Inputs/TriaP1Input.h	(revision 11527)
@@ -0,0 +1,89 @@
+/*! \file TriaP1Input.h 
+ *  \brief: header file for TriaP1Input object
+ */
+
+
+#ifndef _TRIAP1INPUT_H_
+#define _TRIAP1INPUT_H_
+
+/*Headers:*/
+/*{{{1*/
+#include "./Input.h"
+#include "../Elements/TriaRef.h"
+class GaussTria;
+/*}}}*/
+
+class TriaP1Input: public Input,public TriaRef{
+
+	public:
+		/*just hold 3 values for 3 vertices: */
+		int    enum_type;
+		double values[3];
+
+		/*TriaP1Input constructors, destructors: {{{1*/
+		TriaP1Input();
+		TriaP1Input(int enum_type,double* values);
+		~TriaP1Input();
+		/*}}}*/
+		/*Object virtual functions definitions:{{{1 */
+		void  Echo();
+		void  DeepEcho();
+		int   Id(); 
+		int   MyRank();
+		#ifdef _SERIAL_
+		void  Marshall(char** pmarshalled_dataset);
+		int   MarshallSize();
+		void  Demarshall(char** pmarshalled_dataset);
+		#endif
+		int   ObjectEnum();
+		Object* copy();
+		/*}}}*/
+		/*TriaP1Input management: {{{1*/
+		int   InstanceEnum();
+		Input* SpawnTriaInput(int* indices);
+		Input* PointwiseDivide(Input* inputB){_error_("not implemented yet");};
+		Input* PointwiseMin(Input* inputB);
+		Input* PointwiseMax(Input* inputB);
+		ElementResult* SpawnResult(int step, double time);
+		void AddTimeValues(double* values,int step,double time){_error_("not supported yet");};
+		void Configure(Parameters* parameters);
+		/*}}}*/
+		/*numerics: {{{1*/
+		void GetInputValue(bool* pvalue){_error_("not implemented yet");}
+		void GetInputValue(int* pvalue){_error_("not implemented yet");}
+		void GetInputValue(double* pvalue){_error_("not implemented yet");}
+		void GetInputValue(double* pvalue,GaussTria* gauss);
+		void GetInputValue(double* pvalue,GaussPenta* gauss){_error_("not implemented yet");};
+		void GetInputValue(double* pvalue,GaussTria* gauss ,int index){_error_("not implemented yet");};
+		void GetInputValue(double* pvalue,GaussPenta* gauss,int index){_error_("not implemented yet");};
+		void GetInputDerivativeValue(double* derivativevalues, double* xyz_list, GaussTria* gauss);
+		void GetInputDerivativeValue(double* derivativevalues, double* xyz_list, GaussPenta* gauss){_error_("not implemented yet");};
+		void GetInputAverage(double* pvalue);
+		void GetVxStrainRate2d(double* epsilonvx,double* xyz_list, GaussTria* gauss);
+		void GetVyStrainRate2d(double* epsilonvy,double* xyz_list, GaussTria* gauss);
+		void GetVxStrainRate3d(double* epsilonvx,double* xyz_list, GaussPenta* gauss){_error_("not implemented yet");};
+		void GetVyStrainRate3d(double* epsilonvy,double* xyz_list, GaussPenta* gauss){_error_("not implemented yet");};
+		void GetVzStrainRate3d(double* epsilonvz,double* xyz_list, GaussPenta* gauss){_error_("not implemented yet");};
+		void GetVxStrainRate3dPattyn(double* epsilonvx,double* xyz_list, GaussPenta* gauss){_error_("not implemented yet");};
+		void GetVyStrainRate3dPattyn(double* epsilonvy,double* xyz_list, GaussPenta* gauss){_error_("not implemented yet");};
+		void ChangeEnum(int newenumtype);
+
+		void SquareMin(double* psquaremin, bool process_units,Parameters* parameters);
+		void ConstrainMin(double minimum);
+		void Scale(double scale_factor);
+		void ArtificialNoise(double min,double max);
+		void AXPY(Input* xinput,double scalar);
+		void Constrain(double cm_min, double cm_max);
+		double InfinityNorm(void);
+		double Max(void);
+		double MaxAbs(void);
+		double Min(void);
+		double MinAbs(void);
+		void Extrude(void){_error_("not supported yet");};
+		void VerticallyIntegrate(Input* thickness_input){_error_("not supported yet");};
+		void GetVectorFromInputs(Vec vector,int* doflist);
+		void GetValuesPtr(double** pvalues,int* pnum_values);
+		/*}}}*/
+
+};
+#endif  /* _TRIAP1INPUT_H */
Index: sm/trunk/src/c/objects/Inputs/TriaVertexInput.cpp
===================================================================
--- /issm/trunk/src/c/objects/Inputs/TriaVertexInput.cpp	(revision 11526)
+++ 	(revision )
@@ -1,473 +1,0 @@
-/*!\file TriaVertexInput.c
- * \brief: implementation of the TriaVertexInput object
- */
-
-#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 "../../EnumDefinitions/EnumDefinitions.h"
-#include "../../shared/shared.h"
-#include "../../Container/Container.h"
-#include "../../include/include.h"
-
-/*TriaVertexInput constructors and destructor*/
-/*FUNCTION TriaVertexInput::TriaVertexInput(){{{1*/
-TriaVertexInput::TriaVertexInput(){
-	return;
-}
-/*}}}*/
-/*FUNCTION TriaVertexInput::TriaVertexInput(int in_enum_type,double* values){{{1*/
-TriaVertexInput::TriaVertexInput(int in_enum_type,double* in_values)
-	:TriaRef(1)
-{
-
-	/*Set TriaRef*/
-	this->SetElementType(P1Enum,0);
-	this->element_type=P1Enum;
-
-	/*Set Enum*/
-	enum_type=in_enum_type;
-
-	/*Set values*/
-	values[0]=in_values[0];
-	values[1]=in_values[1];
-	values[2]=in_values[2];
-}
-/*}}}*/
-/*FUNCTION TriaVertexInput::~TriaVertexInput(){{{1*/
-TriaVertexInput::~TriaVertexInput(){
-	return;
-}
-/*}}}*/
-
-/*Object virtual functions definitions:*/
-/*FUNCTION TriaVertexInput::Echo {{{1*/
-void TriaVertexInput::Echo(void){
-	this->DeepEcho();
-}
-/*}}}*/
-/*FUNCTION TriaVertexInput::DeepEcho{{{1*/
-void TriaVertexInput::DeepEcho(void){
-
-	printf("TriaVertexInput:\n");
-	printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
-	printf("   values: [%g %g %g]\n",this->values[0],this->values[1],this->values[2]);
-}
-/*}}}*/
-/*FUNCTION TriaVertexInput::Id{{{1*/
-int    TriaVertexInput::Id(void){ return -1; }
-/*}}}*/
-/*FUNCTION TriaVertexInput::MyRank{{{1*/
-int    TriaVertexInput::MyRank(void){ 
-	extern int my_rank;
-	return my_rank; 
-}
-/*}}}*/
-#ifdef _SERIAL_
-/*FUNCTION TriaVertexInput::Marshall{{{1*/
-void  TriaVertexInput::Marshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   enum_value=0;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*get enum value of TriaVertexInput: */
-	enum_value=TriaVertexInputEnum;
-	
-	/*marshall enum: */
-	memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);
-	
-	/*marshall TriaVertexInput data: */
-	memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-	memcpy(marshalled_dataset,&values,sizeof(values));marshalled_dataset+=sizeof(values);
-
-	*pmarshalled_dataset=marshalled_dataset;
-}
-/*}}}*/
-/*FUNCTION TriaVertexInput::MarshallSize{{{1*/
-int   TriaVertexInput::MarshallSize(){
-	
-	return sizeof(values)+
-		+sizeof(enum_type)+
-		+sizeof(int); //sizeof(int) for enum value
-}
-/*}}}*/
-/*FUNCTION TriaVertexInput::Demarshall{{{1*/
-void  TriaVertexInput::Demarshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   i;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*this time, no need to get enum type, the pointer directly points to the beginning of the 
-	 *object data (thanks to DataSet::Demarshall):*/
-	memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-	memcpy(&values,marshalled_dataset,sizeof(values));marshalled_dataset+=sizeof(values);
-
-	/*return: */
-	*pmarshalled_dataset=marshalled_dataset;
-	return;
-}
-/*}}}*/
-#endif
-/*FUNCTION TriaVertexInput::ObjectEnum{{{1*/
-int TriaVertexInput::ObjectEnum(void){
-
-	return TriaVertexInputEnum;
-
-}
-/*}}}*/
-/*FUNCTION TriaVertexInput::copy{{{1*/
-Object* TriaVertexInput::copy() {
-	
-	return new TriaVertexInput(this->enum_type,this->values);
-
-}
-/*}}}*/
-	
-/*TriaVertexInput management*/
-/*FUNCTION TriaVertexInput::InstanceEnum{{{1*/
-int TriaVertexInput::InstanceEnum(void){
-
-	return this->enum_type;
-
-}
-/*}}}*/
-/*FUNCTION TriaVertexInput::SpawnTriaInput{{{1*/
-Input* TriaVertexInput::SpawnTriaInput(int* indices){
-
-	/*output*/
-	TriaVertexInput* outinput=NULL;
-
-	/*Create new Tria input (copy of current input)*/
-	outinput=new TriaVertexInput(this->enum_type,&this->values[0]);
-
-	/*Assign output*/
-	return outinput;
-
-}
-/*}}}*/
-/*FUNCTION TriaVertexInput::SpawnResult{{{1*/
-ElementResult* TriaVertexInput::SpawnResult(int step, double time){
-
-	return new TriaVertexElementResult(this->enum_type,this->values,step,time);
-
-}
-/*}}}*/
-
-/*Object functions*/
-/*FUNCTION TriaVertexInput::GetInputValue(double* pvalue,GaussTria* gauss){{{1*/
-void TriaVertexInput::GetInputValue(double* pvalue,GaussTria* gauss){
-
-	/*Call TriaRef function*/
-	TriaRef::GetInputValue(pvalue,&values[0],gauss);
-
-}
-/*}}}*/
-/*FUNCTION TriaVertexInput::GetInputDerivativeValue(double* p, double* xyz_list, GaussTria* gauss){{{1*/
-void TriaVertexInput::GetInputDerivativeValue(double* p, double* xyz_list, GaussTria* gauss){
-
-	/*Call TriaRef function*/
-	TriaRef::GetInputDerivativeValue(p,&values[0],xyz_list,gauss);
-}
-/*}}}*/
-/*FUNCTION TriaVertexInput::GetVxStrainRate2d{{{1*/
-void TriaVertexInput::GetVxStrainRate2d(double* epsilonvx,double* xyz_list, GaussTria* gauss){
-
-	/*Intermediary*/
-	int       i;
-	const int numnodes=3;
-	double B[3][NDOF2*numnodes];
-	double velocity[3][NDOF2];
-
-	/*Get B matrix: */
-	GetBMacAyeal(&B[0][0], xyz_list, gauss);
-
-	/*Here, we are computing the strain rate of (vx,0)*/
-	for(i=0;i<3;i++){
-		velocity[i][0]=this->values[i];
-		velocity[i][1]=0.0;
-	}
-	/*Get epsilon(vx) = B*velocity*/
-	MatrixMultiply( &B[0][0],3,NDOF2*numnodes,0,
-				&velocity[0][0],NDOF2*numnodes,1,0,
-				epsilonvx,0);
-}
-/*}}}*/
-/*FUNCTION TriaVertexInput::GetVyStrainRate2d{{{1*/
-void TriaVertexInput::GetVyStrainRate2d(double* epsilonvy,double* xyz_list, GaussTria* gauss){
-
-	/*Intermediary*/
-	int       i;
-	const int numnodes=3;
-	double B[3][NDOF2*numnodes];
-	double velocity[3][NDOF2];
-
-	/*Get B matrix: */
-	GetBMacAyeal(&B[0][0], xyz_list, gauss);
-
-	/*Here, we are computing the strain rate of (0,vy)*/
-	for(i=0;i<3;i++){
-		velocity[i][0]=0.0;
-		velocity[i][1]=this->values[i];
-	}
-	/*Get epsilon(vy) = B*velocity*/
-	MatrixMultiply( &B[0][0],3,NDOF2*numnodes,0,
-				&velocity[0][0],NDOF2*numnodes,1,0,
-				epsilonvy,0);
-}
-/*}}}*/
-/*FUNCTION TriaVertexInput::ChangeEnum{{{1*/
-void TriaVertexInput::ChangeEnum(int newenumtype){
-	this->enum_type=newenumtype;
-}
-/*}}}*/
-/*FUNCTION TriaVertexInput::GetInputAverage{{{1*/
-void TriaVertexInput::GetInputAverage(double* pvalue){
-	*pvalue=1./3.*(values[0]+values[1]+values[2]);
-}
-/*}}}*/
-
-/*Intermediary*/
-/*FUNCTION TriaVertexInput::SquareMin{{{1*/
-void TriaVertexInput::SquareMin(double* psquaremin, bool process_units,Parameters* parameters){
-
-	int i;
-	const int numnodes=3;
-	double valuescopy[numnodes];
-	double squaremin;
-
-	/*First,  copy values, to process units if requested: */
-	for(i=0;i<numnodes;i++)valuescopy[i]=this->values[i];
-
-	/*Process units if requested: */
-	if(process_units)UnitConversion(&valuescopy[0],numnodes,IuToExtEnum,enum_type);
-
-	/*Now, figure out minimum of valuescopy: */
-	squaremin=pow(valuescopy[0],2);
-	for(i=1;i<numnodes;i++){
-		if(pow(valuescopy[i],2)<squaremin)squaremin=pow(valuescopy[i],2);
-	}
-	/*Assign output pointers:*/
-	*psquaremin=squaremin;
-}
-/*}}}*/
-/*FUNCTION TriaVertexInput::ContrainMin{{{1*/
-void TriaVertexInput::ConstrainMin(double minimum){
-	
-	int i;
-	const int numnodes=3;
-
-	for(i=0;i<numnodes;i++) if (values[i]<minimum) values[i]=minimum;
-}
-/*}}}*/
-/*FUNCTION TriaVertexInput::InfinityNorm{{{1*/
-double TriaVertexInput::InfinityNorm(void){
-
-	/*Output*/
-	double norm=0;
-	const int numnodes=3;
-
-	for(int i=0;i<numnodes;i++) if(fabs(values[i])>norm) norm=fabs(values[i]);
-	return norm;
-}
-/*}}}*/
-/*FUNCTION TriaVertexInput::Max{{{1*/
-double TriaVertexInput::Max(void){
-
-	const int numnodes=3;
-	double    max=values[0];
-
-	for(int i=1;i<numnodes;i++){
-		if(values[i]>max) max=values[i];
-	}
-	return max;
-}
-/*}}}*/
-/*FUNCTION TriaVertexInput::MaxAbs{{{1*/
-double TriaVertexInput::MaxAbs(void){
-
-	const int numnodes=3;
-	double    max=fabs(values[0]);
-
-	for(int i=1;i<numnodes;i++){
-		if(fabs(values[i])>max) max=fabs(values[i]);
-	}
-	return max;
-}
-/*}}}*/
-/*FUNCTION TriaVertexInput::Min{{{1*/
-double TriaVertexInput::Min(void){
-
-	const int numnodes=3;
-	double    min=values[0];
-
-	for(int i=1;i<numnodes;i++){
-		if(values[i]<min) min=values[i];
-	}
-	return min;
-}
-/*}}}*/
-/*FUNCTION TriaVertexInput::MinAbs{{{1*/
-double TriaVertexInput::MinAbs(void){
-
-	const int numnodes=3;
-	double    min=fabs(values[0]);
-
-	for(int i=1;i<numnodes;i++){
-		if(fabs(values[i])<min) min=fabs(values[i]);
-	}
-	return min;
-}
-/*}}}*/
-/*FUNCTION TriaVertexInput::Scale{{{1*/
-void TriaVertexInput::Scale(double scale_factor){
-	
-	int i;
-	const int numnodes=3;
-
-	for(i=0;i<numnodes;i++)values[i]=values[i]*scale_factor;
-}
-/*}}}*/
-/*FUNCTION TriaVertexInput::ArtificialNoise{{{1*/
-void TriaVertexInput::ArtificialNoise(double min,double max){
-
-	int i;
-	const int numnodes=3;
-	double noise;
-
-	/*Compute random number between bounds:
-	 * rand() outputs an integer in [0 RAND_MAX]
-	 * (double)rand()/RAND_MAX is in [0 1]
-	 */
-	 noise=min+(max-min)*(double)rand()/RAND_MAX;
-
-	for(i=0;i<numnodes;i++)values[i]=values[i]+noise;
-}
-/*}}}*/
-/*FUNCTION TriaVertexInput::AXPY{{{1*/
-void TriaVertexInput::AXPY(Input* xinput,double scalar){
-
-	int i;
-	const int numnodes=3;
-	TriaVertexInput*  xtriavertexinput=NULL;
-
-	/*xinput is of the same type, so cast it: */
-	xtriavertexinput=(TriaVertexInput*)xinput;
-
-	/*Carry out the AXPY operation depending on type:*/
-	switch(xinput->ObjectEnum()){
-
-		case TriaVertexInputEnum :
-			for(i=0;i<numnodes;i++)this->values[i]=this->values[i]+scalar*xtriavertexinput->values[i];
-			return;
-
-		default :
-			_error_("not implemented yet");
-	}
-
-}
-/*}}}*/
-/*FUNCTION TriaVertexInput::Constrain{{{1*/
-void TriaVertexInput::Constrain(double cm_min, double cm_max){
-
-	int i;
-	const int numnodes=3;
-		
-	if(!isnan(cm_min)) for(i=0;i<numnodes;i++)if (this->values[i]<cm_min)this->values[i]=cm_min;
-	if(!isnan(cm_max)) for(i=0;i<numnodes;i++)if (this->values[i]>cm_max)this->values[i]=cm_max;
-
-}
-/*}}}*/
-/*FUNCTION TriaVertexInput::GetVectorFromInputs{{{1*/
-void TriaVertexInput::GetVectorFromInputs(Vec vector,int* doflist){
-
-	const int numvertices=3;
-	VecSetValues(vector,numvertices,doflist,(const double*)this->values,INSERT_VALUES);
-
-} /*}}}*/
-/*FUNCTION TriaVertexInput::GetValuesPtr{{{1*/
-void TriaVertexInput::GetValuesPtr(double** pvalues,int* pnum_values){
-
-	*pvalues=this->values;
-	if(pnum_values)*pnum_values=3;
-
-}
-/*}}}*/
-/*FUNCTION TriaVertexInput::PointwiseMin{{{1*/
-Input* TriaVertexInput::PointwiseMin(Input* inputB){
-
-	/*Ouput*/
-	TriaVertexInput* outinput=NULL;
-
-	/*Intermediaries*/
-	int               i;
-	TriaVertexInput *xinputB     = NULL;
-	int               B_numvalues;
-	const int         numnodes    = 3;
-	double            minvalues[numnodes];
-
-	/*Check that inputB is of the same type*/
-	if (inputB->ObjectEnum()!=TriaVertexInputEnum) _error_("Operation not permitted because inputB is of type %s",EnumToStringx(inputB->ObjectEnum()));
-	xinputB=(TriaVertexInput*)inputB;
-
-	/*Create point wise min*/
-	for(i=0;i<numnodes;i++){
-		if(this->values[i] > xinputB->values[i]) minvalues[i]=xinputB->values[i];
-		else minvalues[i]=this->values[i];
-	}
-
-	/*Create new Tria vertex input (copy of current input)*/
-	outinput=new TriaVertexInput(this->enum_type,&minvalues[0]);
-
-	/*Return output pointer*/
-	return outinput;
-
-}
-/*}}}*/
-/*FUNCTION TriaVertexInput::PointwiseMax{{{1*/
-Input* TriaVertexInput::PointwiseMax(Input* inputB){
-
-	/*Ouput*/
-	TriaVertexInput* outinput=NULL;
-
-	/*Intermediaries*/
-	int               i;
-	TriaVertexInput *xinputB     = NULL;
-	int               B_numvalues;
-	const int         numnodes    = 3;
-	double            maxvalues[numnodes];
-
-	/*Check that inputB is of the same type*/
-	if (inputB->ObjectEnum()!=TriaVertexInputEnum) _error_("Operation not permitted because inputB is of type %s",EnumToStringx(inputB->ObjectEnum()));
-	xinputB=(TriaVertexInput*)inputB;
-
-	/*Create point wise max*/
-	for(i=0;i<numnodes;i++){
-		if(this->values[i] < xinputB->values[i]) maxvalues[i]=xinputB->values[i];
-		else maxvalues[i]=this->values[i];
-	}
-
-	/*Create new Tria vertex input (copy of current input)*/
-	outinput=new TriaVertexInput(this->enum_type,&maxvalues[0]);
-
-	/*Return output pointer*/
-	return outinput;
-
-}
-/*}}}*/
-/*FUNCTION TriaVertexInput::Configure{{{1*/
-void TriaVertexInput::Configure(Parameters* parameters){
-	/*do nothing: */
-}
-/*}}}*/
Index: sm/trunk/src/c/objects/Inputs/TriaVertexInput.h
===================================================================
--- /issm/trunk/src/c/objects/Inputs/TriaVertexInput.h	(revision 11526)
+++ 	(revision )
@@ -1,89 +1,0 @@
-/*! \file TriaVertexInput.h 
- *  \brief: header file for triavertexinput object
- */
-
-
-#ifndef _TRIAVERTEXINPUT_H_
-#define _TRIAVERTEXINPUT_H_
-
-/*Headers:*/
-/*{{{1*/
-#include "./Input.h"
-#include "../Elements/TriaRef.h"
-class GaussTria;
-/*}}}*/
-
-class TriaVertexInput: public Input,public TriaRef{
-
-	public:
-		/*just hold 3 values for 3 vertices: */
-		int    enum_type;
-		double values[3];
-
-		/*TriaVertexInput constructors, destructors: {{{1*/
-		TriaVertexInput();
-		TriaVertexInput(int enum_type,double* values);
-		~TriaVertexInput();
-		/*}}}*/
-		/*Object virtual functions definitions:{{{1 */
-		void  Echo();
-		void  DeepEcho();
-		int   Id(); 
-		int   MyRank();
-		#ifdef _SERIAL_
-		void  Marshall(char** pmarshalled_dataset);
-		int   MarshallSize();
-		void  Demarshall(char** pmarshalled_dataset);
-		#endif
-		int   ObjectEnum();
-		Object* copy();
-		/*}}}*/
-		/*TriaVertexInput management: {{{1*/
-		int   InstanceEnum();
-		Input* SpawnTriaInput(int* indices);
-		Input* PointwiseDivide(Input* inputB){_error_("not implemented yet");};
-		Input* PointwiseMin(Input* inputB);
-		Input* PointwiseMax(Input* inputB);
-		ElementResult* SpawnResult(int step, double time);
-		void AddTimeValues(double* values,int step,double time){_error_("not supported yet");};
-		void Configure(Parameters* parameters);
-		/*}}}*/
-		/*numerics: {{{1*/
-		void GetInputValue(bool* pvalue){_error_("not implemented yet");}
-		void GetInputValue(int* pvalue){_error_("not implemented yet");}
-		void GetInputValue(double* pvalue){_error_("not implemented yet");}
-		void GetInputValue(double* pvalue,GaussTria* gauss);
-		void GetInputValue(double* pvalue,GaussPenta* gauss){_error_("not implemented yet");};
-		void GetInputValue(double* pvalue,GaussTria* gauss ,int index){_error_("not implemented yet");};
-		void GetInputValue(double* pvalue,GaussPenta* gauss,int index){_error_("not implemented yet");};
-		void GetInputDerivativeValue(double* derivativevalues, double* xyz_list, GaussTria* gauss);
-		void GetInputDerivativeValue(double* derivativevalues, double* xyz_list, GaussPenta* gauss){_error_("not implemented yet");};
-		void GetInputAverage(double* pvalue);
-		void GetVxStrainRate2d(double* epsilonvx,double* xyz_list, GaussTria* gauss);
-		void GetVyStrainRate2d(double* epsilonvy,double* xyz_list, GaussTria* gauss);
-		void GetVxStrainRate3d(double* epsilonvx,double* xyz_list, GaussPenta* gauss){_error_("not implemented yet");};
-		void GetVyStrainRate3d(double* epsilonvy,double* xyz_list, GaussPenta* gauss){_error_("not implemented yet");};
-		void GetVzStrainRate3d(double* epsilonvz,double* xyz_list, GaussPenta* gauss){_error_("not implemented yet");};
-		void GetVxStrainRate3dPattyn(double* epsilonvx,double* xyz_list, GaussPenta* gauss){_error_("not implemented yet");};
-		void GetVyStrainRate3dPattyn(double* epsilonvy,double* xyz_list, GaussPenta* gauss){_error_("not implemented yet");};
-		void ChangeEnum(int newenumtype);
-
-		void SquareMin(double* psquaremin, bool process_units,Parameters* parameters);
-		void ConstrainMin(double minimum);
-		void Scale(double scale_factor);
-		void ArtificialNoise(double min,double max);
-		void AXPY(Input* xinput,double scalar);
-		void Constrain(double cm_min, double cm_max);
-		double InfinityNorm(void);
-		double Max(void);
-		double MaxAbs(void);
-		double Min(void);
-		double MinAbs(void);
-		void Extrude(void){_error_("not supported yet");};
-		void VerticallyIntegrate(Input* thickness_input){_error_("not supported yet");};
-		void GetVectorFromInputs(Vec vector,int* doflist);
-		void GetValuesPtr(double** pvalues,int* pnum_values);
-		/*}}}*/
-
-};
-#endif  /* _TRIAVERTEXINPUT_H */
Index: /issm/trunk/src/c/objects/KML/KMLFileReadUtils.cpp
===================================================================
--- /issm/trunk/src/c/objects/KML/KMLFileReadUtils.cpp	(revision 11526)
+++ /issm/trunk/src/c/objects/KML/KMLFileReadUtils.cpp	(revision 11527)
@@ -229,4 +229,59 @@
 /*}}}*/
 
+/*FUNCTION  KMLFileTagName {{{1*/
+char* KMLFileTagName(char* pname,
+					 char* ktag){
+
+	return(KMLFileTagName(pname,NULL,0,
+						  ktag));
+}
+/*}}}*/
+
+/*FUNCTION  KMLFileTagName {{{1*/
+char* KMLFileTagName(char* pname,int *m,int maxlen,
+					 char* ktag){
+
+/*  for the given tag buffer, read and store the name  */
+
+	char*   ktagi;
+	char*   ktokn;
+
+	if (strncmp(&ktag[0],"<"        ,1) || strncmp(&ktag[strlen(ktag)-1],">",1))
+		_error_("KMLFileTagName -- Missing tag delimiters in %s.\n",ktag);
+
+/*  strtok modifies ktag, so work on copy  */
+
+	ktagi=(char *) xmalloc((strlen(ktag)+1)*sizeof(char));
+	memcpy(ktagi,ktag,(strlen(ktag)+1)*sizeof(char));
+
+/*  skip opening delimeter and find subsequent blank or closing delimiter  */
+
+	ktokn=strtok(ktagi,"< >");
+//	_printf_(true,"KMLFileTagName -- initial token=\"%s\".\n",ktokn);
+
+	if (!pname) {
+		if (maxlen)
+			pname=(char *) xmalloc((maxlen       +1)*sizeof(char));
+		else
+			pname=(char *) xmalloc((strlen(ktokn)+1)*sizeof(char));
+	}
+
+	if (maxlen && (maxlen < strlen(ktokn))) {
+		_printf_(true,"KMLFileTagName -- string field too short for %s.\n",ktag);
+		_printf_(true,"KMLFileTagName -- \"%s\" truncated to %d characters.\n",ktokn,maxlen);
+		strncpy(pname,ktokn,maxlen);
+	}
+	else
+		memcpy(pname,ktokn,(strlen(ktokn)+1)*sizeof(char));
+
+	xfree((void**)&ktagi);
+
+	if (m)
+		*m=strlen(pname);
+
+	return(pname);
+}
+/*}}}*/
+
 /*FUNCTION  KMLFileTagAttrib {{{1*/
 int KMLFileTagAttrib(KML_Object* kobj,
@@ -352,4 +407,15 @@
 
 /*FUNCTION  KMLFileTokenParse {{{1*/
+char* KMLFileTokenParse(char* pstr,
+						char* ktag,
+						FILE* fid){
+
+	return(KMLFileTokenParse(pstr,NULL,0,
+							 ktag,
+							 fid));
+}
+/*}}}*/
+
+/*FUNCTION  KMLFileTokenParse {{{1*/
 char* KMLFileTokenParse(char* pstr,int *m,int maxlen,
 						char* ktag,
@@ -357,5 +423,4 @@
 
 	char*   kstr;
-	char*   pstro=NULL;
 
 /*  get next token and allocate if necessary  */
@@ -371,5 +436,4 @@
 		else
 			pstr=(char *) xmalloc((strlen(kstr)+1)*sizeof(char));
-		pstro=pstr;
 	}
 
@@ -401,5 +465,5 @@
 //	_printf_(true,"KMLFileTokenParse -- %s=\"%s\".\n",ktag,pstr);
 
-	return(pstro);
+	return(pstr);
 }
 /*}}}*/
Index: /issm/trunk/src/c/objects/KML/KMLFileReadUtils.h
===================================================================
--- /issm/trunk/src/c/objects/KML/KMLFileReadUtils.h	(revision 11526)
+++ /issm/trunk/src/c/objects/KML/KMLFileReadUtils.h	(revision 11527)
@@ -21,4 +21,8 @@
 						int c,
 						int bufblk);
+char* KMLFileTagName(char* pname,
+					 char* ktag);
+char* KMLFileTagName(char* pname,int *m,int maxlen,
+					 char* ktag);
 int KMLFileTagAttrib(KML_Object* kobj,
 					 char* ktag);
@@ -29,7 +33,10 @@
 					  char* ktag,
 					  FILE* fid);
+char* KMLFileTokenParse(char* pstr,
+						char* ktag,
+						FILE* fid);
 char* KMLFileTokenParse(char* pstr,int *m,int maxlen,
-					  char* ktag,
-					  FILE* fid);
+						char* ktag,
+						FILE* fid);
 int KMLFileTokenParse(float* pfval,
 					  char* ktag,
Index: /issm/trunk/src/c/objects/KML/KML_Container.cpp
===================================================================
--- /issm/trunk/src/c/objects/KML/KML_Container.cpp	(revision 11526)
+++ /issm/trunk/src/c/objects/KML/KML_Container.cpp	(revision 11527)
@@ -74,5 +74,4 @@
 
 	memcpy(indent2,indent,(strlen(indent)+1)*sizeof(char));
-
 	strcat(indent2,"  ");
 
Index: /issm/trunk/src/c/objects/KML/KML_Feature.cpp
===================================================================
--- /issm/trunk/src/c/objects/KML/KML_Feature.cpp	(revision 11526)
+++ /issm/trunk/src/c/objects/KML/KML_Feature.cpp	(revision 11527)
@@ -96,5 +96,4 @@
 
 	memcpy(indent2,indent,(strlen(indent)+1)*sizeof(char));
-
 	strcat(indent2,"  ");
 
Index: /issm/trunk/src/c/objects/KML/KML_File.cpp
===================================================================
--- /issm/trunk/src/c/objects/KML/KML_File.cpp	(revision 11526)
+++ /issm/trunk/src/c/objects/KML/KML_File.cpp	(revision 11527)
@@ -24,5 +24,5 @@
 KML_File::KML_File(){
 
-	kmlobj    =new DataSet;
+	;
 
 }
@@ -31,8 +31,5 @@
 KML_File::~KML_File(){
 
-	if (kmlobj) {
-		delete kmlobj;
-		kmlobj    =NULL;
-	}
+	;
 
 }
@@ -47,6 +44,4 @@
 	_printf_(flag,"KML_File:\n");
 	KML_Object::Echo();
-
-	_printf_(flag,"        kmlobj: (size=%d)\n" ,kmlobj->Size());
 
 	return;
@@ -66,25 +61,8 @@
 void  KML_File::DeepEcho(const char* indent){
 
-	int   i;
-	char  indent2[81];
 	bool  flag=true;
 
 	_printf_(flag,"%sKML_File:\n",indent);
 	KML_Object::DeepEcho(indent);
-
-/*  loop over the kml objects for the file  */
-
-	memcpy(indent2,indent,(strlen(indent)+1)*sizeof(char));
-
-	strcat(indent2,"  ");
-
-	if (kmlobj->Size())
-		for (i=0; i<kmlobj->Size(); i++) {
-			_printf_(flag,"%s        kmlobj: -------- begin [%d] --------\n" ,indent,i);
-			((KML_Object *)kmlobj->GetObjectByOffset(i))->DeepEcho(indent2);
-			_printf_(flag,"%s        kmlobj: --------  end  [%d] --------\n" ,indent,i);
-		}
-	else
-		_printf_(flag,"%s        kmlobj: [empty]\n"    ,indent);
 
 	return;
@@ -94,7 +72,4 @@
 void  KML_File::Write(FILE* filout,const char* indent){
 
-	int   i;
-	char  indent2[81];
-
 	fprintf(filout,"%s<kml",indent);
 	WriteAttrib(filout," ");
@@ -103,13 +78,4 @@
 
 	KML_Object::Write(filout,indent);
-
-/*  loop over the kml objects for the file  */
-
-	memcpy(indent2,indent,(strlen(indent)+1)*sizeof(char));
-
-	strcat(indent2,"  ");
-
-	for (i=0; i<kmlobj->Size(); i++)
-		((KML_Object *)kmlobj->GetObjectByOffset(i))->Write(filout,indent2);
 
 	fprintf(filout,"%s</kml>\n",indent);
@@ -145,106 +111,4 @@
 			_error_("KML_File::Read -- Unexpected field \"%s\".\n",kstri);
 
-		else if (!strncmp(kstri,"<Placemark",10)) {
-			kobj=(KML_Object*)new KML_Placemark();
-			kobj->Read(fid,kstri);
-			kmlobj    ->AddObject((Object*)kobj);
-		}
-
-		else if (!strncmp(kstri,"<Folder", 7)) {
-			kobj=(KML_Object*)new KML_Folder();
-			kobj->Read(fid,kstri);
-			kmlobj    ->AddObject((Object*)kobj);
-		}
-
-		else if (!strncmp(kstri,"<Document", 9)) {
-			kobj=(KML_Object*)new KML_Document();
-			kobj->Read(fid,kstri);
-			kmlobj    ->AddObject((Object*)kobj);
-		}
-
-		else if (!strncmp(kstri,"<GroundOverlay",14)) {
-			kobj=(KML_Object*)new KML_GroundOverlay();
-			kobj->Read(fid,kstri);
-			kmlobj    ->AddObject((Object*)kobj);
-		}
-
-		else if (!strncmp(kstri,"<LatLonBox",10)) {
-			kobj=(KML_Object*)new KML_LatLonBox();
-			kobj->Read(fid,kstri);
-			kmlobj    ->AddObject((Object*)kobj);
-		}
-
-		else if (!strncmp(kstri,"<Icon", 5)) {
-			kobj=(KML_Object*)new KML_Icon();
-			kobj->Read(fid,kstri);
-			kmlobj    ->AddObject((Object*)kobj);
-		}
-
-		else if (!strncmp(kstri,"<Point", 6)) {
-			kobj=(KML_Object*)new KML_Point();
-			kobj->Read(fid,kstri);
-			kmlobj    ->AddObject((Object*)kobj);
-		}
-
-		else if (!strncmp(kstri,"<LineString",11)) {
-			kobj=(KML_Object*)new KML_LineString();
-			kobj->Read(fid,kstri);
-			kmlobj    ->AddObject((Object*)kobj);
-		}
-
-		else if (!strncmp(kstri,"<LinearRing",11)) {
-			kobj=(KML_Object*)new KML_LinearRing();
-			kobj->Read(fid,kstri);
-			kmlobj    ->AddObject((Object*)kobj);
-		}
-
-		else if (!strncmp(kstri,"<Polygon", 8)) {
-			kobj=(KML_Object*)new KML_Polygon();
-			kobj->Read(fid,kstri);
-			kmlobj    ->AddObject((Object*)kobj);
-		}
-
-		else if (!strncmp(kstri,"<MultiGeometry",14)) {
-			kobj=(KML_Object*)new KML_MultiGeometry();
-			kobj->Read(fid,kstri);
-			kmlobj    ->AddObject((Object*)kobj);
-		}
-
-//		else if (!strncmp(kstri,"<IconStyle",10)) {
-//			kobj=(KML_Object*)new KML_IconStyle();
-//			kobj->Read(fid,kstri);
-//			kmlobj    ->AddObject((Object*)kobj);
-//		}
-
-//		else if (!strncmp(kstri,"<LabelStyle",11)) {
-//			kobj=(KML_Object*)new KML_LabelStyle();
-//			kobj->Read(fid,kstri);
-//			kmlobj    ->AddObject((Object*)kobj);
-//		}
-
-		else if (!strncmp(kstri,"<LineStyle",10)) {
-			kobj=(KML_Object*)new KML_LineStyle();
-			kobj->Read(fid,kstri);
-			kmlobj    ->AddObject((Object*)kobj);
-		}
-
-		else if (!strncmp(kstri,"<PolyStyle",10)) {
-			kobj=(KML_Object*)new KML_PolyStyle();
-			kobj->Read(fid,kstri);
-			kmlobj    ->AddObject((Object*)kobj);
-		}
-
-//		else if (!strncmp(kstri,"<BalloonStyle",13)) {
-//			kobj=(KML_Object*)new KML_BalloonStyle();
-//			kobj->Read(fid,kstri);
-//			kmlobj    ->AddObject((Object*)kobj);
-//		}
-
-//		else if (!strncmp(kstri,"<ListStyle",10)) {
-//			kobj=(KML_Object*)new KML_ListStyle();
-//			kobj->Read(fid,kstri);
-//			kmlobj    ->AddObject((Object*)kobj);
-//		}
-
 		else if (!strncmp(kstri,"<",1))
 			KML_Object::Read(fid,kstri);
Index: /issm/trunk/src/c/objects/KML/KML_File.h
===================================================================
--- /issm/trunk/src/c/objects/KML/KML_File.h	(revision 11526)
+++ /issm/trunk/src/c/objects/KML/KML_File.h	(revision 11527)
@@ -19,6 +19,4 @@
 
 	public:
-
-		DataSet* kmlobj;
 
 		/*KML_File constructors, destructors {{{1*/
Index: /issm/trunk/src/c/objects/KML/KML_GroundOverlay.cpp
===================================================================
--- /issm/trunk/src/c/objects/KML/KML_GroundOverlay.cpp	(revision 11526)
+++ /issm/trunk/src/c/objects/KML/KML_GroundOverlay.cpp	(revision 11527)
@@ -80,5 +80,4 @@
 
 	memcpy(indent2,indent,(strlen(indent)+1)*sizeof(char));
-
 	strcat(indent2,"  ");
 
Index: /issm/trunk/src/c/objects/KML/KML_MultiGeometry.cpp
===================================================================
--- /issm/trunk/src/c/objects/KML/KML_MultiGeometry.cpp	(revision 11526)
+++ /issm/trunk/src/c/objects/KML/KML_MultiGeometry.cpp	(revision 11527)
@@ -78,5 +78,4 @@
 
 	memcpy(indent2,indent,(strlen(indent)+1)*sizeof(char));
-
 	strcat(indent2,"  ");
 
Index: /issm/trunk/src/c/objects/KML/KML_Object.cpp
===================================================================
--- /issm/trunk/src/c/objects/KML/KML_Object.cpp	(revision 11526)
+++ /issm/trunk/src/c/objects/KML/KML_Object.cpp	(revision 11527)
@@ -26,4 +26,5 @@
 	attrib    =new DataSet;
 	commnt    =new DataSet;
+	kmlobj    =new DataSet;
 
 }
@@ -40,4 +41,8 @@
 		commnt    =NULL;
 	}
+	if (kmlobj) {
+		delete kmlobj;
+		kmlobj    =NULL;
+	}
 
 }
@@ -52,4 +57,5 @@
 	_printf_(flag,"        attrib: (size=%d)\n" ,attrib->Size());
 	_printf_(flag,"        commnt: (size=%d)\n" ,commnt->Size());
+	_printf_(flag,"        kmlobj: (size=%d)\n" ,kmlobj->Size());
 
 	return;
@@ -70,4 +76,5 @@
 
 	int   i;
+	char  indent2[81];
 	bool  flag=true;
 
@@ -90,4 +97,18 @@
 		_printf_(flag,"%s        commnt: [empty]\n"    ,indent);
 
+/*  loop over the unknown objects for the object  */
+
+	memcpy(indent2,indent,(strlen(indent)+1)*sizeof(char));
+	strcat(indent2,"  ");
+
+	if (kmlobj->Size())
+		for (i=0; i<kmlobj->Size(); i++) {
+            _printf_(flag,"%s        kmlobj: -------- begin [%d] --------\n" ,indent,i);
+			((KML_Unknown *)kmlobj->GetObjectByOffset(i))->DeepEcho(indent2);
+            _printf_(flag,"%s        kmlobj: --------  end  [%d] --------\n" ,indent,i);
+		}
+	else
+		_printf_(flag,"%s        kmlobj: [empty]\n"    ,indent);
+
 	return;
 }
@@ -96,8 +117,19 @@
 void  KML_Object::Write(FILE* filout,const char* indent){
 
+	int   i;
+	char  indent2[81];
+
 //  attributes always written in keyword line of derived classes
 //  comments always written after keyword line of derived classes
 
-	;
+/*  loop over the unknown objects for the object  */
+
+	memcpy(indent2,indent,(strlen(indent)+1)*sizeof(char));
+	strcat(indent2,"  ");
+
+	if (kmlobj->Size())
+		for (i=0; i<kmlobj->Size(); i++) {
+			((KML_Unknown *)kmlobj->GetObjectByOffset(i))->Write(filout,indent2);
+		}
 
 	return;
@@ -106,4 +138,6 @@
 /*FUNCTION KML_Object::Read {{{1*/
 void  KML_Object::Read(FILE* fid,char* kstr){
+
+	KML_Object*  kobj;
 
 /*  process field within opening and closing tags  */
@@ -116,8 +150,113 @@
 		_error_("KML_Object::Read -- Unexpected field \"%s\".\n",kstr);
 
+	else if (!strncmp(kstr,"<Placemark",10)) {
+		kobj=(KML_Object*)new KML_Placemark();
+		kobj->Read(fid,kstr);
+		kmlobj    ->AddObject((Object*)kobj);
+	}
+
+	else if (!strncmp(kstr,"<Folder", 7)) {
+		kobj=(KML_Object*)new KML_Folder();
+		kobj->Read(fid,kstr);
+		kmlobj    ->AddObject((Object*)kobj);
+	}
+
+	else if (!strncmp(kstr,"<Document", 9)) {
+		kobj=(KML_Object*)new KML_Document();
+		kobj->Read(fid,kstr);
+		kmlobj    ->AddObject((Object*)kobj);
+	}
+
+	else if (!strncmp(kstr,"<GroundOverlay",14)) {
+		kobj=(KML_Object*)new KML_GroundOverlay();
+		kobj->Read(fid,kstr);
+		kmlobj    ->AddObject((Object*)kobj);
+	}
+
+	else if (!strncmp(kstr,"<LatLonBox",10)) {
+		kobj=(KML_Object*)new KML_LatLonBox();
+		kobj->Read(fid,kstr);
+		kmlobj    ->AddObject((Object*)kobj);
+	}
+
+	else if (!strncmp(kstr,"<Icon", 5)) {
+		kobj=(KML_Object*)new KML_Icon();
+		kobj->Read(fid,kstr);
+		kmlobj    ->AddObject((Object*)kobj);
+	}
+
+	else if (!strncmp(kstr,"<Point", 6)) {
+		kobj=(KML_Object*)new KML_Point();
+		kobj->Read(fid,kstr);
+		kmlobj    ->AddObject((Object*)kobj);
+	}
+
+	else if (!strncmp(kstr,"<LineString",11)) {
+		kobj=(KML_Object*)new KML_LineString();
+		kobj->Read(fid,kstr);
+		kmlobj    ->AddObject((Object*)kobj);
+	}
+
+	else if (!strncmp(kstr,"<LinearRing",11)) {
+		kobj=(KML_Object*)new KML_LinearRing();
+		kobj->Read(fid,kstr);
+		kmlobj    ->AddObject((Object*)kobj);
+	}
+
+	else if (!strncmp(kstr,"<Polygon", 8)) {
+		kobj=(KML_Object*)new KML_Polygon();
+		kobj->Read(fid,kstr);
+		kmlobj    ->AddObject((Object*)kobj);
+	}
+
+	else if (!strncmp(kstr,"<MultiGeometry",14)) {
+		kobj=(KML_Object*)new KML_MultiGeometry();
+		kobj->Read(fid,kstr);
+		kmlobj    ->AddObject((Object*)kobj);
+	}
+
+//	else if (!strncmp(kstr,"<IconStyle",10)) {
+//		kobj=(KML_Object*)new KML_IconStyle();
+//		kobj->Read(fid,kstr);
+//		kmlobj    ->AddObject((Object*)kobj);
+//	}
+
+//	else if (!strncmp(kstr,"<LabelStyle",11)) {
+//		kobj=(KML_Object*)new KML_LabelStyle();
+//		kobj->Read(fid,kstr);
+//		kmlobj    ->AddObject((Object*)kobj);
+//	}
+
+	else if (!strncmp(kstr,"<LineStyle",10)) {
+		kobj=(KML_Object*)new KML_LineStyle();
+		kobj->Read(fid,kstr);
+		kmlobj    ->AddObject((Object*)kobj);
+	}
+
+	else if (!strncmp(kstr,"<PolyStyle",10)) {
+		kobj=(KML_Object*)new KML_PolyStyle();
+		kobj->Read(fid,kstr);
+		kmlobj    ->AddObject((Object*)kobj);
+	}
+
+//	else if (!strncmp(kstr,"<BalloonStyle",13)) {
+//		kobj=(KML_Object*)new KML_BalloonStyle();
+//		kobj->Read(fid,kstr);
+//		kmlobj    ->AddObject((Object*)kobj);
+//	}
+
+//	else if (!strncmp(kstr,"<ListStyle",10)) {
+//		kobj=(KML_Object*)new KML_ListStyle();
+//		kobj->Read(fid,kstr);
+//		kmlobj    ->AddObject((Object*)kobj);
+//	}
+
 	else if (!strncmp(kstr,"<",1)) {
 		_printf_(true,"KML_Object::Read -- Unrecognized opening tag %s.\n",kstr);
-		KMLFileTagSkip(kstr,
-					   fid);
+//		KMLFileTagSkip(kstr,
+//					   fid);
+		kobj=(KML_Object*)new KML_Unknown();
+		kobj->Read(fid,kstr);
+		kmlobj    ->AddObject((Object*)kobj);
 	}
 
Index: /issm/trunk/src/c/objects/KML/KML_Object.h
===================================================================
--- /issm/trunk/src/c/objects/KML/KML_Object.h	(revision 11526)
+++ /issm/trunk/src/c/objects/KML/KML_Object.h	(revision 11527)
@@ -21,4 +21,5 @@
 		DataSet* attrib;
 		DataSet* commnt;
+		DataSet* kmlobj;
 
 		/*KML_Object constructors, destructors {{{1*/
Index: /issm/trunk/src/c/objects/KML/KML_Overlay.cpp
===================================================================
--- /issm/trunk/src/c/objects/KML/KML_Overlay.cpp	(revision 11526)
+++ /issm/trunk/src/c/objects/KML/KML_Overlay.cpp	(revision 11527)
@@ -79,5 +79,4 @@
 
 	memcpy(indent2,indent,(strlen(indent)+1)*sizeof(char));
-
 	strcat(indent2,"  ");
 
Index: /issm/trunk/src/c/objects/KML/KML_Placemark.cpp
===================================================================
--- /issm/trunk/src/c/objects/KML/KML_Placemark.cpp	(revision 11526)
+++ /issm/trunk/src/c/objects/KML/KML_Placemark.cpp	(revision 11527)
@@ -76,5 +76,4 @@
 
 	memcpy(indent2,indent,(strlen(indent)+1)*sizeof(char));
-
 	strcat(indent2,"  ");
 
Index: /issm/trunk/src/c/objects/KML/KML_Polygon.cpp
===================================================================
--- /issm/trunk/src/c/objects/KML/KML_Polygon.cpp	(revision 11526)
+++ /issm/trunk/src/c/objects/KML/KML_Polygon.cpp	(revision 11527)
@@ -92,5 +92,4 @@
 
 	memcpy(indent2,indent,(strlen(indent)+1)*sizeof(char));
-
 	strcat(indent2,"  ");
 
@@ -134,5 +133,4 @@
 
 	memcpy(indent4,indent,(strlen(indent)+1)*sizeof(char));
-
 	strcat(indent4,"    ");
 
Index: /issm/trunk/src/c/objects/KML/KML_Style.cpp
===================================================================
--- /issm/trunk/src/c/objects/KML/KML_Style.cpp	(revision 11526)
+++ /issm/trunk/src/c/objects/KML/KML_Style.cpp	(revision 11527)
@@ -109,5 +109,4 @@
 
 	memcpy(indent2,indent,(strlen(indent)+1)*sizeof(char));
-
 	strcat(indent2,"  ");
 
Index: /issm/trunk/src/c/objects/KML/KML_Unknown.cpp
===================================================================
--- /issm/trunk/src/c/objects/KML/KML_Unknown.cpp	(revision 11527)
+++ /issm/trunk/src/c/objects/KML/KML_Unknown.cpp	(revision 11527)
@@ -0,0 +1,189 @@
+/*!\file KML_Unknown.cpp
+ * \brief: implementation of the kml_unknown 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 "../../io/io.h"
+#include "../../Container/Container.h"
+#include "../../include/include.h"
+/*}}}*/
+
+/*Constructors/destructor/copy*/
+/*FUNCTION KML_Unknown::KML_Unknown(){{{1*/
+KML_Unknown::KML_Unknown(){
+
+	name      =NULL;
+	value     =NULL;
+
+}
+/*}}}*/
+/*FUNCTION KML_Unknown::~KML_Unknown(){{{1*/
+KML_Unknown::~KML_Unknown(){
+
+	if (name      ) xfree((void**)&name);
+	if (value     ) xfree((void**)&value);
+
+}
+/*}}}*/
+
+/*Other*/
+/*FUNCTION KML_Unknown::Echo {{{1*/
+void  KML_Unknown::Echo(){
+
+	bool  flag=true;
+
+	_printf_(flag,"KML_Unknown %s:\n",name);
+	KML_Object::Echo();
+
+	if (value     )
+		_printf_(flag,"         value: \"%s\"\n"     ,value);
+    else
+        _printf_(flag,"         value: [none]\n"     );
+
+	return;
+}
+/*}}}*/
+/*FUNCTION KML_Unknown::DeepEcho {{{1*/
+void  KML_Unknown::DeepEcho(){
+
+	char  indent[81]="";
+
+	KML_Unknown::DeepEcho(indent);
+
+	return;
+}
+/*}}}*/
+/*FUNCTION KML_Unknown::DeepEcho {{{1*/
+void  KML_Unknown::DeepEcho(const char* indent){
+
+	char*        valuei;
+	char*        vtoken;
+	char         nl[]={'\n','\0'};
+	bool         flag=true;
+
+	_printf_(flag,"%sKML_Unknown %s:\n",indent,name);
+	KML_Object::DeepEcho(indent);
+
+	if (value     ) {
+		valuei=(char *) xmalloc((strlen(value)+1)*sizeof(char));
+		memcpy(valuei,value,(strlen(value)+1)*sizeof(char)); 
+        
+		vtoken=strtok(valuei,nl);
+		_printf_(flag,"%s         value: \"%s"     ,indent,vtoken);
+    
+		while (vtoken=strtok(NULL,nl))
+			_printf_(flag,"\n%s                 %s"     ,indent,vtoken);
+		_printf_(flag,"\"\n");
+
+		xfree((void**)&valuei);
+	}
+    else
+        _printf_(flag,"%s         value: [none]\n"     ,indent);
+
+	return;
+}
+/*}}}*/
+/*FUNCTION KML_Unknown::Write {{{1*/
+void  KML_Unknown::Write(FILE* filout,const char* indent){
+
+	char*        valuei;
+	char*        vtoken;
+	char         nl[]={'\n','\0'};
+
+	fprintf(filout,"%s<%s",indent,name);
+	WriteAttrib(filout," ");
+	fprintf(filout,">\n");
+	WriteCommnt(filout,indent);
+
+	if (value     ) {
+		valuei=(char *) xmalloc((strlen(value)+1)*sizeof(char));
+		memcpy(valuei,value,(strlen(value)+1)*sizeof(char)); 
+        
+		vtoken=strtok(valuei,nl);
+		fprintf(filout,"%s  %s\n",indent,vtoken);
+    
+		while (vtoken=strtok(NULL,nl))
+			fprintf(filout,"%s  %s\n",indent,vtoken);
+
+		xfree((void**)&valuei);
+	}
+
+	KML_Object::Write(filout,indent);
+
+	fprintf(filout,"%s</%s>\n",indent,name);
+
+	return;
+}
+/*}}}*/
+/*FUNCTION KML_Unknown::Read {{{1*/
+void  KML_Unknown::Read(FILE* fid,char* kstr){
+
+	char*        kstri;
+	int          ncom=0;
+	char**       pcom=NULL;
+	char         nl[]={'\n','\0'};
+
+/*  get object name  */
+
+	name=KMLFileTagName(NULL,
+						kstr);
+//	_printf_(true,"KML_Unknown::Read -- opening name=%s.\n",name);
+
+/*  get object attributes and check for solo tag  */
+
+	if (KMLFileTagAttrib(this,
+						 kstr))
+		return;
+
+/*  loop over and process fields within opening and closing tags  */
+
+	while (kstri=KMLFileToken(fid,
+							  &ncom,&pcom)) {
+//		_printf_(true,"KML_Unknown::Read -- kstri=%s.\n",kstri);
+		if      (!strncmp(&kstri[0],"</", 2) &&
+				 !strncmp(&kstri[2],name,strlen(name))) {
+//			_printf_(true,"KML_Unknown::Read -- closing name=%s.\n",name);
+			xfree((void**)&kstri);
+			break;
+		}
+		else if (!strncmp(kstri,"</",2))
+			_error_("KML_Unknown::Read -- Unexpected closing tag %s.\n",kstri);
+
+		else if (strncmp(kstri,"<",1)) {
+			if (value) {
+				value=(char *) xrealloc(value,(strlen(value)+1+strlen(kstri)+1)*sizeof(char));
+				strcat(value,nl);
+				strcat(value,kstri);
+			}
+			else {
+				value=(char *) xmalloc((strlen(kstri)+1)*sizeof(char));
+				memcpy(value,kstri,(strlen(kstri)+1)*sizeof(char));
+			}
+		}
+
+		else if (!strncmp(kstri,"<",1))
+			KML_Object::Read(fid,kstri);
+
+		xfree((void**)&kstri);
+	}
+
+	this->AddCommnt(ncom,pcom);
+
+	for (ncom; ncom>0; ncom--)
+		xfree((void**)&(pcom[ncom-1]));
+	xfree((void**)&pcom);
+
+	return;
+}
+/*}}}*/
Index: /issm/trunk/src/c/objects/KML/KML_Unknown.h
===================================================================
--- /issm/trunk/src/c/objects/KML/KML_Unknown.h	(revision 11527)
+++ /issm/trunk/src/c/objects/KML/KML_Unknown.h	(revision 11527)
@@ -0,0 +1,45 @@
+/*! \file KML_Unknown.h 
+ *  \brief: header file for kml_unknown object
+ */
+
+#ifndef _KML_UNKNOWN_H_
+#define _KML_UNKNOWN_H_
+
+/*Headers:*/
+/*{{{1*/
+#include "../../include/include.h"
+#include "../../shared/Exceptions/exceptions.h"
+#include "../../EnumDefinitions/EnumDefinitions.h"
+
+#include "./KML_Object.h"
+/*}}}*/
+
+class KML_Unknown: public KML_Object {
+
+	public:
+
+		char* name;
+		char* value;
+
+		/*KML_Unknown constructors, destructors {{{1*/
+		KML_Unknown();
+		~KML_Unknown();
+		/*}}}*/
+		/*Object virtual functions definitions:{{{1*/
+		void  Echo();
+		void  DeepEcho();
+		void  DeepEcho(const char* indent);
+		void  Write(FILE* fid,const char* indent);
+		void  Read(FILE* fid,char* kstr);
+		int   Id(){_error_("Not implemented yet.");};
+		int   MyRank(){_error_("Not implemented yet.");};
+		void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
+		int   MarshallSize(){_error_("Not implemented yet.");};
+		void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
+		int   ObjectEnum(){_error_("Not implemented yet.");};
+		Object* copy(){_error_("Not implemented yet.");};
+		/*}}}*/
+
+};
+#endif  /* _KML_UNKNOWN_H */
+
Index: /issm/trunk/src/c/objects/Loads/Icefront.cpp
===================================================================
--- /issm/trunk/src/c/objects/Loads/Icefront.cpp	(revision 11526)
+++ /issm/trunk/src/c/objects/Loads/Icefront.cpp	(revision 11527)
@@ -361,4 +361,9 @@
 }
 /*}}}*/
+/*FUNCTION Icefront::CreateJacobianMatrix{{{1*/
+void  Icefront::CreateJacobianMatrix(Mat Jff){
+	this->CreateKMatrix(Jff,NULL);
+}
+/*}}}1*/
 /*FUNCTION Icefront::PenaltyCreateKMatrix {{{1*/
 void  Icefront::PenaltyCreateKMatrix(Mat Kff, Mat Kfs, double kmax){
@@ -373,4 +378,9 @@
 }
 /*}}}*/
+/*FUNCTION Icefront::PenaltyCreateJacobianMatrix{{{1*/
+void  Icefront::PenaltyCreateJacobianMatrix(Mat Jff,double kmax){
+	this->PenaltyCreateKMatrix(Jff,NULL,kmax);
+}
+/*}}}1*/
 /*FUNCTION Icefront::InAnalysis{{{1*/
 bool Icefront::InAnalysis(int in_analysis_type){
Index: /issm/trunk/src/c/objects/Loads/Icefront.h
===================================================================
--- /issm/trunk/src/c/objects/Loads/Icefront.h	(revision 11526)
+++ /issm/trunk/src/c/objects/Loads/Icefront.h	(revision 11527)
@@ -76,6 +76,8 @@
 		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);
 		bool  InAnalysis(int analysis_type);
 		/*}}}*/
Index: /issm/trunk/src/c/objects/Loads/Load.h
===================================================================
--- /issm/trunk/src/c/objects/Loads/Load.h	(revision 11526)
+++ /issm/trunk/src/c/objects/Loads/Load.h	(revision 11527)
@@ -29,4 +29,6 @@
 		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;
Index: /issm/trunk/src/c/objects/Loads/Numericalflux.h
===================================================================
--- /issm/trunk/src/c/objects/Loads/Numericalflux.h	(revision 11526)
+++ /issm/trunk/src/c/objects/Loads/Numericalflux.h	(revision 11527)
@@ -72,4 +72,6 @@
 		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);
Index: /issm/trunk/src/c/objects/Loads/Pengrid.h
===================================================================
--- /issm/trunk/src/c/objects/Loads/Pengrid.h	(revision 11526)
+++ /issm/trunk/src/c/objects/Loads/Pengrid.h	(revision 11527)
@@ -77,4 +77,6 @@
 		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);
Index: /issm/trunk/src/c/objects/Loads/Penpair.cpp
===================================================================
--- /issm/trunk/src/c/objects/Loads/Penpair.cpp	(revision 11526)
+++ /issm/trunk/src/c/objects/Loads/Penpair.cpp	(revision 11527)
@@ -212,4 +212,9 @@
 	return;
 
+}
+/*}}}1*/
+/*FUNCTION Penpair::CreateJacobianMatrix{{{1*/
+void  Penpair::CreateJacobianMatrix(Mat Jff){
+	this->CreateKMatrix(Jff,NULL);
 }
 /*}}}1*/
@@ -246,4 +251,9 @@
 }
 /*}}}1*/
+/*FUNCTION Penpair::PenaltyCreateJacobianMatrix{{{1*/
+void  Penpair::PenaltyCreateJacobianMatrix(Mat Jff,double kmax){
+	this->PenaltyCreateKMatrix(Jff,NULL,kmax);
+}
+/*}}}1*/
 /*FUNCTION Penpair::InAnalysis{{{1*/
 bool Penpair::InAnalysis(int in_analysis_type){
@@ -266,4 +276,19 @@
 /*FUNCTION Penpair::InputUpdateFromConstant(bool constant, int name) {{{1*/
 void  Penpair::InputUpdateFromConstant(bool constant, int name){
+	/*Nothing updated yet*/
+}
+/*}}}*/
+/*FUNCTION Penpair::InputUpdateFromVector(double* vector, int name, int type) {{{1*/
+void  Penpair::InputUpdateFromVector(double* vector, int name, int type){
+	/*Nothing updated yet*/
+}
+/*}}}*/
+/*FUNCTION Penpair::InputUpdateFromVector(int* vector, int name, int type) {{{1*/
+void  Penpair::InputUpdateFromVector(int* vector, int name, int type){
+	/*Nothing updated yet*/
+}
+/*}}}*/
+/*FUNCTION Penpair::InputUpdateFromVector(bool* vector, int name, int type) {{{1*/
+void  Penpair::InputUpdateFromVector(bool* vector, int name, int type){
 	/*Nothing updated yet*/
 }
Index: /issm/trunk/src/c/objects/Loads/Penpair.h
===================================================================
--- /issm/trunk/src/c/objects/Loads/Penpair.h	(revision 11526)
+++ /issm/trunk/src/c/objects/Loads/Penpair.h	(revision 11527)
@@ -46,7 +46,7 @@
 		/*}}}*/
 		/*Update virtual functions resolution: {{{1*/
-		void  InputUpdateFromVector(double* vector, int name, int type){_error_("Not implemented yet!");}
-		void  InputUpdateFromVector(int* vector, int name, int type){_error_("Not implemented yet!");}
-		void  InputUpdateFromVector(bool* vector, int name, int type){_error_("Not implemented yet!");}
+		void  InputUpdateFromVector(double* vector, int name, int type);
+		void  InputUpdateFromVector(int* vector, int name, int type);
+		void  InputUpdateFromVector(bool* vector, int name, int type);
 		void  InputUpdateFromMatrixDakota(double* matrix, int nrow, int ncols,int name, int type){_error_("Not implemented yet!");}
 		void  InputUpdateFromVectorDakota(double* vector, int name, int type){_error_("Not implemented yet!");}
@@ -64,6 +64,8 @@
 		void  CreateKMatrix(Mat Kff, Mat Kfs);
 		void  CreatePVector(Vec pf);
-		void  PenaltyCreateKMatrix(Mat Kff, Mat kfs, double kmax);
+		void  CreateJacobianMatrix(Mat Jff);
+		void  PenaltyCreateKMatrix(Mat Kff,Mat Kfs,double kmax);
 		void  PenaltyCreatePVector(Vec pf, double kmax);
+		void  PenaltyCreateJacobianMatrix(Mat Jff,double kmax);
 		bool  InAnalysis(int analysis_type);
 		/*}}}*/
Index: /issm/trunk/src/c/objects/Loads/Riftfront.cpp
===================================================================
--- /issm/trunk/src/c/objects/Loads/Riftfront.cpp	(revision 11526)
+++ /issm/trunk/src/c/objects/Loads/Riftfront.cpp	(revision 11527)
@@ -366,6 +366,6 @@
 		
 /*Update virtual functions definitions:*/
-/*FUNCTION Riftfront::InputUpdateFromConstant(int constant,int name) {{{1*/
-void  Riftfront::InputUpdateFromConstant(int constant,int name){
+/*FUNCTION Riftfront::InputUpdateFromConstant(bool constant,int name) {{{1*/
+void  Riftfront::InputUpdateFromConstant(bool constant,int name){
 
 	/*Check that name is a Riftfront input*/
@@ -373,5 +373,5 @@
 
 	/*update input*/
-	this->inputs->AddInput(new IntInput(name,constant));
+	this->inputs->AddInput(new BoolInput(name,constant));
 
 }
@@ -388,5 +388,5 @@
 }
 /*}}}*/
-/*FUNCTION Riftfront::InputUpdateFromConstant(double constant,int name) {{{1*/
+/*FUNCTION Riftfront::InputUpdateFromConstant(double* constant,int name) {{{1*/
 void    Riftfront::InputUpdateFromVector(double* vector, int name, int type){
 
Index: /issm/trunk/src/c/objects/Loads/Riftfront.h
===================================================================
--- /issm/trunk/src/c/objects/Loads/Riftfront.h	(revision 11526)
+++ /issm/trunk/src/c/objects/Loads/Riftfront.h	(revision 11527)
@@ -74,6 +74,6 @@
 		void    InputUpdateFromVectorDakota(bool* vector, int name, int type){_error_("Not implemented yet!");}
 		void    InputUpdateFromConstant(double constant, int name);
-		void    InputUpdateFromConstant(int constant, int name);
-		void    InputUpdateFromConstant(bool constant, int name){_error_("Not implemented yet!");}
+		void    InputUpdateFromConstant(int constant, int name){_error_("Not implemented yet!");}
+		void    InputUpdateFromConstant(bool constant, int name);
 		void    InputUpdateFromSolution(double* solution){_error_("Not implemented yet!");}
 		void  InputUpdateFromIoModel(int index, IoModel* iomodel){_error_("not implemented yet");};
@@ -84,4 +84,6 @@
 		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);
Index: /issm/trunk/src/c/objects/Materials/Matice.cpp
===================================================================
--- /issm/trunk/src/c/objects/Materials/Matice.cpp	(revision 11526)
+++ /issm/trunk/src/c/objects/Materials/Matice.cpp	(revision 11527)
@@ -523,4 +523,69 @@
 }
 /*}}}*/
+/*FUNCTION Matice::GetViscosityDerivativeEpsSquare{{{1*/
+void  Matice::GetViscosityDerivativeEpsSquare(double* pmu_prime, double* epsilon){
+
+	/*output: */
+	double mu_prime;
+	double mu,n,eff2;
+
+	/*input strain rate: */
+	double exx,eyy,exy,exz,eyz;
+
+	/*Get visocisty and n*/
+	GetViscosity3d(&mu,epsilon);
+	n=GetN();
+
+	if((epsilon[0]==0) && (epsilon[1]==0) && (epsilon[2]==0) && 
+				(epsilon[3]==0) && (epsilon[4]==0)){
+		mu_prime=0.5*pow((double)10,(double)14);
+	}
+	else{
+		/*Retrive strain rate components: */
+		exx=epsilon[0];
+		eyy=epsilon[1];
+		exy=epsilon[2];
+		exz=epsilon[3];
+		eyz=epsilon[4];
+		eff2 = exx*exx + eyy*eyy + exx*eyy + exy*exy + exz*exz + eyz*eyz;
+
+		mu_prime=(1-n)/(2*n) * mu/eff2;
+	}
+
+	/*Assign output pointers:*/
+	*pmu_prime=mu_prime;
+}
+/*}}}*/
+/*FUNCTION Matice::GetViscosity2dDerivativeEpsSquare{{{1*/
+void  Matice::GetViscosity2dDerivativeEpsSquare(double* pmu_prime, double* epsilon){
+
+	/*output: */
+	double mu_prime;
+	double mu,n,eff2;
+
+	/*input strain rate: */
+	double exx,eyy,exy,exz;
+
+	/*Get visocisty and n*/
+	GetViscosity2d(&mu,epsilon);
+	n=GetN();
+
+	if((epsilon[0]==0) && (epsilon[1]==0) && (epsilon[2]==0)){
+		mu_prime=0.5*pow((double)10,(double)14);
+	}
+	else{
+		/*Retrive strain rate components: */
+		exx=epsilon[0];
+		eyy=epsilon[1];
+		exy=epsilon[2];
+		eff2 = exx*exx + eyy*eyy + exx*eyy + exy*exy ;
+
+		mu_prime=(1-n)/(2*n) * mu/eff2;
+	}
+
+	/*Assign output pointers:*/
+	*pmu_prime=mu_prime;
+}
+/*}}}*/
 /*FUNCTION Matice::InputDuplicate{{{1*/
 void  Matice::InputDuplicate(int original_enum,int new_enum){
@@ -552,5 +617,5 @@
 					double values[3];
 					for (int i=0;i<3;i++) values[i]=vector[((Tria*)element)->nodes[i]->GetVertexDof()];
-					this->inputs->AddInput(new TriaVertexInput(name,values));
+					this->inputs->AddInput(new TriaP1Input(name,values));
 					return;
 
@@ -594,5 +659,5 @@
 					double values[3];
 					for (int i=0;i<3;i++) values[i]=vector[((Tria*)element)->nodes[i]->GetSidList()]; //use sid list, to index into serial oriented vector 
-					this->inputs->AddInput(new TriaVertexInput(name,values));
+					this->inputs->AddInput(new TriaP1Input(name,values));
 					/*Special case for rheology B in 2D: Pourave land for this solution{{{2*/
 					if(name==MaterialsRheologyBEnum){
@@ -607,5 +672,5 @@
 						if(dim==2){
 							/*Dupliacte rheology input: */
-							this->inputs->AddInput(new TriaVertexInput(MaterialsRheologyBbarEnum,values));
+							this->inputs->AddInput(new TriaP1Input(MaterialsRheologyBbarEnum,values));
 						}
 					}
@@ -683,5 +748,5 @@
 		if (iomodel->Data(MaterialsRheologyBEnum)) {
 			for(i=0;i<num_vertices;i++) nodeinputs[i]=iomodel->Data(MaterialsRheologyBEnum)[int(iomodel->Data(MeshElementsEnum)[num_vertices*index+i]-1)];
-			this->inputs->AddInput(new TriaVertexInput(MaterialsRheologyBbarEnum,nodeinputs));
+			this->inputs->AddInput(new TriaP1Input(MaterialsRheologyBbarEnum,nodeinputs));
 		}
 
@@ -689,5 +754,5 @@
 		if (iomodel->Data(MaterialsRheologyNEnum)) {
 			for(i=0;i<num_vertices;i++) nodeinputs[i]=iomodel->Data(MaterialsRheologyNEnum)[index];
-			this->inputs->AddInput(new TriaVertexInput(MaterialsRheologyNEnum,nodeinputs));
+			this->inputs->AddInput(new TriaP1Input(MaterialsRheologyNEnum,nodeinputs));
 		}
 
@@ -703,5 +768,5 @@
 							for(j=0;j<num_vertices;j++)cmmininputs[j]=iomodel->Data(InversionMinParametersEnum)[int(iomodel->Data(MeshElementsEnum)[num_vertices*index+j]-1)*num_control_type+i];
 							for(j=0;j<num_vertices;j++)cmmaxinputs[j]=iomodel->Data(InversionMaxParametersEnum)[int(iomodel->Data(MeshElementsEnum)[num_vertices*index+j]-1)*num_control_type+i];
-							this->inputs->AddInput(new ControlInput(MaterialsRheologyBbarEnum,TriaVertexInputEnum,nodeinputs,cmmininputs,cmmaxinputs,i+1));
+							this->inputs->AddInput(new ControlInput(MaterialsRheologyBbarEnum,TriaP1InputEnum,nodeinputs,cmmininputs,cmmaxinputs,i+1));
 						}
 						break;
@@ -725,5 +790,5 @@
 		if (iomodel->Data(MaterialsRheologyBEnum)) {
 			for(i=0;i<num_vertices;i++) nodeinputs[i]=iomodel->Data(MaterialsRheologyBEnum)[int(iomodel->Data(MeshElementsEnum)[num_vertices*index+i]-1)];
-			this->inputs->AddInput(new PentaVertexInput(MaterialsRheologyBEnum,nodeinputs));
+			this->inputs->AddInput(new PentaP1Input(MaterialsRheologyBEnum,nodeinputs));
 		}
 
@@ -731,5 +796,5 @@
 		if (iomodel->Data(MaterialsRheologyNEnum)) {
 			for(i=0;i<num_vertices;i++) nodeinputs[i]=iomodel->Data(MaterialsRheologyNEnum)[index];
-			this->inputs->AddInput(new PentaVertexInput(MaterialsRheologyNEnum,nodeinputs));
+			this->inputs->AddInput(new PentaP1Input(MaterialsRheologyNEnum,nodeinputs));
 		}
 
@@ -745,5 +810,5 @@
 							for(j=0;j<num_vertices;j++)cmmininputs[j]=iomodel->Data(InversionMinParametersEnum)[int(iomodel->Data(MeshElementsEnum)[num_vertices*index+j]-1)*num_control_type+i];
 							for(j=0;j<num_vertices;j++)cmmaxinputs[j]=iomodel->Data(InversionMaxParametersEnum)[int(iomodel->Data(MeshElementsEnum)[num_vertices*index+j]-1)*num_control_type+i];
-							this->inputs->AddInput(new ControlInput(MaterialsRheologyBEnum,PentaVertexInputEnum,nodeinputs,cmmininputs,cmmaxinputs,i+1));
+							this->inputs->AddInput(new ControlInput(MaterialsRheologyBEnum,PentaP1InputEnum,nodeinputs,cmmininputs,cmmaxinputs,i+1));
 						}
 						break;
Index: /issm/trunk/src/c/objects/Materials/Matice.h
===================================================================
--- /issm/trunk/src/c/objects/Materials/Matice.h	(revision 11526)
+++ /issm/trunk/src/c/objects/Materials/Matice.h	(revision 11527)
@@ -68,4 +68,6 @@
 		void   GetViscosity3dStokes(double* pviscosity3d, double* epsilon);
 		void   GetViscosityComplement(double* pviscosity_complement, double* pepsilon);
+		void   GetViscosityDerivativeEpsSquare(double* pmu_prime, double* pepsilon);
+		void   GetViscosity2dDerivativeEpsSquare(double* pmu_prime, double* pepsilon);
 		double GetB();
 		double GetBbar();
Index: /issm/trunk/src/c/objects/Materials/Matpar.cpp
===================================================================
--- /issm/trunk/src/c/objects/Materials/Matpar.cpp	(revision 11526)
+++ /issm/trunk/src/c/objects/Materials/Matpar.cpp	(revision 11527)
@@ -416,5 +416,10 @@
 /*FUNCTION Matpar::GetEnthalpyDiffusionParameter{{{1*/
 double Matpar::GetEnthalpyDiffusionParameter(double enthalpy,double pressure){
-	return thermalconductivity/(rho_ice*heatcapacity);
+	if(enthalpy<PureIceEnthalpy(pressure)){
+		return thermalconductivity/(rho_ice*heatcapacity);
+	}
+	else{
+		return 0.1*thermalconductivity/(rho_ice*heatcapacity);
+	}
 }
 /*}}}1*/
Index: /issm/trunk/src/c/objects/Numerics/ElementMatrix.cpp
===================================================================
--- /issm/trunk/src/c/objects/Numerics/ElementMatrix.cpp	(revision 11526)
+++ /issm/trunk/src/c/objects/Numerics/ElementMatrix.cpp	(revision 11527)
@@ -245,9 +245,15 @@
 
 /*ElementMatrix specific routines: */
-/*FUNCTION ElementMatrix::AddToGlobal{{{1*/
+/*FUNCTION ElementMatrix::AddToGlobal(Mat Kff, Mat Kfs){{{1*/
 void ElementMatrix::AddToGlobal(Mat Kff, Mat Kfs){
 
 	int i,j;
 	double* localvalues=NULL;
+
+	/*If Kfs is not provided, call the other function*/
+	if(!Kfs){
+		this->AddToGlobal(Kff);
+		return;
+	}
 
 	/*In debugging mode, check consistency (no NaN, and values not too big)*/
@@ -294,4 +300,41 @@
 }
 /*}}}*/
+/*FUNCTION ElementMatrix::AddToGlobal(Mat Jff){{{1*/
+void ElementMatrix::AddToGlobal(Mat Jff){
+
+	int i,j;
+	double* localvalues=NULL;
+
+	/*Check that Jff is not NULL*/
+	_assert_(Jff); 
+
+	/*In debugging mode, check consistency (no NaN, and values not too big)*/
+	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]);
+				}
+			}
+			/*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!");
+	}
+
+}
+/*}}}*/
 /*FUNCTION ElementMatrix::CheckConsistency{{{1*/
 void ElementMatrix::CheckConsistency(void){
Index: /issm/trunk/src/c/objects/Numerics/ElementMatrix.h
===================================================================
--- /issm/trunk/src/c/objects/Numerics/ElementMatrix.h	(revision 11526)
+++ /issm/trunk/src/c/objects/Numerics/ElementMatrix.h	(revision 11527)
@@ -59,4 +59,5 @@
 		/*ElementMatrix specific routines {{{1*/
 		void AddToGlobal(Mat Kff, Mat Kfs);
+		void AddToGlobal(Mat Jff);
 		void Echo(void);
 		void CheckConsistency(void);
Index: /issm/trunk/src/c/objects/Params/BoolParam.h
===================================================================
--- /issm/trunk/src/c/objects/Params/BoolParam.h	(revision 11526)
+++ /issm/trunk/src/c/objects/Params/BoolParam.h	(revision 11527)
@@ -57,5 +57,5 @@
 		void  GetParameterValue(double* pdouble){_error_("Bool param of enum %i (%s) cannot return a double",enum_type,EnumToStringx(enum_type));}
 		void  GetParameterValue(char** pstring){_error_("Bool param of enum %i (%s) cannot return a string",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(char*** pstringarray,int* pM){_error_("Bool param of enum %i (%s) cannot return a string arrayl",enum_type,EnumToStringx(enum_type));}
+		void  GetParameterValue(char*** pstringarray,int* pM){_error_("Bool param of enum %i (%s) cannot return a string array",enum_type,EnumToStringx(enum_type));}
 		void  GetParameterValue(double** pdoublearray,int* pM){_error_("Bool param of enum %i (%s) cannot return a double array",enum_type,EnumToStringx(enum_type));}
 		void  GetParameterValue(double** pdoublearray,int* pM, int* pN){_error_("Bool param of enum %i (%s) cannot return a double array",enum_type,EnumToStringx(enum_type));}
Index: /issm/trunk/src/c/objects/Params/DoubleMatArrayParam.h
===================================================================
--- /issm/trunk/src/c/objects/Params/DoubleMatArrayParam.h	(revision 11526)
+++ /issm/trunk/src/c/objects/Params/DoubleMatArrayParam.h	(revision 11527)
@@ -60,5 +60,5 @@
 		void  GetParameterValue(double* pdouble){_error_("DoubleMatArray param of enum %i (%s) cannot return a double",enum_type,EnumToStringx(enum_type));}
 		void  GetParameterValue(char** pstring){_error_("DoubleMatArray param of enum %i (%s) cannot return a string",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(char*** pstringarray,int* pM){_error_("DoubleMatArray param of enum %i (%s) cannot return a string arrayl",enum_type,EnumToStringx(enum_type));}
+		void  GetParameterValue(char*** pstringarray,int* pM){_error_("DoubleMatArray param of enum %i (%s) cannot return a string array",enum_type,EnumToStringx(enum_type));}
 		void  GetParameterValue(double** pdoublearray,int* pM){_error_("DoubleMatArray param of enum %i (%s) cannot return a double array",enum_type,EnumToStringx(enum_type));}
 		void  GetParameterValue(double** pdoublearray,int* pM, int* pN){_error_("DoubleMatArray param of enum %i (%s) cannot return a double array",enum_type,EnumToStringx(enum_type));}
Index: /issm/trunk/src/c/objects/Params/DoubleMatParam.h
===================================================================
--- /issm/trunk/src/c/objects/Params/DoubleMatParam.h	(revision 11526)
+++ /issm/trunk/src/c/objects/Params/DoubleMatParam.h	(revision 11527)
@@ -59,5 +59,5 @@
 		void  GetParameterValue(double* pdouble){_error_("DoubleMat param of enum %i (%s) cannot return a double",enum_type,EnumToStringx(enum_type));}
 		void  GetParameterValue(char** pstring){_error_("DoubleMat param of enum %i (%s) cannot return a string",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(char*** pstringarray,int* pM){_error_("DoubleMat param of enum %i (%s) cannot return a string arrayl",enum_type,EnumToStringx(enum_type));}
+		void  GetParameterValue(char*** pstringarray,int* pM){_error_("DoubleMat param of enum %i (%s) cannot return a string array",enum_type,EnumToStringx(enum_type));}
 		void  GetParameterValue(double** pdoublearray,int* pM){_error_("DoubleMat param of enum %i (%s) cannot return a double array",enum_type,EnumToStringx(enum_type));}
 		void  GetParameterValue(double** pdoublearray,int* pM,int* pN);
Index: /issm/trunk/src/c/objects/Params/DoubleParam.h
===================================================================
--- /issm/trunk/src/c/objects/Params/DoubleParam.h	(revision 11526)
+++ /issm/trunk/src/c/objects/Params/DoubleParam.h	(revision 11527)
@@ -58,5 +58,5 @@
 		void  GetParameterValue(double* pdouble){*pdouble=value;}
 		void  GetParameterValue(char** pstring){_error_("Double param of enum %i (%s) cannot return a string",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(char*** pstringarray,int* pM){_error_("Double param of enum %i (%s) cannot return a string arrayl",enum_type,EnumToStringx(enum_type));}
+		void  GetParameterValue(char*** pstringarray,int* pM){_error_("Double param of enum %i (%s) cannot return a string array",enum_type,EnumToStringx(enum_type));}
 		void  GetParameterValue(double** pdoublearray,int* pM);
 		void  GetParameterValue(double** pdoublearray,int* pM, int* pN);
Index: /issm/trunk/src/c/objects/Params/DoubleVecParam.h
===================================================================
--- /issm/trunk/src/c/objects/Params/DoubleVecParam.h	(revision 11526)
+++ /issm/trunk/src/c/objects/Params/DoubleVecParam.h	(revision 11527)
@@ -55,8 +55,8 @@
 		void  GetParameterValue(int* pinteger){_error_("DoubleVec param of enum %i (%s) cannot return an integer",enum_type,EnumToStringx(enum_type));}
 		void  GetParameterValue(int** pintarray,int* pM);
-		void  GetParameterValue(int** pintarray,int* pM,int* pN){_error_("DoubleVec param of enum %i (%s) cannot return a string",enum_type,EnumToStringx(enum_type));};
+		void  GetParameterValue(int** pintarray,int* pM,int* pN){_error_("DoubleVec param of enum %i (%s) cannot return an array of integers",enum_type,EnumToStringx(enum_type));};
 		void  GetParameterValue(double* pdouble){_error_("DoubleVec param of enum %i (%s) cannot return a double",enum_type,EnumToStringx(enum_type));}
 		void  GetParameterValue(char** pstring){_error_("DoubleVec param of enum %i (%s) cannot return a string",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(char*** pstringarray,int* pM){_error_("DoubleVec param of enum %i (%s) cannot return a string arrayl",enum_type,EnumToStringx(enum_type));}
+		void  GetParameterValue(char*** pstringarray,int* pM){_error_("DoubleVec param of enum %i (%s) cannot return a string array",enum_type,EnumToStringx(enum_type));}
 		void  GetParameterValue(double** pdoublearray,int* pM);
 		void  GetParameterValue(double** pdoublearray,int* pM, int* pN);
Index: /issm/trunk/src/c/objects/Params/FileParam.h
===================================================================
--- /issm/trunk/src/c/objects/Params/FileParam.h	(revision 11526)
+++ /issm/trunk/src/c/objects/Params/FileParam.h	(revision 11527)
@@ -57,5 +57,5 @@
 		void  GetParameterValue(double* pdouble){_error_("FileParam of enum %i (%s) cannot return a double",enum_type,EnumToStringx(enum_type));}
 		void  GetParameterValue(char** pstring){_error_("FileParam of enum %i (%s) cannot return a string",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(char*** pstringarray,int* pM){_error_("FileParam of enum %i (%s) cannot return a string arrayl",enum_type,EnumToStringx(enum_type));}
+		void  GetParameterValue(char*** pstringarray,int* pM){_error_("FileParam of enum %i (%s) cannot return a string array",enum_type,EnumToStringx(enum_type));}
 		void  GetParameterValue(double** pdoublearray,int* pM){_error_("FileParam of enum %i (%s) cannot return a double array",enum_type,EnumToStringx(enum_type));}
 		void  GetParameterValue(double** pdoublearray,int* pM, int* pN){_error_("FileParam of enum %i (%s) cannot return a double array",enum_type,EnumToStringx(enum_type));}
Index: /issm/trunk/src/c/objects/Params/IntMatParam.h
===================================================================
--- /issm/trunk/src/c/objects/Params/IntMatParam.h	(revision 11526)
+++ /issm/trunk/src/c/objects/Params/IntMatParam.h	(revision 11527)
@@ -59,5 +59,5 @@
 		void  GetParameterValue(double* pdouble){_error_("IntMat param of enum %i (%s) cannot return a double",enum_type,EnumToStringx(enum_type));}
 		void  GetParameterValue(char** pstring){_error_("IntMat param of enum %i (%s) cannot return a string",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(char*** pstringarray,int* pM){_error_("IntMat param of enum %i (%s) cannot return a string arrayl",enum_type,EnumToStringx(enum_type));}
+		void  GetParameterValue(char*** pstringarray,int* pM){_error_("IntMat param of enum %i (%s) cannot return a string array",enum_type,EnumToStringx(enum_type));}
 		void  GetParameterValue(double** pdoublearray,int* pM){_error_("IntMat param of enum %i (%s) cannot return a double array",enum_type,EnumToStringx(enum_type));}
 		void  GetParameterValue(double** pdoublearray,int* pM,int* pN){_error_("IntMat param of enum %i (%s) cannot return a matrix array",enum_type,EnumToStringx(enum_type));};
Index: /issm/trunk/src/c/objects/Params/IntParam.h
===================================================================
--- /issm/trunk/src/c/objects/Params/IntParam.h	(revision 11526)
+++ /issm/trunk/src/c/objects/Params/IntParam.h	(revision 11527)
@@ -58,5 +58,5 @@
 		void  GetParameterValue(double* pdouble){_error_("Int param of enum %i (%s) cannot return a double",enum_type,EnumToStringx(enum_type));}
 		void  GetParameterValue(char** pstring){_error_("Int param of enum %i (%s) cannot return a string",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(char*** pstringarray,int* pM){_error_("Int param of enum %i (%s) cannot return a string arrayl",enum_type,EnumToStringx(enum_type));}
+		void  GetParameterValue(char*** pstringarray,int* pM){_error_("Int param of enum %i (%s) cannot return a string array",enum_type,EnumToStringx(enum_type));}
 		void  GetParameterValue(double** pdoublearray,int* pM){_error_("Int param of enum %i (%s) cannot return a double array",enum_type,EnumToStringx(enum_type));}
 		void  GetParameterValue(double** pdoublearray,int* pM, int* pN){_error_("Int param of enum %i (%s) cannot return a double array",enum_type,EnumToStringx(enum_type));}
Index: /issm/trunk/src/c/objects/Params/PetscMatParam.h
===================================================================
--- /issm/trunk/src/c/objects/Params/PetscMatParam.h	(revision 11526)
+++ /issm/trunk/src/c/objects/Params/PetscMatParam.h	(revision 11527)
@@ -58,5 +58,5 @@
 		void  GetParameterValue(double* pdouble){_error_("PetscMat param of enum %i (%s) cannot return a double",enum_type,EnumToStringx(enum_type));}
 		void  GetParameterValue(char** pstring){_error_("PetscMat param of enum %i (%s) cannot return a string",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(char*** pstringarray,int* pM){_error_("PetscMat param of enum %i (%s) cannot return a string arrayl",enum_type,EnumToStringx(enum_type));}
+		void  GetParameterValue(char*** pstringarray,int* pM){_error_("PetscMat param of enum %i (%s) cannot return a string array",enum_type,EnumToStringx(enum_type));}
 		void  GetParameterValue(double** pdoublearray,int* pM){_error_("PetscMat param of enum %i (%s) cannot return a double array",enum_type,EnumToStringx(enum_type));}
 		void  GetParameterValue(double** pdoublearray,int* pM, int* pN){_error_("PetscMat param of enum %i (%s) cannot return a double array",enum_type,EnumToStringx(enum_type));}
Index: /issm/trunk/src/c/objects/Params/PetscVecParam.h
===================================================================
--- /issm/trunk/src/c/objects/Params/PetscVecParam.h	(revision 11526)
+++ /issm/trunk/src/c/objects/Params/PetscVecParam.h	(revision 11527)
@@ -58,5 +58,5 @@
 		void  GetParameterValue(double* pdouble){_error_("PetscVec param of enum %i (%s) cannot return a double",enum_type,EnumToStringx(enum_type));}
 		void  GetParameterValue(char** pstring){_error_("PetscVec param of enum %i (%s) cannot return a string",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(char*** pstringarray,int* pM){_error_("PetscVec param of enum %i (%s) cannot return a string arrayl",enum_type,EnumToStringx(enum_type));}
+		void  GetParameterValue(char*** pstringarray,int* pM){_error_("PetscVec param of enum %i (%s) cannot return a string array",enum_type,EnumToStringx(enum_type));}
 		void  GetParameterValue(double** pdoublearray,int* pM){_error_("PetscVec param of enum %i (%s) cannot return a double array",enum_type,EnumToStringx(enum_type));}
 		void  GetParameterValue(double** pdoublearray,int* pM, int* pN){_error_("PetscVec param of enum %i (%s) cannot return a double array",enum_type,EnumToStringx(enum_type));}
Index: /issm/trunk/src/c/objects/Params/StringParam.h
===================================================================
--- /issm/trunk/src/c/objects/Params/StringParam.h	(revision 11526)
+++ /issm/trunk/src/c/objects/Params/StringParam.h	(revision 11527)
@@ -58,5 +58,5 @@
 		void  GetParameterValue(double* pdouble){_error_("String param of enum %i (%s) cannot return a double",enum_type,EnumToStringx(enum_type));}
 		void  GetParameterValue(char** pstring);
-		void  GetParameterValue(char*** pstringarray,int* pM){_error_("String param of enum %i (%s) cannot return a string arrayl",enum_type,EnumToStringx(enum_type));}
+		void  GetParameterValue(char*** pstringarray,int* pM){_error_("String param of enum %i (%s) cannot return a string array",enum_type,EnumToStringx(enum_type));}
 		void  GetParameterValue(double** pdoublearray,int* pM){_error_("String param of enum %i (%s) cannot return a double array",enum_type,EnumToStringx(enum_type));}
 		void  GetParameterValue(double** pdoublearray,int* pM, int* pN){_error_("String param of enum %i (%s) cannot return a double array",enum_type,EnumToStringx(enum_type));}
Index: /issm/trunk/src/c/objects/Patch.cpp
===================================================================
--- /issm/trunk/src/c/objects/Patch.cpp	(revision 11526)
+++ /issm/trunk/src/c/objects/Patch.cpp	(revision 11527)
@@ -12,4 +12,5 @@
 #include <stdio.h>
 #include <string.h>
+#include <math.h>
 #include "./objects.h"
 #include "../Container/Container.h"
Index: /issm/trunk/src/c/objects/Vertex.cpp
===================================================================
--- /issm/trunk/src/c/objects/Vertex.cpp	(revision 11526)
+++ /issm/trunk/src/c/objects/Vertex.cpp	(revision 11527)
@@ -273,9 +273,20 @@
 /*}}}*/
 /*FUNCTION Vertex::UpdateVertexPosition {{{1*/
-void  Vertex::UpdatePosition(double* thickness,double* bed){
+void  Vertex::UpdatePosition(Vec vz,Parameters* parameters,double* thickness,double* bed){
+
+	double oldz,newz;
+	double dt,velz;
+
+	/*Get time stepping*/
+	parameters->FindParam(&dt,TimesteppingTimeStepEnum);
 
 	/*sigma remains constant. z=bed+sigma*thickness*/
-	this->z=bed[this->dof]+sigma*thickness[this->dof];
-
-}
-/*}}}*/
+	oldz = this->z;
+	newz = bed[this->dof]+sigma*thickness[this->dof];
+	velz = (newz-oldz)/dt;
+	this->z = newz;
+
+	/*put vz in vector*/
+	VecSetValue(vz,this->dof,velz,INSERT_VALUES);
+}
+/*}}}*/
Index: /issm/trunk/src/c/objects/Vertex.h
===================================================================
--- /issm/trunk/src/c/objects/Vertex.h	(revision 11526)
+++ /issm/trunk/src/c/objects/Vertex.h	(revision 11527)
@@ -63,5 +63,5 @@
 		int   Sid(void); 
 		int   Connectivity(void); 
-		void  UpdatePosition(double* thickness,double* bed);
+		void  UpdatePosition(Vec vz,Parameters* parameters,double* thickness,double* bed);
 		/*}}}*/
 };
Index: /issm/trunk/src/c/objects/objects.h
===================================================================
--- /issm/trunk/src/c/objects/objects.h	(revision 11526)
+++ /issm/trunk/src/c/objects/objects.h	(revision 11527)
@@ -72,4 +72,5 @@
 #include "./KML/KML_StyleSelector.h"
 #include "./KML/KML_SubStyle.h"
+#include "./KML/KML_Unknown.h"
 #include "./KML/KMLFileReadUtils.h"
 
@@ -88,6 +89,6 @@
 #include "./Inputs/DoubleInput.h"
 #include "./Inputs/IntInput.h"
-#include "./Inputs/PentaVertexInput.h"
-#include "./Inputs/TriaVertexInput.h"
+#include "./Inputs/PentaP1Input.h"
+#include "./Inputs/TriaP1Input.h"
 #include "./Inputs/ControlInput.h"
 #include "./Inputs/DatasetInput.h"
@@ -97,6 +98,6 @@
 #include "./ElementResults/ElementResult.h"
 #include "./ElementResults/DoubleElementResult.h"
-#include "./ElementResults/TriaVertexElementResult.h"
-#include "./ElementResults/PentaVertexElementResult.h" 
+#include "./ElementResults/TriaP1ElementResult.h"
+#include "./ElementResults/PentaP1ElementResult.h" 
 #include "./ElementResults/BoolElementResult.h"
 
Index: /issm/trunk/src/c/shared/Numerics/Synchronize.sh
===================================================================
--- /issm/trunk/src/c/shared/Numerics/Synchronize.sh	(revision 11526)
+++ /issm/trunk/src/c/shared/Numerics/Synchronize.sh	(revision 11527)
@@ -165,4 +165,5 @@
 
 	verbositylevel = (int)level;
+	return verbositylevel;
 
 #else
Index: /issm/trunk/src/c/shared/Numerics/UnitConversion.cpp
===================================================================
--- /issm/trunk/src/c/shared/Numerics/UnitConversion.cpp	(revision 11526)
+++ /issm/trunk/src/c/shared/Numerics/UnitConversion.cpp	(revision 11527)
@@ -63,6 +63,5 @@
 		case BasalforcingsMeltingRateEnum:        scale=yts;break; //m/yr
 		case BasalforcingsMeltingRateCorrectionEnum: scale=yts;break; //m/yr
-		case SurfaceforcingsAccumulationRateEnum: scale=yts;break; //m/yr
-		case SurfaceforcingsAblationRateEnum:     scale=yts;break; //m/yr
+		case SurfaceforcingsPrecipitationEnum:     scale=yts;break; //m/yr
 		case SurfaceforcingsMassBalanceEnum:      scale=yts;break; //m/yr
 		case MisfitEnum:      scale=pow(yts,2);break; //(m/yr)^2
Index: /issm/trunk/src/c/shared/Numerics/Verbosity.cpp
===================================================================
--- /issm/trunk/src/c/shared/Numerics/Verbosity.cpp	(revision 11526)
+++ /issm/trunk/src/c/shared/Numerics/Verbosity.cpp	(revision 11527)
@@ -64,4 +64,5 @@
 
 	verbositylevel = (int)level;
+	return verbositylevel;
 
 #else
Index: /issm/trunk/src/c/shared/TriMesh/TriMeshUtils.cpp
===================================================================
--- /issm/trunk/src/c/shared/TriMesh/TriMeshUtils.cpp	(revision 11526)
+++ /issm/trunk/src/c/shared/TriMesh/TriMeshUtils.cpp	(revision 11527)
@@ -124,5 +124,5 @@
 ******************************************************************************************************************************/
 
-int RiftSegmentsFromSegments(int* pnriftsegs, int** priftsegments, int nel, double* index, int nsegs,double* segments){
+void RiftSegmentsFromSegments(int* pnriftsegs, int** priftsegments, int nel, double* index, int nsegs,double* segments){
 	
 	int i,counter;
@@ -379,23 +379,23 @@
                                    IsInPoly
 ******************************************************************************************************************************/
-int IsInPoly(double* in,double* xc,double* yc,int numnodes,double* x,double* y,int nods){
-
-	int i;
-	double x0,y0;
-
-	/*Go through all nodes of the mesh:*/
-	for (i=0;i<nods;i++){
-		if (in[i]){
-			/*this node already is inside one of the contours, continue*/
-			continue;
-		}
-		/*pick up node: */
-		x0=x[i];
-		y0=y[i];
-		if (pnpoly(numnodes,xc,yc,x0,y0)){
-			in[i]=1;
-		}
-	}
-}
+//void IsInPoly(double* in,double* xc,double* yc,int numnodes,double* x,double* y,int nods){
+//
+//	int i;
+//	double x0,y0;
+//
+//	/*Go through all nodes of the mesh:*/
+//	for (i=0;i<nods;i++){
+//		if (in[i]){
+//			/*this node already is inside one of the contours, continue*/
+//			continue;
+//		}
+//		/*pick up node: */
+//		x0=x[i];
+//		y0=y[i];
+//		if (pnpoly(numnodes,xc,yc,x0,y0)){
+//			in[i]=1;
+//		}
+//	}
+//}
 
 /******************************************************************************************************************************
Index: /issm/trunk/src/c/shared/TriMesh/trimesh.h
===================================================================
--- /issm/trunk/src/c/shared/TriMesh/trimesh.h	(revision 11526)
+++ /issm/trunk/src/c/shared/TriMesh/trimesh.h	(revision 11527)
@@ -26,5 +26,5 @@
 int IsNeighbor(int el1,int el2,double* index);
 int IsOnRift(int el,int nriftsegs,int* riftsegments);
-int RiftSegmentsFromSegments(int* pnriftsegs, int** priftsegments, int nel, double* index, int nsegs,double* segments);
+void RiftSegmentsFromSegments(int* pnriftsegs, int** priftsegments, int nel, double* index, int nsegs,double* segments);
 int DetermineGridElementListOnOneSideOfRift(int* pNumGridElementListOnOneSideOfRift, int** pGridElementListOnOneSideOfRift, int segmentnumber, int nriftsegs, int* riftsegments, int node,double* index,int nel);
 int UpdateSegments(double** psegments,double** psegmentmarkerlist, int* pnsegs, double* index, double* x,double* y,int* riftsegments,int nriftsegs);
Index: /issm/trunk/src/c/solutions/AnalysisConfiguration.cpp
===================================================================
--- /issm/trunk/src/c/solutions/AnalysisConfiguration.cpp	(revision 11526)
+++ /issm/trunk/src/c/solutions/AnalysisConfiguration.cpp	(revision 11527)
@@ -95,5 +95,5 @@
 
 		case TransientSolutionEnum:
-			numanalyses=8;
+			numanalyses=9;
 			analyses=(int*)xmalloc(numanalyses*sizeof(int));
 			analyses[0]=DiagnosticHorizAnalysisEnum;
@@ -104,5 +104,6 @@
 			analyses[5]=ThermalAnalysisEnum;
 			analyses[6]=MeltingAnalysisEnum;
-			analyses[7]=PrognosticAnalysisEnum;
+			analyses[7]=EnthalpyAnalysisEnum;
+			analyses[8]=PrognosticAnalysisEnum;
 			break;
 		
Index: /issm/trunk/src/c/solutions/control_core.cpp
===================================================================
--- /issm/trunk/src/c/solutions/control_core.cpp	(revision 11526)
+++ /issm/trunk/src/c/solutions/control_core.cpp	(revision 11527)
@@ -34,5 +34,5 @@
 		
 	/*intermediary: */
-	double  search_scalar=0;
+	double  search_scalar=1;
 	OptArgs optargs;
 	OptPars optpars;
@@ -70,5 +70,5 @@
 	/*Initialize responses: */
 	J=(double*)xmalloc(nsteps*sizeof(double));
-	step_responses=(int*)xmalloc(num_responses*sizeof(double));
+	step_responses=(int*)xmalloc(num_responses*sizeof(int));
 		
 	/*Initialize some of the BrentSearch arguments: */
@@ -84,10 +84,10 @@
 		femmodel->parameters->SetParam(step_responses,1,num_responses,StepResponsesEnum);
 		
-		/*In case we are running a steady state control method, compute new temperature field using new parameter distribution: */
+		/*In steady state inversion, compute new temperature field now*/
 		if(solution_type==SteadystateSolutionEnum) solutioncore(femmodel);
 
 		_printf_(VerboseControl(),"%s\n","   compute adjoint state:");
 		adjointcore(femmodel);
-		gradient_core(femmodel,n,search_scalar);
+		gradient_core(femmodel,n,search_scalar==0);
 
 		/*Return gradient if asked: */
@@ -100,5 +100,4 @@
 		optpars.maxiter=(int)maxiter[n]; optpars.cm_jump=cm_jump[n];
 		BrentSearch(&search_scalar,J+n,&optpars,&objectivefunctionC,&optargs);
-		//OptimalSearch(&search_scalar,J+n,&optpars,&objectivefunctionC,&optargs);
 
 		_printf_(VerboseControl(),"%s\n","   updating parameter using optimized search scalar"); //true means update save controls
@@ -106,10 +105,4 @@
 		
 		if(controlconvergence(J[n],tol_cm)) break;
-
-		/*Temporary saving every 5 control steps: */
-		/*if (((n+1)%5)==0){
-			_printf_(VerboseControl(),"%s\n","   saving temporary results");
-			controlrestart(femmodel,J);
-		}*/
 	}
 
@@ -122,5 +115,4 @@
 		for(i=0;i<num_controls;i++) InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,control_type[i]);
 		femmodel->results->AddObject(new DoubleVecExternalResult(femmodel->results->Size()+1,JEnum,J,nsteps,1,0));
-		//femmodel->results->AddObject(new StringExternalResult(femmodel->results->Size()+1,InversionControlParametersEnum,EnumToStringx(control_type),1,0));
 	}
 
Index: /issm/trunk/src/c/solutions/controltao_core.cpp
===================================================================
--- /issm/trunk/src/c/solutions/controltao_core.cpp	(revision 11526)
+++ /issm/trunk/src/c/solutions/controltao_core.cpp	(revision 11527)
@@ -13,10 +13,10 @@
 #include "../solvers/solvers.h"
 
-
-#if defined (_HAVE_TAO_) && (_PETSC_MAJOR_ < 3 || (_PETSC_MAJOR_ == 3 && _PETSC_MINOR_ < 2))
-#include "tao.h"
+#if defined (_HAVE_TAO_) && (_PETSC_MAJOR_ == 3 && _PETSC_MINOR_ == 2)
+#include <tao.h>
 
 /*Local prototype*/
-int FormFunctionGradient(TAO_APPLICATION,Vec,double *,Vec,void*);
+int FormFunctionGradient(TaoSolver,Vec,double*,Vec,void*);
+int IssmMonitor(TaoSolver,void*);
 typedef struct {
 	FemModel* femmodel;
@@ -26,112 +26,151 @@
 
 	/*TAO*/
-	int                i,n,info;
-	//TaoMethod          method = "tao_blmvm";
-	//TaoMethod        method = "tao_lmvm";
-	TaoMethod        method = "tao_cg";
-	TaoTerminateReason reason;
-	TAO_SOLVER         tao;
-	TAO_APPLICATION    controlapp;
-	Vec                initial_solution = NULL;
-	AppCtx             user;
-	PetscInt           iter;
-	double             ff,gnorm;
+	int        ierr;
+	int        num_controls,solution_type;
+	int        nsteps,maxiter;
+	AppCtx     user;
+	TaoSolver  tao;
+	double    *dummy          = NULL;
+	int       *control_list   = NULL;
+	Vec        X              = NULL;
+	Vec        XL             = NULL;
+	Vec        XU             = NULL;
 
 	/*Initialize TAO*/
-	int argc; char **args; PetscGetArgs(&argc,&args);
-	int ierr=TaoInitialize(&argc,&args,(char*)0,"");
+	int argc; char **args=NULL;
+	PetscGetArgs(&argc,&args);
+	ierr = TaoInitialize(&argc,&args,(char*)0,"");
 	if(ierr) _error_("Could not initialize Tao");
 
-	/*Line search options*/
-	info = PetscOptionsSetValue("-tao_ls_stepmax","10e11"); if(info) _error_("STOP"); //does not work
-	info = PetscOptionsSetValue("-tao_ls_stepmin","10e5"); if(info) _error_("STOP");    //does not work
-	info = PetscOptionsSetValue("-tao_ls_maxfev","8"); if(info) _error_("STOP");
+	/*Recover some parameters*/
+	femmodel->parameters->FindParam(&solution_type,SolutionTypeEnum);
+	femmodel->parameters->FindParam(&num_controls,InversionNumControlParametersEnum);
+	femmodel->parameters->FindParam(&control_list,NULL,InversionControlParametersEnum);
+	femmodel->parameters->FindParam(&nsteps,InversionNstepsEnum);
+	femmodel->parameters->FindParam(&dummy,NULL,NULL,InversionMaxiterPerStepEnum);
+	maxiter=nsteps*(int)dummy[0]; xfree((void**)&dummy);
 
-	/*TAO options: http://www.mcs.anl.gov/research/projects/tao/docs/manualpages/solver/TaoSetFromOptions.html*/
-	info = PetscOptionsSetValue("-tao_monitor",""); if(info) _error_("STOP");
-	info = PetscOptionsSetValue("-tao_gatol","10e-18"); if(info) _error_("STOP");
-	info = PetscOptionsSetValue("-tao_max_its","10"); if(info) _error_("STOP");
-	info = PetscOptionsSetValue("-tao_max_funcs","20"); if(info) _error_("STOP");
+	/*Initialize TAO*/
+	_printf_(VerboseControl(),"%s\n","   Initializing the Toolkit for Advanced Optimization (TAO)");
+	TaoCreate(PETSC_COMM_WORLD,&tao);
+	TaoSetFromOptions(tao);
+	TaoSetType(tao,"tao_blmvm");
+	//TaoSetType(tao,"tao_cg");
+	//TaoSetType(tao,"tao_lmvm");
 
-	/*Additional options*/
-	//info = PetscOptionsSetValue("-info","/u/astrid-r1b/morlighe/svn/issm/trunk/test/NightlyRun/taolog.txt"); if(info) _error_("STOP");
+	/*Prepare all TAO parameters*/
+	TaoSetMonitor(tao,IssmMonitor,&user,NULL);
+	TaoSetMaximumFunctionEvaluations(tao,maxiter);
+	TaoSetMaximumIterations(tao,nsteps);
+	TaoSetTolerances(tao,0.,0.,0.,0.,0.);
 
-	/*Initialize argument*/
+	GetVectorFromControlInputsx(&X, femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,"value");
+	GetVectorFromControlInputsx(&XL,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,"lowerbound");
+	GetVectorFromControlInputsx(&XU,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,"upperbound");
+	TaoSetInitialVector(tao,X);
+	TaoSetVariableBounds(tao,XL,XU);
+	VecFree(&XL);
+	VecFree(&XU);
+
 	user.femmodel=femmodel;
+	TaoSetObjectiveAndGradientRoutine(tao,FormFunctionGradient,(void*)&user); 
 
-	/*Set up and solve TAO*/
-	GetVectorFromInputsx(&initial_solution,femmodel->elements,femmodel->nodes, femmodel->vertices, femmodel->loads, femmodel->materials, femmodel->parameters,MaterialsRheologyBbarEnum,VertexEnum);
-	info = TaoCreate(PETSC_COMM_WORLD,method,&tao); if(info) _error_("STOP");
-	info = TaoApplicationCreate(PETSC_COMM_WORLD,&controlapp); if(info) _error_("STOP");
-	info = TaoAppSetInitialSolutionVec(controlapp,initial_solution);  if(info) _error_("STOP");
-	info = TaoAppSetObjectiveAndGradientRoutine(controlapp,FormFunctionGradient,(void*)&user);  if(info) _error_("STOP");
-	info = TaoSetOptions(controlapp,tao);  if(info) _error_("STOP");
-	info = TaoSolveApplication(controlapp,tao); //if(info) _error_("STOP");
+	/*Solver optimization problem*/
+	_printf_(VerboseControl(),"%s\n","   Starting optimization");
+	TaoSolve(tao);
+	TaoView(tao,PETSC_VIEWER_STDOUT_WORLD);
+	TaoGetSolutionVector(tao,&X);
+	SetControlInputsFromVectorx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,X);
+	for(int i=0;i<num_controls;i++){
+		InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,control_list[i]);
+	}
 
-	/*Get solution status*/
-	info = TaoGetSolutionStatus(tao,&iter,&ff,&gnorm,0,0,&reason); //CHKERRQ(info);
-	switch(reason){ /*http://www.mcs.anl.gov/research/projects/tao/docs/manualpages/solver/TaoGetTerminationReason.html*/
-		case TAO_CONVERGED_ATOL:       _printf_(true,"TAO_CONVERGED_ATOL (res <= atol)\n"); break;
-		case TAO_CONVERGED_RTOL:       _printf_(true,"TAO_CONVERGED_RTOL (res/res0 <= rtol)\n"); break;
-		case TAO_CONVERGED_TRTOL:      _printf_(true,"TAO_CONVERGED_TRTOL (xdiff <= trtol) \n"); break;
-		case TAO_CONVERGED_MINF:       _printf_(true,"TAO_CONVERGED_MINF  (f <= fmin)\n"); break;
-		case TAO_CONVERGED_USER:       _printf_(true,"TAO_CONVERGED_USER (user defined)\n"); break;
-		case TAO_DIVERGED_MAXITS:      _printf_(true,"TAO_DIVERGED_MAXITS (its>maxits)\n"); break;
-		case TAO_DIVERGED_NAN:         _printf_(true,"TAO_DIVERGED_NAN (Numerical problems)\n"); break;
-		case TAO_DIVERGED_MAXFCN:      _printf_(true,"TAO_DIVERGED_MAXFCN (nfunc > maxnfuncts)\n"); break;
-		case TAO_DIVERGED_LS_FAILURE:  _printf_(true,"TAO_DIVERGED_LS_FAILURE (line search failure)\n"); break;
-		case TAO_DIVERGED_TR_REDUCTION:_printf_(true,"TAO_DIVERGED_TR_REDUCTION \n"); break;
-		case TAO_DIVERGED_USER:        _printf_(true,"TAO_DIVERGED_USER (user defined)\n"); break;
-		default: _printf_(true,"unknown reason");
-	}
-	if (reason<=0){
-		_printf_(true,"Try a different TAO method, adjust some parameters, or check the function evaluation routines\n");
-		_printf_(true," Iterations: %d,  Function Value: %4.2e, Residual: %4.2e \n",iter,ff,gnorm);
-	}
-	else{
-	 _printf_(true,"TAO found a solution");
-	}
-	info = TaoView(tao);  if(info) _error_("STOP");
+	/*Finalize*/
+	_printf_(VerboseControl(),"%s\n","   preparing final solution");
+	femmodel->parameters->SetParam(false,InversionIscontrolEnum); //needed to turn control result output in solutioncore
+	void (*solutioncore)(FemModel*)=NULL;
+	CorePointerFromSolutionEnum(&solutioncore,femmodel->parameters,solution_type);
+	solutioncore(femmodel);
 
-	/*Clean up*/
-	info = TaoDestroy(tao);  if(info) _error_("STOP");
-	info = TaoAppDestroy(controlapp);  if(info) _error_("STOP");
-	VecFree(&initial_solution);
-
-	/* Finalize TAO */
+	/*Clean up and return*/
+	xfree((void**)&control_list);
+	VecFree(&X);
+	TaoDestroy(&tao);
 	TaoFinalize();
 }
-
-int FormFunctionGradient(TAO_APPLICATION taoapp, Vec X, double *fcn,Vec G,void *userCtx){
+int FormFunctionGradient(TaoSolver tao, Vec X, double *fcn,Vec G,void *userCtx){
 
 	/*Retreive arguments*/
-	AppCtx   *user     = (AppCtx*)userCtx;
-	FemModel *femmodel = user->femmodel;
-	Vec       gradient = NULL;
+	int       solution_type,num_cost_functions;
+	AppCtx   *user           = (AppCtx *)userCtx;
+	FemModel *femmodel       = user->femmodel;
+	int      *cost_functions = NULL;
+	double   *cost_functionsd= NULL;
+	Vec       gradient       = NULL;
 
-	/*Temp*/
-//	double*   Xserial=NULL;
-//	VecToMPISerial(&Xserial,X);
-//	printf("X= [%20.20g %20.20g %20.20g]\n",Xserial[0],Xserial[1],Xserial[2]);
-	/*End Temp*/
+	/*Set new variable*/
+	//VecView(X,PETSC_VIEWER_STDOUT_WORLD);
+	SetControlInputsFromVectorx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,X);
 
-	InputUpdateFromConstantx(femmodel->elements,femmodel->nodes, femmodel->vertices, femmodel->loads, femmodel->materials, femmodel->parameters,SurfaceAbsVelMisfitEnum,InversionCostFunctionEnum);
-	InputUpdateFromVectorx(femmodel->elements,femmodel->nodes, femmodel->vertices, femmodel->loads, femmodel->materials, femmodel->parameters,X,MaterialsRheologyBbarEnum,VertexEnum);
-	adjointdiagnostic_core(user->femmodel);
-	Gradjx(&gradient, femmodel->elements,femmodel->nodes, femmodel->vertices,femmodel->loads, femmodel->materials,femmodel->parameters, MaterialsRheologyBbarEnum);
-	VecScale(gradient,10e7);
-	//VecScale(gradient,-1.);
-	VecCopy(gradient,G);
-	CostFunctionx(fcn, femmodel->elements,femmodel->nodes, femmodel->vertices,femmodel->loads, femmodel->materials, femmodel->parameters);
+	/*Recover some parameters*/
+	femmodel->parameters->FindParam(&solution_type,SolutionTypeEnum);
+	femmodel->parameters->FindParam(&num_cost_functions,InversionNumCostFunctionsEnum);
+	femmodel->parameters->FindParam(&cost_functionsd,NULL,NULL,InversionCostFunctionsEnum);
 
-	//printf("X\n");
-	//VecView(X,PETSC_VIEWER_STDOUT_SELF);
+	/*Prepare objective function*/
+	cost_functions=(int*)xmalloc(num_cost_functions*sizeof(int));
+	for(int i=0;i<num_cost_functions;i++) cost_functions[i]=(int)cost_functionsd[i]; //FIXME
+	femmodel->parameters->SetParam(cost_functions,1,num_cost_functions,StepResponsesEnum);
 
-	//printf("Gradient\n");
-	//VecView(G,PETSC_VIEWER_STDOUT_SELF);
+	/*Compute solution and adjoint*/
+	void (*solutioncore)(FemModel*)=NULL;
+	void (*adjointcore)(FemModel*)=NULL;
+	CorePointerFromSolutionEnum(&solutioncore,femmodel->parameters,solution_type);
+	AdjointCorePointerFromSolutionEnum(&adjointcore,solution_type);
+	solutioncore(femmodel);
+	adjointcore(femmodel);
 
-	printf("f(x) = %g\n",*fcn);
+	/*Compute objective function*/
+	CostFunctionx(fcn,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters);
+
+	/*Compute gradient*/
+	Gradjx(&gradient,NULL,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters);
+	VecCopy(gradient,G); VecFree(&gradient);
+	VecScale(G,-1.);
+
+	/*Clean-up and return*/
+	xfree((void**)&cost_functions);
+	xfree((void**)&cost_functionsd);
 	return 0;
 }
+int IssmMonitor(TaoSolver tao, void *userCtx){
+
+	int       i,its,num_responses;
+	double    f,gnorm,cnorm,xdiff;
+	AppCtx   *user      = (AppCtx *)userCtx;
+	FemModel *femmodel  = user->femmodel;
+	Element  *element   = NULL;
+	int      *responses = NULL;
+
+	femmodel->parameters->FindParam(&num_responses,InversionNumCostFunctionsEnum);
+	femmodel->parameters->FindParam(&responses,NULL,NULL,StepResponsesEnum);
+
+	TaoGetSolutionStatus(tao, &its, &f, &gnorm, &cnorm, &xdiff, NULL);
+	if(its==0) _printf_(true,"Iter       Function      Residual  |  List of contributions\n");
+	if(its==0) _printf_(true,"-----------------------------------+-----------------------\n");
+	_printf_(true,"%4i   %12.7g  %12.7g  | ",its,f,gnorm);
+
+	/*Retrieve objective functions independently*/
+	for(i=0;i<num_responses;i++){
+		Responsex(&f,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,EnumToStringx(responses[i]),false,i);
+		_printf_(true," %12.7g ","",f);
+	}
+	_printf_(true,"\n");
+
+	/*Clean-up and return*/
+	xfree((void**)&responses);
+	return 0;
+}
+
 #else
 void controltao_core(FemModel* femmodel){
Index: /issm/trunk/src/c/solutions/convergence.cpp
===================================================================
--- /issm/trunk/src/c/solutions/convergence.cpp	(revision 11526)
+++ /issm/trunk/src/c/solutions/convergence.cpp	(revision 11527)
@@ -8,8 +8,8 @@
 #include "../EnumDefinitions/EnumDefinitions.h"
 
-void convergence(int* pconverged, Mat Kff,Vec pf,Vec uf,Vec old_uf,Parameters* parameters){
+void convergence(bool* pconverged, Mat Kff,Vec pf,Vec uf,Vec old_uf,Parameters* parameters){
 
 	/*output*/
-	int converged=0;
+	bool converged=false;
 
 	/*intermediary*/
@@ -34,5 +34,5 @@
 	 * the get go: */
 	if(!uf){
-		*pconverged=1;
+		*pconverged=true;
 		return;
 	}
@@ -82,9 +82,9 @@
 	if(res<eps_res){
 		_printf_(VerboseConvergence(),"%-50s%g%s%g%s\n","   mechanical equilibrium convergence criterion",res*100," < ",eps_res*100," %");
-		converged=1;
+		converged=true;
 	}
 	else{ 
 		_printf_(VerboseConvergence(),"%-50s%g%s%g%s\n","   mechanical equilibrium convergence criterion",res*100," > ",eps_res*100," %");
-		converged=0;
+		converged=false;
 	}
 
@@ -108,5 +108,5 @@
 			else{ 
 				_printf_(VerboseConvergence(),"%-50s%g%s%g%s\n","   Convergence criterion: norm(du)/norm(u)",ndu/nu*100," > ",eps_rel*100," %");
-				converged=0;
+				converged=false;
 			}
 		}
@@ -133,5 +133,5 @@
 			else{
 				_printf_(VerboseConvergence(),"%-50s%g%s%g%s\n","   Convergence criterion: max(du)",nduinf*yts," > ",eps_abs," m/yr");
-				converged=0;
+				converged=false;
 			}
 		}
Index: /issm/trunk/src/c/solutions/diagnostic_core.cpp
===================================================================
--- /issm/trunk/src/c/solutions/diagnostic_core.cpp	(revision 11526)
+++ /issm/trunk/src/c/solutions/diagnostic_core.cpp	(revision 11527)
@@ -16,15 +16,16 @@
 
 	/*parameters: */
-	bool   dakota_analysis         = false;
-	int    dim                  = -1;
-	bool   ishutter             = false;
-	bool   ismacayealpattyn     = false;
-	bool   isstokes             = false;
-	bool   conserve_loads       = true;
-	bool   modify_loads         = true;
-	bool   control_analysis;
-	int    solution_type;
-	int    numoutputs         = 0;
-	int    *requested_outputs = NULL;
+	bool  dakota_analysis   = false;
+	int   dim               = -1;
+	bool  ishutter          = false;
+	bool  ismacayealpattyn  = false;
+	bool  isstokes          = false;
+	bool  isnewton          = false;
+	bool  conserve_loads    = true;
+	bool  modify_loads      = true;
+	bool  control_analysis;
+	int   solution_type;
+	int   numoutputs        = 0;
+	int  *requested_outputs = NULL;
 
 	/* recover parameters:*/
@@ -33,4 +34,5 @@
 	femmodel->parameters->FindParam(&ismacayealpattyn,FlowequationIsmacayealpattynEnum);
 	femmodel->parameters->FindParam(&isstokes,FlowequationIsstokesEnum);
+	femmodel->parameters->FindParam(&isnewton,DiagnosticIsnewtonEnum);
 	femmodel->parameters->FindParam(&dakota_analysis,QmuIsdakotaEnum);
 	femmodel->parameters->FindParam(&control_analysis,InversionIscontrolEnum);
@@ -72,5 +74,8 @@
 		_printf_(VerboseSolution(),"%s\n","   computing velocities");
 		femmodel->SetCurrentConfiguration(DiagnosticHorizAnalysisEnum);
-		solver_nonlinear(femmodel,modify_loads); 
+		if(isnewton)
+		 solver_newton(femmodel); 
+		else
+		 solver_nonlinear(femmodel,conserve_loads); 
 	}
 
Index: /issm/trunk/src/c/solutions/enthalpy_core.cpp
===================================================================
--- /issm/trunk/src/c/solutions/enthalpy_core.cpp	(revision 11526)
+++ /issm/trunk/src/c/solutions/enthalpy_core.cpp	(revision 11527)
@@ -46,6 +46,5 @@
 
 		/*call enthalpy_core_step: */
-		femmodel->SetCurrentConfiguration(EnthalpyAnalysisEnum);
-		solver_linear(femmodel);
+		enthalpy_core_step(femmodel,i,time);
 
 		if(solution_type==EnthalpySolutionEnum && !control_analysis){
Index: /issm/trunk/src/c/solutions/enthalpy_core_step.cpp
===================================================================
--- /issm/trunk/src/c/solutions/enthalpy_core_step.cpp	(revision 11527)
+++ /issm/trunk/src/c/solutions/enthalpy_core_step.cpp	(revision 11527)
@@ -0,0 +1,26 @@
+/*!\file: enthalpy_core_step.cpp
+ * \brief: core of the enthalpy solution 
+ */ 
+
+#include "../toolkits/toolkits.h"
+#include "../objects/objects.h"
+#include "../shared/shared.h"
+#include "../io/io.h"
+#include "../EnumDefinitions/EnumDefinitions.h"
+#include "./solutions.h"
+#include "../modules/modules.h"
+#include "../include/include.h"
+#include "../solvers/solvers.h"
+
+void enthalpy_core_step(FemModel* femmodel,int step, double time){
+	
+	bool modify_loads=true;
+
+	_printf_(VerboseSolution(),"   computing enthalpy\n");
+	femmodel->SetCurrentConfiguration(EnthalpyAnalysisEnum);
+	solver_nonlinear(femmodel,modify_loads);
+
+	/*transfer enthalpy to enthalpy picard for the next step: */
+	InputDuplicatex(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,EnthalpyEnum,EnthalpyPicardEnum);
+
+}
Index: /issm/trunk/src/c/solutions/gradient_core.cpp
===================================================================
--- /issm/trunk/src/c/solutions/gradient_core.cpp	(revision 11526)
+++ /issm/trunk/src/c/solutions/gradient_core.cpp	(revision 11527)
@@ -13,59 +13,39 @@
 #include "../solvers/solvers.h"
 
-
-void gradient_core(FemModel* femmodel,int step, double search_scalar){ //step defaults to 0, search_scalar defaults to 0
-	
-	/*parameters: */
-	bool    control_steady;
-	int     num_controls;
-	int    *control_type   = NULL;
-	double *optscal_list   = NULL;
-	double  optscal,norm_grad;
+void gradient_core(FemModel* femmodel,int step,bool orthogonalize){ 
 
 	/*Intermediaries*/
-	Vec new_gradient=NULL;
-	Vec gradient=NULL;
-	Vec old_gradient=NULL;
+	double  norm_inf;
+	double *norm_list    = NULL;
+	Vec     new_gradient = NULL;
+	Vec     gradient     = NULL;
+	Vec     old_gradient = NULL;
 
-	/*retrieve parameters:*/
-	femmodel->parameters->FindParam(&control_steady,ControlSteadyEnum);
-	femmodel->parameters->FindParam(&num_controls,InversionNumControlParametersEnum);
-	femmodel->parameters->FindParam(&control_type,NULL,InversionControlParametersEnum);
-	femmodel->parameters->FindParam(&optscal_list,NULL,NULL,InversionGradientScalingEnum);
+	/*Compute gradient*/
+	_printf_(VerboseControl(),"   compute cost function gradient\n");
+	Gradjx(&gradient,&norm_list,femmodel->elements,femmodel->nodes, femmodel->vertices,femmodel->loads, femmodel->materials,femmodel->parameters);
 
-	/*Compute and norm gradient of all controls*/
-	for (int i=0;i<num_controls;i++){
-
-		_printf_(VerboseControl(),"   compute gradient of J with respect to %s\n",EnumToStringx(control_type[i]));
-		Gradjx(&gradient, femmodel->elements,femmodel->nodes, femmodel->vertices,femmodel->loads, femmodel->materials,femmodel->parameters, control_type[i]);
-
-		if(control_steady)diagnostic_core(femmodel);
-
-		if (step>0 && search_scalar==0){
-			_printf_(VerboseControl(),"   orthogonalization\n");
-			ControlInputGetGradientx(&old_gradient,femmodel->elements,femmodel->nodes, femmodel->vertices,femmodel->loads, femmodel->materials,femmodel->parameters,control_type[i]);
-			Orthx(&new_gradient,gradient,old_gradient); VecFree(&old_gradient); VecFree(&gradient);
-		}
-		else{ 
-			_printf_(VerboseControl(),"   normalizing directions\n");
-			Orthx(&new_gradient,gradient,NULL); VecFree(&gradient);
-		}
-
-		/*Get scaling factor of current control:*/
-		VecNorm(new_gradient,NORM_INFINITY,&norm_grad);
-		if(norm_grad<=0)    _error_("||∂J/∂α||∞ = 0    gradient norm of J with respect to %s is zero",EnumToStringx(control_type[i]));
-		if(isnan(norm_grad))_error_("||∂J/∂α||∞ = NaN  gradient norm of J with respect to %s is NaN" ,EnumToStringx(control_type[i]));
-		if(i==0 || (optscal_list[num_controls*step+i]/norm_grad)<optscal) optscal=optscal_list[num_controls*step+i]/norm_grad;
-
-		/*plug back into inputs: */
-		ControlInputSetGradientx(femmodel-> elements,femmodel-> nodes, femmodel-> vertices,femmodel-> loads, femmodel-> materials,  femmodel->parameters,control_type[i],new_gradient);
-		VecFree(&new_gradient);
+	if (orthogonalize){
+		_printf_(VerboseControl(),"   orthogonalization\n");
+		ControlInputGetGradientx(&old_gradient,femmodel->elements,femmodel->nodes, femmodel->vertices,femmodel->loads, femmodel->materials,femmodel->parameters);
+		Orthx(&new_gradient,gradient,old_gradient); VecFree(&old_gradient); VecFree(&gradient);
+	}
+	else{ 
+		new_gradient=gradient;
 	}
 
+	/*Check that gradient is clean*/
+	VecNorm(new_gradient,NORM_INFINITY,&norm_inf);
+	if(norm_inf<=0)    _error_("||∂J/∂α||∞ = 0    gradient norm is zero");
+	if(isnan(norm_inf))_error_("||∂J/∂α||∞ = NaN  gradient norm is NaN");
+
+	/*plug back into inputs: */
+	ControlInputSetGradientx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,new_gradient);
+	VecFree(&new_gradient);
+
 	/*Scale Gradients*/
-	for (int i=0;i<num_controls;i++) ControlInputScaleGradientx(femmodel-> elements,femmodel-> nodes, femmodel-> vertices,femmodel-> loads, femmodel-> materials,  femmodel->parameters,control_type[i],optscal);
+	ControlInputScaleGradientx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,norm_list,step);
 
 	/*Clean up and return*/
-	xfree((void**)&control_type);
-	xfree((void**)&optscal_list);
+	xfree((void**)&norm_list);
 }
Index: /issm/trunk/src/c/solutions/issm.cpp
===================================================================
--- /issm/trunk/src/c/solutions/issm.cpp	(revision 11526)
+++ /issm/trunk/src/c/solutions/issm.cpp	(revision 11527)
@@ -16,6 +16,5 @@
 	FILE *petscoptionsfid  = NULL;
 	bool  waitonlock       = false;
-	bool  dakota_analysis;
-	bool  control_analysis; 
+	bool  dakota_analysis,control_analysis,tao_analysis;
 
 	/*FemModel: */
@@ -81,7 +80,6 @@
 	femmodel->parameters->FindParam(&dakota_analysis,QmuIsdakotaEnum);
 	femmodel->parameters->FindParam(&control_analysis,InversionIscontrolEnum);
+	femmodel->parameters->FindParam(&tao_analysis,InversionTaoEnum);
 	MPI_Barrier(MPI_COMM_WORLD); finish_init=MPI_Wtime();
-
-	/*are we running the solution sequence, or a qmu wrapper around it? : */
 
 	_printf_(true,"call computational core:\n");
@@ -96,5 +94,8 @@
 	else if(control_analysis){
 		#ifdef _HAVE_CONTROL_
-		control_core(femmodel);
+		if(tao_analysis)
+		 controltao_core(femmodel);
+		else
+		 control_core(femmodel);
 		#else
 		_error_("ISSM was not compiled with control support, cannot carry out dakota analysis!");
Index: /issm/trunk/src/c/solutions/solutions.h
===================================================================
--- /issm/trunk/src/c/solutions/solutions.h	(revision 11526)
+++ /issm/trunk/src/c/solutions/solutions.h	(revision 11527)
@@ -15,5 +15,5 @@
 void adjointdiagnostic_core(FemModel* femmodel);
 void adjointbalancethickness_core(FemModel* femmodel);
-void gradient_core(FemModel* femmodel,int step=0, double search_scalar=0);
+void gradient_core(FemModel* femmodel,int n=0,bool orthogonalize=false);
 void diagnostic_core(FemModel* femmodel);
 void hydrology_core(FemModel* femmodel);
@@ -22,4 +22,5 @@
 void thermal_core_step(FemModel* femmodel,int step, double time);
 void enthalpy_core(FemModel* femmodel);
+void enthalpy_core_step(FemModel* femmodel,int step, double time);
 void surfaceslope_core(FemModel* femmodel);
 void bedslope_core(FemModel* femmodel);
@@ -34,5 +35,5 @@
 
 //convergence:
-void convergence(int* pconverged, Mat K_ff,Vec p_f,Vec u_f,Vec u_f_old,Parameters* parameters);
+void convergence(bool* pconverged, Mat K_ff,Vec p_f,Vec u_f,Vec u_f_old,Parameters* parameters);
 bool controlconvergence(double J,double tol_cm);
 bool steadystateconvergence(FemModel* femmodel);
Index: /issm/trunk/src/c/solutions/transient_core.cpp
===================================================================
--- /issm/trunk/src/c/solutions/transient_core.cpp	(revision 11526)
+++ /issm/trunk/src/c/solutions/transient_core.cpp	(revision 11527)
@@ -24,5 +24,5 @@
 	/*parameters: */
 	double finaltime,dt,yts;
-	bool   control_analysis,isdiagnostic,isprognostic,isthermal,isgroundingline;
+	bool   control_analysis,isdiagnostic,isprognostic,isthermal,isgroundingline,isenthalpy;
 	bool   dakota_analysis=false;
 	bool   time_adapt=false;
@@ -51,4 +51,5 @@
 	femmodel->parameters->FindParam(&isthermal,TransientIsthermalEnum);
 	femmodel->parameters->FindParam(&isgroundingline,TransientIsgroundinglineEnum);
+	femmodel->parameters->FindParam(&isenthalpy,ThermalIsenthalpyEnum);
 	if(isgroundingline) femmodel->parameters->FindParam(&groundingline_migration,GroundinglineMigrationEnum);
 	femmodel->parameters->FindParam(&numoutputs,TransientNumRequestedOutputsEnum);
@@ -91,5 +92,10 @@
 			_printf_(VerboseSolution(),"   computing temperatures:\n");
 			#ifdef _HAVE_THERMAL_
-			thermal_core_step(femmodel,step,time);
+			if(isenthalpy==0){
+				thermal_core_step(femmodel,step,time);
+			}
+			else{
+				enthalpy_core_step(femmodel,step,time);
+			}
 			#else
 			_error_("ISSM was not compiled with thermal capabilities. Exiting");
@@ -125,4 +131,5 @@
 		if(solution_type==TransientSolutionEnum && !control_analysis && (step%output_frequency==0 || time==finaltime)){
 			_printf_(VerboseSolution(),"   saving results\n");
+			InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,VzMeshEnum,step,time);
 			InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,VxEnum,step,time);
 			InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,VyEnum,step,time);
@@ -134,5 +141,7 @@
 			InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,BedEnum,step,time);
 			if(dim==3 && isthermal) InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,TemperatureEnum,step,time);
-			InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,BasalforcingsMeltingRateEnum,step,time);
+			if(isenthalpy) InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,WaterfractionEnum,step,time);
+			if(isenthalpy) InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,EnthalpyEnum,step,time);
+			if(!isenthalpy) InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,BasalforcingsMeltingRateEnum,step,time);
 			InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,SurfaceforcingsMassBalanceEnum,step,time);
 			InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,MaskElementonfloatingiceEnum,step,time);
Index: /issm/trunk/src/c/solvers/solver_newton.cpp
===================================================================
--- /issm/trunk/src/c/solvers/solver_newton.cpp	(revision 11527)
+++ /issm/trunk/src/c/solvers/solver_newton.cpp	(revision 11527)
@@ -0,0 +1,95 @@
+/*!\file: solver_nonlinear.cpp
+ * \brief: core of a non-linear solution, using fixed-point method 
+ */ 
+
+#include "../toolkits/toolkits.h"
+#include "../objects/objects.h"
+#include "../io/io.h"
+#include "../EnumDefinitions/EnumDefinitions.h"
+#include "../modules/modules.h"
+#include "../solutions/solutions.h"
+#include "./solvers.h"
+
+void solver_newton(FemModel* femmodel){
+
+	/*intermediary: */
+	bool   converged;
+	int    num_unstable_constraints;
+	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;
+
+	/*parameters:*/
+	int max_nonlinear_iterations;
+	int  configuration_type;
+
+	/*Recover parameters: */
+	femmodel->parameters->FindParam(&max_nonlinear_iterations,DiagnosticMaxiterEnum);
+	femmodel->parameters->FindParam(&configuration_type,ConfigurationTypeEnum);
+	UpdateConstraintsx(femmodel->nodes,femmodel->constraints,femmodel->parameters);
+
+	count=1;
+	converged=false;
+
+	/*Start non-linear iteration using input velocity: */
+	GetSolutionFromInputsx(&ug,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters);
+	Reducevectorgtofx(&uf,ug,femmodel->nodes,femmodel->parameters);
+
+	//Update once again the solution to make sure that vx and vxold are similar (for next step in transient or steadystate)
+	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);
+
+	for(;;){
+
+		VecFree(&old_ug);old_ug=ug;
+		VecFree(&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);
+
+		/*Check convergence*/
+		convergence(&converged,Kff,pf,uf,old_uf,femmodel->parameters); 
+		MatFree(&Kff);VecFree(&pf);
+		if(converged==true) break;
+		if(count>=max_nonlinear_iterations){
+			_printf_(true,"   maximum number of iterations (%i) exceeded\n",max_nonlinear_iterations); 
+			break;
+		}
+
+		/*Prepare next iteration using Newton's method*/
+		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);
+
+		VecDuplicate(pf,&pJf);
+		MatMultPatch(Kff,uf,pJf); MatFree(&Kff);
+		VecScale(pJf,-1.);
+		VecAXPY(pJf,+1.,pf);      VecFree(&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);
+		InputUpdateFromSolutionx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,ug);
+
+		count++;
+	}
+
+	_printf_(VerboseConvergence(),"\n   total number of iterations: %i\n",count-1);
+
+	/*clean-up*/
+	VecFree(&uf);
+	VecFree(&ug);
+	VecFree(&old_ug);
+	VecFree(&old_uf);
+}
Index: /issm/trunk/src/c/solvers/solver_nonlinear.cpp
===================================================================
--- /issm/trunk/src/c/solvers/solver_nonlinear.cpp	(revision 11526)
+++ /issm/trunk/src/c/solvers/solver_nonlinear.cpp	(revision 11527)
@@ -22,5 +22,5 @@
 	
 	Loads* loads=NULL;
-	int converged;
+	bool converged;
 	int constraints_converged;
 	int num_unstable_constraints;
@@ -43,5 +43,5 @@
 
 	count=1;
-	converged=0;
+	converged=false;
 
 	/*Start non-linear iteration using input velocity: */
@@ -50,4 +50,5 @@
 
 	//Update once again the solution to make sure that vx and vxold are similar (for next step in transient or steadystate)
+	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);
 
@@ -63,4 +64,7 @@
 		Solverx(&uf, Kff, pf, old_uf, df, femmodel->parameters);
 		Mergesolutionfromftogx(&ug, uf,ys,femmodel->nodes,femmodel->parameters);VecFree(&ys);
+
+		convergence(&converged,Kff,pf,uf,old_uf,femmodel->parameters); MatFree(&Kff);VecFree(&pf); VecFree(&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);
 
@@ -68,12 +72,9 @@
 		_printf_(VerboseConvergence(),"   number of unstable constraints: %i\n",num_unstable_constraints);
 
-		convergence(&converged,Kff,pf,uf,old_uf,femmodel->parameters); MatFree(&Kff);VecFree(&pf); VecFree(&df);
-		InputUpdateFromConstantx( femmodel->elements,femmodel->nodes, femmodel->vertices, femmodel->loads, femmodel->materials, femmodel->parameters,converged,ConvergedEnum);
-
 		//rift convergence
 		if (!constraints_converged) {
 			if (converged){
-				if (num_unstable_constraints <= min_mechanical_constraints) converged=1;
-				else converged=0;
+				if (num_unstable_constraints <= min_mechanical_constraints) converged=true;
+				else converged=false;
 			}
 		}
@@ -81,10 +82,15 @@
 		/*Increase count: */
 		count++;
-		if(converged==1)break;
+		if(converged==true)break;
 		if(count>=max_nonlinear_iterations){
 			_printf_(true,"   maximum number of iterations (%i) exceeded\n",max_nonlinear_iterations); 
+			converged=true;
+		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);
 			break;
 		}
 	}
+
+	_printf_(VerboseConvergence(),"\n   total number of iterations: %i\n",count-1);
 
 	/*clean-up*/
Index: /issm/trunk/src/c/solvers/solver_stokescoupling_nonlinear.cpp
===================================================================
--- /issm/trunk/src/c/solvers/solver_stokescoupling_nonlinear.cpp	(revision 11526)
+++ /issm/trunk/src/c/solvers/solver_stokescoupling_nonlinear.cpp	(revision 11527)
@@ -14,22 +14,22 @@
 
 	/*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;
-	int converged;
-	int constraints_converged;
-	int num_unstable_constraints;
-	int count;
+	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;
+	bool converged;
+	int  constraints_converged;
+	int  num_unstable_constraints;
+	int  count;
 
 	/*parameters:*/
-	int min_mechanical_constraints;
-	int max_nonlinear_iterations;
-	int configuration_type;
+	int  min_mechanical_constraints;
+	int  max_nonlinear_iterations;
+	int  configuration_type;
 
 	/*Recover parameters: */
@@ -39,5 +39,5 @@
 	
 	count=1;
-	converged=0;
+	converged=false;
 
 	/*First get ug_horiz:*/
@@ -84,5 +84,5 @@
 		/*Increase count: */
 		count++;
-		if(converged==1)break;
+		if(converged==true)break;
 		if(count>=max_nonlinear_iterations){
 			_printf_(true,"   maximum number of iterations (%i) exceeded\n",max_nonlinear_iterations); 
Index: /issm/trunk/src/c/solvers/solvers.h
===================================================================
--- /issm/trunk/src/c/solvers/solvers.h	(revision 11526)
+++ /issm/trunk/src/c/solvers/solvers.h	(revision 11527)
@@ -14,4 +14,5 @@
 void solver_thermal_nonlinear(FemModel* femmodel);
 void solver_nonlinear(FemModel* femmodel,bool conserve_loads);
+void solver_newton(FemModel* femmodel);
 void solver_stokescoupling_nonlinear(FemModel* femmodel,bool conserve_loads);
 void solver_linear(FemModel* femmodel);
Index: /issm/trunk/src/c/toolkits/petsc/patches/PetscOptionsDetermineSolverType.cpp
===================================================================
--- /issm/trunk/src/c/toolkits/petsc/patches/PetscOptionsDetermineSolverType.cpp	(revision 11526)
+++ /issm/trunk/src/c/toolkits/petsc/patches/PetscOptionsDetermineSolverType.cpp	(revision 11527)
@@ -49,4 +49,16 @@
 		solver_type=SUPERLUDISTPACKAGE;
 	}
+	if (strcmp(option,"")==0){
+		solver_type=SUPERLUDISTPACKAGE;
+	}
+
+
+	#if _PETSC_MAJOR_ >= 3 
+	PetscOptionsGetString(PETSC_NULL,"-pc_factor_mat_solver_package",&option[0],100,&flag);
+	if (strcmp(option,"mumps")==0){
+		solver_type=MUMPSPACKAGE_LU;
+	}
+	#endif
+
 	
 	PetscOptionsGetString(PETSC_NULL,"-issm_option_solver",&option[0],100,&flag);
Index: /issm/trunk/src/dox/issm.dox
===================================================================
--- /issm/trunk/src/dox/issm.dox	(revision 11526)
+++ /issm/trunk/src/dox/issm.dox	(revision 11527)
@@ -46,14 +46,14 @@
 </th>
 <tr>
-<th  bgcolor=#FFFFFF style="text-align:left;"> C++ </th><td  bgcolor=#FFFFFF style="text-align:right;">533</td><td  bgcolor=#FFFFFF style="text-align:right;">15543</td><td  bgcolor=#FFFFFF style="text-align:right;">17244</td><td  bgcolor=#FFFFFF style="text-align:right;">57848</td><td  bgcolor=#FFFFFF style="text-align:right;">90635</td>
+<th  bgcolor=#FFFFFF style="text-align:left;"> C++ </th><td  bgcolor=#FFFFFF style="text-align:right;">533</td><td  bgcolor=#FFFFFF style="text-align:right;">15491</td><td  bgcolor=#FFFFFF style="text-align:right;">17275</td><td  bgcolor=#FFFFFF style="text-align:right;">58005</td><td  bgcolor=#FFFFFF style="text-align:right;">90771</td>
 </tr>
 <tr>
-<th  bgcolor=#C6E2FF style="text-align:left;"> MATLAB </th><td  bgcolor=#C6E2FF style="text-align:right;">970</td><td  bgcolor=#C6E2FF style="text-align:right;">7187</td><td  bgcolor=#C6E2FF style="text-align:right;">13630</td><td  bgcolor=#C6E2FF style="text-align:right;">31601</td><td  bgcolor=#C6E2FF style="text-align:right;">52418</td>
+<th  bgcolor=#C6E2FF style="text-align:left;"> MATLAB </th><td  bgcolor=#C6E2FF style="text-align:right;">977</td><td  bgcolor=#C6E2FF style="text-align:right;">7199</td><td  bgcolor=#C6E2FF style="text-align:right;">13702</td><td  bgcolor=#C6E2FF style="text-align:right;">31690</td><td  bgcolor=#C6E2FF style="text-align:right;">52591</td>
 </tr>
 <tr>
-<th  bgcolor=#FFFFFF style="text-align:left;"> C/C++  Header </th><td  bgcolor=#FFFFFF style="text-align:right;">399</td><td  bgcolor=#FFFFFF style="text-align:right;">3064</td><td  bgcolor=#FFFFFF style="text-align:right;">2726</td><td  bgcolor=#FFFFFF style="text-align:right;">10343</td><td  bgcolor=#FFFFFF style="text-align:right;">16133</td>
+<th  bgcolor=#FFFFFF style="text-align:left;"> C/C++  Header </th><td  bgcolor=#FFFFFF style="text-align:right;">399</td><td  bgcolor=#FFFFFF style="text-align:right;">3069</td><td  bgcolor=#FFFFFF style="text-align:right;">2727</td><td  bgcolor=#FFFFFF style="text-align:right;">10358</td><td  bgcolor=#FFFFFF style="text-align:right;">16154</td>
 </tr>
 <tr>
-<th  bgcolor=#C6E2FF style="text-align:left;"> m4 </th><td  bgcolor=#C6E2FF style="text-align:right;">2</td><td  bgcolor=#C6E2FF style="text-align:right;">238</td><td  bgcolor=#C6E2FF style="text-align:right;">163</td><td  bgcolor=#C6E2FF style="text-align:right;">1871</td><td  bgcolor=#C6E2FF style="text-align:right;">2272</td>
+<th  bgcolor=#C6E2FF style="text-align:left;"> m4 </th><td  bgcolor=#C6E2FF style="text-align:right;">7</td><td  bgcolor=#C6E2FF style="text-align:right;">1061</td><td  bgcolor=#C6E2FF style="text-align:right;">242</td><td  bgcolor=#C6E2FF style="text-align:right;">8941</td><td  bgcolor=#C6E2FF style="text-align:right;">10244</td>
 </tr>
 <tr>
@@ -61,5 +61,5 @@
 </tr>
 <tr>
-<th  bgcolor=#C6E2FF style="text-align:left;"> Bourne  Shell </th><td  bgcolor=#C6E2FF style="text-align:right;">8</td><td  bgcolor=#C6E2FF style="text-align:right;">59</td><td  bgcolor=#C6E2FF style="text-align:right;">98</td><td  bgcolor=#C6E2FF style="text-align:right;">262</td><td  bgcolor=#C6E2FF style="text-align:right;">419</td>
+<th  bgcolor=#C6E2FF style="text-align:left;"> Bourne  Shell </th><td  bgcolor=#C6E2FF style="text-align:right;">8</td><td  bgcolor=#C6E2FF style="text-align:right;">61</td><td  bgcolor=#C6E2FF style="text-align:right;">98</td><td  bgcolor=#C6E2FF style="text-align:right;">271</td><td  bgcolor=#C6E2FF style="text-align:right;">430</td>
 </tr>
 <tr>
@@ -76,11 +76,8 @@
 </tr>
 <tr>
-<th  bgcolor=#FFFFFF style="text-align:left;"> SUM: </th><td  bgcolor=#FFFFFF style="text-align:right;">1929</td><td  bgcolor=#FFFFFF style="text-align:right;">26232</td><td  bgcolor=#FFFFFF style="text-align:right;">33895</td><td  bgcolor=#FFFFFF style="text-align:right;">102696</td><td  bgcolor=#FFFFFF style="text-align:right;">162823</td>
+<th  bgcolor=#FFFFFF style="text-align:left;"> SUM: </th><td  bgcolor=#FFFFFF style="text-align:right;">1941</td><td  bgcolor=#FFFFFF style="text-align:right;">27022</td><td  bgcolor=#FFFFFF style="text-align:right;">34078</td><td  bgcolor=#FFFFFF style="text-align:right;">110036</td><td  bgcolor=#FFFFFF style="text-align:right;">171136</td>
 </tr>
 </table>
 
-
-
-
-	<I> Copyright (C) 2011 </I>
+	<I> Copyright (C) 2012 </I>
   */
Index: /issm/trunk/src/m/Makefile.am
===================================================================
--- /issm/trunk/src/m/Makefile.am	(revision 11527)
+++ /issm/trunk/src/m/Makefile.am	(revision 11527)
@@ -0,0 +1,1 @@
+SUBDIRS = classes enum kml model planet qmu shared solutions solvers utils
Index: /issm/trunk/src/m/classes/@modellist/Makefile.am
===================================================================
--- /issm/trunk/src/m/classes/@modellist/Makefile.am	(revision 11527)
+++ /issm/trunk/src/m/classes/@modellist/Makefile.am	(revision 11527)
@@ -0,0 +1,2 @@
+classesdir=$(bindir)/@modellist
+classes_DATA=*.m
Index: /issm/trunk/src/m/classes/@pairoptions/Makefile.am
===================================================================
--- /issm/trunk/src/m/classes/@pairoptions/Makefile.am	(revision 11527)
+++ /issm/trunk/src/m/classes/@pairoptions/Makefile.am	(revision 11527)
@@ -0,0 +1,2 @@
+classesdir=$(bindir)/@pairoptions
+classes_DATA=*.m
Index: /issm/trunk/src/m/classes/Makefile.am
===================================================================
--- /issm/trunk/src/m/classes/Makefile.am	(revision 11527)
+++ /issm/trunk/src/m/classes/Makefile.am	(revision 11527)
@@ -0,0 +1,2 @@
+SUBDIRS = @pairoptions @modellist model clusters
+bin_SCRIPTS=*.m 
Index: /issm/trunk/src/m/classes/clusters/Makefile.am
===================================================================
--- /issm/trunk/src/m/classes/clusters/Makefile.am	(revision 11527)
+++ /issm/trunk/src/m/classes/clusters/Makefile.am	(revision 11527)
@@ -0,0 +1,1 @@
+bin_SCRIPTS=*.m 
Index: /issm/trunk/src/m/classes/clusters/castor.m
===================================================================
--- /issm/trunk/src/m/classes/clusters/castor.m	(revision 11526)
+++ /issm/trunk/src/m/classes/clusters/castor.m	(revision 11527)
@@ -10,11 +10,11 @@
 		 % {{{1
 		 name='castor'
-		 login='larour';
-		 np   =128; %number of processors
+		 login='username';
+		 np   =128;
 		 port=0;
 		 queue='shortc';
 		 time=180;
-		 codepath='/workp/edw/larour/issm-2.0/bin'
-		 executionpath='/workp/edw/larour/Testing/Execution'
+		 codepath='/workp/edw/issm-2.0/bin'
+		 executionpath='/workp/edw/Testing/Execution'
 		 %}}}
 	 end
Index: /issm/trunk/src/m/classes/clusters/cosmos.m
===================================================================
--- /issm/trunk/src/m/classes/clusters/cosmos.m	(revision 11526)
+++ /issm/trunk/src/m/classes/clusters/cosmos.m	(revision 11527)
@@ -10,11 +10,11 @@
 		 % {{{1
 		 name='cosmos'
-		 login='larour';
+		 login='username';
 		 np=128;
 		 port=0;
 		 queue='shortq';
 		 time=3*60;
-		 codepath='/work00/edw/larour/issm-2.0/bin';
-		 executionpath='/work00/edw/larour/Execution';
+		 codepath='/work00/edw/issm-2.0/bin';
+		 executionpath='/work00/edw/Execution';
 		 %}}}
 	 end
Index: /issm/trunk/src/m/classes/clusters/gemini.m
===================================================================
--- /issm/trunk/src/m/classes/clusters/gemini.m	(revision 11526)
+++ /issm/trunk/src/m/classes/clusters/gemini.m	(revision 11527)
@@ -10,11 +10,11 @@
 	% {{{1
 		name='gemini'
-		login='larour';
+		login='username';
 		np=50;
 		port=0;
 		queue='debug';
 		time=60;
-		codepath='/workg/edw/larour/issm-2.0/bin'
-		executionpath='/workg/edw/larour/Testing/Execution'
+		codepath='/workg/edw/issm-2.0/bin'
+		executionpath='/workg/edw/Testing/Execution'
 	%}}}
     end
Index: /issm/trunk/src/m/classes/clusters/generic.m
===================================================================
--- /issm/trunk/src/m/classes/clusters/generic.m	(revision 11526)
+++ /issm/trunk/src/m/classes/clusters/generic.m	(revision 11527)
@@ -78,31 +78,63 @@
 
 			 %open file for writing: 
-			 fid=fopen([modelname '.queue'],'w');
+			 if ~ispc,
+				 fid=fopen([modelname '.queue'],'w');
+			 else
+				 fid=fopen([modelname '.bat'],'w');
+			 end
 
 			 %write instructions for launching a job on the cluster
-			 fprintf(fid,'#!/bin/sh\n');
+			 if ~ispc,
+				 fprintf(fid,'#!/bin/sh\n');
+			 else
+				 fprintf(fid,'@echo off\n');
+			 end
+			 
 			 if ~isvalgrind,
 				 if cluster.interactive
-					 fprintf(fid,'mpiexec -np %i %s/issm.exe %s %s %s ',...
-						 cluster.np,cluster.codepath,EnumToString(solution),cluster.executionpath,modelname);
-				 else
-					 fprintf(fid,'mpiexec -np %i %s/issm.exe %s %s %s 2> %s.errlog >%s.outlog ',...
-						 cluster.np,cluster.codepath,EnumToString(solution),cluster.executionpath,modelname,modelname,modelname);
+					 if ~ispc,
+						 fprintf(fid,'mpiexec -np %i %s/issm.exe %s %s %s ',cluster.np,cluster.codepath,EnumToString(solution),cluster.executionpath,modelname);
+					 else
+						 fprintf(fid,'"%s/issm.exe" %s "%s" %s ',cluster.codepath,EnumToString(solution),cluster.executionpath,modelname);
+					 end
+				 else
+					 if ~ispc,
+						 fprintf(fid,'mpiexec -np %i %s/issm.exe %s %s %s 2> %s.errlog >%s.outlog ',cluster.np,cluster.codepath,EnumToString(solution),cluster.executionpath,modelname,modelname,modelname);
+					 else
+						 fprintf(fid,'"%s/issm.exe" %s "%s" %s 2> %s.errlog >%s.outlog ',cluster.codepath,EnumToString(solution),cluster.executionpath,modelname,modelname,modelname);
+					 end
 				 end
 			 else
-				 %Add --gen-suppressions=all to get suppression lines
-				 fprintf(fid,'LD_PRELOAD=%s \\\n',cluster.valgrindlib);
-				 fprintf(fid,'mpiexec -np %i %s --leak-check=full --suppressions=%s %s/issm.exe %s %s %s 2> %s.errlog >%s.outlog ',...
+				 if ~ispc,
+					 %Add --gen-suppressions=all to get suppression lines
+					 fprintf(fid,'LD_PRELOAD=%s \\\n',cluster.valgrindlib);
+					 fprintf(fid,'mpiexec -np %i %s --leak-check=full --suppressions=%s %s/issm.exe %s %s %s 2> %s.errlog >%s.outlog ',...
 					 cluster.np,cluster.valgrind,cluster.valgrindsup, cluster.codepath,EnumToString(solution),cluster.executionpath,modelname,modelname,modelname);
+				 else
+					 error('valgrind not supported on windows platforms');
+				 end
 			 end
 
 			 if isgprof,
-				 fprintf(fid,'\n gprof %s/issm.exe gmon.out > %s.performance',cluster.codepath,modelname);
+				 if ~ispc,
+					 fprintf(fid,'\n gprof %s/issm.exe gmon.out > %s.performance',cluster.codepath,modelname);
+				 else
+					 error('gprof not supported on windows platforms');
+				 end
+
 			 end
 
 			 if ~md.settings.io_gather,
-				 %concatenate the output files:
-				 fprintf(fid,'\ncat %s.outbin.* > %s.outbin',modelname,modelname);
-			 end
+				 if ~ispc,
+					 %concatenate the output files:
+					 fprintf(fid,'\ncat %s.outbin.* > %s.outbin',modelname,modelname);
+				 else
+					 error('iogather not supported on windows platforms');
+				 end
+
+			 end
+			 
+			 %close file: 
+			 fclose(fid);
 
 			 %in interactive mode, create a run file, and errlog and outlog file
@@ -112,61 +144,71 @@
 			 end
 
+
 		 end
 		 %}}}
 		 function LaunchQueueJob(cluster,md,options)% {{{1
 			 
-			 %lauch command, to be executed via ssh
-			 launchcommand=['cd ' cluster.executionpath ' && rm -rf ./' md.private.runtimename ' && mkdir ' md.private.runtimename ...
-			                ' && cd ' md.private.runtimename ' && mv ../' md.private.runtimename '.tar.gz ./ && tar -zxf ' md.private.runtimename '.tar.gz  && source  ' md.miscellaneous.name '.queue '];
-
-			if ~strcmpi(options.batch,'yes'),
-				
-				%compress the files into one zip.
-				compressstring=['tar -zcf ' md.private.runtimename '.tar.gz ' md.miscellaneous.name '.bin ' md.miscellaneous.name '.queue '  md.miscellaneous.name '.petsc '];
-				if md.qmu.isdakota,
-					compressstring=[compressstring md.miscellaneous.name '.qmu.in'];
-				end
-				if cluster.interactive,
-					compressstring=[compressstring ' ' md.miscellaneous.name '.errlog ' md.miscellaneous.name '.outlog '];
-				end
-				system(compressstring);
-				
-				disp('uploading input file and queueing script');
-				issmscpout(cluster.name,cluster.executionpath,cluster.login,cluster.port,{[md.private.runtimename '.tar.gz']});
-
-				disp('launching solution sequence on remote cluster');
-				issmssh(cluster.name,cluster.login,cluster.port,launchcommand);
-			else
-				disp('batch mode requested: not launching job interactively');
-				disp('launch solution sequence on remote cluster by hand');
-			end
-
-		 end %}}}
-		 function Download(cluster,md)% {{{1
-
-			%some check
-			if isempty(md.private.runtimename),
-				error('supply runtime name for results to be loaded!');
-			end
-
-			%Figure out the  directory where all the files are in: 
-			directory=[cluster.executionpath '/' md.private.runtimename '/'];
-
-			%What packages are we picking up from remote cluster
-			packages={[md.miscellaneous.name '.outlog'],[md.miscellaneous.name '.errlog']};
-			if md.qmu.isdakota,
-				packages{end+1}=[md.miscellaneous.name '.qmu.err'];
-				packages{end+1}=[md.miscellaneous.name '.qmu.out'];
-				if isfield(md.qmu.params,'tabular_graphics_data'),
-					if md.qmu.params.tabular_graphics_data==true,
-						packages{end+1}='dakota_tabular.dat'; 
+			 if ~ispc,
+					 %lauch command, to be executed via ssh
+					 launchcommand=['cd ' cluster.executionpath ' && rm -rf ./' md.private.runtimename ' && mkdir ' md.private.runtimename ...
+					 ' && cd ' md.private.runtimename ' && mv ../' md.private.runtimename '.tar.gz ./ && tar -zxf ' md.private.runtimename '.tar.gz  && source  ' md.miscellaneous.name '.queue '];
+
+					 if ~strcmpi(options.batch,'yes'),
+
+						 %compress the files into one zip.
+						 compressstring=['tar -zcf ' md.private.runtimename '.tar.gz ' md.miscellaneous.name '.bin ' md.miscellaneous.name '.queue '  md.miscellaneous.name '.petsc '];
+						 if md.qmu.isdakota,
+							 compressstring=[compressstring md.miscellaneous.name '.qmu.in'];
 					end
+					if cluster.interactive,
+						compressstring=[compressstring ' ' md.miscellaneous.name '.errlog ' md.miscellaneous.name '.outlog '];
+					end
+					system(compressstring);
+
+					disp('uploading input file and queueing script');
+					issmscpout(cluster.name,cluster.executionpath,cluster.login,cluster.port,{[md.private.runtimename '.tar.gz']});
+
+					disp('launching solution sequence on remote cluster');
+					issmssh(cluster.name,cluster.login,cluster.port,launchcommand);
+				else
+					disp('batch mode requested: not launching job interactively');
+					disp('launch solution sequence on remote cluster by hand');
 				end
 			else
-				packages{end+1}=[md.miscellaneous.name '.outbin'];
+				%launch right here, do not compress or archive.
+				system([md.miscellaneous.name '.bat']);
 			end
 
-			%copy files from cluster to present directory
-			issmscpin(cluster.name, cluster.login, cluster.port, directory, packages);
+		end %}}}
+		 function Download(cluster,md)% {{{1
+
+			if ~ispc,
+				%some check
+				if isempty(md.private.runtimename),
+					error('supply runtime name for results to be loaded!');
+				end
+
+				%Figure out the  directory where all the files are in: 
+				directory=[cluster.executionpath '/' md.private.runtimename '/'];
+
+				%What packages are we picking up from remote cluster
+				packages={[md.miscellaneous.name '.outlog'],[md.miscellaneous.name '.errlog']};
+				if md.qmu.isdakota,
+					packages{end+1}=[md.miscellaneous.name '.qmu.err'];
+					packages{end+1}=[md.miscellaneous.name '.qmu.out'];
+					if isfield(md.qmu.params,'tabular_graphics_data'),
+						if md.qmu.params.tabular_graphics_data==true,
+							packages{end+1}='dakota_tabular.dat'; 
+						end
+					end
+				else
+					packages{end+1}=[md.miscellaneous.name '.outbin'];
+				end
+
+				%copy files from cluster to present directory
+				issmscpin(cluster.name, cluster.login, cluster.port, directory, packages);
+			else
+				%do nothing!
+			end
 		end %}}}
 	end
Index: /issm/trunk/src/m/classes/clusters/greenplanet.m
===================================================================
--- /issm/trunk/src/m/classes/clusters/greenplanet.m	(revision 11527)
+++ /issm/trunk/src/m/classes/clusters/greenplanet.m	(revision 11527)
@@ -0,0 +1,202 @@
+%PFE class definition
+%
+%   Usage:
+%      cluster=greenplanet();
+%      cluster=greenplanet('np',3);
+%      cluster=greenplanet('np',3,'login','username');
+
+classdef greenplanet
+    properties (SetAccess=public)  
+		 % {{{1
+		 name='greenplanet'
+		 login='';
+		 numnodes=20;
+		 cpuspernode=8; 
+		 port=8000;
+		 queue='rignot';
+		 codepath='';
+		 executionpath='';
+		 interactive=0;
+	 end
+	 properties (SetAccess=private) 
+		 np=20*8;
+		 % }}}
+	 end
+	 methods
+		 function cluster=greenplanet(varargin) % {{{1
+
+			 %initialize cluster using default settings if provided
+			 if (exist('greenplanet_settings')==2), greenplanet_settings; end
+
+			 %use provided options to change fields
+			 options=pairoptions(varargin{:});
+			 for i=1:size(options.list,1),
+				 fieldname=options.list{i,1};
+				 fieldvalue=options.list{i,2};
+				 if ismember(fieldname,properties('greenplanet')),
+					 cluster.(fieldname)=fieldvalue;
+				 else
+					 disp(['''' fieldname ''' is not a property of cluster greenplanet']);
+				 end
+			 end
+		 end
+		 %}}}
+		 function disp(cluster) % {{{1
+			 %  display the object
+			 disp(sprintf('class ''%s'' object ''%s'' = ',class(cluster),inputname(1)));
+			 disp(sprintf('    name: %s',cluster.name));
+			 disp(sprintf('    login: %s',cluster.login));
+			 disp(sprintf('    port: %i',cluster.port));
+			 disp(sprintf('    numnodes: %i',cluster.numnodes));
+			 disp(sprintf('    cpuspernode: %i',cluster.cpuspernode));
+			 disp(sprintf('    np: %i',cluster.cpuspernode*cluster.numnodes));
+			 disp(sprintf('    queue: %s',cluster.queue));
+			 disp(sprintf('    codepath: %s',cluster.codepath));
+			 disp(sprintf('    executionpath: %s',cluster.executionpath));
+			 disp(sprintf('    interactive: %i',cluster.interactive));
+		 end
+		 %}}}
+		 function checkconsistency(cluster,md,solution,analyses) % {{{1
+
+			 available_queues={'rignot','default'};
+			 queue_requirements_time=[Inf Inf];
+			 queue_requirements_np=[80 80];
+
+			 QueueRequirements(available_queues,queue_requirements_time,queue_requirements_np,cluster.queue,cluster.np,1)
+
+			 %Miscelaneous
+			 if isempty(cluster.login), checkmessage('login empty'); end
+			 if isempty(cluster.codepath), checkmessage('codepath empty'); end
+			 if isempty(cluster.executionpath), checkmessage('executionpath empty'); end
+
+		 end
+		 %}}}
+		 function BuildQueueScript(cluster,md) % {{{1
+
+			 %retrieve parameters 
+			 modelname=md.miscellaneous.name; 
+			 solution=md.private.solution;
+			 isvalgrind=md.debug.valgrind;
+
+			 %compute number of processors
+			 cluster.np=cluster.numnodes*cluster.cpuspernode;
+
+			 %open file for writing: 
+			 fid=fopen([modelname '.queue'],'w');
+
+			 fprintf(fid,'#PBS -S /bin/bash\n');
+			 fprintf(fid,'#PBS -N %s\n',modelname);
+			 fprintf(fid,'#PBS -q %s \n',cluster.queue);
+			 fprintf(fid,'#PBS -l nodes=%i:ppn=%i\n',cluster.numnodes,cluster.cpuspernode);
+			 fprintf(fid,'#PBS -m bea\n');
+			 fprintf(fid,'#PBS -M mmorligh@uci.edu\n');
+			 fprintf(fid,'#PBS -o %s.outlog \n',modelname);
+			 fprintf(fid,'#PBS -e %s.errlog \n\n',modelname);
+
+			 fprintf(fid,'cd %s/%s\n\n',cluster.executionpath,md.private.runtimename);
+			 fprintf(fid,'mpiexec -np %i %s/issm.exe %s %s %s\n',cluster.np,cluster.codepath,EnumToString(solution),cluster.executionpath,modelname);
+
+			 if ~md.settings.io_gather,
+				 %concatenate the output files:
+				 fprintf(fid,'cat %s.outbin.* > %s.outbin',modelname,modelname);
+			 end
+
+			 %close file
+			 fclose(fid);
+
+			 %in interactive mode, create a run file, and errlog and outlog file
+			 if cluster.interactive,
+				 fid=fopen([modelname '.run'],'w');
+				 fprintf(fid,'mpiexec -np %i %s/issm.exe %s %s %s\n',cluster.np,cluster.codepath,EnumToString(solution),cluster.executionpath,modelname);
+
+				 if ~md.settings.io_gather,
+					 %concatenate the output files:
+					 fprintf(fid,'cat %s.outbin.* > %s.outbin',modelname,modelname);
+				 end
+				 fclose(fid);
+				 fid=fopen([modelname '.errlog'],'w');
+				 fclose(fid);
+				 fid=fopen([modelname '.outlog'],'w');
+				 fclose(fid);
+			 end
+		 end %}}}
+		 function LaunchQueueJob(cluster,md,options)% {{{1
+			 
+			 %lauch command, to be executed via ssh
+			 if ~cluster.interactive, 
+				launchcommand=['cd ' cluster.executionpath ' && rm -rf ./' md.private.runtimename ' && mkdir ' md.private.runtimename ...
+			                ' && cd ' md.private.runtimename ' && mv ../' md.private.runtimename '.tar.gz ./ && tar -zxf ' md.private.runtimename '.tar.gz  && qsub ' md.miscellaneous.name '.queue '];
+			else
+				launchcommand=['cd ' cluster.executionpath '/Interactive' num2str(cluster.interactive) ' && tar -zxf ' md.private.runtimename '.tar.gz'];
+			end
+
+			if ~strcmpi(options.batch,'yes'),
+				
+				%compress the files into one zip.
+				compressstring=['tar -zcf ' md.private.runtimename '.tar.gz ' md.miscellaneous.name '.bin ' md.miscellaneous.name '.queue '  md.miscellaneous.name '.petsc '];
+				if md.qmu.isdakota,
+					compressstring=[compressstring md.miscellaneous.name '.qmu.in '];
+				end
+				if cluster.interactive,
+					compressstring=[compressstring md.miscellaneous.name '.run ' md.miscellaneous.name '.errlog ' md.miscellaneous.name '.outlog '];
+				end
+				system(compressstring);
+				
+				disp('uploading input file and queueing script');
+				if cluster.interactive,
+					directory=[cluster.executionpath '/Interactive' num2str(cluster.interactive)];
+				else 
+					directory=cluster.executionpath;
+				end
+				
+				issmscpout(cluster.name,directory,cluster.login,cluster.port,{[md.private.runtimename '.tar.gz']});
+				
+				disp('launching solution sequence on remote cluster');
+				issmssh(cluster.name,cluster.login,cluster.port,launchcommand);
+
+			else
+				disp('batch mode requested: not launching job interactively');
+				disp('launch solution sequence on remote cluster by hand');
+			end
+		 end
+		 %}}}
+		 function Download(cluster,md)% {{{1
+
+			%some check
+			if isempty(md.private.runtimename),
+				if ~cluster.interactive,
+					error('greenplanet Download error message: supply runtime name for results to be loaded!');
+				end
+			end
+
+			%Figure out the  directory where all the files are in: 
+			if ~cluster.interactive,
+				directory=[cluster.executionpath '/' md.private.runtimename '/'];
+			else
+				directory=[cluster.executionpath '/Interactive' num2str(cluster.interactive) '/'];
+			end
+
+			%What packages are we picking up from remote cluster
+			if ~cluster.interactive,
+				packages={[md.miscellaneous.name '.outlog'],[md.miscellaneous.name '.errlog']};
+			else
+				packages={};
+			end
+			if md.qmu.isdakota,
+				packages{end+1}=[md.miscellaneous.name '.qmu.err'];
+				packages{end+1}=[md.miscellaneous.name '.qmu.out'];
+				if isfield(md.qmu.params,'tabular_graphics_data'),
+					if md.qmu.params.tabular_graphics_data==true,
+						packages{end+1}='dakota_tabular.dat'; 
+					end
+				end
+			else
+				packages{end+1}=[md.miscellaneous.name '.outbin'];
+			end
+
+			%copy files from cluster to present directory
+			issmscpin(cluster.name, cluster.login, cluster.port, directory, packages);
+
+		end %}}}
+	end
+end
Index: /issm/trunk/src/m/classes/clusters/pollux.m
===================================================================
--- /issm/trunk/src/m/classes/clusters/pollux.m	(revision 11526)
+++ /issm/trunk/src/m/classes/clusters/pollux.m	(revision 11527)
@@ -10,11 +10,11 @@
 		 % {{{1
 		 name='pollux'
-		 login='larour';
+		 login='username';
 		 np=128;
 		 port=0;
 		 queue='shortp';
 		 time=180;
-		 codepath='/workc/edw/larour/issm-2.0/bin'
-		 executionpath='/workc/edw/larour/Testing/Execution'
+		 codepath='/workc/edw/issm-2.0/bin'
+		 executionpath='/workc/edw/Testing/Execution'
 		 %}}}
 	 end
Index: /issm/trunk/src/m/classes/diagnostic.m
===================================================================
--- /issm/trunk/src/m/classes/diagnostic.m	(revision 11526)
+++ /issm/trunk/src/m/classes/diagnostic.m	(revision 11527)
@@ -12,4 +12,5 @@
 		reltol                   = 0;
 		abstol                   = 0;
+		isnewton                 = 0;
 		stokesreconditioning     = 0;
 		viscosity_overshoot      = 0;
@@ -82,4 +83,5 @@
 			checkfield(md,'diagnostic.reltol','size',[1 1]);
 			checkfield(md,'diagnostic.abstol','size',[1 1]);
+			checkfield(md,'diagnostic.isnewton','numel',1,'values',[0 1]);
 			checkfield(md,'diagnostic.stokesreconditioning','size',[1 1],'NaN',1);
 			checkfield(md,'diagnostic.viscosity_overshoot','size',[1 1],'NaN',1);
@@ -127,4 +129,5 @@
 			fielddisplay(obj,'reltol','velocity relative convergence criterion, NaN -> not applied');
 			fielddisplay(obj,'abstol','velocity absolute convergence criterion, NaN -> not applied');
+			fielddisplay(obj,'isnewton','Apply Newton''s method instead of a Picard fixed point method');
 			fielddisplay(obj,'maxiter','maximum number of nonlinear iterations');
 			fielddisplay(obj,'viscosity_overshoot','over-shooting constant new=new+C*(new-old)');
@@ -158,4 +161,5 @@
 			WriteData(fid,'object',obj,'fieldname','reltol','format','Double');
 			WriteData(fid,'object',obj,'fieldname','abstol','format','Double');
+			WriteData(fid,'object',obj,'fieldname','isnewton','format','Boolean');
 			WriteData(fid,'object',obj,'fieldname','stokesreconditioning','format','Double');
 			WriteData(fid,'object',obj,'fieldname','viscosity_overshoot','format','Double');
Index: /issm/trunk/src/m/classes/initialization.m
===================================================================
--- /issm/trunk/src/m/classes/initialization.m	(revision 11526)
+++ /issm/trunk/src/m/classes/initialization.m	(revision 11527)
@@ -62,4 +62,7 @@
 				checkfield(md,'initialization.pressure','NaN',1,'size',[md.mesh.numberofvertices 1]);
 			end
+			if (ismember(EnthalpyAnalysisEnum,analyses) & md.thermal.isenthalpy),
+				checkfield(md,'initialization.waterfraction','>=',0,'size',[md.mesh.numberofvertices 1]);
+			end
 		end % }}}
 		function disp(obj) % {{{
Index: /issm/trunk/src/m/classes/inversion.m
===================================================================
--- /issm/trunk/src/m/classes/inversion.m	(revision 11526)
+++ /issm/trunk/src/m/classes/inversion.m	(revision 11527)
@@ -7,4 +7,6 @@
 	properties (SetAccess=public) 
 		iscontrol                   = 0
+		tao                         = 0
+		incomplete_adjoint          = 0
 		control_parameters          = NaN
 		nsteps                      = 0
@@ -42,37 +44,40 @@
 		function obj = setdefaultparameters(obj) % {{{
 
-			 %parameter to be inferred by control methods (only
-			 %drag and B are supported yet)
-			 obj.control_parameters={'FrictionCoefficient'};
+			%default is incomplete adjoint for now
+			obj.incomplete_adjoint=1;
 
-			 %number of steps in the control methods
-			 obj.nsteps=20;
+			%parameter to be inferred by control methods (only
+			%drag and B are supported yet)
+			obj.control_parameters={'FrictionCoefficient'};
 
-			 %maximum number of iteration in the optimization algorithm for
-			 %each step
-			 obj.maxiter_per_step=20*ones(obj.nsteps,1);
+			%number of steps in the control methods
+			obj.nsteps=20;
 
-			 %the inversed parameter is updated as follows:
-			 %new_par=old_par + gradient_scaling(n)*C*gradient with C in [0 1];
-			 %usually the gradient_scaling must be of the order of magnitude of the 
-			 %inversed parameter (10^8 for B, 50 for drag) and can be decreased
-			 %after the first iterations
-			 obj.gradient_scaling=50*ones(obj.nsteps,1);
+			%maximum number of iteration in the optimization algorithm for
+			%each step
+			obj.maxiter_per_step=20*ones(obj.nsteps,1);
 
-			 %several responses can be used:
-			 obj.cost_functions=101*ones(obj.nsteps,1);
+			%the inversed parameter is updated as follows:
+			%new_par=old_par + gradient_scaling(n)*C*gradient with C in [0 1];
+			%usually the gradient_scaling must be of the order of magnitude of the 
+			%inversed parameter (10^8 for B, 50 for drag) and can be decreased
+			%after the first iterations
+			obj.gradient_scaling=50*ones(obj.nsteps,1);
 
-			 %step_threshold is used to speed up control method. When
-			 %misfit(1)/misfit(0) < obj.step_threshold, we go directly to
-			 %the next step
-			 obj.step_threshold=.7*ones(obj.nsteps,1); %30 per cent decrement.
+			%several responses can be used:
+			obj.cost_functions=101*ones(obj.nsteps,1);
 
-			 %stop control solution at the gradient computation and return it? 
-			 obj.gradient_only=0;
+			%step_threshold is used to speed up control method. When
+			%misfit(1)/misfit(0) < obj.step_threshold, we go directly to
+			%the next step
+			obj.step_threshold=.7*ones(obj.nsteps,1); %30 per cent decrement.
 
-			 %cost_function_threshold is a criteria to stop the control methods.
-			 %if J[n]-J[n-1]/J[n] < criteria, the control run stops
-			 %NaN if not applied
-			 obj.cost_function_threshold=NaN; %not activated
+			%stop control solution at the gradient computation and return it? 
+			obj.gradient_only=0;
+
+			%cost_function_threshold is a criteria to stop the control methods.
+			%if J[n]-J[n-1]/J[n] < criteria, the control run stops
+			%NaN if not applied
+			obj.cost_function_threshold=NaN; %not activated
 
 		end % }}}
@@ -86,4 +91,6 @@
 
 			checkfield(md,'inversion.iscontrol','values',[0 1]);
+			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);
@@ -106,4 +113,5 @@
 		function disp(obj) % {{{
 			fielddisplay(obj,'iscontrol','is inversion activated?');
+			fielddisplay(obj,'incomplete_adjoint','do we assume linear viscosity?');
 			fielddisplay(obj,'control_parameters','parameter where inverse control is carried out; ex: {''FrictionCoefficient''}, or {''MaterialsRheologyBbar''}');
 			fielddisplay(obj,'nsteps','number of optimization searches');
@@ -135,4 +143,6 @@
 
 			WriteData(fid,'object',obj,'fieldname','iscontrol','format','Boolean');
+			WriteData(fid,'object',obj,'fieldname','tao','format','Boolean');
+			WriteData(fid,'object',obj,'fieldname','incomplete_adjoint','format','Boolean');
 			if ~obj.iscontrol, return; end
 			WriteData(fid,'object',obj,'fieldname','nsteps','format','Integer');
Index: /issm/trunk/src/m/classes/model/Makefile.am
===================================================================
--- /issm/trunk/src/m/classes/model/Makefile.am	(revision 11527)
+++ /issm/trunk/src/m/classes/model/Makefile.am	(revision 11527)
@@ -0,0 +1,1 @@
+bin_SCRIPTS=*.m 
Index: /issm/trunk/src/m/classes/model/model.m
===================================================================
--- /issm/trunk/src/m/classes/model/model.m	(revision 11526)
+++ /issm/trunk/src/m/classes/model/model.m	(revision 11527)
@@ -136,5 +136,4 @@
 			 if isfield(structmd,'melting_rate'), md.basalforcings.melting_rate=structmd.melting_rate; end
 			 if isfield(structmd,'accumulation'), md.surfaceforcings.mass_balance=structmd.accumulation; end
-			 if isfield(structmd,'accumulation_rate'), md.surfaceforcings.mass_balance=structmd.accumulation_rate; end
 			 if isfield(structmd,'numberofgrids'), md.mesh.numberofvertices=structmd.numberofgrids; end
 			 if isfield(structmd,'numberofgrids2d'), md.mesh.numberofvertices2d=structmd.numberofgrids2d; end
@@ -404,5 +403,9 @@
 			 md.settings         = settings();
 			 md.solver           = solver();
-			 md.solver           = addoptions(md.solver,DiagnosticVertAnalysisEnum,mumpsoptions);
+			 if ismumps,
+				 md.solver           = addoptions(md.solver,DiagnosticVertAnalysisEnum,mumpsoptions);
+			 else
+				 md.solver           = addoptions(md.solver,DiagnosticVertAnalysisEnum,iluasmoptions);
+			 end
 			 md.cluster          = none();
 			 md.balancethickness = balancethickness();
Index: /issm/trunk/src/m/classes/solver.m
===================================================================
--- /issm/trunk/src/m/classes/solver.m	(revision 11526)
+++ /issm/trunk/src/m/classes/solver.m	(revision 11527)
@@ -6,5 +6,5 @@
 classdef solver
     properties (SetAccess=public) 
-		 options={NoneAnalysisEnum,mumpsoptions};
+		 options=cell(0,0);
 	 end
 	 methods
@@ -26,25 +26,41 @@
 		 function obj = setdefaultparameters(obj) % {{{
 
+			 %MUMPS is the default solver
+			 if ismumps,
+				 obj.options={'NoneAnalysis',mumpsoptions};
+			 else
+				 obj.options={'NoneAnalysis',iluasmoptions};
+			 end
+
 		 end % }}}
-		 function obj=addoptions(obj,analysis,solveroptions) % {{{1
+		 function obj = addoptions(obj,analysis,solveroptions) % {{{1
+
+			 %Convert analysis from enum to string
+			 analysis=EnumToString(analysis);
+
 			 %first, find out if analysis has already been supplied
 			 found=false;
 			 for i=1:size(obj.options,1),
 				 inanalysis=obj.options{i,1};
-				 if inanalysis==analysis,
+				 if strcmp(inanalysis,analysis),
 					 found=true;
-					 obj.options{i,1}=analysis;
-					 obj.options{i,2}=solveroptions;
+					 obj.options{i,1} = analysis;
+					 obj.options{i,2} = solveroptions;
 					 break;
 				 end
 			 end
+
 			 if ~found,
-				 obj.options{end+1,1}=analysis;
-				 obj.options{end,2}=solveroptions;
+				 obj.options{end+1,1}= analysis;
+				 obj.options{end,2}  = solveroptions;
 			 end
 		 end
 		 %}}}
 		 function checkconsistency(obj,md,solution,analyses) % {{{
-
+			 for i=1:size(obj.options,1),
+				 if ~ischar(obj.options{i,1}),
+					 checkmessage('solver is not well formatted: Analyses are not strings');
+				 end
+			 end
 		 end % }}}
 		 function PetscFile(solver,filename) % {{{
@@ -70,5 +86,5 @@
 
 				 %first write analysis:
-				 fprintf(fid,'\n+%s\n',EnumToString(analysis)); %append a + to recognize it's an analysis enum
+				 fprintf(fid,'\n+%s\n',analysis); %append a + to recognize it's an analysis enum
 
 				 %now, write options
@@ -126,5 +142,5 @@
 				end
 
-				disp(sprintf('   %s -> ''%s''',EnumToString(analysis),string));
+				disp(sprintf('   %s -> ''%s''',analysis,string));
 			end
 		 end
Index: /issm/trunk/src/m/classes/surfaceforcings.m
===================================================================
--- /issm/trunk/src/m/classes/surfaceforcings.m	(revision 11526)
+++ /issm/trunk/src/m/classes/surfaceforcings.m	(revision 11527)
@@ -6,7 +6,6 @@
 classdef surfaceforcings
 	properties (SetAccess=public) 
-		accumulation_rate = NaN;
-		ablation_rate     = NaN;
-		mass_balance      = NaN;
+		precipitation = NaN;
+		mass_balance  = NaN;
 	end
 	methods
@@ -41,12 +40,10 @@
 			disp(sprintf('   surface forcings parameters:'));
 
-			fielddisplay(obj,'accumulation_rate','surface accumulation rate [m]');
-			fielddisplay(obj,'ablation_rate','surface ablation rate [m]');
-			fielddisplay(obj,'mass_balance','surface mass balance [m]');
+			fielddisplay(obj,'precipitation','surface precipitation [m/yr ice eq]');
+			fielddisplay(obj,'mass_balance','surface mass balance [m/yr ice eq]');
 
 		end % }}}
 		function marshall(obj,fid) % {{{
-			WriteData(fid,'object',obj,'fieldname','accumulation_rate','format','DoubleMat','mattype',1);
-			WriteData(fid,'object',obj,'fieldname','ablation_rate','format','DoubleMat','mattype',1);
+			WriteData(fid,'object',obj,'fieldname','precipitation','format','DoubleMat','mattype',1);
 			WriteData(fid,'object',obj,'fieldname','mass_balance','format','DoubleMat','mattype',1);
 		end % }}}
Index: /issm/trunk/src/m/classes/thermal.m
===================================================================
--- /issm/trunk/src/m/classes/thermal.m	(revision 11526)
+++ /issm/trunk/src/m/classes/thermal.m	(revision 11527)
@@ -12,4 +12,5 @@
 		penalty_lock      = 0;
 		penalty_factor    = 0;
+		isenthalpy        = 0;
 	end
 	methods
@@ -42,12 +43,19 @@
 			%factor used to compute the values of the penalties: kappa=max(stiffness matrix)*10^penalty_factor
 			obj.penalty_factor=3;
+
+			%Should we use cold ice (default) or enthalpy formulation
+			obj.isenthalpy=0;
 		end % }}}
 		function checkconsistency(obj,md,solution,analyses) % {{{
 
 			%Early return
-			if ~ismember(ThermalAnalysisEnum,analyses) | (solution==TransientSolutionEnum & md.transient.isthermal==0), return; end
+			if (~ismember(ThermalAnalysisEnum,analyses) & ~ismember(EnthalpyAnalysisEnum,analyses)) | (solution==TransientSolutionEnum & md.transient.isthermal==0), return; end
 
 			checkfield(md,'thermal.stabilization','numel',1,'values',[0 1 2]);
 			checkfield(md,'thermal.spctemperature','forcing',1);
+			if (ismember(EnthalpyAnalysisEnum,analyses) & md.thermal.isenthalpy),
+			checkfield(md,'thermal.spctemperature','<',md.materials.meltingpoint-md.materials.beta*md.materials.rho_ice*md.constants.g*md.geometry.thickness,'message','spctemperature should be below the adjusted melting point');
+			checkfield(md,'thermal.isenthalpy','numel',1,'values',[0 1]);
+			end
 		end % }}}
 		function disp(obj) % {{{
@@ -59,4 +67,5 @@
 			fielddisplay(obj,'penalty_lock','stabilize unstable thermal constraints that keep zigzagging after n iteration (default is 0, no stabilization)');
 			fielddisplay(obj,'penalty_threshold','threshold to declare convergence of thermal solution (default is 0)');
+			fielddisplay(obj,'isenthalpy','use an enthalpy formulation to include temperate ice (default is 0)');
 
 		end % }}}
@@ -68,4 +77,5 @@
 			WriteData(fid,'object',obj,'fieldname','penalty_lock','format','Integer');
 			WriteData(fid,'object',obj,'fieldname','penalty_factor','format','Double');
+			WriteData(fid,'object',obj,'fieldname','isenthalpy','format','Boolean');
 		end % }}}
 	end
Index: /issm/trunk/src/m/enum/DiagnosticIsnewtonEnum.m
===================================================================
--- /issm/trunk/src/m/enum/DiagnosticIsnewtonEnum.m	(revision 11527)
+++ /issm/trunk/src/m/enum/DiagnosticIsnewtonEnum.m	(revision 11527)
@@ -0,0 +1,11 @@
+function macro=DiagnosticIsnewtonEnum()
+%DIAGNOSTICISNEWTONENUM - Enum of DiagnosticIsnewton
+%
+%   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:
+%      macro=DiagnosticIsnewtonEnum()
+
+macro=StringToEnum('DiagnosticIsnewton');
Index: /issm/trunk/src/m/enum/InversionIncompleteAdjointEnum.m
===================================================================
--- /issm/trunk/src/m/enum/InversionIncompleteAdjointEnum.m	(revision 11527)
+++ /issm/trunk/src/m/enum/InversionIncompleteAdjointEnum.m	(revision 11527)
@@ -0,0 +1,11 @@
+function macro=InversionIncompleteAdjointEnum()
+%INVERSIONINCOMPLETEADJOINTENUM - Enum of InversionIncompleteAdjoint
+%
+%   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:
+%      macro=InversionIncompleteAdjointEnum()
+
+macro=StringToEnum('InversionIncompleteAdjoint');
Index: /issm/trunk/src/m/enum/InversionTaoEnum.m
===================================================================
--- /issm/trunk/src/m/enum/InversionTaoEnum.m	(revision 11527)
+++ /issm/trunk/src/m/enum/InversionTaoEnum.m	(revision 11527)
@@ -0,0 +1,11 @@
+function macro=InversionTaoEnum()
+%INVERSIONTAOENUM - Enum of InversionTao
+%
+%   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:
+%      macro=InversionTaoEnum()
+
+macro=StringToEnum('InversionTao');
Index: /issm/trunk/src/m/enum/Makefile.am
===================================================================
--- /issm/trunk/src/m/enum/Makefile.am	(revision 11527)
+++ /issm/trunk/src/m/enum/Makefile.am	(revision 11527)
@@ -0,0 +1,1 @@
+bin_SCRIPTS=*.m 
Index: /issm/trunk/src/m/enum/PentaP1ElementResultEnum.m
===================================================================
--- /issm/trunk/src/m/enum/PentaP1ElementResultEnum.m	(revision 11527)
+++ /issm/trunk/src/m/enum/PentaP1ElementResultEnum.m	(revision 11527)
@@ -0,0 +1,11 @@
+function macro=PentaP1ElementResultEnum()
+%PENTAP1ELEMENTRESULTENUM - Enum of PentaP1ElementResult
+%
+%   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:
+%      macro=PentaP1ElementResultEnum()
+
+macro=StringToEnum('PentaP1ElementResult');
Index: /issm/trunk/src/m/enum/PentaP1InputEnum.m
===================================================================
--- /issm/trunk/src/m/enum/PentaP1InputEnum.m	(revision 11527)
+++ /issm/trunk/src/m/enum/PentaP1InputEnum.m	(revision 11527)
@@ -0,0 +1,11 @@
+function macro=PentaP1InputEnum()
+%PENTAP1INPUTENUM - Enum of PentaP1Input
+%
+%   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:
+%      macro=PentaP1InputEnum()
+
+macro=StringToEnum('PentaP1Input');
Index: sm/trunk/src/m/enum/PentaVertexElementResultEnum.m
===================================================================
--- /issm/trunk/src/m/enum/PentaVertexElementResultEnum.m	(revision 11526)
+++ 	(revision )
@@ -1,11 +1,0 @@
-function macro=PentaVertexElementResultEnum()
-%PENTAVERTEXELEMENTRESULTENUM - Enum of PentaVertexElementResult
-%
-%   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:
-%      macro=PentaVertexElementResultEnum()
-
-macro=StringToEnum('PentaVertexElementResult');
Index: sm/trunk/src/m/enum/PentaVertexInputEnum.m
===================================================================
--- /issm/trunk/src/m/enum/PentaVertexInputEnum.m	(revision 11526)
+++ 	(revision )
@@ -1,11 +1,0 @@
-function macro=PentaVertexInputEnum()
-%PENTAVERTEXINPUTENUM - Enum of PentaVertexInput
-%
-%   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:
-%      macro=PentaVertexInputEnum()
-
-macro=StringToEnum('PentaVertexInput');
Index: sm/trunk/src/m/enum/SurfaceforcingsAblationRateEnum.m
===================================================================
--- /issm/trunk/src/m/enum/SurfaceforcingsAblationRateEnum.m	(revision 11526)
+++ 	(revision )
@@ -1,11 +1,0 @@
-function macro=SurfaceforcingsAblationRateEnum()
-%SURFACEFORCINGSABLATIONRATEENUM - Enum of SurfaceforcingsAblationRate
-%
-%   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:
-%      macro=SurfaceforcingsAblationRateEnum()
-
-macro=StringToEnum('SurfaceforcingsAblationRate');
Index: sm/trunk/src/m/enum/SurfaceforcingsAccumulationRateEnum.m
===================================================================
--- /issm/trunk/src/m/enum/SurfaceforcingsAccumulationRateEnum.m	(revision 11526)
+++ 	(revision )
@@ -1,11 +1,0 @@
-function macro=SurfaceforcingsAccumulationRateEnum()
-%SURFACEFORCINGSACCUMULATIONRATEENUM - Enum of SurfaceforcingsAccumulationRate
-%
-%   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:
-%      macro=SurfaceforcingsAccumulationRateEnum()
-
-macro=StringToEnum('SurfaceforcingsAccumulationRate');
Index: /issm/trunk/src/m/enum/SurfaceforcingsPrecipitationEnum.m
===================================================================
--- /issm/trunk/src/m/enum/SurfaceforcingsPrecipitationEnum.m	(revision 11527)
+++ /issm/trunk/src/m/enum/SurfaceforcingsPrecipitationEnum.m	(revision 11527)
@@ -0,0 +1,11 @@
+function macro=SurfaceforcingsPrecipitationEnum()
+%SURFACEFORCINGSPRECIPITATIONENUM - Enum of SurfaceforcingsPrecipitation
+%
+%   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:
+%      macro=SurfaceforcingsPrecipitationEnum()
+
+macro=StringToEnum('SurfaceforcingsPrecipitation');
Index: /issm/trunk/src/m/enum/ThermalIsenthalpyEnum.m
===================================================================
--- /issm/trunk/src/m/enum/ThermalIsenthalpyEnum.m	(revision 11527)
+++ /issm/trunk/src/m/enum/ThermalIsenthalpyEnum.m	(revision 11527)
@@ -0,0 +1,11 @@
+function macro=ThermalIsenthalpyEnum()
+%THERMALISENTHALPYENUM - Enum of ThermalIsenthalpy
+%
+%   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:
+%      macro=ThermalIsenthalpyEnum()
+
+macro=StringToEnum('ThermalIsenthalpy');
Index: /issm/trunk/src/m/enum/TriaP1ElementResultEnum.m
===================================================================
--- /issm/trunk/src/m/enum/TriaP1ElementResultEnum.m	(revision 11527)
+++ /issm/trunk/src/m/enum/TriaP1ElementResultEnum.m	(revision 11527)
@@ -0,0 +1,11 @@
+function macro=TriaP1ElementResultEnum()
+%TRIAP1ELEMENTRESULTENUM - Enum of TriaP1ElementResult
+%
+%   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:
+%      macro=TriaP1ElementResultEnum()
+
+macro=StringToEnum('TriaP1ElementResult');
Index: /issm/trunk/src/m/enum/TriaP1InputEnum.m
===================================================================
--- /issm/trunk/src/m/enum/TriaP1InputEnum.m	(revision 11527)
+++ /issm/trunk/src/m/enum/TriaP1InputEnum.m	(revision 11527)
@@ -0,0 +1,11 @@
+function macro=TriaP1InputEnum()
+%TRIAP1INPUTENUM - Enum of TriaP1Input
+%
+%   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:
+%      macro=TriaP1InputEnum()
+
+macro=StringToEnum('TriaP1Input');
Index: sm/trunk/src/m/enum/TriaVertexElementResultEnum.m
===================================================================
--- /issm/trunk/src/m/enum/TriaVertexElementResultEnum.m	(revision 11526)
+++ 	(revision )
@@ -1,11 +1,0 @@
-function macro=TriaVertexElementResultEnum()
-%TRIAVERTEXELEMENTRESULTENUM - Enum of TriaVertexElementResult
-%
-%   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:
-%      macro=TriaVertexElementResultEnum()
-
-macro=StringToEnum('TriaVertexElementResult');
Index: sm/trunk/src/m/enum/TriaVertexInputEnum.m
===================================================================
--- /issm/trunk/src/m/enum/TriaVertexInputEnum.m	(revision 11526)
+++ 	(revision )
@@ -1,11 +1,0 @@
-function macro=TriaVertexInputEnum()
-%TRIAVERTEXINPUTENUM - Enum of TriaVertexInput
-%
-%   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:
-%      macro=TriaVertexInputEnum()
-
-macro=StringToEnum('TriaVertexInput');
Index: /issm/trunk/src/m/kml/Makefile.am
===================================================================
--- /issm/trunk/src/m/kml/Makefile.am	(revision 11527)
+++ /issm/trunk/src/m/kml/Makefile.am	(revision 11527)
@@ -0,0 +1,1 @@
+bin_SCRIPTS=*.m 
Index: /issm/trunk/src/m/model/Makefile.am
===================================================================
--- /issm/trunk/src/m/model/Makefile.am	(revision 11527)
+++ /issm/trunk/src/m/model/Makefile.am	(revision 11527)
@@ -0,0 +1,2 @@
+SUBDIRS = plot mesh display parameterization partition solvers
+bin_SCRIPTS=*.m  
Index: /issm/trunk/src/m/model/collapse.m
===================================================================
--- /issm/trunk/src/m/model/collapse.m	(revision 11526)
+++ /issm/trunk/src/m/model/collapse.m	(revision 11527)
@@ -29,4 +29,7 @@
 if ~isnan(md.inversion.vy_obs), md.inversion.vy_obs=project2d(md,md.inversion.vy_obs,md.mesh.numberoflayers); end;
 if ~isnan(md.inversion.vel_obs), md.inversion.vel_obs=project2d(md,md.inversion.vel_obs,md.mesh.numberoflayers); end;
+if ~isnan(md.inversion.cost_functions_coefficients), md.inversion.cost_functions_coefficients=project2d(md,md.inversion.cost_functions_coefficients,md.mesh.numberoflayers); end;
+if ~isnan(md.inversion.min_parameters), md.inversion.min_parameters=project2d(md,md.inversion.min_parameters,md.mesh.numberoflayers); end;
+if ~isnan(md.inversion.max_parameters), md.inversion.max_parameters=project2d(md,md.inversion.max_parameters,md.mesh.numberoflayers); end;
 if ~isnan(md.surfaceforcings.mass_balance),
 	md.surfaceforcings.mass_balance=project2d(md,md.surfaceforcings.mass_balance,md.mesh.numberoflayers); 
@@ -49,4 +52,8 @@
 if ~isnan(md.flowequation.element_equation)
 	md.flowequation.element_equation=project2d(md,md.flowequation.element_equation,1);
+	md.flowequation.vertex_equation=project2d(md,md.flowequation.vertex_equation,1);
+	md.flowequation.bordermacayeal=project2d(md,md.flowequation.bordermacayeal,1);
+	md.flowequation.borderpattyn=project2d(md,md.flowequation.borderpattyn,1);
+	md.flowequation.borderstokes=project2d(md,md.flowequation.borderstokes,1);
 end	
 
@@ -55,4 +62,5 @@
 md.diagnostic.spcvy=project2d(md,md.diagnostic.spcvy,md.mesh.numberoflayers);
 md.diagnostic.spcvz=project2d(md,md.diagnostic.spcvz,md.mesh.numberoflayers);
+md.diagnostic.referential=project2d(md,md.diagnostic.referential,md.mesh.numberoflayers);
 md.prognostic.spcthickness=project2d(md,md.prognostic.spcthickness,md.mesh.numberoflayers);
 md.thermal.spctemperature=project2d(md,md.thermal.spctemperature,md.mesh.numberoflayers);
@@ -60,5 +68,5 @@
 %Extrusion of Neumann BC
 if ~isnan(md.diagnostic.icefront),
-	numberofneumann2d=size(md.diagnostic.icefront,1)/md.mesh.numberoflayers;
+	numberofneumann2d=size(md.diagnostic.icefront,1)/(md.mesh.numberoflayers-1);
 	md.diagnostic.icefront=[md.diagnostic.icefront(1:numberofneumann2d,1:2) md.diagnostic.icefront(1:numberofneumann2d,5:6)]; %Add two columns on the first layer 
 end
@@ -88,4 +96,6 @@
 md.mask.elementongroundedice=project2d(md,md.mask.elementongroundedice,1);
 md.mask.vertexongroundedice=project2d(md,md.mask.vertexongroundedice,1);
+md.mask.elementonwater=project2d(md,md.mask.elementonwater,1);
+md.mask.vertexonwater=project2d(md,md.mask.vertexonwater,1);
 
 %Initialize with the 2d mesh
Index: /issm/trunk/src/m/model/display/Makefile.am
===================================================================
--- /issm/trunk/src/m/model/display/Makefile.am	(revision 11527)
+++ /issm/trunk/src/m/model/display/Makefile.am	(revision 11527)
@@ -0,0 +1,1 @@
+bin_SCRIPTS=*.m 
Index: /issm/trunk/src/m/model/extrude.m
===================================================================
--- /issm/trunk/src/m/model/extrude.m	(revision 11526)
+++ /issm/trunk/src/m/model/extrude.m	(revision 11527)
@@ -137,6 +137,5 @@
 md.inversion.vel_obs=project3d(md,'vector',md.inversion.vel_obs,'type','node');
 md.surfaceforcings.mass_balance=project3d(md,'vector',md.surfaceforcings.mass_balance,'type','node');
-md.surfaceforcings.accumulation_rate=project3d(md,'vector',md.surfaceforcings.accumulation_rate,'type','node');
-md.surfaceforcings.ablation_rate=project3d(md,'vector',md.surfaceforcings.ablation_rate,'type','node');
+md.surfaceforcings.precipitation=project3d(md,'vector',md.surfaceforcings.precipitation,'type','node');
 md.balancethickness.thickening_rate=project3d(md,'vector',md.balancethickness.thickening_rate,'type','node');
 
@@ -194,5 +193,5 @@
 for i=2:numlayers-1,
 	md.mesh.elementconnectivity((i-1)*md.mesh.numberofelements2d+1:(i)*md.mesh.numberofelements2d,:)...
-	=md.mesh.elementconnectivity((i-1)*md.mesh.numberofelements2d+1:(i)*md.mesh.numberofelements2d,:)+md.mesh.numberofelements2d;
+		=md.mesh.elementconnectivity((i-1)*md.mesh.numberofelements2d+1:(i)*md.mesh.numberofelements2d,:)+md.mesh.numberofelements2d;
 end
 md.mesh.elementconnectivity(find(isnan(md.mesh.elementconnectivity)))=0;
@@ -216,6 +215,7 @@
 md.mask.vertexonwater=project3d(md,'vector',md.mask.vertexonwater,'type','node');
 if ~isnan(md.inversion.cost_functions_coefficients),md.inversion.cost_functions_coefficients=project3d(md,'vector',md.inversion.cost_functions_coefficients,'type','node');end;
-
-%Put lithostatic pressure is there is an existing pressure
+if ~isnan(md.qmu.partition),md.qmu.partition=project3d(md,'vector',md.qmu.partition','type','node');end
+
+%Put lithostatic pressure if there is an existing pressure
 if ~isnan(md.initialization.pressure),
 	md.initialization.pressure=md.constants.g*md.materials.rho_ice*(md.geometry.surface-md.mesh.z);
Index: /issm/trunk/src/m/model/loadresultsfromcluster.m
===================================================================
--- /issm/trunk/src/m/model/loadresultsfromcluster.m	(revision 11526)
+++ /issm/trunk/src/m/model/loadresultsfromcluster.m	(revision 11527)
@@ -30,5 +30,7 @@
 	delete([md.miscellaneous.name '.errlog']);
 	delete([md.miscellaneous.name '.outbin']);
-	delete([md.private.runtimename '.tar.gz']);
+	if ~ispc,
+		delete([md.private.runtimename '.tar.gz']);
+	end
 end
 
@@ -41,6 +43,10 @@
 	else
 		delete([md.miscellaneous.name '.bin']);
-		delete([md.miscellaneous.name '.queue']);
 		delete([md.miscellaneous.name '.petsc']);
+		if ~ispc,
+			delete([md.miscellaneous.name '.queue']);
+		else
+			delete([md.miscellaneous.name '.bat']);
+		end
 	end
 end
Index: /issm/trunk/src/m/model/loadresultsfromdisk.m
===================================================================
--- /issm/trunk/src/m/model/loadresultsfromdisk.m	(revision 11526)
+++ /issm/trunk/src/m/model/loadresultsfromdisk.m	(revision 11527)
@@ -13,4 +13,9 @@
 if ~md.qmu.isdakota,
 
+	%Check that file exists
+	if ~exist(filename,'file'),
+		error(['binary file ' filename ' not found.']);
+	end
+
 	%initialize md.results if not a structure yet
 	if ~isstruct(md.results),
@@ -20,4 +25,7 @@
 	%load results onto model
 	structure=parseresultsfromdisk(filename,~md.settings.io_gather);
+	if isempty(fieldnames(structure)),
+		error(['No result found in binary file ' filename '. Check for solution crash.']);
+	end
 	md.results.(structure(1).SolutionType)=structure;
 
Index: /issm/trunk/src/m/model/mesh/Makefile.am
===================================================================
--- /issm/trunk/src/m/model/mesh/Makefile.am	(revision 11527)
+++ /issm/trunk/src/m/model/mesh/Makefile.am	(revision 11527)
@@ -0,0 +1,1 @@
+bin_SCRIPTS=*.m 
Index: /issm/trunk/src/m/model/parameterization/Makefile.am
===================================================================
--- /issm/trunk/src/m/model/parameterization/Makefile.am	(revision 11527)
+++ /issm/trunk/src/m/model/parameterization/Makefile.am	(revision 11527)
@@ -0,0 +1,1 @@
+bin_SCRIPTS=*.m 
Index: /issm/trunk/src/m/model/partition/Makefile.am
===================================================================
--- /issm/trunk/src/m/model/partition/Makefile.am	(revision 11527)
+++ /issm/trunk/src/m/model/partition/Makefile.am	(revision 11527)
@@ -0,0 +1,1 @@
+bin_SCRIPTS=*.m 
Index: /issm/trunk/src/m/model/partition/partitioner.m
===================================================================
--- /issm/trunk/src/m/model/partition/partitioner.m	(revision 11526)
+++ /issm/trunk/src/m/model/partition/partitioner.m	(revision 11527)
@@ -99,4 +99,6 @@
 %extrude if we are in 3D:
 if md.mesh.dimension==3,
+	md3d.qmu.vertex_weight=md.qmu.vertex_weight;
+	md3d.qmu.adjacency=md.qmu.adjacency;
 	md=md3d;
 	part=project3d(md,'vector',part','type','node');
Index: /issm/trunk/src/m/model/plot/Makefile.am
===================================================================
--- /issm/trunk/src/m/model/plot/Makefile.am	(revision 11527)
+++ /issm/trunk/src/m/model/plot/Makefile.am	(revision 11527)
@@ -0,0 +1,1 @@
+bin_SCRIPTS=*.m 
Index: /issm/trunk/src/m/model/plot/plot_BC.m
===================================================================
--- /issm/trunk/src/m/model/plot/plot_BC.m	(revision 11526)
+++ /issm/trunk/src/m/model/plot/plot_BC.m	(revision 11527)
@@ -2,5 +2,5 @@
 
 %plot neuman
-plot_pressureload(md,options,width,i,data)
+plot_icefront(md,options,width,i,data)
 
 hold on
@@ -35,2 +35,7 @@
 
 hold off
+
+%apply options
+options=addfielddefault(options,'title','Boundary conditions');
+options=addfielddefault(options,'colorbar',0);
+applyoptions(md,[],options);
Index: /issm/trunk/src/m/model/plot/plot_icefront.m
===================================================================
--- /issm/trunk/src/m/model/plot/plot_icefront.m	(revision 11527)
+++ /issm/trunk/src/m/model/plot/plot_icefront.m	(revision 11527)
@@ -0,0 +1,106 @@
+function plot_icefront(md,options,width,i,data);
+%PLOT_ICEFRONT - plot segment on neumann BC
+%
+%   Usage:
+%      plot_icefront(md,options,width,i);
+%
+%   See also: PLOTMODEL
+
+%plot mesh boundaries
+subplot(width,width,i); 
+
+%process mesh and data
+[x y z elements is2d isplanet]=processmesh(md,[],options);
+icefront=md.diagnostic.icefront;
+
+if (md.mesh.dimension==2),
+
+	%plot mesh
+	A=elements(:,1); B=elements(:,2); C=elements(:,3); 
+	h1=patch( 'Faces', [A B C], 'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','none','EdgeColor','black');
+	hold on;
+
+	%highlight elements on neumann
+	pos=find(icefront(:,end)==1);
+	pos=icefront(pos,end-1);
+	A=elements(pos,1); B=elements(pos,2); C=elements(pos,3); 
+	h2=patch( 'Faces', [A B C], 'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','blue','EdgeColor','black');
+	pos=find(icefront(:,end)==0);
+	pos=icefront(pos,end-1);
+	A=elements(pos,1); B=elements(pos,2); C=elements(pos,3); 
+	h3=patch( 'Faces', [A B C], 'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','green','EdgeColor','black');
+
+	pos=find(icefront(:,end)==2);
+	pos=icefront(pos,end-1);
+	A=elements(pos,1); B=elements(pos,2); C=elements(pos,3); 
+	h3bis=patch( 'Faces', [A B C], 'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','cyan','EdgeColor','black');
+
+	%display arrows pointing outward
+	xstart=mean(x(icefront(:,1:end-2)),2);
+	ystart=mean(y(icefront(:,1:end-2)),2);
+	length=sqrt((x(icefront(:,1))-x(icefront(:,2))).^2 + (y(icefront(:,1))-y(icefront(:,2))).^2 );
+	normal(:,1)=cos(atan2((x(icefront(:,1))-x(icefront(:,2))) , (y(icefront(:,2))-y(icefront(:,1)))));
+	normal(:,2)=sin(atan2((x(icefront(:,1))-x(icefront(:,2))) , (y(icefront(:,2))-y(icefront(:,1)))));
+	xend=xstart+length.*normal(:,1);
+	yend=ystart+length.*normal(:,2);
+	q=quiver(xstart,ystart,xend-xstart,yend-ystart); hold on;
+	h4=plot(xstart,ystart,'r*');
+else
+
+	%plot mesh
+	A=elements(:,1); B=elements(:,2); C=elements(:,3); D=elements(:,4); E=elements(:,5); F=elements(:,6);
+	h1=patch( 'Faces', [A B C],'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','none','EdgeColor','black');
+	patch( 'Faces', [D E F],  'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','none','EdgeColor','black');
+	patch( 'Faces', [A B E D],'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','none','EdgeColor','black');
+	patch( 'Faces', [B E F C],'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','none','EdgeColor','black');
+	patch( 'Faces', [C A D F],'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','none','EdgeColor','black');
+	hold on;
+
+	%highlight elements on neumann
+	pos=find(icefront(:,end)==1);
+	pos=icefront(pos,end-1);
+	A=elements(pos,1); B=elements(pos,2); C=elements(pos,3); D=elements(pos,4); E=elements(pos,5); F=elements(pos,6);
+	h2=patch( 'Faces', [A B C],'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','blue','EdgeColor','black');
+	patch( 'Faces', [D E F],  'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','blue','EdgeColor','black');
+	patch( 'Faces', [A B E D],'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','blue','EdgeColor','black');
+	patch( 'Faces', [B E F C],'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','blue','EdgeColor','black');
+	patch( 'Faces', [C A D F],'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','blue','EdgeColor','black');
+	pos=find(icefront(:,end)==0);
+	pos=icefront(pos,end-1);
+	A=elements(pos,1); B=elements(pos,2); C=elements(pos,3); D=elements(pos,4); E=elements(pos,5); F=elements(pos,6);
+	h3=patch( 'Faces', [A B C],'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','green','EdgeColor','black');
+	patch( 'Faces', [D E F],  'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','green','EdgeColor','black');
+	patch( 'Faces', [A B E D],'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','green','EdgeColor','black');
+	patch( 'Faces', [B E F C],'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','green','EdgeColor','black');
+	patch( 'Faces', [C A D F],'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','green','EdgeColor','black');
+	pos=find(icefront(:,end)==2);
+	pos=icefront(pos,end-1);
+	A=elements(pos,1); B=elements(pos,2); C=elements(pos,3); D=elements(pos,4); E=elements(pos,5); F=elements(pos,6);
+	h3bis=patch( 'Faces', [A B C],'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','cyan','EdgeColor','black');
+	patch( 'Faces', [D E F],  'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','cyan','EdgeColor','black');
+	patch( 'Faces', [A B E D],'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','cyan','EdgeColor','black');
+	patch( 'Faces', [B E F C],'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','cyan','EdgeColor','black');
+	patch( 'Faces', [C A D F],'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','cyan','EdgeColor','black');
+
+	%display arrows pointing outward
+	xstart=mean(x(icefront(:,1:end-2)),2);
+	ystart=mean(y(icefront(:,1:end-2)),2);
+	zstart=mean(z(icefront(:,1:end-2)),2);
+	length=sqrt((x(icefront(:,1))-x(icefront(:,2))).^2 + (y(icefront(:,1))-y(icefront(:,2))).^2 );
+	normal(:,1)=cos(atan2((x(icefront(:,1))-x(icefront(:,2))) , (y(icefront(:,2))-y(icefront(:,1)))));
+	normal(:,2)=sin(atan2((x(icefront(:,1))-x(icefront(:,2))) , (y(icefront(:,2))-y(icefront(:,1)))));
+	xend=xstart+length.*normal(:,1);
+	yend=ystart+length.*normal(:,2);
+	q=quiver3(xstart,ystart,zstart,xend-xstart,yend-ystart,zeros(numel(xstart),1)); hold on;
+	h4=plot3(xstart,ystart,zstart,'r*');
+end
+
+%legend (disable warnings)
+warning off
+legend([h2,h3,h3bis,q],'element on ice front (Water)','element on ice front (Air)','element on ice front (Ice)','normal vectors')
+warning on
+
+%apply options
+options=addfielddefault(options,'title','Neumann boundary conditions');
+options=addfielddefault(options,'colorbar',0);
+applyoptions(md,[],options);
Index: /issm/trunk/src/m/model/plot/plot_manager.m
===================================================================
--- /issm/trunk/src/m/model/plot/plot_manager.m	(revision 11526)
+++ /issm/trunk/src/m/model/plot/plot_manager.m	(revision 11527)
@@ -112,6 +112,6 @@
 			plot_sarpwr(md,options,subplotwidth,i)
 			return
-		case 'pressureload'
-			plot_pressureload(md,options,subplotwidth,i,data)
+		case 'icefront'
+			plot_icefront(md,options,subplotwidth,i,data)
 			return
 		case 'segments'
Index: sm/trunk/src/m/model/plot/plot_pressureload.m
===================================================================
--- /issm/trunk/src/m/model/plot/plot_pressureload.m	(revision 11526)
+++ 	(revision )
@@ -1,106 +1,0 @@
-function plot_pressureload(md,options,width,i,data);
-%PLOT_PRESSURELOAD - plot segment on neumann BC
-%
-%   Usage:
-%      plot_pressureload(md,options,width,i);
-%
-%   See also: PLOTMODEL
-
-%plot mesh boundaries
-subplot(width,width,i); 
-
-%process mesh and data
-[x y z elements is2d isplanet]=processmesh(md,[],options);
-pressureload=md.diagnostic.icefront;
-
-if (md.mesh.dimension==2),
-
-	%plot mesh
-	A=elements(:,1); B=elements(:,2); C=elements(:,3); 
-	h1=patch( 'Faces', [A B C], 'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','none','EdgeColor','black');
-	hold on;
-
-	%highlight elements on neumann
-	pos=find(pressureload(:,end)==1);
-	pos=pressureload(pos,end-1);
-	A=elements(pos,1); B=elements(pos,2); C=elements(pos,3); 
-	h2=patch( 'Faces', [A B C], 'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','blue','EdgeColor','black');
-	pos=find(pressureload(:,end)==0);
-	pos=pressureload(pos,end-1);
-	A=elements(pos,1); B=elements(pos,2); C=elements(pos,3); 
-	h3=patch( 'Faces', [A B C], 'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','green','EdgeColor','black');
-
-	pos=find(pressureload(:,end)==2);
-	pos=pressureload(pos,end-1);
-	A=elements(pos,1); B=elements(pos,2); C=elements(pos,3); 
-	h3bis=patch( 'Faces', [A B C], 'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','cyan','EdgeColor','black');
-
-	%display arrows pointing outward
-	xstart=mean(x(pressureload(:,1:end-2)),2);
-	ystart=mean(y(pressureload(:,1:end-2)),2);
-	length=sqrt((x(pressureload(:,1))-x(pressureload(:,2))).^2 + (y(pressureload(:,1))-y(pressureload(:,2))).^2 );
-	normal(:,1)=cos(atan2((x(pressureload(:,1))-x(pressureload(:,2))) , (y(pressureload(:,2))-y(pressureload(:,1)))));
-	normal(:,2)=sin(atan2((x(pressureload(:,1))-x(pressureload(:,2))) , (y(pressureload(:,2))-y(pressureload(:,1)))));
-	xend=xstart+length.*normal(:,1);
-	yend=ystart+length.*normal(:,2);
-	q=quiver(xstart,ystart,xend-xstart,yend-ystart); hold on;
-	h4=plot(xstart,ystart,'r*');
-else
-
-	%plot mesh
-	A=elements(:,1); B=elements(:,2); C=elements(:,3); D=elements(:,4); E=elements(:,5); F=elements(:,6);
-	h1=patch( 'Faces', [A B C],'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','none','EdgeColor','black');
-	patch( 'Faces', [D E F],  'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','none','EdgeColor','black');
-	patch( 'Faces', [A B E D],'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','none','EdgeColor','black');
-	patch( 'Faces', [B E F C],'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','none','EdgeColor','black');
-	patch( 'Faces', [C A D F],'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','none','EdgeColor','black');
-	hold on;
-
-	%highlight elements on neumann
-	pos=find(pressureload(:,end)==1);
-	pos=pressureload(pos,end-1);
-	A=elements(pos,1); B=elements(pos,2); C=elements(pos,3); D=elements(pos,4); E=elements(pos,5); F=elements(pos,6);
-	h2=patch( 'Faces', [A B C],'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','blue','EdgeColor','black');
-	patch( 'Faces', [D E F],  'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','blue','EdgeColor','black');
-	patch( 'Faces', [A B E D],'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','blue','EdgeColor','black');
-	patch( 'Faces', [B E F C],'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','blue','EdgeColor','black');
-	patch( 'Faces', [C A D F],'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','blue','EdgeColor','black');
-	pos=find(pressureload(:,end)==0);
-	pos=pressureload(pos,end-1);
-	A=elements(pos,1); B=elements(pos,2); C=elements(pos,3); D=elements(pos,4); E=elements(pos,5); F=elements(pos,6);
-	h3=patch( 'Faces', [A B C],'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','green','EdgeColor','black');
-	patch( 'Faces', [D E F],  'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','green','EdgeColor','black');
-	patch( 'Faces', [A B E D],'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','green','EdgeColor','black');
-	patch( 'Faces', [B E F C],'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','green','EdgeColor','black');
-	patch( 'Faces', [C A D F],'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','green','EdgeColor','black');
-	pos=find(pressureload(:,end)==2);
-	pos=pressureload(pos,end-1);
-	A=elements(pos,1); B=elements(pos,2); C=elements(pos,3); D=elements(pos,4); E=elements(pos,5); F=elements(pos,6);
-	h3bis=patch( 'Faces', [A B C],'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','cyan','EdgeColor','black');
-	patch( 'Faces', [D E F],  'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','cyan','EdgeColor','black');
-	patch( 'Faces', [A B E D],'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','cyan','EdgeColor','black');
-	patch( 'Faces', [B E F C],'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','cyan','EdgeColor','black');
-	patch( 'Faces', [C A D F],'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','cyan','EdgeColor','black');
-
-	%display arrows pointing outward
-	xstart=mean(x(pressureload(:,1:end-2)),2);
-	ystart=mean(y(pressureload(:,1:end-2)),2);
-	zstart=mean(z(pressureload(:,1:end-2)),2);
-	length=sqrt((x(pressureload(:,1))-x(pressureload(:,2))).^2 + (y(pressureload(:,1))-y(pressureload(:,2))).^2 );
-	normal(:,1)=cos(atan2((x(pressureload(:,1))-x(pressureload(:,2))) , (y(pressureload(:,2))-y(pressureload(:,1)))));
-	normal(:,2)=sin(atan2((x(pressureload(:,1))-x(pressureload(:,2))) , (y(pressureload(:,2))-y(pressureload(:,1)))));
-	xend=xstart+length.*normal(:,1);
-	yend=ystart+length.*normal(:,2);
-	q=quiver3(xstart,ystart,zstart,xend-xstart,yend-ystart,zeros(numel(xstart),1)); hold on;
-	h4=plot3(xstart,ystart,zstart,'r*');
-end
-
-%legend (disable warnings)
-warning off
-legend([h2,h3,h3bis,q],'element on ice front (Water)','element on ice front (Air)','element on ice front (Ice)','normal vectors')
-warning on
-
-%apply options
-options=addfielddefault(options,'title','Neumann boundary conditions');
-options=addfielddefault(options,'colorbar',0);
-applyoptions(md,[],options);
Index: /issm/trunk/src/m/model/plot/plot_riftrelvel.m
===================================================================
--- /issm/trunk/src/m/model/plot/plot_riftrelvel.m	(revision 11526)
+++ /issm/trunk/src/m/model/plot/plot_riftrelvel.m	(revision 11527)
@@ -23,5 +23,5 @@
 u=NaN*ones(md.mesh.numberofvertices,1);
 v=NaN*ones(md.mesh.numberofvertices,1);
-for i=1:md.rifts.numrifts,
+for i=1:size(md.rifts.riftstruct,1),
 	penaltypairs=md.rifts.riftstruct(i).penaltypairs(:,[1 2]);
 	u(md.rifts.riftstruct(i).penaltypairs(:,1))=vx(penaltypairs(:,1))-vx(penaltypairs(:,2));
@@ -62,5 +62,5 @@
 	h1=plot(x(md.mesh.segments(i,1:2)),y(md.mesh.segments(i,1:2)),'b-');
 end
-for i=1:md.rifts.numrifts,
+for i=1:size(md.rifts.riftstruct,1),
 	
 	%get nodes on rift
Index: /issm/trunk/src/m/model/plot/plot_rifts.m
===================================================================
--- /issm/trunk/src/m/model/plot/plot_rifts.m	(revision 11526)
+++ /issm/trunk/src/m/model/plot/plot_rifts.m	(revision 11527)
@@ -17,5 +17,5 @@
 if isstruct(md.rifts.riftstruct),
 	
-	for i=1:md.rifts.numrifts,
+	for i=1:size(md.rifts.riftstruct,1),
 		penaltypairs=md.rifts.riftstruct(i).penaltypairs;
 
Index: /issm/trunk/src/m/model/plot/plot_riftvel.m
===================================================================
--- /issm/trunk/src/m/model/plot/plot_riftvel.m	(revision 11526)
+++ /issm/trunk/src/m/model/plot/plot_riftvel.m	(revision 11527)
@@ -19,5 +19,5 @@
 u=NaN*ones(md.mesh.numberofvertices,1);
 v=NaN*ones(md.mesh.numberofvertices,1);
-for i=1:md.rifts.numrifts,
+for i=1:size(md.rifts.riftstruct,1),
 	penaltypairs=md.rifts.riftstruct(i).penaltypairs(:,[1 2]);
 	u(penaltypairs(:))=md.initialization.vx(penaltypairs(:));
Index: /issm/trunk/src/m/model/plot/plotdoc.m
===================================================================
--- /issm/trunk/src/m/model/plot/plotdoc.m	(revision 11526)
+++ /issm/trunk/src/m/model/plot/plotdoc.m	(revision 11527)
@@ -15,4 +15,5 @@
 disp('                  - ''basal_dragx'' or ''basal_dragy'' : plot a component of the basal drag on the bed (in kPa)');
 disp('                  - ''boundaries'': this will draw all the segment boundaries to the model, including rifts.');
+disp('                  - ''icefront'': this will show segments that are used to define the icefront of the model (Neumann boundary conditions).');
 disp('                  - ''BC'': this will draw all the boundary conditions (Dirichlet and Neumann).');
 disp('                  - ''deviatoricstress_tensor'': plot the components of the deviatoric stress tensor (tauxx,tauyy,tauzz,tauxy,tauxz,tauyz) if computed');
Index: /issm/trunk/src/m/model/radarpower.m
===================================================================
--- /issm/trunk/src/m/model/radarpower.m	(revision 11526)
+++ /issm/trunk/src/m/model/radarpower.m	(revision 11527)
@@ -11,5 +11,5 @@
 
 %If gdal does not work, uncomment the following line
-setenv('LD_LIBRARY_PATH','/proj/ice/larour/issm/trunk/externalpackages/gdal/install/lib/');
+%setenv('LD_LIBRARY_PATH','/proj/ice/larour/issm/trunk/externalpackages/gdal/install/lib/');
 %Parse inputs
 if nargin==1,
Index: /issm/trunk/src/m/model/solveparallel.m
===================================================================
--- /issm/trunk/src/m/model/solveparallel.m	(revision 11526)
+++ /issm/trunk/src/m/model/solveparallel.m	(revision 11527)
@@ -14,5 +14,5 @@
 	%First, build a runtime name that is unique, that we will use to create 
 	%directories, name jobs, etc ...
-	c=clock; md.private.runtimename=sprintf('%s-%i-%i-%i-%i-%i-%i-%i',md.miscellaneous.name,c(2),c(3),c(1),c(4),c(5),floor(c(6)),feature('GetPid'));
+	c=clock; md.private.runtimename=sprintf('%s-%02i-%02i-%04i-%02i-%02i-%02i-%i',md.miscellaneous.name,c(2),c(3),c(1),c(4),c(5),floor(c(6)),feature('GetPid'));
 
 	if verLessThan('matlab', '7.6')
Index: /issm/trunk/src/m/model/solvers/Makefile.am
===================================================================
--- /issm/trunk/src/m/model/solvers/Makefile.am	(revision 11527)
+++ /issm/trunk/src/m/model/solvers/Makefile.am	(revision 11527)
@@ -0,0 +1,1 @@
+bin_SCRIPTS=*.m 
Index: /issm/trunk/src/m/model/tres.m
===================================================================
--- /issm/trunk/src/m/model/tres.m	(revision 11526)
+++ /issm/trunk/src/m/model/tres.m	(revision 11527)
@@ -10,27 +10,15 @@
 if strcmpi(string,'diagnostic'),
 	if md.mesh.dimension==2,
-		if isfield(md.results.DiagnosticSolution,'VxAverage'),
-			md.initialization.vx=PatchToVec(md.results.DiagnosticSolution.VxAverage);
-		else
-			md.initialization.vx=PatchToVec(md.results.DiagnosticSolution.Vx);
-		end
-		if isfield(md.results.DiagnosticSolution,'VyAverage'),
-			md.initialization.vy=PatchToVec(md.results.DiagnosticSolution.VyAverage);
-		else
-			md.initialization.vy=PatchToVec(md.results.DiagnosticSolution.Vy);
-		end
+		md.initialization.vx=md.results.DiagnosticSolution.Vx;
+		md.initialization.vy=md.results.DiagnosticSolution.Vy;
 	else 
-		md.initialization.vx=PatchToVec(md.results.DiagnosticSolution.Vx);
-		md.initialization.vy=PatchToVec(md.results.DiagnosticSolution.Vy);
-		if isfield(md.results.DiagnosticSolution,'Vz'),
-			md.initialization.vz=PatchToVec(md.results.DiagnosticSolution.Vz);
-		else
-			md.initialization.vz=zeros(md.mesh.numberofvertices,1);
-		end
+		md.initialization.vx=md.results.DiagnosticSolution.Vx;
+		md.initialization.vy=md.results.DiagnosticSolution.Vy;
+		md.initialization.vz=md.results.DiagnosticSolution.Vz;
 	end
-	md.initialization.vel=PatchToVec(md.results.DiagnosticSolution.Vel);
+	md.initialization.vel=md.results.DiagnosticSolution.Vel;
 
 	if isfield(md.results.DiagnosticSolution,'Pressure'),
-		md.initialization.pressure=PatchToVec(md.results.DiagnosticSolution.Pressure);
+		md.initialization.pressure=md.results.DiagnosticSolution.Pressure;
 	end
 	if md.rifts.numrifts,
@@ -42,5 +30,5 @@
 		for control_parameters=md.inversion.control_parameters
 			%Will need to be updated... good luck ;)
-			md.(EnumToModelField(control_parameters))=PatchToVec(md.results.DiagnosticSolution.(EnumToString(control_parameters)));
+			md.(EnumToModelField(control_parameters))=md.results.DiagnosticSolution.(EnumToString(control_parameters));
 		end
 	end
@@ -59,10 +47,10 @@
 	for i=1:length(results),
 		if ~isempty(md.results.TransientSolution(i).Vel),
-			results2(count).Vel=PatchToVec(md.results.TransientSolution(i).Vel);
-			results2(count).Surface=PatchToVec(md.results.TransientSolution(i).Surface);
-			results2(count).Thickness=PatchToVec(md.results.TransientSolution(i).Thickness);
-			results2(count).Bed=PatchToVec(md.results.TransientSolution(i).Bed);
-			results2(count).Vx=PatchToVec(md.results.TransientSolution(i).Vx);
-			results2(count).Vy=PatchToVec(md.results.TransientSolution(i).Vy);
+			results2(count).Vel=md.results.TransientSolution(i).Vel;
+			results2(count).Surface=md.results.TransientSolution(i).Surface;
+			results2(count).Thickness=md.results.TransientSolution(i).Thickness;
+			results2(count).Bed=md.results.TransientSolution(i).Bed;
+			results2(count).Vx=md.results.TransientSolution(i).Vx;
+			results2(count).Vy=md.results.TransientSolution(i).Vy;
 			results2(count).time=md.results.TransientSolution(i).time;
 			results2(count).step=md.results.TransientSolution(i).step;
@@ -76,26 +64,26 @@
 	clear results,results2;
 elseif strcmpi(string,'steadystate'),
-	md.initialization.vx=PatchToVec(md.results.SteadystateSolution.Vx);
-	md.initialization.vy=PatchToVec(md.results.SteadystateSolution.Vy);
+	md.initialization.vx=md.results.SteadystateSolution.Vx;
+	md.initialization.vy=md.results.SteadystateSolution.Vy;
 	if isfield(md.results.SteadystateSolution,'Vz'),
-		md.initialization.vz=PatchToVec(md.results.SteadystateSolution.Vz);
+		md.initialization.vz=md.results.SteadystateSolution.Vz;
 	end
 
-	md.initialization.vel=PatchToVec(md.results.SteadystateSolution.Vel);
-	md.initialization.pressure=PatchToVec(md.results.SteadystateSolution.Pressure);
-	md.initialization.temperature=PatchToVec(md.results.SteadystateSolution.Temperature);
-	md.basalforcings.melting_rate=PatchToVec(md.results.SteadystateSolution.BasalforcingsMeltingRate);
+	md.initialization.vel=md.results.SteadystateSolution.Vel;
+	md.initialization.pressure=md.results.SteadystateSolution.Pressure;
+	md.initialization.temperature=md.results.SteadystateSolution.Temperature;
+	md.basalforcings.melting_rate=md.results.SteadystateSolution.BasalforcingsMeltingRate;
 
 	if md.inversion.iscontrol==1,
 		for control_parameters=md.inversion.control_parameters
-			md.(EnumToModelField(control_parameters))=PatchToVec(md.results.SteadystateSolution.(EnumToString(control_parameters)));
+			md.(EnumToModelField(control_parameters))=md.results.SteadystateSolution.(EnumToString(control_parameters));
 		end
 	end
 
 elseif strcmpi(string,'thermal'),
-	md.initialization.temperature=PatchToVec(md.results.ThermalSolution.Temperature);
-	md.basalforcings.melting_rate=PatchToVec(md.results.ThermalSolution.BasalMeltingRate);
+	md.initialization.temperature=md.results.ThermalSolution.Temperature;
+	md.basalforcings.melting_rate=md.results.ThermalSolution.BasalMeltingRate;
 elseif strcmpi(string,'hydrology'),
-	md.initialization.watercolumn=PatchToVec(md.results.HydrologySolution.Watercolumn);
+	md.initialization.watercolumn=md.results.HydrologySolution.Watercolumn;
 
 else 
Index: /issm/trunk/src/m/planet/Makefile.am
===================================================================
--- /issm/trunk/src/m/planet/Makefile.am	(revision 11527)
+++ /issm/trunk/src/m/planet/Makefile.am	(revision 11527)
@@ -0,0 +1,1 @@
+bin_SCRIPTS=*.m 
Index: /issm/trunk/src/m/qmu/Makefile.am
===================================================================
--- /issm/trunk/src/m/qmu/Makefile.am	(revision 11527)
+++ /issm/trunk/src/m/qmu/Makefile.am	(revision 11527)
@@ -0,0 +1,1 @@
+bin_SCRIPTS=*.m 
Index: /issm/trunk/src/m/qmu/expandresponses.m
===================================================================
--- /issm/trunk/src/m/qmu/expandresponses.m	(revision 11526)
+++ /issm/trunk/src/m/qmu/expandresponses.m	(revision 11527)
@@ -1,3 +1,4 @@
 function dresp=expandresponses(md,responses)
+%EXPANDRESPONSES - expand responses
 
 fnames=fieldnames(responses);
Index: /issm/trunk/src/m/shared/Makefile.am
===================================================================
--- /issm/trunk/src/m/shared/Makefile.am	(revision 11527)
+++ /issm/trunk/src/m/shared/Makefile.am	(revision 11527)
@@ -0,0 +1,1 @@
+bin_SCRIPTS=*.m 
Index: /issm/trunk/src/m/solutions/AnalysisConfiguration.m
===================================================================
--- /issm/trunk/src/m/solutions/AnalysisConfiguration.m	(revision 11526)
+++ /issm/trunk/src/m/solutions/AnalysisConfiguration.m	(revision 11527)
@@ -42,6 +42,6 @@
 
 	case TransientSolutionEnum,
-		numanalyses=8; 
-		analyses=[DiagnosticHorizAnalysisEnum;DiagnosticVertAnalysisEnum;DiagnosticHutterAnalysisEnum;SurfaceSlopeAnalysisEnum;BedSlopeAnalysisEnum;ThermalAnalysisEnum;MeltingAnalysisEnum;PrognosticAnalysisEnum];
+		numanalyses=9; 
+		analyses=[DiagnosticHorizAnalysisEnum;DiagnosticVertAnalysisEnum;DiagnosticHutterAnalysisEnum;SurfaceSlopeAnalysisEnum;BedSlopeAnalysisEnum;ThermalAnalysisEnum;MeltingAnalysisEnum;EnthalpyAnalysisEnum;PrognosticAnalysisEnum];
 
 	case FlaimSolutionEnum,
Index: /issm/trunk/src/m/solutions/Makefile.am
===================================================================
--- /issm/trunk/src/m/solutions/Makefile.am	(revision 11527)
+++ /issm/trunk/src/m/solutions/Makefile.am	(revision 11527)
@@ -0,0 +1,1 @@
+bin_SCRIPTS=*.m 
Index: /issm/trunk/src/m/solutions/control_core.m
===================================================================
--- /issm/trunk/src/m/solutions/control_core.m	(revision 11526)
+++ /issm/trunk/src/m/solutions/control_core.m	(revision 11527)
@@ -25,5 +25,5 @@
 	%Initialize misfits with a vector of zeros
 	J=zeros(nsteps,1);
-	search_scalar=0;
+	search_scalar=1;
 
 	%Get core from solution type
@@ -42,5 +42,5 @@
 		femmodel.parameters.StepResponses=responses(n,:);
 
-		%In case we are running a steady state control method, compute new temperature field using new parameter distribution: 
+		%In steady state inversion, compute new temperature field now
 		if (solution_type==SteadystateSolutionEnum)
 			femmodel=steadystate_core(femmodel);
@@ -50,5 +50,5 @@
 		eval(['femmodel=' adjointcore '(femmodel);']);
 
-		femmodel=gradient_core(femmodel,n,search_scalar);
+		femmodel=gradient_core(femmodel,n-1,search_scalar==0);
 
 		%Return gradient if asked
@@ -83,5 +83,4 @@
 	end
 	femmodel.results=AddExternalResult(femmodel.results,JEnum,J);
-	%femmodel.results=AddExternalResult(femmodel.results,InversionControlParametersEnum,control_type);
 
 end %end function
Index: /issm/trunk/src/m/solutions/diagnostic_core.m
===================================================================
--- /issm/trunk/src/m/solutions/diagnostic_core.m	(revision 11526)
+++ /issm/trunk/src/m/solutions/diagnostic_core.m	(revision 11527)
@@ -15,4 +15,5 @@
 	ismacayealpattyn=femmodel.parameters.FlowequationIsmacayealpattyn;
 	isstokes=femmodel.parameters.FlowequationIsstokes;
+	isnewton=femmodel.parameters.DiagnosticIsnewton;
 	dakota_analysis=femmodel.parameters.QmuIsdakota;
 	control_analysis=femmodel.parameters.InversionIscontrol;
@@ -53,5 +54,9 @@
 		issmprintf(VerboseSolution,'\n%s',['   computing horizontal velocities']);
 		femmodel=SetCurrentConfiguration(femmodel,DiagnosticHorizAnalysisEnum);
-		femmodel=solver_nonlinear(femmodel,modify_loads); 
+		if isnewton,
+			femmodel=solver_newton(femmodel); 
+		else
+			femmodel=solver_nonlinear(femmodel,modify_loads); 
+		end
 	end
 	
Index: /issm/trunk/src/m/solutions/enthalpy_core.m
===================================================================
--- /issm/trunk/src/m/solutions/enthalpy_core.m	(revision 11526)
+++ /issm/trunk/src/m/solutions/enthalpy_core.m	(revision 11527)
@@ -4,5 +4,4 @@
 %   Usage:
 %      femmodel=enthalpy_core(femmodel)
-
 
 	%recover parameters common to all solutions
@@ -25,7 +24,5 @@
 		time=(i+1)*dt;
 
-		issmprintf(VerboseSolution,'\n%s',['   computing enthalpy']);
-		femmodel=SetCurrentConfiguration(femmodel,EnthalpyAnalysisEnum);
-		femmodel=solver_linear(femmodel);
+		femmodel=enthalpy_core_step(femmodel,i,time); 
 
 		if (solution_type==EnthalpySolutionEnum & ~control_analysis),
@@ -33,5 +30,5 @@
 			femmodel.elements=InputToResult(femmodel.elements,femmodel.nodes,femmodel.vertices,femmodel.loads,femmodel.materials,femmodel.parameters,EnthalpyEnum,i,time);
 			femmodel.elements=InputToResult(femmodel.elements,femmodel.nodes,femmodel.vertices,femmodel.loads,femmodel.materials,femmodel.parameters,TemperatureEnum,i,time);
-			femmodel.elements=InputToResult(femmodel.elements,femmodel.nodes,femmodel.vertices,femmodel.loads,femmodel.materials,femmodel.parameters,WaterFractionEnum,i,time);
+			femmodel.elements=InputToResult(femmodel.elements,femmodel.nodes,femmodel.vertices,femmodel.loads,femmodel.materials,femmodel.parameters,WaterfractionEnum,i,time);
 		end
 	end
Index: /issm/trunk/src/m/solutions/enthalpy_core_step.m
===================================================================
--- /issm/trunk/src/m/solutions/enthalpy_core_step.m	(revision 11527)
+++ /issm/trunk/src/m/solutions/enthalpy_core_step.m	(revision 11527)
@@ -0,0 +1,14 @@
+function femmodel=enthalpy_core_step(femmodel,step,time)
+%ENTHALPY_CORE_STEP - core of the enthalpy solution for one step 
+%
+%   Usage:
+%      femmodel=enthalpy_core_step(femmodel,step,time)
+
+	%some parameters
+	modify_loads=true;
+
+	issmprintf(VerboseSolution,'\n%s',['   computing enthalpy']);
+	femmodel=SetCurrentConfiguration(femmodel,EnthalpyAnalysisEnum);
+	femmodel=solver_nonlinear(femmodel,modify_loads);
+
+end %end function
Index: /issm/trunk/src/m/solutions/gradient_core.m
===================================================================
--- /issm/trunk/src/m/solutions/gradient_core.m	(revision 11526)
+++ /issm/trunk/src/m/solutions/gradient_core.m	(revision 11527)
@@ -11,8 +11,8 @@
 if nargin==3,
 	step=varargin{1};
-	search_scalar=varargin{2};
+	orthogonalize=varargin{2};
 elseif nargin==1
 	step=0;
-	search_scalar=0;;
+	orthogonalize=false;
 else
 	help gradient_core
@@ -20,40 +20,23 @@
 end
 
-	%recover parameters common to all solutions
-	num_controls=femmodel.parameters.InversionNumControlParameters;
-	control_type=femmodel.parameters.InversionControlParameters;
-	control_steady=femmodel.parameters.ControlSteady;
-	gradient_scaling_list=femmodel.parameters.InversionGradientScaling;
+issmprintf(VerboseControl,['   compute cost function gradient']);
+[grad norm_list]=Gradj(femmodel.elements,femmodel.nodes,femmodel.vertices,femmodel.loads,femmodel.materials,femmodel.parameters);
 
-	for i=1:num_controls,
+if orthogonalize,
+	issmprintf(VerboseControl,'%s',['   orthogonalization']);
+	old_gradient=ControlInputGetGradient(femmodel.elements,femmodel.nodes, femmodel.vertices,femmodel.loads, femmodel.materials,femmodel.parameters);
+	new_gradient=Orth(grad,old_gradient);
+else
+	new_gradient=grad;
+end
 
-		issmprintf(VerboseControl,['   compute gradient of J with respect to %s'],EnumToString(control_type(i)));
-		grad=Gradj(femmodel.elements,femmodel.nodes,femmodel.vertices,femmodel.loads,femmodel.materials,femmodel.parameters,control_type(i));
+%Check that gradient is clean
+norm_grad=norm(new_gradient,inf);
+if(norm_grad<=0),     error(['||∂J/∂α||∞ = 0   gradient norm is zero']); end
+if(isnan(norm_grad)), error(['||∂J/∂α||∞ = NaN gradient norm is NaN' ]); end
 
-		if control_steady,
-			femmodel=diagnostic_core(femmodel);
-		end
+%plug back into inputs:
+[femmodel.elements,femmodel.nodes,femmodel.vertices,femmodel.loads,femmodel.materials,femmodel.parameters]=ControlInputSetGradient(femmodel.elements,femmodel.nodes, femmodel.vertices,femmodel.loads, femmodel.materials,  femmodel.parameters,new_gradient);
 
-		if (step>1 && search_scalar==0),
-			issmprintf(VerboseControl,'%s',['   orthogonalization']);
-			old_gradient=ControlInputGetGradient(femmodel.elements,femmodel.nodes, femmodel.vertices,femmodel.loads, femmodel.materials,femmodel.parameters,control_type(i));
-			new_gradient=Orth(grad,old_gradient);
-		else
-			issmprintf(VerboseControl,'%s',['   normalizing direction']);
-			new_gradient=Orth(grad,[]);
-		end
-
-		 %Get scaling factor of current control:
-		 norm_grad=norm(new_gradient,inf);
-		 if(norm_grad<=0),     error(['||∂J/∂α||∞ = 0   gradient norm of J with respect to ' EnumToString(control_type(i))  ' is zero']); end
-		 if(isnan(norm_grad)), error(['||∂J/∂α||∞ = NaN gradient norm of J with respect to ' EnumToString(control_type(i))  ' is NaN' ]); end
-		 if(i==1 | (gradient_scaling_list(step,i)/norm_grad)<gradient_scaling) gradient_scaling=gradient_scaling_list(step,i)/norm_grad; end
-
-		%plug back into inputs:
-		[femmodel.elements,femmodel.nodes,femmodel.vertices,femmodel.loads,femmodel.materials,femmodel.parameters]=ControlInputSetGradient(femmodel.elements,femmodel.nodes, femmodel.vertices,femmodel.loads, femmodel.materials,  femmodel.parameters,control_type(i),new_gradient);
-	end
-
-	%Scale all gradients
-	for i=1:num_controls,
-		[femmodel.elements,femmodel.nodes,femmodel.vertices,femmodel.loads,femmodel.materials,femmodel.parameters]=ControlInputScaleGradient(femmodel.elements,femmodel.nodes, femmodel.vertices,femmodel.loads, femmodel.materials,  femmodel.parameters,control_type(i),gradient_scaling);
-	end
+%Scale all gradients
+[femmodel.elements,femmodel.nodes,femmodel.vertices,femmodel.loads,femmodel.materials,femmodel.parameters]=ControlInputScaleGradient(femmodel.elements,femmodel.nodes, femmodel.vertices,femmodel.loads, femmodel.materials,  femmodel.parameters,norm_list,step);
Index: /issm/trunk/src/m/solutions/transient_core.m
===================================================================
--- /issm/trunk/src/m/solutions/transient_core.m	(revision 11526)
+++ /issm/trunk/src/m/solutions/transient_core.m	(revision 11527)
@@ -19,4 +19,5 @@
 	isthermal=femmodel.parameters.TransientIsthermal;
 	isgroundingline=femmodel.parameters.TransientIsgroundingline;
+	isenthalpy=femmodel.parameters.ThermalIsenthalpy;
 	groundinglinemigration=femmodel.parameters.GroundinglineMigration;
 
@@ -57,5 +58,9 @@
 		if (isthermal & dim==3)
 			issmprintf(VerboseSolution,'\n%s',['   computing temperature']);
-			femmodel=thermal_core_step(femmodel); 
+			if (isenthalpy==0),
+				femmodel=thermal_core_step(femmodel); 
+			else
+				femmodel=enthalpy_core_step(femmodel); 
+			end
 		end
 
@@ -90,4 +95,6 @@
 			femmodel.elements=InputToResult(femmodel.elements,femmodel.nodes,femmodel.vertices,femmodel.loads,femmodel.materials,femmodel.parameters,BedEnum,step,time);
 			if (dim==3 & isthermal), femmodel.elements=InputToResult(femmodel.elements,femmodel.nodes,femmodel.vertices,femmodel.loads,femmodel.materials,femmodel.parameters,TemperatureEnum,step,time);end
+			if (dim==3 & isenthalpy), femmodel.elements=InputToResult(femmodel.elements,femmodel.nodes,femmodel.vertices,femmodel.loads,femmodel.materials,femmodel.parameters,WaterfractionEnum,step,time);end
+			if (dim==3 & isenthalpy), femmodel.elements=InputToResult(femmodel.elements,femmodel.nodes,femmodel.vertices,femmodel.loads,femmodel.materials,femmodel.parameters,EnthalpyEnum,step,time);end
 			femmodel.elements=InputToResult(femmodel.elements,femmodel.nodes,femmodel.vertices,femmodel.loads,femmodel.materials,femmodel.parameters,BasalforcingsMeltingRateEnum,step,time);
 			femmodel.elements=InputToResult(femmodel.elements,femmodel.nodes,femmodel.vertices,femmodel.loads,femmodel.materials,femmodel.parameters,SurfaceforcingsMassBalanceEnum,step,time);
Index: /issm/trunk/src/m/solvers/Makefile.am
===================================================================
--- /issm/trunk/src/m/solvers/Makefile.am	(revision 11527)
+++ /issm/trunk/src/m/solvers/Makefile.am	(revision 11527)
@@ -0,0 +1,1 @@
+bin_SCRIPTS=*.m 
Index: /issm/trunk/src/m/solvers/solver_newton.m
===================================================================
--- /issm/trunk/src/m/solvers/solver_newton.m	(revision 11527)
+++ /issm/trunk/src/m/solvers/solver_newton.m	(revision 11527)
@@ -0,0 +1,60 @@
+function femmodel=solver_newton(femmodel)
+%SOLVER_NEWTON - core solver of diagnostic run
+%
+%   Usage:
+%      [femmodel]=solver_newton(femmodel)
+
+	%Branch on partitioning schema requested
+	maxiter=femmodel.parameters.DiagnosticMaxiter;
+	configuration_type=femmodel.parameters.ConfigurationType;
+	[femmodel.nodes]=UpdateConstraints(femmodel.nodes,femmodel.constraints,femmodel.parameters);
+
+	%initialize solution vector
+	converged=0; count=1;
+
+	%Start non-linear iteration using input velocity: 
+	ug=GetSolutionFromInputs(femmodel.elements, femmodel.nodes, femmodel.vertices, femmodel.loads, femmodel.materials, femmodel.parameters);
+	uf=Reducevectorgtof( ug, femmodel.nodes,femmodel.parameters);
+
+	%Update the solution to make sure that vx and vxold are similar
+	[femmodel.elements femmodel.loads]=InputUpdateFromConstant(femmodel.elements,femmodel.nodes,femmodel.vertices,femmodel.loads,femmodel.materials,femmodel.parameters,double(converged),ConvergedEnum);
+	[femmodel.elements,femmodel.materials]=InputUpdateFromSolution(femmodel.elements,femmodel.nodes,femmodel.vertices,femmodel.loads,femmodel.materials,femmodel.parameters,ug);
+
+	while(~converged),
+
+		%save pointer to old velocity
+		old_ug=ug;
+		old_uf=uf;
+
+		%Solver forward model
+		[K_ff,K_fs,p_f,df,kmax]=SystemMatrices(femmodel.elements,femmodel.nodes,femmodel.vertices,femmodel.loads,femmodel.materials,femmodel.parameters);
+		ys=CreateNodalConstraints(femmodel.nodes,configuration_type);
+		p_f=Reduceload( p_f, K_fs, ys);
+		issmprintf(VerboseSolver(),'%s%g','      condition number of stiffness matrix: ',condest(K_ff));
+		uf=Solver(K_ff,p_f,old_uf,df,femmodel.parameters);
+		ug=Mergesolutionfromftog( uf, ys, femmodel.nodes,femmodel.parameters); 
+		[femmodel.elements,femmodel.materials]=InputUpdateFromSolution(femmodel.elements,femmodel.nodes,femmodel.vertices,femmodel.loads,femmodel.materials,femmodel.parameters,ug);
+
+		%Check convergence
+		converged=convergence(K_ff,p_f,uf,old_uf,femmodel.parameters);
+		if(converged==1) break; end
+		if(count>maxiter),
+			issmprintf(true,'%s%i%s','      maximum number of iterations ',maxiter,' exceeded');
+			break;
+		end
+
+		%Prepare next iteration using Newton's method
+		[K_ff,K_fs,p_f,df,kmax]=SystemMatrices(femmodel.elements,femmodel.nodes,femmodel.vertices,femmodel.loads,femmodel.materials,femmodel.parameters);
+		ys=CreateNodalConstraints(femmodel.nodes,configuration_type);
+		p_f=Reduceload( p_f, K_fs, ys);
+		pJf=p_f-K_ff*uf;
+		Jff=CreateJacobianMatrix(femmodel.elements,femmodel.nodes,femmodel.vertices,femmodel.loads,femmodel.materials,femmodel.parameters,kmax);
+		duf=Solver(Jff,pJf,[],[],femmodel.parameters);
+		uf=uf+duf;
+		ug=Mergesolutionfromftog(uf,ys,femmodel.nodes,femmodel.parameters); 
+		[femmodel.elements,femmodel.materials]=InputUpdateFromSolution(femmodel.elements,femmodel.nodes,femmodel.vertices,femmodel.loads,femmodel.materials,femmodel.parameters,ug);
+
+		%increase count
+		count=count+1;
+	end
+end
Index: /issm/trunk/src/m/solvers/solver_nonlinear.m
===================================================================
--- /issm/trunk/src/m/solvers/solver_nonlinear.m	(revision 11526)
+++ /issm/trunk/src/m/solvers/solver_nonlinear.m	(revision 11527)
@@ -22,4 +22,5 @@
 
 	%Update the solution to make sure that vx and vxold are similar
+	[femmodel.elements loads]=InputUpdateFromConstant(femmodel.elements,femmodel.nodes,femmodel.vertices,loads,femmodel.materials,femmodel.parameters,double(converged),ConvergedEnum);
 	[femmodel.elements,femmodel.materials]=InputUpdateFromSolution(femmodel.elements,femmodel.nodes,femmodel.vertices,loads,femmodel.materials,femmodel.parameters,ug);
 
@@ -38,9 +39,4 @@
 		ug= Mergesolutionfromftog( uf, ys, femmodel.nodes,femmodel.parameters); 
 
-		[femmodel.elements,femmodel.materials]=InputUpdateFromSolution(femmodel.elements,femmodel.nodes,femmodel.vertices,loads,femmodel.materials,femmodel.parameters,ug);
-		[loads,constraints_converged,num_unstable_constraints] =ConstraintsState( femmodel.elements,femmodel.nodes,femmodel.vertices,loads, femmodel.materials,femmodel.parameters);
-
-		issmprintf(VerboseConvergence(),'%s%i','      number of unstable constraints: ',num_unstable_constraints);
-
 		%Figure out if convergence have been reached
 		converged=convergence(K_ff,p_f,uf,old_uf,femmodel.parameters);
@@ -48,4 +44,9 @@
 		%add convergence status into  status
 		[femmodel.elements loads]=InputUpdateFromConstant(femmodel.elements,femmodel.nodes,femmodel.vertices,loads,femmodel.materials,femmodel.parameters,double(converged),ConvergedEnum);
+
+		[femmodel.elements,femmodel.materials]=InputUpdateFromSolution(femmodel.elements,femmodel.nodes,femmodel.vertices,loads,femmodel.materials,femmodel.parameters,ug);
+		[loads,constraints_converged,num_unstable_constraints] =ConstraintsState( femmodel.elements,femmodel.nodes,femmodel.vertices,loads, femmodel.materials,femmodel.parameters);
+
+		issmprintf(VerboseConvergence(),'%s%i','      number of unstable constraints: ',num_unstable_constraints);
 
 		%rift convergence
Index: /issm/trunk/src/m/utils/Analysis/Makefile.am
===================================================================
--- /issm/trunk/src/m/utils/Analysis/Makefile.am	(revision 11527)
+++ /issm/trunk/src/m/utils/Analysis/Makefile.am	(revision 11527)
@@ -0,0 +1,1 @@
+bin_SCRIPTS=*.m 
Index: /issm/trunk/src/m/utils/Array/Makefile.am
===================================================================
--- /issm/trunk/src/m/utils/Array/Makefile.am	(revision 11527)
+++ /issm/trunk/src/m/utils/Array/Makefile.am	(revision 11527)
@@ -0,0 +1,1 @@
+bin_SCRIPTS=*.m 
Index: /issm/trunk/src/m/utils/BC/Makefile.am
===================================================================
--- /issm/trunk/src/m/utils/BC/Makefile.am	(revision 11527)
+++ /issm/trunk/src/m/utils/BC/Makefile.am	(revision 11527)
@@ -0,0 +1,1 @@
+bin_SCRIPTS=*.m 
Index: /issm/trunk/src/m/utils/BC/SetIceSheetBC.m
===================================================================
--- /issm/trunk/src/m/utils/BC/SetIceSheetBC.m	(revision 11526)
+++ /issm/trunk/src/m/utils/BC/SetIceSheetBC.m	(revision 11527)
@@ -34,11 +34,7 @@
 
 %Create zeros basal melting rate and surface mass balance if not specified
-if isnan(md.surfaceforcings.accumulation_rate),
-	md.surfaceforcings.accumulation_rate=zeros(md.mesh.numberofvertices,1);
-	disp('      no surfaceforcings.accumulation_rate specified: values set as zero');
-end
-if isnan(md.surfaceforcings.ablation_rate),
-	md.surfaceforcings.ablation_rate=zeros(md.mesh.numberofvertices,1);
-	disp('      no surfaceforcings.ablation_rate specified: values set as zero');
+if isnan(md.surfaceforcings.precipitation),
+	md.surfaceforcings.precipitation=zeros(md.mesh.numberofvertices,1);
+	disp('      no surfaceforcings.precipitation specified: values set as zero');
 end
 if isnan(md.surfaceforcings.mass_balance),
Index: /issm/trunk/src/m/utils/BC/SetIceShelfBC.m
===================================================================
--- /issm/trunk/src/m/utils/BC/SetIceShelfBC.m	(revision 11526)
+++ /issm/trunk/src/m/utils/BC/SetIceShelfBC.m	(revision 11527)
@@ -64,13 +64,8 @@
 md.diagnostic.icefront=pressureload;
 
-%Create zeros basalforcings.melting_rate, surfaceforcings.ablation_rate, surfaceforcings.accumulation_rate
-% and surfaceforcings.mass_balance if not specified
-if isnan(md.surfaceforcings.accumulation_rate),
-	md.surfaceforcings.accumulation_rate=zeros(md.mesh.numberofvertices,1);
-	disp('      no surfaceforcings.accumulation_rate specified: values set as zero');
-end
-if isnan(md.surfaceforcings.ablation_rate),
-	md.surfaceforcings.ablation_rate=zeros(md.mesh.numberofvertices,1);
-	disp('      no surfaceforcings.ablation_rate specified: values set as zero');
+%Create zeros basalforcings and surfaceforcings
+if isnan(md.surfaceforcings.precipitation),
+	md.surfaceforcings.precipitation=zeros(md.mesh.numberofvertices,1);
+	disp('      no surfaceforcings.precipitation specified: values set as zero');
 end
 if isnan(md.surfaceforcings.mass_balance),
Index: /issm/trunk/src/m/utils/BC/SetMarineIceSheetBC.m
===================================================================
--- /issm/trunk/src/m/utils/BC/SetMarineIceSheetBC.m	(revision 11526)
+++ /issm/trunk/src/m/utils/BC/SetMarineIceSheetBC.m	(revision 11527)
@@ -75,13 +75,8 @@
 
 
-%Create zeros basalforcings.melting_rate, surfaceforcings.ablation_rate, surfaceforcings.accumulation_rate
-% and surfaceforcings.mass_balance if not specified
-if isnan(md.surfaceforcings.accumulation_rate),
-	md.surfaceforcings.accumulation_rate=zeros(md.mesh.numberofvertices,1);
-	disp('      no surfaceforcings.accumulation_rate specified: values set as zero');
-end
-if isnan(md.surfaceforcings.ablation_rate),
-	md.surfaceforcings.ablation_rate=zeros(md.mesh.numberofvertices,1);
-	disp('      no surfaceforcings.ablation_rate specified: values set as zero');
+%Create zeros basalforcings and surfaceforcings
+if isnan(md.surfaceforcings.precipitation),
+	md.surfaceforcings.precipitation=zeros(md.mesh.numberofvertices,1);
+	disp('      no surfaceforcings.precipitation specified: values set as zero');
 end
 if isnan(md.surfaceforcings.mass_balance),
Index: /issm/trunk/src/m/utils/Basins/Makefile.am
===================================================================
--- /issm/trunk/src/m/utils/Basins/Makefile.am	(revision 11527)
+++ /issm/trunk/src/m/utils/Basins/Makefile.am	(revision 11527)
@@ -0,0 +1,1 @@
+bin_SCRIPTS=*.m 
Index: /issm/trunk/src/m/utils/Cluster/Makefile.am
===================================================================
--- /issm/trunk/src/m/utils/Cluster/Makefile.am	(revision 11527)
+++ /issm/trunk/src/m/utils/Cluster/Makefile.am	(revision 11527)
@@ -0,0 +1,1 @@
+bin_SCRIPTS=*.m 
Index: /issm/trunk/src/m/utils/DataProcessing/Makefile.am
===================================================================
--- /issm/trunk/src/m/utils/DataProcessing/Makefile.am	(revision 11527)
+++ /issm/trunk/src/m/utils/DataProcessing/Makefile.am	(revision 11527)
@@ -0,0 +1,1 @@
+bin_SCRIPTS=*.m 
Index: /issm/trunk/src/m/utils/Ecco3/Makefile.am
===================================================================
--- /issm/trunk/src/m/utils/Ecco3/Makefile.am	(revision 11527)
+++ /issm/trunk/src/m/utils/Ecco3/Makefile.am	(revision 11527)
@@ -0,0 +1,1 @@
+bin_SCRIPTS=*.m 
Index: /issm/trunk/src/m/utils/Exp/Makefile.am
===================================================================
--- /issm/trunk/src/m/utils/Exp/Makefile.am	(revision 11527)
+++ /issm/trunk/src/m/utils/Exp/Makefile.am	(revision 11527)
@@ -0,0 +1,1 @@
+bin_SCRIPTS=*.m 
Index: /issm/trunk/src/m/utils/Geometry/Makefile.am
===================================================================
--- /issm/trunk/src/m/utils/Geometry/Makefile.am	(revision 11527)
+++ /issm/trunk/src/m/utils/Geometry/Makefile.am	(revision 11527)
@@ -0,0 +1,1 @@
+bin_SCRIPTS=*.m 
Index: /issm/trunk/src/m/utils/ImageProcessing/Makefile.am
===================================================================
--- /issm/trunk/src/m/utils/ImageProcessing/Makefile.am	(revision 11527)
+++ /issm/trunk/src/m/utils/ImageProcessing/Makefile.am	(revision 11527)
@@ -0,0 +1,1 @@
+bin_SCRIPTS=*.m 
Index: /issm/trunk/src/m/utils/Interp/Makefile.am
===================================================================
--- /issm/trunk/src/m/utils/Interp/Makefile.am	(revision 11527)
+++ /issm/trunk/src/m/utils/Interp/Makefile.am	(revision 11527)
@@ -0,0 +1,1 @@
+bin_SCRIPTS=*.m 
Index: /issm/trunk/src/m/utils/Kml/Makefile.am
===================================================================
--- /issm/trunk/src/m/utils/Kml/Makefile.am	(revision 11527)
+++ /issm/trunk/src/m/utils/Kml/Makefile.am	(revision 11527)
@@ -0,0 +1,1 @@
+bin_SCRIPTS=*.m 
Index: /issm/trunk/src/m/utils/LatLong/Makefile.am
===================================================================
--- /issm/trunk/src/m/utils/LatLong/Makefile.am	(revision 11527)
+++ /issm/trunk/src/m/utils/LatLong/Makefile.am	(revision 11527)
@@ -0,0 +1,1 @@
+bin_SCRIPTS=*.m 
Index: /issm/trunk/src/m/utils/Makefile.am
===================================================================
--- /issm/trunk/src/m/utils/Makefile.am	(revision 11527)
+++ /issm/trunk/src/m/utils/Makefile.am	(revision 11527)
@@ -0,0 +1,2 @@
+SUBDIRS = Analysis Array BC Basins Cluster DataProcessing Ecco3 Exp Geometry ImageProcessing Interp Kml LatLong Math Meca Mesh Miscellaneous Model Numerics OS Plot Shell String consistency qmu
+bin_SCRIPTS=*.m 
Index: /issm/trunk/src/m/utils/Math/Makefile.am
===================================================================
--- /issm/trunk/src/m/utils/Math/Makefile.am	(revision 11527)
+++ /issm/trunk/src/m/utils/Math/Makefile.am	(revision 11527)
@@ -0,0 +1,1 @@
+bin_SCRIPTS=*.m 
Index: /issm/trunk/src/m/utils/Meca/Makefile.am
===================================================================
--- /issm/trunk/src/m/utils/Meca/Makefile.am	(revision 11527)
+++ /issm/trunk/src/m/utils/Meca/Makefile.am	(revision 11527)
@@ -0,0 +1,1 @@
+bin_SCRIPTS=*.m 
Index: sm/trunk/src/m/utils/Meca/effective_value.m
===================================================================
--- /issm/trunk/src/m/utils/Meca/effective_value.m	(revision 11526)
+++ 	(revision )
@@ -1,18 +1,0 @@
-function effective_value=effective_value(A)
-%EFFECTIVE_VALUE - compute the effective value of any matrix
-%
-%   effective(A)= 1/sqrt(2)*sqrt(sum(Aij^2))
-%
-%   Usage:
-%      effective_value=effective_value(A)
-
-[row,col]=size(A);
-
-SUM=0;
-for i=1:row
-    for j=1:col
-        SUM=SUM+A(i,j)^2;
-    end
-end
-
-effective_value=1/sqrt(2)*sqrt(SUM);
Index: sm/trunk/src/m/utils/Meca/glen_coefficients.m
===================================================================
--- /issm/trunk/src/m/utils/Meca/glen_coefficients.m	(revision 11526)
+++ 	(revision )
@@ -1,26 +1,0 @@
-function [A ,B]=glen_coefficients(Ao,T);
-%GLEN_COEFFICIENTS - compute A and B, given the temperature and Ao
-%
-%   Ao,T according to patterson,Ao in s-1kPa-3.
-%   values range between 3.9 and 5.3*10^-16;
-%   Return: A in s-1kPa-3. B in Pa.a1/3
-%
-%   Usage:
-%      [A ,B]=glen_coefficients(Ao,T)
-
-To=263;
-R=8.314;
-E1=139000;
-E2=60000;
-
-%For T>263,
-Ac1=Ao*exp(E1/R/To);
-%For T<263,
-Ac2=Ao*exp(E2/R/To);
-
-A=Ac1*exp(-E1/R./T);
-pos=find(T<263);
-A(pos)=Ac2*exp(-E2/R./T(pos));
-
-B=(A*365*24*3600).^(-1/3);
-
Index: /issm/trunk/src/m/utils/Mesh/Makefile.am
===================================================================
--- /issm/trunk/src/m/utils/Mesh/Makefile.am	(revision 11527)
+++ /issm/trunk/src/m/utils/Mesh/Makefile.am	(revision 11527)
@@ -0,0 +1,1 @@
+bin_SCRIPTS=*.m 
Index: /issm/trunk/src/m/utils/Miscellaneous/Makefile.am
===================================================================
--- /issm/trunk/src/m/utils/Miscellaneous/Makefile.am	(revision 11527)
+++ /issm/trunk/src/m/utils/Miscellaneous/Makefile.am	(revision 11527)
@@ -0,0 +1,1 @@
+bin_SCRIPTS=*.m 
Index: /issm/trunk/src/m/utils/Miscellaneous/issmdoc.m
===================================================================
--- /issm/trunk/src/m/utils/Miscellaneous/issmdoc.m	(revision 11527)
+++ /issm/trunk/src/m/utils/Miscellaneous/issmdoc.m	(revision 11527)
@@ -0,0 +1,15 @@
+%Quick documentation for ISSM
+
+%First get ISSM tier: 
+ISSM_TIER=issmtier;
+
+disp(sprintf('\n%s','  A comprehensive documentation is available on http://issm.jpl.nasa.gov'));
+disp(sprintf('\n%s','  Example: how to create a square ice shelf'));
+disp(sprintf('%s','	   go to ',ISSM_TIER,'/examples/SquareIceshelf'));
+disp(sprintf('%s','	   md=model;                                %creates a new empty model structure'));
+disp(sprintf('%s','	   md=triangle(md,''DomainOutline.exp'',50000);   %creates a mesh of the domain outline with a resolution of 50000m'));
+disp(sprintf('%s','	   md=geography(md,''all'','''');               %defines the glacier system as an ice shelf (no island)'));
+disp(sprintf('%s','	   md=parameterize(md,''Square.par'');        %fills all the other fields of the model'));
+disp(sprintf('%s','	   md=setelementstype(md,''macayeal'',''all''); %defines all elements as MacAyeal''s'));
+disp(sprintf('%s','	   md=solve(md,DiagnosticSolutionEnum);   %generate the velocity field'));
+disp(sprintf('%s','	   plotmodel(md,''data'',md.results.DiagnosticSolution.Vel);    %displays the velocity (type plotdoc for plotmodel help)'));
Index: /issm/trunk/src/m/utils/Model/Makefile.am
===================================================================
--- /issm/trunk/src/m/utils/Model/Makefile.am	(revision 11527)
+++ /issm/trunk/src/m/utils/Model/Makefile.am	(revision 11527)
@@ -0,0 +1,1 @@
+bin_SCRIPTS=*.m 
Index: /issm/trunk/src/m/utils/Numerics/Makefile.am
===================================================================
--- /issm/trunk/src/m/utils/Numerics/Makefile.am	(revision 11527)
+++ /issm/trunk/src/m/utils/Numerics/Makefile.am	(revision 11527)
@@ -0,0 +1,1 @@
+bin_SCRIPTS=*.m 
Index: /issm/trunk/src/m/utils/OS/Makefile.am
===================================================================
--- /issm/trunk/src/m/utils/OS/Makefile.am	(revision 11527)
+++ /issm/trunk/src/m/utils/OS/Makefile.am	(revision 11527)
@@ -0,0 +1,1 @@
+bin_SCRIPTS=*.m 
Index: /issm/trunk/src/m/utils/OS/ismumps.m
===================================================================
--- /issm/trunk/src/m/utils/OS/ismumps.m	(revision 11527)
+++ /issm/trunk/src/m/utils/OS/ismumps.m	(revision 11527)
@@ -0,0 +1,33 @@
+function flag=ismumps()
+%ISMUMPS - figure out if MUMPS package was compiled with ISSM
+%
+%   Usage:
+%       flag=ismumps();
+
+
+configfile=[issmtier() '/config.h'];
+if ~exist(configfile,'file'),
+	error(['File ' configfile ' not found. ISSM has not been configured yet!']);
+end
+
+%go through the file, and recover the line we want
+flag=2;
+fid=fopen(configfile,'r');
+if(fid==-1), error(['could not open file: ' configfile]); end
+
+while(true),
+	tline=fgets(fid);
+	if ~ischar(tline), break, end
+	if strncmp(tline,'/* #undef _HAVE_MUMPS_ */',25),
+		flag=0;
+		break;
+	end
+	if  strncmp(tline,'#define _HAVE_MUMPS_',20),
+		flag=1;
+		break;
+	end
+end
+fclose(fid);
+if flag==2,
+	error('could not determine whether MUMPS was or was not compiled');
+end
Index: /issm/trunk/src/m/utils/Plot/Makefile.am
===================================================================
--- /issm/trunk/src/m/utils/Plot/Makefile.am	(revision 11527)
+++ /issm/trunk/src/m/utils/Plot/Makefile.am	(revision 11527)
@@ -0,0 +1,1 @@
+bin_SCRIPTS=*.m 
Index: /issm/trunk/src/m/utils/Shell/Makefile.am
===================================================================
--- /issm/trunk/src/m/utils/Shell/Makefile.am	(revision 11527)
+++ /issm/trunk/src/m/utils/Shell/Makefile.am	(revision 11527)
@@ -0,0 +1,1 @@
+bin_SCRIPTS=*.m 
Index: /issm/trunk/src/m/utils/Shell/issmdir.m
===================================================================
--- /issm/trunk/src/m/utils/Shell/issmdir.m	(revision 11526)
+++ /issm/trunk/src/m/utils/Shell/issmdir.m	(revision 11527)
@@ -5,5 +5,9 @@
 %      ISSM_DIR=issmdir()
 
-ISSM_DIR =getenv('ISSM_DIR');
+if ~ispc,
+	ISSM_DIR =getenv('ISSM_DIR');
+else
+	ISSM_DIR =getenv('ISSM_DIR_WIN');
+end
 
 if (isempty(ISSM_DIR)),
Index: /issm/trunk/src/m/utils/Shell/issmtier.m
===================================================================
--- /issm/trunk/src/m/utils/Shell/issmtier.m	(revision 11526)
+++ /issm/trunk/src/m/utils/Shell/issmtier.m	(revision 11527)
@@ -5,5 +5,10 @@
 %      ISSM_TIER=issmtier()
 
-ISSM_TIER =getenv('ISSM_TIER');
+if ~ispc, 
+	ISSM_TIER =getenv('ISSM_TIER');
+else
+	ISSM_TIER =getenv('ISSM_TIER_WIN');
+	ISSM_TIER = ISSM_TIER(1:end-1); %shave off the last '/'
+end
 
 if (isempty(ISSM_TIER)),
Index: /issm/trunk/src/m/utils/String/Makefile.am
===================================================================
--- /issm/trunk/src/m/utils/String/Makefile.am	(revision 11527)
+++ /issm/trunk/src/m/utils/String/Makefile.am	(revision 11527)
@@ -0,0 +1,1 @@
+bin_SCRIPTS=*.m 
Index: /issm/trunk/src/m/utils/consistency/Makefile.am
===================================================================
--- /issm/trunk/src/m/utils/consistency/Makefile.am	(revision 11527)
+++ /issm/trunk/src/m/utils/consistency/Makefile.am	(revision 11527)
@@ -0,0 +1,1 @@
+bin_SCRIPTS=*.m 
Index: /issm/trunk/src/m/utils/consistency/checkfield.m
===================================================================
--- /issm/trunk/src/m/utils/consistency/checkfield.m	(revision 11526)
+++ /issm/trunk/src/m/utils/consistency/checkfield.m	(revision 11527)
@@ -10,4 +10,5 @@
 %      - <:  smallerthan provided value
 %      - <=: smaller or equal to provided value
+%      - < vec:  smallerthan provided values on each vertex
 %      - forcing: 1 if check forcing consistency (size and time)
 %      - values: cell of strings or vector of acceptable values
@@ -153,5 +154,5 @@
 	if any(field2>upperbound),
 		checkmessage(getfieldvalue(options,'message',...
-			['field ''' fieldname ''' should have values above ' num2str(upperbound)]));
+			['field ''' fieldname ''' should have values below ' num2str(upperbound)]));
 	end
 end
@@ -161,5 +162,5 @@
 	if any(field2>=upperbound),
 		checkmessage(getfieldvalue(options,'message',...
-			['field ''' fieldname ''' should have values above ' num2str(upperbound)]));
+			['field ''' fieldname ''' should have values below ' num2str(upperbound(1))]));
 	end
 end
Index: /issm/trunk/src/m/utils/qmu/Makefile.am
===================================================================
--- /issm/trunk/src/m/utils/qmu/Makefile.am	(revision 11527)
+++ /issm/trunk/src/m/utils/qmu/Makefile.am	(revision 11527)
@@ -0,0 +1,1 @@
+bin_SCRIPTS=*.m 
Index: /issm/trunk/src/mex/ControlInputGetGradient/ControlInputGetGradient.cpp
===================================================================
--- /issm/trunk/src/mex/ControlInputGetGradient/ControlInputGetGradient.cpp	(revision 11526)
+++ /issm/trunk/src/mex/ControlInputGetGradient/ControlInputGetGradient.cpp	(revision 11527)
@@ -14,5 +14,4 @@
 	Materials  *materials  = NULL;
 	Parameters *parameters = NULL;
-	int         control_type;
 	Vec         gradient   = NULL;
 
@@ -32,5 +31,4 @@
 	FetchMatlabData((DataSet**)&materials,MATERIALS);
 	FetchMatlabData(&parameters,PARAMETERS);
-	FetchMatlabData(&control_type,CONTROLTYPE);
 
 	/*configure: */
@@ -41,5 +39,5 @@
 
 	/*!core code:*/
-	ControlInputGetGradientx(&gradient,elements, nodes,vertices,loads, materials,parameters,control_type);
+	ControlInputGetGradientx(&gradient,elements, nodes,vertices,loads, materials,parameters);
 
 	/*write output datasets: */
@@ -61,5 +59,5 @@
 {
 	_printf_(true,"\n");
-	_printf_(true,"   usage: [gradient] = %s(elements,nodes,vertices,loads, materials,parameters,control_type);\n",__FUNCT__);
+	_printf_(true,"   usage: [gradient] = %s(elements,nodes,vertices,loads, materials,parameters);\n",__FUNCT__);
 	_printf_(true,"\n");
 }
Index: /issm/trunk/src/mex/ControlInputGetGradient/ControlInputGetGradient.h
===================================================================
--- /issm/trunk/src/mex/ControlInputGetGradient/ControlInputGetGradient.h	(revision 11526)
+++ /issm/trunk/src/mex/ControlInputGetGradient/ControlInputGetGradient.h	(revision 11527)
@@ -23,5 +23,4 @@
 #define MATERIALS (mxArray*)prhs[4]
 #define PARAMETERS (mxArray*)prhs[5]
-#define CONTROLTYPE (mxArray*)prhs[6]
 
 /* serial output macros: */
@@ -32,5 +31,5 @@
 #define NLHS  1
 #undef NRHS
-#define NRHS  7
+#define NRHS  6
 
 #endif
Index: /issm/trunk/src/mex/ControlInputScaleGradient/ControlInputScaleGradient.cpp
===================================================================
--- /issm/trunk/src/mex/ControlInputScaleGradient/ControlInputScaleGradient.cpp	(revision 11526)
+++ /issm/trunk/src/mex/ControlInputScaleGradient/ControlInputScaleGradient.cpp	(revision 11527)
@@ -8,4 +8,5 @@
 
 /*input datasets: */
+int       step;
 Elements   *elements   = NULL;
 Nodes      *nodes      = NULL;
@@ -14,6 +15,5 @@
 Materials  *materials  = NULL;
 Parameters *parameters = NULL;
-int         control_type;
-double      scaling_factor;
+double     *norm_list  = NULL;
 
 /*Boot module: */
@@ -30,6 +30,6 @@
 FetchMatlabData((DataSet**)&materials,MATERIALSIN);
 FetchMatlabData(&parameters,PARAMETERSIN);
-FetchMatlabData(&control_type,CONTROLTYPE);
-FetchMatlabData(&scaling_factor,SCALE);
+FetchMatlabData(&norm_list,NULL,NULL,NORMLIST);
+FetchMatlabData(&step,STEP);
 
 /*configure: */
@@ -39,5 +39,5 @@
 
 /*call "x" code layer*/
-ControlInputScaleGradientx(elements,nodes,vertices,loads, materials,parameters,control_type,scaling_factor);
+ControlInputScaleGradientx(elements,nodes,vertices,loads, materials,parameters,norm_list,step);
 
 /*write output datasets: */
@@ -64,5 +64,5 @@
 {
 	_printf_(true,"\n");
-	_printf_(true,"   usage: [elements,nodes,vertices,loads,materials,parameters] = %s(elements,nodes,vertices,loads,materials,control_type,scaling_factor);\n",__FUNCT__);
+	_printf_(true,"   usage: [elements,nodes,vertices,loads,materials,parameters] = %s(elements,nodes,vertices,loads,materials,norm_list,step);\n",__FUNCT__);
 	_printf_(true,"\n");
 }
Index: /issm/trunk/src/mex/ControlInputScaleGradient/ControlInputScaleGradient.h
===================================================================
--- /issm/trunk/src/mex/ControlInputScaleGradient/ControlInputScaleGradient.h	(revision 11526)
+++ /issm/trunk/src/mex/ControlInputScaleGradient/ControlInputScaleGradient.h	(revision 11527)
@@ -24,6 +24,6 @@
 #define MATERIALSIN (mxArray*)prhs[4]
 #define PARAMETERSIN (mxArray*)prhs[5]
-#define CONTROLTYPE (mxArray*)prhs[6]
-#define SCALE (mxArray*)prhs[7]
+#define NORMLIST (mxArray*)prhs[6]
+#define STEP (mxArray*)prhs[7]
 
 /* serial output macros: */
Index: /issm/trunk/src/mex/ControlInputSetGradient/ControlInputSetGradient.cpp
===================================================================
--- /issm/trunk/src/mex/ControlInputSetGradient/ControlInputSetGradient.cpp	(revision 11526)
+++ /issm/trunk/src/mex/ControlInputSetGradient/ControlInputSetGradient.cpp	(revision 11527)
@@ -14,5 +14,4 @@
 Materials  *materials  = NULL;
 Parameters *parameters = NULL;
-int         control_type;
 double     *gradient   = NULL;
 
@@ -30,5 +29,4 @@
 FetchMatlabData((DataSet**)&materials,MATERIALSIN);
 FetchMatlabData(&parameters,PARAMETERSIN);
-FetchMatlabData(&control_type,CONTROLTYPE);
 FetchMatlabData(&gradient,NULL,GRADIENT);
 
@@ -39,5 +37,5 @@
 
 /*call "x" code layer*/
-ControlInputSetGradientx(elements,nodes,vertices,loads, materials,parameters,control_type,gradient);
+ControlInputSetGradientx(elements,nodes,vertices,loads, materials,parameters,gradient);
 
 /*write output datasets: */
@@ -64,5 +62,5 @@
 {
 	_printf_(true,"\n");
-	_printf_(true,"   usage: [elements,nodes,vertices,loads,materials,parameters] = %s(elements,nodes,vertices,loads,materials,control_type,gradient);\n",__FUNCT__);
+	_printf_(true,"   usage: [elements,nodes,vertices,loads,materials,parameters] = %s(elements,nodes,vertices,loads,materials,gradient);\n",__FUNCT__);
 	_printf_(true,"\n");
 }
Index: /issm/trunk/src/mex/ControlInputSetGradient/ControlInputSetGradient.h
===================================================================
--- /issm/trunk/src/mex/ControlInputSetGradient/ControlInputSetGradient.h	(revision 11526)
+++ /issm/trunk/src/mex/ControlInputSetGradient/ControlInputSetGradient.h	(revision 11527)
@@ -24,6 +24,5 @@
 #define MATERIALSIN (mxArray*)prhs[4]
 #define PARAMETERSIN (mxArray*)prhs[5]
-#define CONTROLTYPE (mxArray*)prhs[6]
-#define GRADIENT (mxArray*)prhs[7]
+#define GRADIENT (mxArray*)prhs[6]
 
 /* serial output macros: */
@@ -39,5 +38,5 @@
 #define NLHS  6
 #undef NRHS
-#define NRHS  8
+#define NRHS  7
 
 #endif
Index: /issm/trunk/src/mex/CreateJacobianMatrix/CreateJacobianMatrix.cpp
===================================================================
--- /issm/trunk/src/mex/CreateJacobianMatrix/CreateJacobianMatrix.cpp	(revision 11527)
+++ /issm/trunk/src/mex/CreateJacobianMatrix/CreateJacobianMatrix.cpp	(revision 11527)
@@ -0,0 +1,66 @@
+/*\file CreateJacobianMatrix.c
+ *\brief: build system matrices (stiffness matrix, loads vector)
+ */
+
+#include "./CreateJacobianMatrix.h"
+
+void mexFunction( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]){
+
+	/*input datasets: */
+	Elements   *elements   = NULL;
+	Nodes      *nodes      = NULL;
+	Vertices   *vertices   = NULL;
+	Loads      *loads      = NULL;
+	Materials  *materials  = NULL;
+	Parameters *parameters = NULL;
+	double kmax;
+	
+	/* output datasets: */
+	Mat    Jff  = NULL;
+
+	/*Boot module: */
+	MODULEBOOT();
+
+	/*checks on arguments on the matlab side: */
+	CheckNumMatlabArguments(nlhs,NLHS,nrhs,NRHS,__FUNCT__,&CreateJacobianMatrixUsage);
+
+	/*Input datasets: */
+	FetchMatlabData((DataSet**)&elements,ELEMENTS);
+	FetchMatlabData((DataSet**)&nodes,NODES);
+	FetchMatlabData((DataSet**)&vertices,VERTICES);
+	FetchMatlabData((DataSet**)&loads,LOADS);
+	FetchMatlabData((DataSet**)&materials,MATERIALS);
+	FetchMatlabData(&parameters,PARAMETERS);
+	FetchMatlabData(&kmax,KMAX);
+
+	/*configure: */
+	elements->  Configure(elements,loads, nodes,vertices, materials,parameters);
+	nodes->     Configure(elements,loads, nodes,vertices, materials,parameters);
+	loads->     Configure(elements, loads, nodes,vertices, materials,parameters);
+	materials-> Configure(elements, loads, nodes,vertices, materials,parameters);
+
+	/*!Generate internal degree of freedom numbers: */
+	CreateJacobianMatrixx(&Jff,elements,nodes,vertices,loads,materials,parameters,kmax);
+
+	/*write output datasets: */
+	WriteMatlabData(JFF,Jff);
+	
+	/*Free ressources: */
+	delete elements;
+	delete nodes;
+	delete vertices;
+	delete loads;
+	delete materials;
+	delete parameters;
+	MatFree(&Jff);
+
+	/*end module: */
+	MODULEEND();
+}
+
+void CreateJacobianMatrixUsage(void)
+{
+	_printf_(true,"\n");
+	_printf_(true,"   usage: [Jff] = %s(elements,nodes,vertices,loads,materials,parameters,kmax);\n",__FUNCT__);
+	_printf_(true,"\n");
+}
Index: /issm/trunk/src/mex/CreateJacobianMatrix/CreateJacobianMatrix.h
===================================================================
--- /issm/trunk/src/mex/CreateJacobianMatrix/CreateJacobianMatrix.h	(revision 11527)
+++ /issm/trunk/src/mex/CreateJacobianMatrix/CreateJacobianMatrix.h	(revision 11527)
@@ -0,0 +1,37 @@
+/*
+	CreateJacobianMatrix.h
+*/
+
+#ifndef _CREATEJACOBIANMATRIX_H
+#define _CREATEJACOBIANMATRIX_H
+
+/* local prototypes: */
+void CreateJacobianMatrixUsage(void);
+
+#include "../../c/modules/modules.h"
+#include "../../c/Container/Container.h"
+#include "../../c/shared/shared.h"
+#include "../../c/EnumDefinitions/EnumDefinitions.h"
+
+#undef __FUNCT__ 
+#define __FUNCT__  "CreateJacobianMatrix"
+
+/* serial input macros: */
+#define ELEMENTS     (mxArray *)prhs[0]
+#define NODES        (mxArray *)prhs[1]
+#define VERTICES     (mxArray *)prhs[2]
+#define LOADS        (mxArray *)prhs[3]
+#define MATERIALS    (mxArray *)prhs[4]
+#define PARAMETERS   (mxArray *)prhs[5]
+#define KMAX         (mxArray *)prhs[6]
+
+/* serial output macros: */
+#define JFF  (mxArray**)&plhs[0]
+
+/* serial arg counts: */
+#undef NLHS
+#define NLHS  1
+#undef NRHS
+#define NRHS  7
+
+#endif  /* _CREATEJACOBIANMATRIX_H*/
Index: /issm/trunk/src/mex/Gradj/Gradj.cpp
===================================================================
--- /issm/trunk/src/mex/Gradj/Gradj.cpp	(revision 11526)
+++ /issm/trunk/src/mex/Gradj/Gradj.cpp	(revision 11527)
@@ -8,5 +8,6 @@
 
 	/*input datasets: */
-	int         control_type;
+	int         control_index,num_controls;
+	double     *norm_list    = NULL;
 	Elements   *elements     = NULL;
 	Nodes      *nodes        = NULL;
@@ -32,5 +33,5 @@
 	FetchMatlabData((DataSet**)&materials,MATERIALS);
 	FetchMatlabData(&parameters,PARAMETERS);
-	FetchMatlabData(&control_type,CONTROLTYPE);
+	parameters->FindParam(&num_controls,InversionNumControlParametersEnum); 
 
 	/*configure: */
@@ -40,7 +41,8 @@
 
 	/*!Call core code: */
-	Gradjx(&gradient, elements,nodes, vertices,loads, materials,parameters, control_type);
+	Gradjx(&gradient,&norm_list,elements,nodes, vertices,loads, materials,parameters);
 
 	/*write output : */
+	WriteMatlabData(NORMLIST,norm_list,num_controls,1);
 	WriteMatlabData(GRADG,gradient);
 
Index: /issm/trunk/src/mex/Gradj/Gradj.h
===================================================================
--- /issm/trunk/src/mex/Gradj/Gradj.h	(revision 11526)
+++ /issm/trunk/src/mex/Gradj/Gradj.h	(revision 11527)
@@ -24,14 +24,14 @@
 #define MATERIALS (mxArray*)prhs[4]
 #define PARAMETERS (mxArray*)prhs[5]
-#define CONTROLTYPE (mxArray*)prhs[6]
 
 /* serial output macros: */
 #define GRADG (mxArray**)&plhs[0]
+#define NORMLIST (mxArray**)&plhs[1]
 
 /* serial arg counts: */
 #undef NLHS
-#define NLHS  1
+#define NLHS  2
 #undef NRHS
-#define NRHS  7
+#define NRHS  6
 
 #endif  /* _GRADJ_H */
Index: /issm/trunk/src/mex/KMLFileRead/KMLFileRead.cpp
===================================================================
--- /issm/trunk/src/mex/KMLFileRead/KMLFileRead.cpp	(revision 11527)
+++ /issm/trunk/src/mex/KMLFileRead/KMLFileRead.cpp	(revision 11527)
@@ -0,0 +1,151 @@
+/*\file KMLFileRead.c
+ *\brief: KML file reader module.
+ */
+#include "./KMLFileRead.h"
+
+void mexFunction( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]){
+
+	int i,j,nnodes=0,verbose=1;
+	KML_Object* kobj;
+
+	/*input: */
+	char*   name=NULL;
+
+	char*   notes=NULL;
+	const mxArray* notesi;
+	mwIndex        nindex;
+
+	int*    elem=NULL;
+	int     melem=0,nelem=0;
+
+	int*    nodecon=NULL;
+	int     mncon=0,nncon=0;
+
+	double* lat=NULL;
+	int     mlat=0,nlat=0,llat=0;
+
+	double* lng=NULL;
+	int     mlng=0,nlng=0,llng=0;
+
+	int     nparts=0;
+
+	int*    part=NULL;
+	int     mprt=0,nprt=0,lprt=0;
+
+	double* data=NULL;
+	int     mdata=0,ndata=0;
+
+	double* cmap=NULL;
+	int     mcmap=0,ncmap=0;
+
+	char*   filnam=NULL;
+
+	FILE*   fidi=NULL;
+	FILE*   fido=NULL;
+
+	Options* options=NULL;
+	char*    echo    =NULL;
+	char*    deepecho=NULL;
+	char*    write   =NULL;
+
+	/* output: */
+	int     ierror=0;
+
+	/*Boot module: */
+	MODULEBOOT();
+
+	/*checks on arguments on the matlab side: */
+	if (nlhs > NLHS) {
+		KMLFileReadUsage();
+		_error_("KMLFileRead usage error");
+	}
+	if (nrhs < NRHS) {
+		KMLFileReadUsage();
+		_error_("KMLFileRead usage error");
+	}
+
+	/*Input datasets: */
+	if (verbose) printf("Fetching inputs:\n");
+	FetchMatlabData(&filnam,FILENAME);
+	if (verbose) printf("  filnam =\"%s\"\n",filnam);
+
+	if (verbose) printf("Parsing options:\n");
+	options=new Options(NRHS,nrhs,prhs);
+	if (options->Size()) for(i=0;i<options->Size();i++) ((Option*)options->GetObjectByOffset(i))->DeepEcho();
+	options->Get(&echo    ,"echo"    ,"off");
+	options->Get(&deepecho,"deepecho","off");
+	options->Get(&write   ,"write"   ,"off");
+
+	/*some checks*/
+	if (verbose) printf("Checking inputs:\n");
+
+	if (!strlen(filnam))
+		strcpy(filnam,"stdout");
+
+	if (verbose) printf("Opening file \"%s\".\n",filnam);
+	fidi=fopen(filnam,"r");
+
+	/* Run core computations: */
+	if (verbose) printf("Calling core:\n");
+	kobj=KMLFileReadx(fidi);
+
+	if (verbose) printf("Closing file \"%s\".\n",filnam);
+	fclose(fidi);
+
+	if (kobj) {
+		if (!strncmp(echo    ,"on",2) || !strncmp(echo    ,"y",1))
+			kobj->Echo();
+		if (!strncmp(deepecho,"on",2) || !strncmp(deepecho,"y",1))
+			kobj->DeepEcho();
+		if (strncmp(write,"off",3) && strncmp(write,"no",2)) {
+			if (!strncmp(write,"on",2) || !strncmp(write,"yes",3) || !strncmp(write,"stdout",6)) {
+				kobj->Write(stdout,"");
+			}
+			else {
+				if (verbose) printf("Opening file \"%s\".\n",write);
+				fido=fopen(write,"w");
+				kobj->Write(fido,"");
+				if (verbose) printf("Closing file \"%s\".\n",write);
+				ierror=fclose(fido);
+			}
+		}
+
+		delete kobj;
+	}
+
+	/*Write data: */
+	WriteMatlabData(ERRORFLAG,ierror);
+
+	/*Clean-up*/
+	xfree((void**)&write);
+	xfree((void**)&deepecho);
+	xfree((void**)&echo);
+	delete options;
+
+	/*end module: */
+	MODULEEND();
+}
+
+void KMLFileReadUsage(void)
+{
+	_printf_(true,"KMLFileRead - KML file reader module:\n");
+	_printf_(true,"\n");
+	_printf_(true,"   This module reads a KML file.\n");
+	_printf_(true,"\n");
+	_printf_(true,"   Usage:\n");
+	_printf_(true,"      [ierror]=KMLFileRead(kmlfile,'param name',param,...);\n");
+	_printf_(true,"\n");
+	_printf_(true,"      kmlfile      file name of kml file to be read (char)\n");
+	_printf_(true,"\n");
+	_printf_(true,"      echo         echo command (char, optional, 'off'/'on')\n");
+	_printf_(true,"      deepecho     deep echo command (char, optional, 'off'/'on')\n");
+	_printf_(true,"      write        write command (char, optional, 'off'/'stdout'/kmlfile)\n");
+	_printf_(true,"\n");
+	_printf_(true,"      ierror       return code (non-zero for error)\n");
+	_printf_(true,"\n");
+	_printf_(true,"   Examples:\n");
+	_printf_(true,"      [ierror]=KMLFileRead('file.kml','deepecho','on');\n");
+	_printf_(true,"      [ierror]=KMLFileRead('filin.kml','echo','on','write','filout.kml');\n");
+	_printf_(true,"\n");
+}
+
Index: /issm/trunk/src/mex/KMLFileRead/KMLFileRead.h
===================================================================
--- /issm/trunk/src/mex/KMLFileRead/KMLFileRead.h	(revision 11527)
+++ /issm/trunk/src/mex/KMLFileRead/KMLFileRead.h	(revision 11527)
@@ -0,0 +1,31 @@
+/*!\file KMLFileRead.h
+ * \brief: prototype for KML file reader mex module.
+ */
+
+#ifndef _KMLFILEREAD_H
+#define _KMLFILEREAD_H
+
+/* local prototypes: */
+void KMLFileReadUsage(void);
+
+#include "../../c/modules/modules.h"
+#include "../../c/Container/Container.h"
+#include "../../c/shared/shared.h"
+
+#undef __FUNCT__ 
+#define __FUNCT__  "KMLFileRead"
+
+
+/* serial input macros: */
+#define FILENAME      prhs[0]
+
+/* serial output macros: */
+#define ERRORFLAG (mxArray**)&plhs[0]
+
+/* serial arg counts: */
+#undef NRHS
+#define NRHS  1
+#undef NLHS
+#define NLHS  1
+
+#endif
Index: sm/trunk/src/mex/KMLMeshWrite/KMLFileRead.cpp
===================================================================
--- /issm/trunk/src/mex/KMLMeshWrite/KMLFileRead.cpp	(revision 11526)
+++ 	(revision )
@@ -1,151 +1,0 @@
-/*\file KMLFileRead.c
- *\brief: KML file reader module.
- */
-#include "./KMLFileRead.h"
-
-void mexFunction( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]){
-
-	int i,j,nnodes=0,verbose=1;
-	KML_Object* kobj;
-
-	/*input: */
-	char*   name=NULL;
-
-	char*   notes=NULL;
-	const mxArray* notesi;
-	mwIndex        nindex;
-
-	int*    elem=NULL;
-	int     melem=0,nelem=0;
-
-	int*    nodecon=NULL;
-	int     mncon=0,nncon=0;
-
-	double* lat=NULL;
-	int     mlat=0,nlat=0,llat=0;
-
-	double* lng=NULL;
-	int     mlng=0,nlng=0,llng=0;
-
-	int     nparts=0;
-
-	int*    part=NULL;
-	int     mprt=0,nprt=0,lprt=0;
-
-	double* data=NULL;
-	int     mdata=0,ndata=0;
-
-	double* cmap=NULL;
-	int     mcmap=0,ncmap=0;
-
-	char*   filnam=NULL;
-
-	FILE*   fidi=NULL;
-	FILE*   fido=NULL;
-
-	Options* options=NULL;
-	char*    echo    =NULL;
-	char*    deepecho=NULL;
-	char*    write   =NULL;
-
-	/* output: */
-	int     ierror=0;
-
-	/*Boot module: */
-	MODULEBOOT();
-
-	/*checks on arguments on the matlab side: */
-	if (nlhs > NLHS) {
-		KMLFileReadUsage();
-		_error_("KMLFileRead usage error");
-	}
-	if (nrhs < NRHS) {
-		KMLFileReadUsage();
-		_error_("KMLFileRead usage error");
-	}
-
-	/*Input datasets: */
-	if (verbose) printf("Fetching inputs:\n");
-	FetchMatlabData(&filnam,FILENAME);
-	if (verbose) printf("  filnam =\"%s\"\n",filnam);
-
-	if (verbose) printf("Parsing options:\n");
-	options=new Options(NRHS,nrhs,prhs);
-	if (options->Size()) for(i=0;i<options->Size();i++) ((Option*)options->GetObjectByOffset(i))->DeepEcho();
-	options->Get(&echo    ,"echo"    ,"off");
-	options->Get(&deepecho,"deepecho","off");
-	options->Get(&write   ,"write"   ,"off");
-
-	/*some checks*/
-	if (verbose) printf("Checking inputs:\n");
-
-	if (!strlen(filnam))
-		strcpy(filnam,"stdout");
-
-	if (verbose) printf("Opening file \"%s\".\n",filnam);
-	fidi=fopen(filnam,"r");
-
-	/* Run core computations: */
-	if (verbose) printf("Calling core:\n");
-	kobj=KMLFileReadx(fidi);
-
-	if (verbose) printf("Closing file \"%s\".\n",filnam);
-	fclose(fidi);
-
-	if (kobj) {
-		if (!strncmp(echo    ,"on",2) || !strncmp(echo    ,"y",1))
-			kobj->Echo();
-		if (!strncmp(deepecho,"on",2) || !strncmp(deepecho,"y",1))
-			kobj->DeepEcho();
-		if (strncmp(write,"off",3) && strncmp(write,"no",2)) {
-			if (!strncmp(write,"on",2) || !strncmp(write,"yes",3) || !strncmp(write,"stdout",6)) {
-				kobj->Write(stdout,"");
-			}
-			else {
-				if (verbose) printf("Opening file \"%s\".\n",write);
-				fido=fopen(write,"w");
-				kobj->Write(fido,"");
-				if (verbose) printf("Closing file \"%s\".\n",write);
-				ierror=fclose(fido);
-			}
-		}
-
-		delete kobj;
-	}
-
-	/*Write data: */
-	WriteMatlabData(ERRORFLAG,ierror);
-
-	/*Clean-up*/
-	xfree((void**)&write);
-	xfree((void**)&deepecho);
-	xfree((void**)&echo);
-	delete options;
-
-	/*end module: */
-	MODULEEND();
-}
-
-void KMLFileReadUsage(void)
-{
-	_printf_(true,"KMLFileRead - KML file reader module:\n");
-	_printf_(true,"\n");
-	_printf_(true,"   This module reads a KML file.\n");
-	_printf_(true,"\n");
-	_printf_(true,"   Usage:\n");
-	_printf_(true,"      [ierror]=KMLFileRead(kmlfile,'param name',param,...);\n");
-	_printf_(true,"\n");
-	_printf_(true,"      kmlfile      file name of kml file to be read (char)\n");
-	_printf_(true,"\n");
-	_printf_(true,"      echo         echo command (char, optional, 'off'/'on')\n");
-	_printf_(true,"      deepecho     deep echo command (char, optional, 'off'/'on')\n");
-	_printf_(true,"      write        write command (char, optional, 'off'/'stdout'/kmlfile)\n");
-	_printf_(true,"\n");
-	_printf_(true,"      ierror       return code (non-zero for error)\n");
-	_printf_(true,"\n");
-	_printf_(true,"   Examples:\n");
-	_printf_(true,"      [ierror]=KMLFileRead('file.kml','deepecho','on');\n");
-	_printf_(true,"      [ierror]=KMLFileRead('filin.kml','echo','on','write','filout.kml');\n");
-	_printf_(true,"\n");
-}
-
Index: sm/trunk/src/mex/KMLMeshWrite/KMLFileRead.h
===================================================================
--- /issm/trunk/src/mex/KMLMeshWrite/KMLFileRead.h	(revision 11526)
+++ 	(revision )
@@ -1,31 +1,0 @@
-/*!\file KMLFileRead.h
- * \brief: prototype for KML file reader mex module.
- */
-
-#ifndef _KMLFILEREAD_H
-#define _KMLFILEREAD_H
-
-/* local prototypes: */
-void KMLFileReadUsage(void);
-
-#include "../../c/modules/modules.h"
-#include "../../c/Container/Container.h"
-#include "../../c/shared/shared.h"
-
-#undef __FUNCT__ 
-#define __FUNCT__  "KMLFileRead"
-
-
-/* serial input macros: */
-#define FILENAME      prhs[0]
-
-/* serial output macros: */
-#define ERRORFLAG (mxArray**)&plhs[0]
-
-/* serial arg counts: */
-#undef NRHS
-#define NRHS  1
-#undef NLHS
-#define NLHS  1
-
-#endif
Index: /issm/trunk/src/mex/Makefile.am
===================================================================
--- /issm/trunk/src/mex/Makefile.am	(revision 11526)
+++ /issm/trunk/src/mex/Makefile.am	(revision 11527)
@@ -1,3 +1,3 @@
-INCLUDES = @MATLABINCL@ @PETSCINCL@ @MPIINCL@ @METISINCL@ @TRIANGLEINCL@ @CHACOINCL@ @SCOTCHINCL@ @SHAPELIBINCL@
+INCLUDES = @MATLABINCL@ @PETSCINCL@ @MPIINCL@ @METISINCL@ @TRIANGLEINCL@ @CHACOINCL@ @SCOTCHINCL@ @SHAPELIBINCL@ 
 EXEEXT=$(MEXEXT)
 
@@ -22,4 +22,5 @@
 				CostFunction \
 				CreateNodalConstraints\
+				CreateJacobianMatrix\
 				Echo\
 				ElementConnectivity\
@@ -95,11 +96,15 @@
 bin_PROGRAMS += 
 else
+if DAKOTA
 bin_PROGRAMS += DakotaResponses\
 				Dakota\
 				InputUpdateFromDakota
+else
+bin_PROGRAMS += 
+endif
 endif 
 #}}}
 #Flags and libraries {{{1
-LDADD =   $(TRIANGLELIB) ../c/libISSM.a $(PETSCLIB) $(FLIBS)  $(PLAPACKLIB)  $(MUMPSLIB) $(SCALAPACKLIB)  $(BLACSLIB)  $(HYPRELIB) $(MLLIB) $(DAKOTALIB) $(METISLIB) $(CHACOLIB) $(SCOTCHLIB) $(BLASLAPACKLIB)  $(MPILIB) $(MATHLIB) $(FORTRANLIB) $(GRAPHICSLIB) $(MULTITHREADINGLIB) $(SHAPELIBLIB)
+LDADD =   $(TRIANGLELIB) ../c/libISSM.a $(PETSCLIB) $(FLIBS)  $(PLAPACKLIB)  $(MUMPSLIB) $(SCALAPACKLIB)  $(BLACSLIB)  $(HYPRELIB) $(MLLIB) $(DAKOTALIB) $(METISLIB) $(CHACOLIB) $(SCOTCHLIB) $(BLASLAPACKLIB)  $(MPILIB) $(MATHLIB) $(FORTRANLIB) $(GRAPHICSLIB) $(MULTITHREADINGLIB) $(SHAPELIBLIB) $(MEXLIB)
 
 AM_LDFLAGS = $(MEXLINK)
@@ -234,6 +239,6 @@
 									InterpFromMesh2d/InterpFromMesh2d.h
 
-KMLFileRead_SOURCES = KMLMeshWrite/KMLFileRead.cpp\
-			  KMLMeshWrite/KMLFileRead.h
+KMLFileRead_SOURCES = KMLFileRead/KMLFileRead.cpp\
+			  KMLFileRead/KMLFileRead.h
 
 KMLMeshWrite_SOURCES = KMLMeshWrite/KMLMeshWrite.cpp\
@@ -326,4 +331,8 @@
 SystemMatrices_SOURCES = SystemMatrices/SystemMatrices.cpp\
 			  SystemMatrices/SystemMatrices.h
+
+
+CreateJacobianMatrix_SOURCES = CreateJacobianMatrix/CreateJacobianMatrix.cpp\
+								 CreateJacobianMatrix/CreateJacobianMatrix.h
 
 SurfaceArea_SOURCES = SurfaceArea/SurfaceArea.cpp\
Index: /issm/trunk/src/mex/MeshProfileIntersection/MeshProfileIntersection.cpp
===================================================================
--- /issm/trunk/src/mex/MeshProfileIntersection/MeshProfileIntersection.cpp	(revision 11526)
+++ /issm/trunk/src/mex/MeshProfileIntersection/MeshProfileIntersection.cpp	(revision 11527)
@@ -54,9 +54,9 @@
 	//index
 	FetchMatlabData(&double_index,&nel,&dummy,INDEX);
-	if(dummy!=3)_error_(" element triangulation should be of 3 column width!");
+	if(dummy!=3 && dummy!=6)_error_(" element triangulation should be of 3 or 6 column width!");
 	index=(int*)xmalloc(nel*3*sizeof(int));
 	for(i=0;i<nel;i++){
 		for(j=0;j<3;j++){
-			*(index+3*i+j)=(int)*(double_index+3*i+j)-1; //"C" style indexing
+			*(index+3*i+j)=(int)*(double_index+dummy*i+j)-1; //"C" style indexing
 		}
 	}
Index: /issm/trunk/src/mex/Solver/Solver.cpp
===================================================================
--- /issm/trunk/src/mex/Solver/Solver.cpp	(revision 11526)
+++ /issm/trunk/src/mex/Solver/Solver.cpp	(revision 11527)
@@ -33,5 +33,5 @@
 	FetchMatlabData(&parameters,PARAMETERS);
 
-	/*In serial mode, we have no set any petsc options, do it now: */
+	/*In serial mode, we have not set any petsc options, do it now: */
 	#ifdef _SERIAL_
 	parameters->FindParam(&analysis_type,AnalysisTypeEnum);
Index: /issm/trunk/startup.m
===================================================================
--- /issm/trunk/startup.m	(revision 11526)
+++ /issm/trunk/startup.m	(revision 11527)
@@ -11,6 +11,10 @@
 lastwarn(''); 
 
-%Recover ISSM_TIER 
-ISSM_TIER=getenv('ISSM_TIER');
+%Recover ISSM_TIER , or if on a Windows machine, ISSM_TIER_WIN
+if ~ispc,
+	ISSM_TIER=getenv('ISSM_TIER');
+else
+	ISSM_TIER=getenv('ISSM_TIER_WIN');
+end
 if (isempty(ISSM_TIER)),
 	error('issmdir error message: ''ISSM_TIER'' environment variable is empty! You should define ISSM_TIER in your .cshrc or .bashrc!');
@@ -22,13 +26,33 @@
 
 %ISSM path
-addpath([ISSM_TIER '/src/m/utils/']); %loads recursivepath
-addpath([ISSM_TIER '/doc']);
-addpath([ISSM_TIER '/bin']);
-addpath(recursivepath([ISSM_TIER '/src/m']));
-addpath(recursivepath([ISSM_TIER '/externalpackages/scotch']));
-addpath(recursivepath([ISSM_TIER '/externalpackages/canos']));
-addpath(recursivepath([ISSM_TIER '/externalpackages/kml']));
-addpath(recursivepath([ISSM_TIER '/externalpackages/googleearthtoolbox/']));
-addpath(recursivepath([ISSM_TIER '/externalpackages/export_fig']));
+addpath(pwd); %add current path first
+
+if exist([ISSM_TIER '/src/m/utils/'],'dir'),
+	addpath([ISSM_TIER '/src/m/utils/']); %loads recursivepath
+end
+if exist([ISSM_TIER '/doc'],'dir'),
+	addpath([ISSM_TIER '/doc']);
+end
+if exist([ISSM_TIER '/bin'],'dir'),
+	addpath([ISSM_TIER '/bin']);
+end
+if exist([ISSM_TIER '/src/m'],'dir'),
+	addpath(recursivepath([ISSM_TIER '/src/m']));
+end
+if exist([ISSM_TIER '/externalpackages/scotch'],'dir'),
+	addpath(recursivepath([ISSM_TIER '/externalpackages/scotch']));
+end
+if exist([ISSM_TIER '/externalpackages/canos'],'dir'),
+	addpath(recursivepath([ISSM_TIER '/externalpackages/canos']));
+end
+if exist([ISSM_TIER '/externalpackages/kml'],'dir'),
+	addpath(recursivepath([ISSM_TIER '/externalpackages/kml']));
+end
+if exist([ISSM_TIER '/externalpackages/googleearthtoolbox/'],'dir'),
+	addpath(recursivepath([ISSM_TIER '/externalpackages/googleearthtoolbox/']));
+end
+if exist([ISSM_TIER '/externalpackages/export_fig'],'dir'),
+	addpath(recursivepath([ISSM_TIER '/externalpackages/export_fig']));
+end
 clear ISSM_TIER;
 
@@ -43,15 +67,17 @@
 %  deal with Matlab bug (on Linux, not WinXP) -- unless
 %  the class has been called, "empty" method can not be found
-normal_uncertain;
-continuous_design;
-continuous_state;
-linear_inequality_constraint;
-linear_equality_constraint;
-response_function;
-objective_function;
-least_squares_term;
-nonlinear_inequality_constraint;
-nonlinear_equality_constraint;
-clear ans;
+if ~ispc,
+	normal_uncertain;
+	continuous_design;
+	continuous_state;
+	linear_inequality_constraint;
+	linear_equality_constraint;
+	response_function;
+	objective_function;
+	least_squares_term;
+	nonlinear_inequality_constraint;
+	nonlinear_equality_constraint;
+	clear ans;
+end
 
 %disable matlab bell!
@@ -60,2 +86,11 @@
 % no warning if we try to plot while in nojvm (will not be supported in future releases)
 warning off MATLAB:HandleGraphics:noJVM
+
+%at the end, get to tests directory if ISSM_TESTS exists: 
+if ispc, 
+	addpath([pwd '\bin']);
+	ISSM_TESTS=getenv('ISSM_TESTS');
+	if ~isempty(ISSM_TESTS),
+		cd(ISSM_TESTS);
+	end
+end
Index: /issm/trunk/test/NightlyRun/IdToName.m
===================================================================
--- /issm/trunk/test/NightlyRun/IdToName.m	(revision 11526)
+++ /issm/trunk/test/NightlyRun/IdToName.m	(revision 11527)
@@ -44,4 +44,10 @@
 	case 136, name='SquareShelfConstrainedBalThic2dDGParallel';
 	case 137, name='SquareBamgMesh';
+	case 139, name='SquareShelfConstrainedEnthalpySteaSerial';
+	case 140, name='SquareShelfConstrainedEnthalpySteaParallel';
+	case 141, name='SquareShelfConstrainedEnthalpyTranSerial';
+	case 142, name='SquareShelfConstrainedEnthalpyTranParallel';
+	case 143, name='SquareShelfConstrainedTransP3dEnthSerial';
+	case 144, name='SquareShelfConstrainedTransP3dEnthParallel';
 	case 201, name='SquareShelfDiagM2dSerial';
 	case 202, name='SquareShelfDiagM2dParallel';
@@ -160,4 +166,10 @@
 	case 347, name='SquareSheetConstrainedTranCflH3dSerial';
 	case 348, name='SquareSheetConstrainedTranCflH3dParallel';
+	case 349, name='SquareSheetConstrainedEnthalpySteaSerial';
+	case 350, name='SquareSheetConstrainedEnthalpySteaParallel';
+	case 351, name='SquareSheetConstrainedEnthalpyTranSerial';
+	case 352, name='SquareSheetConstrainedEnthalpyTranParallel';
+	case 353, name='SquareSheetConstrainedTransP3dEnthSerial';
+	case 354, name='SquareSheetConstrainedTransP3dEnthParallel';
 	case 401, name='SquareSheetShelfDiagM2dSerial';
 	case 402, name='SquareSheetShelfDiagM2dParallel';
Index: /issm/trunk/test/NightlyRun/Makefile
===================================================================
--- /issm/trunk/test/NightlyRun/Makefile	(revision 11526)
+++ /issm/trunk/test/NightlyRun/Makefile	(revision 11527)
@@ -1,2 +1,2 @@
 clean: 
-	rm -rf *.tar.gz *.bin *.errlog *.outlog  *.outbin *.petsc *.queue *.run valgrind.log*
+	rm -rf *.tar.gz *.bin *.errlog *.outlog  *.outbin *.petsc *.queue *.run valgrind.log* *.bat *.lock
Index: /issm/trunk/test/NightlyRun/runme.m
===================================================================
--- /issm/trunk/test/NightlyRun/runme.m	(revision 11526)
+++ /issm/trunk/test/NightlyRun/runme.m	(revision 11527)
@@ -48,5 +48,5 @@
 benchmark=getfieldvalue(options,'benchmark','nightly');
 if ~ismember(benchmark,{'all','nightly','ismip','eismint','thermal','mesh','validation','tranforcing'})
-	disp('runme warnig: benchmark not supported, defaulting to test ''nightly''')
+	disp('runme warning: benchmark not supported, defaulting to test ''nightly''')
 	benchmark='nighlty';
 end
Index: /issm/trunk/test/NightlyRun/test1104.m
===================================================================
--- /issm/trunk/test/NightlyRun/test1104.m	(revision 11526)
+++ /issm/trunk/test/NightlyRun/test1104.m	(revision 11527)
@@ -69,5 +69,5 @@
 	1e-08,1e-08,1e-08,...
 	1e-08,1e-08,1e-08,...
-	1e-08,1e-07,1e-07,...
+	1e-07,1e-07,1e-07,...
 };
 field_values={};
Index: /issm/trunk/test/NightlyRun/test1106.m
===================================================================
--- /issm/trunk/test/NightlyRun/test1106.m	(revision 11526)
+++ /issm/trunk/test/NightlyRun/test1106.m	(revision 11527)
@@ -62,5 +62,5 @@
 };
 field_tolerances={...
-	1e-12,1e-12,1e-12,...
+	1e-12,1e-12,1e-11,...
 	1e-12,1e-12,1e-12,...
 	1e-12,1e-12,1e-12,...
Index: /issm/trunk/test/NightlyRun/test1107.m
===================================================================
--- /issm/trunk/test/NightlyRun/test1107.m	(revision 11526)
+++ /issm/trunk/test/NightlyRun/test1107.m	(revision 11527)
@@ -136,5 +136,5 @@
 	1e-08,1e-08,1e-07,...
 	1e-08,1e-08,1e-07,...
-	1e-07,1e-08,1e-07,...
+	1e-07,1e-08,1e-06,...
 };
 field_values={};
Index: /issm/trunk/test/NightlyRun/test1108.m
===================================================================
--- /issm/trunk/test/NightlyRun/test1108.m	(revision 11526)
+++ /issm/trunk/test/NightlyRun/test1108.m	(revision 11527)
@@ -76,5 +76,5 @@
 	1e-08,1e-07,1e-08,...
 	1e-08,1e-08,1e-08,...
-	1e-08,1e-08,1e-08,...
+	1e-08,1e-07,1e-07,...
 	1e-07,1e-06,1e-07,...
 };
Index: /issm/trunk/test/NightlyRun/test1109.m
===================================================================
--- /issm/trunk/test/NightlyRun/test1109.m	(revision 11526)
+++ /issm/trunk/test/NightlyRun/test1109.m	(revision 11527)
@@ -88,13 +88,13 @@
 %Fields and tolerances to track changes
 field_names     ={ ...
-	'VxPattynSliding','VyPattynSliding','VzPattynSliding',...
+	'VyPattynSliding','VzPattynSliding',...
 	'VxStokesSliding','VyStokesSliding','VzStokesSliding',...
-	'VxPattynFrozen','VyPattynFrozen','VzPattynFrozen',...
+	'VyPattynFrozen','VzPattynFrozen',...
 	'VxStokesFrozen','VyStokesFrozen','VzStokesFrozen'
 };
 field_tolerances={...
-	1e-06,1e-05,1e-05,...
+	1e-05,1e-05,...
 	1e-06,1e-06,1e-06,...
-	1e-06,1e-05,1e-05,...
+	1e-05,1e-04,...
 	1e-06,1e-06,1e-06,...
 };
Index: /issm/trunk/test/NightlyRun/test122.m
===================================================================
--- /issm/trunk/test/NightlyRun/test122.m	(revision 11526)
+++ /issm/trunk/test/NightlyRun/test122.m	(revision 11527)
@@ -8,8 +8,12 @@
 
 %Fields and tolerances to track changes
-field_names     ={'Vx1','Vy1','Vz1','Vel1','Pressure1','Bed1','Surface1','Thickness1','Temperature1','BasalforcingsMeltingRate1', ...
-				      'Vx2','Vy2','Vz2','Vel2','Pressure2','Bed2','Surface2','Thickness2','Temperature2','BasalforcingsMeltingRate2', ...
-					   'Vx3','Vy3','Vz3','Vel3','Pressure3','Bed3','Surface3','Thickness3','Temperature3','BasalforcingsMeltingRate3'};
-field_tolerances={1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-05,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-05,1e-09,1e-09,1e-08,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-05};
+field_names={...
+	'Vx1','Vy1','Vz1','Vel1','Pressure1','Bed1','Surface1','Thickness1','Temperature1','BasalforcingsMeltingRate1', ...
+	'Vx2','Vy2','Vz2','Vel2','Pressure2','Bed2','Surface2','Thickness2','Temperature2','BasalforcingsMeltingRate2', ...
+	'Vx3','Vy3','Vz3','Vel3','Pressure3','Bed3','Surface3','Thickness3','Temperature3','BasalforcingsMeltingRate3'};
+field_tolerances={...
+	1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-05,...
+	1e-09,1e-09,1e-08,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-05,...
+	1e-09,1e-09,1e-08,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-05};
 field_values={...
 	(md.results.TransientSolution(1).Vx),...
Index: /issm/trunk/test/NightlyRun/test139.m
===================================================================
--- /issm/trunk/test/NightlyRun/test139.m	(revision 11527)
+++ /issm/trunk/test/NightlyRun/test139.m	(revision 11527)
@@ -0,0 +1,18 @@
+md=triangle(model,'../Exp/Square.exp',180000);
+md=setmask(md,'all','');
+md=parameterize(md,'../Par/SquareShelfConstrained.par');
+md=extrude(md,3,1);
+md=setflowequation(md,'macayeal','all');
+md.timestepping.time_step=0;
+md.cluster=none;
+md.initialization.waterfraction=zeros(md.mesh.numberofvertices,1);
+md=solve(md,EnthalpySolutionEnum);
+
+%Fields and tolerances to track changes
+field_names     ={'Enthalpy','Waterfraction','Temperature'};
+field_tolerances={1e-13,1e-10,1e-13};
+field_values={...
+	(md.results.EnthalpySolution.Enthalpy),...
+	(md.results.EnthalpySolution.Waterfraction),...
+	(md.results.EnthalpySolution.Temperature),...
+	};
Index: /issm/trunk/test/NightlyRun/test140.m
===================================================================
--- /issm/trunk/test/NightlyRun/test140.m	(revision 11527)
+++ /issm/trunk/test/NightlyRun/test140.m	(revision 11527)
@@ -0,0 +1,19 @@
+md=triangle(model,'../Exp/Square.exp',180000);
+md=setmask(md,'all','');
+md=parameterize(md,'../Par/SquareShelfConstrained.par');
+md=extrude(md,3,1);
+md=setflowequation(md,'macayeal','all');
+md.timestepping.time_step=0;
+md.cluster=generic('name',oshostname(),'np',3);
+md.initialization.waterfraction=zeros(md.mesh.numberofvertices,1);
+%md=solve(md,ThermalSolutionEnum);
+md=solve(md,EnthalpySolutionEnum);
+
+%Fields and tolerances to track changes
+field_names     ={'Enthalpy','Waterfraction','Temperature'};
+field_tolerances={1e-13,1e-13,1e-13};
+field_values={...
+	(md.results.EnthalpySolution.Enthalpy),...
+	(md.results.EnthalpySolution.Waterfraction),...
+	(md.results.EnthalpySolution.Temperature),...
+	};
Index: /issm/trunk/test/NightlyRun/test141.m
===================================================================
--- /issm/trunk/test/NightlyRun/test141.m	(revision 11527)
+++ /issm/trunk/test/NightlyRun/test141.m	(revision 11527)
@@ -0,0 +1,25 @@
+md=triangle(model,'../Exp/Square.exp',180000);
+md=setmask(md,'all','');
+md=parameterize(md,'../Par/SquareShelfConstrained.par');
+md=extrude(md,3,1);
+md=setflowequation(md,'macayeal','all');
+md.initialization.waterfraction=zeros(md.mesh.numberofvertices,1);
+md.cluster=none;
+md=solve(md,EnthalpySolutionEnum);
+
+%Fields and tolerances to track changes
+field_names     ={'Enthalpy1','Waterfraction1','Temperature1',...
+	'Enthalpy2','Waterfraction2','Temperature2',...
+	'Enthalpy3','Waterfraction3','Temperature3'};
+field_tolerances={1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13};
+field_values={...
+	(md.results.EnthalpySolution(1).Enthalpy),...
+	(md.results.EnthalpySolution(1).Waterfraction),...
+	(md.results.EnthalpySolution(1).Temperature),...
+	(md.results.EnthalpySolution(2).Enthalpy),...
+	(md.results.EnthalpySolution(2).Waterfraction),...
+	(md.results.EnthalpySolution(2).Temperature),...
+	(md.results.EnthalpySolution(3).Enthalpy),...
+	(md.results.EnthalpySolution(3).Waterfraction),...
+	(md.results.EnthalpySolution(3).Temperature),...
+	};
Index: /issm/trunk/test/NightlyRun/test142.m
===================================================================
--- /issm/trunk/test/NightlyRun/test142.m	(revision 11527)
+++ /issm/trunk/test/NightlyRun/test142.m	(revision 11527)
@@ -0,0 +1,26 @@
+md=triangle(model,'../Exp/Square.exp',180000);
+md=setmask(md,'all','');
+md=parameterize(md,'../Par/SquareShelfConstrained.par');
+md=extrude(md,3,1);
+md=setflowequation(md,'macayeal','all');
+md.cluster=generic('name',oshostname(),'np',3);
+md.initialization.waterfraction=zeros(md.mesh.numberofvertices,1);
+%md=solve(md,ThermalSolutionEnum);
+md=solve(md,EnthalpySolutionEnum);
+
+%Fields and tolerances to track changes
+field_names     ={'Enthalpy1','Waterfraction1','Temperature1',...
+	'Enthalpy2','Waterfraction2','Temperature2',...
+	'Enthalpy3','Waterfraction3','Temperature3'};
+field_tolerances={1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-10,1e-13};
+field_values={...
+	(md.results.EnthalpySolution(1).Enthalpy),...
+	(md.results.EnthalpySolution(1).Waterfraction),...
+	(md.results.EnthalpySolution(1).Temperature),...
+	(md.results.EnthalpySolution(2).Enthalpy),...
+	(md.results.EnthalpySolution(2).Waterfraction),...
+	(md.results.EnthalpySolution(2).Temperature),...
+	(md.results.EnthalpySolution(3).Enthalpy),...
+	(md.results.EnthalpySolution(3).Waterfraction),...
+	(md.results.EnthalpySolution(3).Temperature),...
+	};
Index: /issm/trunk/test/NightlyRun/test143.m
===================================================================
--- /issm/trunk/test/NightlyRun/test143.m	(revision 11527)
+++ /issm/trunk/test/NightlyRun/test143.m	(revision 11527)
@@ -0,0 +1,53 @@
+md=triangle(model,'../Exp/Square.exp',200000);
+md=setmask(md,'all','');
+md=parameterize(md,'../Par/SquareShelfConstrained.par');
+md=extrude(md,3,1);
+md=setflowequation(md,'pattyn','all');
+md.initialization.waterfraction=zeros(md.mesh.numberofvertices,1);
+md.thermal.isenthalpy=1;
+md.thermal.stabilization=2;
+md.cluster=none;
+md=solve(md,TransientSolutionEnum);
+
+%Fields and tolerances to track changes
+field_names     ={'Vx1','Vy1','Vz1','Vel1','Pressure1','Bed1','Surface1','Thickness1','Temperature1','Enthalpy1','Waterfraction1', ...
+				      'Vx2','Vy2','Vz2','Vel2','Pressure2','Bed2','Surface2','Thickness2','Temperature2','Enthalpy2','Waterfraction2', ...
+					   'Vx3','Vy3','Vz3','Vel3','Pressure3','Bed3','Surface3','Thickness3','Temperature3','Enthalpy3','Waterfraction3'};
+field_tolerances={1e-09,1e-09,1e-09,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,...
+						1e-09,1e-09,1e-10,1e-09,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,...
+						1e-09,5e-10,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10};
+field_values={...
+	(md.results.TransientSolution(1).Vx),...
+	(md.results.TransientSolution(1).Vy),...
+	(md.results.TransientSolution(1).Vz),...
+	(md.results.TransientSolution(1).Vel),...
+	(md.results.TransientSolution(1).Pressure),...
+	(md.results.TransientSolution(1).Bed),...
+	(md.results.TransientSolution(1).Surface),...
+	(md.results.TransientSolution(1).Thickness),...
+	(md.results.TransientSolution(1).Temperature),...
+	(md.results.TransientSolution(1).Enthalpy),...
+	(md.results.TransientSolution(1).Waterfraction),...
+	(md.results.TransientSolution(2).Vx),...
+	(md.results.TransientSolution(2).Vy),...
+	(md.results.TransientSolution(2).Vz),...
+	(md.results.TransientSolution(2).Vel),...
+	(md.results.TransientSolution(2).Pressure),...
+	(md.results.TransientSolution(2).Bed),...
+	(md.results.TransientSolution(2).Surface),...
+	(md.results.TransientSolution(2).Thickness),...
+	(md.results.TransientSolution(2).Temperature),...
+	(md.results.TransientSolution(2).Enthalpy),...
+	(md.results.TransientSolution(2).Waterfraction),...
+	(md.results.TransientSolution(3).Vx),...
+	(md.results.TransientSolution(3).Vy),...
+	(md.results.TransientSolution(3).Vz),...
+	(md.results.TransientSolution(3).Vel),...
+	(md.results.TransientSolution(3).Pressure),...
+	(md.results.TransientSolution(3).Bed),...
+	(md.results.TransientSolution(3).Surface),...
+	(md.results.TransientSolution(3).Thickness),...
+	(md.results.TransientSolution(3).Temperature),...
+	(md.results.TransientSolution(3).Enthalpy),...
+	(md.results.TransientSolution(3).Waterfraction),...
+	};
Index: /issm/trunk/test/NightlyRun/test144.m
===================================================================
--- /issm/trunk/test/NightlyRun/test144.m	(revision 11527)
+++ /issm/trunk/test/NightlyRun/test144.m	(revision 11527)
@@ -0,0 +1,54 @@
+md=triangle(model,'../Exp/Square.exp',200000);
+md=setmask(md,'all','');
+md=parameterize(md,'../Par/SquareShelfConstrained.par');
+md=extrude(md,3,1);
+md=setflowequation(md,'pattyn','all');
+md.initialization.waterfraction=zeros(md.mesh.numberofvertices,1);
+md.thermal.isenthalpy=1;
+md.thermal.stabilization=2;
+md.cluster=generic('name',oshostname(),'np',3);
+md=solve(md,TransientSolutionEnum);
+
+%Fields and tolerances to track changes
+field_names     ={'Vx1','Vy1','Vz1','Vel1','Pressure1','Bed1','Surface1','Thickness1','Temperature1','Enthalpy1','Waterfraction1', ...
+				      'Vx2','Vy2','Vz2','Vel2','Pressure2','Bed2','Surface2','Thickness2','Temperature2','Enthalpy2','Waterfraction2', ...
+					   'Vx3','Vy3','Vz3','Vel3','Pressure3','Bed3','Surface3','Thickness3','Temperature3','Enthalpy3','Waterfraction3'};
+field_tolerances={...
+	1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,...
+	1e-09,1e-09,1e-08,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,...
+	1e-09,1e-09,1e-08,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09};
+field_values={...
+	(md.results.TransientSolution(1).Vx),...
+	(md.results.TransientSolution(1).Vy),...
+	(md.results.TransientSolution(1).Vz),...
+	(md.results.TransientSolution(1).Vel),...
+	(md.results.TransientSolution(1).Pressure),...
+	(md.results.TransientSolution(1).Bed),...
+	(md.results.TransientSolution(1).Surface),...
+	(md.results.TransientSolution(1).Thickness),...
+	(md.results.TransientSolution(1).Temperature),...
+	(md.results.TransientSolution(1).Enthalpy),...
+	(md.results.TransientSolution(1).Waterfraction),...
+	(md.results.TransientSolution(2).Vx),...
+	(md.results.TransientSolution(2).Vy),...
+	(md.results.TransientSolution(2).Vz),...
+	(md.results.TransientSolution(2).Vel),...
+	(md.results.TransientSolution(2).Pressure),...
+	(md.results.TransientSolution(2).Bed),...
+	(md.results.TransientSolution(2).Surface),...
+	(md.results.TransientSolution(2).Thickness),...
+	(md.results.TransientSolution(2).Temperature),...
+	(md.results.TransientSolution(2).Enthalpy),...
+	(md.results.TransientSolution(2).Waterfraction),...
+	(md.results.TransientSolution(3).Vx),...
+	(md.results.TransientSolution(3).Vy),...
+	(md.results.TransientSolution(3).Vz),...
+	(md.results.TransientSolution(3).Vel),...
+	(md.results.TransientSolution(3).Pressure),...
+	(md.results.TransientSolution(3).Bed),...
+	(md.results.TransientSolution(3).Surface),...
+	(md.results.TransientSolution(3).Thickness),...
+	(md.results.TransientSolution(3).Temperature),...
+	(md.results.TransientSolution(3).Enthalpy),...
+	(md.results.TransientSolution(3).Waterfraction),...
+	};
Index: /issm/trunk/test/NightlyRun/test1502.m
===================================================================
--- /issm/trunk/test/NightlyRun/test1502.m	(revision 11526)
+++ /issm/trunk/test/NightlyRun/test1502.m	(revision 11527)
@@ -1,10 +1,10 @@
 printingflag = false;
 
-md=triangle(model,'../Exp/Square.exp',700000);
+md=triangle(model,'../Exp/Square.exp',450000);
 md=setmask(md,'all','');
 md=parameterize(md,'../Par/SquareShelf.par');
 md=setflowequation(md,'macayeal','all');
 md=extrude(md,3,1);
-md.cluster=generic('name',oshostname(),'np',3);
+md.cluster=generic('name',oshostname(),'np',2);
 md.transient.isthermal=0;
 
Index: /issm/trunk/test/NightlyRun/test218.m
===================================================================
--- /issm/trunk/test/NightlyRun/test218.m	(revision 11526)
+++ /issm/trunk/test/NightlyRun/test218.m	(revision 11527)
@@ -11,5 +11,8 @@
 				      'Vx2','Vy2','Vz2','Vel2','Pressure2','Bed2','Surface2','Thickness2','Temperature2','BasalforcingsMeltingRate2', ...
 					   'Vx3','Vy3','Vz3','Vel3','Pressure3','Bed3','Surface3','Thickness3','Temperature3','BasalforcingsMeltingRate3'};
-field_tolerances={1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13};
+field_tolerances={...
+	1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-8,...
+	1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-8,...
+	1e-13,1e-13,1e-08,1e-13,1e-13,1e-10,1e-10,1e-10,1e-13,1e-8};
 field_values={...
 	(md.results.TransientSolution(1).Vx),...
Index: /issm/trunk/test/NightlyRun/test222.m
===================================================================
--- /issm/trunk/test/NightlyRun/test222.m	(revision 11526)
+++ /issm/trunk/test/NightlyRun/test222.m	(revision 11527)
@@ -9,11 +9,12 @@
 
 %Fields and tolerances to track changes
-field_names     ={'Vx1','Vy1','Vz1','Vel1','Pressure1','Bed1','Surface1','Thickness1','Temperature1','BasalforcingsMeltingRate1', ...
-				      'Vx2','Vy2','Vz2','Vel2','Pressure2','Bed2','Surface2','Thickness2','Temperature2','BasalforcingsMeltingRate2', ...
-					   'Vx3','Vy3','Vz3','Vel3','Pressure3','Bed3','Surface3','Thickness3','Temperature3','BasalforcingsMeltingRate3'};
+field_names={...
+	'Vx1','Vy1','Vz1','Vel1','Pressure1','Bed1','Surface1','Thickness1','Temperature1','BasalforcingsMeltingRate1', ...
+	'Vx2','Vy2','Vz2','Vel2','Pressure2','Bed2','Surface2','Thickness2','Temperature2','BasalforcingsMeltingRate2', ...
+	'Vx3','Vy3','Vz3','Vel3','Pressure3','Bed3','Surface3','Thickness3','Temperature3','BasalforcingsMeltingRate3'};
 field_tolerances={...
 	1e-08,1e-08,1e-06,1e-08,1e-08,1e-08,1e-08,1e-08,1e-08,1e-08,...
-	1e-08,1e-08,1e-06,1e-08,1e-08,1e-08,1e-08,1e-08,1e-08,1e-07,...
-	1e-07,1e-08,1e-06,1e-08,1e-08,1e-08,1e-08,1e-08,1e-08,1e-06};
+	1e-08,1e-08,1e-06,1e-08,1e-08,1e-08,1e-08,1e-08,1e-08,1e-06,...
+	1e-07,1e-07,1e-06,1e-08,1e-08,1e-08,1e-08,1e-08,1e-08,1e-06};
 field_values={...
 	(md.results.TransientSolution(1).Vx),...
Index: /issm/trunk/test/NightlyRun/test223.m
===================================================================
--- /issm/trunk/test/NightlyRun/test223.m	(revision 11526)
+++ /issm/trunk/test/NightlyRun/test223.m	(revision 11527)
@@ -18,5 +18,4 @@
 
 md.cluster=none;
-md.verbose=verbose('all');
 md=solve(md,DiagnosticSolutionEnum);
 
Index: /issm/trunk/test/NightlyRun/test266.m
===================================================================
--- /issm/trunk/test/NightlyRun/test266.m	(revision 11526)
+++ /issm/trunk/test/NightlyRun/test266.m	(revision 11527)
@@ -16,5 +16,5 @@
 					   'Vx4','Vy4','Vz4','Vel4','Pressure4','Bed4','Surface4','Thickness4','Temperature4','BasalforcingsMeltingRate4'};
 field_tolerances={1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09, ...
-						1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09, ...
+						1e-09,1e-09,1e-08,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-07, ...
 						1e-09,1e-09,1e-08,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-06, ...
 						1e-09,1e-09,1e-08,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-06};
Index: /issm/trunk/test/NightlyRun/test314.m
===================================================================
--- /issm/trunk/test/NightlyRun/test314.m	(revision 11526)
+++ /issm/trunk/test/NightlyRun/test314.m	(revision 11527)
@@ -9,5 +9,5 @@
 %Fields and tolerances to track changes
 field_names     ={'Vx','Vy','Vz','Vel','Pressure'};
-field_tolerances={1e-09,1e-09,1e-10,1e-10,1e-10};
+field_tolerances={1e-09,1e-09,1e-10,2e-10,1e-10};
 field_values={...
 	(md.results.DiagnosticSolution.Vx),...
Index: /issm/trunk/test/NightlyRun/test349.m
===================================================================
--- /issm/trunk/test/NightlyRun/test349.m	(revision 11527)
+++ /issm/trunk/test/NightlyRun/test349.m	(revision 11527)
@@ -0,0 +1,18 @@
+md=triangle(model,'../Exp/Square.exp',180000);
+md=setmask(md,'','');
+md=parameterize(md,'../Par/SquareSheetConstrained.par');
+md=extrude(md,3,1);
+md=setflowequation(md,'macayeal','all');
+md.initialization.waterfraction=zeros(md.mesh.numberofvertices,1);
+md.timestepping.time_step=0;
+md.cluster=none;
+md=solve(md,EnthalpySolutionEnum);
+
+%Fields and tolerances to track changes
+field_names     ={'Enthalpy','Waterfraction','Temperature'};
+field_tolerances={1e-13,1e-13,1e-13};
+field_values={...
+	(md.results.EnthalpySolution.Enthalpy),...
+	(md.results.EnthalpySolution.Waterfraction),...
+	(md.results.EnthalpySolution.Temperature),...
+	};
Index: /issm/trunk/test/NightlyRun/test350.m
===================================================================
--- /issm/trunk/test/NightlyRun/test350.m	(revision 11527)
+++ /issm/trunk/test/NightlyRun/test350.m	(revision 11527)
@@ -0,0 +1,18 @@
+md=triangle(model,'../Exp/Square.exp',180000);
+md=setmask(md,'','');
+md=parameterize(md,'../Par/SquareSheetConstrained.par');
+md=extrude(md,3,1);
+md=setflowequation(md,'macayeal','all');
+md.timestepping.time_step=0;
+md.cluster=generic('name',oshostname(),'np',3);
+md.initialization.waterfraction=zeros(md.mesh.numberofvertices,1);
+md=solve(md,EnthalpySolutionEnum);
+
+%Fields and tolerances to track changes
+field_names     ={'Enthalpy','Waterfraction','Temperature'};
+field_tolerances={1e-13,1e-13,1e-13};
+field_values={...
+	(md.results.EnthalpySolution.Enthalpy),...
+	(md.results.EnthalpySolution.Waterfraction),...
+	(md.results.EnthalpySolution.Temperature),...
+	};
Index: /issm/trunk/test/NightlyRun/test351.m
===================================================================
--- /issm/trunk/test/NightlyRun/test351.m	(revision 11527)
+++ /issm/trunk/test/NightlyRun/test351.m	(revision 11527)
@@ -0,0 +1,25 @@
+md=triangle(model,'../Exp/Square.exp',180000);
+md=setmask(md,'','');
+md=parameterize(md,'../Par/SquareSheetConstrained.par');
+md=extrude(md,3,1);
+md=setflowequation(md,'macayeal','all');
+md.initialization.waterfraction=zeros(md.mesh.numberofvertices,1);
+md.cluster=none;
+md=solve(md,EnthalpySolutionEnum);
+
+%Fields and tolerances to track changes
+field_names     ={'Enthalpy1','Waterfraction1','Temperature1',...
+	'Enthalpy2','Waterfraction2','Temperature2',...
+	'Enthalpy3','Waterfraction3','Temperature3'};
+field_tolerances={1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13};
+field_values={...
+	(md.results.EnthalpySolution(1).Enthalpy),...
+	(md.results.EnthalpySolution(1).Waterfraction),...
+	(md.results.EnthalpySolution(1).Temperature),...
+	(md.results.EnthalpySolution(2).Enthalpy),...
+	(md.results.EnthalpySolution(2).Waterfraction),...
+	(md.results.EnthalpySolution(2).Temperature),...
+	(md.results.EnthalpySolution(3).Enthalpy),...
+	(md.results.EnthalpySolution(3).Waterfraction),...
+	(md.results.EnthalpySolution(3).Temperature),...
+	};
Index: /issm/trunk/test/NightlyRun/test352.m
===================================================================
--- /issm/trunk/test/NightlyRun/test352.m	(revision 11527)
+++ /issm/trunk/test/NightlyRun/test352.m	(revision 11527)
@@ -0,0 +1,26 @@
+md=triangle(model,'../Exp/Square.exp',180000);
+md=setmask(md,'','');
+md=parameterize(md,'../Par/SquareSheetConstrained.par');
+md=extrude(md,3,1);
+md=setflowequation(md,'macayeal','all');
+md.cluster=generic('name',oshostname(),'np',3);
+md.initialization.waterfraction=zeros(md.mesh.numberofvertices,1);
+%md=solve(md,ThermalSolutionEnum);
+md=solve(md,EnthalpySolutionEnum);
+
+%Fields and tolerances to track changes
+field_names     ={'Enthalpy1','Waterfraction1','Temperature1',...
+	'Enthalpy2','Waterfraction2','Temperature2',...
+	'Enthalpy3','Waterfraction3','Temperature3'};
+field_tolerances={1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13};
+field_values={...
+	(md.results.EnthalpySolution(1).Enthalpy),...
+	(md.results.EnthalpySolution(1).Waterfraction),...
+	(md.results.EnthalpySolution(1).Temperature),...
+	(md.results.EnthalpySolution(2).Enthalpy),...
+	(md.results.EnthalpySolution(2).Waterfraction),...
+	(md.results.EnthalpySolution(2).Temperature),...
+	(md.results.EnthalpySolution(3).Enthalpy),...
+	(md.results.EnthalpySolution(3).Waterfraction),...
+	(md.results.EnthalpySolution(3).Temperature),...
+	};
Index: /issm/trunk/test/NightlyRun/test353.m
===================================================================
--- /issm/trunk/test/NightlyRun/test353.m	(revision 11527)
+++ /issm/trunk/test/NightlyRun/test353.m	(revision 11527)
@@ -0,0 +1,55 @@
+md=triangle(model,'../Exp/Square.exp',200000);
+md=setmask(md,'','');
+md=parameterize(md,'../Par/SquareSheetConstrained.par');
+md=extrude(md,3,1);
+md=setflowequation(md,'pattyn','all');
+md.cluster=none;
+md.initialization.waterfraction=zeros(md.mesh.numberofvertices,1);
+md.initialization.temperature(:)=272;
+md.thermal.spctemperature(find(md.mesh.vertexonsurface))=272;
+md.thermal.isenthalpy=1;
+md.basalforcings.geothermalflux(:)=5;
+md=solve(md,TransientSolutionEnum);
+
+%Fields and tolerances to track changes
+field_names     ={'Vx1','Vy1','Vz1','Vel1','Pressure1','Bed1','Surface1','Thickness1','Temperature1','Enthalpy1','Waterfraction1', ...
+				      'Vx2','Vy2','Vz2','Vel2','Pressure2','Bed2','Surface2','Thickness2','Temperature2','Enthalpy2','Waterfraction2', ...
+					   'Vx3','Vy3','Vz3','Vel3','Pressure3','Bed3','Surface3','Thickness3','Temperature3','Enthalpy3','Waterfraction3'};
+field_tolerances={1e-09,1e-09,1e-09,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,...
+						1e-09,1e-09,1e-10,1e-09,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,...
+						1e-09,5e-10,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10};
+field_values={...
+	(md.results.TransientSolution(1).Vx),...
+	(md.results.TransientSolution(1).Vy),...
+	(md.results.TransientSolution(1).Vz),...
+	(md.results.TransientSolution(1).Vel),...
+	(md.results.TransientSolution(1).Pressure),...
+	(md.results.TransientSolution(1).Bed),...
+	(md.results.TransientSolution(1).Surface),...
+	(md.results.TransientSolution(1).Thickness),...
+	(md.results.TransientSolution(1).Temperature),...
+	(md.results.TransientSolution(1).Enthalpy),...
+	(md.results.TransientSolution(1).Waterfraction),...
+	(md.results.TransientSolution(2).Vx),...
+	(md.results.TransientSolution(2).Vy),...
+	(md.results.TransientSolution(2).Vz),...
+	(md.results.TransientSolution(2).Vel),...
+	(md.results.TransientSolution(2).Pressure),...
+	(md.results.TransientSolution(2).Bed),...
+	(md.results.TransientSolution(2).Surface),...
+	(md.results.TransientSolution(2).Thickness),...
+	(md.results.TransientSolution(2).Temperature),...
+	(md.results.TransientSolution(2).Enthalpy),...
+	(md.results.TransientSolution(2).Waterfraction),...
+	(md.results.TransientSolution(3).Vx),...
+	(md.results.TransientSolution(3).Vy),...
+	(md.results.TransientSolution(3).Vz),...
+	(md.results.TransientSolution(3).Vel),...
+	(md.results.TransientSolution(3).Pressure),...
+	(md.results.TransientSolution(3).Bed),...
+	(md.results.TransientSolution(3).Surface),...
+	(md.results.TransientSolution(3).Thickness),...
+	(md.results.TransientSolution(3).Temperature),...
+	(md.results.TransientSolution(3).Enthalpy),...
+	(md.results.TransientSolution(3).Waterfraction),...
+	};
Index: /issm/trunk/test/NightlyRun/test354.m
===================================================================
--- /issm/trunk/test/NightlyRun/test354.m	(revision 11527)
+++ /issm/trunk/test/NightlyRun/test354.m	(revision 11527)
@@ -0,0 +1,55 @@
+md=triangle(model,'../Exp/Square.exp',200000);
+md=setmask(md,'','');
+md=parameterize(md,'../Par/SquareSheetConstrained.par');
+md=extrude(md,3,1);
+md=setflowequation(md,'pattyn','all');
+md.cluster=generic('name',oshostname(),'np',3);
+md.initialization.waterfraction=zeros(md.mesh.numberofvertices,1);
+md.initialization.temperature(:)=272;
+md.thermal.spctemperature(find(md.mesh.vertexonsurface))=272;
+md.thermal.isenthalpy=1;
+md.basalforcings.geothermalflux(:)=5;
+md=solve(md,TransientSolutionEnum);
+
+%Fields and tolerances to track changes
+field_names     ={'Vx1','Vy1','Vz1','Vel1','Pressure1','Bed1','Surface1','Thickness1','Temperature1','Enthalpy1','Waterfraction1', ...
+				      'Vx2','Vy2','Vz2','Vel2','Pressure2','Bed2','Surface2','Thickness2','Temperature2','Enthalpy2','Waterfraction2', ...
+					   'Vx3','Vy3','Vz3','Vel3','Pressure3','Bed3','Surface3','Thickness3','Temperature3','Enthalpy3','Waterfraction3'};
+field_tolerances={1e-09,1e-09,1e-09,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,...
+						1e-09,1e-09,1e-10,1e-09,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,...
+						1e-09,5e-10,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10};
+field_values={...
+	(md.results.TransientSolution(1).Vx),...
+	(md.results.TransientSolution(1).Vy),...
+	(md.results.TransientSolution(1).Vz),...
+	(md.results.TransientSolution(1).Vel),...
+	(md.results.TransientSolution(1).Pressure),...
+	(md.results.TransientSolution(1).Bed),...
+	(md.results.TransientSolution(1).Surface),...
+	(md.results.TransientSolution(1).Thickness),...
+	(md.results.TransientSolution(1).Temperature),...
+	(md.results.TransientSolution(1).Enthalpy),...
+	(md.results.TransientSolution(1).Waterfraction),...
+	(md.results.TransientSolution(2).Vx),...
+	(md.results.TransientSolution(2).Vy),...
+	(md.results.TransientSolution(2).Vz),...
+	(md.results.TransientSolution(2).Vel),...
+	(md.results.TransientSolution(2).Pressure),...
+	(md.results.TransientSolution(2).Bed),...
+	(md.results.TransientSolution(2).Surface),...
+	(md.results.TransientSolution(2).Thickness),...
+	(md.results.TransientSolution(2).Temperature),...
+	(md.results.TransientSolution(2).Enthalpy),...
+	(md.results.TransientSolution(2).Waterfraction),...
+	(md.results.TransientSolution(3).Vx),...
+	(md.results.TransientSolution(3).Vy),...
+	(md.results.TransientSolution(3).Vz),...
+	(md.results.TransientSolution(3).Vel),...
+	(md.results.TransientSolution(3).Pressure),...
+	(md.results.TransientSolution(3).Bed),...
+	(md.results.TransientSolution(3).Surface),...
+	(md.results.TransientSolution(3).Thickness),...
+	(md.results.TransientSolution(3).Temperature),...
+	(md.results.TransientSolution(3).Enthalpy),...
+	(md.results.TransientSolution(3).Waterfraction),...
+	};
Index: /issm/trunk/test/NightlyRun/test430.m
===================================================================
--- /issm/trunk/test/NightlyRun/test430.m	(revision 11526)
+++ /issm/trunk/test/NightlyRun/test430.m	(revision 11527)
@@ -24,5 +24,5 @@
 %Fields and tolerances to track changes
 field_names     ={'Gradient' 'Misfits' 'FrictionCoefficient' 'Pressure' 'Vel' 'Vx' 'Vy' 'Vz' 'Temperature' 'BasalforcingsMeltingRate'};
-field_tolerances={1e-10,1e-10,1e-11,1e-13,1e-10,1e-09,1e-10,1e-8,1e-10,1e-6};
+field_tolerances={1e-10,1e-10,1e-11,1e-13,1e-10,1e-09,1e-10,1e-8,1e-09,1e-6};
 field_values={...
 	(md.results.SteadystateSolution.Gradient1),...
Index: /issm/trunk/test/NightlyRun/test525.m
===================================================================
--- /issm/trunk/test/NightlyRun/test525.m	(revision 11526)
+++ /issm/trunk/test/NightlyRun/test525.m	(revision 11527)
@@ -19,4 +19,5 @@
 md.timestepping.time_step=0;
 
+md.thermal.penalty_lock=5;
 md.cluster=none;
 md=solve(md,SteadystateSolutionEnum);
Index: /issm/trunk/test/NightlyRun/test526.m
===================================================================
--- /issm/trunk/test/NightlyRun/test526.m	(revision 11526)
+++ /issm/trunk/test/NightlyRun/test526.m	(revision 11527)
@@ -19,4 +19,5 @@
 md.timestepping.time_step=0;
 
+md.thermal.penalty_lock=5;
 md.cluster=generic('name',oshostname(),'np',3);
 md=solve(md,SteadystateSolutionEnum);
Index: /issm/trunk/test/NightlyRun/test626.m
===================================================================
--- /issm/trunk/test/NightlyRun/test626.m	(revision 11526)
+++ /issm/trunk/test/NightlyRun/test626.m	(revision 11527)
@@ -25,4 +25,5 @@
 md.inversion.step_threshold=0.99*ones(md.inversion.nsteps,1);
 
+md.verbose.control=1;
 md.cluster=generic('name',oshostname(),'np',3);
 md=solve(md,BalancethicknessSolutionEnum);
