Index: /issm/trunk/CMakeLists.txt
===================================================================
--- /issm/trunk/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,74 @@
+# CMake version check. Version 2.6 is considered standard.
+cmake_minimum_required (VERSION 2.6) 
+
+# Project Information {{{
+# Project Name
+project(ISSM) 
+set(ISSM_VERSION_MAJOR 4)
+set(ISSM_VERSION_MINOR 1)
+# }}}
+# Contact Information {{{
+set(ISSM_EMAIL "issm@jpl.nasa.gov")
+set(ISSM_WEBSITE "http://issm.jpl.nasa.gov")
+# }}}
+
+# Environment Variables {{{
+# Out of source build can be done here.
+set(CMAKE_BINARY_DIR ${ISSM_DIR})
+# }}}
+
+# Install Targets {{{
+# Install 'issm.exe'
+#install(TARGETS issm RUNTIME)
+
+# Install 'libISSMCore.a' and 'libISSMOverload.a'
+# install(TARGETS ISSMCore
+#                ISSMOverload
+#        ARCHIVE)
+# }}}
+# Optional Install {{{
+#if(${SHARED_LIBS} IS ON)
+#   install(TARGETS ISSMCore
+#                   ISSMOverload
+#           LIBRARY)
+#endif(${SHARED_LIBS} IS ON)
+# }}}
+
+# Language Checks {{{
+
+# 'C' language check.
+include(CheckLanguage)
+
+check_language(C)
+if(CMAKE_C_COMPILER)
+   enable_language(C)
+else(CMAKE_C_COMPILER)
+   message(FATAL_ERROR "No C support found!")
+endif(CMAKE_C_COMPILER)
+
+# 'C++' language check.
+check_language(CXX)
+if(CMAKE_CXX_COMPILER)
+   enable_language(CXX)
+else(CMAKE_CXX_COMPILER)
+   message(FATA_ERROR "No C++ support found!")
+endif(CMAKE_CXX_COMPILER)
+
+# 'Fortran' language check.
+#check_language(Fortran)
+#if(CMAKE_Fortran_COMPILER)
+#   enable_language(Fortran)
+#else(CMAKE_Fortran_COMPILER)
+#   message(FATA_ERROR "No Fortran support")
+#endif(CMAKE_Fortran_COMPILER)
+# }}}
+
+# Subdirectories {{{
+add_subdirectory(src) 
+# }}}
+
+# Options {{{
+option(SHARED_LIBS "Set whether to produce shared libraries, or not. Default is no."
+       OFF)
+# Questionable whether all options should be contained within this file or included from some other file.
+# }}}
Index: /issm/trunk/configs/config-arm-linux.sh
===================================================================
--- /issm/trunk/configs/config-arm-linux.sh	(revision 14309)
+++ /issm/trunk/configs/config-arm-linux.sh	(revision 14310)
@@ -6,5 +6,6 @@
     --host="arm-linux-androideabi" \
     --enable-shared \
-    --with-android=jni\
+    --with-android=jni \
+	--with-android-ndk=$ISSM_DIR/externalpackages/android/android-ndk/install \
     --without-fortran \
 	--without-wrappers \
Index: /issm/trunk/configs/config-hoffman2.sh
===================================================================
--- /issm/trunk/configs/config-hoffman2.sh	(revision 14310)
+++ /issm/trunk/configs/config-hoffman2.sh	(revision 14310)
@@ -0,0 +1,18 @@
+#!/bin/csh
+
+./configure \
+ --prefix=$ISSM_DIR \
+ --with-wrappers=no \
+ --with-metis-dir=$ISSM_DIR/externalpackages/metis/install \
+ --with-petsc-dir=$ISSM_DIR/externalpackages/petsc/install \
+ --with-mpi-include=/u/local/intel/11.1/openmpi/1.4.5/include \
+ --with-mpi-lib="-L/u/local/intel/11.1/openmpi/1.4.5/include -lmpi" \
+ --with-petsc-arch=$ISSM_ARCH \
+ --with-plapack-lib="-L$ISSM_DIR/externalpackages/petsc/install/ -lPLAPACK" \
+ --with-plapack-include="-I$ISSM_DIR/externalpackages/petsc/install/externalpackages/PLAPACKR32-hg/INCLUDE" \
+ --with-mumps-dir=$ISSM_DIR/externalpackages/petsc/install/ \
+ --with-blas-lapack-dir=$ISSM_DIR/externalpackages/petsc/install \
+ --with-scalapack-dir=$ISSM_DIR/externalpackages/petsc/install/ \
+ --with-blacs-dir=$ISSM_DIR/externalpackages/petsc/install/ \
+ --with-graphics-lib=/usr/lib64/libX11.so \
+ --with-cxxoptflags="-O3 -L/u/local/intel/11.1/openmpi/1.4.5/lib -lmpi -lmpi_f77 -lmpi_cxx"
Index: /issm/trunk/configure.ac
===================================================================
--- /issm/trunk/configure.ac	(revision 14309)
+++ /issm/trunk/configure.ac	(revision 14310)
@@ -2,5 +2,5 @@
 
 #AUTOCONF
-AC_INIT([ISSM],[4.2.4],[issm@jpl.nasa.gov],[issm],[http://issm.jpl.nasa.gov]) #Initializing configure
+AC_INIT([ISSM],[4.2.5],[issm@jpl.nasa.gov],[issm],[http://issm.jpl.nasa.gov]) #Initializing configure
 AC_CONFIG_AUX_DIR([./aux-config])         #Put config files in aux-config
 AC_CONFIG_MACRO_DIR([m4])                 #m4 macros are located in m4
Index: /issm/trunk/externalpackages/adolc/install-dev.sh
===================================================================
--- /issm/trunk/externalpackages/adolc/install-dev.sh	(revision 14309)
+++ /issm/trunk/externalpackages/adolc/install-dev.sh	(revision 14310)
@@ -6,4 +6,5 @@
 
 git clone -b 2.3.x_ISSM  git://git.mcs.anl.gov/adol-c.git adolc_issm
+#git reset --hard b254b2a001a1b7a024a9184cd087ae06eb975cad
 
 #Compile ADOL-C
Index: /issm/trunk/externalpackages/adolc/install-update-dev.sh
===================================================================
--- /issm/trunk/externalpackages/adolc/install-update-dev.sh	(revision 14309)
+++ /issm/trunk/externalpackages/adolc/install-update-dev.sh	(revision 14310)
@@ -15,4 +15,5 @@
 cd adolc_issm
 git pull
+#git reset --hard b254b2a001a1b7a024a9184cd087ae06eb975cad
 
 autoreconf -f -i 
Index: sm/trunk/externalpackages/dakota/LHSDriver.cpp.patch
===================================================================
--- /issm/trunk/externalpackages/dakota/LHSDriver.cpp.patch	(revision 14309)
+++ 	(revision )
@@ -1,8 +1,0 @@
-766c766
-<   /*char output_string[32], message_string[32], title_string[32],
----
->   char output_string[32], message_string[32], title_string[32],
-802c802
-<   check_error(err_code, "lhs_files");*/
----
->   check_error(err_code, "lhs_files");
Index: sm/trunk/externalpackages/dakota/NIDRProblemDescDB.C.patch
===================================================================
--- /issm/trunk/externalpackages/dakota/NIDRProblemDescDB.C.patch	(revision 14309)
+++ 	(revision )
@@ -1,4 +1,0 @@
-95a96,98
->   
->   //close the input file
->   fclose(nidrin);
Index: sm/trunk/externalpackages/dakota/NonDLocalReliability.C.patch
===================================================================
--- /issm/trunk/externalpackages/dakota/NonDLocalReliability.C.patch	(revision 14309)
+++ 	(revision )
@@ -1,7 +1,0 @@
-2276a2277
-> 	  // add sensitivity output to importance factors (jes, 8/06/10)
-2280c2281,2282
-< 	    << impFactor[i][j] << '\n';
----
-> 	    << impFactor[i][j] << "  Sensitivity = " << setw(write_precision+7)
-> 	    << fnGradsMeanX(i, j) << '\n';
Index: sm/trunk/externalpackages/dakota/NonDSampling.C.patch
===================================================================
--- /issm/trunk/externalpackages/dakota/NonDSampling.C.patch	(revision 14309)
+++ 	(revision )
@@ -1,15 +1,0 @@
-656a657,658
-> 
-> 
-659a662,663
->    
-> 	return; //don't compute for now, too expensive.
-705c709
-<   //calculate simple rank correlation coeff
----
->   //calculate simple correlation coeff
-710a715
-> 
-1071a1077,1078
-> 
-> 	return; //don't output for now.
Index: sm/trunk/externalpackages/dakota/NonDUnilevelRBDO.C.patch
===================================================================
--- /issm/trunk/externalpackages/dakota/NonDUnilevelRBDO.C.patch	(revision 14309)
+++ 	(revision )
@@ -1,10 +1,0 @@
-1052,1053c1052,1057
-< 	  s << "  Importance Factor for variable " << setw(11)
-< 	    << uv_labels[j].data() << " = " << impFactor[i][j] << '\n';
----
-> 	  // add sensitivity output to importance factors (jes, 8/06/10)
-> 	  s << "  Importance Factor for variable " << setiosflags(ios::left)
-> 	    << setw(11) << uv_labels[j].data() << " = "
-> 	    << resetiosflags(ios::adjustfield) << setw(write_precision+7)
-> 	    << impFactor[i][j] << "  Sensitivity = " << setw(write_precision+7)
-> 	    << fnGradsMeanX(i, j) << '\n';
Index: sm/trunk/externalpackages/dakota/ParallelLibrary.C.patch
===================================================================
--- /issm/trunk/externalpackages/dakota/ParallelLibrary.C.patch	(revision 14309)
+++ 	(revision )
@@ -1,34 +1,0 @@
-134a135
->   initialized=0; //we run serially all the time!
-165a167,197
-> /** This constructor is provided for the Issm software, to run serial 
->  * Dakota in a parallel MPI ring: */
-> ParallelLibrary::ParallelLibrary(char* serial_mode): worldRank(0), worldSize(1),
->   mpirunFlag(false), ownMPIFlag(false), dryRunFlag(false), dummyFlag(false),
->   stdOutputFlag(false), stdErrorFlag(false), startClock(0),
->   stdOutputFilename(NULL), stdErrorFilename(NULL), readRestartFilename(NULL),
->   writeRestartFilename(NULL), stopRestartEvals(0),
->   currPLIter(parallelLevels.end()), currPCIter(parallelConfigurations.end())
-> {
->   startClock   = clock();
-> #ifdef DAKOTA_UTILIB
->   utilib::exception_mngr::set_mode(utilib::exception_mngr::Abort);
->   startCPUTime = CPUSeconds();       // see utilib/src/sys/seconds.cpp
->   startWCTime  = WallClockSeconds(); // see utilib/src/sys/seconds.cpp
-> #endif // DAKOTA_UTILIB
-> 
->   // do not initialize MPI.  Get worldRank/worldSize if available
->   ParallelLevel pl;
-> #ifdef HAVE_MPI // mpi available, we still don't want to run in parallel for  Dakota!
->   pl.serverIntraComm = MPI_COMM_NULL;
->   Cout << "Running Dakota in serial mode on CPU 0, inside an MPI ring.";
-> #else // mpi not available
->   pl.serverIntraComm = MPI_COMM_NULL;
->   Cout << "Running Dakota in serial mode.\n";
-> #endif // HAVE_MPI
-> 
->   parallelLevels.insert(pl);
->   currPLIter = parallelLevels.begin();
->   increment_parallel_configuration();
-> }
-> 
Index: sm/trunk/externalpackages/dakota/ParallelLibrary.H.patch
===================================================================
--- /issm/trunk/externalpackages/dakota/ParallelLibrary.H.patch	(revision 14309)
+++ 	(revision )
@@ -1,3 +1,0 @@
-346a347,348
->   /// library mode constructor, serial mode
->   ParallelLibrary(char*  serial_mode);
Index: /issm/trunk/externalpackages/dakota/configs/4.2/LHSDriver.cpp.patch
===================================================================
--- /issm/trunk/externalpackages/dakota/configs/4.2/LHSDriver.cpp.patch	(revision 14310)
+++ /issm/trunk/externalpackages/dakota/configs/4.2/LHSDriver.cpp.patch	(revision 14310)
@@ -0,0 +1,8 @@
+766c766
+<   /*char output_string[32], message_string[32], title_string[32],
+---
+>   char output_string[32], message_string[32], title_string[32],
+802c802
+<   check_error(err_code, "lhs_files");*/
+---
+>   check_error(err_code, "lhs_files");
Index: /issm/trunk/externalpackages/dakota/configs/4.2/NIDRProblemDescDB.C.patch
===================================================================
--- /issm/trunk/externalpackages/dakota/configs/4.2/NIDRProblemDescDB.C.patch	(revision 14310)
+++ /issm/trunk/externalpackages/dakota/configs/4.2/NIDRProblemDescDB.C.patch	(revision 14310)
@@ -0,0 +1,4 @@
+95a96,98
+>   
+>   //close the input file
+>   fclose(nidrin);
Index: /issm/trunk/externalpackages/dakota/configs/4.2/NonDLocalReliability.C.patch
===================================================================
--- /issm/trunk/externalpackages/dakota/configs/4.2/NonDLocalReliability.C.patch	(revision 14310)
+++ /issm/trunk/externalpackages/dakota/configs/4.2/NonDLocalReliability.C.patch	(revision 14310)
@@ -0,0 +1,7 @@
+2276a2277
+> 	  // add sensitivity output to importance factors (jes, 8/06/10)
+2280c2281,2282
+< 	    << impFactor[i][j] << '\n';
+---
+> 	    << impFactor[i][j] << "  Sensitivity = " << setw(write_precision+7)
+> 	    << fnGradsMeanX(i, j) << '\n';
Index: /issm/trunk/externalpackages/dakota/configs/4.2/NonDSampling.C.patch
===================================================================
--- /issm/trunk/externalpackages/dakota/configs/4.2/NonDSampling.C.patch	(revision 14310)
+++ /issm/trunk/externalpackages/dakota/configs/4.2/NonDSampling.C.patch	(revision 14310)
@@ -0,0 +1,15 @@
+656a657,658
+> 
+> 
+659a662,663
+>    
+> 	return; //don't compute for now, too expensive.
+705c709
+<   //calculate simple rank correlation coeff
+---
+>   //calculate simple correlation coeff
+710a715
+> 
+1071a1077,1078
+> 
+> 	return; //don't output for now.
Index: /issm/trunk/externalpackages/dakota/configs/4.2/NonDUnilevelRBDO.C.patch
===================================================================
--- /issm/trunk/externalpackages/dakota/configs/4.2/NonDUnilevelRBDO.C.patch	(revision 14310)
+++ /issm/trunk/externalpackages/dakota/configs/4.2/NonDUnilevelRBDO.C.patch	(revision 14310)
@@ -0,0 +1,10 @@
+1052,1053c1052,1057
+< 	  s << "  Importance Factor for variable " << setw(11)
+< 	    << uv_labels[j].data() << " = " << impFactor[i][j] << '\n';
+---
+> 	  // add sensitivity output to importance factors (jes, 8/06/10)
+> 	  s << "  Importance Factor for variable " << setiosflags(ios::left)
+> 	    << setw(11) << uv_labels[j].data() << " = "
+> 	    << resetiosflags(ios::adjustfield) << setw(write_precision+7)
+> 	    << impFactor[i][j] << "  Sensitivity = " << setw(write_precision+7)
+> 	    << fnGradsMeanX(i, j) << '\n';
Index: /issm/trunk/externalpackages/dakota/configs/4.2/ParallelLibrary.C.patch
===================================================================
--- /issm/trunk/externalpackages/dakota/configs/4.2/ParallelLibrary.C.patch	(revision 14310)
+++ /issm/trunk/externalpackages/dakota/configs/4.2/ParallelLibrary.C.patch	(revision 14310)
@@ -0,0 +1,34 @@
+134a135
+>   initialized=0; //we run serially all the time!
+165a167,197
+> /** This constructor is provided for the Issm software, to run serial 
+>  * Dakota in a parallel MPI ring: */
+> ParallelLibrary::ParallelLibrary(char* serial_mode): worldRank(0), worldSize(1),
+>   mpirunFlag(false), ownMPIFlag(false), dryRunFlag(false), dummyFlag(false),
+>   stdOutputFlag(false), stdErrorFlag(false), startClock(0),
+>   stdOutputFilename(NULL), stdErrorFilename(NULL), readRestartFilename(NULL),
+>   writeRestartFilename(NULL), stopRestartEvals(0),
+>   currPLIter(parallelLevels.end()), currPCIter(parallelConfigurations.end())
+> {
+>   startClock   = clock();
+> #ifdef DAKOTA_UTILIB
+>   utilib::exception_mngr::set_mode(utilib::exception_mngr::Abort);
+>   startCPUTime = CPUSeconds();       // see utilib/src/sys/seconds.cpp
+>   startWCTime  = WallClockSeconds(); // see utilib/src/sys/seconds.cpp
+> #endif // DAKOTA_UTILIB
+> 
+>   // do not initialize MPI.  Get worldRank/worldSize if available
+>   ParallelLevel pl;
+> #ifdef HAVE_MPI // mpi available, we still don't want to run in parallel for  Dakota!
+>   pl.serverIntraComm = MPI_COMM_NULL;
+>   Cout << "Running Dakota in serial mode on CPU 0, inside an MPI ring.";
+> #else // mpi not available
+>   pl.serverIntraComm = MPI_COMM_NULL;
+>   Cout << "Running Dakota in serial mode.\n";
+> #endif // HAVE_MPI
+> 
+>   parallelLevels.insert(pl);
+>   currPLIter = parallelLevels.begin();
+>   increment_parallel_configuration();
+> }
+> 
Index: /issm/trunk/externalpackages/dakota/configs/4.2/ParallelLibrary.H.patch
===================================================================
--- /issm/trunk/externalpackages/dakota/configs/4.2/ParallelLibrary.H.patch	(revision 14310)
+++ /issm/trunk/externalpackages/dakota/configs/4.2/ParallelLibrary.H.patch	(revision 14310)
@@ -0,0 +1,3 @@
+346a347,348
+>   /// library mode constructor, serial mode
+>   ParallelLibrary(char*  serial_mode);
Index: /issm/trunk/externalpackages/dakota/configs/5.2/NIDRProblemDescDB.C.patch
===================================================================
--- /issm/trunk/externalpackages/dakota/configs/5.2/NIDRProblemDescDB.C.patch	(revision 14310)
+++ /issm/trunk/externalpackages/dakota/configs/5.2/NIDRProblemDescDB.C.patch	(revision 14310)
@@ -0,0 +1,5 @@
+109a110,113
+> 
+>   //close the input file
+>   fclose(nidrin);
+> 
Index: /issm/trunk/externalpackages/dakota/configs/5.2/NonDLocalReliability.C.patch
===================================================================
--- /issm/trunk/externalpackages/dakota/configs/5.2/NonDLocalReliability.C.patch	(revision 14310)
+++ /issm/trunk/externalpackages/dakota/configs/5.2/NonDLocalReliability.C.patch	(revision 14310)
@@ -0,0 +1,9 @@
+2218a2219
+> 	  // add sensitivity output to importance factors (jes, 8/06/10)
+2223c2224,2227
+< 	    << std::setw(width) << impFactor(j,i) << '\n';
+---
+> 	    << std::setw(width) << impFactor(j,i)
+> 	    << "  Sensitivity = "
+> 	    << std::resetiosflags(std::ios::adjustfield)
+> 	    << std::setw(width) << fnGradsMeanX(j,i) << '\n';
Index: /issm/trunk/externalpackages/dakota/configs/5.2/NonDSampling.C.patch
===================================================================
--- /issm/trunk/externalpackages/dakota/configs/5.2/NonDSampling.C.patch	(revision 14310)
+++ /issm/trunk/externalpackages/dakota/configs/5.2/NonDSampling.C.patch	(revision 14310)
@@ -0,0 +1,14 @@
+438,439c438,440
+<   if (!subIteratorFlag)
+<     nonDSampCorr.compute_correlations(vars_samples, resp_samples);
+---
+> //don't compute for now, too expensive.
+> //  if (!subIteratorFlag)
+> //    nonDSampCorr.compute_correlations(vars_samples, resp_samples);
+894,895c895,897
+<     nonDSampCorr.print_correlations(s, cv_labels, div_labels, drv_labels,
+<       iteratedModel.response_labels());
+---
+> //don't output for now.
+> //    nonDSampCorr.print_correlations(s, cv_labels, div_labels, drv_labels,
+> //      iteratedModel.response_labels());
Index: /issm/trunk/externalpackages/dakota/configs/5.2/NonDUnilevelRBDO.C.patch
===================================================================
--- /issm/trunk/externalpackages/dakota/configs/5.2/NonDUnilevelRBDO.C.patch	(revision 14310)
+++ /issm/trunk/externalpackages/dakota/configs/5.2/NonDUnilevelRBDO.C.patch	(revision 14310)
@@ -0,0 +1,7 @@
+1046a1047
+> 	  // add sensitivity output to importance factors (jes, 8/06/10)
+1048c1049,1050
+< 	    << uv_labels[j].data() << " = " << impFactor[i][j] << '\n';
+---
+> 	    << uv_labels[j].data() << " = " << impFactor[i][j]
+> 	    << "  Sensitivity = " << fnGradsMeanX(i,j) << '\n';
Index: /issm/trunk/externalpackages/dakota/configs/5.2/ParallelLibrary.C.patch
===================================================================
--- /issm/trunk/externalpackages/dakota/configs/5.2/ParallelLibrary.C.patch	(revision 14310)
+++ /issm/trunk/externalpackages/dakota/configs/5.2/ParallelLibrary.C.patch	(revision 14310)
@@ -0,0 +1,36 @@
+178a179
+>   initialized=0; //we run serially all the time!
+214a216,248
+> /** This constructor is provided for the Issm software, to run serial
+>  * Dakota in a parallel MPI ring: */
+> ParallelLibrary::ParallelLibrary(char* serial_mode):
+>   worldRank(0), worldSize(1), 
+>   mpirunFlag(false), ownMPIFlag(false), dummyFlag(false),
+>   stdOutputToFile(false), stdErrorToFile(false), checkFlag(false),
+>   preRunFlag(true), runFlag(true), postRunFlag(true), userModesFlag(false), 
+>   startClock(0), stopRestartEvals(0),
+>   currPLIter(parallelLevels.end()), currPCIter(parallelConfigurations.end())
+> {
+>   startClock   = clock();
+> #ifdef DAKOTA_UTILIB
+>   utilib::exception_mngr::set_mode(utilib::exception_mngr::Abort);
+>   startCPUTime = CPUSeconds();       // see utilib/src/sys/seconds.cpp
+>   startWCTime  = WallClockSeconds(); // see utilib/src/sys/seconds.cpp
+> #endif // DAKOTA_UTILIB
+> 
+>   // do not initialize MPI.  Get worldRank/worldSize if available
+>   ParallelLevel pl;
+> #ifdef HAVE_MPI // mpi available, we still don't want to run in parallel for Dakota!
+>   pl.serverIntraComm = MPI_COMM_NULL;
+>   Cout << "Running Dakota 5.2 MPI executable in serial mode on CPU 0 for ISSM.";
+> #else // mpi not available
+>   pl.serverIntraComm = MPI_COMM_NULL;
+>   Cout << "Running Dakota 5.2 serial executable in serial mode for ISSM.\n";
+> #endif // HAVE_MPI
+> 
+>   parallelLevels.push_back(pl);
+>   currPLIter = parallelLevels.begin();
+>   increment_parallel_configuration();
+> }
+> 
+> 
Index: /issm/trunk/externalpackages/dakota/configs/5.2/ParallelLibrary.H.patch
===================================================================
--- /issm/trunk/externalpackages/dakota/configs/5.2/ParallelLibrary.H.patch	(revision 14310)
+++ /issm/trunk/externalpackages/dakota/configs/5.2/ParallelLibrary.H.patch	(revision 14310)
@@ -0,0 +1,3 @@
+358a359,360
+>   /// library mode constructor, serial mode (for the Issm software)
+>   ParallelLibrary(char*  serial_mode);
Index: /issm/trunk/externalpackages/dakota/configs/5.2/pecos_global_defs.hpp.patch
===================================================================
--- /issm/trunk/externalpackages/dakota/configs/5.2/pecos_global_defs.hpp.patch	(revision 14310)
+++ /issm/trunk/externalpackages/dakota/configs/5.2/pecos_global_defs.hpp.patch	(revision 14310)
@@ -0,0 +1,4 @@
+24a25
+> #ifndef PI
+25a27
+> #endif
Index: /issm/trunk/externalpackages/dakota/install-4.2-altix64-cosmos.sh
===================================================================
--- /issm/trunk/externalpackages/dakota/install-4.2-altix64-cosmos.sh	(revision 14310)
+++ /issm/trunk/externalpackages/dakota/install-4.2-altix64-cosmos.sh	(revision 14310)
@@ -0,0 +1,97 @@
+#!/bin/bash
+set -eu
+
+#Some cleanup
+rm -rf Dakota
+rm -rf src 
+rm -rf install 
+mkdir src install 
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/Dakota_4_3.src.tar.gz' 'Dakota_4_3.src.tar.gz'
+
+#Untar 
+tar -zxvf  Dakota_4_3.src.tar.gz
+
+#Move Dakota to src directory
+mv Dakota/* src
+rm -rf Dakota
+
+#Apply patches
+patch src/src/ParallelLibrary.C configs/4.2/ParallelLibrary.C.patch
+patch src/src/ParallelLibrary.H configs/4.2/ParallelLibrary.H.patch
+patch src/src/NIDRProblemDescDB.C configs/4.2/NIDRProblemDescDB.C.patch
+patch src/src/NonDSampling.C configs/4.2/NonDSampling.C.patch
+patch src/src/NonDLocalReliability.C configs/4.2/NonDLocalReliability.C.patch
+patch src/src/NonDUnilevelRBDO.C configs/4.2/NonDUnilevelRBDO.C.patch    #  source not even used?
+#patch -R src/packages/Pecos/src/LHSDriver.cpp configs/4.2/LHSDriver.cpp.patch
+
+#Configure dakota
+cd src
+./configure \ 
+	--prefix="$ISSM_DIR/externalpackages/dakota/install" \
+	--without-graphics  \
+	--with-pic \
+	--disable-mpi \
+	--with-blas=/opt/intel/mkl/9.1.023/lib/64/libmkl.so \
+	--with-lapack=/opt/intel/mkl/9.1.023/lib/64/libmkl_lapack.so 
+cd ..
+
+#Before compiling, if running on 64 bits, we need to active fPIC compilation. Some packages 
+#do not register -fPIC in Dakota, which is a problem. Edit the faulty Makefiles and add the -fPIC 
+#flag to the compilation.
+cat ./src/methods/NCSUOpt/Makefile | sed 's/FFLAGS = -g -O2/FFLAGS = -g -O2 -fPIC/g' >  temp
+mv temp ./src/methods/NCSUOpt/Makefile
+
+cat ./src/methods/acro/packages/pebbl/src/Makefile | sed 's/CXXFLAGS = -O2 -fpermissive/CXXFLAGS = -O2 -fpermissive -fPIC/g' > temp
+mv temp ./src/methods/acro/packages/pebbl/src/Makefile
+
+cat ./src/methods/hopspack/src-nappspack/Makefile | sed 's/CXXFLAGS = -g -O2/CXXFLAGS = -g -O2  -fPIC/g' > temp
+mv temp ./src/methods/hopspack/src-nappspack/Makefile
+
+cat ./src/methods/hopspack/src-cddlib/Makefile | sed 's/CFLAGS = -g -O2/CFLAGS = -g -O2 -fPIC/g' > temp
+mv temp  ./src/methods/hopspack/src-cddlib/Makefile 
+
+cat ./src/methods/hopspack/src-shared/Makefile | sed 's/CFLAGS = -g -O2/CFLAGS = -g -O2 -fPIC/g' > temp
+mv temp  ./src/methods/hopspack/src-shared/Makefile 
+
+cat ./src/methods/hopspack/src-shared/Makefile | sed 's/CXXFLAGS = -g -O2/CXXFLAGS = -g -O2  -fPIC/g' > temp
+mv temp  ./src/methods/hopspack/src-shared/Makefile 
+
+cat ./src/methods/hopspack/src-conveyor/Makefile | sed 's/CXXFLAGS = -g -O2/CXXFLAGS = -g -O2 -fPIC/g' > temp
+mv temp  ./src/methods/hopspack/src-conveyor/Makefile 
+
+cat ./src/methods/hopspack/src-appspack/Makefile | sed 's/CXXFLAGS = -g -O2/CXXFLAGS = -g -O2  -fPIC/g' > temp
+mv temp ./src/methods/hopspack/src-appspack/Makefile 
+
+cat ./src/methods/acro/packages/colin/src/Makefile | sed 's/CXXFLAGS = -O2 -fpermissive/CXXFLAGS = -O2 -fpermissive -fPIC/g' > temp
+mv temp ./src/methods/acro/packages/colin/src/Makefile
+
+cat ./src/methods/acro/packages/coliny/src/Makefile | sed 's/CXXFLAGS = -O2 -fpermissive/CXXFLAGS = -O2 -fpermissive -fPIC/g' > temp
+mv temp ./src/methods/acro/packages/coliny/src/Makefile
+
+cat ./src/methods/acro/packages/tpl/3po/Makefile | sed 's/CFLAGS = -O2/CFLAGS = -O2 -fPIC/g' > temp
+mv temp  ./src/methods/acro/packages/tpl/3po/Makefile 
+
+cat ./src/methods/acro/packages/tpl/3po/Makefile | sed 's/CXXFLAGS = -O2 -fpermissive/CFLAGS = -O2 -fpermissive -fPIC/g' > temp
+mv temp  ./src/methods/acro/packages/tpl/3po/Makefile 
+
+cat ./src/packages/ampl/Makefile | sed 's/CFLAGS = -g -O2/CFLAGS = -g -O2 -fPIC/g' > temp
+mv temp  ./src/packages/ampl/Makefile 
+
+#Compile and install dakota
+cd src 
+if [ $# -eq 0 ];
+then
+	make
+	make install
+else
+	make -j $1
+	make -j $1 install
+fi
+cd ..
+
+#Weird behaviour of Dakota: libamplsolver.a and amplsolver.a are not the same thing!
+cd install/lib
+mv libamplsolver.a libamplsolver.a.bak
+ln -s ../../src/packages/ampl/amplsolver.a ./libamplsolver.a
Index: /issm/trunk/externalpackages/dakota/install-4.2-discover.sh
===================================================================
--- /issm/trunk/externalpackages/dakota/install-4.2-discover.sh	(revision 14310)
+++ /issm/trunk/externalpackages/dakota/install-4.2-discover.sh	(revision 14310)
@@ -0,0 +1,97 @@
+#!/bin/bash
+set -eu
+
+#Some cleanup
+rm -rf Dakota
+rm -rf src
+rm -rf install
+mkdir src install
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/Dakota_4_3.src.tar.gz' 'Dakota_4_3.src.tar.gz'
+
+#Untar 
+tar -zxvf  Dakota_4_3.src.tar.gz
+
+#Move Dakota to src directory
+mv Dakota/* src
+rm -rf Dakota
+
+#Apply patches
+patch src/src/ParallelLibrary.C configs/4.2/ParallelLibrary.C.patch
+patch src/src/ParallelLibrary.H configs/4.2/ParallelLibrary.H.patch
+patch src/src/NIDRProblemDescDB.C configs/4.2/NIDRProblemDescDB.C.patch
+patch src/src/NonDSampling.C configs/4.2/NonDSampling.C.patch
+patch src/src/NonDLocalReliability.C configs/4.2/NonDLocalReliability.C.patch
+patch src/src/NonDUnilevelRBDO.C configs/4.2/NonDUnilevelRBDO.C.patch    #  source not even used?
+#patch -R src/packages/Pecos/src/LHSDriver.cpp configs/4.2/LHSDriver.cpp.patch
+
+#Configure dakota
+cd src
+./configure \
+--prefix="$ISSM_DIR/externalpackages/dakota/install/" \
+--without-graphics  \
+--with-pic \
+--disable-mpi \
+--with-blas="-L/usr/local/intel/mkl/10.1.2.024/lib/64 -lmkl_lapack -lmkl -lguide -lpthread" \
+--with-lapack="-L/usr/local/intel/mkl/10.1.2.024/lib/64 -lmkl_lapack -lmkl -lguide -lpthread"
+cd ..
+
+#Before compiling, if running on 64 bits, we need to active fPIC compilation. Some packages 
+#do not register -fPIC in Dakota, which is a problem. Edit the faulty Makefiles and add the -fPIC 
+#flag to the compilation.
+cat ./src/methods/NCSUOpt/Makefile | sed 's/FFLAGS = -g -O2/FFLAGS = -g -O2 -fPIC/g' >  temp
+mv temp ./src/methods/NCSUOpt/Makefile
+
+cat ./src/methods/acro/packages/pebbl/src/Makefile | sed 's/CXXFLAGS = -O2 -fpermissive/CXXFLAGS = -O2 -fpermissive -fPIC/g' > temp
+mv temp ./src/methods/acro/packages/pebbl/src/Makefile
+
+cat ./src/methods/hopspack/src-nappspack/Makefile | sed 's/CXXFLAGS = -g -O2/CXXFLAGS = -g -O2  -fPIC/g' > temp
+mv temp ./src/methods/hopspack/src-nappspack/Makefile
+
+cat ./src/methods/hopspack/src-cddlib/Makefile | sed 's/CFLAGS = -g -O2/CFLAGS = -g -O2 -fPIC/g' > temp
+mv temp  ./src/methods/hopspack/src-cddlib/Makefile
+
+cat ./src/methods/hopspack/src-shared/Makefile | sed 's/CFLAGS = -g -O2/CFLAGS = -g -O2 -fPIC/g' > temp
+mv temp  ./src/methods/hopspack/src-shared/Makefile
+
+cat ./src/methods/hopspack/src-shared/Makefile | sed 's/CXXFLAGS = -g -O2/CXXFLAGS = -g -O2  -fPIC/g' > temp
+mv temp  ./src/methods/hopspack/src-shared/Makefile
+
+cat ./src/methods/hopspack/src-conveyor/Makefile | sed 's/CXXFLAGS = -g -O2/CXXFLAGS = -g -O2 -fPIC/g' > temp
+mv temp  ./src/methods/hopspack/src-conveyor/Makefile
+
+cat ./src/methods/hopspack/src-appspack/Makefile | sed 's/CXXFLAGS = -g -O2/CXXFLAGS = -g -O2  -fPIC/g' > temp
+mv temp ./src/methods/hopspack/src-appspack/Makefile
+
+cat ./src/methods/acro/packages/colin/src/Makefile | sed 's/CXXFLAGS = -O2 -fpermissive/CXXFLAGS = -O2 -fpermissive -fPIC/g' > temp
+mv temp ./src/methods/acro/packages/colin/src/Makefile
+
+cat ./src/methods/acro/packages/coliny/src/Makefile | sed 's/CXXFLAGS = -O2 -fpermissive/CXXFLAGS = -O2 -fpermissive -fPIC/g' > temp
+mv temp ./src/methods/acro/packages/coliny/src/Makefile
+
+cat ./src/methods/acro/packages/tpl/3po/Makefile | sed 's/CFLAGS = -O2/CFLAGS = -O2 -fPIC/g' > temp
+mv temp  ./src/methods/acro/packages/tpl/3po/Makefile
+
+cat ./src/methods/acro/packages/tpl/3po/Makefile | sed 's/CXXFLAGS = -O2 -fpermissive/CFLAGS = -O2 -fpermissive -fPIC/g' > temp
+mv temp  ./src/methods/acro/packages/tpl/3po/Makefile
+
+cat ./src/packages/ampl/Makefile | sed 's/CFLAGS = -g -O2/CFLAGS = -g -O2 -fPIC/g' > temp
+mv temp  ./src/packages/ampl/Makefile
+
+#Compile and install dakota
+cd src
+if [ $# -eq 0 ];
+then
+	make
+	make install
+else
+	make -j $1
+	make -j $1 install
+fi
+cd ..
+
+#Weird behaviour of Dakota: libamplsolver.a and amplsolver.a are not the same thing!
+cd install/lib
+mv libamplsolver.a libamplsolver.a.bak
+ln -s ../../src/packages/ampl/amplsolver.a ./libamplsolver.a
Index: /issm/trunk/externalpackages/dakota/install-4.2-linux64-astrid.sh
===================================================================
--- /issm/trunk/externalpackages/dakota/install-4.2-linux64-astrid.sh	(revision 14310)
+++ /issm/trunk/externalpackages/dakota/install-4.2-linux64-astrid.sh	(revision 14310)
@@ -0,0 +1,97 @@
+#!/bin/bash
+set -eu
+
+#Some cleanup
+rm -rf Dakota
+rm -rf src 
+rm -rf install 
+mkdir src install 
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/Dakota_4_3.src.tar.gz' 'Dakota_4_3.src.tar.gz'
+
+#Untar 
+tar -zxvf  Dakota_4_3.src.tar.gz
+
+#Move Dakota to src directory
+mv Dakota/* src
+rm -rf Dakota
+
+#Apply patches
+patch src/src/ParallelLibrary.C configs/4.2/ParallelLibrary.C.patch
+patch src/src/ParallelLibrary.H configs/4.2/ParallelLibrary.H.patch
+patch src/src/NIDRProblemDescDB.C configs/4.2/NIDRProblemDescDB.C.patch
+patch src/src/NonDSampling.C configs/4.2/NonDSampling.C.patch
+patch src/src/NonDLocalReliability.C configs/4.2/NonDLocalReliability.C.patch
+patch src/src/NonDUnilevelRBDO.C configs/4.2/NonDUnilevelRBDO.C.patch    #  source not even used?
+#patch -R src/packages/Pecos/src/LHSDriver.cpp configs/4.2/LHSDriver.cpp.patch
+
+#Configure dakota
+cd src
+./configure \
+	--prefix="$ISSM_DIR/externalpackages/dakota/install" \
+	--without-graphics  \
+	--with-pic \
+	--disable-mpi \
+	--with-blas=/usr/lib64/libblas.so.3.0.3 \
+	--with-lapack=/usr/lib64/liblapack.so.3.0.3
+cd ..
+
+#Before compiling, if running on 64 bits, we need to active fPIC compilation. Some packages 
+#do not register -fPIC in Dakota, which is a problem. Edit the faulty Makefiles and add the -fPIC 
+#flag to the compilation.
+cat ./src/methods/NCSUOpt/Makefile | sed 's/FFLAGS = -g -O2/FFLAGS = -g -O2 -fPIC/g' >  temp
+mv temp ./src/methods/NCSUOpt/Makefile
+
+cat ./src/methods/acro/packages/pebbl/src/Makefile | sed 's/CXXFLAGS = -O2 -fpermissive/CXXFLAGS = -O2 -fpermissive -fPIC/g' > temp
+mv temp ./src/methods/acro/packages/pebbl/src/Makefile
+
+cat ./src/methods/hopspack/src-nappspack/Makefile | sed 's/CXXFLAGS = -g -O2/CXXFLAGS = -g -O2  -fPIC/g' > temp
+mv temp ./src/methods/hopspack/src-nappspack/Makefile
+
+cat ./src/methods/hopspack/src-cddlib/Makefile | sed 's/CFLAGS = -g -O2/CFLAGS = -g -O2 -fPIC/g' > temp
+mv temp  ./src/methods/hopspack/src-cddlib/Makefile 
+
+cat ./src/methods/hopspack/src-shared/Makefile | sed 's/CFLAGS = -g -O2/CFLAGS = -g -O2 -fPIC/g' > temp
+mv temp  ./src/methods/hopspack/src-shared/Makefile 
+
+cat ./src/methods/hopspack/src-shared/Makefile | sed 's/CXXFLAGS = -g -O2/CXXFLAGS = -g -O2  -fPIC/g' > temp
+mv temp  ./src/methods/hopspack/src-shared/Makefile 
+
+cat ./src/methods/hopspack/src-conveyor/Makefile | sed 's/CXXFLAGS = -g -O2/CXXFLAGS = -g -O2 -fPIC/g' > temp
+mv temp  ./src/methods/hopspack/src-conveyor/Makefile 
+
+cat ./src/methods/hopspack/src-appspack/Makefile | sed 's/CXXFLAGS = -g -O2/CXXFLAGS = -g -O2  -fPIC/g' > temp
+mv temp ./src/methods/hopspack/src-appspack/Makefile 
+
+cat ./src/methods/acro/packages/colin/src/Makefile | sed 's/CXXFLAGS = -O2 -fpermissive/CXXFLAGS = -O2 -fpermissive -fPIC/g' > temp
+mv temp ./src/methods/acro/packages/colin/src/Makefile
+
+cat ./src/methods/acro/packages/coliny/src/Makefile | sed 's/CXXFLAGS = -O2 -fpermissive/CXXFLAGS = -O2 -fpermissive -fPIC/g' > temp
+mv temp ./src/methods/acro/packages/coliny/src/Makefile
+
+cat ./src/methods/acro/packages/tpl/3po/Makefile | sed 's/CFLAGS = -O2/CFLAGS = -O2 -fPIC/g' > temp
+mv temp  ./src/methods/acro/packages/tpl/3po/Makefile 
+
+cat ./src/methods/acro/packages/tpl/3po/Makefile | sed 's/CXXFLAGS = -O2 -fpermissive/CFLAGS = -O2 -fpermissive -fPIC/g' > temp
+mv temp  ./src/methods/acro/packages/tpl/3po/Makefile 
+
+cat ./src/packages/ampl/Makefile | sed 's/CFLAGS = -g -O2/CFLAGS = -g -O2 -fPIC/g' > temp
+mv temp  ./src/packages/ampl/Makefile 
+
+#Compile and install dakota
+cd src 
+if [ $# -eq 0 ];
+then
+	make
+	make install
+else
+	make -j $1
+	make -j $1 install
+fi
+cd ..
+
+#Weird behaviour of Dakota: libamplsolver.a and amplsolver.a are not the same thing!
+cd install/lib
+mv libamplsolver.a libamplsolver.a.bak
+ln -s ../../src/packages/ampl/amplsolver.a ./libamplsolver.a
Index: /issm/trunk/externalpackages/dakota/install-4.2-linux64-cloud.sh
===================================================================
--- /issm/trunk/externalpackages/dakota/install-4.2-linux64-cloud.sh	(revision 14310)
+++ /issm/trunk/externalpackages/dakota/install-4.2-linux64-cloud.sh	(revision 14310)
@@ -0,0 +1,97 @@
+#!/bin/bash
+set -eu
+
+#Some cleanup
+rm -rf Dakota
+rm -rf src 
+rm -rf install 
+mkdir src install 
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/Dakota_4_3.src.tar.gz' 'Dakota_4_3.src.tar.gz'
+
+#Untar 
+tar -zxvf  Dakota_4_3.src.tar.gz
+
+#Move Dakota to src directory
+mv Dakota/* src
+rm -rf Dakota
+
+#Apply patches
+patch src/src/ParallelLibrary.C configs/4.2/ParallelLibrary.C.patch
+patch src/src/ParallelLibrary.H configs/4.2/ParallelLibrary.H.patch
+patch src/src/NIDRProblemDescDB.C configs/4.2/NIDRProblemDescDB.C.patch
+patch src/src/NonDSampling.C configs/4.2/NonDSampling.C.patch
+patch src/src/NonDLocalReliability.C configs/4.2/NonDLocalReliability.C.patch
+patch src/src/NonDUnilevelRBDO.C configs/4.2/NonDUnilevelRBDO.C.patch    #  source not even used?
+#patch -R src/packages/Pecos/src/LHSDriver.cpp configs/4.2/LHSDriver.cpp.patch
+
+#Configure dakota
+cd src
+./configure \
+	--prefix="$ISSM_DIR/externalpackages/dakota/install" \
+	--without-graphics  \
+	--with-pic \
+	--disable-mpi \
+	--with-blas=/usr/lib/libblas.so \
+	--with-lapack=/usr/lib/liblapack.so
+cd ..
+
+#Before compiling, if running on 64 bits, we need to active fPIC compilation. Some packages 
+#do not register -fPIC in Dakota, which is a problem. Edit the faulty Makefiles and add the -fPIC 
+#flag to the compilation.
+cat ./src/methods/NCSUOpt/Makefile | sed 's/FFLAGS = -g -O2/FFLAGS = -g -O2 -fPIC/g' >  temp
+mv temp ./src/methods/NCSUOpt/Makefile
+
+cat ./src/methods/acro/packages/pebbl/src/Makefile | sed 's/CXXFLAGS = -O2 -fpermissive/CXXFLAGS = -O2 -fpermissive -fPIC/g' > temp
+mv temp ./src/methods/acro/packages/pebbl/src/Makefile
+
+cat ./src/methods/hopspack/src-nappspack/Makefile | sed 's/CXXFLAGS = -g -O2/CXXFLAGS = -g -O2  -fPIC/g' > temp
+mv temp ./src/methods/hopspack/src-nappspack/Makefile
+
+cat ./src/methods/hopspack/src-cddlib/Makefile | sed 's/CFLAGS = -g -O2/CFLAGS = -g -O2 -fPIC/g' > temp
+mv temp  ./src/methods/hopspack/src-cddlib/Makefile 
+
+cat ./src/methods/hopspack/src-shared/Makefile | sed 's/CFLAGS = -g -O2/CFLAGS = -g -O2 -fPIC/g' > temp
+mv temp  ./src/methods/hopspack/src-shared/Makefile 
+
+cat ./src/methods/hopspack/src-shared/Makefile | sed 's/CXXFLAGS = -g -O2/CXXFLAGS = -g -O2  -fPIC/g' > temp
+mv temp  ./src/methods/hopspack/src-shared/Makefile 
+
+cat ./src/methods/hopspack/src-conveyor/Makefile | sed 's/CXXFLAGS = -g -O2/CXXFLAGS = -g -O2 -fPIC/g' > temp
+mv temp  ./src/methods/hopspack/src-conveyor/Makefile 
+
+cat ./src/methods/hopspack/src-appspack/Makefile | sed 's/CXXFLAGS = -g -O2/CXXFLAGS = -g -O2  -fPIC/g' > temp
+mv temp ./src/methods/hopspack/src-appspack/Makefile 
+
+cat ./src/methods/acro/packages/colin/src/Makefile | sed 's/CXXFLAGS = -O2 -fpermissive/CXXFLAGS = -O2 -fpermissive -fPIC/g' > temp
+mv temp ./src/methods/acro/packages/colin/src/Makefile
+
+cat ./src/methods/acro/packages/coliny/src/Makefile | sed 's/CXXFLAGS = -O2 -fpermissive/CXXFLAGS = -O2 -fpermissive -fPIC/g' > temp
+mv temp ./src/methods/acro/packages/coliny/src/Makefile
+
+cat ./src/methods/acro/packages/tpl/3po/Makefile | sed 's/CFLAGS = -O2/CFLAGS = -O2 -fPIC/g' > temp
+mv temp  ./src/methods/acro/packages/tpl/3po/Makefile 
+
+cat ./src/methods/acro/packages/tpl/3po/Makefile | sed 's/CXXFLAGS = -O2 -fpermissive/CFLAGS = -O2 -fpermissive -fPIC/g' > temp
+mv temp  ./src/methods/acro/packages/tpl/3po/Makefile 
+
+cat ./src/packages/ampl/Makefile | sed 's/CFLAGS = -g -O2/CFLAGS = -g -O2 -fPIC/g' > temp
+mv temp  ./src/packages/ampl/Makefile 
+
+#Compile and install dakota
+cd src 
+if [ $# -eq 0 ];
+then
+	make
+	make install
+else
+	make -j $1
+	make -j $1 install
+fi
+cd ..
+
+#Weird behaviour of Dakota: libamplsolver.a and amplsolver.a are not the same thing!
+cd install/lib
+mv libamplsolver.a libamplsolver.a.bak
+ln -s ../../src/packages/ampl/amplsolver.a ./libamplsolver.a
Index: /issm/trunk/externalpackages/dakota/install-4.2-linux64-murdo.sh
===================================================================
--- /issm/trunk/externalpackages/dakota/install-4.2-linux64-murdo.sh	(revision 14310)
+++ /issm/trunk/externalpackages/dakota/install-4.2-linux64-murdo.sh	(revision 14310)
@@ -0,0 +1,97 @@
+#!/bin/bash
+set -eu
+
+#Some cleanup
+rm -rf Dakota
+rm -rf src 
+rm -rf install 
+mkdir src install 
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/Dakota_4_3.src.tar.gz' 'Dakota_4_3.src.tar.gz'
+
+#Untar 
+tar -zxvf  Dakota_4_3.src.tar.gz
+
+#Move Dakota to src directory
+mv Dakota/* src
+rm -rf Dakota
+
+#Apply patches
+patch src/src/ParallelLibrary.C configs/4.2/ParallelLibrary.C.patch
+patch src/src/ParallelLibrary.H configs/4.2/ParallelLibrary.H.patch
+patch src/src/NIDRProblemDescDB.C configs/4.2/NIDRProblemDescDB.C.patch
+patch src/src/NonDSampling.C configs/4.2/NonDSampling.C.patch
+patch src/src/NonDLocalReliability.C configs/4.2/NonDLocalReliability.C.patch
+patch src/src/NonDUnilevelRBDO.C configs/4.2/NonDUnilevelRBDO.C.patch    #  source not even used?
+#patch -R src/packages/Pecos/src/LHSDriver.cpp configs/4.2/LHSDriver.cpp.patch
+
+#Configure dakota
+cd src
+./configure \
+	--prefix="$ISSM_DIR/externalpackages/dakota/install" \
+	--without-graphics  \
+	--with-pic \
+	--disable-mpi \
+	--with-blas=/usr/lib64/libblas.so.3.1.1 \
+	--with-lapack=/usr/lib64/liblapack.so.3.1.1
+cd ..
+
+#Before compiling, if running on 64 bits, we need to active fPIC compilation. Some packages 
+#do not register -fPIC in Dakota, which is a problem. Edit the faulty Makefiles and add the -fPIC 
+#flag to the compilation.
+cat ./src/methods/NCSUOpt/Makefile | sed 's/FFLAGS = -g -O2/FFLAGS = -g -O2 -fPIC/g' >  temp
+mv temp ./src/methods/NCSUOpt/Makefile
+
+cat ./src/methods/acro/packages/pebbl/src/Makefile | sed 's/CXXFLAGS = -O2 -fpermissive/CXXFLAGS = -O2 -fpermissive -fPIC/g' > temp
+mv temp ./src/methods/acro/packages/pebbl/src/Makefile
+
+cat ./src/methods/hopspack/src-nappspack/Makefile | sed 's/CXXFLAGS = -g -O2/CXXFLAGS = -g -O2  -fPIC/g' > temp
+mv temp ./src/methods/hopspack/src-nappspack/Makefile
+
+cat ./src/methods/hopspack/src-cddlib/Makefile | sed 's/CFLAGS = -g -O2/CFLAGS = -g -O2 -fPIC/g' > temp
+mv temp  ./src/methods/hopspack/src-cddlib/Makefile 
+
+cat ./src/methods/hopspack/src-shared/Makefile | sed 's/CFLAGS = -g -O2/CFLAGS = -g -O2 -fPIC/g' > temp
+mv temp  ./src/methods/hopspack/src-shared/Makefile 
+
+cat ./src/methods/hopspack/src-shared/Makefile | sed 's/CXXFLAGS = -g -O2/CXXFLAGS = -g -O2  -fPIC/g' > temp
+mv temp  ./src/methods/hopspack/src-shared/Makefile 
+
+cat ./src/methods/hopspack/src-conveyor/Makefile | sed 's/CXXFLAGS = -g -O2/CXXFLAGS = -g -O2 -fPIC/g' > temp
+mv temp  ./src/methods/hopspack/src-conveyor/Makefile 
+
+cat ./src/methods/hopspack/src-appspack/Makefile | sed 's/CXXFLAGS = -g -O2/CXXFLAGS = -g -O2  -fPIC/g' > temp
+mv temp ./src/methods/hopspack/src-appspack/Makefile 
+
+cat ./src/methods/acro/packages/colin/src/Makefile | sed 's/CXXFLAGS = -O2 -fpermissive/CXXFLAGS = -O2 -fpermissive -fPIC/g' > temp
+mv temp ./src/methods/acro/packages/colin/src/Makefile
+
+cat ./src/methods/acro/packages/coliny/src/Makefile | sed 's/CXXFLAGS = -O2 -fpermissive/CXXFLAGS = -O2 -fpermissive -fPIC/g' > temp
+mv temp ./src/methods/acro/packages/coliny/src/Makefile
+
+cat ./src/methods/acro/packages/tpl/3po/Makefile | sed 's/CFLAGS = -O2/CFLAGS = -O2 -fPIC/g' > temp
+mv temp  ./src/methods/acro/packages/tpl/3po/Makefile 
+
+cat ./src/methods/acro/packages/tpl/3po/Makefile | sed 's/CXXFLAGS = -O2 -fpermissive/CFLAGS = -O2 -fpermissive -fPIC/g' > temp
+mv temp  ./src/methods/acro/packages/tpl/3po/Makefile 
+
+cat ./src/packages/ampl/Makefile | sed 's/CFLAGS = -g -O2/CFLAGS = -g -O2 -fPIC/g' > temp
+mv temp  ./src/packages/ampl/Makefile 
+
+#Compile and install dakota
+cd src 
+if [ $# -eq 0 ];
+then
+	make
+	make install
+else
+	make -j $1
+	make -j $1 install
+fi
+cd ..
+
+#Weird behaviour of Dakota: libamplsolver.a and amplsolver.a are not the same thing!
+cd install/lib
+mv libamplsolver.a libamplsolver.a.bak
+ln -s ../../src/packages/ampl/amplsolver.a ./libamplsolver.a
Index: /issm/trunk/externalpackages/dakota/install-4.2-macosx64.sh
===================================================================
--- /issm/trunk/externalpackages/dakota/install-4.2-macosx64.sh	(revision 14310)
+++ /issm/trunk/externalpackages/dakota/install-4.2-macosx64.sh	(revision 14310)
@@ -0,0 +1,97 @@
+#!/bin/bash
+set -eu
+
+#Some cleanup
+rm -rf Dakota
+rm -rf src 
+rm -rf install 
+mkdir src install 
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/Dakota_4_3.src.tar.gz' 'Dakota_4_3.src.tar.gz'
+
+#Untar 
+tar -zxvf  Dakota_4_3.src.tar.gz
+
+#Move Dakota to src directory
+mv Dakota/* src
+rm -rf Dakota
+
+#Apply patches
+patch src/src/ParallelLibrary.C configs/4.2/ParallelLibrary.C.patch
+patch src/src/ParallelLibrary.H configs/4.2/ParallelLibrary.H.patch
+patch src/src/NIDRProblemDescDB.C configs/4.2/NIDRProblemDescDB.C.patch
+patch src/src/NonDSampling.C configs/4.2/NonDSampling.C.patch
+patch src/src/NonDLocalReliability.C configs/4.2/NonDLocalReliability.C.patch
+patch src/src/NonDUnilevelRBDO.C configs/4.2/NonDUnilevelRBDO.C.patch    #  source not even used?
+#patch -R src/packages/Pecos/src/LHSDriver.cpp configs/4.2/LHSDriver.cpp.patch
+
+#Configure dakota
+cd src
+./configure \
+   --prefix="$ISSM_DIR/externalpackages/dakota/install" \
+   --without-graphics  \
+   --with-pic \
+   --disable-mpi \
+   --with-blas="-L$ISSM_DIR/externalpackages/petsc/install/lib -lfblas " \
+   --with-lapack="-L$ISSM_DIR/externalpackages/petsc/install/lib -lflapack "
+cd ..
+
+#Before compiling, if running on 64 bits, we need to active fPIC compilation. Some packages 
+#do not register -fPIC in Dakota, which is a problem. Edit the faulty Makefiles and add the -fPIC 
+#flag to the compilation.
+cat ./src/methods/NCSUOpt/Makefile | sed 's/FFLAGS = -g -O2/FFLAGS = -g -O2 -fPIC/g' >  temp
+mv temp ./src/methods/NCSUOpt/Makefile
+
+cat ./src/methods/acro/packages/pebbl/src/Makefile | sed 's/CXXFLAGS = -O2 -fpermissive/CXXFLAGS = -O2 -fpermissive -fPIC/g' > temp
+mv temp ./src/methods/acro/packages/pebbl/src/Makefile
+
+cat ./src/methods/hopspack/src-nappspack/Makefile | sed 's/CXXFLAGS = -g -O2/CXXFLAGS = -g -O2 -fPIC/g' > temp
+mv temp ./src/methods/hopspack/src-nappspack/Makefile
+
+cat ./src/methods/hopspack/src-cddlib/Makefile | sed 's/CFLAGS = -g -O2/CFLAGS = -g -O2 -fPIC/g' > temp
+mv temp  ./src/methods/hopspack/src-cddlib/Makefile 
+
+cat ./src/methods/hopspack/src-shared/Makefile | sed 's/CFLAGS = -g -O2/CFLAGS = -g -O2 -fPIC/g' > temp
+mv temp  ./src/methods/hopspack/src-shared/Makefile 
+
+cat ./src/methods/hopspack/src-shared/Makefile | sed 's/CXXFLAGS = -g -O2/CXXFLAGS = -g -O2 -fPIC/g' > temp
+mv temp  ./src/methods/hopspack/src-shared/Makefile 
+
+cat ./src/methods/hopspack/src-conveyor/Makefile | sed 's/CXXFLAGS = -g -O2/CXXFLAGS = -g -O2 -fPIC/g' > temp
+mv temp  ./src/methods/hopspack/src-conveyor/Makefile 
+
+cat ./src/methods/hopspack/src-appspack/Makefile | sed 's/CXXFLAGS = -g -O2/CXXFLAGS = -g -O2 -fPIC/g' > temp
+mv temp ./src/methods/hopspack/src-appspack/Makefile 
+
+cat ./src/methods/acro/packages/colin/src/Makefile | sed 's/CXXFLAGS = -O2 -fpermissive/CXXFLAGS = -O2 -fpermissive -fPIC/g' > temp
+mv temp ./src/methods/acro/packages/colin/src/Makefile
+
+cat ./src/methods/acro/packages/coliny/src/Makefile | sed 's/CXXFLAGS = -O2 -fpermissive/CXXFLAGS = -O2 -fpermissive -fPIC/g' > temp
+mv temp ./src/methods/acro/packages/coliny/src/Makefile
+
+cat ./src/methods/acro/packages/tpl/3po/Makefile | sed 's/CFLAGS = -O2/CFLAGS = -O2 -fPIC/g' > temp
+mv temp  ./src/methods/acro/packages/tpl/3po/Makefile 
+
+cat ./src/methods/acro/packages/tpl/3po/Makefile | sed 's/CXXFLAGS = -O2 -fpermissive/CFLAGS = -O2 -fpermissive -fPIC/g' > temp
+mv temp  ./src/methods/acro/packages/tpl/3po/Makefile 
+
+cat ./src/packages/ampl/Makefile | sed 's/CFLAGS = -g -O2 -D_NONSTD_SOURCE/CFLAGS = -g -O2 -fPIC/g' > temp
+mv temp  ./src/packages/ampl/Makefile 
+
+#Compile and install dakota
+cd src 
+if [ $# -eq 0 ];
+then
+	make
+	make install
+else
+	make -j $1
+	make -j $1 install
+fi
+cd ..
+
+#Weird behaviour of Dakota: libamplsolver.a and amplsolver.a are not the same thing!
+cd install/lib
+mv libamplsolver.a libamplsolver.a.bak
+ln -s ../../src/packages/ampl/amplsolver.a ./libamplsolver.a
Index: /issm/trunk/externalpackages/dakota/install-4.2-pleiades-petsc3.3.sh
===================================================================
--- /issm/trunk/externalpackages/dakota/install-4.2-pleiades-petsc3.3.sh	(revision 14310)
+++ /issm/trunk/externalpackages/dakota/install-4.2-pleiades-petsc3.3.sh	(revision 14310)
@@ -0,0 +1,103 @@
+#!/bin/bash
+set -eu
+
+#Some cleanup
+rm -rf Dakota
+rm -rf src
+rm -rf install
+mkdir src install
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/Dakota_4_3.src.tar.gz' 'Dakota_4_3.src.tar.gz'
+
+#Untar 
+tar -zxvf  Dakota_4_3.src.tar.gz
+
+#Move Dakota to src directory
+mv Dakota/* src
+rm -rf Dakota
+
+#Apply patches
+patch src/src/ParallelLibrary.C configs/4.2/ParallelLibrary.C.patch
+patch src/src/ParallelLibrary.H configs/4.2/ParallelLibrary.H.patch
+patch src/src/NIDRProblemDescDB.C configs/4.2/NIDRProblemDescDB.C.patch
+patch src/src/NonDSampling.C configs/4.2/NonDSampling.C.patch
+patch src/src/NonDLocalReliability.C configs/4.2/NonDLocalReliability.C.patch
+patch src/src/NonDUnilevelRBDO.C configs/4.2/NonDUnilevelRBDO.C.patch    #  source not even used?
+#patch -R src/packages/Pecos/src/LHSDriver.cpp configs/4.2/LHSDriver.cpp.patch
+
+#Configure dakota
+cd src
+./configure \
+--prefix="$ISSM_DIR/externalpackages/dakota/install/" \
+--without-graphics  \
+--with-pic \
+--disable-mpi \
+--with-blas="-L$ISSM_DIR/externalpackages/petsc/install/lib -lfblas " \
+--with-lapack="-L$ISSM_DIR/externalpackages/petsc/install/lib -lflapack "
+
+#--with-blas="-L/nasa/intel/mkl/10.0.011/lib/64/ -lmkl -lmkl_lapack -liomp5 -lpthread" \
+#--with-lapack="-L/nasa/intel/mkl/10.0.011/lib/64/ -lmkl -lmkl_lapack -liomp5 -lpthread"
+#--with-blas="-L/nasa/intel/Compiler/11.1/046/mkl/lib/em64t/ -lmkl_intel_lp64 -lmkl_lapack" \
+#--with-lapack="-L/nasa/intel/Compiler/11.1/046/mkl/lib/em64t/ -lmkl_intel_lp64 -lmkl_lapack"
+
+cd ..
+
+#Before compiling, if running on 64 bits, we need to active fPIC compilation. Some packages 
+#do not register -fPIC in Dakota, which is a problem. Edit the faulty Makefiles and add the -fPIC 
+#flag to the compilation.
+cat ./src/methods/NCSUOpt/Makefile | sed 's/FFLAGS = -g -O2/FFLAGS = -g -O2 -fPIC/g' >  temp
+mv temp ./src/methods/NCSUOpt/Makefile
+
+cat ./src/methods/acro/packages/pebbl/src/Makefile | sed 's/CXXFLAGS = -O2 -fpermissive/CXXFLAGS = -O2 -fpermissive -fPIC/g' > temp
+mv temp ./src/methods/acro/packages/pebbl/src/Makefile
+
+cat ./src/methods/hopspack/src-nappspack/Makefile | sed 's/CXXFLAGS = -g -O2/CXXFLAGS = -g -O2  -fPIC/g' > temp
+mv temp ./src/methods/hopspack/src-nappspack/Makefile
+
+cat ./src/methods/hopspack/src-cddlib/Makefile | sed 's/CFLAGS = -g -O2/CFLAGS = -g -O2 -fPIC/g' > temp
+mv temp  ./src/methods/hopspack/src-cddlib/Makefile
+
+cat ./src/methods/hopspack/src-shared/Makefile | sed 's/CFLAGS = -g -O2/CFLAGS = -g -O2 -fPIC/g' > temp
+mv temp  ./src/methods/hopspack/src-shared/Makefile
+
+cat ./src/methods/hopspack/src-shared/Makefile | sed 's/CXXFLAGS = -g -O2/CXXFLAGS = -g -O2  -fPIC/g' > temp
+mv temp  ./src/methods/hopspack/src-shared/Makefile
+
+cat ./src/methods/hopspack/src-conveyor/Makefile | sed 's/CXXFLAGS = -g -O2/CXXFLAGS = -g -O2 -fPIC/g' > temp
+mv temp  ./src/methods/hopspack/src-conveyor/Makefile
+
+cat ./src/methods/hopspack/src-appspack/Makefile | sed 's/CXXFLAGS = -g -O2/CXXFLAGS = -g -O2  -fPIC/g' > temp
+mv temp ./src/methods/hopspack/src-appspack/Makefile
+
+cat ./src/methods/acro/packages/colin/src/Makefile | sed 's/CXXFLAGS = -O2 -fpermissive/CXXFLAGS = -O2 -fpermissive -fPIC/g' > temp
+mv temp ./src/methods/acro/packages/colin/src/Makefile
+
+cat ./src/methods/acro/packages/coliny/src/Makefile | sed 's/CXXFLAGS = -O2 -fpermissive/CXXFLAGS = -O2 -fpermissive -fPIC/g' > temp
+mv temp ./src/methods/acro/packages/coliny/src/Makefile
+
+cat ./src/methods/acro/packages/tpl/3po/Makefile | sed 's/CFLAGS = -O2/CFLAGS = -O2 -fPIC/g' > temp
+mv temp  ./src/methods/acro/packages/tpl/3po/Makefile
+
+cat ./src/methods/acro/packages/tpl/3po/Makefile | sed 's/CXXFLAGS = -O2 -fpermissive/CFLAGS = -O2 -fpermissive -fPIC/g' > temp
+mv temp  ./src/methods/acro/packages/tpl/3po/Makefile
+
+cat ./src/packages/ampl/Makefile | sed 's/CFLAGS = -g -O2/CFLAGS = -g -O2 -fPIC/g' > temp
+mv temp  ./src/packages/ampl/Makefile
+
+#Compile and install dakota
+cd src
+if [ $# -eq 0 ];
+then
+	make
+	make install
+else
+	make -j $1
+	make -j $1 install
+fi
+cd ..
+
+#Weird behaviour of Dakota: libamplsolver.a and amplsolver.a are not the same thing!
+cd install/lib
+mv libamplsolver.a libamplsolver.a.bak
+ln -s ../../src/packages/ampl/amplsolver.a ./libamplsolver.a
Index: /issm/trunk/externalpackages/dakota/install-4.2-pleiades.sh
===================================================================
--- /issm/trunk/externalpackages/dakota/install-4.2-pleiades.sh	(revision 14310)
+++ /issm/trunk/externalpackages/dakota/install-4.2-pleiades.sh	(revision 14310)
@@ -0,0 +1,97 @@
+#!/bin/bash
+set -eu
+
+#Some cleanup
+rm -rf Dakota
+rm -rf src
+rm -rf install
+mkdir src install
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/Dakota_4_3.src.tar.gz' 'Dakota_4_3.src.tar.gz'
+
+#Untar 
+tar -zxvf  Dakota_4_3.src.tar.gz
+
+#Move Dakota to src directory
+mv Dakota/* src
+rm -rf Dakota
+
+#Apply patches
+patch src/src/ParallelLibrary.C configs/4.2/ParallelLibrary.C.patch
+patch src/src/ParallelLibrary.H configs/4.2/ParallelLibrary.H.patch
+patch src/src/NIDRProblemDescDB.C configs/4.2/NIDRProblemDescDB.C.patch
+patch src/src/NonDSampling.C configs/4.2/NonDSampling.C.patch
+patch src/src/NonDLocalReliability.C configs/4.2/NonDLocalReliability.C.patch
+patch src/src/NonDUnilevelRBDO.C configs/4.2/NonDUnilevelRBDO.C.patch    #  source not even used?
+#patch -R src/packages/Pecos/src/LHSDriver.cpp configs/4.2/LHSDriver.cpp.patch
+
+#Configure dakota
+cd src
+./configure \
+--prefix="$ISSM_DIR/externalpackages/dakota/install/" \
+--without-graphics  \
+--with-pic \
+--disable-mpi \
+--with-blas="-L/nasa/intel/mkl/10.0.011/lib/64/ -lmkl -lmkl_lapack -liomp5 -lpthread" \
+--with-lapack="-L/nasa/intel/mkl/10.0.011/lib/64/ -lmkl -lmkl_lapack -liomp5 -lpthread"
+cd ..
+
+#Before compiling, if running on 64 bits, we need to active fPIC compilation. Some packages 
+#do not register -fPIC in Dakota, which is a problem. Edit the faulty Makefiles and add the -fPIC 
+#flag to the compilation.
+cat ./src/methods/NCSUOpt/Makefile | sed 's/FFLAGS = -g -O2/FFLAGS = -g -O2 -fPIC/g' >  temp
+mv temp ./src/methods/NCSUOpt/Makefile
+
+cat ./src/methods/acro/packages/pebbl/src/Makefile | sed 's/CXXFLAGS = -O2 -fpermissive/CXXFLAGS = -O2 -fpermissive -fPIC/g' > temp
+mv temp ./src/methods/acro/packages/pebbl/src/Makefile
+
+cat ./src/methods/hopspack/src-nappspack/Makefile | sed 's/CXXFLAGS = -g -O2/CXXFLAGS = -g -O2  -fPIC/g' > temp
+mv temp ./src/methods/hopspack/src-nappspack/Makefile
+
+cat ./src/methods/hopspack/src-cddlib/Makefile | sed 's/CFLAGS = -g -O2/CFLAGS = -g -O2 -fPIC/g' > temp
+mv temp  ./src/methods/hopspack/src-cddlib/Makefile
+
+cat ./src/methods/hopspack/src-shared/Makefile | sed 's/CFLAGS = -g -O2/CFLAGS = -g -O2 -fPIC/g' > temp
+mv temp  ./src/methods/hopspack/src-shared/Makefile
+
+cat ./src/methods/hopspack/src-shared/Makefile | sed 's/CXXFLAGS = -g -O2/CXXFLAGS = -g -O2  -fPIC/g' > temp
+mv temp  ./src/methods/hopspack/src-shared/Makefile
+
+cat ./src/methods/hopspack/src-conveyor/Makefile | sed 's/CXXFLAGS = -g -O2/CXXFLAGS = -g -O2 -fPIC/g' > temp
+mv temp  ./src/methods/hopspack/src-conveyor/Makefile
+
+cat ./src/methods/hopspack/src-appspack/Makefile | sed 's/CXXFLAGS = -g -O2/CXXFLAGS = -g -O2  -fPIC/g' > temp
+mv temp ./src/methods/hopspack/src-appspack/Makefile
+
+cat ./src/methods/acro/packages/colin/src/Makefile | sed 's/CXXFLAGS = -O2 -fpermissive/CXXFLAGS = -O2 -fpermissive -fPIC/g' > temp
+mv temp ./src/methods/acro/packages/colin/src/Makefile
+
+cat ./src/methods/acro/packages/coliny/src/Makefile | sed 's/CXXFLAGS = -O2 -fpermissive/CXXFLAGS = -O2 -fpermissive -fPIC/g' > temp
+mv temp ./src/methods/acro/packages/coliny/src/Makefile
+
+cat ./src/methods/acro/packages/tpl/3po/Makefile | sed 's/CFLAGS = -O2/CFLAGS = -O2 -fPIC/g' > temp
+mv temp  ./src/methods/acro/packages/tpl/3po/Makefile
+
+cat ./src/methods/acro/packages/tpl/3po/Makefile | sed 's/CXXFLAGS = -O2 -fpermissive/CFLAGS = -O2 -fpermissive -fPIC/g' > temp
+mv temp  ./src/methods/acro/packages/tpl/3po/Makefile
+
+cat ./src/packages/ampl/Makefile | sed 's/CFLAGS = -g -O2/CFLAGS = -g -O2 -fPIC/g' > temp
+mv temp  ./src/packages/ampl/Makefile
+
+#Compile and install dakota
+cd src
+if [ $# -eq 0 ];
+then
+	make
+	make install
+else
+	make -j $1
+	make -j $1 install
+fi
+cd ..
+
+#Weird behaviour of Dakota: libamplsolver.a and amplsolver.a are not the same thing!
+cd install/lib
+mv libamplsolver.a libamplsolver.a.bak
+ln -s ../../src/packages/ampl/amplsolver.a ./libamplsolver.a
Index: /issm/trunk/externalpackages/dakota/install-5.2-linux64-astrid.sh
===================================================================
--- /issm/trunk/externalpackages/dakota/install-5.2-linux64-astrid.sh	(revision 14310)
+++ /issm/trunk/externalpackages/dakota/install-5.2-linux64-astrid.sh	(revision 14310)
@@ -0,0 +1,51 @@
+#!/bin/bash
+set -eu
+
+#Some cleanup
+rm -rf Dakota
+rm -rf src 
+rm -rf install 
+mkdir src install 
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/Dakota_5_2.src.tar.gz' 'Dakota_5_2.src.tar.gz'
+
+#Untar 
+tar -zxvf Dakota_5_2.src.tar.gz
+
+#Move Dakota to src directory
+mv Dakota/* src
+rm -rf Dakota
+
+#Apply patches
+patch src/src/ParallelLibrary.C configs/5.2/ParallelLibrary.C.patch
+patch src/src/ParallelLibrary.H configs/5.2/ParallelLibrary.H.patch
+#patch src/src/NIDRProblemDescDB.C configs/5.2/NIDRProblemDescDB.C.patch    #  causes segfault in 5.2
+patch src/src/NonDSampling.C configs/5.2/NonDSampling.C.patch
+patch src/src/NonDLocalReliability.C configs/5.2/NonDLocalReliability.C.patch
+patch src/src/NonDUnilevelRBDO.C configs/5.2/NonDUnilevelRBDO.C.patch    #  source not even used?
+patch src/packages/pecos/src/pecos_global_defs.hpp configs/5.2/pecos_global_defs.hpp.patch
+
+#Configure dakota
+cd src
+./configure \
+	--prefix="$ISSM_DIR/externalpackages/dakota/install" \
+	--without-graphics  \
+	--with-pic \
+	--disable-mpi \
+	--with-plugin \
+	--with-blas=/usr/lib64/libblas.so.3.0.3 \
+	--with-lapack=/usr/lib64/liblapack.so.3.0.3
+cd ..
+
+#Compile and install dakota
+cd src 
+if [ $# -eq 0 ];
+then
+	make
+	make install
+else
+	make -j $1
+	make -j $1 install
+fi
+cd ..
Index: sm/trunk/externalpackages/dakota/install-altix64-cosmos.sh
===================================================================
--- /issm/trunk/externalpackages/dakota/install-altix64-cosmos.sh	(revision 14309)
+++ 	(revision )
@@ -1,97 +1,0 @@
-#!/bin/bash
-set -eu
-
-#Some cleanup
-rm -rf Dakota
-rm -rf src 
-rm -rf install 
-mkdir src install 
-
-#Download from ISSM server
-$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/Dakota_4_3.src.tar.gz' 'Dakota_4_3.src.tar.gz'
-
-#Untar 
-tar -zxvf  Dakota_4_3.src.tar.gz
-
-#Move Dakota to src directory
-mv Dakota/* src
-rm -rf Dakota
-
-#Apply patches
-patch src/src/ParallelLibrary.C ./ParallelLibrary.C.patch
-patch src/src/ParallelLibrary.H ./ParallelLibrary.H.patch
-patch src/src/NIDRProblemDescDB.C ./NIDRProblemDescDB.C.patch
-patch src/src/NonDSampling.C ./NonDSampling.C.patch
-patch src/src/NonDLocalReliability.C ./NonDLocalReliability.C.patch
-patch src/src/NonDUnilevelRBDO.C ./NonDUnilevelRBDO.C.patch    #  source not even used?
-#patch -R src/packages/Pecos/src/LHSDriver.cpp ./LHSDriver.cpp.patch
-
-#Configure dakota
-cd src
-./configure \ 
-	--prefix="$ISSM_DIR/externalpackages/dakota/install" \
-	--without-graphics  \
-	--with-pic \
-	--disable-mpi \
-	--with-blas=/opt/intel/mkl/9.1.023/lib/64/libmkl.so \
-	--with-lapack=/opt/intel/mkl/9.1.023/lib/64/libmkl_lapack.so 
-cd ..
-
-#Before compiling, if running on 64 bits, we need to active fPIC compilation. Some packages 
-#do not register -fPIC in Dakota, which is a problem. Edit the faulty Makefiles and add the -fPIC 
-#flag to the compilation.
-cat ./src/methods/NCSUOpt/Makefile | sed 's/FFLAGS = -g -O2/FFLAGS = -g -O2 -fPIC/g' >  temp
-mv temp ./src/methods/NCSUOpt/Makefile
-
-cat ./src/methods/acro/packages/pebbl/src/Makefile | sed 's/CXXFLAGS = -O2 -fpermissive/CXXFLAGS = -O2 -fpermissive -fPIC/g' > temp
-mv temp ./src/methods/acro/packages/pebbl/src/Makefile
-
-cat ./src/methods/hopspack/src-nappspack/Makefile | sed 's/CXXFLAGS = -g -O2/CXXFLAGS = -g -O2  -fPIC/g' > temp
-mv temp ./src/methods/hopspack/src-nappspack/Makefile
-
-cat ./src/methods/hopspack/src-cddlib/Makefile | sed 's/CFLAGS = -g -O2/CFLAGS = -g -O2 -fPIC/g' > temp
-mv temp  ./src/methods/hopspack/src-cddlib/Makefile 
-
-cat ./src/methods/hopspack/src-shared/Makefile | sed 's/CFLAGS = -g -O2/CFLAGS = -g -O2 -fPIC/g' > temp
-mv temp  ./src/methods/hopspack/src-shared/Makefile 
-
-cat ./src/methods/hopspack/src-shared/Makefile | sed 's/CXXFLAGS = -g -O2/CXXFLAGS = -g -O2  -fPIC/g' > temp
-mv temp  ./src/methods/hopspack/src-shared/Makefile 
-
-cat ./src/methods/hopspack/src-conveyor/Makefile | sed 's/CXXFLAGS = -g -O2/CXXFLAGS = -g -O2 -fPIC/g' > temp
-mv temp  ./src/methods/hopspack/src-conveyor/Makefile 
-
-cat ./src/methods/hopspack/src-appspack/Makefile | sed 's/CXXFLAGS = -g -O2/CXXFLAGS = -g -O2  -fPIC/g' > temp
-mv temp ./src/methods/hopspack/src-appspack/Makefile 
-
-cat ./src/methods/acro/packages/colin/src/Makefile | sed 's/CXXFLAGS = -O2 -fpermissive/CXXFLAGS = -O2 -fpermissive -fPIC/g' > temp
-mv temp ./src/methods/acro/packages/colin/src/Makefile
-
-cat ./src/methods/acro/packages/coliny/src/Makefile | sed 's/CXXFLAGS = -O2 -fpermissive/CXXFLAGS = -O2 -fpermissive -fPIC/g' > temp
-mv temp ./src/methods/acro/packages/coliny/src/Makefile
-
-cat ./src/methods/acro/packages/tpl/3po/Makefile | sed 's/CFLAGS = -O2/CFLAGS = -O2 -fPIC/g' > temp
-mv temp  ./src/methods/acro/packages/tpl/3po/Makefile 
-
-cat ./src/methods/acro/packages/tpl/3po/Makefile | sed 's/CXXFLAGS = -O2 -fpermissive/CFLAGS = -O2 -fpermissive -fPIC/g' > temp
-mv temp  ./src/methods/acro/packages/tpl/3po/Makefile 
-
-cat ./src/packages/ampl/Makefile | sed 's/CFLAGS = -g -O2/CFLAGS = -g -O2 -fPIC/g' > temp
-mv temp  ./src/packages/ampl/Makefile 
-
-#Compile and install dakota
-cd src 
-if [ $# -eq 0 ];
-then
-	make
-	make install
-else
-	make -j $1
-	make -j $1 install
-fi
-cd ..
-
-#Weird behaviour of Dakota: libamplsolver.a and amplsolver.a are not the same thing!
-cd install/lib
-mv libamplsolver.a libamplsolver.a.bak
-ln -s ../../src/packages/ampl/amplsolver.a ./libamplsolver.a
Index: sm/trunk/externalpackages/dakota/install-discover.sh
===================================================================
--- /issm/trunk/externalpackages/dakota/install-discover.sh	(revision 14309)
+++ 	(revision )
@@ -1,97 +1,0 @@
-#!/bin/bash
-set -eu
-
-#Some cleanup
-rm -rf Dakota
-rm -rf src
-rm -rf install
-mkdir src install
-
-#Download from ISSM server
-$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/Dakota_4_3.src.tar.gz' 'Dakota_4_3.src.tar.gz'
-
-#Untar 
-tar -zxvf  Dakota_4_3.src.tar.gz
-
-#Move Dakota to src directory
-mv Dakota/* src
-rm -rf Dakota
-
-#Apply patches
-patch src/src/ParallelLibrary.C ./ParallelLibrary.C.patch
-patch src/src/ParallelLibrary.H ./ParallelLibrary.H.patch
-patch src/src/NIDRProblemDescDB.C ./NIDRProblemDescDB.C.patch
-patch src/src/NonDSampling.C ./NonDSampling.C.patch
-patch src/src/NonDLocalReliability.C ./NonDLocalReliability.C.patch
-patch src/src/NonDUnilevelRBDO.C ./NonDUnilevelRBDO.C.patch    #  source not even used?
-#patch -R src/packages/Pecos/src/LHSDriver.cpp ./LHSDriver.cpp.patch
-
-#Configure dakota
-cd src
-./configure \
---prefix="$ISSM_DIR/externalpackages/dakota/install/" \
---without-graphics  \
---with-pic \
---disable-mpi \
---with-blas="-L/usr/local/intel/mkl/10.1.2.024/lib/64 -lmkl_lapack -lmkl -lguide -lpthread" \
---with-lapack="-L/usr/local/intel/mkl/10.1.2.024/lib/64 -lmkl_lapack -lmkl -lguide -lpthread"
-cd ..
-
-#Before compiling, if running on 64 bits, we need to active fPIC compilation. Some packages 
-#do not register -fPIC in Dakota, which is a problem. Edit the faulty Makefiles and add the -fPIC 
-#flag to the compilation.
-cat ./src/methods/NCSUOpt/Makefile | sed 's/FFLAGS = -g -O2/FFLAGS = -g -O2 -fPIC/g' >  temp
-mv temp ./src/methods/NCSUOpt/Makefile
-
-cat ./src/methods/acro/packages/pebbl/src/Makefile | sed 's/CXXFLAGS = -O2 -fpermissive/CXXFLAGS = -O2 -fpermissive -fPIC/g' > temp
-mv temp ./src/methods/acro/packages/pebbl/src/Makefile
-
-cat ./src/methods/hopspack/src-nappspack/Makefile | sed 's/CXXFLAGS = -g -O2/CXXFLAGS = -g -O2  -fPIC/g' > temp
-mv temp ./src/methods/hopspack/src-nappspack/Makefile
-
-cat ./src/methods/hopspack/src-cddlib/Makefile | sed 's/CFLAGS = -g -O2/CFLAGS = -g -O2 -fPIC/g' > temp
-mv temp  ./src/methods/hopspack/src-cddlib/Makefile
-
-cat ./src/methods/hopspack/src-shared/Makefile | sed 's/CFLAGS = -g -O2/CFLAGS = -g -O2 -fPIC/g' > temp
-mv temp  ./src/methods/hopspack/src-shared/Makefile
-
-cat ./src/methods/hopspack/src-shared/Makefile | sed 's/CXXFLAGS = -g -O2/CXXFLAGS = -g -O2  -fPIC/g' > temp
-mv temp  ./src/methods/hopspack/src-shared/Makefile
-
-cat ./src/methods/hopspack/src-conveyor/Makefile | sed 's/CXXFLAGS = -g -O2/CXXFLAGS = -g -O2 -fPIC/g' > temp
-mv temp  ./src/methods/hopspack/src-conveyor/Makefile
-
-cat ./src/methods/hopspack/src-appspack/Makefile | sed 's/CXXFLAGS = -g -O2/CXXFLAGS = -g -O2  -fPIC/g' > temp
-mv temp ./src/methods/hopspack/src-appspack/Makefile
-
-cat ./src/methods/acro/packages/colin/src/Makefile | sed 's/CXXFLAGS = -O2 -fpermissive/CXXFLAGS = -O2 -fpermissive -fPIC/g' > temp
-mv temp ./src/methods/acro/packages/colin/src/Makefile
-
-cat ./src/methods/acro/packages/coliny/src/Makefile | sed 's/CXXFLAGS = -O2 -fpermissive/CXXFLAGS = -O2 -fpermissive -fPIC/g' > temp
-mv temp ./src/methods/acro/packages/coliny/src/Makefile
-
-cat ./src/methods/acro/packages/tpl/3po/Makefile | sed 's/CFLAGS = -O2/CFLAGS = -O2 -fPIC/g' > temp
-mv temp  ./src/methods/acro/packages/tpl/3po/Makefile
-
-cat ./src/methods/acro/packages/tpl/3po/Makefile | sed 's/CXXFLAGS = -O2 -fpermissive/CFLAGS = -O2 -fpermissive -fPIC/g' > temp
-mv temp  ./src/methods/acro/packages/tpl/3po/Makefile
-
-cat ./src/packages/ampl/Makefile | sed 's/CFLAGS = -g -O2/CFLAGS = -g -O2 -fPIC/g' > temp
-mv temp  ./src/packages/ampl/Makefile
-
-#Compile and install dakota
-cd src
-if [ $# -eq 0 ];
-then
-	make
-	make install
-else
-	make -j $1
-	make -j $1 install
-fi
-cd ..
-
-#Weird behaviour of Dakota: libamplsolver.a and amplsolver.a are not the same thing!
-cd install/lib
-mv libamplsolver.a libamplsolver.a.bak
-ln -s ../../src/packages/ampl/amplsolver.a ./libamplsolver.a
Index: sm/trunk/externalpackages/dakota/install-linux64-astrid.sh
===================================================================
--- /issm/trunk/externalpackages/dakota/install-linux64-astrid.sh	(revision 14309)
+++ 	(revision )
@@ -1,97 +1,0 @@
-#!/bin/bash
-set -eu
-
-#Some cleanup
-rm -rf Dakota
-rm -rf src 
-rm -rf install 
-mkdir src install 
-
-#Download from ISSM server
-$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/Dakota_4_3.src.tar.gz' 'Dakota_4_3.src.tar.gz'
-
-#Untar 
-tar -zxvf  Dakota_4_3.src.tar.gz
-
-#Move Dakota to src directory
-mv Dakota/* src
-rm -rf Dakota
-
-#Apply patches
-patch src/src/ParallelLibrary.C ./ParallelLibrary.C.patch
-patch src/src/ParallelLibrary.H ./ParallelLibrary.H.patch
-patch src/src/NIDRProblemDescDB.C ./NIDRProblemDescDB.C.patch
-patch src/src/NonDSampling.C ./NonDSampling.C.patch
-patch src/src/NonDLocalReliability.C ./NonDLocalReliability.C.patch
-patch src/src/NonDUnilevelRBDO.C ./NonDUnilevelRBDO.C.patch    #  source not even used?
-#patch -R src/packages/Pecos/src/LHSDriver.cpp ./LHSDriver.cpp.patch
-
-#Configure dakota
-cd src
-./configure \
-	--prefix="$ISSM_DIR/externalpackages/dakota/install" \
-	--without-graphics  \
-	--with-pic \
-	--disable-mpi \
-	--with-blas=/usr/lib64/libblas.so.3.0.3 \
-	--with-lapack=/usr/lib64/liblapack.so.3.0.3
-cd ..
-
-#Before compiling, if running on 64 bits, we need to active fPIC compilation. Some packages 
-#do not register -fPIC in Dakota, which is a problem. Edit the faulty Makefiles and add the -fPIC 
-#flag to the compilation.
-cat ./src/methods/NCSUOpt/Makefile | sed 's/FFLAGS = -g -O2/FFLAGS = -g -O2 -fPIC/g' >  temp
-mv temp ./src/methods/NCSUOpt/Makefile
-
-cat ./src/methods/acro/packages/pebbl/src/Makefile | sed 's/CXXFLAGS = -O2 -fpermissive/CXXFLAGS = -O2 -fpermissive -fPIC/g' > temp
-mv temp ./src/methods/acro/packages/pebbl/src/Makefile
-
-cat ./src/methods/hopspack/src-nappspack/Makefile | sed 's/CXXFLAGS = -g -O2/CXXFLAGS = -g -O2  -fPIC/g' > temp
-mv temp ./src/methods/hopspack/src-nappspack/Makefile
-
-cat ./src/methods/hopspack/src-cddlib/Makefile | sed 's/CFLAGS = -g -O2/CFLAGS = -g -O2 -fPIC/g' > temp
-mv temp  ./src/methods/hopspack/src-cddlib/Makefile 
-
-cat ./src/methods/hopspack/src-shared/Makefile | sed 's/CFLAGS = -g -O2/CFLAGS = -g -O2 -fPIC/g' > temp
-mv temp  ./src/methods/hopspack/src-shared/Makefile 
-
-cat ./src/methods/hopspack/src-shared/Makefile | sed 's/CXXFLAGS = -g -O2/CXXFLAGS = -g -O2  -fPIC/g' > temp
-mv temp  ./src/methods/hopspack/src-shared/Makefile 
-
-cat ./src/methods/hopspack/src-conveyor/Makefile | sed 's/CXXFLAGS = -g -O2/CXXFLAGS = -g -O2 -fPIC/g' > temp
-mv temp  ./src/methods/hopspack/src-conveyor/Makefile 
-
-cat ./src/methods/hopspack/src-appspack/Makefile | sed 's/CXXFLAGS = -g -O2/CXXFLAGS = -g -O2  -fPIC/g' > temp
-mv temp ./src/methods/hopspack/src-appspack/Makefile 
-
-cat ./src/methods/acro/packages/colin/src/Makefile | sed 's/CXXFLAGS = -O2 -fpermissive/CXXFLAGS = -O2 -fpermissive -fPIC/g' > temp
-mv temp ./src/methods/acro/packages/colin/src/Makefile
-
-cat ./src/methods/acro/packages/coliny/src/Makefile | sed 's/CXXFLAGS = -O2 -fpermissive/CXXFLAGS = -O2 -fpermissive -fPIC/g' > temp
-mv temp ./src/methods/acro/packages/coliny/src/Makefile
-
-cat ./src/methods/acro/packages/tpl/3po/Makefile | sed 's/CFLAGS = -O2/CFLAGS = -O2 -fPIC/g' > temp
-mv temp  ./src/methods/acro/packages/tpl/3po/Makefile 
-
-cat ./src/methods/acro/packages/tpl/3po/Makefile | sed 's/CXXFLAGS = -O2 -fpermissive/CFLAGS = -O2 -fpermissive -fPIC/g' > temp
-mv temp  ./src/methods/acro/packages/tpl/3po/Makefile 
-
-cat ./src/packages/ampl/Makefile | sed 's/CFLAGS = -g -O2/CFLAGS = -g -O2 -fPIC/g' > temp
-mv temp  ./src/packages/ampl/Makefile 
-
-#Compile and install dakota
-cd src 
-if [ $# -eq 0 ];
-then
-	make
-	make install
-else
-	make -j $1
-	make -j $1 install
-fi
-cd ..
-
-#Weird behaviour of Dakota: libamplsolver.a and amplsolver.a are not the same thing!
-cd install/lib
-mv libamplsolver.a libamplsolver.a.bak
-ln -s ../../src/packages/ampl/amplsolver.a ./libamplsolver.a
Index: sm/trunk/externalpackages/dakota/install-linux64-cloud.sh
===================================================================
--- /issm/trunk/externalpackages/dakota/install-linux64-cloud.sh	(revision 14309)
+++ 	(revision )
@@ -1,97 +1,0 @@
-#!/bin/bash
-set -eu
-
-#Some cleanup
-rm -rf Dakota
-rm -rf src 
-rm -rf install 
-mkdir src install 
-
-#Download from ISSM server
-$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/Dakota_4_3.src.tar.gz' 'Dakota_4_3.src.tar.gz'
-
-#Untar 
-tar -zxvf  Dakota_4_3.src.tar.gz
-
-#Move Dakota to src directory
-mv Dakota/* src
-rm -rf Dakota
-
-#Apply patches
-patch src/src/ParallelLibrary.C ./ParallelLibrary.C.patch
-patch src/src/ParallelLibrary.H ./ParallelLibrary.H.patch
-patch src/src/NIDRProblemDescDB.C ./NIDRProblemDescDB.C.patch
-patch src/src/NonDSampling.C ./NonDSampling.C.patch
-patch src/src/NonDLocalReliability.C ./NonDLocalReliability.C.patch
-patch src/src/NonDUnilevelRBDO.C ./NonDUnilevelRBDO.C.patch    #  source not even used?
-#patch -R src/packages/Pecos/src/LHSDriver.cpp ./LHSDriver.cpp.patch
-
-#Configure dakota
-cd src
-./configure \
-	--prefix="$ISSM_DIR/externalpackages/dakota/install" \
-	--without-graphics  \
-	--with-pic \
-	--disable-mpi \
-	--with-blas=/usr/lib/libblas.so \
-	--with-lapack=/usr/lib/liblapack.so
-cd ..
-
-#Before compiling, if running on 64 bits, we need to active fPIC compilation. Some packages 
-#do not register -fPIC in Dakota, which is a problem. Edit the faulty Makefiles and add the -fPIC 
-#flag to the compilation.
-cat ./src/methods/NCSUOpt/Makefile | sed 's/FFLAGS = -g -O2/FFLAGS = -g -O2 -fPIC/g' >  temp
-mv temp ./src/methods/NCSUOpt/Makefile
-
-cat ./src/methods/acro/packages/pebbl/src/Makefile | sed 's/CXXFLAGS = -O2 -fpermissive/CXXFLAGS = -O2 -fpermissive -fPIC/g' > temp
-mv temp ./src/methods/acro/packages/pebbl/src/Makefile
-
-cat ./src/methods/hopspack/src-nappspack/Makefile | sed 's/CXXFLAGS = -g -O2/CXXFLAGS = -g -O2  -fPIC/g' > temp
-mv temp ./src/methods/hopspack/src-nappspack/Makefile
-
-cat ./src/methods/hopspack/src-cddlib/Makefile | sed 's/CFLAGS = -g -O2/CFLAGS = -g -O2 -fPIC/g' > temp
-mv temp  ./src/methods/hopspack/src-cddlib/Makefile 
-
-cat ./src/methods/hopspack/src-shared/Makefile | sed 's/CFLAGS = -g -O2/CFLAGS = -g -O2 -fPIC/g' > temp
-mv temp  ./src/methods/hopspack/src-shared/Makefile 
-
-cat ./src/methods/hopspack/src-shared/Makefile | sed 's/CXXFLAGS = -g -O2/CXXFLAGS = -g -O2  -fPIC/g' > temp
-mv temp  ./src/methods/hopspack/src-shared/Makefile 
-
-cat ./src/methods/hopspack/src-conveyor/Makefile | sed 's/CXXFLAGS = -g -O2/CXXFLAGS = -g -O2 -fPIC/g' > temp
-mv temp  ./src/methods/hopspack/src-conveyor/Makefile 
-
-cat ./src/methods/hopspack/src-appspack/Makefile | sed 's/CXXFLAGS = -g -O2/CXXFLAGS = -g -O2  -fPIC/g' > temp
-mv temp ./src/methods/hopspack/src-appspack/Makefile 
-
-cat ./src/methods/acro/packages/colin/src/Makefile | sed 's/CXXFLAGS = -O2 -fpermissive/CXXFLAGS = -O2 -fpermissive -fPIC/g' > temp
-mv temp ./src/methods/acro/packages/colin/src/Makefile
-
-cat ./src/methods/acro/packages/coliny/src/Makefile | sed 's/CXXFLAGS = -O2 -fpermissive/CXXFLAGS = -O2 -fpermissive -fPIC/g' > temp
-mv temp ./src/methods/acro/packages/coliny/src/Makefile
-
-cat ./src/methods/acro/packages/tpl/3po/Makefile | sed 's/CFLAGS = -O2/CFLAGS = -O2 -fPIC/g' > temp
-mv temp  ./src/methods/acro/packages/tpl/3po/Makefile 
-
-cat ./src/methods/acro/packages/tpl/3po/Makefile | sed 's/CXXFLAGS = -O2 -fpermissive/CFLAGS = -O2 -fpermissive -fPIC/g' > temp
-mv temp  ./src/methods/acro/packages/tpl/3po/Makefile 
-
-cat ./src/packages/ampl/Makefile | sed 's/CFLAGS = -g -O2/CFLAGS = -g -O2 -fPIC/g' > temp
-mv temp  ./src/packages/ampl/Makefile 
-
-#Compile and install dakota
-cd src 
-if [ $# -eq 0 ];
-then
-	make
-	make install
-else
-	make -j $1
-	make -j $1 install
-fi
-cd ..
-
-#Weird behaviour of Dakota: libamplsolver.a and amplsolver.a are not the same thing!
-cd install/lib
-mv libamplsolver.a libamplsolver.a.bak
-ln -s ../../src/packages/ampl/amplsolver.a ./libamplsolver.a
Index: sm/trunk/externalpackages/dakota/install-linux64-murdo.sh
===================================================================
--- /issm/trunk/externalpackages/dakota/install-linux64-murdo.sh	(revision 14309)
+++ 	(revision )
@@ -1,97 +1,0 @@
-#!/bin/bash
-set -eu
-
-#Some cleanup
-rm -rf Dakota
-rm -rf src 
-rm -rf install 
-mkdir src install 
-
-#Download from ISSM server
-$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/Dakota_4_3.src.tar.gz' 'Dakota_4_3.src.tar.gz'
-
-#Untar 
-tar -zxvf  Dakota_4_3.src.tar.gz
-
-#Move Dakota to src directory
-mv Dakota/* src
-rm -rf Dakota
-
-#Apply patches
-patch src/src/ParallelLibrary.C ./ParallelLibrary.C.patch
-patch src/src/ParallelLibrary.H ./ParallelLibrary.H.patch
-patch src/src/NIDRProblemDescDB.C ./NIDRProblemDescDB.C.patch
-patch src/src/NonDSampling.C ./NonDSampling.C.patch
-patch src/src/NonDLocalReliability.C ./NonDLocalReliability.C.patch
-patch src/src/NonDUnilevelRBDO.C ./NonDUnilevelRBDO.C.patch    #  source not even used?
-#patch -R src/packages/Pecos/src/LHSDriver.cpp ./LHSDriver.cpp.patch
-
-#Configure dakota
-cd src
-./configure \
-	--prefix="$ISSM_DIR/externalpackages/dakota/install" \
-	--without-graphics  \
-	--with-pic \
-	--disable-mpi \
-	--with-blas=/usr/lib64/libblas.so.3.1.1 \
-	--with-lapack=/usr/lib64/liblapack.so.3.1.1
-cd ..
-
-#Before compiling, if running on 64 bits, we need to active fPIC compilation. Some packages 
-#do not register -fPIC in Dakota, which is a problem. Edit the faulty Makefiles and add the -fPIC 
-#flag to the compilation.
-cat ./src/methods/NCSUOpt/Makefile | sed 's/FFLAGS = -g -O2/FFLAGS = -g -O2 -fPIC/g' >  temp
-mv temp ./src/methods/NCSUOpt/Makefile
-
-cat ./src/methods/acro/packages/pebbl/src/Makefile | sed 's/CXXFLAGS = -O2 -fpermissive/CXXFLAGS = -O2 -fpermissive -fPIC/g' > temp
-mv temp ./src/methods/acro/packages/pebbl/src/Makefile
-
-cat ./src/methods/hopspack/src-nappspack/Makefile | sed 's/CXXFLAGS = -g -O2/CXXFLAGS = -g -O2  -fPIC/g' > temp
-mv temp ./src/methods/hopspack/src-nappspack/Makefile
-
-cat ./src/methods/hopspack/src-cddlib/Makefile | sed 's/CFLAGS = -g -O2/CFLAGS = -g -O2 -fPIC/g' > temp
-mv temp  ./src/methods/hopspack/src-cddlib/Makefile 
-
-cat ./src/methods/hopspack/src-shared/Makefile | sed 's/CFLAGS = -g -O2/CFLAGS = -g -O2 -fPIC/g' > temp
-mv temp  ./src/methods/hopspack/src-shared/Makefile 
-
-cat ./src/methods/hopspack/src-shared/Makefile | sed 's/CXXFLAGS = -g -O2/CXXFLAGS = -g -O2  -fPIC/g' > temp
-mv temp  ./src/methods/hopspack/src-shared/Makefile 
-
-cat ./src/methods/hopspack/src-conveyor/Makefile | sed 's/CXXFLAGS = -g -O2/CXXFLAGS = -g -O2 -fPIC/g' > temp
-mv temp  ./src/methods/hopspack/src-conveyor/Makefile 
-
-cat ./src/methods/hopspack/src-appspack/Makefile | sed 's/CXXFLAGS = -g -O2/CXXFLAGS = -g -O2  -fPIC/g' > temp
-mv temp ./src/methods/hopspack/src-appspack/Makefile 
-
-cat ./src/methods/acro/packages/colin/src/Makefile | sed 's/CXXFLAGS = -O2 -fpermissive/CXXFLAGS = -O2 -fpermissive -fPIC/g' > temp
-mv temp ./src/methods/acro/packages/colin/src/Makefile
-
-cat ./src/methods/acro/packages/coliny/src/Makefile | sed 's/CXXFLAGS = -O2 -fpermissive/CXXFLAGS = -O2 -fpermissive -fPIC/g' > temp
-mv temp ./src/methods/acro/packages/coliny/src/Makefile
-
-cat ./src/methods/acro/packages/tpl/3po/Makefile | sed 's/CFLAGS = -O2/CFLAGS = -O2 -fPIC/g' > temp
-mv temp  ./src/methods/acro/packages/tpl/3po/Makefile 
-
-cat ./src/methods/acro/packages/tpl/3po/Makefile | sed 's/CXXFLAGS = -O2 -fpermissive/CFLAGS = -O2 -fpermissive -fPIC/g' > temp
-mv temp  ./src/methods/acro/packages/tpl/3po/Makefile 
-
-cat ./src/packages/ampl/Makefile | sed 's/CFLAGS = -g -O2/CFLAGS = -g -O2 -fPIC/g' > temp
-mv temp  ./src/packages/ampl/Makefile 
-
-#Compile and install dakota
-cd src 
-if [ $# -eq 0 ];
-then
-	make
-	make install
-else
-	make -j $1
-	make -j $1 install
-fi
-cd ..
-
-#Weird behaviour of Dakota: libamplsolver.a and amplsolver.a are not the same thing!
-cd install/lib
-mv libamplsolver.a libamplsolver.a.bak
-ln -s ../../src/packages/ampl/amplsolver.a ./libamplsolver.a
Index: sm/trunk/externalpackages/dakota/install-macosx64.sh
===================================================================
--- /issm/trunk/externalpackages/dakota/install-macosx64.sh	(revision 14309)
+++ 	(revision )
@@ -1,97 +1,0 @@
-#!/bin/bash
-set -eu
-
-#Some cleanup
-rm -rf Dakota
-rm -rf src 
-rm -rf install 
-mkdir src install 
-
-#Download from ISSM server
-$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/Dakota_4_3.src.tar.gz' 'Dakota_4_3.src.tar.gz'
-
-#Untar 
-tar -zxvf  Dakota_4_3.src.tar.gz
-
-#Move Dakota to src directory
-mv Dakota/* src
-rm -rf Dakota
-
-#Apply patches
-patch src/src/ParallelLibrary.C ./ParallelLibrary.C.patch
-patch src/src/ParallelLibrary.H ./ParallelLibrary.H.patch
-patch src/src/NIDRProblemDescDB.C ./NIDRProblemDescDB.C.patch
-patch src/src/NonDSampling.C ./NonDSampling.C.patch
-patch src/src/NonDLocalReliability.C ./NonDLocalReliability.C.patch
-patch src/src/NonDUnilevelRBDO.C ./NonDUnilevelRBDO.C.patch    #  source not even used?
-#patch -R src/packages/Pecos/src/LHSDriver.cpp ./LHSDriver.cpp.patch
-
-#Configure dakota
-cd src
-./configure \
-   --prefix="$ISSM_DIR/externalpackages/dakota/install" \
-   --without-graphics  \
-   --with-pic \
-   --disable-mpi \
-   --with-blas="-L$ISSM_DIR/externalpackages/petsc/install/lib -lfblas " \
-   --with-lapack="-L$ISSM_DIR/externalpackages/petsc/install/lib -lflapack "
-cd ..
-
-#Before compiling, if running on 64 bits, we need to active fPIC compilation. Some packages 
-#do not register -fPIC in Dakota, which is a problem. Edit the faulty Makefiles and add the -fPIC 
-#flag to the compilation.
-cat ./src/methods/NCSUOpt/Makefile | sed 's/FFLAGS = -g -O2/FFLAGS = -g -O2 -fPIC/g' >  temp
-mv temp ./src/methods/NCSUOpt/Makefile
-
-cat ./src/methods/acro/packages/pebbl/src/Makefile | sed 's/CXXFLAGS = -O2 -fpermissive/CXXFLAGS = -O2 -fpermissive -fPIC/g' > temp
-mv temp ./src/methods/acro/packages/pebbl/src/Makefile
-
-cat ./src/methods/hopspack/src-nappspack/Makefile | sed 's/CXXFLAGS = -g -O2/CXXFLAGS = -g -O2 -fPIC/g' > temp
-mv temp ./src/methods/hopspack/src-nappspack/Makefile
-
-cat ./src/methods/hopspack/src-cddlib/Makefile | sed 's/CFLAGS = -g -O2/CFLAGS = -g -O2 -fPIC/g' > temp
-mv temp  ./src/methods/hopspack/src-cddlib/Makefile 
-
-cat ./src/methods/hopspack/src-shared/Makefile | sed 's/CFLAGS = -g -O2/CFLAGS = -g -O2 -fPIC/g' > temp
-mv temp  ./src/methods/hopspack/src-shared/Makefile 
-
-cat ./src/methods/hopspack/src-shared/Makefile | sed 's/CXXFLAGS = -g -O2/CXXFLAGS = -g -O2 -fPIC/g' > temp
-mv temp  ./src/methods/hopspack/src-shared/Makefile 
-
-cat ./src/methods/hopspack/src-conveyor/Makefile | sed 's/CXXFLAGS = -g -O2/CXXFLAGS = -g -O2 -fPIC/g' > temp
-mv temp  ./src/methods/hopspack/src-conveyor/Makefile 
-
-cat ./src/methods/hopspack/src-appspack/Makefile | sed 's/CXXFLAGS = -g -O2/CXXFLAGS = -g -O2 -fPIC/g' > temp
-mv temp ./src/methods/hopspack/src-appspack/Makefile 
-
-cat ./src/methods/acro/packages/colin/src/Makefile | sed 's/CXXFLAGS = -O2 -fpermissive/CXXFLAGS = -O2 -fpermissive -fPIC/g' > temp
-mv temp ./src/methods/acro/packages/colin/src/Makefile
-
-cat ./src/methods/acro/packages/coliny/src/Makefile | sed 's/CXXFLAGS = -O2 -fpermissive/CXXFLAGS = -O2 -fpermissive -fPIC/g' > temp
-mv temp ./src/methods/acro/packages/coliny/src/Makefile
-
-cat ./src/methods/acro/packages/tpl/3po/Makefile | sed 's/CFLAGS = -O2/CFLAGS = -O2 -fPIC/g' > temp
-mv temp  ./src/methods/acro/packages/tpl/3po/Makefile 
-
-cat ./src/methods/acro/packages/tpl/3po/Makefile | sed 's/CXXFLAGS = -O2 -fpermissive/CFLAGS = -O2 -fpermissive -fPIC/g' > temp
-mv temp  ./src/methods/acro/packages/tpl/3po/Makefile 
-
-cat ./src/packages/ampl/Makefile | sed 's/CFLAGS = -g -O2 -D_NONSTD_SOURCE/CFLAGS = -g -O2 -fPIC/g' > temp
-mv temp  ./src/packages/ampl/Makefile 
-
-#Compile and install dakota
-cd src 
-if [ $# -eq 0 ];
-then
-	make
-	make install
-else
-	make -j $1
-	make -j $1 install
-fi
-cd ..
-
-#Weird behaviour of Dakota: libamplsolver.a and amplsolver.a are not the same thing!
-cd install/lib
-mv libamplsolver.a libamplsolver.a.bak
-ln -s ../../src/packages/ampl/amplsolver.a ./libamplsolver.a
Index: sm/trunk/externalpackages/dakota/install-pleiades-petsc3.3.sh
===================================================================
--- /issm/trunk/externalpackages/dakota/install-pleiades-petsc3.3.sh	(revision 14309)
+++ 	(revision )
@@ -1,103 +1,0 @@
-#!/bin/bash
-set -eu
-
-#Some cleanup
-rm -rf Dakota
-rm -rf src
-rm -rf install
-mkdir src install
-
-#Download from ISSM server
-$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/Dakota_4_3.src.tar.gz' 'Dakota_4_3.src.tar.gz'
-
-#Untar 
-tar -zxvf  Dakota_4_3.src.tar.gz
-
-#Move Dakota to src directory
-mv Dakota/* src
-rm -rf Dakota
-
-#Apply patches
-patch src/src/ParallelLibrary.C ./ParallelLibrary.C.patch
-patch src/src/ParallelLibrary.H ./ParallelLibrary.H.patch
-patch src/src/NIDRProblemDescDB.C ./NIDRProblemDescDB.C.patch
-patch src/src/NonDSampling.C ./NonDSampling.C.patch
-patch src/src/NonDLocalReliability.C ./NonDLocalReliability.C.patch
-patch src/src/NonDUnilevelRBDO.C ./NonDUnilevelRBDO.C.patch    #  source not even used?
-#patch -R src/packages/Pecos/src/LHSDriver.cpp ./LHSDriver.cpp.patch
-
-#Configure dakota
-cd src
-./configure \
---prefix="$ISSM_DIR/externalpackages/dakota/install/" \
---without-graphics  \
---with-pic \
---disable-mpi \
---with-blas="-L$ISSM_DIR/externalpackages/petsc/install/lib -lfblas " \
---with-lapack="-L$ISSM_DIR/externalpackages/petsc/install/lib -lflapack "
-
-#--with-blas="-L/nasa/intel/mkl/10.0.011/lib/64/ -lmkl -lmkl_lapack -liomp5 -lpthread" \
-#--with-lapack="-L/nasa/intel/mkl/10.0.011/lib/64/ -lmkl -lmkl_lapack -liomp5 -lpthread"
-#--with-blas="-L/nasa/intel/Compiler/11.1/046/mkl/lib/em64t/ -lmkl_intel_lp64 -lmkl_lapack" \
-#--with-lapack="-L/nasa/intel/Compiler/11.1/046/mkl/lib/em64t/ -lmkl_intel_lp64 -lmkl_lapack"
-
-cd ..
-
-#Before compiling, if running on 64 bits, we need to active fPIC compilation. Some packages 
-#do not register -fPIC in Dakota, which is a problem. Edit the faulty Makefiles and add the -fPIC 
-#flag to the compilation.
-cat ./src/methods/NCSUOpt/Makefile | sed 's/FFLAGS = -g -O2/FFLAGS = -g -O2 -fPIC/g' >  temp
-mv temp ./src/methods/NCSUOpt/Makefile
-
-cat ./src/methods/acro/packages/pebbl/src/Makefile | sed 's/CXXFLAGS = -O2 -fpermissive/CXXFLAGS = -O2 -fpermissive -fPIC/g' > temp
-mv temp ./src/methods/acro/packages/pebbl/src/Makefile
-
-cat ./src/methods/hopspack/src-nappspack/Makefile | sed 's/CXXFLAGS = -g -O2/CXXFLAGS = -g -O2  -fPIC/g' > temp
-mv temp ./src/methods/hopspack/src-nappspack/Makefile
-
-cat ./src/methods/hopspack/src-cddlib/Makefile | sed 's/CFLAGS = -g -O2/CFLAGS = -g -O2 -fPIC/g' > temp
-mv temp  ./src/methods/hopspack/src-cddlib/Makefile
-
-cat ./src/methods/hopspack/src-shared/Makefile | sed 's/CFLAGS = -g -O2/CFLAGS = -g -O2 -fPIC/g' > temp
-mv temp  ./src/methods/hopspack/src-shared/Makefile
-
-cat ./src/methods/hopspack/src-shared/Makefile | sed 's/CXXFLAGS = -g -O2/CXXFLAGS = -g -O2  -fPIC/g' > temp
-mv temp  ./src/methods/hopspack/src-shared/Makefile
-
-cat ./src/methods/hopspack/src-conveyor/Makefile | sed 's/CXXFLAGS = -g -O2/CXXFLAGS = -g -O2 -fPIC/g' > temp
-mv temp  ./src/methods/hopspack/src-conveyor/Makefile
-
-cat ./src/methods/hopspack/src-appspack/Makefile | sed 's/CXXFLAGS = -g -O2/CXXFLAGS = -g -O2  -fPIC/g' > temp
-mv temp ./src/methods/hopspack/src-appspack/Makefile
-
-cat ./src/methods/acro/packages/colin/src/Makefile | sed 's/CXXFLAGS = -O2 -fpermissive/CXXFLAGS = -O2 -fpermissive -fPIC/g' > temp
-mv temp ./src/methods/acro/packages/colin/src/Makefile
-
-cat ./src/methods/acro/packages/coliny/src/Makefile | sed 's/CXXFLAGS = -O2 -fpermissive/CXXFLAGS = -O2 -fpermissive -fPIC/g' > temp
-mv temp ./src/methods/acro/packages/coliny/src/Makefile
-
-cat ./src/methods/acro/packages/tpl/3po/Makefile | sed 's/CFLAGS = -O2/CFLAGS = -O2 -fPIC/g' > temp
-mv temp  ./src/methods/acro/packages/tpl/3po/Makefile
-
-cat ./src/methods/acro/packages/tpl/3po/Makefile | sed 's/CXXFLAGS = -O2 -fpermissive/CFLAGS = -O2 -fpermissive -fPIC/g' > temp
-mv temp  ./src/methods/acro/packages/tpl/3po/Makefile
-
-cat ./src/packages/ampl/Makefile | sed 's/CFLAGS = -g -O2/CFLAGS = -g -O2 -fPIC/g' > temp
-mv temp  ./src/packages/ampl/Makefile
-
-#Compile and install dakota
-cd src
-if [ $# -eq 0 ];
-then
-	make
-	make install
-else
-	make -j $1
-	make -j $1 install
-fi
-cd ..
-
-#Weird behaviour of Dakota: libamplsolver.a and amplsolver.a are not the same thing!
-cd install/lib
-mv libamplsolver.a libamplsolver.a.bak
-ln -s ../../src/packages/ampl/amplsolver.a ./libamplsolver.a
Index: sm/trunk/externalpackages/dakota/install-pleiades.sh
===================================================================
--- /issm/trunk/externalpackages/dakota/install-pleiades.sh	(revision 14309)
+++ 	(revision )
@@ -1,97 +1,0 @@
-#!/bin/bash
-set -eu
-
-#Some cleanup
-rm -rf Dakota
-rm -rf src
-rm -rf install
-mkdir src install
-
-#Download from ISSM server
-$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/Dakota_4_3.src.tar.gz' 'Dakota_4_3.src.tar.gz'
-
-#Untar 
-tar -zxvf  Dakota_4_3.src.tar.gz
-
-#Move Dakota to src directory
-mv Dakota/* src
-rm -rf Dakota
-
-#Apply patches
-patch src/src/ParallelLibrary.C ./ParallelLibrary.C.patch
-patch src/src/ParallelLibrary.H ./ParallelLibrary.H.patch
-patch src/src/NIDRProblemDescDB.C ./NIDRProblemDescDB.C.patch
-patch src/src/NonDSampling.C ./NonDSampling.C.patch
-patch src/src/NonDLocalReliability.C ./NonDLocalReliability.C.patch
-patch src/src/NonDUnilevelRBDO.C ./NonDUnilevelRBDO.C.patch    #  source not even used?
-#patch -R src/packages/Pecos/src/LHSDriver.cpp ./LHSDriver.cpp.patch
-
-#Configure dakota
-cd src
-./configure \
---prefix="$ISSM_DIR/externalpackages/dakota/install/" \
---without-graphics  \
---with-pic \
---disable-mpi \
---with-blas="-L/nasa/intel/mkl/10.0.011/lib/64/ -lmkl -lmkl_lapack -liomp5 -lpthread" \
---with-lapack="-L/nasa/intel/mkl/10.0.011/lib/64/ -lmkl -lmkl_lapack -liomp5 -lpthread"
-cd ..
-
-#Before compiling, if running on 64 bits, we need to active fPIC compilation. Some packages 
-#do not register -fPIC in Dakota, which is a problem. Edit the faulty Makefiles and add the -fPIC 
-#flag to the compilation.
-cat ./src/methods/NCSUOpt/Makefile | sed 's/FFLAGS = -g -O2/FFLAGS = -g -O2 -fPIC/g' >  temp
-mv temp ./src/methods/NCSUOpt/Makefile
-
-cat ./src/methods/acro/packages/pebbl/src/Makefile | sed 's/CXXFLAGS = -O2 -fpermissive/CXXFLAGS = -O2 -fpermissive -fPIC/g' > temp
-mv temp ./src/methods/acro/packages/pebbl/src/Makefile
-
-cat ./src/methods/hopspack/src-nappspack/Makefile | sed 's/CXXFLAGS = -g -O2/CXXFLAGS = -g -O2  -fPIC/g' > temp
-mv temp ./src/methods/hopspack/src-nappspack/Makefile
-
-cat ./src/methods/hopspack/src-cddlib/Makefile | sed 's/CFLAGS = -g -O2/CFLAGS = -g -O2 -fPIC/g' > temp
-mv temp  ./src/methods/hopspack/src-cddlib/Makefile
-
-cat ./src/methods/hopspack/src-shared/Makefile | sed 's/CFLAGS = -g -O2/CFLAGS = -g -O2 -fPIC/g' > temp
-mv temp  ./src/methods/hopspack/src-shared/Makefile
-
-cat ./src/methods/hopspack/src-shared/Makefile | sed 's/CXXFLAGS = -g -O2/CXXFLAGS = -g -O2  -fPIC/g' > temp
-mv temp  ./src/methods/hopspack/src-shared/Makefile
-
-cat ./src/methods/hopspack/src-conveyor/Makefile | sed 's/CXXFLAGS = -g -O2/CXXFLAGS = -g -O2 -fPIC/g' > temp
-mv temp  ./src/methods/hopspack/src-conveyor/Makefile
-
-cat ./src/methods/hopspack/src-appspack/Makefile | sed 's/CXXFLAGS = -g -O2/CXXFLAGS = -g -O2  -fPIC/g' > temp
-mv temp ./src/methods/hopspack/src-appspack/Makefile
-
-cat ./src/methods/acro/packages/colin/src/Makefile | sed 's/CXXFLAGS = -O2 -fpermissive/CXXFLAGS = -O2 -fpermissive -fPIC/g' > temp
-mv temp ./src/methods/acro/packages/colin/src/Makefile
-
-cat ./src/methods/acro/packages/coliny/src/Makefile | sed 's/CXXFLAGS = -O2 -fpermissive/CXXFLAGS = -O2 -fpermissive -fPIC/g' > temp
-mv temp ./src/methods/acro/packages/coliny/src/Makefile
-
-cat ./src/methods/acro/packages/tpl/3po/Makefile | sed 's/CFLAGS = -O2/CFLAGS = -O2 -fPIC/g' > temp
-mv temp  ./src/methods/acro/packages/tpl/3po/Makefile
-
-cat ./src/methods/acro/packages/tpl/3po/Makefile | sed 's/CXXFLAGS = -O2 -fpermissive/CFLAGS = -O2 -fpermissive -fPIC/g' > temp
-mv temp  ./src/methods/acro/packages/tpl/3po/Makefile
-
-cat ./src/packages/ampl/Makefile | sed 's/CFLAGS = -g -O2/CFLAGS = -g -O2 -fPIC/g' > temp
-mv temp  ./src/packages/ampl/Makefile
-
-#Compile and install dakota
-cd src
-if [ $# -eq 0 ];
-then
-	make
-	make install
-else
-	make -j $1
-	make -j $1 install
-fi
-cd ..
-
-#Weird behaviour of Dakota: libamplsolver.a and amplsolver.a are not the same thing!
-cd install/lib
-mv libamplsolver.a libamplsolver.a.bak
-ln -s ../../src/packages/ampl/amplsolver.a ./libamplsolver.a
Index: /issm/trunk/externalpackages/dem/dem.m
===================================================================
--- /issm/trunk/externalpackages/dem/dem.m	(revision 14310)
+++ /issm/trunk/externalpackages/dem/dem.m	(revision 14310)
@@ -0,0 +1,530 @@
+function [h,I]=dem(x,y,z,varargin)
+%DEM Shaded relief image plot
+%	DEM(X,Y,Z) plots the Digital Elevation Model defined by X and Y 
+%	coordinate vectors and elevation matrix Z, as a lighted image using
+%	specific "landcolor" and "seacolor" colormaps. DEM uses IMAGESC 
+%	function which is much faster than SURFL when dealing with large 
+%	high-resolution DEM.
+%
+%	DEM(X,Y,Z,OPT) specifies options with OPT = [A,C,SCUT,ZMIN,ZMAX,ZCUT],
+%	where sorted optional scalars are:
+%	  A = azimuth light (in degrees relative to North). Default is A = -45
+%	      for a natural northwestern illumination.
+%	  C = controls contrast, as the exponent of the gradient value. Default
+%	      is C = 1 for linear contrast; use C = 0 to remove lighting, 
+%	      C = 0.5 for moderate lighting, C = 2 or more for strong contrast.
+%	  SCUT = controls lighting scale saturation with a median-style filter
+%	      in % of elements. Default is SCUT = 0.2 (0.2% maximum gradient 
+%	      values is ignored). Use SCUT = 0 for full scale gradient.
+%	  ZMIN,ZMAX = fixes min and max elevation values for colormap. Use NaN
+%	      to keep real min and/or max data values.
+%	  ZCUT = median-style filter to cut extremes values (in % of elements).
+%	      Default is ZCUT = 0.5 to ignore the 0.5% of most min/max 
+%	      elevation values. Use ZCUT = 0 for full scale.
+%	Use OPT=[] to keep default values and define following arguments.
+%
+%	DEM(...,CMAP) uses CMAP colormap instead of default (landcolor, if 
+%	exists or jet). Note that defining CMAP disables the default SEACOLOR
+%	colormap attribution for Z<=0 elevations.
+%
+%	DEM(...,NOVALUE) defines the values that will be replaced by NaN. This 
+%	might be mandatory for DEM that use a value like -99999 or -32768 if 
+%	you don't want a flat image...
+%
+%	DEM(...,SEACOLOR) sets the colormap used for zero and negative values.
+%	Default is seacolor (if exists) or single color [0.7,0.9,1] (a light 
+%	cyan) to simulate sea color. Use [] to apply colormap CMAP on the full
+%	elevation scale.
+%
+%	DEM(...,'interp') interpolates linearly NaN values (fills the gaps).
+%
+%	DEM(...,'lake') detects automaticaly flat areas different from sea 
+%	level (non-zero elevations) and draws them as lake surfaces.
+%
+%	DEM(...,'dec') plots classic basemap-style axis, considering 
+%	coordinates as cartesian (decimal).
+%
+%	DEM(...,'dms') plots geographic basemap-style axis in deg/min/sec,
+%	considering coordinates X as longitude and Y as latitude. Axis aspect 
+%	ratio will be adjusted to approximatively preserve distances (this is  
+%	not a real projection!).
+%
+%	DEM(...,'scale') adds a legend to the right of graph, with elevation 
+%	scale (colormap) and a distance scale if 'dms' option is used.
+%
+%	[H,I]=DEM(...) returns graphic handle H and illuminated image as I, an
+%	MxNx3 matrix (if Z is MxN).
+%
+%	Informations:
+%	 - For optimization purpose, DEM will automatically decimate data to
+%	   limit to a total of 1500x1500 pixels images. To avoid it, use option
+%	   DEM(...,'nodecim') or DEM(...,'decim',N) where N is an integer, but 
+%	   be aware that large grids may require computer ressources and induce  
+%	   disk swap or memory errors.
+%	 - Colormaps are Mx3 RGB matrix so it is easy to modify saturation 
+%	   (CMAP.^N), set darker (CMAP/N), lighter ((N - 1 + CMAP)/N), inverse
+%	    it (flipud(CMAP)), etc...
+%	 - To get free worldwide topographic data (SRTM), see READHGT function.
+%
+%	Author: François Beauducel <beauducel@ipgp.fr>
+%	Created: 2007-05-17
+%	Updated: 2013-01-05
+
+%	Copyright (c) 2013, François Beauducel, covered by BSD License.
+%	All rights reserved.
+%
+%	Redistribution and use in source and binary forms, with or without 
+%	modification, are permitted provided that the following conditions are 
+%	met:
+%
+%	   * Redistributions of source code must retain the above copyright 
+%	     notice, this list of conditions and the following disclaimer.
+%	   * 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
+%	                           
+%	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 COPYRIGHT OWNER OR CONTRIBUTORS 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.
+
+if nargin < 3
+	error('Not enough input arguments.');
+end
+
+% default OPT arguments
+a = -45;
+c = 1;
+scut = 0.2;
+zmin = NaN;
+zmax = NaN;
+zcut = 0.5;
+grey = 0.2*[1,1,1];
+csea = [];
+fs = 10;	% tick label fontsize
+
+dec = 0;
+dms = 0;
+scale = 0;
+inter = 0;
+lake = 0;
+decimflag = 0;
+decim = 0;
+
+novalue_color = [0,0,0];
+
+if ~isnumeric(x) | ~isnumeric(y) | ~isnumeric(z)
+	error('X,Y and Z must be numeric.')
+end
+
+if all(size(x) ~= 1) | all(size(y) ~= 1)
+	error('X and Y must be vectors, not matrix.')
+end
+
+if length(x) ~= size(z,2) | length(y) ~= size(z,1)
+	error('If Z has a size of [M,N], X must have a length of N, and Y a length of M.')
+end
+
+if nargin > 3
+	dec = any(strcmp(varargin,'dec'));
+	dms = any(strcmp(varargin,'dms'));
+	if dms & any(abs(y) > 91)
+		error('With DMS option Y must be in valid latitudes interval (decimal degrees).')
+	end
+	scale = any(strcmp(varargin,'scale'));
+	inter = any(strcmp(varargin,'interp'));
+	lake = any(strcmp(varargin,'lake'));
+	if any(strcmp(varargin,'nodecim'))
+		decim = 1;
+		decimflag = 1;
+	end
+	kdecim = find(strcmp(varargin,'decim'));
+	if ~isempty(kdecim)
+		decimflag = 1;
+		if (kdecim + 1) <= nargin & isnumeric(varargin{kdecim+1})
+			decim = round(varargin{kdecim+1});
+			decimflag = 2;
+		end
+	end
+end
+nargs = decimflag + dec + dms + scale + lake + inter;
+
+if (nargin - nargs) > 3
+	opt = varargin{1};
+	if ~isnumeric(opt)
+		error('OPT = [A,C,S,ZMIN,ZMAX] argument must be numeric.');
+	end
+	if ~isempty(opt)
+		a = opt(1);
+	end
+	if length(opt) > 1
+		c = opt(2);
+		if c < 0
+			error('C argument must be positive.');
+		end
+	end
+	if length(opt) > 2
+		scut = opt(3);
+		if scut < 0 | scut >= 100
+			error('SCUT argument must be a positive percentage.');
+		end
+	end
+	if length(opt) > 4
+		zmin = opt(4);
+		zmax = opt(5);
+	end
+	if length(opt) > 5
+		zcut = opt(6);
+		if zcut < 0 | zcut >= 100
+			error('ZCUT argument must be a positive percentage.');
+		end
+	end
+end
+
+if (nargin - nargs) < 5
+	cmap = [];
+else
+	cmap = varargin{2};
+	if ~isnumeric(cmap) | (~isempty(cmap) & (size(cmap,2) ~= 3 | min(cmap(:)) < 0 | max(cmap(:)) > 1))
+		error('CMAP must be a valid colormap (3-column [R,G,B] matrix with 0.0 to 1.0 values).')
+	end
+end
+
+if (nargin - nargs) < 6
+	novalue = NaN;
+else
+	novalue = varargin{3};
+	if ~isnumeric(novalue) | numel(novalue) > 1
+		error('NOVALUE must be scalar.')
+	end
+end
+
+if (nargin - nargs) < 7
+	if isempty(cmap)
+		if exist('seacolor','file')
+			csea = seacolor(256);
+		else
+			csea = [.7,.9,1];
+		end
+	end
+else
+	csea = varargin{4};
+	if ~isnumeric(csea)
+		error('Unknown option')
+	elseif (~isempty(csea) & (size(csea,2) ~= 3 | min(csea) < 0 | max(csea) > 1))
+		error('SEACOLOR must be a valid [R,G,B] vector with 0.0 to 1.0 values).')
+	end
+end
+
+if isempty(cmap)
+	if exist('landcolor','file')
+		cmap = landcolor.^1.3;
+	else
+		cmap = jet(256);
+	end
+end
+
+
+
+% decimates data to avoid disk swap/out of memory...
+nmax = 1500;
+if decim
+	n = decim;
+else
+	n = ceil(sqrt(numel(z))/nmax);
+end
+if n > 1
+	x = x(1:n:end);
+	y = y(1:n:end);
+	z = z(1:n:end,1:n:end);
+	fprintf('DEM: on the plot data has been decimated by a factor of %d...\n',n);
+end
+
+z = double(z); % necessary for most of the following calculations...
+z(z==novalue) = NaN;
+
+if inter
+	z = fillgap(x,y,z);
+end
+
+if isempty(csea)
+	k = (z~=0 & ~isnan(z));
+else
+	k = ~isnan(z);
+end
+
+if isnan(zmin)
+	zmin = nmedian(z(k),zcut/100);
+end
+if isnan(zmax)
+	zmax = nmedian(z(k),1 - zcut/100);
+end
+dz = zmax - zmin;
+
+if dz > 0
+	% builds the colormap: concatenates seacolor and landcolor around 0
+	if ~isempty(csea) & zmin < 0 & zmax > 0
+		l = size(csea,1);
+		r = size(cmap,1)*abs(zmin)/zmax/l;
+		cmap = cat(1,interp1(1:l,csea,linspace(1,l,round(l*r)),'*linear'),cmap);
+	end
+	
+	% normalisation of Z using CMAP and convertion to RGB
+	I = ind2rgb(uint16((z - zmin)*(length(cmap)/dz)),cmap);
+	
+	if c > 0
+		% computes lighting from elevation gradient
+		[fx,fy] = gradient(z,x,y);
+		%fx = filter([1,0,0,0,-1],1,rf(z'))';
+		%fy = filter([1,0,0,0,-1],1,rf(z));
+		fxy = -fx*sind(a) - fy*cosd(a);
+		clear fx fy	% free some memory...
+		
+		% lake option: zero gradient
+		if lake
+			dx = diff(z,1,2);
+			dy = diff(z,1,1);
+			u1 = ones(size(z,1),1);
+			u2 = ones(1,size(z,2));
+			z(cat(1,u2,dy)==0 & cat(1,dy,u2)==0 & cat(2,dx,u1)==0 & cat(2,u1,dx)==0) = 0;
+			clear dx dy	% free some memory...
+		end
+
+		fxy(isnan(fxy)) = 0;
+
+		% computes maximum absolute gradient (median-style), normalizes, saturates and duplicates in 3-D matrix
+		r = repmat(max(min(fxy/nmedian(abs(fxy),1 - scut/100),1),-1),[1,1,3]);
+	
+		% applies contrast using exponent
+		rp = (1 - abs(r)).^c;
+		I = I.*rp;
+	
+		% lighter for positive gradient
+		k = find(r > 0);
+		I(k) = I(k) + (1 - rp(k));
+				
+	end
+	
+	% set novalues / NaN to black color
+	[i,j] = find(isnan(z));
+	if ~isempty(i)
+		I(sub2ind(size(I),repmat(i,1,3),repmat(j,1,3),repmat(1:3,size(i,1),1))) = repmat(novalue_color,size(i,1),1);
+	end
+	% set the seacolor for 0 values
+	if ~isempty(csea)
+		[i,j] = find(z==0);
+		if ~isempty(i)
+			I(sub2ind(size(I),repmat(i,1,3),repmat(j,1,3),repmat(1:3,size(i,1),1))) = repmat(csea(end,:),size(i,1),1);
+		end
+	end
+
+	hh = imagesc(x,y,I);
+else
+	hh = imagesc(x,y,z);
+	colormap(cmap);
+	text(mean(x),mean(y),'SPLASH!','Color','c','FontWeight','bold','HorizontalAlignment','center')
+end
+
+orient tall
+axis xy, axis equal, axis tight
+
+xlim = [min(x),max(x)];
+ylim = [min(y),max(y)];
+zlim = [min(z(:)),max(z(:))];
+
+% axis basemap style
+if dec | dms
+	axis off
+
+	if dms
+		% approximates X-Y aspect ratio for this latitude (< 20-m precision for 1x1° grid)
+		xyr = cos(mean(y)*pi/180);
+	else
+		xyr = 1;
+	end
+	set(gca,'DataAspectRatio',[1,xyr,1])
+	bwy = 0.008*diff(ylim); % Y border width = 1%
+	bwx = bwy/xyr; % border width (in degree of longitude)
+
+	% transparent borders
+	patch([xlim(1)-bwx,xlim(2)+bwx,xlim(2)+bwx,xlim(1)-bwx],ylim(1) - bwy*[0,0,1,1],'k','FaceColor','none','clipping','off')
+	patch([xlim(1)-bwx,xlim(2)+bwx,xlim(2)+bwx,xlim(1)-bwx],ylim(2) + bwy*[0,0,1,1],'k','FaceColor','none','clipping','off')
+	patch(xlim(1) - bwx*[0,0,1,1],[ylim(1)-bwy,ylim(2)+bwy,ylim(2)+bwy,ylim(1)-bwy],'k','FaceColor','none','clipping','off')
+	patch(xlim(2) + bwx*[0,0,1,1],[ylim(1)-bwy,ylim(2)+bwy,ylim(2)+bwy,ylim(1)-bwy],'k','FaceColor','none','clipping','off')
+
+	dlon = {'E','W'};
+	dlat = {'N','S'};
+
+	if dec
+		ddx = dtick(diff(xlim));
+		ddy = dtick(diff(ylim));
+	else
+		ddx = dtick(diff(xlim),1);
+		ddy = dtick(diff(ylim),1);
+	end
+
+	xtick = (ddx*ceil(xlim(1)/ddx)):ddx:xlim(2);
+	for xt = xtick(1:2:end)
+		dt = ddx - max(0,xt + ddx - xlim(2));
+		patch(repmat(xt + dt*[0,1,1,0]',[1,2]),[ylim(1) - bwy*[0,0,1,1];ylim(2) + bwy*[0,0,1,1]]','k','clipping','off')
+		text(xt,ylim(1) - bwy,deg2dms(xt,dlon,dec),'FontSize',fs,'HorizontalAlignment','center','VerticalAlignment','top');
+	end
+
+	ytick = (ddy*ceil(ylim(1)/ddy)):ddy:ylim(2);
+	for yt = ytick(1:2:end)
+		dt = ddy - max(0,yt + ddy - ylim(2));
+		patch([xlim(1) - bwx*[0,0,1,1];xlim(2) + bwx*[0,0,1,1]]',repmat(yt + dt*[0,1,1,0]',[1,2]),'k','clipping','off')
+		text(xlim(1) - 1.1*bwx,yt,deg2dms(yt,dlat,dec),'FontSize',fs,'HorizontalAlignment','right','VerticalAlignment','middle');
+	end
+end
+
+% scale legend
+if scale
+	%wsc = diff(xlim)*0.01;
+	wsc = bwx;
+	xsc = xlim(2) + wsc*4;
+
+	% elevation scale (colorbar)
+	zscale = linspace(zlim(1),zlim(2),length(cmap));
+	yscale = linspace(0,diff(ylim)/2,length(cmap));
+	ysc = ylim(1);
+	ddz = dtick(dz*max(0.5*xyr*diff(xlim)/yscale(end),1));
+	ztick = (ddz*ceil(zlim(1)/ddz)):ddz:zlim(2);
+	patch(xsc + repmat(wsc*[-1;1;1;-1],[1,length(cmap)]), ...
+		ysc + [repmat(yscale,[2,1]);repmat(yscale + diff(yscale(1:2)),[2,1])], ...
+		repmat(zscale,[4,1]), ...
+		'EdgeColor','flat','LineWidth',.1,'FaceColor','flat','clipping','off')
+	colormap(cmap)
+	caxis([zmin,zmax])
+	patch(xsc + wsc*[-1,1,1,-1],ysc + yscale(end)*[0,0,1,1],'k','FaceColor','none','Clipping','off')
+	text(xsc + 2*wsc + zeros(size(ztick)),ysc + (ztick - zlim(1))*0.5*diff(ylim)/diff(zlim),num2str(ztick'), ...
+		'HorizontalAlignment','left','VerticalAlignment','middle','FontSize',8)
+	
+	% distance scale (in case of DMS only)
+	if dms
+		degkm = 6370*pi/180;
+		dkm = dtick(diff(ylim)*degkm);
+		ysc = ylim(2) - 0.5*dkm/degkm;
+		patch(xsc + wsc*[-1,-1,0,0],ysc + dkm*0.5*[-1,1,1,-1]/degkm,'k','FaceColor',grey,'clipping','off')
+		if dkm > 1
+			skm = sprintf('%g km',dkm);
+		else
+			skm = sprintf('%g m',dkm*1000);
+		end
+		text(xsc,ysc,skm,'rotation',-90,'HorizontalAlignment','center','VerticalAlignment','bottom', ...
+			'Color',grey,'FontWeight','bold')
+	end
+
+end
+
+
+if nargout > 0
+	h = hh;
+end
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+function y = nmedian(x,n)
+%NMEDIAN Generalized median filter
+%	NMEDIAN(X,N) sorts elemets of X and returns N-th value (N normalized).
+%	So:
+%	   N = 0 is minimum value
+%	   N = 0.5 is median value
+%	   N = 1 is maximum value
+
+if nargin < 2
+	n = 0.5;
+end
+y = sort(x(:));
+y = interp1(sort(y),n*(length(y)-1) + 1);
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+function dd = dtick(dlim,deg)
+%DTICK Tick intervals
+
+if nargin < 2
+	deg = 0;
+end
+
+if deg & dlim <= 2/60
+	% less than 2 minutes: base 36
+	m = 10^floor(log10(dlim*36))/36;
+elseif deg & dlim <= 2
+	% less than 2 degrees: base 6
+	m = 10^floor(log10(dlim*6))/6;
+else
+	% more than few degrees or not degrees: decimal rules
+	m = 10^floor(log10(dlim));
+end
+p = ceil(dlim/m);
+if p <= 1
+	dd = .1*m;
+elseif p == 2
+	dd = .2*m;
+elseif p <= 5
+	dd = .5*m;
+else
+	dd = m;
+end
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+function s = deg2dms(x,ll,dec)
+%DEG2DMS Degree/minute/second display
+
+if dec
+	s = sprintf('%7.7g',x);
+else
+	xa = abs(x) + 1/360000;
+	sd = sprintf('%d%c',floor(xa),176);	% ASCII char 176 is the degree sign
+	sm = '';
+	ss = '';
+	if mod(x,1)
+		sm = sprintf('%02d''',floor(mod(60*xa,60)));
+		sa = floor(mod(3600*xa,60));
+		if sa
+			ss = sprintf('%02d"',sa);
+		else
+			if strcmp(sm,'00''')
+				sm = '';
+			end
+		end
+	end
+	s = [sd,sm,ss,ll{1+int8(x<0)}];
+end
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+function z = fillgap(x,y,z)
+% GRIDDATA is not efficient for large arrays, but has great advantage to be
+% included in Matlab core functions! To optimize interpolation, we
+% reduce the number of relevant data by building a mask of surrounding
+% pixels of novalue areas... playing with linear index!
+
+sz = size(z);
+k = find(isnan(z));
+k(k == 1 | k == numel(z)) = []; % removes first and last index (if exist)
+if ~isempty(k)
+	[xx,yy] = meshgrid(x,y);
+	mask = zeros(sz,'int8');
+	k2 = ind90(sz,k); % k2 is linear index in the row order
+	% sets to 1 every previous and next index, both in column and row order
+	mask([k-1;k+1;ind90(fliplr(sz),[k2-1;k2+1])]) = 1; 
+	mask(k) = 0; % removes the novalue index
+	kb = find(mask); % keeps only border values
+	z(k) = griddata(xx(kb),yy(kb),z(kb),xx(k),yy(k));
+end
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+function k2 = ind90(sz,k)
+
+[i,j] = ind2sub(sz,k);
+k2 = sub2ind(fliplr(sz),j,i); % switched i and j: k2 is linear index in row order
Index: /issm/trunk/externalpackages/dem/landcolor.m
===================================================================
--- /issm/trunk/externalpackages/dem/landcolor.m	(revision 14310)
+++ /issm/trunk/externalpackages/dem/landcolor.m	(revision 14310)
@@ -0,0 +1,78 @@
+function y = landcolor(n)
+%LANDCOLOR Land colormap
+%
+%	Author: Francois Beauducel <beauducel@ipgp.fr>
+%	$Revision: 1.0.0 $   $Date: 2012/05/17 11:22:44 $
+
+J = [ ...
+0.095678 0.53427 0.21682 
+0.15785 0.5979 0.23274 
+0.21286 0.64673 0.2514 
+0.26411 0.68789 0.27268 
+0.32959 0.72416 0.31308 
+0.39794 0.75695 0.36038 
+0.46153 0.7871 0.40624 
+0.52108 0.81516 0.45135 
+0.57702 0.84152 0.49547 
+0.62973 0.86645 0.53891 
+0.67946 0.89016 0.58187 
+0.72647 0.91282 0.62427 
+0.77095 0.93455 0.66619 
+0.81306 0.95546 0.70772 
+0.85292 0.97563 0.7489 
+0.89066 0.99514 0.78976 
+0.88379 0.98595 0.77038 
+0.86389 0.96758 0.73236 
+0.84615 0.94972 0.69623 
+0.8303 0.93233 0.66186 
+0.81612 0.91536 0.6291 
+0.80341 0.8988 0.59784 
+0.79201 0.8826 0.56795 
+0.78191 0.86676 0.53946 
+0.7729 0.85123 0.51224 
+0.76479 0.83602 0.48615 
+0.75747 0.8211 0.46111 
+0.75084 0.80645 0.43704 
+0.74506 0.79206 0.41414 
+0.73981 0.77792 0.39211 
+0.73501 0.76401 0.37089 
+0.73068 0.75033 0.35052 
+0.72683 0.73685 0.33106 
+0.72042 0.72074 0.31228 
+0.71032 0.70085 0.29417 
+0.69761 0.67821 0.27694 
+0.68489 0.65558 0.26026 
+0.67235 0.63313 0.24418 
+0.65997 0.61082 0.22889 
+0.64775 0.58874 0.21406 
+0.63568 0.56689 0.19983 
+0.62376 0.54527 0.18622 
+0.61197 0.52391 0.17299 
+0.60033 0.50283 0.16046 
+0.58881 0.48203 0.14832 
+0.57742 0.46151 0.13667 
+0.56616 0.44133 0.12555 
+0.55502 0.4214 0.11472 
+0.54398 0.4019 0.10456 
+0.53306 0.38266 0.094633 
+0.52226 0.36382 0.085242 
+0.51155 0.3453 0.076179 
+0.50095 0.32714 0.067515 
+0.49045 0.30938 0.059259 
+0.48005 0.29193 0.051294 
+0.46973 0.27495 0.043796 
+0.45951 0.25823 0.0365 
+0.44938 0.24206 0.029715 
+0.43934 0.22609 0.023063 
+0.42938 0.21074 0.016949 
+0.41951 0.19556 0.010917 
+0.40971 0.18105 0.0054326 
+0.4 0.16667 0 
+];
+
+l = length(J);
+if nargin < 1
+	n = 256;
+end
+y = interp1(1:l,J,linspace(1,l,n),'*linear');
+
Index: /issm/trunk/externalpackages/dem/license.txt
===================================================================
--- /issm/trunk/externalpackages/dem/license.txt	(revision 14310)
+++ /issm/trunk/externalpackages/dem/license.txt	(revision 14310)
@@ -0,0 +1,24 @@
+Copyright (c) 2013, François Beauducel
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without 
+modification, are permitted provided that the following conditions are 
+met:
+
+    * Redistributions of source code must retain the above copyright 
+      notice, this list of conditions and the following disclaimer.
+    * 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
+      
+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 COPYRIGHT OWNER OR CONTRIBUTORS 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.
Index: /issm/trunk/externalpackages/dem/seacolor.m
===================================================================
--- /issm/trunk/externalpackages/dem/seacolor.m	(revision 14310)
+++ /issm/trunk/externalpackages/dem/seacolor.m	(revision 14310)
@@ -0,0 +1,58 @@
+function y = seacolor(n)
+%SEACOLOR Sea colormap adapted from NGDC ETOPO1
+%
+%	Author: Francois Beauducel <beauducel@ipgp.fr>
+
+J = [ ...
+    0.0392         0    0.4745
+    0.1020         0    0.5373
+    0.1020         0    0.5373
+    0.1490         0    0.5961
+    0.1490         0    0.5961
+    0.1059    0.0118    0.6510
+    0.1059    0.0118    0.6510
+    0.0627    0.0235    0.7059
+    0.0627    0.0235    0.7059
+    0.0196    0.0353    0.7569
+    0.0196    0.0353    0.7569
+         0    0.0549    0.7961
+         0    0.0549    0.7961
+         0    0.0863    0.8235
+         0    0.0863    0.8235
+         0    0.1176    0.8471
+         0    0.1176    0.8471
+         0    0.1529    0.8745
+         0    0.1529    0.8745
+    0.0471    0.2667    0.9059
+    0.0471    0.2667    0.9059
+    0.1020    0.4000    0.9412
+    0.1020    0.4000    0.9412
+    0.0745    0.4588    0.9569
+    0.0745    0.4588    0.9569
+    0.0549    0.5216    0.9765
+    0.0549    0.5216    0.9765
+    0.0824    0.6196    0.9882
+    0.0824    0.6196    0.9882
+    0.1176    0.6980    1.0000
+    0.1176    0.6980    1.0000
+    0.1686    0.7294    1.0000
+    0.1686    0.7294    1.0000
+    0.2157    0.7569    1.0000
+    0.2157    0.7569    1.0000
+    0.2549    0.7843    1.0000
+    0.2549    0.7843    1.0000
+    0.3098    0.8235    1.0000
+    0.3098    0.8235    1.0000
+    0.3686    0.8745    1.0000
+    0.3686    0.8745    1.0000
+    0.5412    0.8902    1.0000
+    0.5412    0.8902    1.0000
+    0.7373    0.9020    1.0000
+];
+
+l = length(J);
+if nargin < 1
+	n = 256;
+end
+y = interp1(1:l,J,linspace(1,l,n),'*linear');
+
Index: /issm/trunk/externalpackages/export_fig/export_fig.m
===================================================================
--- /issm/trunk/externalpackages/export_fig/export_fig.m	(revision 14309)
+++ /issm/trunk/externalpackages/export_fig/export_fig.m	(revision 14310)
@@ -123,6 +123,6 @@
 %   -bookmark - option to indicate that a bookmark with the name of the
 %               figure is to be created in the output file (pdf only).
-%   handle - The handle of the figure or axes (can be an array of handles
-%            of several axes, but these must be in the same figure) to be
+%   handle - The handle of the figure, axes or uipanels (can be an array of
+%            handles, but the objects must be in the same figure) to be
 %            saved. Default: gcf.
 %
@@ -166,17 +166,24 @@
 % 09/05/12: Incorporate patch of Arcelia Arrieta (many thanks), to keep
 %           tick marks fixed.
-
-function [im alpha] = export_fig(varargin)
+% 12/12/12: Add support for isolating uipanels. Thanks to michael for
+%           suggesting it.
+
+function [im, alpha] = export_fig(varargin)
 % Make sure the figure is rendered correctly _now_ so that properties like
 % axes limits are up-to-date.
 drawnow;
 % Parse the input arguments
-[fig options] = parse_args(nargout, varargin{:});
+[fig, options] = parse_args(nargout, varargin{:});
 % Isolate the subplot, if it is one
-cls = strcmp(get(fig(1), 'Type'), 'axes');
+cls = all(ismember(get(fig, 'Type'), {'axes', 'uipanel'}));
 if cls
     % Given handles of one or more axes, so isolate them from the rest
     fig = isolate_axes(fig);
 else
+    % Check we have a figure
+    if ~isequal(get(fig, 'Type'), 'figure');
+        error('Handle must be that of a figure, axes or uipanel');
+    end
+    % Get the old InvertHardcopy mode
     old_mode = get(fig, 'InvertHardcopy');
 end
@@ -198,5 +205,5 @@
     end
 end
-% MATLAB "feature": axes limits can change when printing
+% MATLAB "feature": axes limits and tick marks can change when printing
 Hlims = findall(fig, 'Type', 'axes');
 if ~cls
@@ -282,5 +289,5 @@
         % Crop the background
         if options.crop
-            [alpha v] = crop_background(alpha, 0);
+            [alpha, v] = crop_background(alpha, 0);
             A = A(v(1):v(2),v(3):v(4),:);
         end
@@ -289,5 +296,5 @@
             res = options.magnify * get(0, 'ScreenPixelsPerInch') / 25.4e-3;
             % Save the png
-            imwrite(A, [options.name '.png'], 'Alpha', alpha, 'ResolutionUnit', 'meter', 'XResolution', res, 'YResolution', res);
+            imwrite(A, [options.name '.png'], 'Alpha', double(alpha), 'ResolutionUnit', 'meter', 'XResolution', res, 'YResolution', res);
             % Clear the png bit
             options.png = false;
@@ -325,5 +332,5 @@
             tcol = 255;
         else
-            [A tcol] = print2array(fig, magnify, renderer);
+            [A, tcol] = print2array(fig, magnify, renderer);
         end
         % Crop the background
@@ -460,5 +467,5 @@
 return
 
-function [fig options] = parse_args(nout, varargin)
+function [fig, options] = parse_args(nout, varargin)
 % Parse the input arguments
 % Set the defaults
@@ -542,5 +549,5 @@
             end
         else
-            [p options.name ext] = fileparts(varargin{a});
+            [p, options.name, ext] = fileparts(varargin{a});
             if ~isempty(p)
                 options.name = [p filesep options.name];
@@ -577,5 +584,5 @@
 
 % Check whether transparent background is wanted (old way)
-if isequal(get(fig, 'Color'), 'none')
+if isequal(get(ancestor(fig, 'figure'), 'Color'), 'none')
     options.transparent = true;
 end
@@ -667,7 +674,7 @@
 return
 
-function [A v] = crop_background(A, bcol)
+function [A, v] = crop_background(A, bcol)
 % Map the foreground pixels
-[h w c] = size(A);
+[h, w, c] = size(A);
 if isscalar(bcol) && c > 1
     bcol = bcol(ones(1, c));
Index: /issm/trunk/externalpackages/export_fig/ghostscript.m
===================================================================
--- /issm/trunk/externalpackages/export_fig/ghostscript.m	(revision 14309)
+++ /issm/trunk/externalpackages/export_fig/ghostscript.m	(revision 14310)
@@ -1,3 +1,2 @@
-function varargout = ghostscript(cmd)
 %GHOSTSCRIPT  Calls a local GhostScript executable with the input command
 %
@@ -25,35 +24,35 @@
 % Thanks to Jonas Dorn for the fix for the title of the uigetdir window on
 % Mac OS.
-
 % Thanks to Nathan Childress for the fix to the default location on 64-bit
 % Windows systems.
-
 % 27/4/11 - Find 64-bit Ghostscript on Windows. Thanks to Paul Durack and
 % Shaun Kline for pointing out the issue
-
 % 4/5/11 - Thanks to David Chorlian for pointing out an alternative
 % location for gs on linux.
+% 12/12/12 - Add extra executable name on Windows. Thanks to Ratish
+% Punnoose for highlighting the issue.
 
+function varargout = ghostscript(cmd)
 % Call ghostscript
 [varargout{1:nargout}] = system(sprintf('"%s" %s', gs_path, cmd));
 return
 
-function path = gs_path
+function path_ = gs_path
 % Return a valid path
 % Start with the currently set path
-path = user_string('ghostscript');
+path_ = user_string('ghostscript');
 % Check the path works
-if check_gs_path(path)
+if check_gs_path(path_)
     return
 end
 % Check whether the binary is on the path
 if ispc
-    bin = {'gswin32c.exe', 'gswin64c.exe'};
+    bin = {'gswin32c.exe', 'gswin64c.exe', 'gs'};
 else
     bin = {'gs'};
 end
 for a = 1:numel(bin)
-    path = bin{a};
-    if check_store_gs_path(path)
+    path_ = bin{a};
+    if check_store_gs_path(path_)
         return
     end
@@ -76,5 +75,5 @@
                 path2 = [default_location dir_list(a).name executable{b}];
                 if exist(path2, 'file') == 2
-                    path = path2;
+                    path_ = path2;
                     ver_num = ver_num2;
                 end
@@ -82,5 +81,5 @@
         end
     end
-    if check_store_gs_path(path)
+    if check_store_gs_path(path_)
         return
     end
@@ -88,6 +87,6 @@
     bin = {'/usr/bin/gs', '/usr/local/bin/gs'};
     for a = 1:numel(bin)
-        path = bin{a};
-        if check_store_gs_path(path)
+        path_ = bin{a};
+        if check_store_gs_path(path_)
             return
         end
@@ -110,7 +109,7 @@
     for a = 1:numel(bin_dir)
         for b = 1:numel(bin)
-            path = [base bin_dir{a} bin{b}];
-            if exist(path, 'file') == 2
-                if check_store_gs_path(path)
+            path_ = [base bin_dir{a} bin{b}];
+            if exist(path_, 'file') == 2
+                if check_store_gs_path(path_)
                     return
                 end
@@ -121,12 +120,12 @@
 error('Ghostscript not found. Have you installed it from www.ghostscript.com?');
 
-function good = check_store_gs_path(path)
+function good = check_store_gs_path(path_)
 % Check the path is valid
-good = check_gs_path(path);
+good = check_gs_path(path_);
 if ~good
     return
 end
 % Update the current default path to the path found
-if ~user_string('ghostscript', path)
+if ~user_string('ghostscript', path_)
     warning('Path to ghostscript installation could not be saved. Enter it manually in ghostscript.txt.');
     return
@@ -134,7 +133,7 @@
 return
 
-function good = check_gs_path(path)
+function good = check_gs_path(path_)
 % Check the path is valid
-[good message] = system(sprintf('"%s" -h', path));
+[good, message] = system(sprintf('"%s" -h', path_));
 good = good == 0;
 return
Index: /issm/trunk/externalpackages/export_fig/isolate_axes.m
===================================================================
--- /issm/trunk/externalpackages/export_fig/isolate_axes.m	(revision 14309)
+++ /issm/trunk/externalpackages/export_fig/isolate_axes.m	(revision 14310)
@@ -5,11 +5,12 @@
 %   fh = isolate_axes(ah, vis)
 %
-% This function will create a new figure containing the axes specified, and
-% also their associated legends and colorbars. The axes specified must all
-% be in the same figure, but they will generally only be a subset of the
-% axes in the figure.
+% This function will create a new figure containing the axes/uipanels
+% specified, and also their associated legends and colorbars. The objects
+% specified must all be in the same figure, but they will generally only be
+% a subset of the objects in the figure.
 %
 % IN:
-%    ah - An array of axes handles, which must come from the same figure.
+%    ah - An array of axes and uipanel handles, which must come from the
+%         same figure.
 %    vis - A boolean indicating whether the new figure should be visible.
 %          Default: false.
@@ -23,4 +24,6 @@
 % 16/3/2012 Moved copyfig to its own function. Thanks to Bob Fratantonio
 % for pointing out that the function is also used in export_fig.m.
+% 12/12/12 - Add support for isolating uipanels. Thanks to michael for
+% suggesting it.
 
 function fh = isolate_axes(ah, vis)
@@ -29,10 +32,10 @@
     error('ah must be an array of handles');
 end
-% Check that the handles are all for axes, and are all in the same figure
+% Check that the handles are all for axes or uipanels, and are all in the same figure
 fh = ancestor(ah(1), 'figure');
 nAx = numel(ah);
 for a = 1:nAx
-    if ~strcmp(get(ah(a), 'Type'), 'axes')
-        error('All handles must be axes handles.');
+    if ~ismember(get(ah(a), 'Type'), {'axes', 'uipanel'})
+        error('All handles must be axes or uipanel handles.');
     end
     if ~isequal(ancestor(ah(a), 'figure'), fh)
@@ -40,5 +43,5 @@
     end
 end
-% Tag the axes so we can find them in the copy
+% Tag the objects so we can find them in the copy
 old_tag = get(ah, 'Tag');
 if nAx == 1
@@ -51,5 +54,5 @@
     set(fh, 'Visible', 'off');
 end
-% Reset the axes tags
+% Reset the object tags
 for a = 1:nAx
     set(ah(a), 'Tag', old_tag{a});
@@ -59,5 +62,5 @@
 if numel(ah) ~= nAx
     close(fh);
-    error('Incorrect number of axes found.');
+    error('Incorrect number of objects found.');
 end
 % Set the axes tags to what they should be
@@ -87,5 +90,5 @@
 % Get all the objects in the figure
 axs = findall(fh);
-% Delete everything except for the input axes and associated items
+% Delete everything except for the input objects and associated items
 delete(axs(~ismember(axs, [ah; allchildren(ah); allancestors(ah)])));
 return
Index: /issm/trunk/externalpackages/export_fig/pdftops.m
===================================================================
--- /issm/trunk/externalpackages/export_fig/pdftops.m	(revision 14309)
+++ /issm/trunk/externalpackages/export_fig/pdftops.m	(revision 14310)
@@ -33,10 +33,10 @@
 return
 
-function path = xpdf_path
+function path_ = xpdf_path
 % Return a valid path
 % Start with the currently set path
-path = user_string('pdftops');
+path_ = user_string('pdftops');
 % Check the path works
-if check_xpdf_path(path)
+if check_xpdf_path(path_)
     return
 end
@@ -48,14 +48,14 @@
 end
 if check_store_xpdf_path(bin)
-    path = bin;
+    path_ = bin;
     return
 end
 % Search the obvious places
 if ispc
-    path = 'C:\Program Files\xpdf\pdftops.exe';
+    path_ = 'C:\Program Files\xpdf\pdftops.exe';
 else
-    path = '/usr/local/bin/pdftops';
+    path_ = '/usr/local/bin/pdftops';
 end
-if check_store_xpdf_path(path)
+if check_store_xpdf_path(path_)
     return
 end
@@ -75,10 +75,10 @@
     bin_dir = {'', ['bin' filesep], ['lib' filesep]};
     for a = 1:numel(bin_dir)
-        path = [base bin_dir{a} bin];
-        if exist(path, 'file') == 2
+        path_ = [base bin_dir{a} bin];
+        if exist(path_, 'file') == 2
             break;
         end
     end
-    if check_store_xpdf_path(path)
+    if check_store_xpdf_path(path_)
         return
     end
@@ -86,12 +86,12 @@
 error('pdftops executable not found.');
 
-function good = check_store_xpdf_path(path)
+function good = check_store_xpdf_path(path_)
 % Check the path is valid
-good = check_xpdf_path(path);
+good = check_xpdf_path(path_);
 if ~good
     return
 end
 % Update the current default path to the path found
-if ~user_string('pdftops', path)
+if ~user_string('pdftops', path_)
     warning('Path to pdftops executable could not be saved. Enter it manually in pdftops.txt.');
     return
@@ -99,7 +99,7 @@
 return
 
-function good = check_xpdf_path(path)
+function good = check_xpdf_path(path_)
 % Check the path is valid
-[good message] = system(sprintf('"%s" -h', path));
+[good message] = system(sprintf('"%s" -h', path_));
 % system returns good = 1 even when the command runs
 % Look for something distinct in the help text
Index: /issm/trunk/externalpackages/export_fig/print2array.m
===================================================================
--- /issm/trunk/externalpackages/export_fig/print2array.m	(revision 14309)
+++ /issm/trunk/externalpackages/export_fig/print2array.m	(revision 14310)
@@ -25,25 +25,24 @@
 %   bcol - 1x3 uint8 vector of the background color
 
-% Copyright (C) Oliver Woodford 2008-2011
+% Copyright (C) Oliver Woodford 2008-2012
 
-% 5/9/2011 Set EraseModes to normal when using opengl or zbuffer renderers.
-% Thanks to Pawel Kocieniewski for reporting the issue.
+% 05/09/11: Set EraseModes to normal when using opengl or zbuffer
+%           renderers. Thanks to Pawel Kocieniewski for reporting the
+%           issue.
+% 21/09/11: Bug fix: unit8 -> uint8! Thanks to Tobias Lamour for reporting
+%           the issue.
+% 14/11/11: Bug fix: stop using hardcopy(), as it interfered with figure
+%           size and erasemode settings. Makes it a bit slower, but more
+%           reliable. Thanks to Phil Trinh and Meelis Lootus for reporting
+%           the issues.
+% 09/12/11: Pass font path to ghostscript.
+% 27/01/12: Bug fix affecting painters rendering tall figures. Thanks to
+%           Ken Campbell for reporting it.
+% 03/04/12: Bug fix to median input. Thanks to Andy Matthews for reporting
+%           it.
+% 26/10/12: Set PaperOrientation to portrait. Thanks to Michael Watts for
+%           reporting the issue.
 
-% 21/9/2011 Bug fix: unit8 -> uint8!
-% Thanks to Tobias Lamour for reporting the issue.
-
-% 14/11/2011 Bug fix: stop using hardcopy(), as it interfered with figure
-% size and erasemode settings. Makes it a bit slower, but more reliable.
-% Thanks to Phil Trinh and Meelis Lootus for reporting the issues.
-
-% 9/12/2011 Pass font path to ghostscript.
-
-% 27/1/2012 Bug fix affecting painters rendering tall figures. Thanks to
-% Ken Campbell for reporting it.
-
-% 3/4/2012 Bug fix to median input. Thanks to Andy Matthews for reporting
-% it.
-
-function [A bcol] = print2array(fig, res, renderer)
+function [A, bcol] = print2array(fig, res, renderer)
 % Generate default input arguments, if needed
 if nargin < 2
@@ -85,8 +84,8 @@
         % Execute the ghostscript command
         ghostscript(cmd_str);
-    catch
+    catch me
         % Delete the intermediate file
         delete(tmp_eps);
-        rethrow(lasterror);
+        rethrow(me);
     end
     % Delete the intermediate file
@@ -134,6 +133,7 @@
     err = false;
     % Set paper size
-    old_mode = get(fig, 'PaperPositionMode');
-    set(fig, 'PaperPositionMode', 'auto');
+    old_pos_mode = get(fig, 'PaperPositionMode');
+    old_orientation = get(fig, 'PaperOrientation');
+    set(fig, 'PaperPositionMode', 'auto', 'PaperOrientation', 'portrait');
     try
         % Print to tiff file
@@ -147,5 +147,5 @@
     end
     % Reset paper size
-    set(fig, 'PaperPositionMode', old_mode);
+    set(fig, 'PaperPositionMode', old_pos_mode, 'PaperOrientation', old_orientation);
     % Throw any error that occurred
     if err
Index: /issm/trunk/externalpackages/export_fig/print2eps.m
===================================================================
--- /issm/trunk/externalpackages/export_fig/print2eps.m	(revision 14309)
+++ /issm/trunk/externalpackages/export_fig/print2eps.m	(revision 14310)
@@ -28,22 +28,24 @@
 % fex id: 5743, but the implementation is mine :)
 
-% 14/11/2011 Fix a MATLAB bug rendering black or white text incorrectly.
-% Thanks to Mathieu Morlighem for reporting the issue and obtaining a fix
-% from TMW.
-
-% 8/12/2011 Added ability to correct fonts. Several people have requested
-% this at one time or another, and also pointed me to printeps (fex id:
-% 7501), so thank you to them. My implementation (which was not inspired by
-% printeps - I'd already had the idea for my approach) goes
-% slightly further in that it allows multiple fonts to be swapped.
-
-% 14/12/2011 Fix bug affecting font names containing spaces. Many thanks to
-% David Szwer for reporting the issue.
-
-% 25/1/2012 Add a font not to be swapped. Thanks to Anna Rafferty and Adam
-% Jackson for reporting the issue. Also fix a bug whereby using a font
-% alias can lead to another font being swapped in.
-
-% 10/4/2012 Make the font swapping case insensitive.
+% 14/11/2011: Fix a MATLAB bug rendering black or white text incorrectly.
+%             Thanks to Mathieu Morlighem for reporting the issue and
+%             obtaining a fix from TMW.
+% 08/12/11: Added ability to correct fonts. Several people have requested
+%           this at one time or another, and also pointed me to printeps
+%           (fex id: 7501), so thank you to them. My implementation (which
+%           was not inspired by printeps - I'd already had the idea for my
+%           approach) goes slightly further in that it allows multiple
+%           fonts to be swapped.
+% 14/12/11: Fix bug affecting font names containing spaces. Thanks to David
+%           Szwer for reporting the issue.
+% 25/01/12: Add a font not to be swapped. Thanks to Anna Rafferty and Adam
+%           Jackson for reporting the issue. Also fix a bug whereby using a
+%           font alias can lead to another font being swapped in.
+% 10/04/12: Make the font swapping case insensitive.
+% 26/10/12: Set PaperOrientation to portrait. Thanks to Michael Watts for
+%           reporting the issue.
+% 26/10/12: Fix issue to do with swapping fonts changing other fonts and
+%           sizes we don't want, due to listeners. Thanks to Malcolm Hudson
+%           for reporting the issue.
 
 function print2eps(name, fig, varargin)
@@ -59,5 +61,5 @@
 end
 % Find all the used fonts in the figure
-font_handles = findall(fig, '-property', 'FontName');
+font_handles = findobj(fig, '-property', 'FontName');
 fonts = get(font_handles, 'FontName');
 if ~iscell(fonts)
@@ -86,19 +88,44 @@
 require_swap = find(~ismember(fontslu, matlab_fontsl));
 unused_fonts = find(~ismember(matlab_fontsl, fontslu));
-font_swap = cell(3, 0);
-for a = 1:min(numel(require_swap), numel(unused_fonts))
-    ind = find(strcmp(fontslu{require_swap(a)}, fontsl));
-    n = numel(ind);
-    font_swap(1,end+1:end+n) = reshape(mat2cell(font_handles(ind), ones(n, 1)), 1, []);
-    font_swap(2,end-n+1:end) = matlab_fonts(unused_fonts(a));
-    font_swap(3,end-n+1:end) = reshape(fonts(ind), 1, []);
+font_swap = cell(3, min(numel(require_swap), numel(unused_fonts)));
+fonts_new = fonts;
+for a = 1:size(font_swap, 2)
+    font_swap{1,a} = find(strcmp(fontslu{require_swap(a)}, fontsl));
+    font_swap{2,a} = matlab_fonts{unused_fonts(a)};
+    font_swap{3,a} = fonts{font_swap{1,end}(1)};
+    fonts_new(font_swap{1,a}) = {font_swap{2,a}};
 end
 % Swap the fonts
-for a = 1:size(font_swap, 2)
-    set(font_swap{1,a}, 'FontName', font_swap{2,a});
+if ~isempty(font_swap)
+    fonts_size = get(font_handles, 'FontSize');
+    if iscell(fonts_size)
+        fonts_size = cell2mat(fonts_size);
+    end
+    M = false(size(font_handles));
+    % Loop because some changes may not stick first time, due to listeners
+    c = 0;
+    update = zeros(1000, 1);
+    for b = 1:10 % Limit number of loops to avoid infinite loop case
+        for a = 1:numel(M)
+            M(a) = ~isequal(get(font_handles(a), 'FontName'), fonts_new{a}) || ~isequal(get(font_handles(a), 'FontSize'), fonts_size(a));
+            if M(a)
+                set(font_handles(a), 'FontName', fonts_new{a}, 'FontSize', fonts_size(a));
+                c = c + 1;
+                update(c) = a;
+            end
+        end
+        if ~any(M)
+            break;
+        end
+    end
+    % Compute the order to revert fonts later, without the need of a loop
+    [update, M] = unique(update(1:c));
+    [M, M] = sort(M);
+    update = reshape(update(M), 1, []);
 end
 % Set paper size
-old_mode = get(fig, 'PaperPositionMode');
-set(fig, 'PaperPositionMode', 'auto');
+old_pos_mode = get(fig, 'PaperPositionMode');
+old_orientation = get(fig, 'PaperOrientation');
+set(fig, 'PaperPositionMode', 'auto', 'PaperOrientation', 'portrait');
 % MATLAB bug fix - black and white text can come out inverted sometimes
 % Find the white and black text
@@ -120,10 +147,10 @@
 set(white_text_handles, 'Color', [1 1 1]);
 % Reset paper size
-set(fig, 'PaperPositionMode', old_mode);
+set(fig, 'PaperPositionMode', old_pos_mode, 'PaperOrientation', old_orientation);
 % Correct the fonts
 if ~isempty(font_swap)
     % Reset the font names in the figure
-    for a = 1:size(font_swap, 2)
-        set(font_swap{1,a}, 'FontName', font_swap{3,a});
+    for a = update
+        set(font_handles(a), 'FontName', fonts{a}, 'FontSize', fonts_size(a));
     end
     % Replace the font names in the eps file
Index: sm/trunk/externalpackages/gdal/GDALmake.opt.patch
===================================================================
--- /issm/trunk/externalpackages/gdal/GDALmake.opt.patch	(revision 14309)
+++ 	(revision )
@@ -1,8 +1,0 @@
-31c31
-< LIBS	=	$(SDE_LIB) -I/usr/include -lsqlite3 -L/usr/lib -lexpat -ljpeg -lpng -lz  -lm -lrt -ldl  $(KAK_LIBS) $(DWG_LIBS) $(CURL_LIB) \
----
-> LIBS	=	$(SDE_LIB) -I/usr/include -lsqlite3 -L/usr/lib64 -lexpat -ljpeg -lpng -lz  -lm -lrt -ldl  $(KAK_LIBS) $(DWG_LIBS) $(CURL_LIB) \
-225c225
-< CURL_LIB	=	-L/usr/kerberos/lib64 -lcurl -ldl -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err -lidn -lssl -lcrypto -lz  
----
-> CURL_LIB	=	-L/usr/lib64 -lcurl -ldl -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err -lidn -lssl -lcrypto -lz  
Index: sm/trunk/externalpackages/gdal/GDALmake.opt.patch.astrid
===================================================================
--- /issm/trunk/externalpackages/gdal/GDALmake.opt.patch.astrid	(revision 14309)
+++ 	(revision )
@@ -1,8 +1,0 @@
-31c31
-< LIBS	=	$(SDE_LIB) -I/usr/include -lsqlite3 -L/usr/lib -lexpat -ljpeg -lz  -lm -lrt -ldl  $(KAK_LIBS) $(DWG_LIBS) $(CURL_LIB) \
----
-> LIBS	=	$(SDE_LIB) -I/usr/include -lsqlite3 -L/usr/lib64 -lexpat -ljpeg -lz  -lm -lrt -ldl  $(KAK_LIBS) $(DWG_LIBS) $(CURL_LIB) \
-225c225
-< CURL_LIB	=	-L/usr/kerberos/lib64 -lcurl -ldl -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err -lidn -lssl -lcrypto -lz  
----
-> CURL_LIB	=	-L/usr/lib64 -lcurl -ldl -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err -lidn -lssl -lcrypto -lz  
Index: /issm/trunk/externalpackages/gdal/configs/GDALmake.opt.patch.astrid
===================================================================
--- /issm/trunk/externalpackages/gdal/configs/GDALmake.opt.patch.astrid	(revision 14310)
+++ /issm/trunk/externalpackages/gdal/configs/GDALmake.opt.patch.astrid	(revision 14310)
@@ -0,0 +1,8 @@
+31c31
+< LIBS	=	$(SDE_LIB) -I/usr/include -lsqlite3 -L/usr/lib -lexpat -ljpeg -lz  -lm -lrt -ldl  $(KAK_LIBS) $(DWG_LIBS) $(CURL_LIB) \
+---
+> LIBS	=	$(SDE_LIB) -I/usr/include -lsqlite3 -L/usr/lib64 -lexpat -ljpeg -lz  -lm -lrt -ldl  $(KAK_LIBS) $(DWG_LIBS) $(CURL_LIB) \
+225c225
+< CURL_LIB	=	-L/usr/kerberos/lib64 -lcurl -ldl -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err -lidn -lssl -lcrypto -lz  
+---
+> CURL_LIB	=	-L/usr/lib64 -lcurl -ldl -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err -lidn -lssl -lcrypto -lz  
Index: /issm/trunk/externalpackages/gdal/configs/GDALmake.opt.patch.murdo
===================================================================
--- /issm/trunk/externalpackages/gdal/configs/GDALmake.opt.patch.murdo	(revision 14310)
+++ /issm/trunk/externalpackages/gdal/configs/GDALmake.opt.patch.murdo	(revision 14310)
@@ -0,0 +1,8 @@
+31c31
+< LIBS	=	$(SDE_LIB) -I/usr/include -lsqlite3 -L/usr/lib -lexpat -ljpeg -lpng -lz  -lm -lrt -ldl  $(KAK_LIBS) $(DWG_LIBS) $(CURL_LIB) \
+---
+> LIBS	=	$(SDE_LIB) -I/usr/include -lsqlite3 -L/usr/lib64 -lexpat -ljpeg -lpng -lz  -lm -lrt -ldl  $(KAK_LIBS) $(DWG_LIBS) $(CURL_LIB) \
+225c225
+< CURL_LIB	=	-L/usr/kerberos/lib64 -lcurl -ldl -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err -lidn -lssl -lcrypto -lz  
+---
+> CURL_LIB	=	-L/usr/lib64 -lcurl -ldl -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err -lidn -lssl -lcrypto -lz  
Index: /issm/trunk/externalpackages/gdal/install-1.6-linux64-astrid.sh
===================================================================
--- /issm/trunk/externalpackages/gdal/install-1.6-linux64-astrid.sh	(revision 14310)
+++ /issm/trunk/externalpackages/gdal/install-1.6-linux64-astrid.sh	(revision 14310)
@@ -0,0 +1,41 @@
+#!/bin/bash
+set -eu
+
+#Some cleanup
+rm -rf src
+rm -rf install
+rm -rf gdal-1.6.0
+mkdir src install
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/gdal-1.6.0.tar.gz' 'gdal-1.6.0.tar.gz'
+
+#Untar 
+tar -zxvf  gdal-1.6.0.tar.gz
+
+#Move gdal into src directory
+mv gdal-1.6.0/* src
+rm -rf gdal-1.6.0
+
+#Configure gdal
+cd src
+./configure \
+	--prefix="$ISSM_DIR/externalpackages/gdal/install" \
+	--without-python \
+	--without-png \
+	--with-netcdf=no \
+	--with-jasper=no \
+	--without-ld-shared \
+	--with-unix-stdio-64=no \
+	--with-expat-lib=/usr/lib64/libexpat.so
+
+#Patch GDALmake.opt
+patch GDALmake.opt ../configs/GDALmake.opt.patch.astrid
+
+#Compile and install gdal
+if [ $# -eq 0 ]; then
+	make
+else
+	make -j $1
+fi
+make install
Index: /issm/trunk/externalpackages/gdal/install-1.6-linux64-murdo.sh
===================================================================
--- /issm/trunk/externalpackages/gdal/install-1.6-linux64-murdo.sh	(revision 14310)
+++ /issm/trunk/externalpackages/gdal/install-1.6-linux64-murdo.sh	(revision 14310)
@@ -0,0 +1,39 @@
+#!/bin/bash
+set -eu
+
+#Some cleanup
+rm -rf src
+rm -rf install
+rm -rf gdal-1.6.0
+mkdir src install
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/gdal-1.6.0.tar.gz' 'gdal-1.6.0.tar.gz'
+
+#Untar 
+tar -zxvf  gdal-1.6.0.tar.gz
+
+#Move gdal into src directory
+mv gdal-1.6.0/* src
+rm -rf gdal-1.6.0
+
+#Configure gdal
+cd src
+./configure --prefix="$ISSM_DIR/externalpackages/gdal/install" \
+	--without-python \
+	--without-png \
+	--with-netcdf=no \
+	--with-jasper=no \
+	--without-ld-shared \
+	--with-unix-stdio-64=no 
+
+#Patch GDALmake.opt
+patch GDALmake.opt ../configs/GDALmake.opt.patch
+
+#Compile and install gdal
+if [ $# -eq 0 ]; then
+	make
+else
+	make -j $1
+fi
+make install
Index: /issm/trunk/externalpackages/gdal/install-1.6-macosx64.sh
===================================================================
--- /issm/trunk/externalpackages/gdal/install-1.6-macosx64.sh	(revision 14310)
+++ /issm/trunk/externalpackages/gdal/install-1.6-macosx64.sh	(revision 14310)
@@ -0,0 +1,38 @@
+#!/bin/bash
+set -eu
+
+#Some cleanup
+rm -rf src
+rm -rf install
+rm -rf gdal-1.6.0
+mkdir src install
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/gdal-1.6.0.tar.gz' 'gdal-1.6.0.tar.gz'
+
+#Untar 
+tar -zxvf  gdal-1.6.0.tar.gz
+
+#Move gdal into src directory
+mv gdal-1.6.0/* src
+rm -rf gdal-1.6.0
+
+#Configure gdal
+cd src
+./configure \
+	--prefix="$ISSM_DIR/externalpackages/gdal/install" \
+	--without-python \
+	--without-png \
+	--with-netcdf=no \
+	--with-jasper=no \
+	--without-ld-shared \
+	--with-unix-stdio-64=no \
+	--with-expat-lib=/usr/lib64/libexpat.so
+
+#Compile and install gdal
+if [ $# -eq 0 ]; then
+	make
+else
+	make -j $1
+fi
+make install
Index: /issm/trunk/externalpackages/gdal/install-1.9-linux64.sh
===================================================================
--- /issm/trunk/externalpackages/gdal/install-1.9-linux64.sh	(revision 14310)
+++ /issm/trunk/externalpackages/gdal/install-1.9-linux64.sh	(revision 14310)
@@ -0,0 +1,37 @@
+#!/bin/bash
+set -eu
+
+#WARNING: you need to have python installed in externalpackages
+
+#Some cleanup
+rm -rf src
+rm -rf install
+rm -rf gdal-1.9.2
+mkdir src install
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/gdal-1.9.2.tar.gz' 'gdal-1.9.2.tar.gz'
+
+#Untar 
+tar -zxvf  gdal-1.9.2.tar.gz
+
+#Move gdal into src directory
+mv gdal-1.9.2/* src
+rm -rf gdal-1.9.2
+
+#Configure gdal
+cd src
+./configure \
+	--prefix="$ISSM_DIR/externalpackages/gdal/install" \
+	--with-python \
+	--with-netcdf=no \
+	--with-jasper=no \
+	--without-hdf5
+
+#Compile and install gdal
+if [ $# -eq 0 ]; then
+	make
+else
+	make -j $1
+fi
+make install
Index: /issm/trunk/externalpackages/gdal/install-1.9-macosx64.sh
===================================================================
--- /issm/trunk/externalpackages/gdal/install-1.9-macosx64.sh	(revision 14310)
+++ /issm/trunk/externalpackages/gdal/install-1.9-macosx64.sh	(revision 14310)
@@ -0,0 +1,34 @@
+#!/bin/bash
+set -eu
+
+#Some cleanup
+rm -rf src
+rm -rf install
+rm -rf gdal-1.9.2
+mkdir src install
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/gdal-1.9.2.tar.gz' 'gdal-1.9.2.tar.gz'
+
+#Untar 
+tar -zxvf  gdal-1.9.2.tar.gz
+
+#Move gdal into src directory
+mv gdal-1.9.2/* src
+rm -rf gdal-1.9.2
+
+#Configure gdal
+cd src
+./configure \
+	--prefix="$ISSM_DIR/externalpackages/gdal/install" \
+	--with-python \
+	--with-netcdf=no \
+	--without-hdf5
+
+#Compile and install gdal
+if [ $# -eq 0 ]; then
+	make
+else
+	make -j $1
+fi
+make install
Index: sm/trunk/externalpackages/gdal/install-linux64-astrid.sh
===================================================================
--- /issm/trunk/externalpackages/gdal/install-linux64-astrid.sh	(revision 14309)
+++ 	(revision )
@@ -1,41 +1,0 @@
-#!/bin/bash
-set -eu
-
-#Some cleanup
-rm -rf src
-rm -rf install
-rm -rf gdal-1.6.0
-mkdir src install
-
-#Download from ISSM server
-$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/gdal-1.6.0.tar.gz' 'gdal-1.6.0.tar.gz'
-
-#Untar 
-tar -zxvf  gdal-1.6.0.tar.gz
-
-#Move gdal into src directory
-mv gdal-1.6.0/* src
-rm -rf gdal-1.6.0
-
-#Configure gdal
-cd src
-./configure \
-	--prefix="$ISSM_DIR/externalpackages/gdal/install" \
-	--without-python \
-	--without-png \
-	--with-netcdf=no \
-	--with-jasper=no \
-	--without-ld-shared \
-	--with-unix-stdio-64=no \
-	--with-expat-lib=/usr/lib64/libexpat.so
-
-#Patch GDALmake.opt
-patch GDALmake.opt ../GDALmake.opt.patch.astrid
-
-#Compile and install gdal
-if [ $# -eq 0 ]; then
-	make
-else
-	make -j $1
-fi
-make install
Index: sm/trunk/externalpackages/gdal/install-linux64-murdo.sh
===================================================================
--- /issm/trunk/externalpackages/gdal/install-linux64-murdo.sh	(revision 14309)
+++ 	(revision )
@@ -1,39 +1,0 @@
-#!/bin/bash
-set -eu
-
-#Some cleanup
-rm -rf src
-rm -rf install
-rm -rf gdal-1.6.0
-mkdir src install
-
-#Download from ISSM server
-$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/gdal-1.6.0.tar.gz' 'gdal-1.6.0.tar.gz'
-
-#Untar 
-tar -zxvf  gdal-1.6.0.tar.gz
-
-#Move gdal into src directory
-mv gdal-1.6.0/* src
-rm -rf gdal-1.6.0
-
-#Configure gdal
-cd src
-./configure --prefix="$ISSM_DIR/externalpackages/gdal/install" \
-	--without-python \
-	--without-png \
-	--with-netcdf=no \
-	--with-jasper=no \
-	--without-ld-shared \
-	--with-unix-stdio-64=no 
-
-#Patch GDALmake.opt
-patch GDALmake.opt ../GDALmake.opt.patch
-
-#Compile and install gdal
-if [ $# -eq 0 ]; then
-	make
-else
-	make -j $1
-fi
-make install
Index: sm/trunk/externalpackages/gdal/install-macosx64.sh
===================================================================
--- /issm/trunk/externalpackages/gdal/install-macosx64.sh	(revision 14309)
+++ 	(revision )
@@ -1,38 +1,0 @@
-#!/bin/bash
-set -eu
-
-#Some cleanup
-rm -rf src
-rm -rf install
-rm -rf gdal-1.6.0
-mkdir src install
-
-#Download from ISSM server
-$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/gdal-1.6.0.tar.gz' 'gdal-1.6.0.tar.gz'
-
-#Untar 
-tar -zxvf  gdal-1.6.0.tar.gz
-
-#Move gdal into src directory
-mv gdal-1.6.0/* src
-rm -rf gdal-1.6.0
-
-#Configure gdal
-cd src
-./configure \
-	--prefix="$ISSM_DIR/externalpackages/gdal/install" \
-	--without-python \
-	--without-png \
-	--with-netcdf=no \
-	--with-jasper=no \
-	--without-ld-shared \
-	--with-unix-stdio-64=no \
-	--with-expat-lib=/usr/lib64/libexpat.so
-
-#Compile and install gdal
-if [ $# -eq 0 ]; then
-	make
-else
-	make -j $1
-fi
-make install
Index: /issm/trunk/externalpackages/gsl/install-android.sh
===================================================================
--- /issm/trunk/externalpackages/gsl/install-android.sh	(revision 14309)
+++ /issm/trunk/externalpackages/gsl/install-android.sh	(revision 14310)
@@ -28,11 +28,10 @@
     patch Makefile.am < Makefile.am.patch
 
-    autoreconf -iv --force -I $ISSM_DIR/externalpackages/autotools/install/share/aclocal
+    autoreconf -i
 
     ./configure \
         --build="i386-apple-darwin10.8.0" \
         --host=$host_triplet \
-	    --prefix="$ISSM_DIR/externalpackages/gsl/install/" \
-        --disable-static
+	    --prefix="$ISSM_DIR/externalpackages/gsl/install"
 fi
 
Index: /issm/trunk/externalpackages/gsl/install-greenplanet.sh
===================================================================
--- /issm/trunk/externalpackages/gsl/install-greenplanet.sh	(revision 14310)
+++ /issm/trunk/externalpackages/gsl/install-greenplanet.sh	(revision 14310)
@@ -0,0 +1,30 @@
+#!/bin/bash
+set -eu
+
+#Some cleanup
+rm -rf src install gsl-1.15
+mkdir src install
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/gsl-1.15.tar.gz' 'gsl-1.15.tar.gz'
+
+#Untar 
+tar -zxvf  gsl-1.15.tar.gz
+
+#Move gsl into src directory
+mv gsl-1.15/* src
+rm -rf gsl-1.15
+
+#Configure gsl
+cd src
+
+./configure \
+	--prefix="$ISSM_DIR/externalpackages/gsl/install" 
+
+#Compile gsl
+if [ $# -eq 0 ]; then
+	make
+else
+	make -j $1
+fi
+make install 
Index: /issm/trunk/externalpackages/howatmask/enviread.m
===================================================================
--- /issm/trunk/externalpackages/howatmask/enviread.m	(revision 14310)
+++ /issm/trunk/externalpackages/howatmask/enviread.m	(revision 14310)
@@ -0,0 +1,323 @@
+function I=enviread(varargin)
+%enviread: Read binary image files using ENVI header information
+%
+%I=enviread('filename') where the header file is named filename.hdr
+%and exists in the same directory. Otherwise use 
+%
+%I=enviread('filename','hdrfilename')
+%
+%The output structure I contains fields I.x, I.y, I.z and I.info
+%containing the x-coordinate vector, y-coordinate vector,
+%images data and header info, respectively. I.z will be in whatever
+%number format (double, int, etc.) as in the envi file.
+%
+%Original version by Ian Howat, Ohio State Universtiy, ihowat@gmail.com
+%Thanks to Yushin Ahn and Ray Jung
+%
+%% Current version 3 - adding subsetting feature to read only parts of
+%% files.
+
+file=varargin{1};
+hdrfile=[deblank(file),'.hdr'];
+info=read_envihdr(hdrfile);
+sub = [1, info.samples, 1, info.lines];
+if nargin==2
+    if varargin{2}=='date'
+        [pathstr, name, ext, versn] = fileparts(file);
+        info.hdrname=hdrfile;
+        info.ipath=pathstr;
+        info.iname=name;
+        info.ipname=file;
+        info.year =name(1:4);
+        info.month=name(5:6);
+        info.day  =name(7:8);
+        info.date =name(1:8);
+        info.sfname=name(1:14);
+        info.datenum=datenum(str2double(info.year),...
+            str2double(info.month),str2double(info.day));
+    end
+end
+
+% subset
+if nargin == 3;
+    if strcmp(varargin{2},'pixel_subset');
+        sub = varargin{3};
+    elseif strcmp(varargin{2},'map_subset');
+        sub = varargin{3};
+        subx = (sub(1:2)-info.map_info.mapx)./info.map_info.dx;
+        suby = (info.map_info.mapy - sub(3:4))./info.map_info.dy;
+        subx = round(subx);
+        suby = round(suby);
+        
+        subx(subx < 1) = 1;
+        suby(suby < 1) = 1;
+        subx(subx > info.samples) = info.samples;
+        suby(suby > info.lines)   = info.lines;
+      
+        sub  = [subx,suby];
+    end
+end
+
+sub(1:2) = sort(sub(1:2));
+sub(3:4) = sort(sub(3:4));
+
+
+%% Make geo-location vectors
+if isfield(info.map_info,'mapx') && isfield(info.map_info,'mapy')
+    xi = info.map_info.image_coords(1);
+    yi = info.map_info.image_coords(2);
+    xm = info.map_info.mapx;
+    ym = info.map_info.mapy;
+    %adjust points to corner (1.5,1.5)
+    if yi > 1.5
+        ym =  ym + ((yi*info.map_info.dy)-info.map_info.dy);
+    end
+    if xi > 1.5
+        xm = xm - ((xi*info.map_info.dy)-info.map_info.dx);
+    end
+
+    I.x = xm + ((0:info.samples-1).*info.map_info.dx);
+    I.y = ym - ((0:info.lines-1).*  info.map_info.dy);
+    %I.x = xm + (subE(1):subE(2)-1).*info.map_info.dx;
+    %I.y = ym - (subE(3):subE(4)-1).*info.map_info.dy;
+end
+
+
+I.x = I.x(sub(1):sub(2));
+I.y = I.y(sub(3):sub(4));
+
+
+%% Set binary format parameters
+switch info.byte_order
+    case {0}
+        machine = 'ieee-le';
+    case {1}
+        machine = 'ieee-be';
+    otherwise
+        machine = 'n';
+end
+switch info.data_type
+    case {1}
+        format = 'uint8';
+    case {2}
+        format= 'int16';
+    case{3}
+        format= 'int32';
+    case {4}
+        format= 'single';
+    case {5}
+        format= 'double';
+    case {6}
+        disp('>> Sorry, Complex (2x32 bits)data currently not supported');
+        disp('>> Importing as double-precision instead');
+        format= 'double';
+    case {9}
+        error('Sorry, double-precision complex (2x64 bits) data currently not supported');
+    case {12}
+        format= 'uint16';
+    case {13}
+        format= 'uint32';
+    case {14}
+        format= 'int64';
+    case {15}
+        format= 'uint64';
+    otherwise
+        error(['File type number: ',num2str(dtype),' not supported']);
+end
+
+%% file read
+% Version 2 code by Yushin Ahn - replaces resize calls with loops (except
+% for BIP formats) to work on big arrays.
+
+        %tmp=zeros(info.lines, info.samples,info.bands,format);
+        tmp=zeros(sub(4)-sub(3)+1,sub(2)-sub(1)+1,info.bands,format);
+        fid=fopen(file,'r');
+
+switch lower(info.interleave)
+
+    case {'bsq'}
+        % Format:
+        % [Band 1]       
+        % R1: C1, C2, C3, ...
+        % R2: C1, C2, C3, ...
+        %  ...
+        % RN: C1, C2, C3, ...
+        %
+        % [Band 2]
+        %  ...
+        % [Band N]
+
+%% Old Script w/out subsetting
+%         for b=1:info.bands
+%             for i=1:info.lines
+%                 t=fread(fid,info.samples,format);
+%                 tmp(i,:,b)=t;    
+%             end
+%         end
+        
+%% New Subsetting script - IMH
+        offset1=(sub(3)-1)*info.samples;
+        fseek(fid,offset1,'bof');
+        for b=1:info.bands
+            for i=sub(3):sub(4)
+                t=fread(fid,info.samples,format);
+                %if i >=  sub(3) && i <= sub(4)
+                    tmp(i-sub(3)+1,:,b)=t(sub(1):sub(2));
+                %end
+            end
+            offset2 = info.samples*info.lines*b+offset1;
+            fseek(fid,offset2,'bof');
+        end
+
+    case {'bil'}
+        % Format:        
+        % [Row 1]      
+        % B1: C1, C2, C3, ...
+        % B2: C1, C2, C3, ...
+        %
+        %  ...
+        % [Row N]
+
+%         for i=1:info.lines
+%             for b=1:info.bands
+%                  t=fread(fid,info.samples,format);
+%                 tmp(i,:,b)=t;       
+%             end
+%         end
+      
+%% New Subsetting script - IMH
+        for i=1:sub(4) 
+            for b=1:info.bands
+                t=fread(fid,info.samples,format);
+                if i >=  sub(3) && i <= sub(4) 
+                    tmp(i-sub(3)+1,:,b)=t(sub(1):sub(2));    
+                end
+            end
+        end
+
+
+
+    case {'bip'}
+    
+        % Row 1
+        % C1: B1 B2 B3, ...
+        % C2: B1 B2 B3, ...
+        % ...
+        % Row N
+        %This section authored by Ray Jung, APL-Johns Hopkins
+        Z = fread(fid,info.samples*info.lines*info.bands,format,0,machine);  
+        Z = reshape(Z, [info.bands, info.samples, info.lines]);
+
+        for k=1:info.bands
+            tmp(:,:,k) = squeeze(Z(k,:,:))';
+        end     
+end
+fclose(fid);
+
+% tmp2=zeros(subE(4)-subE(3)+1,subE(2)-subE(1)+1,info.bands,format);
+% [a,b]=size(tmp);
+% for i=1:info.bands
+%     tmp2(xoff+1:a,yoff+1:b,1)=tmp(1:a,1:b,1);
+% end
+I.z=tmp;
+I.info =info;
+
+
+
+%% sub function
+function info = read_envihdr(hdrfile)
+% READ_ENVIHDR read and return ENVI image file header information.
+%   INFO = READ_ENVIHDR('HDR_FILE') reads the ASCII ENVI-generated image
+%   header file and returns all the information in a structure of
+%   parameters.
+%
+%   Example:
+%   >> info = read_envihdr('my_envi_image.hdr')
+%   info =
+%          description: [1x101 char]
+%              samples: 658
+%                lines: 749
+%                bands: 3
+%        header_offset: 0
+%            file_type: 'ENVI Standard'
+%            data_type: 4
+%           interleave: 'bsq'
+%          sensor_type: 'Unknown'
+%           byte_order: 0
+%             map_info: [1x1 struct]
+%      projection_info: [1x102 char]
+%     wavelength_units: 'Unknown'
+%           pixel_size: [1x1 struct]
+%           band_names: [1x154 char]
+%
+%   NOTE: This function is used by ENVIREAD to import data.
+% Ian M. Howat, Applied Physics Lab, University of Washington
+% ihowat@apl.washington.edu
+% Version 1: 19-Jul-2007 00:50:57
+fid = fopen(hdrfile);
+while fid;
+    line = fgetl(fid);
+    if line == -1
+        break
+    else
+        eqsn = findstr(line,'=');
+        if ~isempty(eqsn)
+            param = strtrim(line(1:eqsn-1));
+            param(findstr(param,' ')) = '_';
+            value = strtrim(line(eqsn+1:end));
+            if isempty(str2num(value))
+                if ~isempty(findstr(value,'{')) && isempty(findstr(value,'}'))
+                    while isempty(findstr(value,'}'))
+                        line = fgetl(fid);
+                        value = [value,strtrim(line)];
+                    end
+                end
+                eval(['info.',param,' = ''',value,''';'])
+            else
+                eval(['info.',param,' = ',value,';'])
+            end
+        end
+    end
+end
+fclose(fid);
+
+if isfield(info,'map_info')
+    line = info.map_info;
+    line(line == '{' | line == '}') = [];
+    line = strtrim(split(line,','));
+    info.map_info = [];
+    info.map_info.projection = line{1};
+    info.map_info.image_coords = [str2num(line{2}),str2num(line{3})];
+    info.map_info.mapx = str2num(line{4});
+    info.map_info.mapy = str2num(line{5});
+    info.map_info.dx  = str2num(line{6});
+    info.map_info.dy  = str2num(line{7});
+    if length(line) == 9
+        info.map_info.datum  = line{8};
+        info.map_info.units  = line{9}(7:end);
+    elseif length(line) == 11
+        info.map_info.zone  = str2num(line{8});
+        info.map_info.hemi  = line{9};
+        info.map_info.datum  = line{10};
+        info.map_info.units  = line{11}(7:end);
+    end
+end
+
+if isfield(info,'pixel_size')
+    line = info.pixel_size;
+    line(line == '{' | line == '}') = [];
+    line = strtrim(split(line,','));
+    info.pixel_size = [];
+    info.pixel_size.x = str2num(line{1});
+    info.pixel_size.y = str2num(line{2});
+    info.pixel_size.units = line{3}(7:end);
+end
+
+%%
+function A = split(s,d)
+%This function by Gerald Dalley (dalleyg@mit.edu), 2004
+A = {};
+while (length(s) > 0)
+    [t,s] = strtok(s,d);
+    A = {A{:}, t};
+end
Index: /issm/trunk/externalpackages/howatmask/subsetGimpIceMask.m
===================================================================
--- /issm/trunk/externalpackages/howatmask/subsetGimpIceMask.m	(revision 14310)
+++ /issm/trunk/externalpackages/howatmask/subsetGimpIceMask.m	(revision 14310)
@@ -0,0 +1,282 @@
+function [M,Mx,My] = subsetGimpIceMask(x0,x1,y0,y1)
+% subsetGimpIceMask samples mask tiles for a given coordinate range
+%
+%   [M,Mx,My] = subsetGimpIceMask(x0,x1,y0,y1) returns the mask in array M
+%   with map vectors Mx and My within the bounding box specified by
+%   coordinate ranges x0 < x1 and y0 < y1. The function finds tiles
+%   overlappimg the box, samples the tiles and mosaics the samples into one
+%   array.
+%
+% 	Example: Specify the following coordinate range and map the result.
+%   >> x0 = 260000; x1 = 377900;  y0 = -2609400; y1 = -2543000;
+%   >> [M,Mx,My] = subsetGimpIceMask(x0,x1,y0,y1);
+%   >> imagesc(Mx,My,M); axis equal xy; colormap gray;
+%
+%   Ian Howat, Ohio State University, ihowat@gmail.com
+%   The Greenland Ice Mapping Project is funded by NASA.
+%   $Revision: 0 $  $Date: 09-Nov-2011 14:48:24$
+%
+
+%make coordinate index
+nt = 6;
+ps = 15;
+xn0 = -640000 ; %xn1 = 857550;
+yn0 =  -3313350; %yn1 = -665450;
+
+c = 16640;
+r = 29420;
+
+x = xn0:ps:xn0 + c.*ps.*nt;
+y = yn0:ps:yn0 + r.*ps.*nt;
+
+X = cell(1,nt);
+Y = cell(nt,1);
+i=1;
+for i=1:nt;
+    
+    X{i} = [x((i-1)*c+1),x(i*c)];
+    Y{i} = [y((i-1)*r+1),y(i*r)];
+    
+end
+
+X = repmat(X,[nt,1]);
+Y = repmat(Y,[1,nt]);
+N = cell(size(X));
+
+
+i=1;
+for i=1:numel(X)
+    N{i} = [[X{i}(1),Y{i}(2)];...
+        [X{i}(2),Y{i}(2)];...
+        [X{i}(2),Y{i}(1)];...
+        [X{i}(1),Y{i}(1)]];
+end
+
+
+%% find overlapping tiles
+p = [[x0,y1];[x1,y1];[x1,y0];[x0,y0]];
+
+n = zeros(size(N));
+
+i=1;
+for i=1:numel(N)
+    n(i) = any(inpolygon(p(:,1),p(:,2),N{i}(:,1),N{i}(:,2)));
+end
+i=1;
+for i=1:size(n,1)
+    n(i,find(n(i,:),1,'first'):find(n(i,:),1,'last')) = 1;
+end
+i=1;
+for i=1:size(n,2)
+    n(find(n(:,i),1,'first'):find(n(:,i),1,'last'),i) = 1;
+end
+
+[i,j] = find(n);
+row = (min(i):max(i))';
+col = min(j):max(j);
+col = repmat(col,[length(row),1])-1;
+row = repmat(row,[1,size(col,2)])-1;
+
+% make output cells
+M = cell(size(row));
+Mx = M;
+My = M;
+
+% read each overlapping file and populate output cell
+j=1;
+for j=1:size(col,2)
+    i=1;
+    for i=1:size(row,1);
+        m = enviread(['GimpIceMask_15m_tile',num2str(col(i,j)),'_',...
+            num2str(row(i,j))],'map_subset',[x0 x1 y0 y1]);
+        M{end-i+1,j} = m.z;
+        Mx{end-i+1,j} = m.x;
+        My{end-i+1,j} = m.y';
+        
+        
+    end
+end
+
+% put together cells
+M = cell2mat(M);
+Mx =cell2mat(Mx(1,:));
+My =cell2mat(My(:,1));
+
+
+function I=enviread(varargin)
+
+file=varargin{1};
+hdrfile=[deblank(file),'.hdr'];
+info=read_envihdr(hdrfile);
+sub = [1, info.samples, 1, info.lines];
+
+sub = varargin{3};
+subx = (sub(1:2)-info.map_info.mapx)./info.map_info.dx;
+suby = (info.map_info.mapy - sub(3:4))./info.map_info.dy;
+subx = round(subx);
+suby = round(suby);
+
+subx(subx < 1) = 1;
+suby(suby < 1) = 1;
+subx(subx > info.samples) = info.samples;
+suby(suby > info.lines)   = info.lines;
+
+sub  = [subx,suby];
+
+sub(1:2) = sort(sub(1:2));
+sub(3:4) = sort(sub(3:4));
+
+%% Make geo-location vectors
+if isfield(info.map_info,'mapx') && isfield(info.map_info,'mapy')
+    xi = info.map_info.image_coords(1);
+    yi = info.map_info.image_coords(2);
+    xm = info.map_info.mapx;
+    ym = info.map_info.mapy;
+    %adjust points to corner (1.5,1.5)
+    if yi > 1.5
+        ym =  ym + ((yi*info.map_info.dy)-info.map_info.dy);
+    end
+    if xi > 1.5
+        xm = xm - ((xi*info.map_info.dy)-info.map_info.dx);
+    end
+    
+    I.x = xm + ((0:info.samples-1).*info.map_info.dx);
+    I.y = ym - ((0:info.lines-1).*  info.map_info.dy);
+    
+end
+
+I.x = I.x(sub(1):sub(2));
+I.y = I.y(sub(3):sub(4));
+
+%% Set binary format parameters
+switch info.byte_order
+    case {0}
+        machine = 'ieee-le';
+    case {1}
+        machine = 'ieee-be';
+    otherwise
+        machine = 'n';
+end
+
+format = 'uint8';
+
+tmp=zeros(sub(4)-sub(3)+1,sub(2)-sub(1)+1,info.bands,format);
+fid=fopen(file,'r');
+
+offset1=(sub(3)-1)*info.samples;
+fseek(fid,offset1,'bof');
+for b=1:info.bands
+    for i=sub(3):sub(4)
+        t=fread(fid,info.samples,format);
+        tmp(i-sub(3)+1,:,b)=t(sub(1):sub(2));
+    end
+    offset2 = info.samples*info.lines*b+offset1;
+    fseek(fid,offset2,'bof');
+end
+
+fclose(fid);
+
+I.z=tmp;
+I.info =info;
+
+%% sub function
+function info = read_envihdr(hdrfile)
+% READ_ENVIHDR read and return ENVI image file header information.
+%   INFO = READ_ENVIHDR('HDR_FILE') reads the ASCII ENVI-generated image
+%   header file and returns all the information in a structure of
+%   parameters.
+%
+%   Example:
+%   >> info = read_envihdr('my_envi_image.hdr')
+%   info =
+%          description: [1x101 char]
+%              samples: 658
+%                lines: 749
+%                bands: 3
+%        header_offset: 0
+%            file_type: 'ENVI Standard'
+%            data_type: 4
+%           interleave: 'bsq'
+%          sensor_type: 'Unknown'
+%           byte_order: 0
+%             map_info: [1x1 struct]
+%      projection_info: [1x102 char]
+%     wavelength_units: 'Unknown'
+%           pixel_size: [1x1 struct]
+%           band_names: [1x154 char]
+%
+%   NOTE: This function is used by ENVIREAD to import data.
+% Ian M. Howat, Applied Physics Lab, University of Washington
+% ihowat@apl.washington.edu
+% Version 1: 19-Jul-2007 00:50:57
+fid = fopen(hdrfile);
+while fid;
+    line = fgetl(fid);
+    if line == -1
+        break
+    else
+        eqsn = findstr(line,'=');
+        if ~isempty(eqsn)
+            param = strtrim(line(1:eqsn-1));
+            param(findstr(param,' ')) = '_';
+            value = strtrim(line(eqsn+1:end));
+            if isempty(str2num(value))
+                if ~isempty(findstr(value,'{')) && isempty(findstr(value,'}'))
+                    while isempty(findstr(value,'}'))
+                        line = fgetl(fid);
+                        value = [value,strtrim(line)];
+                    end
+                end
+                eval(['info.',param,' = ''',value,''';'])
+            else
+                eval(['info.',param,' = ',value,';'])
+            end
+        end
+    end
+end
+fclose(fid);
+
+if isfield(info,'map_info')
+    line = info.map_info;
+    line(line == '{' | line == '}') = [];
+    line = strtrim(split(line,','));
+    info.map_info = [];
+    info.map_info.projection = line{1};
+    info.map_info.image_coords = [str2num(line{2}),str2num(line{3})];
+    info.map_info.mapx = str2num(line{4});
+    info.map_info.mapy = str2num(line{5});
+    info.map_info.dx  = str2num(line{6});
+    info.map_info.dy  = str2num(line{7});
+    if length(line) == 9
+        info.map_info.datum  = line{8};
+        info.map_info.units  = line{9}(7:end);
+    elseif length(line) == 11
+        info.map_info.zone  = str2num(line{8});
+        info.map_info.hemi  = line{9};
+        info.map_info.datum  = line{10};
+        info.map_info.units  = line{11}(7:end);
+    end
+end
+
+if isfield(info,'pixel_size')
+    line = info.pixel_size;
+    line(line == '{' | line == '}') = [];
+    line = strtrim(split(line,','));
+    info.pixel_size = [];
+    info.pixel_size.x = str2num(line{1});
+    info.pixel_size.y = str2num(line{2});
+    info.pixel_size.units = line{3}(7:end);
+end
+
+%%
+function A = split(s,d)
+%This function by Gerald Dalley (dalleyg@mit.edu), 2004
+A = {};
+while (length(s) > 0)
+    [t,s] = strtok(s,d);
+    A = {A{:}, t};
+end
+
+
+
+
Index: /issm/trunk/externalpackages/metis/install-4.0-hoffman2.sh
===================================================================
--- /issm/trunk/externalpackages/metis/install-4.0-hoffman2.sh	(revision 14310)
+++ /issm/trunk/externalpackages/metis/install-4.0-hoffman2.sh	(revision 14310)
@@ -0,0 +1,24 @@
+#!/bin/bash
+set -eu
+
+#Some cleanup
+rm -rf install metis-4.0
+mkdir install
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/metis-4.0.tar.gz' 'metis-4.0.tar.gz'
+
+#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/pleiades/Makefile.in.patch
+
+#Compile
+make
Index: /issm/trunk/externalpackages/petsc/install-3.2-hoffman2.sh
===================================================================
--- /issm/trunk/externalpackages/petsc/install-3.2-hoffman2.sh	(revision 14310)
+++ /issm/trunk/externalpackages/petsc/install-3.2-hoffman2.sh	(revision 14310)
@@ -0,0 +1,35 @@
+#!/bin/bash
+set -eu
+
+#Some cleanup
+rm -rf install petsc-3.2-p3 src
+mkdir install src
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/petsc-3.2-p3.tar.gz' 'petsc-3.2-p3.tar.gz'
+
+#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_DIR/externalpackages/petsc/install" \
+	--with-mpi=1 \
+	--PETSC_ARCH=linux-gnu-amd64 \
+	--PETSC_DIR="$ISSM_DIR/externalpackages/petsc/src" \
+	--with-debugging=0 \
+	--download-mumps=yes \
+	--download-scalapack=yes \
+	--download-blacs=yes \
+	--download-blas=yes \
+	--download-f-blas-lapack=yes \
+	--download-plapack=yes \
+	--download-parmetis=yes \
+	--with-pic=1
+
+#Compile petsc and install it
+make
+make install
Index: /issm/trunk/m4/issm_options.m4
===================================================================
--- /issm/trunk/m4/issm_options.m4	(revision 14309)
+++ /issm/trunk/m4/issm_options.m4	(revision 14310)
@@ -163,12 +163,4 @@
 	fi
 	AC_MSG_RESULT($HAVE_TRIANGLE)
-
-	AC_MSG_CHECKING(for triangle and parallel status)
-	if test $HAVE_TRIANGLE = no; then
-		if test "$SERIAL_VALUE" = "yes" ; then
-			AC_MSG_ERROR([--with-triangle-dir  missing. Triangle is needed to run ISSM serially!])
-		fi
-	fi
-	AC_MSG_RESULT(ok)
 	dnl }}}
 	dnl dakota{{{
@@ -182,15 +174,42 @@
 		dnl defaults
 		HAVE_DAKOTA=yes
+		AC_MSG_RESULT($HAVE_DAKOTA)
 		DAKOTAINCL=-I$DAKOTA_ROOT/include
+		AC_MSG_CHECKING(for dakota version)
+		DAKOTA_VERSION=`cat $DAKOTA_ROOT/include/dakota_config.h | grep "#define PACKAGE_VERSION" | sed 's/#define PACKAGE_VERSION//' | sed 's/ //g' | sed -e 's/\"//g' `
+		AC_MSG_RESULT($DAKOTA_VERSION)
+		AC_DEFINE_UNQUOTED([DAKOTA_VERSION],"$DAKOTA_VERSION",[Dakota version number])
 		case "${host_os}" in
 			*cygwin*)
-			DAKOTALIB="-L$DAKOTA_ROOT/lib -ldakota -lteuchos -lpecos -lfftw3 -llhs -levidence -lsurfpack -lconmin -lddace -lfsudace -ljega -lcport -lopt -lpsuade -lnewmat -lncsuopt -lgsl -lquadrature -lcoliny -lcolin -lpebbl -lutilib -l3po -lnappspack -lappspack -lconveyor -lshared -lcdd -lamplsolver"
+				if      test x$DAKOTA_VERSION = x4.2; then
+					DAKOTALIB="-L$DAKOTA_ROOT/lib -ldakota -lteuchos -lpecos -lfftw3 -llhs -levidence -lsurfpack -lconmin -lddace -lfsudace -ljega -lcport -lopt -lpsuade -lnewmat -lncsuopt -lgsl -lquadrature -lcoliny -lcolin -lpebbl -lutilib -l3po -lnappspack -lappspack -lconveyor -lshared -lcdd -lamplsolver"
+				else if test x$DAKOTA_VERSION = x5.1 || test x$DAKOTA_VERSION = x5.2; then
+					DAKOTALIB="-L$DAKOTA_ROOT/lib -ldakota -lteuchos -lpecos -llhs -lsparsegrid -lsurfpack -lconmin -lddace -lfsudace -ljega -lcport -loptpp -lpsuade -lncsuopt -lcolin -linterfaces -lmomh -lscolib -lpebbl -ltinyxml -lutilib -l3po -lhopspack -lnidr -lamplsolver -lboost_signals -lboost_regex -lboost_filesystem -lboost_system"
+				else
+					AC_MSG_ERROR([Dakota version not found or version ($DAKOTA_VERSION) not supported!]);
+				fi
+				fi
 			;;
 			*linux*)
-			  DAKOTALIB="-L$DAKOTA_ROOT/lib -ldakota -lteuchos -lpecos -lfftw3 -llhs -levidence -lsurfpack -lconmin -lddace -lfsudace -ljega -lcport -lopt -lpsuade -lnewmat -lncsuopt -lgsl -lquadrature -lcoliny -lcolin -lpebbl -lutilib -l3po -lnappspack -lappspack -lconveyor -lshared -lcdd -lamplsolver"
+				if      test x$DAKOTA_VERSION = x4.2; then
+					DAKOTALIB="-L$DAKOTA_ROOT/lib -ldakota -lteuchos -lpecos -lfftw3 -llhs -levidence -lsurfpack -lconmin -lddace -lfsudace -ljega -lcport -lopt -lpsuade -lnewmat -lncsuopt -lgsl -lquadrature -lcoliny -lcolin -lpebbl -lutilib -l3po -lnappspack -lappspack -lconveyor -lshared -lcdd -lamplsolver"
+				else if test x$DAKOTA_VERSION = x5.1 || test x$DAKOTA_VERSION = x5.2; then
+					DAKOTALIB="-L$DAKOTA_ROOT/lib -ldakota -lteuchos -lpecos -llhs -lsparsegrid -lsurfpack -lconmin -lddace -lfsudace -ljega -lcport -loptpp -lpsuade -lncsuopt -lcolin -linterfaces -lmomh -lscolib -lpebbl -ltinyxml -lutilib -l3po -lhopspack -lnidr -lamplsolver -lboost_signals -lboost_regex -lboost_filesystem -lboost_system"
+				else
+					AC_MSG_ERROR([Dakota version not found or version ($DAKOTA_VERSION) not supported!]);
+				fi
+				fi
 			;;
 			*darwin*)
-			  DAKOTALIB="-L$DAKOTA_ROOT/lib -ldakota -lteuchos -lpecos -lfftw3 -llhs -levidence -lsurfpack -lconmin -lddace -lfsudace -ljega -lcport -lopt -lpsuade -lnewmat -lncsuopt -lgsl -lquadrature -lcoliny -lcolin -lpebbl -lutilib -l3po -lnappspack -lappspack -lconveyor -lshared -lcdd -lamplsolver" 
-			  dnl DAKOTALIB+= "-lgslcblas -L/usr/lib -lblas -llapack"
+				if      test x$DAKOTA_VERSION = x4.2; then
+					DAKOTALIB="-L$DAKOTA_ROOT/lib -ldakota -lteuchos -lpecos -lfftw3 -llhs -levidence -lsurfpack -lconmin -lddace -lfsudace -ljega -lcport -lopt -lpsuade -lnewmat -lncsuopt -lgsl -lquadrature -lcoliny -lcolin -lpebbl -lutilib -l3po -lnappspack -lappspack -lconveyor -lshared -lcdd -lamplsolver" 
+					dnl DAKOTALIB+= "-lgslcblas -L/usr/lib -lblas -llapack"
+				else if test x$DAKOTA_VERSION = x5.1 || test x$DAKOTA_VERSION = x5.2; then
+					DAKOTALIB="-L$DAKOTA_ROOT/lib -ldakota -lteuchos -lpecos -llhs -lsparsegrid -lsurfpack -lconmin -lddace -lfsudace -ljega -lcport -loptpp -lpsuade -lncsuopt -lcolin -linterfaces -lmomh -lscolib -lpebbl -ltinyxml -lutilib -l3po -lhopspack -lnidr -lamplsolver -lboost_signals -lboost_regex -lboost_filesystem -lboost_system"
+					dnl DAKOTALIB+= "-lgslcblas -L/usr/lib -lblas -llapack"
+				else
+					AC_MSG_ERROR([Dakota version not found or version ($DAKOTA_VERSION) not supported!]);
+				fi
+				fi
 			;;
 		esac
@@ -201,7 +220,7 @@
 	else
 		HAVE_DAKOTA=no
+		AC_MSG_RESULT($HAVE_DAKOTA)
 	fi
 	AM_CONDITIONAL([DAKOTA], [test x$HAVE_DAKOTA = xyes])
-	AC_MSG_RESULT($HAVE_DAKOTA)
 	dnl }}}
 	dnl boost{{{
@@ -1045,7 +1064,19 @@
 		dnl check that --with-fortran-lib may have been provided
 		if test -n "$FORTRAN_LIB" ; then
-			FORTRANLIB="$FORTRAN_LIB"
-			AC_DEFINE([_HAVE_FORTRAN_],[1],[with FORTRAN in ISSM src])
-			AC_SUBST([FORTRANLIB])
+			dnl check that library provided EXISTS!
+		   FORTRAN_DIR=$(echo $FORTRAN_LIB | sed -e "s/-L//g" | awk '{print $[1]}')
+			if test -d "$FORTRAN_DIR" || test -f "$FORTRAN_DIR"; then
+				FORTRANLIB="$FORTRAN_LIB"
+				AC_DEFINE([_HAVE_FORTRAN_],[1],[with FORTRAN in ISSM src])
+				AC_SUBST([FORTRANLIB])
+			else
+			 if test "x$HAVE_MPI" = "xyes"; then
+				FORTRANLIB=$(mpif77 -print-file-name="libgfortran.a")
+				if test -f "$FORTRANLIB"; then
+					 AC_MSG_ERROR([fortran library provided ($FORTRAN_LIB) does not exist, MPI suggests the following library: $FORTRANLIB]);
+				fi
+			 fi
+				AC_MSG_ERROR([frtran library provided ($FORTRAN_LIB$) does not exist!]);
+			fi
 		fi
 		AC_MSG_RESULT(done)
@@ -1059,10 +1090,20 @@
 
 	dnl check that --with-graphics-lib may have been provided
+	
 	if test -n "$GRAPHICS_LIB" ; then
-		HAVE_GRAPHICS=yes
-		GRAPHICSLIB="$GRAPHICS_LIB"
-
-		AC_DEFINE([_HAVE_GRAPHICS_],[1],[with GRAPHICS in ISSM src])
-		AC_SUBST([GRAPHICSLIB])
+		dnl check that library provided EXISTS!
+		GRAPHICS_DIR=$(echo $GRAPHICS_LIB | sed -e "s/-L//g" | awk '{print $[1]}')
+		if test -d "$GRAPHICS_DIR" || test -f "$GRAPHICS_DIR"; then
+			HAVE_GRAPHICS=yes
+			GRAPHICSLIB="$GRAPHICS_LIB"
+			AC_DEFINE([_HAVE_GRAPHICS_],[1],[with GRAPHICS in ISSM src])
+			AC_SUBST([GRAPHICSLIB])
+		else
+			if test -f "$PETSC_ROOT/conf/petscvariables"; then
+				GRAPHICSLIB=$(cat $PETSC_ROOT/conf/petscvariables | grep X_LIB)
+				AC_MSG_ERROR([graphics library provided ($GRAPHICS_LIB) does not exist, PETSc suggests the following library: $GRAPHICSLIB]);
+			fi
+			AC_MSG_ERROR([graphics library provided ($GRAPHICS_LIB$) does not exist!]);
+		fi
 	fi
 	AC_MSG_RESULT(done)
@@ -1326,6 +1367,6 @@
 		dnl defaults
 		HAVE_ANDROID=jni
-
 		AC_DEFINE([_HAVE_ANDROID_],[1],[with android capability])
+		AC_DEFINE([_HAVE_ANDROID_JNI_],[1],[with android jni])
 	elif test "x$ANDROID" = "xexe"; then
 		dnl defaults
@@ -1342,4 +1383,22 @@
 	AM_CONDITIONAL([ANDROIDEXE], [test x$HAVE_ANDROID = xexe])
 	AC_MSG_RESULT($HAVE_ANDROID)
+	dnl }}}
+	dnl with-android-ndk{{{
+	AC_ARG_WITH([android-ndk],
+	  AS_HELP_STRING([--with-android-ndk=DIR], [android-ndk root directory.]),
+	  [ANDROID_NDK_ROOT=$withval],[ANDROID_NDK_ROOT=""]) 
+	AC_MSG_CHECKING(with android ndk)
+	
+	if test -d "$ANDROID_NDK_ROOT"; then
+		dnl defaults
+		HAVE_ANDROID_NDK=yes
+		ANDROID_NDKINCL="-I$ANDROID_NDK_ROOT/arm-linux-android-install/sysroot/usr/include"
+
+		AC_DEFINE([_HAVE_ANDROID_NDK_],[1],[with android ndk in ISSM src])
+		AC_SUBST([ANDROID_NDKINCL])
+	else
+		HAVE_ANDROID_NDK=no
+	fi
+	AC_MSG_RESULT($HAVE_ANDROID_NDK)
 	dnl }}}
 	dnl with-3d{{{
Index: /issm/trunk/scripts/DownloadExternalPackage.py
===================================================================
--- /issm/trunk/scripts/DownloadExternalPackage.py	(revision 14309)
+++ /issm/trunk/scripts/DownloadExternalPackage.py	(revision 14310)
@@ -6,11 +6,11 @@
 #
 
+# imports {{{
 import os,sys,re
 import urllib
 from HTMLParser import HTMLParser
 from urllib import FancyURLopener
-
-# Start class myHTMLParser
-class MyHTMLParser(HTMLParser):
+# }}}
+class MyHTMLParser(HTMLParser): #{{{
 
     def __init__(self, pattern):
@@ -23,113 +23,117 @@
             if "href" == i[0] and str(self.matcher.match(i[1])) != "None":
                 self.targets.append(i[1])
-# End class myHTMLParser
+#}}}
+def main(argv=None): # {{{
+    # Separates the URL into a directory and the file or pattern based on the
+    # last appearance of '/'.
+	if len(sys.argv) > 1:
+	    pivot = sys.argv[1].rfind("/")
+	    url = (sys.argv[1])[:pivot]
+	    pivot += 1
+	    find = (sys.argv[1])[pivot:]
+	else:
+	    print "******************************************************************************************************************************"
+	    print "* Invalid input!                                                                                                             *"
+	    print "*                                                                                                                            *"
+	    print "* Try: 'DownloadExternalPackage.py url [localFile]'                                                                          *"
+	    print "*                                                                                                                            *"
+	    print "* Where 'URL' is the URL with an explicit package name or the URL followed by the truncated package name. And 'localFile' is *"
+	    print "* the file name (including extension) that you would like to save as.                                                        *"
+	    print "*                                                                                                                            *"
+	    print "* Examples:                                                                                                                  *" 
+	    print "*                                                                                                                            *"
+	    print "* DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/petsc-2.3.2-p3.tar.gz' 'petsc-2.3.2-p3.tar.gz' *"
+	    print "*                                                                                                                            *"
+	    print "*     This is the old style and the safest way to download a package.                                                        *"
+	    print "*                                                                                                                            *"
+	    print "* DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/libtool' 'libtool.tar.gz'                      *"
+	    print "*                                                                                                                            *"
+	    print "*     This is the new style. For packages like 'Libtool', which we never expect to be using multiple versions, this will     *"
+	    print "*     download the most recent version and save it as the generic 'libtool.tar.gz'.                                          *"
+	    print "*                                                                                                                            *"
+	    print "* DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/gsl-1.' 'gsl-1.15.tar.gz'                      *"
+	    print "*                                                                                                                            *"
+	    print "*     This is the new style. This is a demonstration of how this script can be used to disambiguate a package name if there  *"
+	    print "*     are more than once package matching 'gsl-'.                                                                            *"
+	    print "*                                                                                                                            *"
+	    print "* DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/libtool'                                       *"
+	    print "*                                                                                                                            *"
+	    print "*     This is the new style. This will download a package with 'libtool' as a prefix and save it as its canonical name.      *"
+	    print "*                                                                                                                            *"
+	    print "*                                                                                                                            *"
+	    print "******************************************************************************************************************************"
+	
+	if len(sys.argv) > 2:
+	    localFile=sys.argv[2]
+	    print "Downloaded file will be saved as: " + localFile
+	else:
+	    localFile = None
+	    print "Downloaded file will saved with the same file name."
+	
+	
+	print "Looking for: " + find
+	
+	# As an extra precaution, if no extension is given for a particular package
+	# such as '.../libtool', then ensure that files found are of appropriate
+	# file extensions. 
+	#
+	# WARNING: The external packages directory includes executable binaries with
+	# '.exe' extensions. As such, '.exe' is an acceptable suffix, but this is 
+	# inherently dangerous since this script can be used to download from any
+	# valid website. Furthermore, if an individual attempts a "man-in-the-middle"  
+	# attack, then the user would be capable of downloading executables from 
+	# an untrusted source.
+	pattern = find + "[\w.-]*(\.tar\.gz|tar\.gz2|tgz|zip|exe)?"
+	parser = MyHTMLParser(pattern)
+	
+	# Creates a 'FancyURL' which allows the script to fail gracefully by catching
+	# HTTP error codes 30X and several 40X(where 'X' is a natural number).
+	urlObject = FancyURLopener()
+	obj = urlObject.open(url)
+	parser.feed(obj.read())
+	
+	# If a file pattern was used to describe the file that should be downloaded,
+	# then there is the potential for multiple file matches. Currently, the script
+	# will detect this ambiguity and print out all the matches, while informing 
+	# the user that he must refine his search.
+	#
+	# TODO: Prompt the user to select from a list his/her preferred target.
+	if len(parser.targets) > 1:
+	    print "Could not resolve your download due to the number of hits."
+	    print "Refine your search."
+	    for i in parser.targets:
+	        print i
+	
+	elif len(parser.targets) == 1:
+	    print "Found: " + parser.targets[0]
+	    url += "/" + parser.targets[0]
+	
+	    if localFile is None:
+	        if os.path.exists(parser.targets[0]): 
+	            print "File " + parser.targets[0] + " already exists and will not be downloaded..."
+	        else:
+	            urllib.urlretrieve(url, parser.targets[0])
+	            print "File saved as: " + parser.targets[0]
+	    else:
+	        if os.path.exists(localFile): 
+	            print "File "+ localFile +" already exists and will not be downloaded..."
+	        else:
+	            if parser.targets[0] == localFile:
+	                print "File found and destination match."
+	            elif parser.matcher.match(localFile) != "None":
+	                print "File found matches destination pattern."
+	            else:
+	                print "WARNING: the file found \'" + parser.targets[0] + "\' does not match \'" + localFile + "\'"
+	                print "Ensure the downloaded version is suitable."
+	
+	            urllib.urlretrieve(url, localFile)
+	            print "File saved as: " + localFile
+	
+	else:
+	    print "No matches found!"
+	
+	obj.close()
+# End 'main' function. }}}
 
-# Separates the URL into a directory and the file or pattern based on the
-# last appearance of '/'.
-if len(sys.argv) > 1:
-    pivot = sys.argv[1].rfind("/")
-    url = (sys.argv[1])[:pivot]
-    pivot += 1
-    find = (sys.argv[1])[pivot:]
-else:
-    print "******************************************************************************************************************************"
-    print "* Invalid input!                                                                                                             *"
-    print "*                                                                                                                            *"
-    print "* Try: 'DownloadExternalPackage.py url [localFile]'                                                                          *"
-    print "*                                                                                                                            *"
-    print "* Where 'URL' is the URL with an explicit package name or the URL followed by the truncated package name. And 'localFile' is *"
-    print "* the file name (including extension) that you would like to save as.                                                        *"
-    print "*                                                                                                                            *"
-    print "* Examples:                                                                                                                  *" 
-    print "*                                                                                                                            *"
-    print "* DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/petsc-2.3.2-p3.tar.gz' 'petsc-2.3.2-p3.tar.gz' *"
-    print "*                                                                                                                            *"
-    print "*     This is the old style and the safest way to download a package.                                                        *"
-    print "*                                                                                                                            *"
-    print "* DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/libtool' 'libtool.tar.gz'                      *"
-    print "*                                                                                                                            *"
-    print "*     This is the new style. For packages like 'Libtool', which we never expect to be using multiple versions, this will     *"
-    print "*     download the most recent version and save it as the generic 'libtool.tar.gz'.                                          *"
-    print "*                                                                                                                            *"
-    print "* DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/gsl-1.' 'gsl-1.15.tar.gz'                      *"
-    print "*                                                                                                                            *"
-    print "*     This is the new style. This is a demonstration of how this script can be used to disambiguate a package name if there  *"
-    print "*     are more than once package matching 'gsl-'.                                                                            *"
-    print "*                                                                                                                            *"
-    print "* DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/libtool'                                       *"
-    print "*                                                                                                                            *"
-    print "*     This is the new style. This will download a package with 'libtool' as a prefix and save it as its canonical name.      *"
-    print "*                                                                                                                            *"
-    print "*                                                                                                                            *"
-    print "******************************************************************************************************************************"
-
-if len(sys.argv) > 2:
-    localFile=sys.argv[2]
-    print "Downloaded file will saved as: " + localFile
-else:
-    localFile = None
-    print "Downloaded file will saved with the same file name."
-
-
-print "Looking for " + find
-
-# As an extra precaution, if no extension is given for a particular package
-# such as '.../libtool', then ensure that files found are of appropriate
-# file extensions. 
-#
-# WARNING: The external packages directory includes executable binaries with
-# '.exe' extensions. As such, '.exe' is an acceptable suffix, but this is 
-# inherently dangerous since this script can be used to download from any
-# valid website. Furthermore, if an individual attempts a "man-in-the-middle"  
-# attack, then the user would be capable of downloading executables from 
-# an untrusted source.
-pattern = find + "[\w.-]*(\.tar\.gz|tar\.gz2|tgz|zip|exe)?"
-parser = MyHTMLParser(pattern)
-
-# Creates a 'FancyURL' which allows the script to fail gracefully by catching
-# HTTP error codes 30X and several 40X(where 'X' is a natural number).
-urlObject = FancyURLopener()
-obj = urlObject.open(url)
-parser.feed(obj.read())
-
-# If a file pattern was used to describe the file that should be downloaded,
-# then there is the potential for multiple file matches. Currently, the script
-# will detect this ambiguity and print out all the matches, while informing 
-# the user that he must refine his search.
-#
-# TODO: Prompt the user to select from a list his/her preferred target.
-if len(parser.targets) > 1:
-    print "Could not resolve your download due to the number of hits."
-    print "Refine your search."
-    for i in parser.targets:
-        print i
-
-elif len(parser.targets) == 1:
-    print "Found: " + parser.targets[0]
-    url += "/" + parser.targets[0]
-
-    if localFile is None:
-        if os.path.exists(parser.targets[0]): 
-            print "File " + parser.targets[0] + " already exists and will not be downloaded..."
-        else:
-            urllib.urlretrieve(url, parser.targets[0])
-            print "File saved as: " + parser.targets[0]
-    else:
-        if os.path.exists(localFile): 
-            print "File "+ localFile +" already exists and will not be downloaded..."
-        else:
-            if parser.targets[0] == localFile:
-                print "File found and destination match."
-            elif parser.matcher.match(localFile) != "None":
-                print "File found matches destination pattern."
-            else:
-                print "WARNING: the file found \'" + parser.targets[0] + "\' does not match \'" + localFile + "\'"
-                print "Ensure the downloaded version is suitable."
-
-            urllib.urlretrieve(url, localFile)
-            print "File saved as: " + localFile
-
-else:
-    print "No matches found!"
-
-obj.close()
+if __name__ == "__main__":
+    main()
Index: /issm/trunk/src/CMakeLists.txt
===================================================================
--- /issm/trunk/src/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,8 @@
+# Subdirectories {{{
+add_subdirectory(c)
+#add_subdirectory(m)
+#add_subdirectory(wrappers)
+#Android Dir {{{
+# add_subdirectory(android)
+#}}}
+# }}}
Index: /issm/trunk/src/android/ISSM/AndroidManifest.xml
===================================================================
--- /issm/trunk/src/android/ISSM/AndroidManifest.xml	(revision 14309)
+++ /issm/trunk/src/android/ISSM/AndroidManifest.xml	(revision 14310)
@@ -2,6 +2,6 @@
     package="com.example.issm"
     android:versionCode="1"
-    android:versionName="1.0" >
-
+    android:versionName="1.0"
+    android:installLocation="preferExternal" >
     <uses-sdk
         android:minSdkVersion="10"
@@ -12,5 +12,5 @@
         android:label="@string/app_name"
         android:theme="@style/AppTheme" >
-        <activity android:name=".MapSelection"
+        <activity android:name="com.example.issm.SplashScreen"
             	  android:label="@string/title_activity_issm" >
             <intent-filter>
@@ -20,4 +20,8 @@
             </activity>
             <activity
+            android:name=".MenuPage"
+            android:label="@string/title_activity_issm" >
+        </activity>
+            <activity
             android:name=".ISSM"
             android:label="@string/title_activity_issm" >
Index: /issm/trunk/src/android/ISSM/Makefile.am
===================================================================
--- /issm/trunk/src/android/ISSM/Makefile.am	(revision 14309)
+++ /issm/trunk/src/android/ISSM/Makefile.am	(revision 14310)
@@ -5,5 +5,5 @@
 deps = 	 	 
 else 	 	 
-deps = ../../c/libISSMCore.a 	 	 
+deps = $(ISSM_DIR)/src/c/libISSMCore.a ./jni/Main.cpp
 endif
 
@@ -14,2 +14,5 @@
 	$(ANDROID_NDK_DIR)/ndk-build -C ./jni clean
 	$(ANDROID_NDK_DIR)/ndk-build -C ./jni
+
+clean:
+	rm -rf libs obj
Index: /issm/trunk/src/android/ISSM/assets/Map/antarctica.petsc
===================================================================
--- /issm/trunk/src/android/ISSM/assets/Map/antarctica.petsc	(revision 14310)
+++ /issm/trunk/src/android/ISSM/assets/Map/antarctica.petsc	(revision 14310)
@@ -0,0 +1,19 @@
+%Petsc options file: SeaRISEgreenland.petsc written from Matlab solver array
+
++NoneAnalysis
+-mat_type aij
+-ksp_type gmres
+-pc_type asm
+-sub_pc_type ilu
+-pc_asm_overlap 5
+-ksp_max_it 100
+-ksp_rtol 1e-15
+
++DiagnosticVertAnalysis
+-mat_type aij
+-ksp_type gmres
+-pc_type asm
+-sub_pc_type ilu
+-pc_asm_overlap 5
+-ksp_max_it 100
+-ksp_rtol 1e-15
Index: /issm/trunk/src/android/ISSM/assets/Map/greenland.petsc
===================================================================
--- /issm/trunk/src/android/ISSM/assets/Map/greenland.petsc	(revision 14310)
+++ /issm/trunk/src/android/ISSM/assets/Map/greenland.petsc	(revision 14310)
@@ -0,0 +1,19 @@
+%Petsc options file: SeaRISEgreenland.petsc written from Matlab solver array
+
++NoneAnalysis
+-mat_type aij
+-ksp_type gmres
+-pc_type asm
+-sub_pc_type ilu
+-pc_asm_overlap 5
+-ksp_max_it 100
+-ksp_rtol 1e-15
+
++DiagnosticVertAnalysis
+-mat_type aij
+-ksp_type gmres
+-pc_type asm
+-sub_pc_type ilu
+-pc_asm_overlap 5
+-ksp_max_it 100
+-ksp_rtol 1e-15
Index: /issm/trunk/src/android/ISSM/bin/AndroidManifest.xml
===================================================================
--- /issm/trunk/src/android/ISSM/bin/AndroidManifest.xml	(revision 14309)
+++ /issm/trunk/src/android/ISSM/bin/AndroidManifest.xml	(revision 14310)
@@ -2,6 +2,6 @@
     package="com.example.issm"
     android:versionCode="1"
-    android:versionName="1.0" >
-
+    android:versionName="1.0"
+    android:installLocation="preferExternal" >
     <uses-sdk
         android:minSdkVersion="10"
@@ -12,5 +12,5 @@
         android:label="@string/app_name"
         android:theme="@style/AppTheme" >
-        <activity android:name=".MapSelection"
+        <activity android:name="com.example.issm.SplashScreen"
             	  android:label="@string/title_activity_issm" >
             <intent-filter>
@@ -20,4 +20,8 @@
             </activity>
             <activity
+            android:name=".MenuPage"
+            android:label="@string/title_activity_issm" >
+        </activity>
+            <activity
             android:name=".ISSM"
             android:label="@string/title_activity_issm" >
Index: /issm/trunk/src/android/ISSM/jni/Android.mk
===================================================================
--- /issm/trunk/src/android/ISSM/jni/Android.mk	(revision 14309)
+++ /issm/trunk/src/android/ISSM/jni/Android.mk	(revision 14310)
@@ -2,7 +2,5 @@
 my_LOCAL_PATH:=$(LOCAL_PATH)
 
-#include $(LOCAL_PATH)/issmlib\Android.mk
 include $(call all-subdir-makefiles)
-
 
 LOCAL_PATH := $(my_LOCAL_PATH)
@@ -12,8 +10,7 @@
 LOCAL_ALLOW_UNDEFINED_SYMBOLS := true
 LOCAL_CFLAGS := -Wno-psabi -DHAVE_CONFIG_H
-LOCAL_LDLIBS := -llog -ldl
+LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -llog -ldl -lm
 LOCAL_MODULE := IssmJni
 LOCAL_SRC_FILES := Main.cpp 
-LOCAL_STATIC_LIBRARIES := libISSMCore
-
+LOCAL_STATIC_LIBRARIES := libISSMCore libgsl libgslcblas
 include $(BUILD_SHARED_LIBRARY)
Index: /issm/trunk/src/android/ISSM/jni/Application.mk
===================================================================
--- /issm/trunk/src/android/ISSM/jni/Application.mk	(revision 14309)
+++ /issm/trunk/src/android/ISSM/jni/Application.mk	(revision 14310)
@@ -1,3 +1,4 @@
-APP_STL:=stlport_static
+APP_STL:= gnustl_static
 APP_CPPFLAGS := -frtti
 APP_CPPFLAGS += -fexceptions
+APP_ABI := armeabi
Index: /issm/trunk/src/android/ISSM/jni/Main.cpp
===================================================================
--- /issm/trunk/src/android/ISSM/jni/Main.cpp	(revision 14309)
+++ /issm/trunk/src/android/ISSM/jni/Main.cpp	(revision 14310)
@@ -1,58 +1,167 @@
 #include <jni.h>
-#include "../../../c/android/fac.h"
+#include <android/log.h>
 #include "../../../c/issm.h"
 #include <cstddef>
 #include <stdio.h>
-///////////////////////////////////////////////////////////////////////////////////////////
+#include <android/log.h>
+
 namespace com_example_issm
 {
-	fac* f;
+	/*Global variables{{{*/
 	FemModel *fm;
-//------------------------------------------------------------------------------------
-	jint initilize(JNIEnv *env, jclass clazz, jstring file)
+	double* xyz; /*keep vertices information here*/
+	/*}}}*/
+	jint Initialize(JNIEnv *env, jclass clazz, jstring jsolution_type, jstring jabsfile, jstring jrelfile) /*{{{*/
 	{
-		char *nativefile = (char*)env->GetStringUTFChars(file,0);
+		
+		/*arguments to constructor: */
+		int argc; //arguments to constructor.
+		char** argv = NULL;
+		COMM    communicator = 1; //fake communicator for constructor
+		const char* issmname = "issm.exe";
+		char *solution_type = NULL;
+		char *absfile = NULL;
+		char *relfile = NULL;
 
-		f = new fac();
+		/*log:*/
+		__android_log_print(ANDROID_LOG_INFO, "Native","Initializing FemModel");
 
-		//call Model constructor passing in infile as File Descriptor parameter.
-		fm  = new FemModel(nativefile);
+		/*retrieve from java machine: */
+		solution_type = (char*)env->GetStringUTFChars(jsolution_type,0);
+		absfile = (char*)env->GetStringUTFChars(jabsfile,0);
+		relfile = (char*)env->GetStringUTFChars(jrelfile,0);
 
-		env->ReleaseStringUTFChars(file, nativefile); //must realease the char*
-		//jint size = (jint) fm->bufferSize();
-		//return size;
+		/*creat arguments to call constructor for FemModel: */
+		argc=4; 
+		argv=(char**)malloc(argc*sizeof(char*));
+		argv[0]=(char*)issmname;
+		argv[1]=solution_type;
+		argv[2]=absfile;
+		argv[3]=relfile;
+		
+		/*call Model constructor passing in infile as File Descriptor parameter.*/
+		fm  = new FemModel(argc,argv,communicator);
 
-		return 0; //return 0 for now.
+		/*release strings: */
+		env->ReleaseStringUTFChars(jsolution_type, solution_type); //must realease the char*
+		env->ReleaseStringUTFChars(jabsfile, absfile); //must realease the char*
+		env->ReleaseStringUTFChars(jrelfile, relfile); //must realease the char*
+
+		/*figure out size of solution: */
+		__android_log_print(ANDROID_LOG_INFO, "Native","Number of elements");
+		jint size = (jint) fm->elements->NumberOfElements();
+
+		/*retrieve vertices x,y and z coordinates: */
+		__android_log_print(ANDROID_LOG_INFO, "Native","Retrieving vertices");
+		xyz=fm->vertices->ToXYZ();
+		
+		/*log: */
+		__android_log_print(ANDROID_LOG_INFO, "Native","Done Initializing FemModel");
+
+		return size;
+
 	}
-//------------------------------------------------------------------------------------
-	//fill out the first two slots, extract the same way in java using get(int position)
-	void solve(JNIEnv *env, jclass clazz , jint alpha, jobject buf)
-	{
+	/*}}}*/
+	void Solve(JNIEnv *env, jclass clazz , jdouble alpha, jobject buf){ /*{{{*/
+
+		int i,count;
+		double x1,y1,z1,vel1;
+		double x2,y2,z2,vel2;
+		double x3,y3,z3,vel3;
+		int    v1,v2,v3,eid;
+		Patch* patch=NULL;
+		
+		/*log:*/
+		__android_log_print(ANDROID_LOG_INFO, "Native","Solving ");
+
+		/*retrieve buffer: */
 		jdouble *dBuf = (jdouble *)env->GetDirectBufferAddress(buf);
 
-		//pass bBuff to fem model to allocate data
-		// fm -> solve(dBuf, alpha);
+		/*reset basal friction to what it was before: */
+		__android_log_print(ANDROID_LOG_INFO, "Native","alpha %g ",alpha);
+		InputDuplicatex(fm->elements,fm->nodes,fm->vertices,fm->loads,fm->materials,fm->parameters,AndroidFrictionCoefficientEnum,FrictionCoefficientEnum);
 
-	}
-//------------------------------------------------------------------------------------
-	jlong factorial(JNIEnv *env, jclass clazz, jlong n)
+		/*now scale friction by alpha: */
+		InputScalex(fm->elements,fm->nodes,fm->vertices,fm->loads,fm->materials,fm->parameters,FrictionCoefficientEnum,alpha/100);
+
+		/*solve: */
+		fm -> Solve();
+
+		/*retrieve results: */
+		__android_log_print(ANDROID_LOG_INFO, "Native","Retrieving results ");
+		patch=fm->elements->ResultsToPatch();
+
+		/*sort out the velocities: */
+		for(i=0;i<patch->numrows;i++){
+			if ((patch->values[i*patch->numcols+0])==VelEnum){
+
+				/*Each row of the Patch object is made of the following information: 
+				  - the result enum_type, 
+				  - the step and time, 
+				  - the id of the element, 
+				  - the interpolation type, 
+				  - the vertices ids, 
+				  - and the values at the nodes (could be different from the vertices)
+				*/
+				eid=(int)patch->values[i*patch->numcols+3]-1;
+				v1=(int)patch->values[i*patch->numcols+5]; 
+				x1=xyz[3*(v1-1)+0]; y1=xyz[3*(v1-1)+1]; z1=xyz[3*(v1-1)+2];
+				
+				v2=(int)patch->values[i*patch->numcols+6];
+				x2=xyz[3*(v2-1)+0]; y2=xyz[3*(v2-1)+1]; z2=xyz[3*(v2-1)+2];
+				
+				v3=(int)patch->values[i*patch->numcols+7];
+				x3=xyz[3*(v3-1)+0]; y3=xyz[3*(v3-1)+1]; z3=xyz[3*(v3-1)+2];
+
+				vel1=patch->values[i*patch->numcols+8]; 
+				vel2=patch->values[i*patch->numcols+9]; 
+				vel3=patch->values[i*patch->numcols+10]; 
+
+				/*plug into dBuf: */
+				/*vertex 1: */
+				dBuf[12*eid+0]=x1;
+				dBuf[12*eid+1]=y1;
+				dBuf[12*eid+2]=z1;
+
+				/*vertex 2: */
+				dBuf[12*eid+3]=x2;
+				dBuf[12*eid+4]=y2;
+				dBuf[12*eid+5]=z2;
+			
+				/*vertex 3: */
+				dBuf[12*eid+6]=x3;
+				dBuf[12*eid+7]=y3;
+				dBuf[12*eid+8]=z3;
+				
+				/*values at 3 vertices: */
+				dBuf[12*eid+9]=vel1;
+				dBuf[12*eid+10]=vel2;
+				dBuf[12*eid+11]=vel3;
+
+			}
+		}
+
+		/*for(i=0;i<148;i++){
+		__android_log_print(ANDROID_LOG_INFO, "Native","%g %g %g | %g %g %g | %g %g %g | %g %g %g\n",
+				dBuf[12*i+0],dBuf[12*i+1],dBuf[12*i+2],
+				dBuf[12*i+3],dBuf[12*i+4],dBuf[12*i+5],
+				dBuf[12*i+6],dBuf[12*i+7],dBuf[12*i+8],
+				dBuf[12*i+9],dBuf[12*i+10],dBuf[12*i+11]);
+		}*/
+
+		/*delete temporary data:*/
+		delete patch;
+
+	}/*}}}*/
+	static JNINativeMethod method_table[] = /*{{{*/
 	{
-		if( f != NULL)
-			return (jlong) (f->factorial(n));
-		return 0;
-	}
+			{"createISSMModel"   ,"(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)I"  , (void *) Initialize},
+			{"solveISSMModel", "(DLjava/nio/DoubleBuffer;)V", (void *) Solve}
+	};
+	/*}}}*/
+}
 
-//------------------------------------------------------------------------------------
-	static JNINativeMethod method_table[] =
-	{
-			{"fac"      	,     "(J)J" 	, (void *) factorial},
-			{"createISSMModel"   ,"(Ljava/lang/String;)I"  , (void *) initilize},
-			{"processBuffer", "(ILjava/nio/DoubleBuffer;)V", (void *) solve}
-	};
-}
-//------------------------------------------------------------------------------------
 using namespace com_example_issm;
-
-extern "C" jint JNI_OnLoad(JavaVM* vm, void* reserved)
+extern "C" jint JNI_OnLoad(JavaVM* vm, void* reserved) /*{{{*/
 {
     JNIEnv* env;
@@ -72,3 +181,3 @@
     }
 }
-///////////////////////////////////////////////////////////////////////////////////////////
+/*}}}*/
Index: /issm/trunk/src/android/ISSM/jni/gsllib/Android.mk
===================================================================
--- /issm/trunk/src/android/ISSM/jni/gsllib/Android.mk	(revision 14310)
+++ /issm/trunk/src/android/ISSM/jni/gsllib/Android.mk	(revision 14310)
@@ -0,0 +1,13 @@
+LOCAL_PATH:= $(call my-dir)
+my_directory:= $(LOCAL_PATH)
+include $(CLEAR_VARS)
+LOCAL_MODULE    := libgsl
+LOCAL_SRC_FILES := ../../../../../externalpackages/gsl/install/lib/libgsl.a
+LOCAL_EXPORT_C_INCLUDES := $(ISSM_DIR)/externalpackages/gsl/install/include/gsl/
+include $(PREBUILT_STATIC_LIBRARY)
+
+LOCAL_PATH=$(my_directory)
+include $(CLEAR_VARS)
+LOCAL_MODULE    := libgslcblas
+LOCAL_SRC_FILES := ../../../../../externalpackages/gsl/install/lib/libgslcblas.a
+include $(PREBUILT_STATIC_LIBRARY)
Index: /issm/trunk/src/android/ISSM/jni/issmlib/Android.mk
===================================================================
--- /issm/trunk/src/android/ISSM/jni/issmlib/Android.mk	(revision 14309)
+++ /issm/trunk/src/android/ISSM/jni/issmlib/Android.mk	(revision 14310)
@@ -2,5 +2,7 @@
 include $(CLEAR_VARS)
 LOCAL_MODULE    := libISSMCore
-LOCAL_SRC_FILES := libISSMCore.a
+LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -llog 
+LOCAL_SRC_FILES := ../../../../../lib/libISSMCore.a
 LOCAL_EXPORT_C_INCLUDES := $(ISSM_DIR)
 include $(PREBUILT_STATIC_LIBRARY)
+
Index: /issm/trunk/src/android/ISSM/project.properties
===================================================================
--- /issm/trunk/src/android/ISSM/project.properties	(revision 14309)
+++ /issm/trunk/src/android/ISSM/project.properties	(revision 14310)
@@ -12,3 +12,3 @@
 
 # Project target.
-target=android-15
+target=android-16
Index: /issm/trunk/src/android/ISSM/res/anim/alpha.xml
===================================================================
--- /issm/trunk/src/android/ISSM/res/anim/alpha.xml	(revision 14310)
+++ /issm/trunk/src/android/ISSM/res/anim/alpha.xml	(revision 14310)
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<alpha
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:fromAlpha="0.0"
+    android:toAlpha="1.0"
+    android:duration="3000" />
Index: /issm/trunk/src/android/ISSM/res/anim/translate.xml
===================================================================
--- /issm/trunk/src/android/ISSM/res/anim/translate.xml	(revision 14310)
+++ /issm/trunk/src/android/ISSM/res/anim/translate.xml	(revision 14310)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8"?>
+<set
+    xmlns:android="http://schemas.android.com/apk/res/android">
+ 
+<translate
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:fromXDelta="0%"
+    android:toXDelta="0%"
+    android:fromYDelta="200%"
+    android:toYDelta="0%"
+    android:duration="2000"
+    android:zAdjustment="top" />
+ 
+</set>
Index: sm/trunk/src/android/ISSM/res/layout/activity_issm.xml
===================================================================
--- /issm/trunk/src/android/ISSM/res/layout/activity_issm.xml	(revision 14309)
+++ 	(revision )
@@ -1,33 +1,0 @@
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:tools="http://schemas.android.com/tools"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent" >
-
-    <EditText
-        android:id="@+id/input"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:layout_alignParentLeft="true"
-        android:ems="10"
-        android:inputType="number" />
-
-    <Button
-        android:id="@+id/button1"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:layout_alignRight="@+id/input"
-        android:layout_below="@+id/input"
-        android:layout_marginRight="46dp"
-        android:layout_marginTop="23dp"
-        android:text="calculate" />
-
-    <TextView
-        android:id="@+id/output"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:layout_alignParentLeft="true"
-        android:layout_below="@+id/button1"
-        android:layout_marginTop="39dp"
-        android:textSize="20sp" />
-
-</RelativeLayout>
Index: sm/trunk/src/android/ISSM/res/layout/activity_mapselection.xml
===================================================================
--- /issm/trunk/src/android/ISSM/res/layout/activity_mapselection.xml	(revision 14309)
+++ 	(revision )
@@ -1,27 +1,0 @@
-
-    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
-        android:layout_width="fill_parent"
-        android:layout_height="fill_parent" >
-
-        <Button
-            android:id="@+id/button1"
-            style="@layout/activity_mapselection"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_alignParentLeft="true"
-            android:layout_alignParentTop="true"
-            android:layout_marginLeft="63dp"
-            android:layout_marginTop="97dp"
-            android:text="Greenland" />
-
-        <Button
-            android:id="@+id/button2"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_alignBaseline="@+id/button1"
-            android:layout_alignBottom="@+id/button1"
-            android:layout_marginLeft="64dp"
-            android:layout_toRightOf="@+id/button1"
-            android:text="Antarctica" />
-
-    </RelativeLayout>
Index: /issm/trunk/src/android/ISSM/res/layout/issmcore.xml
===================================================================
--- /issm/trunk/src/android/ISSM/res/layout/issmcore.xml	(revision 14310)
+++ /issm/trunk/src/android/ISSM/res/layout/issmcore.xml	(revision 14310)
@@ -0,0 +1,73 @@
+<RelativeLayout 
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:id="@+id/relativeLay"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:orientation="horizontal"
+    android:background="@drawable/background" >
+      <TextView
+        android:id="@+id/friction"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_alignParentLeft="true"
+        android:layout_alignParentTop="true"
+        android:textSize="15sp"
+        android:typeface="serif"
+        android:textColor="#f49956"
+        android:text="Friction" />
+      
+      <TextView
+        android:id="@+id/value"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_alignParentLeft="true"
+        android:layout_below="@+id/friction"
+        android:typeface="serif"
+        android:textColor="#FF0000"
+        android:text="100%" />
+
+    <com.example.issm.VerticalSeekBar
+        android:id="@+id/seekbar"
+        android:layout_width="wrap_content"
+        android:layout_height="300dp"
+        android:layout_above="@+id/back"
+        android:layout_marginBottom="50dp"
+        android:max="490"
+        android:progress="100"
+        android:progressDrawable="@layout/seekbar_progress"
+        android:thumb="@drawable/thumb" />
+      
+    <FrameLayout
+        android:id="@+id/frame"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_above="@+id/solve"
+        android:layout_below="@+id/value"
+        android:layout_marginLeft="30dp"
+        android:layout_marginBottom="12dp" >
+    </FrameLayout>
+    
+
+    <Button
+        android:id="@+id/back"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_alignParentBottom="true"
+        android:layout_alignParentLeft="true"
+        android:layout_marginBottom="17dp"
+        android:background="@drawable/btn_lightblue_glossy"
+        android:text="Back"/>
+
+    <Button
+        android:id="@+id/solve"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_alignBaseline="@+id/back"
+        android:layout_alignBottom="@+id/back"
+        android:layout_marginLeft="14dp"
+        android:layout_toRightOf="@+id/back"
+        android:background="@drawable/btn_lightblue_glossy"
+        android:text="Solve"/>
+
+</RelativeLayout>
Index: /issm/trunk/src/android/ISSM/res/layout/issmmapselection.xml
===================================================================
--- /issm/trunk/src/android/ISSM/res/layout/issmmapselection.xml	(revision 14310)
+++ /issm/trunk/src/android/ISSM/res/layout/issmmapselection.xml	(revision 14310)
@@ -0,0 +1,32 @@
+
+    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+        android:layout_width="fill_parent"
+        android:layout_height="fill_parent"
+	android:background="@drawable/background" >
+
+        <ImageButton
+            android:id="@+id/greenland"
+            android:layout_width="150dip"
+            android:layout_height="150dip"
+            android:layout_alignParentTop="true"
+            android:layout_centerHorizontal="true"
+            android:layout_marginTop="42dp"
+            android:background="@drawable/greenland" />
+
+		<View
+		    android:layout_width="wrap_content"
+		    android:layout_height="2dip"
+		    android:layout_marginTop="70dip"
+		    android:layout_below="@+id/greenland"
+		    android:background="#DDFFDD" />
+		
+        <ImageButton
+            android:id="@+id/antarctica"
+            android:layout_width="150dip"
+            android:layout_height="150dip"
+            android:layout_alignLeft="@+id/greenland"
+            android:layout_alignParentBottom="true"
+            android:layout_marginBottom="42dp"
+            android:background="@drawable/antarctica" />
+
+           </RelativeLayout>
Index: /issm/trunk/src/android/ISSM/res/layout/main_issm.xml
===================================================================
--- /issm/trunk/src/android/ISSM/res/layout/main_issm.xml	(revision 14310)
+++ /issm/trunk/src/android/ISSM/res/layout/main_issm.xml	(revision 14310)
@@ -0,0 +1,9 @@
+	<ViewFlipper
+	        xmlns:android="http://schemas.android.com/apk/res/android"
+			android:id="@+id/flipper"
+			android:layout_width="fill_parent"
+			android:layout_height="fill_parent"	>
+	<include android:id="@+id/first"  layout="@layout/issmmapselection" />
+	<include android:id="@+id/second"  layout="@layout/issmcore" />
+	</ViewFlipper>
+
Index: /issm/trunk/src/android/ISSM/res/layout/menupage.xml
===================================================================
--- /issm/trunk/src/android/ISSM/res/layout/menupage.xml	(revision 14310)
+++ /issm/trunk/src/android/ISSM/res/layout/menupage.xml	(revision 14310)
@@ -0,0 +1,51 @@
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+        android:layout_width="fill_parent"
+        android:layout_height="fill_parent"
+        android:background="@drawable/background" >
+
+        <ImageButton
+            android:id="@+id/start"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_alignParentLeft="true"
+            android:layout_alignParentTop="true"
+            android:layout_marginLeft="19dp"
+            android:layout_marginTop="107dp"
+            android:background="@null"
+            android:src="@drawable/start" />
+        
+        <ImageButton
+            android:id="@+id/video"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_alignParentRight="true"
+            android:layout_alignParentTop="true"
+            android:layout_marginRight="19dp"
+            android:layout_marginTop="107dp"
+            android:background="@null"
+            android:src="@drawable/video" />
+        
+        <ImageButton
+            android:id="@+id/intro"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_below="@+id/start"
+            android:layout_marginLeft="19dp"
+            android:layout_marginTop="107dp"
+            android:background="@null"
+            android:src="@drawable/intro" />
+        
+        <ImageButton
+            android:id="@+id/visitus"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_below="@+id/video"
+             android:layout_alignParentRight="true"
+            android:layout_marginRight="19dp"
+            android:layout_marginTop="107dp"
+            android:background="@null"
+            android:src="@drawable/visitus" />
+        
+ 
+
+    </RelativeLayout>
Index: /issm/trunk/src/android/ISSM/res/layout/popuptext.xml
===================================================================
--- /issm/trunk/src/android/ISSM/res/layout/popuptext.xml	(revision 14310)
+++ /issm/trunk/src/android/ISSM/res/layout/popuptext.xml	(revision 14310)
@@ -0,0 +1,39 @@
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="fill_parent"
+    android:layout_height="fill_parent"
+    android:orientation="vertical" 
+    android:background="@android:color/background_light">
+     <ScrollView android:layout_width="fill_parent"
+    	android:layout_height="0dip" 
+    	android:layout_weight="1">
+    	 <LinearLayout 
+		     android:layout_width="wrap_content"
+		     android:layout_height="wrap_content"
+		     android:orientation="vertical" 
+		     android:layout_margin="1dp">
+	    		<TextView
+		          android:background="#07000000"
+		          android:id="@+id/header"
+		          android:layout_width="wrap_content"
+				  android:layout_height="wrap_content"
+				  android:gravity="center"	
+				  android:textStyle="bold" 
+				  android:textSize="20sp"
+		          android:text="\tWelcome to the Ice Sheet System Model (ISSM)." >
+		      </TextView>
+		      <TextView
+		          android:background="#07000000"
+		          android:id="@+id/infotext"
+		          android:layout_width="wrap_content"
+				  android:layout_height="wrap_content"	 
+		          android:text="\tISSM is the result of a collaboration between the Jet Propulsion Laboratory and University of California at Irvine. Its purpose is to tackle the challenge of modeling the evolution of the polar ice caps in Greenland and Antarctica. \n\tISSM is funded by the NASA Cryosphere and MAP (Modeling Analysis and Prediction) programs, JPL R&amp;TD(Research, Technology and Development) and the National Science Foundation. Our main collaborators are:MSSMat Laboratory of École Centrale Paris, Argonne National Laboratory and the Department of Geology of University of Buffalo, NY.\n\tAs synthesized in the last Intergovernmental Panel on Climate Change (IPCC) Assessment Report AR4,future changes in the Greenland and Antarctic ice sheet mass, particularly due to changes in ice flow,are a major source of uncertainty that could increase sea level rise projections.\n\tTo remedy this problem, large scale ice flow models are necessary that can accurately model the evolution of Greenland and Antarctica in a warming climate. In order to achieve this goal,and improve projections of future sea level rise, ISSM relies on state of the art technologies,developed in synergy with the Research and Technology Development (R&amp;TD) at JPL." >
+			  </TextView>
+		</LinearLayout>
+	</ScrollView>
+		      <Button
+		          android:id="@+id/dismiss"
+		          android:layout_width="fill_parent"
+		          android:layout_height="wrap_content"
+		          android:text="Dismiss" >
+		      </Button>
+</LinearLayout>
Index: /issm/trunk/src/android/ISSM/res/layout/seekbar_progress.xml
===================================================================
--- /issm/trunk/src/android/ISSM/res/layout/seekbar_progress.xml	(revision 14310)
+++ /issm/trunk/src/android/ISSM/res/layout/seekbar_progress.xml	(revision 14310)
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:id="@android:id/background">
+        <nine-patch
+            xmlns:android="http://schemas.android.com/apk/res/android"
+            android:src="@drawable/seek_bg"
+            android:dither="true"
+         />
+    </item>
+    <item android:id="@android:id/secondaryProgress">
+        <clip>
+            <shape>
+                <gradient
+                    android:startColor="#80028ac8"
+                    android:centerColor="#80127fb1"
+                    android:centerY="0.75"
+                    android:endColor="#a004638f"
+                    android:angle="270"
+                />
+            </shape>
+        </clip>
+    </item>
+    <item
+        android:id="@android:id/progress"
+        android:drawable="@layout/seekbar_progress_bg"
+    />
+</layer-list>
Index: /issm/trunk/src/android/ISSM/res/layout/seekbar_progress_bg.xml
===================================================================
--- /issm/trunk/src/android/ISSM/res/layout/seekbar_progress_bg.xml	(revision 14310)
+++ /issm/trunk/src/android/ISSM/res/layout/seekbar_progress_bg.xml	(revision 14310)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8"?>
+ <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
+    <item>
+        <clip>
+        <bitmap xmlns:android="http://schemas.android.com/apk/res/android"
+            android:src="@drawable/blue" 	
+            android:antialias="true"
+            android:dither="false"
+            android:filter="false"
+            android:gravity="left"
+        />
+        </clip>
+    </item>
+</layer-list>
Index: /issm/trunk/src/android/ISSM/res/layout/splashscreen.xml
===================================================================
--- /issm/trunk/src/android/ISSM/res/layout/splashscreen.xml	(revision 14310)
+++ /issm/trunk/src/android/ISSM/res/layout/splashscreen.xml	(revision 14310)
@@ -0,0 +1,16 @@
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="fill_parent"
+    android:layout_height="fill_parent"
+    android:background="@drawable/background"
+    android:layout_gravity="center"
+     android:id="@+id/lin_lay"
+    android:gravity="center"
+    android:orientation="vertical" >
+ 
+    <ImageView
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:id="@+id/logo"
+        android:background="@drawable/issm_logo" />
+ 
+</LinearLayout>
Index: /issm/trunk/src/android/ISSM/res/menu/issm_menu.xml
===================================================================
--- /issm/trunk/src/android/ISSM/res/menu/issm_menu.xml	(revision 14310)
+++ /issm/trunk/src/android/ISSM/res/menu/issm_menu.xml	(revision 14310)
@@ -0,0 +1,36 @@
+    <menu xmlns:android="http://schemas.android.com/apk/res/android">
+        <item android:id="@+id/menu_color"
+          android:icon="@drawable/ic_color"
+          android:title="Color" >
+          <menu>
+          	<item android:id="@+id/cl_hsv"
+          	      android:title="HSV" />
+          	<item android:id="@+id/cl_autumn"
+          	      android:title="Autumn" />
+          	<item android:id="@+id/cl_bone"
+          	      android:title="Bone" />                
+          	<item android:id="@+id/cl_cool"
+          	      android:title="Cool" />
+          	<item android:id="@+id/cl_copper"
+          	      android:title="Copper" />
+          	<item android:id="@+id/cl_gray"
+          	      android:title="Gray" />
+          	<item android:id="@+id/cl_hot"
+          	      android:title="Hot" />
+          	<item android:id="@+id/cl_jet"
+          	      android:title="Jet" />
+          	<item android:id="@+id/cl_pink"
+          	      android:title="Pink" />
+          	<item android:id="@+id/cl_spring"
+          	      android:title="Spring" />
+          	<item android:id="@+id/cl_winter"
+          	      android:title="Winter" />
+          	<item android:id="@+id/cl_summer"
+          	      android:title="Summer" />                                                      
+          </menu>
+     </item>   
+ 
+    	<item android:id="@+id/menu_about"
+          android:icon="@drawable/ic_about"
+          android:title="About" />
+    	</menu>
Index: /issm/trunk/src/android/ISSM/src/com/example/issm/ColorBar.java
===================================================================
--- /issm/trunk/src/android/ISSM/src/com/example/issm/ColorBar.java	(revision 14310)
+++ /issm/trunk/src/android/ISSM/src/com/example/issm/ColorBar.java	(revision 14310)
@@ -0,0 +1,94 @@
+package com.example.issm;
+
+import android.content.Context;
+import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.Paint;
+import android.view.MotionEvent;
+import android.view.View;
+/////////////////////////////////////////////////////////////
+public class ColorBar extends View
+{
+	Paint paint = new Paint();
+	Paint textpaint = new Paint();
+	//coordinate of the colorbar
+    private int width = 30;
+	private int start_x = 10;
+	private int start_y = 30;
+	private int end_y = 0;
+	boolean touch;
+	final int MAX_SCALING =255;
+	double [][] colorBuffer;
+    public ColorBar(Context context)
+    {
+        super(context);
+        setWillNotDraw(false);
+        paint.setStrokeWidth(5);
+		textpaint.setColor(Color.WHITE);
+        textpaint.setTextSize(20);
+        touch = false;
+    }
+//----------------------------------------------------------------    
+    //change the color map
+    public void setColorMap(ColorMap colorMap)
+    {
+    	this.colorBuffer = colorMap.getColorBuffer();
+    }
+//----------------------------------------------------------------        
+    @Override
+    public void onDraw(Canvas canvas) 
+    {
+    	int r,g,b;
+    	int y = start_y;
+    	for(int i = 0; i < 64; i++ )
+    	{  	
+    		r =  Math.round((float)colorBuffer[i][0]*MAX_SCALING);
+    		g =  Math.round((float)colorBuffer[i][1]*MAX_SCALING);
+    		b =  Math.round((float)colorBuffer[i][2]*MAX_SCALING);
+    		paint.setColor(Color.argb(MAX_SCALING, r, g, b));
+    		canvas.drawLine(start_x, y, start_x+width, y, paint);
+    		
+    		if(i == 60)  canvas.drawText("_0.0", start_x+width, y, textpaint);
+    		if(i == 48) canvas.drawText("_0.2", start_x+width, y, textpaint);
+    		if(i == 36) canvas.drawText("_0.4", start_x+width, y, textpaint);
+    		if(i == 24) canvas.drawText("_0.6", start_x+width, y, textpaint);
+    		if(i == 12) canvas.drawText("_0.8", start_x+width, y, textpaint);
+    		if(i == 0) canvas.drawText("_1.0", start_x+width, y, textpaint);
+    		
+    		y+=5;
+    	}
+    	
+    	end_y = y;
+    }
+//----------------------------------------------------------------        
+    //allow user to move color bar around
+    @Override
+    public boolean onTouchEvent (MotionEvent event)
+    {
+
+	      if (event.getAction() == MotionEvent.ACTION_DOWN) 
+	      {    
+	    	  int x = (int) event.getX();
+	    	  int y = (int) event.getY(); 
+	    	  if(x >= start_x && x <= start_x+width && y >= start_y && y <= end_y)
+	    		  touch = true;
+	      } 
+	      else if (event.getAction() == MotionEvent.ACTION_MOVE) 
+	      {
+	    	 if(touch)
+	    	 {
+	    		 start_x = (int) event.getX();
+	    		 start_y = (int) event.getY(); 
+	    	 }
+	    	 invalidate();
+	
+	      } 
+	      else if (event.getAction() == MotionEvent.ACTION_UP) 
+	      {
+	    	  touch = false;
+	      }
+	      return true;
+    }
+//----------------------------------------------------------------        
+}
+////////////////////////////////////////////////////////////////////////////
Index: /issm/trunk/src/android/ISSM/src/com/example/issm/ColorMap.java
===================================================================
--- /issm/trunk/src/android/ISSM/src/com/example/issm/ColorMap.java	(revision 14310)
+++ /issm/trunk/src/android/ISSM/src/com/example/issm/ColorMap.java	(revision 14310)
@@ -0,0 +1,915 @@
+package com.example.issm;
+
+/////////////////////////////////////////////////////////
+class ColorMap
+{
+	private double[][] d;
+	final int rowNumber = 64;
+//-------------------------------------------------------
+	public ColorMap()
+	{
+		setDefault();
+	}
+//-------------------------------------------------------
+	public double[][] getColorBuffer()
+	{
+		return d;
+	}
+//--------------------------------------------------------	
+	//set default color map => hsv {{{
+	public void setDefault()
+	{
+		d = new double[][]{	
+				{1.0, 	0.0, 	0.0 },
+				{ 1.0, 	0.0938, 	0.0 },
+				{ 1.0, 	0.1875, 	0.0 },
+				{ 1.0, 	0.2813, 	0.0 },
+				{ 1.0, 	0.375, 	0.0 },
+				{ 1.0, 	0.4688, 	0.0 },
+				{ 1.0, 	0.5625, 	0.0 },
+				{ 1.0, 	0.6563, 	0.0 },
+				{ 1.0, 	0.75, 	0.0 },
+				{ 1.0, 	0.8438, 	0.0 },
+				{ 1.0, 	0.9375, 	0.0 },
+				{ 0.9688, 	1.0, 	0.0 },
+				{ 0.875, 	1.0, 	0.0 },
+				{ 0.7813, 	1.0, 	0.0 },
+				{ 0.6875, 	1.0, 	0.0 },
+				{ 0.5938, 	1.0, 	0.0 },
+				{ 0.5, 	1.0, 	0.0 },
+				{ 0.4063, 	1.0, 	0.0 },
+				{ 0.3125, 	1.0, 	0.0 },
+				{ 0.2188, 	1.0, 	0.0 },
+				{ 0.125, 	1.0, 	0.0 },
+				{ 0.0313, 	1.0, 	0.0 },
+				{ 0.0, 	1.0, 	0.0625 },
+				{ 0.0, 	1.0, 	0.1563 },
+				{ 0.0, 	1.0, 	0.25 },
+				{ 0.0, 	1.0, 	0.3438 },
+				{ 0.0, 	1.0, 	0.4375 },
+				{ 0.0, 	1.0, 	0.5313 },
+				{ 0.0, 	1.0, 	0.625 },
+				{ 0.0, 	1.0, 	0.7188 },
+				{ 0.0, 	1.0, 	0.8125 },
+				{ 0.0, 	1.0, 	0.9063 },
+				{ 0.0, 	1.0, 	1.0 },
+				{ 0.0, 	0.9063, 	1.0 },
+				{ 0.0, 	0.8125, 	1.0 },
+				{ 0.0, 	0.7188, 	1.0 },
+				{ 0.0, 	0.625, 	1.0 },
+				{ 0.0, 	0.5313, 	1.0 },
+				{ 0.0, 	0.4375, 	1.0 },
+				{ 0.0, 	0.3438, 	1.0 },
+				{ 0.0, 	0.25, 	1.0 },
+				{ 0.0, 	0.1563, 	1.0 },
+				{ 0.0, 	0.0625, 	1.0 },
+				{ 0.0313, 	0.0, 	1.0 },
+				{ 0.125, 	0.0, 	1.0 },
+				{ 0.2188, 	0.0, 	1.0 },
+				{ 0.3125, 	0.0, 	1.0 },
+				{ 0.4063, 	0.0, 	1.0 },
+				{ 0.5, 	0.0, 	1.0 },
+				{ 0.5938, 	0.0, 	1.0 },
+				{ 0.6875, 	0.0, 	1.0 },
+				{ 0.7813, 	0.0, 	1.0 },
+				{ 0.875, 	0.0, 	1.0 },
+				{ 0.9688, 	0.0, 	1.0 },
+				{ 1.0, 	0.0, 	0.9375 },
+				{ 1.0, 	0.0, 	0.8438 },
+				{ 1.0, 	0.0, 	0.75 },
+				{ 1.0, 	0.0, 	0.6563 },
+				{ 1.0, 	0.0, 	0.5625 },
+				{ 1.0, 	0.0, 	0.4688 },
+				{ 1.0, 	0.0, 	0.375 },
+				{ 1.0, 	0.0, 	0.2813 },
+				{ 1.0, 	0.0, 	0.1875 },
+				{ 1.0, 	0.0, 	0.0938 }
+			};
+	} 
+	//}}}
+//-------------------------------------------------------
+	public void setAutumn()
+	{
+		d = new double[][]{
+				{ 1.0, 	0.0, 	0.0 },
+				{ 1.0, 	0.0159, 	0.0 },
+				{ 1.0, 	0.0317, 	0.0 },
+				{ 1.0, 	0.0476, 	0.0 },
+				{ 1.0, 	0.0635, 	0.0 },
+				{ 1.0, 	0.0794, 	0.0 },
+				{ 1.0, 	0.0952, 	0.0 },
+				{ 1.0, 	0.1111, 	0.0 },
+				{ 1.0, 	0.127, 	0.0 },
+				{ 1.0, 	0.1429, 	0.0 },
+				{ 1.0, 	0.1587, 	0.0 },
+				{ 1.0, 	0.1746, 	0.0 },
+				{ 1.0, 	0.1905, 	0.0 },
+				{ 1.0, 	0.2063, 	0.0 },
+				{ 1.0, 	0.2222, 	0.0 },
+				{ 1.0, 	0.2381, 	0.0 },
+				{ 1.0, 	0.254, 	0.0 },
+				{ 1.0, 	0.2698, 	0.0 },
+				{ 1.0, 	0.2857, 	0.0 },
+				{ 1.0, 	0.3016, 	0.0 },
+				{ 1.0, 	0.3175, 	0.0 },
+				{ 1.0, 	0.3333, 	0.0 },
+				{ 1.0, 	0.3492, 	0.0 },
+				{ 1.0, 	0.3651, 	0.0 },
+				{ 1.0, 	0.381, 	0.0 },
+				{ 1.0, 	0.3968, 	0.0 },
+				{ 1.0, 	0.4127, 	0.0 },
+				{ 1.0, 	0.4286, 	0.0 },
+				{ 1.0, 	0.4444, 	0.0 },
+				{ 1.0, 	0.4603, 	0.0 },
+				{ 1.0, 	0.4762, 	0.0 },
+				{ 1.0, 	0.4921, 	0.0 },
+				{ 1.0, 	0.5079, 	0.0 },
+				{ 1.0, 	0.5238, 	0.0 },
+				{ 1.0, 	0.5397, 	0.0 },
+				{ 1.0, 	0.5556, 	0.0 },
+				{ 1.0, 	0.5714, 	0.0 },
+				{ 1.0, 	0.5873, 	0.0 },
+				{ 1.0, 	0.6032, 	0.0 },
+				{ 1.0, 	0.619, 	0.0 },
+				{ 1.0, 	0.6349, 	0.0 },
+				{ 1.0, 	0.6508, 	0.0 },
+				{ 1.0, 	0.6667, 	0.0 },
+				{ 1.0, 	0.6825, 	0.0 },
+				{ 1.0, 	0.6984, 	0.0 },
+				{ 1.0, 	0.7143, 	0.0 },
+				{ 1.0, 	0.7302, 	0.0 },
+				{ 1.0, 	0.746, 	0.0 },
+				{ 1.0, 	0.7619, 	0.0 },
+				{ 1.0, 	0.7778, 	0.0 },
+				{ 1.0, 	0.7937, 	0.0 },
+				{ 1.0, 	0.8095, 	0.0 },
+				{ 1.0, 	0.8254, 	0.0 },
+				{ 1.0, 	0.8413, 	0.0 },
+				{ 1.0, 	0.8571, 	0.0 },
+				{ 1.0, 	0.873, 	0.0 },
+				{ 1.0, 	0.8889, 	0.0 },
+				{ 1.0, 	0.9048, 	0.0 },
+				{ 1.0, 	0.9206, 	0.0 },
+				{ 1.0, 	0.9365, 	0.0 },
+				{ 1.0, 	0.9524, 	0.0 },
+				{ 1.0, 	0.9683, 	0.0 },
+				{ 1.0, 	0.9841, 	0.0 },
+				{ 1.0, 	1.0, 	0.0 }
+			};
+	}
+//-------------------------------------------------------
+	public void setBone()
+	{
+		d = new double[][]{
+				{ 0.0, 	0.0, 	0.0052 },
+				{ 0.0139, 	0.0139, 	0.0243 },
+				{ 0.0278, 	0.0278, 	0.0434 },
+				{ 0.0417, 	0.0417, 	0.0625 },
+				{ 0.0556, 	0.0556, 	0.0816 },
+				{ 0.0694, 	0.0694, 	0.1007 },
+				{ 0.0833, 	0.0833, 	0.1198 },
+				{ 0.0972, 	0.0972, 	0.1389 },
+				{ 0.1111, 	0.1111, 	0.158 },
+				{ 0.125, 	0.125, 	0.1771 },
+				{ 0.1389, 	0.1389, 	0.1962 },
+				{ 0.1528, 	0.1528, 	0.2153 },
+				{ 0.1667, 	0.1667, 	0.2344 },
+				{ 0.1806, 	0.1806, 	0.2535 },
+				{ 0.1944, 	0.1944, 	0.2726 },
+				{ 0.2083, 	0.2083, 	0.2917 },
+				{ 0.2222, 	0.2222, 	0.3108 },
+				{ 0.2361, 	0.2361, 	0.3299 },
+				{ 0.25, 	0.25, 	0.349 },
+				{ 0.2639, 	0.2639, 	0.3681 },
+				{ 0.2778, 	0.2778, 	0.3872 },
+				{ 0.2917, 	0.2917, 	0.4062 },
+				{ 0.3056, 	0.3056, 	0.4253 },
+				{ 0.3194, 	0.3194, 	0.4444 },
+				{ 0.3333, 	0.3385, 	0.4583 },
+				{ 0.3472, 	0.3576, 	0.4722 },
+				{ 0.3611, 	0.3767, 	0.4861 },
+				{ 0.375, 	0.3958, 	0.5 },
+				{ 0.3889, 	0.4149, 	0.5139 },
+				{ 0.4028, 	0.434, 	0.5278 },
+				{ 0.4167, 	0.4531, 	0.5417 },
+				{ 0.4306, 	0.4722, 	0.5556 },
+				{ 0.4444, 	0.4913, 	0.5694 },
+				{ 0.4583, 	0.5104, 	0.5833 },
+				{ 0.4722, 	0.5295, 	0.5972 },
+				{ 0.4861, 	0.5486, 	0.6111 },
+				{ 0.5, 	0.5677, 	0.625 },
+				{ 0.5139, 	0.5868, 	0.6389 },
+				{ 0.5278, 	0.6059, 	0.6528 },
+				{ 0.5417, 	0.625, 	0.6667 },
+				{ 0.5556, 	0.6441, 	0.6806 },
+				{ 0.5694, 	0.6632, 	0.6944 },
+				{ 0.5833, 	0.6823, 	0.7083 },
+				{ 0.5972, 	0.7014, 	0.7222 },
+				{ 0.6111, 	0.7205, 	0.7361 },
+				{ 0.625, 	0.7396, 	0.75 },
+				{ 0.6389, 	0.7587, 	0.7639 },
+				{ 0.6528, 	0.7778, 	0.7778 },
+				{ 0.6745, 	0.7917, 	0.7917 },
+				{ 0.6962, 	0.8056, 	0.8056 },
+				{ 0.7179, 	0.8194, 	0.8194 },
+				{ 0.7396, 	0.8333, 	0.8333 },
+				{ 0.7613, 	0.8472, 	0.8472 },
+				{ 0.783, 	0.8611, 	0.8611 },
+				{ 0.8047, 	0.875, 	0.875 },
+				{ 0.8264, 	0.8889, 	0.8889 },
+				{ 0.8481, 	0.9028, 	0.9028 },
+				{ 0.8698, 	0.9167, 	0.9167 },
+				{ 0.8915, 	0.9306, 	0.9306 },
+				{ 0.9132, 	0.9444, 	0.9444 },
+				{ 0.9349, 	0.9583, 	0.9583 },
+				{ 0.9566, 	0.9722, 	0.9722 },
+				{ 0.9783, 	0.9861, 	0.9861 },
+				{ 1.0, 	1.0, 	1.0 }
+			};
+	}		
+//-------------------------------------------------------
+	public void setCool()
+	{
+		d = new double[][]{
+				{ 0.0, 	1.0, 	1.0 },
+				{ 0.0159, 	0.9841, 	1.0 },
+				{ 0.0317, 	0.9683, 	1.0 },
+				{ 0.0476, 	0.9524, 	1.0 },
+				{ 0.0635, 	0.9365, 	1.0 },
+				{ 0.0794, 	0.9206, 	1.0 },
+				{ 0.0952, 	0.9048, 	1.0 },
+				{ 0.1111, 	0.8889, 	1.0 },
+				{ 0.127, 	0.873, 	1.0 },
+				{ 0.1429, 	0.8571, 	1.0 },
+				{ 0.1587, 	0.8413, 	1.0 },
+				{ 0.1746, 	0.8254, 	1.0 },
+				{ 0.1905, 	0.8095, 	1.0 },
+				{ 0.2063, 	0.7937, 	1.0 },
+				{ 0.2222, 	0.7778, 	1.0 },
+				{ 0.2381, 	0.7619, 	1.0 },
+				{ 0.254, 	0.746, 	1.0 },
+				{ 0.2698, 	0.7302, 	1.0 },
+				{ 0.2857, 	0.7143, 	1.0 },
+				{ 0.3016, 	0.6984, 	1.0 },
+				{ 0.3175, 	0.6825, 	1.0 },
+				{ 0.3333, 	0.6667, 	1.0 },
+				{ 0.3492, 	0.6508, 	1.0 },
+				{ 0.3651, 	0.6349, 	1.0 },
+				{ 0.381, 	0.619, 	1.0 },
+				{ 0.3968, 	0.6032, 	1.0 },
+				{ 0.4127, 	0.5873, 	1.0 },
+				{ 0.4286, 	0.5714, 	1.0 },
+				{ 0.4444, 	0.5556, 	1.0 },
+				{ 0.4603, 	0.5397, 	1.0 },
+				{ 0.4762, 	0.5238, 	1.0 },
+				{ 0.4921, 	0.5079, 	1.0 },
+				{ 0.5079, 	0.4921, 	1.0 },
+				{ 0.5238, 	0.4762, 	1.0 },
+				{ 0.5397, 	0.4603, 	1.0 },
+				{ 0.5556, 	0.4444, 	1.0 },
+				{ 0.5714, 	0.4286, 	1.0 },
+				{ 0.5873, 	0.4127, 	1.0 },
+				{ 0.6032, 	0.3968, 	1.0 },
+				{ 0.619, 	0.381, 	1.0 },
+				{ 0.6349, 	0.3651, 	1.0 },
+				{ 0.6508, 	0.3492, 	1.0 },
+				{ 0.6667, 	0.3333, 	1.0 },
+				{ 0.6825, 	0.3175, 	1.0 },
+				{ 0.6984, 	0.3016, 	1.0 },
+				{ 0.7143, 	0.2857, 	1.0 },
+				{ 0.7302, 	0.2698, 	1.0 },
+				{ 0.746, 	0.254, 	1.0 },
+				{ 0.7619, 	0.2381, 	1.0 },
+				{ 0.7778, 	0.2222, 	1.0 },
+				{ 0.7937, 	0.2063, 	1.0 },
+				{ 0.8095, 	0.1905, 	1.0 },
+				{ 0.8254, 	0.1746, 	1.0 },
+				{ 0.8413, 	0.1587, 	1.0 },
+				{ 0.8571, 	0.1429, 	1.0 },
+				{ 0.873, 	0.127, 	1.0 },
+				{ 0.8889, 	0.1111, 	1.0 },
+				{ 0.9048, 	0.0952, 	1.0 },
+				{ 0.9206, 	0.0794, 	1.0 },
+				{ 0.9365, 	0.0635, 	1.0 },
+				{ 0.9524, 	0.0476, 	1.0 },
+				{ 0.9683, 	0.0317, 	1.0 },
+				{ 0.9841, 	0.0159, 	1.0 },
+				{ 1.0, 	0.0, 	1.0 }
+			};
+	}
+//-------------------------------------------------------
+	public void setCopper()
+	{
+		d = new double[][]{
+				{ 0.0, 	0.0, 	0.0 },
+				{ 0.0198, 	0.0124, 	0.0079 },
+				{ 0.0397, 	0.0248, 	0.0158 },
+				{ 0.0595, 	0.0372, 	0.0237 },
+				{ 0.0794, 	0.0496, 	0.0316 },
+				{ 0.0992, 	0.062, 	0.0395 },
+				{ 0.119, 	0.0744, 	0.0474 },
+				{ 0.1389, 	0.0868, 	0.0553 },
+				{ 0.1587, 	0.0992, 	0.0632 },
+				{ 0.1786, 	0.1116, 	0.0711 },
+				{ 0.1984, 	0.124, 	0.079 },
+				{ 0.2183, 	0.1364, 	0.0869 },
+				{ 0.2381, 	0.1488, 	0.0948 },
+				{ 0.2579, 	0.1612, 	0.1027 },
+				{ 0.2778, 	0.1736, 	0.1106 },
+				{ 0.2976, 	0.186, 	0.1185 },
+				{ 0.3175, 	0.1984, 	0.1263 },
+				{ 0.3373, 	0.2108, 	0.1342 },
+				{ 0.3571, 	0.2232, 	0.1421 },
+				{ 0.377, 	0.2356, 	0.15 },
+				{ 0.3968, 	0.248, 	0.1579 },
+				{ 0.4167, 	0.2604, 	0.1658 },
+				{ 0.4365, 	0.2728, 	0.1737 },
+				{ 0.4563, 	0.2852, 	0.1816 },
+				{ 0.4762, 	0.2976, 	0.1895 },
+				{ 0.496, 	0.31, 	0.1974 },
+				{ 0.5159, 	0.3224, 	0.2053 },
+				{ 0.5357, 	0.3348, 	0.2132 },
+				{ 0.5556, 	0.3472, 	0.2211 },
+				{ 0.5754, 	0.3596, 	0.229 },
+				{ 0.5952, 	0.372, 	0.2369 },
+				{ 0.6151, 	0.3844, 	0.2448 },
+				{ 0.6349, 	0.3968, 	0.2527 },
+				{ 0.6548, 	0.4092, 	0.2606 },
+				{ 0.6746, 	0.4216, 	0.2685 },
+				{ 0.6944, 	0.434, 	0.2764 },
+				{ 0.7143, 	0.4464, 	0.2843 },
+				{ 0.7341, 	0.4588, 	0.2922 },
+				{ 0.754, 	0.4712, 	0.3001 },
+				{ 0.7738, 	0.4836, 	0.308 },
+				{ 0.7937, 	0.496, 	0.3159 },
+				{ 0.8135, 	0.5084, 	0.3238 },
+				{ 0.8333, 	0.5208, 	0.3317 },
+				{ 0.8532, 	0.5332, 	0.3396 },
+				{ 0.873, 	0.5456, 	0.3475 },
+				{ 0.8929, 	0.558, 	0.3554 },
+				{ 0.9127, 	0.5704, 	0.3633 },
+				{ 0.9325, 	0.5828, 	0.3712 },
+				{ 0.9524, 	0.5952, 	0.379 },
+				{ 0.9722, 	0.6076, 	0.3869 },
+				{ 0.9921, 	0.62, 	0.3948 },
+				{ 1.0, 	0.6324, 	0.4027 },
+				{ 1.0, 	0.6448, 	0.4106 },
+				{ 1.0, 	0.6572, 	0.4185 },
+				{ 1.0, 	0.6696, 	0.4264 },
+				{ 1.0, 	0.682, 	0.4343 },
+				{ 1.0, 	0.6944, 	0.4422 },
+				{ 1.0, 	0.7068, 	0.4501 },
+				{ 1.0, 	0.7192, 	0.458 },
+				{ 1.0, 	0.7316, 	0.4659 },
+				{ 1.0, 	0.744, 	0.4738 },
+				{ 1.0, 	0.7564, 	0.4817 },
+				{ 1.0, 	0.7688, 	0.4896 },
+				{ 1.0, 	0.7812, 	0.4975 },
+			};
+	}
+//-------------------------------------------------------
+	public void setGray()
+	{
+		d = new double[][]{
+				{ 0.0, 	0.0, 	0.0 },
+				{ 0.0159, 	0.0159, 	0.0159 },
+				{ 0.0317, 	0.0317, 	0.0317 },
+				{ 0.0476, 	0.0476, 	0.0476 },
+				{ 0.0635, 	0.0635, 	0.0635 },
+				{ 0.0794, 	0.0794, 	0.0794 },
+				{ 0.0952, 	0.0952, 	0.0952 },
+				{ 0.1111, 	0.1111, 	0.1111 },
+				{ 0.127, 	0.127, 	0.127 },
+				{ 0.1429, 	0.1429, 	0.1429 },
+				{ 0.1587, 	0.1587, 	0.1587 },
+				{ 0.1746, 	0.1746, 	0.1746 },
+				{ 0.1905, 	0.1905, 	0.1905 },
+				{ 0.2063, 	0.2063, 	0.2063 },
+				{ 0.2222, 	0.2222, 	0.2222 },
+				{ 0.2381, 	0.2381, 	0.2381 },
+				{ 0.254, 	0.254, 	0.254 },
+				{ 0.2698, 	0.2698, 	0.2698 },
+				{ 0.2857, 	0.2857, 	0.2857 },
+				{ 0.3016, 	0.3016, 	0.3016 },
+				{ 0.3175, 	0.3175, 	0.3175 },
+				{ 0.3333, 	0.3333, 	0.3333 },
+				{ 0.3492, 	0.3492, 	0.3492 },
+				{ 0.3651, 	0.3651, 	0.3651 },
+				{ 0.381, 	0.381, 	0.381 },
+				{ 0.3968, 	0.3968, 	0.3968 },
+				{ 0.4127, 	0.4127, 	0.4127 },
+				{ 0.4286, 	0.4286, 	0.4286 },
+				{ 0.4444, 	0.4444, 	0.4444 },
+				{ 0.4603, 	0.4603, 	0.4603 },
+				{ 0.4762, 	0.4762, 	0.4762 },
+				{ 0.4921, 	0.4921, 	0.4921 },
+				{ 0.5079, 	0.5079, 	0.5079 },
+				{ 0.5238, 	0.5238, 	0.5238 },
+				{ 0.5397, 	0.5397, 	0.5397 },
+				{ 0.5556, 	0.5556, 	0.5556 },
+				{ 0.5714, 	0.5714, 	0.5714 },
+				{ 0.5873, 	0.5873, 	0.5873 },
+				{ 0.6032, 	0.6032, 	0.6032 },
+				{ 0.619, 	0.619, 	0.619 },
+				{ 0.6349, 	0.6349, 	0.6349 },
+				{ 0.6508, 	0.6508, 	0.6508 },
+				{ 0.6667, 	0.6667, 	0.6667 },
+				{ 0.6825, 	0.6825, 	0.6825 },
+				{ 0.6984, 	0.6984, 	0.6984 },
+				{ 0.7143, 	0.7143, 	0.7143 },
+				{ 0.7302, 	0.7302, 	0.7302 },
+				{ 0.746, 	0.746, 	0.746 },
+				{ 0.7619, 	0.7619, 	0.7619 },
+				{ 0.7778, 	0.7778, 	0.7778 },
+				{ 0.7937, 	0.7937, 	0.7937 },
+				{ 0.8095, 	0.8095, 	0.8095 },
+				{ 0.8254, 	0.8254, 	0.8254 },
+				{ 0.8413, 	0.8413, 	0.8413 },
+				{ 0.8571, 	0.8571, 	0.8571 },
+				{ 0.873, 	0.873, 	0.873 },
+				{ 0.8889, 	0.8889, 	0.8889 },
+				{ 0.9048, 	0.9048, 	0.9048 },
+				{ 0.9206, 	0.9206, 	0.9206 },
+				{ 0.9365, 	0.9365, 	0.9365 },
+				{ 0.9524, 	0.9524, 	0.9524 },
+				{ 0.9683, 	0.9683, 	0.9683 },
+				{ 0.9841, 	0.9841, 	0.9841 },
+				{ 1.0, 	1.0, 	1.0 }
+			};
+	}
+//-------------------------------------------------------
+	public void setHot()
+	{
+		d = new double[][]{
+				{ 0.0417, 	0.0, 	0.0 },
+				{ 0.0833, 	0.0, 	0.0 },
+				{ 0.125, 	0.0, 	0.0 },
+				{ 0.1667, 	0.0, 	0.0 },
+				{ 0.2083, 	0.0, 	0.0 },
+				{ 0.25, 	0.0, 	0.0 },
+				{ 0.2917, 	0.0, 	0.0 },
+				{ 0.3333, 	0.0, 	0.0 },
+				{ 0.375, 	0.0, 	0.0 },
+				{ 0.4167, 	0.0, 	0.0 },
+				{ 0.4583, 	0.0, 	0.0 },
+				{ 0.5, 	0.0, 	0.0 },
+				{ 0.5417, 	0.0, 	0.0 },
+				{ 0.5833, 	0.0, 	0.0 },
+				{ 0.625, 	0.0, 	0.0 },
+				{ 0.6667, 	0.0, 	0.0 },
+				{ 0.7083, 	0.0, 	0.0 },
+				{ 0.75, 	0.0, 	0.0 },
+				{ 0.7917, 	0.0, 	0.0 },
+				{ 0.8333, 	0.0, 	0.0 },
+				{ 0.875, 	0.0, 	0.0 },
+				{ 0.9167, 	0.0, 	0.0 },
+				{ 0.9583, 	0.0, 	0.0 },
+				{ 1.0, 	0.0, 	0.0 },
+				{ 1.0, 	0.0417, 	0.0 },
+				{ 1.0, 	0.0833, 	0.0 },
+				{ 1.0, 	0.125, 	0.0 },
+				{ 1.0, 	0.1667, 	0.0 },
+				{ 1.0, 	0.2083, 	0.0 },
+				{ 1.0, 	0.25, 	0.0 },
+				{ 1.0, 	0.2917, 	0.0 },
+				{ 1.0, 	0.3333, 	0.0 },
+				{ 1.0, 	0.375, 	0.0 },
+				{ 1.0, 	0.4167, 	0.0 },
+				{ 1.0, 	0.4583, 	0.0 },
+				{ 1.0, 	0.5, 	0.0 },
+				{ 1.0, 	0.5417, 	0.0 },
+				{ 1.0, 	0.5833, 	0.0 },
+				{ 1.0, 	0.625, 	0.0 },
+				{ 1.0, 	0.6667, 	0.0 },
+				{ 1.0, 	0.7083, 	0.0 },
+				{ 1.0, 	0.75, 	0.0 },
+				{ 1.0, 	0.7917, 	0.0 },
+				{ 1.0, 	0.8333, 	0.0 },
+				{ 1.0, 	0.875, 	0.0 },
+				{ 1.0, 	0.9167, 	0.0 },
+				{ 1.0, 	0.9583, 	0.0 },
+				{ 1.0, 	1.0, 	0.0 },
+				{ 1.0, 	1.0, 	0.0625 },
+				{ 1.0, 	1.0, 	0.125 },
+				{ 1.0, 	1.0, 	0.1875 },
+				{ 1.0, 	1.0, 	0.25 },
+				{ 1.0, 	1.0, 	0.3125 },
+				{ 1.0, 	1.0, 	0.375 },
+				{ 1.0, 	1.0, 	0.4375 },
+				{ 1.0, 	1.0, 	0.5 },
+				{ 1.0, 	1.0, 	0.5625 },
+				{ 1.0, 	1.0, 	0.625 },
+				{ 1.0, 	1.0, 	0.6875 },
+				{ 1.0, 	1.0, 	0.75 },
+				{ 1.0, 	1.0, 	0.8125 },
+				{ 1.0, 	1.0, 	0.875 },
+				{ 1.0, 	1.0, 	0.9375 },
+				{ 1.0, 	1.0, 	1.0 },
+			};
+	}
+//-------------------------------------------------------
+	public void setJet()
+	{
+		d = new double[][]{
+				{ 0.0, 	0.0, 	0.5625 },
+				{ 0.0, 	0.0, 	0.625 },
+				{ 0.0, 	0.0, 	0.6875 },
+				{ 0.0, 	0.0, 	0.75 },
+				{ 0.0, 	0.0, 	0.8125 },
+				{ 0.0, 	0.0, 	0.875 },
+				{ 0.0, 	0.0, 	0.9375 },
+				{ 0.0, 	0.0, 	1.0 },
+				{ 0.0, 	0.0625, 	1.0 },
+				{ 0.0, 	0.125, 	1.0 },
+				{ 0.0, 	0.1875, 	1.0 },
+				{ 0.0, 	0.25, 	1.0 },
+				{ 0.0, 	0.3125, 	1.0 },
+				{ 0.0, 	0.375, 	1.0 },
+				{ 0.0, 	0.4375, 	1.0 },
+				{ 0.0, 	0.5, 	1.0 },
+				{ 0.0, 	0.5625, 	1.0 },
+				{ 0.0, 	0.625, 	1.0 },
+				{ 0.0, 	0.6875, 	1.0 },
+				{ 0.0, 	0.75, 	1.0 },
+				{ 0.0, 	0.8125, 	1.0 },
+				{ 0.0, 	0.875, 	1.0 },
+				{ 0.0, 	0.9375, 	1.0 },
+				{ 0.0, 	1.0, 	1.0 },
+				{ 0.0625, 	1.0, 	0.9375 },
+				{ 0.125, 	1.0, 	0.875 },
+				{ 0.1875, 	1.0, 	0.8125 },
+				{ 0.25, 	1.0, 	0.75 },
+				{ 0.3125, 	1.0, 	0.6875 },
+				{ 0.375, 	1.0, 	0.625 },
+				{ 0.4375, 	1.0, 	0.5625 },
+				{ 0.5, 	1.0, 	0.5 },
+				{ 0.5625, 	1.0, 	0.4375 },
+				{ 0.625, 	1.0, 	0.375 },
+				{ 0.6875, 	1.0, 	0.3125 },
+				{ 0.75, 	1.0, 	0.25 },
+				{ 0.8125, 	1.0, 	0.1875 },
+				{ 0.875, 	1.0, 	0.125 },
+				{ 0.9375, 	1.0, 	0.0625 },
+				{ 1.0, 	1.0, 	0.0 },
+				{ 1.0, 	0.9375, 	0.0 },
+				{ 1.0, 	0.875, 	0.0 },
+				{ 1.0, 	0.8125, 	0.0 },
+				{ 1.0, 	0.75, 	0.0 },
+				{ 1.0, 	0.6875, 	0.0 },
+				{ 1.0, 	0.625, 	0.0 },
+				{ 1.0, 	0.5625, 	0.0 },
+				{ 1.0, 	0.5, 	0.0 },
+				{ 1.0, 	0.4375, 	0.0 },
+				{ 1.0, 	0.375, 	0.0 },
+				{ 1.0, 	0.3125, 	0.0 },
+				{ 1.0, 	0.25, 	0.0 },
+				{ 1.0, 	0.1875, 	0.0 },
+				{ 1.0, 	0.125, 	0.0 },
+				{ 1.0, 	0.0625, 	0.0 },
+				{ 1.0, 	0.0, 	0.0 },
+				{ 0.9375, 	0.0, 	0.0 },
+				{ 0.875, 	0.0, 	0.0 },
+				{ 0.8125, 	0.0, 	0.0 },
+				{ 0.75, 	0.0, 	0.0 },
+				{ 0.6875, 	0.0, 	0.0 },
+				{ 0.625, 	0.0, 	0.0 },
+				{ 0.5625, 	0.0, 	0.0 },
+				{ 0.5, 	0.0, 	0.0 }
+			};
+	}
+//-------------------------------------------------------
+	public void setPink()
+	{
+		d = new double[][]{
+				{ 0.1179, 	0.0, 	0.0 },
+				{ 0.1959, 	0.1029, 	0.1029 },
+				{ 0.2507, 	0.1455, 	0.1455 },
+				{ 0.2955, 	0.1782, 	0.1782 },
+				{ 0.3343, 	0.2057, 	0.2057 },
+				{ 0.3691, 	0.23, 	0.23 },
+				{ 0.4009, 	0.252, 	0.252 },
+				{ 0.4303, 	0.2722, 	0.2722 },
+				{ 0.4579, 	0.291, 	0.291 },
+				{ 0.4839, 	0.3086, 	0.3086 },
+				{ 0.5085, 	0.3253, 	0.3253 },
+				{ 0.532, 	0.3412, 	0.3412 },
+				{ 0.5546, 	0.3563, 	0.3563 },
+				{ 0.5762, 	0.3709, 	0.3709 },
+				{ 0.5971, 	0.3849, 	0.3849 },
+				{ 0.6172, 	0.3984, 	0.3984 },
+				{ 0.6367, 	0.4115, 	0.4115 },
+				{ 0.6557, 	0.4241, 	0.4241 },
+				{ 0.6741, 	0.4364, 	0.4364 },
+				{ 0.692, 	0.4484, 	0.4484 },
+				{ 0.7094, 	0.46, 	0.46 },
+				{ 0.7265, 	0.4714, 	0.4714 },
+				{ 0.7431, 	0.4825, 	0.4825 },
+				{ 0.7594, 	0.4933, 	0.4933 },
+				{ 0.7664, 	0.5175, 	0.504 },
+				{ 0.7732, 	0.5407, 	0.5143 },
+				{ 0.78, 	0.5628, 	0.5245 },
+				{ 0.7868, 	0.5842, 	0.5345 },
+				{ 0.7935, 	0.6048, 	0.5443 },
+				{ 0.8001, 	0.6247, 	0.554 },
+				{ 0.8067, 	0.644, 	0.5634 },
+				{ 0.8133, 	0.6627, 	0.5727 },
+				{ 0.8197, 	0.6809, 	0.5819 },
+				{ 0.8262, 	0.6986, 	0.5909 },
+				{ 0.8325, 	0.7159, 	0.5998 },
+				{ 0.8389, 	0.7328, 	0.6086 },
+				{ 0.8452, 	0.7493, 	0.6172 },
+				{ 0.8514, 	0.7655, 	0.6257 },
+				{ 0.8576, 	0.7813, 	0.6341 },
+				{ 0.8637, 	0.7968, 	0.6424 },
+				{ 0.8698, 	0.812, 	0.6506 },
+				{ 0.8759, 	0.827, 	0.6587 },
+				{ 0.8819, 	0.8416, 	0.6667 },
+				{ 0.8879, 	0.856, 	0.6746 },
+				{ 0.8938, 	0.8702, 	0.6824 },
+				{ 0.8997, 	0.8842, 	0.6901 },
+				{ 0.9056, 	0.8979, 	0.6977 },
+				{ 0.9114, 	0.9114, 	0.7052 },
+				{ 0.9172, 	0.9172, 	0.7272 },
+				{ 0.923, 	0.923, 	0.7485 },
+				{ 0.9287, 	0.9287, 	0.7692 },
+				{ 0.9344, 	0.9344, 	0.7893 },
+				{ 0.94, 	0.94, 	0.809 },
+				{ 0.9456, 	0.9456, 	0.8282 },
+				{ 0.9512, 	0.9512, 	0.8469 },
+				{ 0.9567, 	0.9567, 	0.8653 },
+				{ 0.9623, 	0.9623, 	0.8832 },
+				{ 0.9677, 	0.9677, 	0.9008 },
+				{ 0.9732, 	0.9732, 	0.9181 },
+				{ 0.9786, 	0.9786, 	0.9351 },
+				{ 0.984, 	0.984, 	0.9517 },
+				{ 0.9894, 	0.9894, 	0.9681 },
+				{ 0.9947, 	0.9947, 	0.9842 },
+				{ 1.0, 	1.0, 	1.0 }
+			};
+	}
+//-------------------------------------------------------
+	public void setSpring()
+	{
+		d = new double[][]{
+				{ 1.0, 	0.0, 	1.0 },
+				{ 1.0, 	0.0159, 	0.9841 },
+				{ 1.0, 	0.0317, 	0.9683 },
+				{ 1.0, 	0.0476, 	0.9524 },
+				{ 1.0, 	0.0635, 	0.9365 },
+				{ 1.0, 	0.0794, 	0.9206 },
+				{ 1.0, 	0.0952, 	0.9048 },
+				{ 1.0, 	0.1111, 	0.8889 },
+				{ 1.0, 	0.127, 	0.873 },
+				{ 1.0, 	0.1429, 	0.8571 },
+				{ 1.0, 	0.1587, 	0.8413 },
+				{ 1.0, 	0.1746, 	0.8254 },
+				{ 1.0, 	0.1905, 	0.8095 },
+				{ 1.0, 	0.2063, 	0.7937 },
+				{ 1.0, 	0.2222, 	0.7778 },
+				{ 1.0, 	0.2381, 	0.7619 },
+				{ 1.0, 	0.254, 	0.746 },
+				{ 1.0, 	0.2698, 	0.7302 },
+				{ 1.0, 	0.2857, 	0.7143 },
+				{ 1.0, 	0.3016, 	0.6984 },
+				{ 1.0, 	0.3175, 	0.6825 },
+				{ 1.0, 	0.3333, 	0.6667 },
+				{ 1.0, 	0.3492, 	0.6508 },
+				{ 1.0, 	0.3651, 	0.6349 },
+				{ 1.0, 	0.381, 	0.619 },
+				{ 1.0, 	0.3968, 	0.6032 },
+				{ 1.0, 	0.4127, 	0.5873 },
+				{ 1.0, 	0.4286, 	0.5714 },
+				{ 1.0, 	0.4444, 	0.5556 },
+				{ 1.0, 	0.4603, 	0.5397 },
+				{ 1.0, 	0.4762, 	0.5238 },
+				{ 1.0, 	0.4921, 	0.5079 },
+				{ 1.0, 	0.5079, 	0.4921 },
+				{ 1.0, 	0.5238, 	0.4762 },
+				{ 1.0, 	0.5397, 	0.4603 },
+				{ 1.0, 	0.5556, 	0.4444 },
+				{ 1.0, 	0.5714, 	0.4286 },
+				{ 1.0, 	0.5873, 	0.4127 },
+				{ 1.0, 	0.6032, 	0.3968 },
+				{ 1.0, 	0.619, 	0.381 },
+				{ 1.0, 	0.6349, 	0.3651 },
+				{ 1.0, 	0.6508, 	0.3492 },
+				{ 1.0, 	0.6667, 	0.3333 },
+				{ 1.0, 	0.6825, 	0.3175 },
+				{ 1.0, 	0.6984, 	0.3016 },
+				{ 1.0, 	0.7143, 	0.2857 },
+				{ 1.0, 	0.7302, 	0.2698 },
+				{ 1.0, 	0.746, 	0.254 },
+				{ 1.0, 	0.7619, 	0.2381 },
+				{ 1.0, 	0.7778, 	0.2222 },
+				{ 1.0, 	0.7937, 	0.2063 },
+				{ 1.0, 	0.8095, 	0.1905 },
+				{ 1.0, 	0.8254, 	0.1746 },
+				{ 1.0, 	0.8413, 	0.1587 },
+				{ 1.0, 	0.8571, 	0.1429 },
+				{ 1.0, 	0.873, 	0.127 },
+				{ 1.0, 	0.8889, 	0.1111 },
+				{ 1.0, 	0.9048, 	0.0952 },
+				{ 1.0, 	0.9206, 	0.0794 },
+				{ 1.0, 	0.9365, 	0.0635 },
+				{ 1.0, 	0.9524, 	0.0476 },
+				{ 1.0, 	0.9683, 	0.0317 },
+				{ 1.0, 	0.9841, 	0.0159 },
+				{ 1.0, 	1.0, 	0.0 }
+			};
+	}
+//-------------------------------------------------------
+	public void setSummer()
+	{
+		d = new double[][]{
+				{ 0.0, 	0.5, 	0.4 },
+				{ 0.0159, 	0.5079, 	0.4 },
+				{ 0.0317, 	0.5159, 	0.4 },
+				{ 0.0476, 	0.5238, 	0.4 },
+				{ 0.0635, 	0.5317, 	0.4 },
+				{ 0.0794, 	0.5397, 	0.4 },
+				{ 0.0952, 	0.5476, 	0.4 },
+				{ 0.1111, 	0.5556, 	0.4 },
+				{ 0.127, 	0.5635, 	0.4 },
+				{ 0.1429, 	0.5714, 	0.4 },
+				{ 0.1587, 	0.5794, 	0.4 },
+				{ 0.1746, 	0.5873, 	0.4 },
+				{ 0.1905, 	0.5952, 	0.4 },
+				{ 0.2063, 	0.6032, 	0.4 },
+				{ 0.2222, 	0.6111, 	0.4 },
+				{ 0.2381, 	0.619, 	0.4 },
+				{ 0.254, 	0.627, 	0.4 },
+				{ 0.2698, 	0.6349, 	0.4 },
+				{ 0.2857, 	0.6429, 	0.4 },
+				{ 0.3016, 	0.6508, 	0.4 },
+				{ 0.3175, 	0.6587, 	0.4 },
+				{ 0.3333, 	0.6667, 	0.4 },
+				{ 0.3492, 	0.6746, 	0.4 },
+				{ 0.3651, 	0.6825, 	0.4 },
+				{ 0.381, 	0.6905, 	0.4 },
+				{ 0.3968, 	0.6984, 	0.4 },
+				{ 0.4127, 	0.7063, 	0.4 },
+				{ 0.4286, 	0.7143, 	0.4 },
+				{ 0.4444, 	0.7222, 	0.4 },
+				{ 0.4603, 	0.7302, 	0.4 },
+				{ 0.4762, 	0.7381, 	0.4 },
+				{ 0.4921, 	0.746, 	0.4 },
+				{ 0.5079, 	0.754, 	0.4 },
+				{ 0.5238, 	0.7619, 	0.4 },
+				{ 0.5397, 	0.7698, 	0.4 },
+				{ 0.5556, 	0.7778, 	0.4 },
+				{ 0.5714, 	0.7857, 	0.4 },
+				{ 0.5873, 	0.7937, 	0.4 },
+				{ 0.6032, 	0.8016, 	0.4 },
+				{ 0.619, 	0.8095, 	0.4 },
+				{ 0.6349, 	0.8175, 	0.4 },
+				{ 0.6508, 	0.8254, 	0.4 },
+				{ 0.6667, 	0.8333, 	0.4 },
+				{ 0.6825, 	0.8413, 	0.4 },
+				{ 0.6984, 	0.8492, 	0.4 },
+				{ 0.7143, 	0.8571, 	0.4 },
+				{ 0.7302, 	0.8651, 	0.4 },
+				{ 0.746, 	0.873, 	0.4 },
+				{ 0.7619, 	0.881, 	0.4 },
+				{ 0.7778, 	0.8889, 	0.4 },
+				{ 0.7937, 	0.8968, 	0.4 },
+				{ 0.8095, 	0.9048, 	0.4 },
+				{ 0.8254, 	0.9127, 	0.4 },
+				{ 0.8413, 	0.9206, 	0.4 },
+				{ 0.8571, 	0.9286, 	0.4 },
+				{ 0.873, 	0.9365, 	0.4 },
+				{ 0.8889, 	0.9444, 	0.4 },
+				{ 0.9048, 	0.9524, 	0.4 },
+				{ 0.9206, 	0.9603, 	0.4 },
+				{ 0.9365, 	0.9683, 	0.4 },
+				{ 0.9524, 	0.9762, 	0.4 },
+				{ 0.9683, 	0.9841, 	0.4 },
+				{ 0.9841, 	0.9921, 	0.4 },
+				{ 1.0, 	1.0, 	0.4 }
+			};
+	}
+//-------------------------------------------------------
+	public void setWinter()
+	{
+		d = new double[][]{
+				{ 0.0, 	0.0, 	1.0 },
+				{ 0.0, 	0.0159, 	0.9921 },
+				{ 0.0, 	0.0317, 	0.9841 },
+				{ 0.0, 	0.0476, 	0.9762 },
+				{ 0.0, 	0.0635, 	0.9683 },
+				{ 0.0, 	0.0794, 	0.9603 },
+				{ 0.0, 	0.0952, 	0.9524 },
+				{ 0.0, 	0.1111, 	0.9444 },
+				{ 0.0, 	0.127, 	0.9365 },
+				{ 0.0, 	0.1429, 	0.9286 },
+				{ 0.0, 	0.1587, 	0.9206 },
+				{ 0.0, 	0.1746, 	0.9127 },
+				{ 0.0, 	0.1905, 	0.9048 },
+				{ 0.0, 	0.2063, 	0.8968 },
+				{ 0.0, 	0.2222, 	0.8889 },
+				{ 0.0, 	0.2381, 	0.881 },
+				{ 0.0, 	0.254, 	0.873 },
+				{ 0.0, 	0.2698, 	0.8651 },
+				{ 0.0, 	0.2857, 	0.8571 },
+				{ 0.0, 	0.3016, 	0.8492 },
+				{ 0.0, 	0.3175, 	0.8413 },
+				{ 0.0, 	0.3333, 	0.8333 },
+				{ 0.0, 	0.3492, 	0.8254 },
+				{ 0.0, 	0.3651, 	0.8175 },
+				{ 0.0, 	0.381, 	0.8095 },
+				{ 0.0, 	0.3968, 	0.8016 },
+				{ 0.0, 	0.4127, 	0.7937 },
+				{ 0.0, 	0.4286, 	0.7857 },
+				{ 0.0, 	0.4444, 	0.7778 },
+				{ 0.0, 	0.4603, 	0.7698 },
+				{ 0.0, 	0.4762, 	0.7619 },
+				{ 0.0, 	0.4921, 	0.754 },
+				{ 0.0, 	0.5079, 	0.746 },
+				{ 0.0, 	0.5238, 	0.7381 },
+				{ 0.0, 	0.5397, 	0.7302 },
+				{ 0.0, 	0.5556, 	0.7222 },
+				{ 0.0, 	0.5714, 	0.7143 },
+				{ 0.0, 	0.5873, 	0.7063 },
+				{ 0.0, 	0.6032, 	0.6984 },
+				{ 0.0, 	0.619, 	0.6905 },
+				{ 0.0, 	0.6349, 	0.6825 },
+				{ 0.0, 	0.6508, 	0.6746 },
+				{ 0.0, 	0.6667, 	0.6667 },
+				{ 0.0, 	0.6825, 	0.6587 },
+				{ 0.0, 	0.6984, 	0.6508 },
+				{ 0.0, 	0.7143, 	0.6429 },
+				{ 0.0, 	0.7302, 	0.6349 },
+				{ 0.0, 	0.746, 	0.627 },
+				{ 0.0, 	0.7619, 	0.619 },
+				{ 0.0, 	0.7778, 	0.6111 },
+				{ 0.0, 	0.7937, 	0.6032 },
+				{ 0.0, 	0.8095, 	0.5952 },
+				{ 0.0, 	0.8254, 	0.5873 },
+				{ 0.0, 	0.8413, 	0.5794 },
+				{ 0.0, 	0.8571, 	0.5714 },
+				{ 0.0, 	0.873, 	0.5635 },
+				{ 0.0, 	0.8889, 	0.5556 },
+				{ 0.0, 	0.9048, 	0.5476 },
+				{ 0.0, 	0.9206, 	0.5397 },
+				{ 0.0, 	0.9365, 	0.5317 },
+				{ 0.0, 	0.9524, 	0.5238 },
+				{ 0.0, 	0.9683, 	0.5159 },
+				{ 0.0, 	0.9841, 	0.5079 },
+				{ 0.0, 	1.0, 	0.5 }
+			};
+	}	
+//-------------------------------------------------------
+	public void getRGB(double alpha, RGB rgb)
+	{
+
+		double d1,d2,d3;
+		double d1a,d2a,d3a;
+		double d1b,d2b,d3b;
+		int    index1,index2;
+
+		if (alpha==0){
+			d1=d[0][0];
+			d2=d[0][1];
+			d3=d[0][2];
+		}
+		else if (alpha==1){
+			d1=d[rowNumber-1][0];
+			d2=d[rowNumber-1][1];
+			d3=d[rowNumber-1][2];
+		}
+		else{
+			index1=(int)(alpha*(rowNumber-1));
+			index2=index1+1;
+			
+			d1a=d[index1][0];
+			d2a=d[index1][1];
+			d3a=d[index1][2];
+
+			d1b=d[index2][0];
+			d2b=d[index2][1];
+			d3b=d[index2][2];
+
+			d1=(d1a+d1b)/2;
+			d2=(d2a+d2b)/2;
+			d3=(d3a+d3b)/2;
+		}
+	
+		rgb.setR( (float) d1);
+		rgb.setG( (float) d2);
+		rgb.setB( (float) d3);
+	}	
+//-------------------------------------------------------
+} // end class colorMap
+/////////////////////////////////////////////////////////
+class RGB
+{
+	private float R,G,B;
+//-------------------------------------------------------
+	public void setR(float value) {this.R = value;}
+	public void setG(float value) {this.G = value;}
+	public void setB(float value) {this.B = value;}
+	public float getR() { return R;}
+	public float getG() { return G;}
+	public float getB() { return B;}
+//-------------------------------------------------------
+} //end class RGB	
+/////////////////////////////////////////////////////////
Index: /issm/trunk/src/android/ISSM/src/com/example/issm/ISSM.java
===================================================================
--- /issm/trunk/src/android/ISSM/src/com/example/issm/ISSM.java	(revision 14309)
+++ /issm/trunk/src/android/ISSM/src/com/example/issm/ISSM.java	(revision 14310)
@@ -1,26 +1,32 @@
 package com.example.issm;
 
-import java.io.IOException;
-import java.io.InputStream;
 import java.nio.ByteBuffer;
 import java.nio.ByteOrder;
 import java.nio.DoubleBuffer;
-
+import android.opengl.GLSurfaceView;
+import android.os.AsyncTask;
 import android.os.Bundle;
 import android.app.Activity;
-import android.content.res.AssetManager;
-import android.text.TextUtils;
+import android.app.ProgressDialog;
 import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
 import android.view.View;
 import android.view.View.OnClickListener;
+import android.view.animation.AccelerateInterpolator;
+import android.view.animation.Animation;
+import android.view.animation.TranslateAnimation;
 import android.widget.Button;
-import android.widget.EditText;
+import android.widget.FrameLayout;
+import android.widget.ImageButton;
+import android.widget.SeekBar;
+import android.widget.SeekBar.OnSeekBarChangeListener;
 import android.widget.TextView;
-
-
-public class ISSM extends Activity implements OnClickListener 
+import android.widget.Toast;
+import android.widget.ViewFlipper;
+
+
+public class ISSM extends Activity implements OnClickListener
 {
-	private EditText input;
-	private TextView output;
 	private DoubleBuffer buff;
 	private IssmJni issmNative;
@@ -28,62 +34,313 @@
 	private String issmFolder;
 	private int size;
+    private GLSurfaceView mGLView;
+	private FrameLayout frame;
+	private VerticalSeekBar bar;
+	private TextView value;
+	private ColorMap colorMap;
+	private int alpha;
+	private final int MINIMUM = 90;
+	private final int OFFSET = 10;
+	private ViewFlipper viewflipper;
+	private ProgressDialog dialog;
+	private ColorBar colorBar;
+	//------------------------------------------------------------------------------------------------    
     @Override
-  //------------------------------------------------------------------------------------------------    
-    public void onCreate(Bundle savedInstanceState) {
+    public void onCreate(Bundle savedInstanceState)
+    {
         super.onCreate(savedInstanceState);
-        Bundle map = getIntent().getExtras();
+        setContentView(R.layout.main_issm);
+        this.initialize();         
+    }
+  //----------------------------------------------------------------------------------------------
+    private void initialize()
+    {
+    	Bundle map = getIntent().getExtras();
         {
         	if(map!= null)
         	{
-        		mapName = map.getString("map");
         		issmFolder = map.getString("pathToFile");
         	}
         }
-        setContentView(R.layout.activity_issm);
-        this.input  = (EditText) super.findViewById(R.id.input);
-        this.output  = (TextView) super.findViewById(R.id.output);
-        Button button = (Button) super.findViewById(R.id.button1);
-        button.setOnClickListener(this);
+    	alpha = MINIMUM + OFFSET;
+    	frame = (FrameLayout)findViewById(R.id.frame);
+    	viewflipper = (ViewFlipper) findViewById(R.id.flipper);
+        this.bar  = (VerticalSeekBar) findViewById(R.id.seekbar);
+        this.value  = (TextView) super.findViewById(R.id.value);
+        Button solve = (Button) super.findViewById(R.id.solve);
+        solve.setOnClickListener(this);
+        Button back = (Button) super.findViewById(R.id.back);
+        back.setOnClickListener(this);
+        ImageButton gl = (ImageButton) findViewById(R.id.greenland);		
+		gl.setOnClickListener(this);
+		ImageButton art = (ImageButton) findViewById(R.id.antarctica);
+		art.setOnClickListener(this);
+        bar.setOnSeekBarChangeListener(new OnSeekBarChangeListener()
+        {
+                public void onProgressChanged(SeekBar seekBar, int progress,boolean fromUser)
+                {
+	                	
+                        alpha = progress + OFFSET;
+                        value.setText("" + alpha + "%");
+                }
+
+	            @Override
+	            public void onStartTrackingTouch(SeekBar seekBar) {}
+	
+	            @Override
+	            public void onStopTrackingTouch(SeekBar seekBar) {}
+        });
+
+        //load up the ISSM library and create double buffer in java
+        //which later on will be pass for native for allocation.
+        issmNative = new IssmJni();
         
-        //load up the ISSM library and create double buffer in java
-        //which later on will be pass for native allocation.
-        issmNative = new IssmJni();
-        buff = ByteBuffer.allocateDirect(15*8).order(ByteOrder.nativeOrder()).asDoubleBuffer();
-        this.createModel();
+        //set default color map to be HSV
+        this.colorMap = new ColorMap();
+        //create colorBar
+        colorBar = new ColorBar(this);
+        colorBar.setColorMap(colorMap);
     }
 //------------------------------------------------------------------------------------------------    
     public void createModel()
     {
+		String solution_type="DiagnosticSolution";
     	String file = "";
     	if( mapName.equals("greenland"))
 		{
-    		file = "test102.petsc";
-		}
-    	else file = "test102.petsc";
-    	size = issmNative.createISSMModel(issmFolder + file);
-    }
-//------------------------------------------------------------------------------------------------
-    public void fillBuffer()
-    {
-    	issmNative.processBuffer(5,buff);
-    }
- //------------------------------------------------------------------------------------------------   
+    		file = "greenland";
+		}
+    	else file = "antarctica";
+
+    	size = issmNative.createISSMModel(solution_type,issmFolder,file);
+    	buff = ByteBuffer.allocateDirect(size*12*8).order(ByteOrder.nativeOrder()).asDoubleBuffer();
+    }
+//------------------------------------------------------------------------------------------------  
+    public boolean onCreateOptionsMenu(Menu menu) 
+    {
+    	MenuInflater menuInflater = getMenuInflater();
+    	menuInflater.inflate(R.menu.issm_menu,menu);
+    	
+    	return true;
+    }
+//------------------------------------------------------------------------------------------------  
+    //Option Menu that allow user to choose color. 
+   public boolean onOptionsItemSelected(MenuItem item)
+    {
+    	switch (item.getItemId())
+        {
+	        case R.id.menu_about:          
+	            Toast.makeText(ISSM.this, "ISSM Application", Toast.LENGTH_SHORT).show();
+	            return true;
+	 	            
+	        case R.id.cl_autumn:
+	        	colorMap.setAutumn(); colorBar.setColorMap(colorMap);
+	        	drawFigure();
+	        	return true;
+	        
+	        case R.id.cl_bone:
+	        	colorMap.setBone(); colorBar.setColorMap(colorMap);
+	        	drawFigure();
+	        	return true;
+	        
+	        case R.id.cl_cool:
+	        	colorMap.setCool(); colorBar.setColorMap(colorMap);
+	        	drawFigure();
+	        	return true;
+	        	
+	        case R.id.cl_copper:
+	        	colorMap.setCopper(); colorBar.setColorMap(colorMap);
+	        	drawFigure();
+	        	return true;
+	        	
+	        case R.id.cl_gray:
+	        	colorMap.setGray(); colorBar.setColorMap(colorMap);
+	        	drawFigure();
+	        	return true;
+	        
+	        case R.id.cl_hot:
+	        	colorMap.setGray(); colorBar.setColorMap(colorMap);
+	        	drawFigure();
+	        	return true;
+	        
+	        case R.id.cl_hsv:
+	        	colorMap.setDefault(); colorBar.setColorMap(colorMap);
+	        	drawFigure();
+	        	return true;
+	        	
+	        case R.id.cl_jet:
+	        	colorMap.setJet(); colorBar.setColorMap(colorMap);
+	        	drawFigure();
+	        	return true;
+	        	
+	        case R.id.cl_pink:
+	        	colorMap.setPink(); colorBar.setColorMap(colorMap);
+	        	drawFigure();
+	        	return true;
+	        	
+	        case R.id.cl_spring:
+	        	colorMap.setSpring(); colorBar.setColorMap(colorMap);
+	        	drawFigure();
+	        	return true;
+	        	
+	        case R.id.cl_summer:	
+	        	colorMap.setSummer(); colorBar.setColorMap(colorMap);
+	        	drawFigure();
+	        	return true;
+	        	
+	        case R.id.cl_winter:
+	        	colorMap.setWinter();colorBar.setColorMap(colorMap);
+	        	drawFigure();
+	        	return true;
+	        default:
+	        	return super.onOptionsItemSelected(item);
+        }
+    	
+    }
+//   
+   
+//---------------------------------------------------------------------------------   
     public void onClick(View view) 
 	{
-		//factorial method
-		String input = this.input.getText().toString();
-		if(TextUtils.isEmpty(input))
-		{
-			return;
-		}		
-		long resultfromFac = issmNative.fac(Long.parseLong(input));
-		//example of how to fill buffer Native
-		this.fillBuffer();
+    	switch(view.getId())
+    	{
+	    	case R.id.greenland:
+			{
+				mapName= "greenland";
+				viewflipper.setInAnimation(inFromRightAnimation());
+		        viewflipper.setOutAnimation(outToLeftAnimation());
+		        viewflipper.showNext();
+		        //create FemModel in native code and return the size of the model
+		        this.createModel();
+		        break;
+			}
+	    	case R.id.antarctica:
+			{
+				mapName= "antarctica";
+				viewflipper.setInAnimation(inFromRightAnimation());
+		        viewflipper.setOutAnimation(outToLeftAnimation());
+		        viewflipper.showNext();
+		        //create FemModel in native code and return the size of the model
+		        this.createModel();
+		        break;
+			}
+	    	case R.id.back:
+	    	{
+	    		 frame.removeView(mGLView);
+	    		 viewflipper.setInAnimation(inFromLeftAnimation());
+		         viewflipper.setOutAnimation(outToRightAnimation());
+		         viewflipper.showPrevious(); 
+		         break;
+	    	}
+    		case R.id.solve:
+    		{
+    			dialog = new ProgressDialog(view.getContext());
+    			dialog.setCancelable(true);
+    			dialog.setMessage("Loading View. Please Wait ...");
+    			dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
+    			dialog.setProgress(0);
+    			dialog.setMax(100);
+    			new CalculationTask().execute(alpha);
+    			break;
+    		}
+    	}
+	}
+//---------------------------------------------------------------------------------- 
+    public void drawFigure()
+    {
+    	frame.removeAllViews();
+    	mGLView = new MyGLSurfaceView(this, buff, size, colorMap);
+    	frame.addView(mGLView);
+    	//frame.addView(colorBar);
+    }
+//------------------------------------------------------------------------------------
+   //AsyncTask will allow to display while doing some task in the background
+   private class CalculationTask extends AsyncTask<Integer,Integer,Boolean>
+   {
+		@Override
+		protected Boolean doInBackground(Integer... target) 
+		{
+			Thread thread = new Thread()
+			{
+				public void run()
+				{
+					for(int i = 0; i <= 100; i+=5)
+					{
+						try {
+							Thread.sleep(300);
+						} catch (InterruptedException e) {
+							// TODO Auto-generated catch block
+							e.printStackTrace();
+						}
+						publishProgress(i);
+					}
+				}
+			};
+			thread.start();
+			issmNative.solveISSMModel(target[0],buff);
+			return true;
+		}
 		
-		//print result from fac and the first two slot of filled buffer.
-		this.output.setText("Result = " + resultfromFac + "\n" 
-										+ "First slot from buffer:\n" 
-										+ buff.get(0) + " size " +  size);
-
-	}
+		protected void onPreExecute()
+		{
+			super.onPostExecute(null);
+			dialog.show();
+		}
+		protected void onProgressUpdate(Integer ... value)
+		{
+			super.onProgressUpdate();
+			dialog.setProgress(value[0]);
+		}
+		protected void onPostExecute(Boolean result)
+		{
+			super.onPostExecute(result);
+			dialog.dismiss();
+			if(result) drawFigure();
+		}
+	   
+   }
+//----------------------------------------------------------------------------------- 
+    
+    // Below are implementation for the animation between map selection and core computation
+
+	private Animation inFromRightAnimation() {
+
+	Animation inFromRight = new TranslateAnimation(
+	Animation.RELATIVE_TO_PARENT,  +1.0f, Animation.RELATIVE_TO_PARENT,  0.0f,
+	Animation.RELATIVE_TO_PARENT,  0.0f, Animation.RELATIVE_TO_PARENT,   0.0f
+	);
+	inFromRight.setDuration(500);
+	inFromRight.setInterpolator(new AccelerateInterpolator());
+	return inFromRight;
+	}
+	private Animation outToLeftAnimation() {
+	Animation outtoLeft = new TranslateAnimation(
+	  Animation.RELATIVE_TO_PARENT,  0.0f, Animation.RELATIVE_TO_PARENT,  -1.0f,
+	  Animation.RELATIVE_TO_PARENT,  0.0f, Animation.RELATIVE_TO_PARENT,   0.0f
+	);
+	outtoLeft.setDuration(500);
+	outtoLeft.setInterpolator(new AccelerateInterpolator());
+	return outtoLeft;
+	}
+
+	private Animation inFromLeftAnimation() {
+	Animation inFromLeft = new TranslateAnimation(
+	Animation.RELATIVE_TO_PARENT,  -1.0f, Animation.RELATIVE_TO_PARENT,  0.0f,
+	Animation.RELATIVE_TO_PARENT,  0.0f, Animation.RELATIVE_TO_PARENT,   0.0f
+	);
+	inFromLeft.setDuration(500);
+	inFromLeft.setInterpolator(new AccelerateInterpolator());
+	return inFromLeft;
+	}
+	private Animation outToRightAnimation() {
+	Animation outtoRight = new TranslateAnimation(
+	  Animation.RELATIVE_TO_PARENT,  0.0f, Animation.RELATIVE_TO_PARENT,  +1.0f,
+	  Animation.RELATIVE_TO_PARENT,  0.0f, Animation.RELATIVE_TO_PARENT,   0.0f
+	);
+	outtoRight.setDuration(500);
+	outtoRight.setInterpolator(new AccelerateInterpolator());
+	return outtoRight;
+	}
+//-------------------------------------------------------------------------------------------	 
 }
+/////////////////////////////////////////////////////////////////////////////////////////////
Index: /issm/trunk/src/android/ISSM/src/com/example/issm/IssmJni.java
===================================================================
--- /issm/trunk/src/android/ISSM/src/com/example/issm/IssmJni.java	(revision 14309)
+++ /issm/trunk/src/android/ISSM/src/com/example/issm/IssmJni.java	(revision 14310)
@@ -4,7 +4,6 @@
 class IssmJni
 {
-	public native long fac(long n);
-	public native void processBuffer(int alpha, DoubleBuffer buff);
-	public native int createISSMModel(String file);
+	public native void solveISSMModel(double alpha, DoubleBuffer buff);
+	public native int createISSMModel(String solution_type, String absfile, String relfile);
 	static 
 	{
Index: sm/trunk/src/android/ISSM/src/com/example/issm/MapSelection.java
===================================================================
--- /issm/trunk/src/android/ISSM/src/com/example/issm/MapSelection.java	(revision 14309)
+++ 	(revision )
@@ -1,143 +1,0 @@
-package com.example.issm;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-import android.app.Activity;
-import android.os.Bundle;
-import android.os.Environment;
-import android.text.TextUtils;
-import android.util.Log;
-import android.view.Menu;
-import android.view.View;
-import android.widget.Button;
-import android.widget.Toast;
-import android.content.Intent;
-import android.content.SharedPreferences;
-import android.content.res.AssetManager;
-/////////////////////////////////////////////////////////////////////////// 
-public class MapSelection extends Activity
-{
-	ISSM issm = new ISSM();
-	private static final String PREFERENCE_FIRST_RUN = null;
-	private String extStorageDirectory;
-	private String issmFolder;
-//------------------------------------------------------------------------	
-	public void onCreate(Bundle icicle)
-	{
-		super.onCreate(icicle);
-		setContentView(R.layout.activity_mapselection);
-		
-		 SharedPreferences settings = this.getSharedPreferences("ISSM", 0);
-		    boolean firstrun = settings.getBoolean(PREFERENCE_FIRST_RUN, true);
-		    extStorageDirectory = Environment.getExternalStorageDirectory().toString();
-		    
-		    issmFolder = extStorageDirectory + "/ISSM/input_files/";
-		    if (firstrun) 
-		    { // Checks to see if we've ran the application b4
-		        SharedPreferences.Editor e = settings.edit();
-		        e.putBoolean(PREFERENCE_FIRST_RUN, false);
-		        
-		        e.commit();
-		        // If not, run these methods:
-		        SetDirectory(issmFolder);
-		    }
-		    
-	
-		//this button represents greenland and pass signal to issm
-		Button gl = (Button) findViewById(R.id.button1);		
-		gl.setOnClickListener(new View.OnClickListener() 
-		{
-			public void onClick(View v) 
-			{
-				Intent i = new Intent(MapSelection.this, ISSM.class);
-				i.putExtra("map", "greenland");
-				i.putExtra("pathToFile", issmFolder);
-		        startActivity(i);
-			}
-		});
-		
-		//this button represents artarctica and pass signal to issm
-		Button art = (Button) findViewById(R.id.button2);
-		art.setOnClickListener(new View.OnClickListener() 
-		{
-			public void onClick(View v) 
-			{
-				Intent i = new Intent(MapSelection.this, ISSM.class);
-				i.putExtra("map", "antarctica");
-				i.putExtra("pathToFile", issmFolder);
-		        startActivity(i);
-			}
-		});
-	}
-//------------------------------------------------------------------------
-	private void SetDirectory(String directory) 
-	{
-	    if (android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED)) 
-	    {
-	    	System.out.println(issmFolder);
-	        File txtDirectory = new File(issmFolder);
-	        
-	        // Check and create directory in SDcard
-	        if(!txtDirectory.exists())
-	        {
-	        	txtDirectory.mkdirs();
-	        	System.out.println("making directory");
-	        }
-	        CopyAssets(); // Then run the method to copy the file.
-
-	    } 
-	    else if (android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED_READ_ONLY)) 
-	    {
-	    	Toast toast = Toast.makeText(this.getApplicationContext(), "Memory is not mounted to device", Toast.LENGTH_LONG);
-	    	toast.show();
-	    }
-
-	}
-//----------------------------------------------------------------------------
-	/**
-	 * -- Copy the file from the assets folder to the sdCard
-	 * ===========================================================
-	 **/
-		private void CopyAssets() 
-		{
-		    AssetManager assetManager = getAssets();
-		    String[] files = null;
-		    try {
-		        files = assetManager.list("Map");
-		    } catch (IOException e) {
-		        Log.e("tag", e.getMessage());
-		    }
-		    for (int i = 0; i < files.length; i++) {
-		        InputStream in = null;
-		        OutputStream out = null;
-		        try {
-		            in = assetManager.open("Map/"+files[i]);
-		            out = new FileOutputStream(issmFolder + files[i]);
-		            copyFile(in, out);
-		            in.close();
-		            in = null;
-		            out.flush();
-		            out.close();
-		            out = null;
-		        } catch (Exception e) {
-		            Log.e("tag", e.getMessage());
-		        }
-		    }
-		    System.out.println("Done");
-		}
-//----------------------------------------------------------------------------
-		private void copyFile(InputStream in, OutputStream out) throws IOException 
-		{
-		    byte[] buffer = new byte[1024];
-		    int read;
-		    while ((read = in.read(buffer)) != -1) {
-		        out.write(buffer, 0, read);
-		    }
-		}
-//----------------------------------------------------------------------------
-}
-/////////////////////////////////////////////////////////////////////////// 
Index: /issm/trunk/src/android/ISSM/src/com/example/issm/MenuPage.java
===================================================================
--- /issm/trunk/src/android/ISSM/src/com/example/issm/MenuPage.java	(revision 14310)
+++ /issm/trunk/src/android/ISSM/src/com/example/issm/MenuPage.java	(revision 14310)
@@ -0,0 +1,88 @@
+package com.example.issm;
+
+import android.app.Activity;
+import android.net.Uri;
+import android.os.Bundle;
+import android.view.Gravity;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.widget.Button;
+import android.widget.ImageButton;
+import android.widget.PopupWindow;
+import android.content.Intent;
+/////////////////////////////////////////////////////////////////////////// 
+public class MenuPage extends Activity
+{
+	ISSM issm = new ISSM();
+	private String issmFolder; 
+//------------------------------------------------------------------------	
+	public void onCreate(Bundle icicle)
+	{
+		super.onCreate(icicle);
+		setContentView(R.layout.menupage);		
+		Bundle map = getIntent().getExtras();
+        {
+        	if(map!= null)
+        	{
+        		issmFolder = map.getString("pathToFile");
+        	}
+        }
+        //start the core implementation of ISSM
+	    ImageButton start = (ImageButton) findViewById(R.id.start);		
+		start.setOnClickListener(new View.OnClickListener() 
+		{
+			public void onClick(View v) 
+			{
+				Intent i = new Intent(MenuPage.this, ISSM.class);
+				i.putExtra("pathToFile", issmFolder);
+		        startActivity(i);
+			}
+		});
+		// navigate to youtube video
+		ImageButton video = (ImageButton) findViewById(R.id.video);		
+		video.setOnClickListener(new View.OnClickListener() 
+		{
+			public void onClick(View v) 
+			{
+				String url = "http://www.youtube.com/watch?v=KlDO0C8r_ws";
+				Intent i = new Intent(Intent.ACTION_VIEW);
+				i.setData(Uri.parse(url));
+		        startActivity(i);
+			}
+		});
+		// pop up a text box that contains information about ISSM
+		final ImageButton intro = (ImageButton) findViewById(R.id.intro);	
+		intro.setOnClickListener(new View.OnClickListener() 
+		{
+			public void onClick(View v)
+			{
+				LayoutInflater layoutInflater = (LayoutInflater)getBaseContext().getSystemService(LAYOUT_INFLATER_SERVICE);  
+				View popupView = layoutInflater.inflate(R.layout.popuptext, null);  
+				final PopupWindow popupWindow = new PopupWindow( popupView, 400,600, true);
+				popupWindow.showAtLocation(popupView, Gravity.CENTER, 0, 0);
+				Button dismiss = (Button)popupView.findViewById(R.id.dismiss);
+	            dismiss.setOnClickListener(new Button.OnClickListener()
+	            {
+	            	public void onClick(View v)
+	            	{
+	            		popupWindow.dismiss();
+	            	}
+	            });
+			}
+		});
+		//navigate to website
+		ImageButton visitus = (ImageButton) findViewById(R.id.visitus);		
+		visitus.setOnClickListener(new View.OnClickListener() 
+		{
+			public void onClick(View v) 
+			{
+				String url = "http://issm.jpl.nasa.gov/";
+				Intent i = new Intent(Intent.ACTION_VIEW);
+				i.setData(Uri.parse(url));
+		        startActivity(i);
+			}
+		});
+	}
+//-------------------------------------------------------------------------------------	
+}
+///////////////////////////////////////////////////////////////////////////////////////// 
Index: /issm/trunk/src/android/ISSM/src/com/example/issm/MyGLRenderer.java
===================================================================
--- /issm/trunk/src/android/ISSM/src/com/example/issm/MyGLRenderer.java	(revision 14310)
+++ /issm/trunk/src/android/ISSM/src/com/example/issm/MyGLRenderer.java	(revision 14310)
@@ -0,0 +1,349 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.example.issm;
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+import java.nio.FloatBuffer;
+
+import javax.microedition.khronos.egl.EGLConfig;
+import javax.microedition.khronos.opengles.GL10;
+
+import android.opengl.GLES20;
+import android.opengl.GLSurfaceView;
+import android.opengl.Matrix;
+
+public class MyGLRenderer implements GLSurfaceView.Renderer 
+{
+	public volatile float mAngle;
+	public volatile float mAngleX; /* NEW STUFF*/
+	public volatile float mAngleY;
+	
+	
+    private FloatBuffer[] triangleVert;
+	
+	private float[][] mScaleMatrix;  // scaling /* NEW STUFF*/
+	private float[][] mRotXMatrix;	 // rotation x 
+	private float[][] mRotYMatrix;	 // rotation x
+
+	/**
+	 * Store the model matrix. This matrix is used to move models from object space (where each model can be thought
+	 * of being located at the center of the universe) to world space.
+	 */
+	private float[][] mModelMatrix;
+	
+	/**
+	 * Store the view matrix. This can be thought of as our camera. This matrix transforms world space to eye space;
+	 * it positions things relative to our eye.
+	 */
+	private float[][] mViewMatrix;
+
+	/** Store the projection matrix. This is used to project the scene onto a 2D viewport. */
+	private float[][] mProjectionMatrix;
+
+	/** Allocate storage for the final combined matrix. This will be passed into the shader program. */
+	private float[][] mMVPMatrix;
+
+	/** This will be used to pass in the transformation matrix. */
+	private int mMatrixHandle;
+	
+    private float[][] triangleData2DArr;
+    
+    private int mPositionHandle;
+    
+    private int mColorHandle;
+    
+	/** How many bytes per float. */
+    private final int mBytesPerFloat = 4;
+
+    /** How many elements per vertex. */
+    private final int mStrideBytes = 7 * mBytesPerFloat;
+
+    /** Offset of the position data. */
+    private final int mPositionOffset = 0;
+
+    /** Size of the position data in elements. */
+    private final int mPositionDataSize = 3;
+
+    /** Offset of the color data. */
+    private final int mColorOffset = 3;
+
+    /** Size of the color data in elements. */
+    private final int mColorDataSize = 4;	
+
+	// scaling /* NEW STUFF*/
+	float scaleX = 1.0f;
+	float scaleY = 1.0f;
+	float scaleZ = 1.0f;
+
+	public float eyeX;
+	public float eyeY;
+	public float eyeZ;
+	
+    public MyGLRenderer(float[][] vertices)
+    {	
+    	triangleData2DArr = new float[vertices.length][21];
+ 
+    	triangleVert = new FloatBuffer[vertices.length];
+    	mScaleMatrix  = new float[triangleVert.length][16];  // scaling  /* NEW STUFF*/
+    	mRotXMatrix  = new float[triangleVert.length][16];	 // rotation x
+    	mRotYMatrix  = new float[triangleVert.length][16];	 // rotation x
+    	
+    	for (int i = 0; i < vertices.length; i++)
+    	{
+    		for (int j = 0; j < 21; j++)
+    			triangleData2DArr[i][j] = vertices[i][j]; 
+    	}
+	    
+	    // initialize vertex byte buffer for shape coordinates
+    	for (int i = 0; i < vertices.length; i++)
+    	{
+    		triangleVert[i] = ByteBuffer.allocateDirect(triangleData2DArr[i].length * mBytesPerFloat)
+    													.order(ByteOrder.nativeOrder()).asFloatBuffer();
+    		triangleVert[i].put(triangleData2DArr[i]).position(0);
+    	}
+    }
+    
+	public void changeScale(float scale) /* NEW STUFF*/
+	{
+		if (scaleX * scale > 3.0f) return;
+		  scaleX *= scale; scaleY *= scale; scaleZ *= scale;
+		
+		//scaleX += scale;scaleY += scale;scaleZ += scale;
+		//scaleX = scale;scaleY = scale;scaleZ = scale;
+		//scaleX /= 100;scaleY /= 100;scaleZ /= 100;
+	}
+
+	public void defaultScale() 
+	{
+		scaleX = 1f;
+		scaleY = 1f;
+		scaleZ = 1f;
+	}
+	
+    public void onSurfaceCreated(GL10 unused, EGLConfig config) 
+    {
+        // Set the background frame color
+        GLES20.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
+        
+		// Position the eye behind the origin.
+		eyeX = 0.0f;
+		eyeY = 0.0f;
+		eyeZ = 1.5f;
+
+		// We are looking toward the distance
+		final float lookX = 0.0f;
+		final float lookY = 0.0f;
+		final float lookZ = -5.0f;
+
+		// Set our up vector. This is where our head would be pointing were we holding the camera.
+		final float upX = 0.0f;
+		final float upY = 1.0f;
+		final float upZ = 0.0f;
+
+		// Set the view matrix. This matrix can be said to represent the camera position.
+		// NOTE: In OpenGL 1, a ModelView matrix is used, which is a combination of a model and
+		// view matrix. In OpenGL 2, we can keep track of these matrices separately if we choose.
+		mViewMatrix = new float[triangleVert.length][16];
+		
+		
+		for (int i = 0; i < triangleVert.length; i++)
+			Matrix.setLookAtM(mViewMatrix[i], 0, eyeX, eyeY, eyeZ, lookX, lookY, lookZ, upX, upY, upZ);
+			//Matrix.setLookAtM(mVMatrix[i], 0, 0, 0, -5.0f, 0.0f, 0f, 0f, 0f, 1.0f, 0.0f);
+        
+		final String vertexShader =
+				"uniform mat4 u_MVPMatrix;      \n"		// A constant representing the combined model/view/projection matrix.
+			  + "attribute vec4 a_Position;     \n"		// Per-vertex position information we will pass in.
+			  + "attribute vec4 a_Color;        \n"		// Per-vertex color information we will pass in.			  
+			  + "varying vec4 v_Color;          \n"		// This will be passed into the fragment shader.
+			  + "void main()                    \n"		// The entry point for our vertex shader.
+			  + "{                              \n"
+			  + "   v_Color = a_Color;          \n"		// Pass the color through to the fragment shader. 
+			  
+			  											// It will be interpolated across the triangle.
+			  + "   gl_Position = u_MVPMatrix   \n" 	// gl_Position is a special variable used to store the final position.
+			  + "               * a_Position;   \n"     // Multiply the vertex by the matrix to get the final point in 			                                            			 
+			  + "}                              \n";    // normalized screen coordinates.
+
+			final String fragmentShader =
+				"precision mediump float;       \n"		// Set the default precision to medium. We don't need as high of a											// precision in the fragment shader.				
+			  + "varying vec4 v_Color;          \n"		// This is the color from the vertex shader interpolated across the 
+			  											// triangle per fragment.			  
+			  + "void main()                    \n"		// The entry point for our fragment shader.
+			  + "{                              \n"
+			  + "   gl_FragColor = v_Color;     \n"		// Pass the color directly through the pipeline.		  
+			  + "}                              \n";												
+
+    	   
+        int vertexShaderHandle = GLES20.glCreateShader(GLES20.GL_VERTEX_SHADER);
+		// Pass in the shader source.
+		GLES20.glShaderSource(vertexShaderHandle, vertexShader);
+
+		// Compile the shader.
+		GLES20.glCompileShader(vertexShaderHandle);
+
+		// Get the compilation status.
+		final int[] compileStatus1 = new int[1];
+		GLES20.glGetShaderiv(vertexShaderHandle, GLES20.GL_COMPILE_STATUS, compileStatus1, 0);
+
+		// If the compilation failed, delete the shader.
+		if (compileStatus1[0] == 0) 
+		{				
+			GLES20.glDeleteShader(vertexShaderHandle);
+			vertexShaderHandle = 0;
+		}
+		
+         
+    	int fragmentShaderHandle = GLES20.glCreateShader(GLES20.GL_FRAGMENT_SHADER);
+		// Pass in the shader source.
+		GLES20.glShaderSource(fragmentShaderHandle, fragmentShader);
+
+		// Compile the shader.
+		GLES20.glCompileShader(fragmentShaderHandle);
+
+		// Get the compilation status.
+		final int[] compileStatus2 = new int[1];
+		GLES20.glGetShaderiv(fragmentShaderHandle, GLES20.GL_COMPILE_STATUS, compileStatus2, 0);
+
+		// If the compilation failed, delete the shader.
+		if (compileStatus2[0] == 0) 
+		{				
+			GLES20.glDeleteShader(fragmentShaderHandle);
+			fragmentShaderHandle = 0;
+		}
+
+        
+        int mProgram = GLES20.glCreateProgram();
+		// Bind the vertex shader to the program.
+		GLES20.glAttachShader(mProgram, vertexShaderHandle);			
+
+		// Bind the fragment shader to the program.
+		GLES20.glAttachShader(mProgram, fragmentShaderHandle);
+
+		// Bind attributes
+		GLES20.glBindAttribLocation(mProgram, 0, "a_Position");
+		GLES20.glBindAttribLocation(mProgram, 1, "a_Color");
+		
+		// Link the two shaders together into a program.
+		GLES20.glLinkProgram(mProgram);
+
+		// Get the link status.
+		final int[] linkStatus = new int[1];
+		GLES20.glGetProgramiv(mProgram, GLES20.GL_LINK_STATUS, linkStatus, 0);
+
+		// If the link failed, delete the program.
+		if (linkStatus[0] == 0) 
+		{				
+			GLES20.glDeleteProgram(mProgram);
+			mProgram = 0;
+		}
+		
+		for (int i = 0; i < triangleVert.length; i++)
+		{
+			mMatrixHandle = GLES20.glGetUniformLocation(mProgram, "u_MVPMatrix");       
+	        mPositionHandle = GLES20.glGetAttribLocation(mProgram, "a_Position");
+	        mColorHandle = GLES20.glGetAttribLocation(mProgram, "a_Color");
+		}
+        
+        // Add program to OpenGL environment
+        GLES20.glUseProgram(mProgram);
+    }
+    public void onSurfaceChanged(GL10 unused, int width, int height) 
+    {
+        // Adjust the viewport based on geometry changes,
+        // such as screen rotation
+        GLES20.glViewport(0, 0, width, height);
+        
+		// Create a new perspective projection matrix. The height will stay the same
+		// while the width will vary as per aspect ratio.
+		final float ratio = (float) width / height;
+		
+		mProjectionMatrix = new float[triangleVert.length][16];
+		for (int i = 0; i < triangleVert.length; i++)
+			Matrix.frustumM(mProjectionMatrix[i], 0, -ratio*0.7f, ratio*1.0f, 0.0f, 1.0f, 1.0f, 14f);
+    }
+    
+    public void onDrawFrame(GL10 glUnused) 
+    {
+    	// Draw background color
+    	GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
+    	
+    	mModelMatrix = new float[triangleVert.length][16];
+        // Draw the triangle facing straight on.
+    	for (int i = 0; i < triangleVert.length; i++)
+    	{
+    		//Matrix.setIdentityM(mModelMatrix[i], 0); /* NEW STUFF*/
+    		Matrix.setIdentityM(mScaleMatrix[i], 0);
+    		Matrix.scaleM(mScaleMatrix[i], 0, scaleX, scaleY, scaleZ);
+    		
+    		// Rotation along x
+    		Matrix.setRotateM(mRotXMatrix[i], 0, this.mAngleY, -1.0f, 0.0f, 0.0f);
+    		Matrix.setRotateM(mRotYMatrix[i], 0, this.mAngleX, 0.0f, 1.0f, 0.0f); /* NEW STUFF*/
+    		
+    		Matrix.setLookAtM(mViewMatrix[i], 0, eyeX, eyeY, eyeZ, 0.0f, 0.0f, -5.0f, 0.0f, 1.0f, 0.0f); 
+    	
+    	}
+    		
+    	mMVPMatrix = new float[triangleVert.length][16];
+    	draw(triangleVert); 
+
+    }
+
+    private void draw(final FloatBuffer[] aTriangleBuffer)
+    {
+    	for (int i = 0; i < aTriangleBuffer.length; i++)
+    	{
+	        // Pass in the position information
+	        aTriangleBuffer[i].position(mPositionOffset);
+	        GLES20.glVertexAttribPointer(mPositionHandle, mPositionDataSize, GLES20.GL_FLOAT, false,
+	                				     mStrideBytes, aTriangleBuffer[i]);
+	        
+	        GLES20.glEnableVertexAttribArray(mPositionHandle);
+	     
+	        
+	        // Pass in the color information
+	        aTriangleBuffer[i].position(mColorOffset);
+	        GLES20.glVertexAttribPointer(mColorHandle, mColorDataSize, GLES20.GL_FLOAT, false,
+	                					 mStrideBytes, aTriangleBuffer[i]);
+	        
+	        GLES20.glEnableVertexAttribArray(mColorHandle);
+	        
+	        Matrix.setRotateM(mRotXMatrix[i], 0, this.mAngleY, -1.0f, 0.0f, 0.0f); /* NEW STUFF*/
+    		Matrix.setRotateM(mRotYMatrix[i], 0, this.mAngleX, 0.0f, 1.0f, 0.0f);
+
+    		float tempMatrix[][] = new float[triangleVert.length][16]; /* NEW STUFF*/
+    		Matrix.multiplyMM(tempMatrix[i], 0, mRotYMatrix[i], 0, mRotXMatrix[i], 0);
+    		Matrix.multiplyMM(mModelMatrix[i], 0, mScaleMatrix[i], 0, tempMatrix[i], 0);
+
+			// This multiplies the view matrix by the model matrix, and stores the result in the MVP matrix
+	        // (which currently contains model * view).
+	        Matrix.multiplyMM(mMVPMatrix[i], 0, mViewMatrix[i], 0, mModelMatrix[i], 0);
+	        
+	        // This multiplies the modelview matrix by the projection matrix, and stores the result in the MVP matrix
+	        // (which now contains model * view * projection).
+	        Matrix.multiplyMM(mMVPMatrix[i], 0, mProjectionMatrix[i], 0, mMVPMatrix[i], 0);
+	        
+	        GLES20.glUniformMatrix4fv(mMatrixHandle, 1, false, mMVPMatrix[i], 0);   
+
+	        // Draw the triangle
+	        GLES20.glDrawArrays(GLES20.GL_TRIANGLES, 0, 3);
+	        
+	        // Disable vertex array
+	        GLES20.glDisableVertexAttribArray(mPositionHandle);
+    	}
+    }
+
+}
Index: /issm/trunk/src/android/ISSM/src/com/example/issm/MyGLSurfaceView.java
===================================================================
--- /issm/trunk/src/android/ISSM/src/com/example/issm/MyGLSurfaceView.java	(revision 14310)
+++ /issm/trunk/src/android/ISSM/src/com/example/issm/MyGLSurfaceView.java	(revision 14310)
@@ -0,0 +1,229 @@
+package com.example.issm;
+
+import java.nio.DoubleBuffer;
+import java.util.Random;
+
+import android.content.Context;
+import android.opengl.GLSurfaceView;
+import android.util.FloatMath;
+import android.view.MotionEvent;
+
+
+class MyGLSurfaceView extends GLSurfaceView 
+{
+	private MyGLRenderer mRend;
+	private DoubleBuffer db;
+	private int size;
+	double vmax = 0, vmin=0;
+	final int firstVelocity = 9; 
+	ColorMap colorMap;
+	
+	// pinch to zoom
+	float oldDist = 100.0f;
+	float newDist;
+	
+	int mode = 0;
+    public MyGLSurfaceView(Context context, DoubleBuffer db, int size, ColorMap colorMap) 
+    {
+        super(context);
+        // Create an OpenGL ES 2.0 context.
+        setEGLContextClientVersion(2);
+        this.db = db;
+        this.size = size;
+        this.colorMap = colorMap;
+        vmin = db.get(firstVelocity);
+        findMinMaxVelocity(); 
+        intialize();
+    }
+    private void intialize()
+    {
+        final int MAX_VERTICES = 21;
+        float f[][] = new float[size][MAX_VERTICES];
+        //indexes prefer to velocity at each vertices of triangles.
+        double alpha1, alpha2, alpha3;
+		float  xmin,xmax,ymin,ymax;
+        final int XSCALE_FACTOR = 1;
+        final int YSCALE_FACTOR = 2;
+        RGB rgb = new RGB();
+
+		for (int i = 0; i < size; i++) {
+				f[i][0] = (float)db.get(12*i+0);
+				f[i][1] = (float)db.get(12*i+1);
+				f[i][2] = (float)db.get(12*i+2);
+				f[i][7] = (float)db.get(12*i+3);
+				f[i][8] = (float)db.get(12*i+4);
+				f[i][9] = (float)db.get(12*i+5);
+				f[i][14] = (float)db.get(12*i+6);
+				f[i][15] = (float)db.get(12*i+7);
+				f[i][16] = (float)db.get(12*i+8);
+				
+				f[i][6] = 1.0f;
+				f[i][13] = 1.0f;
+				f[i][20] = 1.0f;
+				
+				alpha1 = getAlphaColor(db.get(12*i+9));
+				alpha2 = getAlphaColor(db.get(12*i+10));
+				alpha3 = getAlphaColor(db.get(12*i+11));
+				
+				colorMap.getRGB(alpha1, rgb);
+				float r1 = rgb.getR();
+				float g1 = rgb.getG();
+				float b1 = rgb.getB();
+				
+				colorMap.getRGB(alpha2, rgb);
+				float r2 = rgb.getR();
+				float g2 = rgb.getG();
+				float b2 = rgb.getB();
+				
+				colorMap.getRGB(alpha3, rgb);
+				float r3 = rgb.getR();
+				float g3 = rgb.getG();
+				float b3 = rgb.getB();
+				
+				
+				f[i][3] = r1;
+				f[i][4] = g1;
+				f[i][5] = b1;
+				
+				f[i][10] = r2;
+				f[i][11] = g2;
+				f[i][12] = b2;
+				
+				f[i][17] = r3;
+				f[i][18] = g3;
+				f[i][19] = b3;
+
+		}
+
+		/*scale coordinates: */
+		xmin=0; ymin=0; xmax=0; ymax=0;
+
+		for (int i = 0; i < size; i++) {
+			if (f[i][0]<xmin) xmin=f[i][0];
+			if (f[i][0]>xmax) xmax=f[i][0];
+
+			if (f[i][1]<ymin) ymin=f[i][1];
+			if (f[i][1]>ymax) ymax=f[i][1];
+		}
+		
+		for (int i = 0; i < size; i++) {
+				f[i][0] =  (f[i][0]-xmin)/(xmax-xmin)*XSCALE_FACTOR;
+				f[i][1] =  (f[i][1]-ymin)/(ymax-ymin)*YSCALE_FACTOR;
+				f[i][7] =  (f[i][7]-xmin)/(xmax-xmin)*XSCALE_FACTOR;
+				f[i][8] =  (f[i][8]-ymin)/(ymax-ymin)*YSCALE_FACTOR;
+				f[i][14] =  (f[i][14]-xmin)/(xmax-xmin)*XSCALE_FACTOR;
+				f[i][15] =  (f[i][15]-ymin)/(ymax-ymin)*YSCALE_FACTOR;
+		}
+		
+		//Random r = new Random();
+		//float z1,z2,z3;
+		for(int i = 0 ; i <size; i++)
+		{
+			//r.nextFloat() will generate random from 0-1
+			
+			System.out.println(f[i][2]);
+			System.out.println(f[i][9]);
+			System.out.println(f[i][16]);
+			
+			//System.out.println("z = " + z1 + "," + z2 + "," + z3);
+			//System.out.println("x = " + f[i][1] + "," + f[i][7] + "," + f[i][14]);
+		}
+			
+    	mRend = new MyGLRenderer(f);
+    	// Set the Renderer for drawing on the GLSurfaceView
+        setRenderer(mRend);
+
+        // Render the view only when there is a change in the drawing data
+        setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
+    }
+    private void findMinMaxVelocity()
+    {
+    	for(int i = 0; i < size*12; i++)
+    	{
+    		if(i%12==9 || i%12==10 ||i%12==11 )
+    		{
+    			if (db.get(i) <  vmin) vmin = db.get(i);
+    			if (db.get(i) >= vmax) vmax = db.get(i);
+    		}
+    		else continue; 
+    	}
+    	
+    }  
+    private double getAlphaColor(double velocity)
+    {
+    	return (velocity-vmin)/(vmax-vmin);
+    }
+    
+    private final float TOUCH_SCALE_FACTOR = 180.0f / 320;
+    private float mPreviousX;
+    
+    private float mPreviousY;
+ // touch events
+ 	private final int NONE = 0;
+ 	private final int DRAG = 0;
+ 	private final int ZOOM = 0;
+    @Override
+    public boolean onTouchEvent(MotionEvent e) /* NEW STUFF*/
+	{
+		float x = e.getX();
+		float y = e.getY();
+		switch (e.getAction()) {
+			case MotionEvent.ACTION_DOWN:			// one touch: drag
+		      mode = DRAG;
+		      //mRend.eyeX = e.getX();
+		      //mRend.eyeY = e.getY;
+		      break;
+		      
+			case MotionEvent.ACTION_POINTER_DOWN:	// two touches: zoom
+				oldDist = spacing(e);
+				if (oldDist > 10.0f) 
+					mode = ZOOM; // zoom
+				break;
+				
+			case MotionEvent.ACTION_UP:		// no mode
+				mode = NONE;
+				oldDist = 100.0f;
+				break;
+				
+			case MotionEvent.ACTION_POINTER_UP:		// no mode
+				mode = NONE;
+				oldDist = 100.0f;
+				break;
+				
+			case MotionEvent.ACTION_MOVE:						// rotation
+				if (e.getPointerCount() > 1 && mode == ZOOM) 
+				{
+					newDist = spacing(e);
+					if (newDist > 10.0f) {
+						float scale = newDist/oldDist; // scale
+						
+						// scale in the renderer
+						mRend.changeScale(scale);
+						oldDist = newDist;
+					}
+				}
+				else if (mode == DRAG)
+				{
+					float dx = x - mPreviousX;
+					float dy = y - mPreviousY;
+					
+					mRend.mAngleX += dx * TOUCH_SCALE_FACTOR;
+					mRend.mAngleY += dy * TOUCH_SCALE_FACTOR;
+
+					requestRender();
+				}
+				break;
+		}
+		mPreviousX = x;
+		mPreviousY = y;
+		return true;
+	}
+	
+	private float spacing(MotionEvent event) /* NEW STUFF*/
+	{
+		float x = event.getX(0) - event.getX(1);
+		float y = event.getY(0) - event.getY(1);
+		return FloatMath.sqrt(x * x + y * y);
+	}
+}
+
Index: /issm/trunk/src/android/ISSM/src/com/example/issm/SplashScreen.java
===================================================================
--- /issm/trunk/src/android/ISSM/src/com/example/issm/SplashScreen.java	(revision 14310)
+++ /issm/trunk/src/android/ISSM/src/com/example/issm/SplashScreen.java	(revision 14310)
@@ -0,0 +1,156 @@
+package com.example.issm;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import android.app.Activity;
+import android.os.AsyncTask;
+import android.os.Bundle;
+import android.os.Environment;
+import android.util.Log;
+import android.view.animation.Animation;
+import android.view.animation.AnimationUtils;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.Toast;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.content.res.AssetManager;
+/////////////////////////////////////////////////////////////////////////// 
+public class SplashScreen extends Activity
+{
+	MenuPage mp = new MenuPage();
+	private static final String PREFERENCE_FIRST_RUN = null;
+	private String extStorageDirectory;
+	private String issmFolder; 
+	SharedPreferences settings;
+//------------------------------------------------------------------------	
+	public void onCreate(Bundle icicle)
+	{
+		super.onCreate(icicle);
+		setContentView(R.layout.splashscreen);		
+	    settings = this.getSharedPreferences("MenuPage", 0);
+	    boolean firstrun = settings.getBoolean(PREFERENCE_FIRST_RUN, true);
+	    extStorageDirectory = Environment.getExternalStorageDirectory().toString();
+	    issmFolder = extStorageDirectory + "/ISSM/input_files/";
+
+	    new CopyDataTask().execute(firstrun);    
+	}
+//-------------------------------------------------------------------------------------------
+	//Start the splashscreen at beginning while transferring 
+	//data file from Assets folder to SDcard
+	private class CopyDataTask extends AsyncTask<Boolean,Void,Boolean>
+	   {
+			@Override
+			protected Boolean doInBackground(Boolean... target) 
+			{
+				StartAnimations();
+				try {
+					Thread.sleep(3000);
+				} catch (InterruptedException e1) {
+					// TODO Auto-generated catch block
+					e1.printStackTrace();
+				}
+				if(target[0] = false)
+				{
+			        SharedPreferences.Editor e = settings.edit();
+			        e.putBoolean(PREFERENCE_FIRST_RUN, false);
+			        
+			        e.commit();
+			        // If not, run these methods:
+			        SetDirectory(issmFolder);
+				}
+				return true;
+			}
+			protected void onPostExecute(Boolean result)
+			{
+				Intent i = new Intent(SplashScreen.this, MenuPage.class);
+				i.putExtra("pathToFile", issmFolder);
+		        startActivity(i);
+			}
+	   }
+//-------------------------------------------------------------------------------------------
+	private void SetDirectory(String directory) 
+	{
+	    if (android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED)) 
+	    {
+	    	System.out.println(issmFolder);
+	        File txtDirectory = new File(issmFolder);
+	        
+	        // Check and create directory in SDcard
+	        if(!txtDirectory.exists())
+	        {
+	        	txtDirectory.mkdirs();
+	        	System.out.println("making directory");
+	        }
+	        CopyAssets(); // Then run the method to copy the file.
+
+	    } 
+	    else if (android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED_READ_ONLY)) 
+	    {
+	    	Toast toast = Toast.makeText(this.getApplicationContext(), "Memory is not mounted to device", Toast.LENGTH_LONG);
+	    	toast.show();
+	    }
+
+	}
+//----------------------------------------------------------------------------
+	/**
+	 * -- Copy the file from the assets folder to the sdCard
+	 * ===========================================================
+	 **/
+		private void CopyAssets() 
+		{
+		    AssetManager assetManager = getAssets();
+		    String[] files = null;
+		    try {
+		        files = assetManager.list("Map");
+		    } catch (IOException e) {
+		        Log.e("tag", e.getMessage());
+		    }
+		    for (int i = 0; i < files.length; i++) {
+		        InputStream in = null;
+		        OutputStream out = null;
+		        try {
+		            in = assetManager.open("Map/"+files[i]);
+		            out = new FileOutputStream(issmFolder + files[i]);
+		            copyFile(in, out);
+		            in.close();
+		            in = null;
+		            out.flush();
+		            out.close();
+		            out = null;
+		        } catch (Exception e) {
+		            Log.e("tag", e.getMessage());
+		        }
+		    }
+		    System.out.println("Done");
+		}
+//----------------------------------------------------------------------------
+		private void copyFile(InputStream in, OutputStream out) throws IOException 
+		{
+		    byte[] buffer = new byte[1024];
+		    int read;
+		    while ((read = in.read(buffer)) != -1) {
+		        out.write(buffer, 0, read);
+		    }
+		}
+//----------------------------------------------------------------------------
+		 private void StartAnimations() 
+		 {
+		        Animation anim = AnimationUtils.loadAnimation(this, R.anim.alpha);
+		        anim.reset();
+		        LinearLayout l=(LinearLayout) findViewById(R.id.lin_lay);
+		        l.clearAnimation();
+		        l.startAnimation(anim);
+		 
+		        anim = AnimationUtils.loadAnimation(this, R.anim.translate);
+		        anim.reset();
+		        ImageView iv = (ImageView) findViewById(R.id.logo);
+		        iv.clearAnimation();
+		        iv.startAnimation(anim);
+		    }
+//-------------------------------------------------------------------------------		 
+}
+////////////////////////////////////////////////////////////////////////////////// 
Index: /issm/trunk/src/android/ISSM/src/com/example/issm/VerticalSeekBar.java
===================================================================
--- /issm/trunk/src/android/ISSM/src/com/example/issm/VerticalSeekBar.java	(revision 14310)
+++ /issm/trunk/src/android/ISSM/src/com/example/issm/VerticalSeekBar.java	(revision 14310)
@@ -0,0 +1,60 @@
+package com.example.issm;
+
+import android.content.Context;
+import android.graphics.Canvas;
+import android.util.AttributeSet;
+import android.view.MotionEvent;
+import android.widget.SeekBar;
+
+public class VerticalSeekBar extends SeekBar {
+
+	private final int MAX_SIZE = 500;
+    public VerticalSeekBar(Context context) {
+        super(context);
+    }
+
+    public VerticalSeekBar(Context context, AttributeSet attrs, int defStyle) {
+        super(context, attrs, defStyle);
+    }
+
+    public VerticalSeekBar(Context context, AttributeSet attrs) {
+        super(context, attrs);
+    }
+
+    protected void onSizeChanged(int w, int h, int oldw, int oldh) {
+        super.onSizeChanged(h, w, oldh, oldw);
+    }
+
+    @Override
+    protected synchronized void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+        super.onMeasure(heightMeasureSpec, widthMeasureSpec);
+        setMeasuredDimension(getMeasuredHeight(), getMeasuredWidth());
+    }
+
+    protected void onDraw(Canvas c) {
+    	c.rotate(-90);
+        c.translate(-getHeight(),0);
+        super.onDraw(c);
+    }
+
+    @Override
+    public boolean onTouchEvent(MotionEvent event) {
+        if (!isEnabled()) {
+            return false;
+        }
+        int i = 0;
+        switch (event.getAction()) {
+            case MotionEvent.ACTION_DOWN:
+            case MotionEvent.ACTION_MOVE:
+            case MotionEvent.ACTION_UP:
+                i = getMax() - (int) (getMax() * event.getY() / getHeight());
+                setProgress(i);
+                onSizeChanged(getWidth(), getHeight(), 0, 0);
+                break;
+
+            case MotionEvent.ACTION_CANCEL:
+                break;
+        }
+        return true;
+    }
+}
Index: /issm/trunk/src/android/ISSM_Visual/AndroidManifest.xml
===================================================================
--- /issm/trunk/src/android/ISSM_Visual/AndroidManifest.xml	(revision 14309)
+++ /issm/trunk/src/android/ISSM_Visual/AndroidManifest.xml	(revision 14310)
@@ -1,4 +1,4 @@
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
-    package="com.example.issm_visual"
+    package="gov.nasa.jpl.issm.visual"
     android:versionCode="1"
     android:versionName="1.0" >
Index: /issm/trunk/src/android/ISSM_Visual/bin/AndroidManifest.xml
===================================================================
--- /issm/trunk/src/android/ISSM_Visual/bin/AndroidManifest.xml	(revision 14309)
+++ /issm/trunk/src/android/ISSM_Visual/bin/AndroidManifest.xml	(revision 14310)
@@ -1,4 +1,4 @@
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
-    package="com.example.issm_visual"
+    package="gov.nasa.jpl.issm.visual"
     android:versionCode="1"
     android:versionName="1.0" >
Index: /issm/trunk/src/android/ISSM_Visual/res/layout/activity_issmvisual.xml
===================================================================
--- /issm/trunk/src/android/ISSM_Visual/res/layout/activity_issmvisual.xml	(revision 14309)
+++ /issm/trunk/src/android/ISSM_Visual/res/layout/activity_issmvisual.xml	(revision 14310)
@@ -15,11 +15,11 @@
 
     <TextView
-        android:id="@+id/status"
+        android:id="@+id/value"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_above="@+id/seekBar"
         android:layout_centerHorizontal="true"
-        android:layout_marginBottom="16dp"
-        android:text="Status: " />
+        android:layout_marginBottom="15dp"
+        android:text="alpha value = 0" />
 
     <FrameLayout
@@ -31,16 +31,14 @@
         android:layout_above="@+id/value"
         android:layout_centerHorizontal="true"
-        android:layout_marginBottom="16dp" >
+        android:layout_marginBottom="12dp" >
     </FrameLayout>
 
-    <TextView
-        android:id="@+id/value"
+    <Button
+        android:id="@+id/button1"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
-        android:layout_above="@+id/status"
-        android:layout_alignRight="@+id/status"
-        android:layout_centerHorizontal="true"
-        android:layout_marginBottom="16dp"
-        android:text="Value: " />
+        android:layout_above="@+id/seekBar"
+        android:layout_alignParentRight="true"
+        android:text="Reset" />
 
 </RelativeLayout>
Index: /issm/trunk/src/android/ISSM_Visual/src/gov/nasa/jpl/issm/visual/ISSMVisual.java
===================================================================
--- /issm/trunk/src/android/ISSM_Visual/src/gov/nasa/jpl/issm/visual/ISSMVisual.java	(revision 14310)
+++ /issm/trunk/src/android/ISSM_Visual/src/gov/nasa/jpl/issm/visual/ISSMVisual.java	(revision 14310)
@@ -0,0 +1,95 @@
+package gov.nasa.jpl.issm.visual;
+
+
+import android.app.Activity;
+import android.content.DialogInterface.OnClickListener;
+import android.opengl.GLSurfaceView;
+import android.os.Bundle;
+import android.view.Menu;
+import android.view.View;
+import android.widget.Button;
+import android.widget.FrameLayout;
+import android.widget.SeekBar;
+import android.widget.SeekBar.OnSeekBarChangeListener;
+import android.widget.TextView;
+
+public class ISSMVisual extends Activity implements OnSeekBarChangeListener
+{
+	private SeekBar bar;
+    private TextView /*txtStatus,*/ txtValue;
+    private GLSurfaceView mGLView;
+	private FrameLayout frame;
+	
+    @Override
+    public void onCreate(Bundle savedInstanceState) 
+    {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.activity_issmvisual);
+        
+        bar = (SeekBar)findViewById(R.id.seekBar); // make seekbar object
+        bar.setOnSeekBarChangeListener(this); // set seekbar listener
+        txtValue = (TextView)findViewById(R.id.value);
+        Button reset = (Button)findViewById(R.id.button1);
+        reset.setOnClickListener(new View.OnClickListener()
+        {
+            public void onClick(View v) 
+            {
+            	frame.removeView(mGLView);
+            	mGLView = new MyGLSurfaceView(ISSMVisual.this);
+            	frame.addView(mGLView);
+            }
+        });
+        //txtStatus = (TextView)findViewById(R.id.status);
+        
+        mGLView = new MyGLSurfaceView(this);
+        frame = (FrameLayout)findViewById(R.id.frame);
+        frame.addView(mGLView);
+    }
+	public void onProgressChanged(SeekBar seekBar, int val,
+    		boolean fromUser) 
+    {
+    	// change progress text label with current Seekbar value
+    	txtValue.setText("alpha value = " + val);
+    	//txtStatus.setText("Status: changing");
+    }
+	
+    public void onStartTrackingTouch(SeekBar seekBar) {/*txtStatus.setText("Status: Starting to track touch");*/}
+    
+    public void onStopTrackingTouch(SeekBar seekBar) 
+    {
+    	seekBar.setSecondaryProgress(seekBar.getProgress()); // set the shade of the previous value.
+    	
+    	//txtStatus.setText("Status: Ended tracking touch");
+    	frame.removeView(mGLView);
+    	mGLView = new MyGLSurfaceView(this);
+        frame.addView(mGLView);
+    }
+    
+    @Override
+    protected void onPause() 
+    {
+        super.onPause();
+        // The following call pauses the rendering thread.
+        // If your OpenGL application is memory intensive,
+        // you should consider de-allocating objects that
+        // consume significant memory here.
+        mGLView.onPause();
+    }
+    
+    @Override
+    protected void onResume() 
+    {
+        super.onResume();
+        // The following call resumes a paused rendering thread.
+        // If you de-allocated graphic objects for onPause()
+        // this is a good place to re-allocate them.
+        mGLView.onResume();
+    }
+
+    @Override
+    public boolean onCreateOptionsMenu(Menu menu) 
+    {
+        getMenuInflater().inflate(R.menu.activity_issmvisual, menu);
+        return true;
+    }
+}
Index: /issm/trunk/src/android/ISSM_Visual/src/gov/nasa/jpl/issm/visual/MyGLRenderer.java
===================================================================
--- /issm/trunk/src/android/ISSM_Visual/src/gov/nasa/jpl/issm/visual/MyGLRenderer.java	(revision 14310)
+++ /issm/trunk/src/android/ISSM_Visual/src/gov/nasa/jpl/issm/visual/MyGLRenderer.java	(revision 14310)
@@ -0,0 +1,294 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package gov.nasa.jpl.issm.visual;
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+import java.nio.FloatBuffer;
+
+import javax.microedition.khronos.egl.EGLConfig;
+import javax.microedition.khronos.opengles.GL10;
+
+import android.opengl.GLES20;
+import android.opengl.GLSurfaceView;
+import android.opengl.Matrix;
+
+public class MyGLRenderer implements GLSurfaceView.Renderer 
+{
+	public volatile float mAngle;
+	
+	/**
+	 * Store the model matrix. This matrix is used to move models from object space (where each model can be thought
+	 * of being located at the center of the universe) to world space.
+	 */
+	private float[][] mModelMatrix;
+	
+	/**
+	 * Store the view matrix. This can be thought of as our camera. This matrix transforms world space to eye space;
+	 * it positions things relative to our eye.
+	 */
+	private float[][] mViewMatrix;
+
+	/** Store the projection matrix. This is used to project the scene onto a 2D viewport. */
+	private float[][] mProjectionMatrix;
+
+	/** Allocate storage for the final combined matrix. This will be passed into the shader program. */
+	private float[][] mMVPMatrix;
+
+	/** This will be used to pass in the transformation matrix. */
+	private int mMatrixHandle;
+	
+    private FloatBuffer[] triangleVert;
+    
+    private float[][] triangleData2DArr;
+    
+    private int mPositionHandle;
+    
+    private int mColorHandle;
+    
+	/** How many bytes per float. */
+    private final int mBytesPerFloat = 4;
+
+    /** How many elements per vertex. */
+    private final int mStrideBytes = 7 * mBytesPerFloat;
+
+    /** Offset of the position data. */
+    private final int mPositionOffset = 0;
+
+    /** Size of the position data in elements. */
+    private final int mPositionDataSize = 3;
+
+    /** Offset of the color data. */
+    private final int mColorOffset = 3;
+
+    /** Size of the color data in elements. */
+    private final int mColorDataSize = 4;	
+
+    public MyGLRenderer(float[][] vertices)
+    {	
+    	triangleData2DArr = new float[vertices.length][21];
+    	triangleVert = new FloatBuffer[vertices.length];
+    	
+    	for (int i = 0; i < vertices.length; i++)
+    	{
+    		for (int j = 0; j < 21; j++)
+    			triangleData2DArr[i][j] = vertices[i][j]; 
+    	}
+	    		
+	    // initialize vertex byte buffer for shape coordinates
+    	for (int i = 0; i < vertices.length; i++)
+    	{
+    		triangleVert[i] = ByteBuffer.allocateDirect(triangleData2DArr[i].length * mBytesPerFloat)
+    													.order(ByteOrder.nativeOrder()).asFloatBuffer();
+    		triangleVert[i].put(triangleData2DArr[i]).position(0);
+    	}
+    }
+    
+    public void onSurfaceCreated(GL10 unused, EGLConfig config) 
+    {
+        // Set the background frame color
+        GLES20.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
+        
+		// Position the eye behind the origin.
+		final float eyeX = 0.0f;
+		final float eyeY = 0.0f;
+		final float eyeZ = 1.5f;
+
+		// We are looking toward the distance
+		final float lookX = 0.0f;
+		final float lookY = 0.0f;
+		final float lookZ = -5.0f;
+
+		// Set our up vector. This is where our head would be pointing were we holding the camera.
+		final float upX = 0.0f;
+		final float upY = 1.0f;
+		final float upZ = 0.0f;
+
+		// Set the view matrix. This matrix can be said to represent the camera position.
+		// NOTE: In OpenGL 1, a ModelView matrix is used, which is a combination of a model and
+		// view matrix. In OpenGL 2, we can keep track of these matrices separately if we choose.
+		mViewMatrix = new float[triangleVert.length][16];
+		
+		for (int i = 0; i < triangleVert.length; i++)
+			Matrix.setLookAtM(mViewMatrix[i], 0, eyeX, eyeY, eyeZ, lookX, lookY, lookZ, upX, upY, upZ);
+        
+		final String vertexShader =
+				"uniform mat4 u_MVPMatrix;      \n"		// A constant representing the combined model/view/projection matrix.
+			  + "attribute vec4 a_Position;     \n"		// Per-vertex position information we will pass in.
+			  + "attribute vec4 a_Color;        \n"		// Per-vertex color information we will pass in.			  
+			  + "varying vec4 v_Color;          \n"		// This will be passed into the fragment shader.
+			  + "void main()                    \n"		// The entry point for our vertex shader.
+			  + "{                              \n"
+			  + "   v_Color = a_Color;          \n"		// Pass the color through to the fragment shader. 
+			  											// It will be interpolated across the triangle.
+			  + "   gl_Position = u_MVPMatrix   \n" 	// gl_Position is a special variable used to store the final position.
+			  + "               * a_Position;   \n"     // Multiply the vertex by the matrix to get the final point in 			                                            			 
+			  + "}                              \n";    // normalized screen coordinates.
+
+			final String fragmentShader =
+				"precision mediump float;       \n"		// Set the default precision to medium. We don't need as high of a											// precision in the fragment shader.				
+			  + "varying vec4 v_Color;          \n"		// This is the color from the vertex shader interpolated across the 
+			  											// triangle per fragment.			  
+			  + "void main()                    \n"		// The entry point for our fragment shader.
+			  + "{                              \n"
+			  + "   gl_FragColor = v_Color;     \n"		// Pass the color directly through the pipeline.		  
+			  + "}                              \n";												
+
+    	   
+        int vertexShaderHandle = GLES20.glCreateShader(GLES20.GL_VERTEX_SHADER);
+		// Pass in the shader source.
+		GLES20.glShaderSource(vertexShaderHandle, vertexShader);
+
+		// Compile the shader.
+		GLES20.glCompileShader(vertexShaderHandle);
+
+		// Get the compilation status.
+		final int[] compileStatus1 = new int[1];
+		GLES20.glGetShaderiv(vertexShaderHandle, GLES20.GL_COMPILE_STATUS, compileStatus1, 0);
+
+		// If the compilation failed, delete the shader.
+		if (compileStatus1[0] == 0) 
+		{				
+			GLES20.glDeleteShader(vertexShaderHandle);
+			vertexShaderHandle = 0;
+		}
+		
+         
+    	int fragmentShaderHandle = GLES20.glCreateShader(GLES20.GL_FRAGMENT_SHADER);
+		// Pass in the shader source.
+		GLES20.glShaderSource(fragmentShaderHandle, fragmentShader);
+
+		// Compile the shader.
+		GLES20.glCompileShader(fragmentShaderHandle);
+
+		// Get the compilation status.
+		final int[] compileStatus2 = new int[1];
+		GLES20.glGetShaderiv(fragmentShaderHandle, GLES20.GL_COMPILE_STATUS, compileStatus2, 0);
+
+		// If the compilation failed, delete the shader.
+		if (compileStatus2[0] == 0) 
+		{				
+			GLES20.glDeleteShader(fragmentShaderHandle);
+			fragmentShaderHandle = 0;
+		}
+
+        
+        int mProgram = GLES20.glCreateProgram();
+		// Bind the vertex shader to the program.
+		GLES20.glAttachShader(mProgram, vertexShaderHandle);			
+
+		// Bind the fragment shader to the program.
+		GLES20.glAttachShader(mProgram, fragmentShaderHandle);
+
+		// Bind attributes
+		GLES20.glBindAttribLocation(mProgram, 0, "a_Position");
+		GLES20.glBindAttribLocation(mProgram, 1, "a_Color");
+
+		// Link the two shaders together into a program.
+		GLES20.glLinkProgram(mProgram);
+
+		// Get the link status.
+		final int[] linkStatus = new int[1];
+		GLES20.glGetProgramiv(mProgram, GLES20.GL_LINK_STATUS, linkStatus, 0);
+
+		// If the link failed, delete the program.
+		if (linkStatus[0] == 0) 
+		{				
+			GLES20.glDeleteProgram(mProgram);
+			mProgram = 0;
+		}
+		
+		for (int i = 0; i < triangleVert.length; i++)
+		{
+			mMatrixHandle = GLES20.glGetUniformLocation(mProgram, "u_MVPMatrix");        
+	        mPositionHandle = GLES20.glGetAttribLocation(mProgram, "a_Position");
+	        mColorHandle = GLES20.glGetAttribLocation(mProgram, "a_Color");
+		}
+        
+        // Add program to OpenGL environment
+        GLES20.glUseProgram(mProgram);
+    }
+    
+    public void onSurfaceChanged(GL10 unused, int width, int height) 
+    {
+        // Adjust the viewport based on geometry changes,
+        // such as screen rotation
+        GLES20.glViewport(0, 0, width, height);
+        
+		// Create a new perspective projection matrix. The height will stay the same
+		// while the width will vary as per aspect ratio.
+		final float ratio = (float) width / height;
+		
+		mProjectionMatrix = new float[triangleVert.length][16];
+		for (int i = 0; i < triangleVert.length; i++)
+			Matrix.frustumM(mProjectionMatrix[i], 0, -ratio*1.4f, ratio*1.4f, -1.4f, 1.4f, 1.4f, 14f);
+    }
+    
+    public void onDrawFrame(GL10 glUnused) 
+    {
+    	// Draw background color
+    	GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
+    	
+    	mModelMatrix = new float[triangleVert.length][16];
+        // Draw the triangle facing straight on.
+    	for (int i = 0; i < triangleVert.length; i++)
+    		Matrix.setIdentityM(mModelMatrix[i], 0);
+    		
+    	mMVPMatrix = new float[triangleVert.length][16];
+    	draw(triangleVert); 
+
+    }
+
+    private void draw(final FloatBuffer[] aTriangleBuffer)
+    {
+    	for (int i = 0; i < aTriangleBuffer.length; i++)
+    	{
+	        // Pass in the position information
+	        aTriangleBuffer[i].position(mPositionOffset);
+	        GLES20.glVertexAttribPointer(mPositionHandle, mPositionDataSize, GLES20.GL_FLOAT, false,
+	                				     mStrideBytes, aTriangleBuffer[i]);
+	        
+	        GLES20.glEnableVertexAttribArray(mPositionHandle);
+	     
+	        
+	        // Pass in the color information
+	        aTriangleBuffer[i].position(mColorOffset);
+	        GLES20.glVertexAttribPointer(mColorHandle, mColorDataSize, GLES20.GL_FLOAT, false,
+	                					 mStrideBytes, aTriangleBuffer[i]);
+	        
+	        GLES20.glEnableVertexAttribArray(mColorHandle);
+	        
+	        Matrix.setRotateM(mModelMatrix[i], 0, mAngle, 0, 0, -1.0f);
+
+			// This multiplies the view matrix by the model matrix, and stores the result in the MVP matrix
+	        // (which currently contains model * view).
+	        Matrix.multiplyMM(mMVPMatrix[i], 0, mViewMatrix[i], 0, mModelMatrix[i], 0);
+	        
+	        // This multiplies the modelview matrix by the projection matrix, and stores the result in the MVP matrix
+	        // (which now contains model * view * projection).
+	        Matrix.multiplyMM(mMVPMatrix[i], 0, mProjectionMatrix[i], 0, mMVPMatrix[i], 0);
+	        
+	        GLES20.glUniformMatrix4fv(mMatrixHandle, 1, false, mMVPMatrix[i], 0);
+	        
+	        // Draw the triangle
+	        GLES20.glDrawArrays(GLES20.GL_TRIANGLES, 0, 3);
+	        
+	        // Disable vertex array
+	        GLES20.glDisableVertexAttribArray(mPositionHandle);
+    	}
+    }
+
+}
Index: /issm/trunk/src/android/ISSM_Visual/src/gov/nasa/jpl/issm/visual/MyGLSurfaceView.java
===================================================================
--- /issm/trunk/src/android/ISSM_Visual/src/gov/nasa/jpl/issm/visual/MyGLSurfaceView.java	(revision 14310)
+++ /issm/trunk/src/android/ISSM_Visual/src/gov/nasa/jpl/issm/visual/MyGLSurfaceView.java	(revision 14310)
@@ -0,0 +1,82 @@
+package gov.nasa.jpl.issm.visual;
+
+import android.content.Context;
+import android.opengl.GLSurfaceView;
+import android.view.MotionEvent;
+
+
+class MyGLSurfaceView extends GLSurfaceView 
+{
+	private MyGLRenderer mRend;
+    public MyGLSurfaceView(Context context) 
+    {
+        super(context);
+
+        // Create an OpenGL ES 2.0 context.
+        setEGLContextClientVersion(2);
+        
+        final int NMAX_TRIANGLES = 2000;
+        final int MAX_VERTICES = 21;
+        
+        float f[][] = new float[NMAX_TRIANGLES][MAX_VERTICES];
+        int n, random;
+		for (int i = 0; i < f.length; i++)
+		{
+			for (int j = 0; j < MAX_VERTICES; j++)
+			{
+				if (j == 6 || j == 13 || j == 20) continue;
+				n = 1;
+		        random = (int)(Math.floor((Math.random()*10)+1));
+		        if (random <= 5) n = -1;
+		        
+				f[i][j] = (float)(Math.random()*n);
+			}
+		}
+
+        mRend = new MyGLRenderer(f);
+        
+        // Set the Renderer for drawing on the GLSurfaceView
+        setRenderer(mRend);
+
+        // Render the view only when there is a change in the drawing data
+        setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
+    }
+    
+    private final float TOUCH_SCALE_FACTOR = 180.0f / 320;
+    private float mPreviousX;
+    
+    private float mPreviousY;
+    @Override
+    public boolean onTouchEvent(MotionEvent e) {
+        // MotionEvent reports input details from the touch screen
+        // and other input controls. In this case, you are only
+        // interested in events where the touch position changed.
+
+        float x = e.getX();
+        float y = e.getY();
+
+        switch (e.getAction()) {
+            case MotionEvent.ACTION_MOVE:
+
+                float dx = x - mPreviousX;
+                float dy = y - mPreviousY;
+
+                // reverse direction of rotation above the mid-line
+                if (y > getHeight() / 2) {
+                  dx = dx * -1 ;
+                }
+
+                // reverse direction of rotation to left of the mid-line
+                if (x < getWidth() / 2) {
+                  dy = dy * -1 ;
+                }
+
+                mRend.mAngle += (dx + dy) * TOUCH_SCALE_FACTOR;  // = 180.0f / 320
+                requestRender();
+        }
+
+        mPreviousX = x;
+        mPreviousY = y;
+        return true;
+    }
+}
Index: /issm/trunk/src/android/ISSM_Visual/src/gov/nasa/jpl/issm/visual/colormap/colormap.c
===================================================================
--- /issm/trunk/src/android/ISSM_Visual/src/gov/nasa/jpl/issm/visual/colormap/colormap.c	(revision 14310)
+++ /issm/trunk/src/android/ISSM_Visual/src/gov/nasa/jpl/issm/visual/colormap/colormap.c	(revision 14310)
@@ -0,0 +1,83 @@
+int nrows=64;
+double hsv[nrows,3]={
+1.0000         0         0
+    1.0000    0.0938         0
+    1.0000    0.1875         0
+    1.0000    0.2812         0
+    1.0000    0.3750         0
+    1.0000    0.4688         0
+    1.0000    0.5625         0
+    1.0000    0.6562         0
+    1.0000    0.7500         0
+    1.0000    0.8438         0
+    1.0000    0.9375         0
+    0.9688    1.0000         0
+    0.8750    1.0000         0
+    0.7812    1.0000         0
+    0.6875    1.0000         0
+    0.5938    1.0000         0
+    0.5000    1.0000         0
+    0.4062    1.0000         0
+    0.3125    1.0000         0
+    0.2188    1.0000         0
+    0.1250    1.0000         0
+    0.0312    1.0000         0
+         0    1.0000    0.0625
+         0    1.0000    0.1562
+         0    1.0000    0.2500
+         0    1.0000    0.3438
+         0    1.0000    0.4375
+         0    1.0000    0.5312
+         0    1.0000    0.6250
+         0    1.0000    0.7188
+         0    1.0000    0.8125
+         0    1.0000    0.9062
+         0    1.0000    1.0000
+         0    0.9062    1.0000
+         0    0.8125    1.0000
+         0    0.7188    1.0000
+         0    0.6250    1.0000
+         0    0.5312    1.0000
+         0    0.4375    1.0000
+         0    0.3438    1.0000
+         0    0.2500    1.0000
+         0    0.1562    1.0000
+         0    0.0625    1.0000
+    0.0312         0    1.0000
+    0.1250         0    1.0000
+    0.2188         0    1.0000
+    0.3125         0    1.0000
+    0.4062         0    1.0000
+    0.5000         0    1.0000
+    0.5938         0    1.0000
+    0.6875         0    1.0000
+    0.7812         0    1.0000
+    0.8750         0    1.0000
+    0.9688         0    1.0000
+    1.0000         0    0.9375
+    1.0000         0    0.8438
+    1.0000         0    0.7500
+    1.0000         0    0.6562
+    1.0000         0    0.5625
+    1.0000         0    0.4688
+    1.0000         0    0.3750
+    1.0000         0    0.2812
+    1.0000         0    0.1875
+    1.0000         0    0.0938
+}
+
+
+
+value v=5*10^-5; // (m/s)
+value vmin,vmax;
+
+
+
+double alpha=(vmax-alpha)/(vmax-vmin);
+int i=(int)(alpha*nrows);
+
+double r,g,b;
+
+r=hsv[i,1];
+g=hsv[i,2];
+b=hsv[i,3];
Index: /issm/trunk/src/android/ISSM_Visual/src/gov/nasa/jpl/issm/visual/colormap/list_of_colormaps
===================================================================
--- /issm/trunk/src/android/ISSM_Visual/src/gov/nasa/jpl/issm/visual/colormap/list_of_colormaps	(revision 14310)
+++ /issm/trunk/src/android/ISSM_Visual/src/gov/nasa/jpl/issm/visual/colormap/list_of_colormaps	(revision 14310)
@@ -0,0 +1,23 @@
+hsv        - Hue-saturation-value color map.
+hot        - Black-red-yellow-white color map.
+gray       - Linear gray-scale color map.
+bone       - Gray-scale with tinge of blue color map.
+copper     - Linear copper-tone color map.
+pink       - Pastel shades of pink color map.
+white      - All white color map.
+flag       - Alternating red, white, blue, and black color map.
+lines      - Color map with the line colors.
+colorcube  - Enhanced color-cube color map.
+vga        - Windows colormap for 16 colors.
+jet        - Variant of HSV.
+prism      - Prism color map.
+cool       - Shades of cyan and magenta color map.
+autumn     - Shades of red and yellow color map.
+spring     - Shades of magenta and yellow color map.
+winter     - Shades of blue and green color map.
+summer  
+
+
+
+a=colormap('hsv');
+a
Index: /issm/trunk/src/c/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,15 @@
+# Subdirectories {{{
+add_subdirectory(classes)
+add_subdirectory(Container)
+add_subdirectory(EnumDefinitions)
+add_subdirectory(include)
+add_subdirectory(io)
+add_subdirectory(modules)
+add_subdirectory(shared)
+add_subdirectory(solutions)
+add_subdirectory(solvers)
+add_subdirectory(toolkits)
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c)
+# }}}
Index: /issm/trunk/src/c/Container/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/Container/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/Container/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,24 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/Container)
+# }}}
+# CORE_SOURCES {{{
+set(CORE_SOURCES $ENV{ISSM_DIR}/src/c/Container/Constraints.cpp
+                     $ENV{ISSM_DIR}/src/c/Container/DataSet.cpp
+                    $ENV{ISSM_DIR}/src/c/Container/Elements.cpp
+                      $ENV{ISSM_DIR}/src/c/Container/Inputs.cpp
+                       $ENV{ISSM_DIR}/src/c/Container/Loads.cpp
+                   $ENV{ISSM_DIR}/src/c/Container/Materials.cpp
+                       $ENV{ISSM_DIR}/src/c/Container/Nodes.cpp
+                     $ENV{ISSM_DIR}/src/c/Container/Options.cpp
+                  $ENV{ISSM_DIR}/src/c/Container/Parameters.cpp
+                     $ENV{ISSM_DIR}/src/c/Container/Results.cpp
+                    $ENV{ISSM_DIR}/src/c/Container/Vertices.cpp PARENT_SCOPE)
+# }}}
+# KRIGING_SOURCES {{{
+set(KRIGING_SOURCES $ENV{ISSM_DIR}/src/c/Container/Observations.cpp PARENT_SCOPE)
+# }}}
+# PKRIGING_SOURCES {{{
+set(PKRIGING_SOURCES $ENV{ISSM_DIR}/src/c/Container/Observations.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/Container/DataSet.cpp
===================================================================
--- /issm/trunk/src/c/Container/DataSet.cpp	(revision 14309)
+++ /issm/trunk/src/c/Container/DataSet.cpp	(revision 14310)
@@ -178,4 +178,5 @@
 	/*Check index in debugging mode*/
 	_assert_(this!=NULL);
+	_assert_(offset>=0);
 	_assert_(offset<this->Size());
 
Index: /issm/trunk/src/c/Container/Observations.cpp
===================================================================
--- /issm/trunk/src/c/Container/Observations.cpp	(revision 14309)
+++ /issm/trunk/src/c/Container/Observations.cpp	(revision 14310)
@@ -45,4 +45,7 @@
 	IssmPDouble  offset,minlength,minspacing,mintrimming,maxtrimming;
 	Observation *observation = NULL;
+
+	/*Check that observations is not empty*/
+	if(n==0) _error_("No observation found");
 
 	/*Get extrema*/
@@ -122,5 +125,5 @@
 	/*Output and Intermediaries*/
 	int          nobs,i,index;
-	IssmPDouble  h2,hmin2,radius2;
+	IssmPDouble  hmin,h2,hmin2,radius2;
 	int         *indices      = NULL;
 	Observation *observation  = NULL;
@@ -128,4 +131,12 @@
 	/*If radius is not provided or is 0, return all observations*/
 	if(radius==0) radius=this->quadtree->root->length;
+
+	/*First, find closest point in Quadtree (fast but might not be the true closest obs)*/
+	this->quadtree->ClosestObs(&index,x_interp,y_interp);
+	if(index>=0){
+		observation=dynamic_cast<Observation*>(this->GetObjectByOffset(index));
+		hmin = sqrt((observation->x-x_interp)*(observation->x-x_interp) + (observation->y-y_interp)*(observation->y-y_interp));
+		if(hmin<radius) radius=hmin;
+	}
 
 	/*Compute radius square*/
@@ -137,13 +148,12 @@
 		observation=dynamic_cast<Observation*>(this->GetObjectByOffset(indices[i]));
 		h2 = (observation->x-x_interp)*(observation->x-x_interp) + (observation->y-y_interp)*(observation->y-y_interp);
-
 		if(i==0){
 			hmin2 = h2;
-			index = i;
+			index = indices[i];
 		}
 		else{
 			if(h2<hmin2){
 				hmin2 = h2;
-				index = i;
+				index = indices[i];
 			}
 		}
@@ -151,17 +161,31 @@
 
 	/*Assign output pointer*/
-	if(!nobs){
+	if(index>=0){
+		observation=dynamic_cast<Observation*>(this->GetObjectByOffset(index));
+		*px=observation->x;
+		*py=observation->y;
+		*pobs=observation->value;
+	}
+	else{
+
 		*px=UNDEF;
 		*py=UNDEF;
 		*pobs=UNDEF;
 	}
-	else{
-		observation=dynamic_cast<Observation*>(this->GetObjectByOffset(indices[index]));
-		*px=observation->x;
-		*py=observation->y;
-		*pobs=observation->value;
-	}
 	xDelete<int>(indices);
 
+}/*}}}*/
+/*FUNCTION Observations::Distances{{{*/
+void Observations::Distances(IssmPDouble* distances,IssmPDouble *x,IssmPDouble *y,int n,IssmPDouble radius){
+
+	IssmPDouble xi,yi,obs;
+
+	for(int i=0;i<n;i++){
+		this->ClosestObservation(&xi,&yi,&obs,x[i],y[i],radius);
+		if(xi==UNDEF && yi==UNDEF)
+		 distances[i]=UNDEF;
+		else
+		 distances[i]=sqrt( (x[i]-xi)*(x[i]-xi) + (y[i]-yi)*(y[i]-yi) );
+	}
 }/*}}}*/
 /*FUNCTION Observations::ObservationList(IssmPDouble **px,IssmPDouble **py,IssmPDouble **pobs,int* pnobs,IssmPDouble x_interp,IssmPDouble y_interp,IssmPDouble radius,int maxdata){{{*/
Index: /issm/trunk/src/c/Container/Observations.h
===================================================================
--- /issm/trunk/src/c/Container/Observations.h	(revision 14309)
+++ /issm/trunk/src/c/Container/Observations.h	(revision 14310)
@@ -27,4 +27,5 @@
 		/*Methods*/
 		void ClosestObservation(IssmDouble *px,IssmDouble *py,IssmDouble *pobs,IssmDouble x_interp,IssmDouble y_interp,IssmDouble radius);
+		void Distances(IssmPDouble* distances,IssmPDouble *x,IssmPDouble *y,int n,IssmPDouble radius);
 		void InterpolationIDW(IssmDouble *pprediction,IssmDouble x_interp,IssmDouble y_interp,IssmDouble radius,int mindata,int maxdata,IssmDouble power);
 		void InterpolationV4(IssmDouble *pprediction,IssmDouble x_interp,IssmDouble y_interp,IssmDouble radius,int mindata,int maxdata);
Index: /issm/trunk/src/c/Container/Vertices.cpp
===================================================================
--- /issm/trunk/src/c/Container/Vertices.cpp	(revision 14309)
+++ /issm/trunk/src/c/Container/Vertices.cpp	(revision 14310)
@@ -199,2 +199,45 @@
 }
 /*}}}*/
+/*FUNCTION Vertices::ToXYZ{{{*/
+IssmDouble* Vertices::ToXYZ(void){
+
+	/*intermediary: */
+	int i;
+	int my_rank;
+	int num_vertices;
+	
+	/*output: */
+	Matrix<IssmDouble>* xyz = NULL;
+	IssmDouble* xyz_serial=NULL;
+
+	/*recover my_rank:*/
+	my_rank=IssmComm::GetRank();
+
+	/*First, figure out number of vertices: */
+	num_vertices=this->NumberOfVertices();
+
+	/*Now, allocate matrix to hold all the vertices x,y and z values: */
+	xyz= new Matrix<IssmDouble>(num_vertices,3);
+
+	/*Go through vertices, and for each vertex, object, report it cpu: */
+	for(i=0;i<this->Size();i++){
+
+		/*let vertex fill matrix: */
+		Vertex* vertex=dynamic_cast<Vertex*>(this->GetObjectByOffset(i));
+		vertex->ToXYZ(xyz);
+	}
+
+	/*Assemble:*/
+	xyz->Assemble();
+
+	/*gather on cpu 0: */
+	xyz_serial=xyz->ToSerial();
+
+	/*free ressources: */
+	delete xyz;
+	if(my_rank!=0)delete xyz_serial;
+
+	/*return matrix: */
+	return xyz_serial;
+}
+/*}}}*/
Index: /issm/trunk/src/c/Container/Vertices.h
===================================================================
--- /issm/trunk/src/c/Container/Vertices.h	(revision 14309)
+++ /issm/trunk/src/c/Container/Vertices.h	(revision 14310)
@@ -28,4 +28,5 @@
 		int   NumberOfVertices(void);
 		void  Ranks(int* ranks);
+		IssmDouble* ToXYZ(void);
 };
 
Index: /issm/trunk/src/c/EnumDefinitions/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/EnumDefinitions/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/EnumDefinitions/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,5 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/EnumDefinitions)
+# }}}
Index: /issm/trunk/src/c/EnumDefinitions/EnumDefinitions.h
===================================================================
--- /issm/trunk/src/c/EnumDefinitions/EnumDefinitions.h	(revision 14309)
+++ /issm/trunk/src/c/EnumDefinitions/EnumDefinitions.h	(revision 14310)
@@ -196,12 +196,7 @@
 	SurfaceforcingsIssmbgradientsEnum,
 	SurfaceforcingsMonthlytemperaturesEnum,
-	SurfaceforcingsHcEnum,
 	SurfaceforcingsHrefEnum,
 	SurfaceforcingsSmbrefEnum,
-	SurfaceforcingsSmbPosMaxEnum,
-	SurfaceforcingsSmbPosMinEnum,
-	SurfaceforcingsAPosEnum,
 	SurfaceforcingsBPosEnum,
-	SurfaceforcingsANegEnum,
 	SurfaceforcingsBNegEnum,
 	ThermalMaxiterEnum,
@@ -235,4 +230,6 @@
 	BalancethicknessAnalysisEnum,
 	BalancethicknessSolutionEnum,
+	WeakBalancethicknessAnalysisEnum,
+	WeakBalancethicknessSolutionEnum,
 	BedSlopeAnalysisEnum,
 	BedSlopeSolutionEnum,
@@ -355,4 +352,5 @@
 	AdjointyEnum,
 	AdjointzEnum,
+	BalancethicknessMisfitEnum,
 	BedSlopeXEnum,
 	BedSlopeYEnum,
@@ -382,4 +380,5 @@
 	QmuSurfaceEnum,
 	QmuMeltingEnum,
+	AndroidFrictionCoefficientEnum,
 	ResetPenaltiesEnum,
 	SegmentOnIceShelfEnum,
@@ -425,5 +424,4 @@
 	DragCoefficientAbsGradientEnum,
 	TransientInputEnum,
-	OutputfilenameEnum,
 	WaterfractionEnum,
 	WatercolumnEnum,
Index: /issm/trunk/src/c/Makefile.am
===================================================================
--- /issm/trunk/src/c/Makefile.am	(revision 14309)
+++ /issm/trunk/src/c/Makefile.am	(revision 14310)
@@ -1,3 +1,3 @@
-AM_CPPFLAGS = @DAKOTAINCL@ @SHAPELIBINCL@ @PETSCINCL@ @SLEPCINCL@ @MPIINCL@ @METISINCL@ @CHACOINCL@ @SCOTCHINCL@ @PLAPACKINCL@ @BLASLAPACKINCL@ @MKLINCL@ @MUMPSINCL@ @TRIANGLEINCL@ @SPAIINCL@ @HYPREINCL@ @PROMETHEUSINCL@ @SUPERLUINCL@ @SPOOLESINCL@ @PASTIXINCL@ @MLINCL@ @TAOINCL@ @ADIC2INCL@ @ADOLCINCL@ @GSLINCL@ @BOOSTINCL@
+AM_CPPFLAGS = @DAKOTAINCL@ @SHAPELIBINCL@ @PETSCINCL@ @SLEPCINCL@ @MPIINCL@ @METISINCL@ @CHACOINCL@ @SCOTCHINCL@ @PLAPACKINCL@ @BLASLAPACKINCL@ @MKLINCL@ @MUMPSINCL@ @TRIANGLEINCL@ @SPAIINCL@ @HYPREINCL@ @PROMETHEUSINCL@ @SUPERLUINCL@ @SPOOLESINCL@ @PASTIXINCL@ @MLINCL@ @TAOINCL@ @ADIC2INCL@ @ADOLCINCL@ @GSLINCL@ @BOOSTINCL@ @ANDROID_NDKINCL@
 
 EXEEXT=$(ISSMEXT)
@@ -475,5 +475,6 @@
 					    ./modules/ModelProcessorx/Balancethickness/CreateConstraintsBalancethickness.cpp\
 						./modules/ModelProcessorx/Balancethickness/CreateLoadsBalancethickness.cpp\
-						./solutions/balancethickness_core.cpp
+						./solutions/balancethickness_core.cpp \
+						./solutions/dummy_core.cpp
 #}}}
 #Slope sources  {{{
@@ -499,6 +500,5 @@
 #}}}
 #Android sources  {{{
-android_sources = ./android/fac.h\
-				  ./android/fac.cpp
+android_sources = 
 #}}}
 #3D sources  {{{
@@ -627,4 +627,6 @@
 			     ./modules/Kml2Expx/Kml2Expx.h\
 			     ./modules/Kml2Expx/Kml2Expx.cpp\
+			     ./modules/Shp2Expx/Shp2Expx.h\
+			     ./modules/Shp2Expx/Shp2Expx.cpp\
 			     ./modules/Shp2Kmlx/Shp2Kmlx.h\
 			     ./modules/Shp2Kmlx/Shp2Kmlx.cpp\
@@ -739,5 +741,5 @@
 			./shared/Exp/IsInPoly.cpp\
 			./shared/Exp/IsInPolySerial.cpp\
-			./shared/Exp/DomainOutlineWrite.cpp\
+			./shared/Exp/ExpWrite.cpp\
 			./shared/TriMesh/trimesh.h\
 			./shared/TriMesh/AssociateSegmentToElement.cpp\
@@ -781,9 +783,4 @@
 			./modules/MeshProfileIntersectionx/MeshProfileIntersectionx.cpp\
 			./modules/MeshProfileIntersectionx/MeshProfileIntersectionx.h\
-			./modules/MeshProfileIntersectionx/MeshSegmentsIntersection.cpp\
-			./modules/MeshProfileIntersectionx/ElementSegmentsIntersection.cpp\
-			./modules/MeshProfileIntersectionx/ElementSegment.cpp\
-			./modules/MeshProfileIntersectionx/SegmentIntersect.cpp\
-			./modules/MeshProfileIntersectionx/NodeInElement.cpp\
 			./modules/ContourToMeshx/ContourToMeshx.cpp\
 			./modules/ContourToMeshx/ContourToMeshxt.cpp\
Index: /issm/trunk/src/c/classes/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/classes/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/classes/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,20 @@
+# Subdirectories {{{
+add_subdirectory(bamg)
+add_subdirectory(dakota)
+add_subdirectory(gauss)
+add_subdirectory(kriging)
+add_subdirectory(matrix)
+add_subdirectory(objects)
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/classes)
+# }}}
+# CORE_SOURCES {{{
+set(CORE_SOURCES $ENV{ISSM_DIR}/src/c/classes/DofIndexing.cpp
+                    $ENV{ISSM_DIR}/src/c/classes/FemModel.cpp
+                        $ENV{ISSM_DIR}/src/c/classes/Hook.cpp
+                     $ENV{ISSM_DIR}/src/c/classes/IoModel.cpp
+                    $ENV{ISSM_DIR}/src/c/classes/IssmComm.cpp
+                       $ENV{ISSM_DIR}/src/c/classes/Patch.cpp
+                  $ENV{ISSM_DIR}/src/c/classes/RiftStruct.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/classes/FemModel.cpp
===================================================================
--- /issm/trunk/src/c/classes/FemModel.cpp	(revision 14309)
+++ /issm/trunk/src/c/classes/FemModel.cpp	(revision 14310)
@@ -20,9 +20,4 @@
 
 /*Object constructors and destructor*/
-/*FUNCTION FemModel::FemModel(char* filename) {{{*/
-FemModel::FemModel(char* filename){
-
-}
-/*}}}*/
 /*FUNCTION FemModel::FemModel(int argc,char** argv){{{*/
 FemModel::FemModel(int argc,char** argv,COMM incomm){
@@ -707,4 +702,5 @@
 		case ThicknessAlongGradientEnum: ThicknessAlongGradientx(responses, elements,nodes, vertices, loads, materials, parameters,process_units,weight_index); break;
 		case ThicknessAcrossGradientEnum:ThicknessAcrossGradientx(responses, elements,nodes, vertices, loads, materials, parameters,process_units,weight_index); break;
+		case BalancethicknessMisfitEnum:BalancethicknessMisfitx(responses,process_units,weight_index); break;
 		case TotalSmbEnum:					this->TotalSmbx(responses,process_units); break;
 		case RheologyBbarAbsGradientEnum:RheologyBbarAbsGradientx(responses, elements,nodes, vertices, loads, materials, parameters,process_units,weight_index); break;
@@ -1363,4 +1359,23 @@
 #endif
 #ifdef _HAVE_CONTROL_
+void FemModel::BalancethicknessMisfitx(IssmDouble* presponse,bool process_units,int weight_index){/*{{{*/
+
+	IssmDouble J = 0;
+	IssmDouble J_sum;
+
+	for(int i=0;i<this->elements->Size();i++){
+		Element* element=dynamic_cast<Element*>(this->elements->GetObjectByOffset(i));
+		J+=element->BalancethicknessMisfit(process_units,weight_index);
+	}
+	#ifdef _HAVE_MPI_
+	MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0,IssmComm::GetComm() );
+	MPI_Bcast(&J_sum,1,MPI_DOUBLE,0,IssmComm::GetComm());
+	J=J_sum;
+	#endif
+
+	/*Assign output pointers: */
+	*presponse=J;
+
+}/*}}}*/
 void FemModel::ThicknessAbsGradientx( IssmDouble* pJ, bool process_units, int weight_index){/*{{{*/
 
Index: /issm/trunk/src/c/classes/FemModel.h
===================================================================
--- /issm/trunk/src/c/classes/FemModel.h	(revision 14309)
+++ /issm/trunk/src/c/classes/FemModel.h	(revision 14310)
@@ -47,5 +47,4 @@
 
 		/*constructors, destructors: */
-		FemModel(char* filename);
 		FemModel(int argc,char** argv,COMM comm_init);
 		FemModel(char* rootpath, char* inputfilename, char* outputfilename, char* petscfilename, char* lockfilename, const int solution_type,const int* analyses,const int nummodels);
@@ -81,4 +80,5 @@
 		void IceVolumex(IssmDouble* pV,bool process_units);
 		void ElementResponsex(IssmDouble* presponse,int response_enum,bool process_units);
+		void BalancethicknessMisfitx(IssmDouble* pV,bool process_units,int weight_index);
 		#endif
 		#ifdef  _HAVE_DAKOTA_
Index: /issm/trunk/src/c/classes/IssmComm.cpp
===================================================================
--- /issm/trunk/src/c/classes/IssmComm.cpp	(revision 14309)
+++ /issm/trunk/src/c/classes/IssmComm.cpp	(revision 14310)
@@ -11,16 +11,32 @@
 #include "./IssmComm.h"
 #include "../include/types.h"
+#include "../include/macros.h"
+#include "../shared/Exceptions/exceptions.h"
 
 void IssmComm::SetComm(COMM incomm){ /*{{{*/
-	comm=incomm;
+
+	/*A comm is provided, we are running in parallel (this is not a module)*/
+	parallel = true;
+	comm     = incomm;
+
+}/*}}}*/
+void IssmComm::SetComm(void){ /*{{{*/
+
+	/*no comm provided, This is a matlab/python module*/
+	parallel = false;
+
+	/*No need to initialise comm*/
+
 }/*}}}*/
 COMM IssmComm::GetComm(){  /*{{{*/
+	if(!parallel) _error_("Cannot return comm in serial mode");
 	return comm;
 }/*}}}*/
 int IssmComm::GetRank(){  /*{{{*/
+
 	int my_rank = 0;
-
-	/*for matlab and python modules, comm == -1*/
-	if((int)comm==-1) return my_rank;
+	
+	/*for matlab and python modules*/
+	if(!parallel) return my_rank;
 
 	#ifdef _HAVE_MPI_
@@ -35,6 +51,6 @@
 	int size = 1;
 
-	/*for matlab and python modules, comm == -1*/
-	if((int)comm==-1) return size;
+	/*for matlab and python modules*/
+	if(!parallel) return size;
 
 	#ifdef _HAVE_MPI_
Index: /issm/trunk/src/c/classes/IssmComm.h
===================================================================
--- /issm/trunk/src/c/classes/IssmComm.h	(revision 14309)
+++ /issm/trunk/src/c/classes/IssmComm.h	(revision 14310)
@@ -21,10 +21,12 @@
 	private:
 		static COMM comm;
+		static bool parallel;
 
 	public:
 		static void SetComm(COMM incomm);
-		static COMM GetComm();
-		static int GetRank();
-		static int GetSize();
+		static void SetComm(void);
+		static COMM GetComm(void);
+		static int GetRank(void);
+		static int GetSize(void);
 };
 
Index: /issm/trunk/src/c/classes/RiftStruct.cpp
===================================================================
--- /issm/trunk/src/c/classes/RiftStruct.cpp	(revision 14309)
+++ /issm/trunk/src/c/classes/RiftStruct.cpp	(revision 14310)
@@ -22,5 +22,5 @@
 
 }/*}}}*/
-RiftStruct::RiftStruct(int numrifts_in,int *riftsnumsegments_in,double **riftssegments_in,int *riftsnumpairs_in,double **riftspairs_in,int *riftsnumpenaltypairs_in,double **riftspenaltypairs_in,double* riftstips_in){/*{{{*/
+RiftStruct::RiftStruct(int numrifts_in,int *riftsnumsegments_in,int**riftssegments_in,int *riftsnumpairs_in,int**riftspairs_in,int *riftsnumpenaltypairs_in,double **riftspenaltypairs_in,int * riftstips_in){/*{{{*/
 
 	int i;
@@ -37,8 +37,8 @@
 	/*riftssegments*/
 	_assert_(riftssegments_in);
-	this->riftssegments=xNew<double*>(numrifts_in);
+	this->riftssegments=xNew<int*>(numrifts_in);
 	for(i=0;i<numrifts_in;i++){
-		this->riftssegments[i]=xNew<double>(riftsnumsegments_in[i]*3);
-		xMemCpy<double>(this->riftssegments[i],riftssegments_in[i],riftsnumsegments_in[i]*3);
+		this->riftssegments[i]=xNew<int>(riftsnumsegments_in[i]*3);
+		xMemCpy<int>(this->riftssegments[i],riftssegments_in[i],riftsnumsegments_in[i]*3);
 	}
 
@@ -50,8 +50,8 @@
 	/*riftspairs*/
 	_assert_(riftspairs_in);
-	this->riftspairs=xNew<double*>(numrifts_in);
+	this->riftspairs=xNew<int*>(numrifts_in);
 	for(i=0;i<numrifts_in;i++){
-		this->riftspairs[i]=xNew<double>(riftsnumpairs_in[i]*2);
-		xMemCpy<double>(this->riftspairs[i],riftspairs_in[i],riftsnumpairs_in[i]*2);
+		this->riftspairs[i]=xNew<int>(riftsnumpairs_in[i]*2);
+		xMemCpy<int>(this->riftspairs[i],riftspairs_in[i],riftsnumpairs_in[i]*2);
 	}
 
@@ -71,6 +71,6 @@
 	/*riftstips*/
 	_assert_(riftstips_in);
-	this->riftstips=xNew<double>(2*numrifts_in);
-	xMemCpy<double>(this->riftstips,riftstips_in,2*numrifts_in);
+	this->riftstips=xNew<int>(2*numrifts_in);
+	xMemCpy<int>(this->riftstips,riftstips_in,2*numrifts_in);
 
 	/*state*/
@@ -85,10 +85,10 @@
 
 	xDelete<int>(this->riftsnumsegments);
-	xDelete<double*>(this->riftssegments);
+	xDelete<int*>(this->riftssegments);
 	xDelete<int>(this->riftsnumpairs);
-	xDelete<double*>(this->riftspairs);
+	xDelete<int*>(this->riftspairs);
 	xDelete<int>(this->riftsnumpenaltypairs);
 	xDelete<double*>(this->riftspenaltypairs);
-	xDelete<double>(this->riftstips);
+	xDelete<int>(this->riftstips);
 	xDelete<double*>(this->state);
 
Index: /issm/trunk/src/c/classes/RiftStruct.h
===================================================================
--- /issm/trunk/src/c/classes/RiftStruct.h	(revision 14309)
+++ /issm/trunk/src/c/classes/RiftStruct.h	(revision 14310)
@@ -10,15 +10,15 @@
 	public:
 		int      numrifts;
-		double **riftssegments;
+		int    **riftssegments;
 		int     *riftsnumsegments;
-		double **riftspairs;
+		int    **riftspairs;
 		int     *riftsnumpairs;
 		double **riftspenaltypairs;
 		int     *riftsnumpenaltypairs;
-		double  *riftstips;
+		int     *riftstips;
 		double **state;
 
 		RiftStruct();
-		RiftStruct(int numrifts_in,int *riftsnumsegments_in,double **riftssegments_in,int *riftsnumpairs_in,double **riftspairs_in,int *riftsnumpenaltypairs_in,double **riftspenaltypairs_in,double* riftstips_in);
+		RiftStruct(int numrifts_in,int *riftsnumsegments_in,int **riftssegments_in,int *riftsnumpairs_in,int **riftspairs_in,int *riftsnumpenaltypairs_in,double **riftspenaltypairs_in,int* riftstips_in);
 		~RiftStruct();
 };
Index: /issm/trunk/src/c/classes/bamg/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/classes/bamg/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/classes/bamg/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,31 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/classes/bamg)
+# }}}
+# BAMG_SOURCES {{{
+set(BAMG_SOURCES $ENV{ISSM_DIR}/src/c/classes/bamg/AdjacentTriangle.cpp
+                         $ENV{ISSM_DIR}/src/c/classes/bamg/BamgGeom.cpp
+                         $ENV{ISSM_DIR}/src/c/classes/bamg/BamgMesh.cpp
+                         $ENV{ISSM_DIR}/src/c/classes/bamg/BamgOpts.cpp
+                     $ENV{ISSM_DIR}/src/c/classes/bamg/BamgQuadtree.cpp
+                       $ENV{ISSM_DIR}/src/c/classes/bamg/BamgVertex.cpp
+                      $ENV{ISSM_DIR}/src/c/classes/bamg/CrackedEdge.cpp
+                            $ENV{ISSM_DIR}/src/c/classes/bamg/Curve.cpp
+                        $ENV{ISSM_DIR}/src/c/classes/bamg/Direction.cpp
+                             $ENV{ISSM_DIR}/src/c/classes/bamg/Edge.cpp
+                      $ENV{ISSM_DIR}/src/c/classes/bamg/EigenMetric.cpp
+                         $ENV{ISSM_DIR}/src/c/classes/bamg/GeomEdge.cpp
+                         $ENV{ISSM_DIR}/src/c/classes/bamg/Geometry.cpp
+                    $ENV{ISSM_DIR}/src/c/classes/bamg/GeomSubDomain.cpp
+                       $ENV{ISSM_DIR}/src/c/classes/bamg/GeomVertex.cpp
+      $ENV{ISSM_DIR}/src/c/classes/bamg/ListofIntersectionTriangles.cpp
+                             $ENV{ISSM_DIR}/src/c/classes/bamg/Mesh.cpp
+                           $ENV{ISSM_DIR}/src/c/classes/bamg/Metric.cpp
+                          $ENV{ISSM_DIR}/src/c/classes/bamg/SetOfE4.cpp
+                        $ENV{ISSM_DIR}/src/c/classes/bamg/SubDomain.cpp
+                         $ENV{ISSM_DIR}/src/c/classes/bamg/Triangle.cpp
+                     $ENV{ISSM_DIR}/src/c/classes/bamg/VertexOnEdge.cpp
+                     $ENV{ISSM_DIR}/src/c/classes/bamg/VertexOnGeom.cpp
+                   $ENV{ISSM_DIR}/src/c/classes/bamg/VertexOnVertex.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/classes/bamg/Mesh.cpp
===================================================================
--- /issm/trunk/src/c/classes/bamg/Mesh.cpp	(revision 14309)
+++ /issm/trunk/src/c/classes/bamg/Mesh.cpp	(revision 14310)
@@ -899,8 +899,9 @@
 		}
 		//Build output
+		connectivitymax_2++;//add last column for size
 		bamgmesh->NodalConnectivitySize[0]=nbv;
 		bamgmesh->NodalConnectivitySize[1]=connectivitymax_2;
 		bamgmesh->NodalConnectivity=xNew<double>(connectivitymax_2*nbv);
-		for (i=0;i<connectivitymax_2*nbv;i++) bamgmesh->NodalConnectivity[i]=NAN;
+		for (i=0;i<connectivitymax_2*nbv;i++) bamgmesh->NodalConnectivity[i]=0;
 		for (i=0;i<nbv;i++){
 			k=0;
@@ -917,4 +918,5 @@
 				k++;
 			}
+			bamgmesh->NodalConnectivity[connectivitymax_2*(i+1)-1]=k;
 		}
 
Index: /issm/trunk/src/c/classes/dakota/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/classes/dakota/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/classes/dakota/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,8 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/classes/dakota)
+# }}}
+# DAKOTA_SOURCES {{{
+set(DAKOTA_SOURCES $ENV{ISSM_DIR}/src/c/classes/dakota/DakotaPlugin.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/classes/gauss/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/classes/gauss/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/classes/gauss/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,11 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/classes/gauss)
+# }}}
+# CORE_SOURCES {{{
+set(CORE_SOURCES $ENV{ISSM_DIR}/src/c/classes/gauss/GaussTria.cpp PARENT_SCOPE)
+# }}}
+# THREED_SOURCES {{{
+set(THREED_SOURCES $ENV{ISSM_DIR}/src/c/classes/gauss/GaussPenta.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/classes/kriging/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/classes/kriging/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/classes/kriging/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,21 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/classes/kriging)
+# }}}
+# KRIGING_SOURCES {{{
+set(KRIGING_SOURCES $ENV{ISSM_DIR}/src/c/classes/kriging/ExponentialVariogram.cpp
+                       $ENV{ISSM_DIR}/src/c/classes/kriging/GaussianVariogram.cpp
+                             $ENV{ISSM_DIR}/src/c/classes/kriging/Observation.cpp
+                          $ENV{ISSM_DIR}/src/c/classes/kriging/PowerVariogram.cpp
+                                $ENV{ISSM_DIR}/src/c/classes/kriging/Quadtree.cpp
+                      $ENV{ISSM_DIR}/src/c/classes/kriging/SphericalVariogram.cpp PARENT_SCOPE)
+# }}}
+# PKRIGING_SOURCES {{{
+set(PKRIGING_SOURCES $ENV{ISSM_DIR}/src/c/classes/kriging/ExponentialVariogram.cpp
+                        $ENV{ISSM_DIR}/src/c/classes/kriging/GaussianVariogram.cpp
+                              $ENV{ISSM_DIR}/src/c/classes/kriging/Observation.cpp
+                           $ENV{ISSM_DIR}/src/c/classes/kriging/PowerVariogram.cpp
+                                 $ENV{ISSM_DIR}/src/c/classes/kriging/Quadtree.cpp
+                       $ENV{ISSM_DIR}/src/c/classes/kriging/SphericalVariogram.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/classes/matrix/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/classes/matrix/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/classes/matrix/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,9 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/classes/matrix)
+# }}}
+# CORE_SOURCES {{{
+set(CORE_SOURCES $ENV{ISSM_DIR}/src/c/classes/matrix/ElementMatrix.cpp
+                 $ENV{ISSM_DIR}/src/c/classes/matrix/ElementVector.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/classes/objects/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/classes/objects/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/classes/objects/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,22 @@
+# Subdirectories {{{
+add_subdirectory(Constraints)
+add_subdirectory(ElementResults)
+add_subdirectory(Elements)
+add_subdirectory(ExternalResults)
+add_subdirectory(Inputs)
+add_subdirectory(KML)
+add_subdirectory(Loads)
+add_subdirectory(Materials)
+add_subdirectory(Options)
+add_subdirectory(Params)
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/classes/objects)
+# }}}
+# CORE_SOURCES {{{
+set(CORE_SOURCES $ENV{ISSM_DIR}/src/c/classes/objects/DependentObject.cpp
+               $ENV{ISSM_DIR}/src/c/classes/objects/IndependentObject.cpp
+                            $ENV{ISSM_DIR}/src/c/classes/objects/Node.cpp
+                        $ENV{ISSM_DIR}/src/c/classes/objects/Profiler.cpp
+                          $ENV{ISSM_DIR}/src/c/classes/objects/Vertex.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/classes/objects/Constraints/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/classes/objects/Constraints/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/classes/objects/Constraints/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,10 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/classes/objects/Constraints)
+# }}}
+# CORE_SOURCES {{{
+set(CORE_SOURCES $ENV{ISSM_DIR}/src/c/classes/objects/Constraints/SpcDynamic.cpp
+                  $ENV{ISSM_DIR}/src/c/classes/objects/Constraints/SpcStatic.cpp
+               $ENV{ISSM_DIR}/src/c/classes/objects/Constraints/SpcTransient.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/classes/objects/ElementResults/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/classes/objects/ElementResults/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/classes/objects/ElementResults/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,13 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/classes/objects/ElementResults)
+# }}}
+# CORE_SOURCES {{{
+set(CORE_SOURCES $ENV{ISSM_DIR}/src/c/classes/objects/ElementResults/BoolElementResult.cpp
+               $ENV{ISSM_DIR}/src/c/classes/objects/ElementResults/DoubleElementResult.cpp
+               $ENV{ISSM_DIR}/src/c/classes/objects/ElementResults/TriaP1ElementResult.cpp PARENT_SCOPE)
+# }}}
+# THREED_SOURCES {{{
+set(THREED_SOURCES $ENV{ISSM_DIR}/src/c/classes/objects/ElementResults/PentaP1ElementResult.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/classes/objects/Elements/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/classes/objects/Elements/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/classes/objects/Elements/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,15 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/classes/objects/Elements)
+# }}}
+# CORE_SOURCES {{{
+set(CORE_SOURCES $ENV{ISSM_DIR}/src/c/classes/objects/Elements/Tria.cpp
+             $ENV{ISSM_DIR}/src/c/classes/objects/Elements/TriaHook.cpp
+              $ENV{ISSM_DIR}/src/c/classes/objects/Elements/TriaRef.cpp PARENT_SCOPE)
+# }}}
+# THREED_SOURCES {{{
+set(THREED_SOURCES $ENV{ISSM_DIR}/src/c/classes/objects/Elements/Penta.cpp
+               $ENV{ISSM_DIR}/src/c/classes/objects/Elements/PentaHook.cpp
+                $ENV{ISSM_DIR}/src/c/classes/objects/Elements/PentaRef.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/classes/objects/Elements/Element.h
===================================================================
--- /issm/trunk/src/c/classes/objects/Elements/Element.h	(revision 14309)
+++ /issm/trunk/src/c/classes/objects/Elements/Element.h	(revision 14310)
@@ -110,4 +110,5 @@
 		virtual IssmDouble ThicknessAlongGradient(bool process_units,int weight_index)=0;
 		virtual IssmDouble ThicknessAcrossGradient(bool process_units,int weight_index)=0;
+		virtual IssmDouble BalancethicknessMisfit(bool process_units,int weight_index)=0;
 		virtual IssmDouble RheologyBbarAbsGradient(bool process_units,int weight_index)=0;
 		virtual IssmDouble DragCoefficientAbsGradient(bool process_units,int weight_index)=0;
Index: /issm/trunk/src/c/classes/objects/Elements/Penta.cpp
===================================================================
--- /issm/trunk/src/c/classes/objects/Elements/Penta.cpp	(revision 14309)
+++ /issm/trunk/src/c/classes/objects/Elements/Penta.cpp	(revision 14310)
@@ -2727,12 +2727,7 @@
 
 	/*Recover SmbGradients*/
-	GetInputListOnVertices(&Hc[0],SurfaceforcingsHcEnum);
 	GetInputListOnVertices(&Href[0],SurfaceforcingsHrefEnum);
 	GetInputListOnVertices(&Smbref[0],SurfaceforcingsSmbrefEnum);
-	GetInputListOnVertices(&smb_pos_max[0],SurfaceforcingsSmbPosMaxEnum);
-	GetInputListOnVertices(&smb_pos_min[0],SurfaceforcingsSmbPosMinEnum);
-	GetInputListOnVertices(&a_pos[0],SurfaceforcingsAPosEnum);
 	GetInputListOnVertices(&b_pos[0],SurfaceforcingsBPosEnum);
-	GetInputListOnVertices(&a_neg[0],SurfaceforcingsANegEnum);
 	GetInputListOnVertices(&b_neg[0],SurfaceforcingsBNegEnum);
 
@@ -2747,13 +2742,9 @@
    // loop over all vertices
  for(i=0;i<NUMVERTICES;i++){
-     if(s[i]>Hc[i]){
-		  if(Href[i]>Hc[i]){smb[i]=Smbref[i]+b_pos[i]*(s[i]-Href[i]);}
-		  if(Href[i]<=Hc[i]){smb[i]=a_pos[i]+b_pos[i]*s[i];}
-		  if(smb[i]>smb_pos_max[i]){smb[i]=smb_pos_max[i];}
-		  if(smb[i]<smb_pos_min[i]){smb[i]=smb_pos_min[i];}
+     if(Smbref[i]>0){
+		  smb[i]=Smbref[i]+b_pos[i]*(s[i]-Href[i]);
 	  }
 	  else{
-		  if(Href[i]>Hc[i]){smb[i]=a_neg[i]+b_neg[i]*s[i];}
-		  if(Href[i]<=Hc[i]){smb[i]=Smbref[i]+b_neg[i]*(s[i]-Href[i]);}
+		  smb[i]=Smbref[i]+b_neg[i]*(s[i]-Href[i]);
 	  }
 	  smb[i]=smb[i]/rho_ice;      // SMB in m/y ice		
Index: /issm/trunk/src/c/classes/objects/Elements/Penta.h
===================================================================
--- /issm/trunk/src/c/classes/objects/Elements/Penta.h	(revision 14309)
+++ /issm/trunk/src/c/classes/objects/Elements/Penta.h	(revision 14310)
@@ -166,4 +166,5 @@
 		IssmDouble ThicknessAlongGradient( bool process_units,int weight_index){_error_("not supported");};
 		IssmDouble ThicknessAcrossGradient(bool process_units,int weight_index){_error_("not supported");};
+		IssmDouble BalancethicknessMisfit(bool process_units,int weight_index){_error_("not supported");};
 		void   InputControlUpdate(IssmDouble scalar,bool save_parameter);
 		#endif
Index: /issm/trunk/src/c/classes/objects/Elements/Tria.cpp
===================================================================
--- /issm/trunk/src/c/classes/objects/Elements/Tria.cpp	(revision 14309)
+++ /issm/trunk/src/c/classes/objects/Elements/Tria.cpp	(revision 14310)
@@ -1550,4 +1550,12 @@
 						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,TriaP1InputEnum,nodeinputs,cmmininputs,cmmaxinputs,i+1));
+					}
+					break;
+				case ThicknessEnum:
+					if (iomodel->Data(ThicknessEnum)){
+						for(j=0;j<3;j++)nodeinputs[j]=iomodel->Data(ThicknessEnum)[tria_vertex_ids[j]-1];
+						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(ThicknessEnum,TriaP1InputEnum,nodeinputs,cmmininputs,cmmaxinputs,i+1));
 					}
 					break;
@@ -2317,13 +2325,8 @@
    IssmDouble h[NUMVERTICES];					// ice thickness (m)		
 	IssmDouble s[NUMVERTICES];					// surface elevation (m)
-	IssmDouble a_pos[NUMVERTICES];				// Hs-SMB relation parameter 
 	IssmDouble b_pos[NUMVERTICES];				// Hs-SMB relation parameter
-	IssmDouble a_neg[NUMVERTICES];				// Hs-SMB relation parameter
 	IssmDouble b_neg[NUMVERTICES];				// Hs-SMB relation paremeter
-	IssmDouble Hc[NUMVERTICES];					// elevation of transition between accumulation regime and ablation regime
 	IssmDouble Href[NUMVERTICES];					// reference elevation from which deviations are used to calculate the SMB adjustment
 	IssmDouble Smbref[NUMVERTICES];				// reference SMB to which deviations are added
-	IssmDouble smb_pos_max[NUMVERTICES];		// maximum SMB value in the accumulation regime
-	IssmDouble smb_pos_min[NUMVERTICES];		// minimum SMB value in the accumulation regime
    IssmDouble rho_water;                   // density of fresh water
 	IssmDouble rho_ice;                     // density of ice
@@ -2333,12 +2336,7 @@
 
 	/*Recover SmbGradients*/
-	GetInputListOnVertices(&Hc[0],SurfaceforcingsHcEnum);
 	GetInputListOnVertices(&Href[0],SurfaceforcingsHrefEnum);
 	GetInputListOnVertices(&Smbref[0],SurfaceforcingsSmbrefEnum);
-	GetInputListOnVertices(&smb_pos_max[0],SurfaceforcingsSmbPosMaxEnum);
-	GetInputListOnVertices(&smb_pos_min[0],SurfaceforcingsSmbPosMinEnum);
-	GetInputListOnVertices(&a_pos[0],SurfaceforcingsAPosEnum);
 	GetInputListOnVertices(&b_pos[0],SurfaceforcingsBPosEnum);
-	GetInputListOnVertices(&a_neg[0],SurfaceforcingsANegEnum);
 	GetInputListOnVertices(&b_neg[0],SurfaceforcingsBNegEnum);
 
@@ -2353,22 +2351,11 @@
    // loop over all vertices
    for(i=0;i<NUMVERTICES;i++){
-     if(s[i]>Hc[i]){
-		  if(Href[i]>Hc[i]){smb[i]=Smbref[i]+b_pos[i]*(s[i]-Href[i]);}
-		  if(Href[i]<=Hc[i]){smb[i]=a_pos[i]+b_pos[i]*s[i];}
-		  if(smb[i]>smb_pos_max[i]){smb[i]=smb_pos_max[i];}
-		  if(smb[i]<smb_pos_min[i]){smb[i]=smb_pos_min[i];}
+     if(Smbref[i]>0){
+		  smb[i]=Smbref[i]+b_pos[i]*(s[i]-Href[i]);
 	  }
 	  else{
-		  if(Href[i]>Hc[i]){smb[i]=a_neg[i]+b_neg[i]*s[i];}
-		  if(Href[i]<=Hc[i]){smb[i]=Smbref[i]+b_neg[i]*(s[i]-Href[i]);}
+		  smb[i]=Smbref[i]+b_neg[i]*(s[i]-Href[i]);
 	  }
 	  smb[i]=smb[i]/rho_ice;      // SMB in m/y ice		
-  /*   printf("s %e \n",s[i]); 
-     printf("Hsref %e \n",Href[i]); 
-     printf("Hc %e \n",Hc[i]); 
-     printf("Smbref %e \n",Smbref[i]); 
-     printf("b_neg %e \n",b_neg[i]); 
-     printf("smb %e \n",smb[i]); 
-	  _error_("stop-in-code"); */
 		}  //end of the loop over the vertices
 	  /*Update inputs*/
@@ -3459,4 +3446,62 @@
 
 #ifdef _HAVE_CONTROL_
+/*FUNCTION Tria::BalancethicknessMisfit{{{*/
+IssmDouble Tria::BalancethicknessMisfit(bool process_units,int weight_index){
+
+	/* Intermediaries */
+	IssmDouble Jelem = 0;
+	IssmDouble weight;
+	IssmDouble Jdet,temp;
+	IssmDouble xyz_list[NUMVERTICES][3];
+	IssmDouble dH[2];
+	IssmDouble vx,vy,H;
+	IssmDouble dvx[2],dvy[2];
+	IssmDouble dhdt,basal_melting,surface_mass_balance;
+	GaussTria *gauss = NULL;
+
+	/*If on water, return 0: */
+	if(IsOnWater()) return 0;
+
+	/*Retrieve all inputs we will be needing: */
+	GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES);
+	Input* weights_input              = inputs->GetInput(InversionCostFunctionsCoefficientsEnum);   _assert_(weights_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* surface_mass_balance_input = inputs->GetInput(SurfaceforcingsMassBalanceEnum);         _assert_(surface_mass_balance_input);
+	Input* basal_melting_input        = inputs->GetInput(BasalforcingsMeltingRateEnum);           _assert_(basal_melting_input);
+	Input* dhdt_input                 = inputs->GetInput(BalancethicknessThickeningRateEnum);     _assert_(dhdt_input);
+
+	/* Start looping on the number of gaussian points: */
+	gauss=new GaussTria(2);
+	for(int ig=gauss->begin();ig<gauss->end();ig++){
+
+		gauss->GaussPoint(ig);
+
+		/* Get Jacobian determinant: */
+		GetJacobianDeterminant2d(&Jdet, &xyz_list[0][0],gauss);
+
+		/*Get all parameters at gaussian point*/
+		weights_input->GetInputValue(&weight,gauss,weight_index);
+		thickness_input->GetInputValue(&H, gauss);
+		thickness_input->GetInputDerivativeValue(&dH[0],&xyz_list[0][0],gauss);
+		surface_mass_balance_input->GetInputValue(&surface_mass_balance,gauss);
+		basal_melting_input->GetInputValue(&basal_melting,gauss);
+		dhdt_input->GetInputValue(&dhdt,gauss);
+		vx_input->GetInputValue(&vx,gauss);
+		vx_input->GetInputDerivativeValue(&dvx[0],&xyz_list[0][0],gauss);
+		vy_input->GetInputValue(&vy,gauss);
+		vy_input->GetInputDerivativeValue(&dvy[0],&xyz_list[0][0],gauss);
+
+		/*Weak balance thickness J = 1/2 (div(Hv)-a)^2*/
+		temp  = vx*dH[0]+vy*dH[1]+H*(dvx[0]+dvy[1]) - (surface_mass_balance-basal_melting-dhdt);
+		Jelem+=weight*1/2*temp*temp*Jdet*gauss->weight;
+	}
+
+	/*Clean up and return*/
+	delete gauss;
+	return Jelem;
+}
+/*}}}*/
 /*FUNCTION Tria::InputControlUpdate{{{*/
 void  Tria::InputControlUpdate(IssmDouble scalar,bool save_parameter){
@@ -3580,4 +3625,7 @@
 			GradjVyBalancedthickness(gradient,control_index);
 			break;
+		case ThicknessEnum:
+			GradjThicknessWeakBalancedthickness(gradient,control_index);
+			break;
 		default:
 			_error_("control type not supported yet: " << control_type);
@@ -3597,4 +3645,5 @@
 		case ThicknessAlongGradientEnum:
 		case ThicknessAcrossGradientEnum:
+		case BalancethicknessMisfitEnum:
 		case SurfaceAbsVelMisfitEnum:
 		case SurfaceRelVelMisfitEnum:
@@ -4042,4 +4091,114 @@
 	/*Clean up and return*/
 	delete gauss;
+}
+/*}}}*/
+/*FUNCTION Tria::GradjThicknessWeakBalancedthickness{{{*/
+void  Tria::GradjThicknessWeakBalancedthickness(Vector<IssmDouble>* gradient,int control_index){
+
+	/*Intermediaries */
+	int         i,resp;
+	int         vertexpidlist[NUMVERTICES];
+	IssmDouble  Jdet;
+	IssmDouble  thickness,thicknessobs,weight;
+	int         num_responses;
+	IssmDouble  xyz_list[NUMVERTICES][3];
+	IssmDouble  basis[3];
+	IssmDouble  dbasis[NDOF2][NUMVERTICES];
+	IssmDouble  dH[2];
+	IssmDouble  vx,vy,vel;
+	IssmDouble  dvx[2],dvy[2];
+	IssmDouble dhdt,basal_melting,surface_mass_balance;
+	GaussTria *gauss     = NULL;
+	int       *responses = NULL;
+	IssmDouble grade_g[NUMVERTICES] = {0.0};
+
+	/* Get node coordinates and dof list: */
+	GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES);
+	GradientIndexing(&vertexpidlist[0],control_index);
+
+	/*Retrieve all inputs and parameters*/
+	GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES);
+	this->parameters->FindParam(&num_responses,InversionNumCostFunctionsEnum);
+	this->parameters->FindParam(&responses,NULL,NULL,StepResponsesEnum);
+	Input* thickness_input            = inputs->GetInput(ThicknessEnum);                          _assert_(thickness_input);
+	Input* thicknessobs_input         = inputs->GetInput(InversionThicknessObsEnum);              _assert_(thicknessobs_input);
+	Input* weights_input              = inputs->GetInput(InversionCostFunctionsCoefficientsEnum); _assert_(weights_input);
+	Input* vx_input                   = inputs->GetInput(VxEnum);                                 _assert_(vx_input);
+	Input* vy_input                   = inputs->GetInput(VyEnum);                                 _assert_(vy_input);
+	Input* surface_mass_balance_input = inputs->GetInput(SurfaceforcingsMassBalanceEnum);         _assert_(surface_mass_balance_input);
+	Input* basal_melting_input        = inputs->GetInput(BasalforcingsMeltingRateEnum);           _assert_(basal_melting_input);
+	Input* dhdt_input                 = inputs->GetInput(BalancethicknessThickeningRateEnum);     _assert_(dhdt_input);
+
+	/* Start  looping on the number of gaussian points: */
+	gauss=new GaussTria(2);
+	for(int ig=gauss->begin();ig<gauss->end();ig++){
+
+		gauss->GaussPoint(ig);
+
+		GetJacobianDeterminant2d(&Jdet, &xyz_list[0][0],gauss);
+		GetNodalFunctions(basis, gauss);
+		GetNodalFunctionsDerivatives(&dbasis[0][0],&xyz_list[0][0],gauss);
+
+		thickness_input->GetInputValue(&thickness, gauss);
+		thickness_input->GetInputDerivativeValue(&dH[0],&xyz_list[0][0],gauss);
+		thicknessobs_input->GetInputValue(&thicknessobs, gauss);
+
+		/*Loop over all requested responses*/
+		for(resp=0;resp<num_responses;resp++) switch(responses[resp]){
+
+			case ThicknessAbsMisfitEnum:
+				weights_input->GetInputValue(&weight, gauss,resp);
+				for(i=0;i<NUMVERTICES;i++) grade_g[i]+= (thicknessobs-thickness)*weight*Jdet*gauss->weight*basis[i];
+				break;
+			case ThicknessAbsGradientEnum:
+				weights_input->GetInputValue(&weight, gauss,resp);
+				for(i=0;i<NUMVERTICES;i++) grade_g[i]+= - weight*dH[0]*dbasis[0][i]*Jdet*gauss->weight;
+				for(i=0;i<NUMVERTICES;i++) grade_g[i]+= - weight*dH[1]*dbasis[1][i]*Jdet*gauss->weight;
+				break;
+			case ThicknessAlongGradientEnum:
+				weights_input->GetInputValue(&weight, gauss,resp);
+				vx_input->GetInputValue(&vx,gauss);
+				vy_input->GetInputValue(&vy,gauss);
+				vel = sqrt(vx*vx+vy*vy);
+				vx  = vx/(vel+1.e-9);
+				vy  = vy/(vel+1.e-9);
+				for(i=0;i<NUMVERTICES;i++) grade_g[i]+= - weight*(dH[0]*vx+dH[1]*vy)*(dbasis[0][i]*vx+dbasis[1][i]*vy)*Jdet*gauss->weight;
+				break;
+			case ThicknessAcrossGradientEnum:
+				weights_input->GetInputValue(&weight, gauss,resp);
+				vx_input->GetInputValue(&vx,gauss);
+				vy_input->GetInputValue(&vy,gauss);
+				vel = sqrt(vx*vx+vy*vy);
+				vx  = vx/(vel+1.e-9);
+				vy  = vy/(vel+1.e-9);
+				for(i=0;i<NUMVERTICES;i++) grade_g[i]+= - weight*(dH[0]*(-vy)+dH[1]*vx)*(dbasis[0][i]*(-vy)+dbasis[1][i]*vx)*Jdet*gauss->weight;
+				break;
+			case BalancethicknessMisfitEnum:
+				weights_input->GetInputValue(&weight, gauss,resp);
+				surface_mass_balance_input->GetInputValue(&surface_mass_balance,gauss);
+				basal_melting_input->GetInputValue(&basal_melting,gauss);
+				dhdt_input->GetInputValue(&dhdt,gauss);
+				vx_input->GetInputValue(&vx,gauss);
+				vx_input->GetInputDerivativeValue(&dvx[0],&xyz_list[0][0],gauss);
+				vy_input->GetInputValue(&vy,gauss);
+				vy_input->GetInputDerivativeValue(&dvy[0],&xyz_list[0][0],gauss);
+				for(i=0;i<NUMVERTICES;i++){
+					grade_g[i]+= - weight*Jdet*gauss->weight*(
+								(vx*dH[0]+vy*dH[1] + thickness*(dvx[0]+dvy[1]))*(vx*dbasis[0][i]+ vy*dbasis[1][i] + basis[i]*(dvx[0]+dvy[1]))
+								-(surface_mass_balance-basal_melting-dhdt)*(vx*dbasis[0][i]+ vy*dbasis[1][i] + basis[i]*(dvx[0]+dvy[1]))
+								);
+				}
+				break;
+			default:
+				_error_("response " << EnumToStringx(responses[resp]) << " not supported yet");
+		}
+	}
+
+
+	gradient->SetValues(NUMVERTICES,vertexpidlist,grade_g,ADD_VAL);
+
+	/*Clean up and return*/
+	delete gauss;
+	xDelete<int>(responses);
 }
 /*}}}*/
Index: /issm/trunk/src/c/classes/objects/Elements/Tria.h
===================================================================
--- /issm/trunk/src/c/classes/objects/Elements/Tria.h	(revision 14309)
+++ /issm/trunk/src/c/classes/objects/Elements/Tria.h	(revision 14310)
@@ -153,4 +153,5 @@
 		void   GradjVxBalancedthickness(Vector<IssmDouble>* gradient,int control_index);
 		void   GradjVyBalancedthickness(Vector<IssmDouble>* gradient,int control_index);
+		void   GradjThicknessWeakBalancedthickness(Vector<IssmDouble>* gradient,int control_index);
 		void   GetVectorFromControlInputs(Vector<IssmDouble>* gradient,int control_enum,int control_index,const char* data);
 		void   SetControlInputsFromVector(IssmDouble* vector,int control_enum,int control_index);
@@ -164,4 +165,5 @@
 		IssmDouble ThicknessAlongGradient( bool process_units,int weight_index);
 		IssmDouble ThicknessAcrossGradient(bool process_units,int weight_index);
+		IssmDouble BalancethicknessMisfit(     bool process_units,int weight_index);
 		IssmDouble SurfaceRelVelMisfit(    bool process_units,int weight_index);
 		IssmDouble SurfaceLogVelMisfit(    bool process_units,int weight_index);
Index: /issm/trunk/src/c/classes/objects/ExternalResults/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/classes/objects/ExternalResults/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/classes/objects/ExternalResults/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,5 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/classes/objects/ExternalResults)
+# }}}
Index: /issm/trunk/src/c/classes/objects/Inputs/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/classes/objects/Inputs/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/classes/objects/Inputs/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,16 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/classes/objects/Inputs)
+# }}}
+# CORE_SOURCES {{{
+set(CORE_SOURCES $ENV{ISSM_DIR}/src/c/classes/objects/Inputs/BoolInput.cpp
+              $ENV{ISSM_DIR}/src/c/classes/objects/Inputs/DatasetInput.cpp
+               $ENV{ISSM_DIR}/src/c/classes/objects/Inputs/DoubleInput.cpp
+                  $ENV{ISSM_DIR}/src/c/classes/objects/Inputs/IntInput.cpp
+            $ENV{ISSM_DIR}/src/c/classes/objects/Inputs/TransientInput.cpp
+               $ENV{ISSM_DIR}/src/c/classes/objects/Inputs/TriaP1Input.cpp PARENT_SCOPE)
+# }}}
+# THREED_SOURCES {{{
+set(THREED_SOURCES $ENV{ISSM_DIR}/src/c/classes/objects/Inputs/PentaP1Input.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/classes/objects/KML/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/classes/objects/KML/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/classes/objects/KML/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,34 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/classes/objects/KML)
+# }}}
+# KML_SOURCES {{{
+set(KML_SOURCES $ENV{ISSM_DIR}/src/c/classes/objects/KML/KML_Attribute.cpp
+               $ENV{ISSM_DIR}/src/c/classes/objects/KML/KML_ColorStyle.cpp
+                  $ENV{ISSM_DIR}/src/c/classes/objects/KML/KML_Comment.cpp
+                $ENV{ISSM_DIR}/src/c/classes/objects/KML/KML_Container.cpp
+                 $ENV{ISSM_DIR}/src/c/classes/objects/KML/KML_Document.cpp
+                  $ENV{ISSM_DIR}/src/c/classes/objects/KML/KML_Feature.cpp
+                     $ENV{ISSM_DIR}/src/c/classes/objects/KML/KML_File.cpp
+                   $ENV{ISSM_DIR}/src/c/classes/objects/KML/KML_Folder.cpp
+                 $ENV{ISSM_DIR}/src/c/classes/objects/KML/KML_Geometry.cpp
+            $ENV{ISSM_DIR}/src/c/classes/objects/KML/KML_GroundOverlay.cpp
+                     $ENV{ISSM_DIR}/src/c/classes/objects/KML/KML_Icon.cpp
+                $ENV{ISSM_DIR}/src/c/classes/objects/KML/KML_LatLonBox.cpp
+               $ENV{ISSM_DIR}/src/c/classes/objects/KML/KML_LinearRing.cpp
+               $ENV{ISSM_DIR}/src/c/classes/objects/KML/KML_LineString.cpp
+                $ENV{ISSM_DIR}/src/c/classes/objects/KML/KML_LineStyle.cpp
+            $ENV{ISSM_DIR}/src/c/classes/objects/KML/KML_MultiGeometry.cpp
+                   $ENV{ISSM_DIR}/src/c/classes/objects/KML/KML_Object.cpp
+                  $ENV{ISSM_DIR}/src/c/classes/objects/KML/KML_Overlay.cpp
+                $ENV{ISSM_DIR}/src/c/classes/objects/KML/KML_Placemark.cpp
+                    $ENV{ISSM_DIR}/src/c/classes/objects/KML/KML_Point.cpp
+                  $ENV{ISSM_DIR}/src/c/classes/objects/KML/KML_Polygon.cpp
+                $ENV{ISSM_DIR}/src/c/classes/objects/KML/KML_PolyStyle.cpp
+                    $ENV{ISSM_DIR}/src/c/classes/objects/KML/KML_Style.cpp
+            $ENV{ISSM_DIR}/src/c/classes/objects/KML/KML_StyleSelector.cpp
+                 $ENV{ISSM_DIR}/src/c/classes/objects/KML/KML_SubStyle.cpp
+                  $ENV{ISSM_DIR}/src/c/classes/objects/KML/KML_Unknown.cpp
+             $ENV{ISSM_DIR}/src/c/classes/objects/KML/KMLFileReadUtils.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/classes/objects/KML/KML_LineString.cpp
===================================================================
--- /issm/trunk/src/c/classes/objects/KML/KML_LineString.cpp	(revision 14309)
+++ /issm/trunk/src/c/classes/objects/KML/KML_LineString.cpp	(revision 14310)
@@ -197,5 +197,11 @@
 	x  =xNew<IssmDouble>(ncoord);
 	y  =xNew<IssmDouble>(ncoord);
-	Ll2xyx(x,y,lat,lon,ncoord,sgn,cm,sp);
+	if (sgn) {
+		Ll2xyx(x,y,lat,lon,ncoord,sgn,cm,sp);
+	}
+	else {
+		memcpy(x,lon,ncoord*sizeof(IssmDouble));
+		memcpy(y,lat,ncoord*sizeof(IssmDouble));
+	}
 
 /*  write header  */
Index: /issm/trunk/src/c/classes/objects/KML/KML_LinearRing.cpp
===================================================================
--- /issm/trunk/src/c/classes/objects/KML/KML_LinearRing.cpp	(revision 14309)
+++ /issm/trunk/src/c/classes/objects/KML/KML_LinearRing.cpp	(revision 14310)
@@ -186,5 +186,11 @@
 	x  =xNew<IssmDouble>(ncoord);
 	y  =xNew<IssmDouble>(ncoord);
-	Ll2xyx(x,y,lat,lon,ncoord,sgn,cm,sp);
+	if (sgn) {
+		Ll2xyx(x,y,lat,lon,ncoord,sgn,cm,sp);
+	}
+	else {
+		memcpy(x,lon,ncoord*sizeof(IssmDouble));
+		memcpy(y,lat,ncoord*sizeof(IssmDouble));
+	}
 
 /*  write header  */
Index: /issm/trunk/src/c/classes/objects/KML/KML_Point.cpp
===================================================================
--- /issm/trunk/src/c/classes/objects/KML/KML_Point.cpp	(revision 14309)
+++ /issm/trunk/src/c/classes/objects/KML/KML_Point.cpp	(revision 14310)
@@ -166,5 +166,11 @@
 /*  convert latitude and longitude to x and y  */
 
-	Ll2xyx(&x,&y,&lat,&lon,1,sgn,cm,sp);
+	if (sgn) {
+		Ll2xyx(&x,&y,&lat,&lon,1,sgn,cm,sp);
+	}
+	else {
+		memcpy(&x,&lon,1*sizeof(IssmDouble));
+		memcpy(&y,&lat,1*sizeof(IssmDouble));
+	}
 
 /*  write header  */
Index: /issm/trunk/src/c/classes/objects/Loads/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/classes/objects/Loads/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/classes/objects/Loads/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,15 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/classes/objects/Loads)
+# }}}
+# CORE_SOURCES {{{
+set(CORE_SOURCES $ENV{ISSM_DIR}/src/c/classes/objects/Loads/Friction.cpp
+                 $ENV{ISSM_DIR}/src/c/classes/objects/Loads/Icefront.cpp
+            $ENV{ISSM_DIR}/src/c/classes/objects/Loads/Numericalflux.cpp
+                  $ENV{ISSM_DIR}/src/c/classes/objects/Loads/Pengrid.cpp
+                  $ENV{ISSM_DIR}/src/c/classes/objects/Loads/Penpair.cpp PARENT_SCOPE)
+# }}}
+# RIFTS_SOURCES {{{
+set(RIFTS_SOURCES $ENV{ISSM_DIR}/src/c/classes/objects/Loads/Riftfront.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/classes/objects/Materials/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/classes/objects/Materials/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/classes/objects/Materials/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,10 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/classes/objects/Materials)
+# }}}
+# CORE_SOURCES {{{
+set(CORE_SOURCES $ENV{ISSM_DIR}/src/c/classes/objects/Materials/Matdamageice.cpp
+                       $ENV{ISSM_DIR}/src/c/classes/objects/Materials/Matice.cpp
+                       $ENV{ISSM_DIR}/src/c/classes/objects/Materials/Matpar.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/classes/objects/Options/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/classes/objects/Options/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/classes/objects/Options/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,8 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/classes/objects/Options)
+# }}}
+# CORE_SOURCES {{{
+set(CORE_SOURCES $ENV{ISSM_DIR}/src/c/classes/objects/Options/OptionUtilities.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/classes/objects/Params/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/classes/objects/Params/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/classes/objects/Params/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,23 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/classes/objects/Params)
+# }}}
+# CORE_SOURCES {{{
+set(CORE_SOURCES $ENV{ISSM_DIR}/src/c/classes/objects/Params/BoolParam.cpp
+              $ENV{ISSM_DIR}/src/c/classes/objects/Params/DataSetParam.cpp
+       $ENV{ISSM_DIR}/src/c/classes/objects/Params/DoubleMatArrayParam.cpp
+            $ENV{ISSM_DIR}/src/c/classes/objects/Params/DoubleMatParam.cpp
+               $ENV{ISSM_DIR}/src/c/classes/objects/Params/DoubleParam.cpp
+   $ENV{ISSM_DIR}/src/c/classes/objects/Params/DoubleTransientMatParam.cpp
+            $ENV{ISSM_DIR}/src/c/classes/objects/Params/DoubleVecParam.cpp
+                 $ENV{ISSM_DIR}/src/c/classes/objects/Params/FileParam.cpp
+               $ENV{ISSM_DIR}/src/c/classes/objects/Params/IntMatParam.cpp
+                  $ENV{ISSM_DIR}/src/c/classes/objects/Params/IntParam.cpp
+               $ENV{ISSM_DIR}/src/c/classes/objects/Params/IntVecParam.cpp
+               $ENV{ISSM_DIR}/src/c/classes/objects/Params/MatrixParam.cpp
+          $ENV{ISSM_DIR}/src/c/classes/objects/Params/StringArrayParam.cpp
+               $ENV{ISSM_DIR}/src/c/classes/objects/Params/StringParam.cpp
+            $ENV{ISSM_DIR}/src/c/classes/objects/Params/TransientParam.cpp
+               $ENV{ISSM_DIR}/src/c/classes/objects/Params/VectorParam.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/classes/objects/Vertex.cpp
===================================================================
--- /issm/trunk/src/c/classes/objects/Vertex.cpp	(revision 14309)
+++ /issm/trunk/src/c/classes/objects/Vertex.cpp	(revision 14310)
@@ -194,2 +194,20 @@
 }
 /*}}}*/
+/*FUNCTION Vertex::ToXYZ {{{*/
+void  Vertex::ToXYZ(Matrix<IssmDouble>* matrix){
+
+	IssmDouble xyz[3];
+	int        indices[3];
+	
+	if (this->clone==true) return;
+
+	xyz[0]=x;
+	xyz[1]=y; 
+	xyz[2]=z;
+	indices[0]=0;
+	indices[1]=1; 
+	indices[2]=2;
+
+	matrix->SetValues(1,&sid,3,&indices[0],&xyz[0],INS_VAL);
+}
+/*}}}*/
Index: /issm/trunk/src/c/classes/objects/Vertex.h
===================================================================
--- /issm/trunk/src/c/classes/objects/Vertex.h	(revision 14309)
+++ /issm/trunk/src/c/classes/objects/Vertex.h	(revision 14310)
@@ -13,4 +13,5 @@
 #include "../../include/include.h"
 template <class doubletype> class Vector;
+template <class doubletype> class Matrix;
 class Parameters;
 class IoModel;
@@ -53,4 +54,5 @@
 		void  UpdateClonePids(int* allborderpids);
 		void  SetClone(int* minranks);
+		void  ToXYZ(Matrix<IssmDouble>* matrix);
 };
 #endif  /* _VERTEX_H */
Index: /issm/trunk/src/c/include/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/include/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/include/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,5 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/include)
+# }}}
Index: /issm/trunk/src/c/include/globals.h
===================================================================
--- /issm/trunk/src/c/include/globals.h	(revision 14309)
+++ /issm/trunk/src/c/include/globals.h	(revision 14310)
@@ -10,4 +10,5 @@
 
 COMM IssmComm::comm;
+bool IssmComm::parallel;
 
 #endif
Index: /issm/trunk/src/c/io/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/io/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/io/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,9 @@
+# Subdirectories {{{
+add_subdirectory(Disk)
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/io)
+# }}}
+# CORE_SOURCES {{{
+set(CORE_SOURCES $ENV{ISSM_DIR}/src/c/io/PrintfFunction.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/io/Disk/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/io/Disk/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/io/Disk/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,10 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/io/Disk)
+# }}}
+# CORE_SOURCES {{{
+set(CORE_SOURCES $ENV{ISSM_DIR}/src/c/io/Disk/pfclose.cpp
+                  $ENV{ISSM_DIR}/src/c/io/Disk/pfopen.cpp
+           $ENV{ISSM_DIR}/src/c/io/Disk/WriteLockFile.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/io/PrintfFunction.cpp
===================================================================
--- /issm/trunk/src/c/io/PrintfFunction.cpp	(revision 14309)
+++ /issm/trunk/src/c/io/PrintfFunction.cpp	(revision 14310)
@@ -8,4 +8,8 @@
 #include "../shared/shared.h"
 #include "../include/include.h"
+
+#ifdef _HAVE_ANDROID_NDK_
+#include <android/log.h>
+#endif
 
 int PrintfFunction(const char* format,...){
@@ -58,5 +62,9 @@
 
 	if(my_rank==0){
+		#ifdef _HAVE_ANDROID_JNI_
+		__android_log_print(ANDROID_LOG_INFO, "Native",message.c_str());
+		#else
 		printf("%s\n",message.c_str());
+		#endif
 	}
 	return 1;
Index: /issm/trunk/src/c/modules/AverageFilterx/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/AverageFilterx/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/AverageFilterx/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,5 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/AverageFilterx)
+# }}}
Index: /issm/trunk/src/c/modules/AverageOntoPartitionx/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/AverageOntoPartitionx/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/AverageOntoPartitionx/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,8 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/AverageOntoPartitionx)
+# }}}
+# DAKOTA_SOURCES {{{
+set(DAKOTA_SOURCES $ENV{ISSM_DIR}/src/c/modules/AverageOntoPartitionx/AverageOntoPartitionx.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/modules/BamgConvertMeshx/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/BamgConvertMeshx/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/BamgConvertMeshx/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,8 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/BamgConvertMeshx)
+# }}}
+# BAMG_SOURCES {{{
+set(BAMG_SOURCES $ENV{ISSM_DIR}/src/c/modules/BamgConvertMeshx/BamgConvertMeshx.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/modules/BamgTriangulatex/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/BamgTriangulatex/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/BamgTriangulatex/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,8 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/BamgTriangulatex)
+# }}}
+# BAMG_SOURCES {{{
+set(BAMG_SOURCES $ENV{ISSM_DIR}/src/c/modules/BamgTriangulatex/BamgTriangulatex.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/modules/Bamgx/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/Bamgx/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/Bamgx/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,8 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/Bamgx)
+# }}}
+# BAMG_SOURCES {{{
+set(BAMG_SOURCES $ENV{ISSM_DIR}/src/c/modules/Bamgx/Bamgx.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/modules/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,100 @@
+# Subdirectories {{{
+add_subdirectory(AverageFilterx)
+add_subdirectory(AverageOntoPartitionx)
+add_subdirectory(BamgConvertMeshx)
+add_subdirectory(BamgTriangulatex)
+add_subdirectory(Bamgx)
+add_subdirectory(Chacox)
+add_subdirectory(ComputeBasalStressx)
+add_subdirectory(ComputeStrainRatex)
+add_subdirectory(ConfigureObjectsx)
+add_subdirectory(ConstraintsStatex)
+add_subdirectory(ContourToMeshx)
+add_subdirectory(ContourToNodesx)
+add_subdirectory(ControlInputGetGradientx)
+add_subdirectory(ControlInputScaleGradientx)
+add_subdirectory(ControlInputSetGradientx)
+add_subdirectory(CreateNodalConstraintsx)
+add_subdirectory(Delta18oParameterizationx)
+add_subdirectory(DragCoefficientAbsGradientx)
+add_subdirectory(ElementConnectivityx)
+add_subdirectory(EnumToStringx)
+add_subdirectory(Exp2Kmlx)
+add_subdirectory(GetSolutionFromInputsx)
+add_subdirectory(GetVectorFromControlInputsx)
+add_subdirectory(GetVectorFromInputsx)
+add_subdirectory(Gradjx)
+add_subdirectory(GroundinglineMigrationx)
+add_subdirectory(HoleFillerx)
+add_subdirectory(InputArtificialNoisex)
+add_subdirectory(InputControlUpdatex)
+add_subdirectory(InputConvergencex)
+add_subdirectory(InputDuplicatex)
+add_subdirectory(InputScalex)
+add_subdirectory(InputToResultx)
+add_subdirectory(InputUpdateFromConstantx)
+add_subdirectory(InputUpdateFromDakotax)
+add_subdirectory(InputUpdateFromMatrixDakotax)
+add_subdirectory(InputUpdateFromSolutionx)
+add_subdirectory(InputUpdateFromVectorDakotax)
+add_subdirectory(InputUpdateFromVectorx)
+add_subdirectory(InterpFromGridToMeshx)
+add_subdirectory(InterpFromMesh2dx)
+add_subdirectory(InterpFromMeshToGridx)
+add_subdirectory(InterpFromMeshToMesh2dx)
+add_subdirectory(InterpFromMeshToMesh3dx)
+add_subdirectory(IoModelToConstraintsx)
+add_subdirectory(Kml2Expx)
+add_subdirectory(KMLFileReadx)
+add_subdirectory(KMLMeshWritex)
+add_subdirectory(KMLOverlayx)
+add_subdirectory(Krigingx)
+add_subdirectory(Ll2xyx)
+add_subdirectory(Mergesolutionfromftogx)
+add_subdirectory(MeshPartitionx)
+add_subdirectory(MeshProfileIntersectionx)
+add_subdirectory(ModelProcessorx)
+add_subdirectory(NodalValuex)
+add_subdirectory(NodeConnectivityx)
+add_subdirectory(NodesDofx)
+add_subdirectory(Orthx)
+add_subdirectory(OutputResultsx)
+add_subdirectory(OutputRiftsx)
+add_subdirectory(ParsePetscOptionsx)
+add_subdirectory(PointCloudFindNeighborsx)
+add_subdirectory(PositiveDegreeDayx)
+add_subdirectory(PropagateFlagsFromConnectivityx)
+add_subdirectory(Reduceloadx)
+add_subdirectory(Reducevectorgtofx)
+add_subdirectory(Reducevectorgtosx)
+add_subdirectory(ResetConstraintsx)
+add_subdirectory(ResetCoordinateSystemx)
+add_subdirectory(RheologyBbarAbsGradientx)
+add_subdirectory(Scotchx)
+add_subdirectory(SetControlInputsFromVectorx)
+add_subdirectory(Shp2Expx)
+add_subdirectory(Shp2Kmlx)
+add_subdirectory(SmbGradientsx)
+add_subdirectory(Solverx)
+add_subdirectory(SpcNodesx)
+add_subdirectory(StringToEnumx)
+add_subdirectory(SurfaceAbsVelMisfitx)
+add_subdirectory(SurfaceAreax)
+add_subdirectory(SurfaceAverageVelMisfitx)
+add_subdirectory(SurfaceLogVelMisfitx)
+add_subdirectory(SurfaceLogVxVyMisfitx)
+add_subdirectory(SurfaceRelVelMisfitx)
+add_subdirectory(ThicknessAbsMisfitx)
+add_subdirectory(ThicknessAcrossGradientx)
+add_subdirectory(ThicknessAlongGradientx)
+add_subdirectory(TriaSearchx)
+add_subdirectory(TriMeshProcessRiftsx)
+add_subdirectory(TriMeshx)
+add_subdirectory(UpdateDynamicConstraintsx)
+add_subdirectory(VecMergex)
+add_subdirectory(VerticesDofx)
+add_subdirectory(Xy2llx)
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules)
+# }}}
Index: /issm/trunk/src/c/modules/Chacox/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/Chacox/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/Chacox/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,5 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/Chacox)
+# }}}
Index: /issm/trunk/src/c/modules/ComputeBasalStressx/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/ComputeBasalStressx/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/ComputeBasalStressx/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,8 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/ComputeBasalStressx)
+# }}}
+# CORE_SOURCES {{{
+set(CORE_SOURCES $ENV{ISSM_DIR}/src/c/modules/ComputeBasalStressx/ComputeBasalStressx.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/modules/ComputeStrainRatex/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/ComputeStrainRatex/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/ComputeStrainRatex/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,8 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/ComputeStrainRatex)
+# }}}
+# CORE_SOURCES {{{
+set(CORE_SOURCES $ENV{ISSM_DIR}/src/c/modules/ComputeStrainRatex/ComputeStrainRatex.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/modules/ConfigureObjectsx/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/ConfigureObjectsx/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/ConfigureObjectsx/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,8 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/ConfigureObjectsx)
+# }}}
+# CORE_SOURCES {{{
+set(CORE_SOURCES $ENV{ISSM_DIR}/src/c/modules/ConfigureObjectsx/ConfigureObjectsx.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/modules/ConstraintsStatex/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/ConstraintsStatex/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/ConstraintsStatex/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,15 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/ConstraintsStatex)
+# }}}
+# CORE_SOURCES {{{
+set(CORE_SOURCES $ENV{ISSM_DIR}/src/c/modules/ConstraintsStatex/ConstraintsStatex.cpp PARENT_SCOPE)
+# }}}
+# THERMAL_SOURCES {{{
+set(THERMAL_SOURCES $ENV{ISSM_DIR}/src/c/modules/ConstraintsStatex/ThermalConstraintsState.cpp
+                           $ENV{ISSM_DIR}/src/c/modules/ConstraintsStatex/ThermalIsPresent.cpp PARENT_SCOPE)
+# }}}
+# RIFTS_SOURCES {{{
+set(RIFTS_SOURCES $ENV{ISSM_DIR}/src/c/modules/ConstraintsStatex/RiftConstraintsState.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/modules/ContourToMeshx/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/ContourToMeshx/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/ContourToMeshx/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,5 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/ContourToMeshx)
+# }}}
Index: /issm/trunk/src/c/modules/ContourToNodesx/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/ContourToNodesx/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/ContourToNodesx/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,5 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/ContourToNodesx)
+# }}}
Index: /issm/trunk/src/c/modules/ControlInputGetGradientx/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/ControlInputGetGradientx/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/ControlInputGetGradientx/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,5 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/ControlInputGetGradientx)
+# }}}
Index: /issm/trunk/src/c/modules/ControlInputScaleGradientx/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/ControlInputScaleGradientx/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/ControlInputScaleGradientx/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,5 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/ControlInputScaleGradientx)
+# }}}
Index: /issm/trunk/src/c/modules/ControlInputSetGradientx/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/ControlInputSetGradientx/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/ControlInputSetGradientx/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,5 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/ControlInputSetGradientx)
+# }}}
Index: /issm/trunk/src/c/modules/CreateNodalConstraintsx/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/CreateNodalConstraintsx/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/CreateNodalConstraintsx/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,8 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/CreateNodalConstraintsx)
+# }}}
+# CORE_SOURCES {{{
+set(CORE_SOURCES $ENV{ISSM_DIR}/src/c/modules/CreateNodalConstraintsx/CreateNodalConstraintsx.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/modules/Delta18oParameterizationx/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/Delta18oParameterizationx/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/Delta18oParameterizationx/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,8 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/Delta18oParameterizationx)
+# }}}
+# CORE_SOURCES {{{
+set(CORE_SOURCES $ENV{ISSM_DIR}/src/c/modules/Delta18oParameterizationx/Delta18oParameterizationx.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/modules/DragCoefficientAbsGradientx/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/DragCoefficientAbsGradientx/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/DragCoefficientAbsGradientx/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,5 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/DragCoefficientAbsGradientx)
+# }}}
Index: /issm/trunk/src/c/modules/ElementConnectivityx/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/ElementConnectivityx/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/ElementConnectivityx/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,5 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/ElementConnectivityx)
+# }}}
Index: /issm/trunk/src/c/modules/EnumToStringx/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/EnumToStringx/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/EnumToStringx/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,8 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/EnumToStringx)
+# }}}
+# CORE_SOURCES {{{
+set(CORE_SOURCES $ENV{ISSM_DIR}/src/c/modules/EnumToStringx/EnumToStringx.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/modules/EnumToStringx/EnumToStringx.cpp
===================================================================
--- /issm/trunk/src/c/modules/EnumToStringx/EnumToStringx.cpp	(revision 14309)
+++ /issm/trunk/src/c/modules/EnumToStringx/EnumToStringx.cpp	(revision 14310)
@@ -201,12 +201,7 @@
 		case SurfaceforcingsIssmbgradientsEnum : return "SurfaceforcingsIssmbgradients";
 		case SurfaceforcingsMonthlytemperaturesEnum : return "SurfaceforcingsMonthlytemperatures";
-		case SurfaceforcingsHcEnum : return "SurfaceforcingsHc";
 		case SurfaceforcingsHrefEnum : return "SurfaceforcingsHref";
 		case SurfaceforcingsSmbrefEnum : return "SurfaceforcingsSmbref";
-		case SurfaceforcingsSmbPosMaxEnum : return "SurfaceforcingsSmbPosMax";
-		case SurfaceforcingsSmbPosMinEnum : return "SurfaceforcingsSmbPosMin";
-		case SurfaceforcingsAPosEnum : return "SurfaceforcingsAPos";
 		case SurfaceforcingsBPosEnum : return "SurfaceforcingsBPos";
-		case SurfaceforcingsANegEnum : return "SurfaceforcingsANeg";
 		case SurfaceforcingsBNegEnum : return "SurfaceforcingsBNeg";
 		case ThermalMaxiterEnum : return "ThermalMaxiter";
@@ -238,4 +233,6 @@
 		case BalancethicknessAnalysisEnum : return "BalancethicknessAnalysis";
 		case BalancethicknessSolutionEnum : return "BalancethicknessSolution";
+		case WeakBalancethicknessAnalysisEnum : return "WeakBalancethicknessAnalysis";
+		case WeakBalancethicknessSolutionEnum : return "WeakBalancethicknessSolution";
 		case BedSlopeAnalysisEnum : return "BedSlopeAnalysis";
 		case BedSlopeSolutionEnum : return "BedSlopeSolution";
@@ -346,4 +343,5 @@
 		case AdjointyEnum : return "Adjointy";
 		case AdjointzEnum : return "Adjointz";
+		case BalancethicknessMisfitEnum : return "BalancethicknessMisfit";
 		case BedSlopeXEnum : return "BedSlopeX";
 		case BedSlopeYEnum : return "BedSlopeY";
@@ -373,4 +371,5 @@
 		case QmuSurfaceEnum : return "QmuSurface";
 		case QmuMeltingEnum : return "QmuMelting";
+		case AndroidFrictionCoefficientEnum : return "AndroidFrictionCoefficient";
 		case ResetPenaltiesEnum : return "ResetPenalties";
 		case SegmentOnIceShelfEnum : return "SegmentOnIceShelf";
@@ -416,5 +415,4 @@
 		case DragCoefficientAbsGradientEnum : return "DragCoefficientAbsGradient";
 		case TransientInputEnum : return "TransientInput";
-		case OutputfilenameEnum : return "Outputfilename";
 		case WaterfractionEnum : return "Waterfraction";
 		case WatercolumnEnum : return "Watercolumn";
Index: /issm/trunk/src/c/modules/Exp2Kmlx/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/Exp2Kmlx/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/Exp2Kmlx/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,8 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/Exp2Kmlx)
+# }}}
+# KML_SOURCES {{{
+set(KML_SOURCES $ENV{ISSM_DIR}/src/c/modules/Exp2Kmlx/Exp2Kmlx.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/modules/GetSolutionFromInputsx/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/GetSolutionFromInputsx/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/GetSolutionFromInputsx/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,8 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/GetSolutionFromInputsx)
+# }}}
+# CORE_SOURCES {{{
+set(CORE_SOURCES $ENV{ISSM_DIR}/src/c/modules/GetSolutionFromInputsx/GetSolutionFromInputsx.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/modules/GetVectorFromControlInputsx/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/GetVectorFromControlInputsx/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/GetVectorFromControlInputsx/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,5 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/GetVectorFromControlInputsx)
+# }}}
Index: /issm/trunk/src/c/modules/GetVectorFromInputsx/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/GetVectorFromInputsx/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/GetVectorFromInputsx/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,8 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/GetVectorFromInputsx)
+# }}}
+# CORE_SOURCES {{{
+set(CORE_SOURCES $ENV{ISSM_DIR}/src/c/modules/GetVectorFromInputsx/GetVectorFromInputsx.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/modules/Gradjx/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/Gradjx/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/Gradjx/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,5 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/Gradjx)
+# }}}
Index: /issm/trunk/src/c/modules/GroundinglineMigrationx/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/GroundinglineMigrationx/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/GroundinglineMigrationx/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,5 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/GroundinglineMigrationx)
+# }}}
Index: /issm/trunk/src/c/modules/HoleFillerx/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/HoleFillerx/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/HoleFillerx/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,5 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/HoleFillerx)
+# }}}
Index: /issm/trunk/src/c/modules/InputArtificialNoisex/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/InputArtificialNoisex/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/InputArtificialNoisex/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,8 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/InputArtificialNoisex)
+# }}}
+# CORE_SOURCES {{{
+set(CORE_SOURCES $ENV{ISSM_DIR}/src/c/modules/InputArtificialNoisex/InputArtificialNoisex.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/modules/InputControlUpdatex/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/InputControlUpdatex/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/InputControlUpdatex/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,5 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/InputControlUpdatex)
+# }}}
Index: /issm/trunk/src/c/modules/InputConvergencex/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/InputConvergencex/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/InputConvergencex/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,8 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/InputConvergencex)
+# }}}
+# CORE_SOURCES {{{
+set(CORE_SOURCES $ENV{ISSM_DIR}/src/c/modules/InputConvergencex/InputConvergencex.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/modules/InputDuplicatex/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/InputDuplicatex/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/InputDuplicatex/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,8 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/InputDuplicatex)
+# }}}
+# CORE_SOURCES {{{
+set(CORE_SOURCES $ENV{ISSM_DIR}/src/c/modules/InputDuplicatex/InputDuplicatex.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/modules/InputScalex/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/InputScalex/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/InputScalex/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,8 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/InputScalex)
+# }}}
+# CORE_SOURCES {{{
+set(CORE_SOURCES $ENV{ISSM_DIR}/src/c/modules/InputScalex/InputScalex.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/modules/InputToResultx/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/InputToResultx/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/InputToResultx/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,8 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/InputToResultx)
+# }}}
+# CORE_SOURCES {{{
+set(CORE_SOURCES $ENV{ISSM_DIR}/src/c/modules/InputToResultx/InputToResultx.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/modules/InputUpdateFromConstantx/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/InputUpdateFromConstantx/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/InputUpdateFromConstantx/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,8 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/InputUpdateFromConstantx)
+# }}}
+# CORE_SOURCES {{{
+set(CORE_SOURCES $ENV{ISSM_DIR}/src/c/modules/InputUpdateFromConstantx/InputUpdateFromConstantx.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/modules/InputUpdateFromDakotax/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/InputUpdateFromDakotax/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/InputUpdateFromDakotax/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,8 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/InputUpdateFromDakotax)
+# }}}
+# DAKOTA_SOURCES {{{
+set(DAKOTA_SOURCES $ENV{ISSM_DIR}/src/c/modules/InputUpdateFromDakotax/InputUpdateFromDakotax.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/modules/InputUpdateFromMatrixDakotax/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/InputUpdateFromMatrixDakotax/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/InputUpdateFromMatrixDakotax/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,8 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/InputUpdateFromMatrixDakotax)
+# }}}
+# DAKOTA_SOURCES {{{
+set(DAKOTA_SOURCES $ENV{ISSM_DIR}/src/c/modules/InputUpdateFromMatrixDakotax/InputUpdateFromMatrixDakotax.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/modules/InputUpdateFromSolutionx/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/InputUpdateFromSolutionx/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/InputUpdateFromSolutionx/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,8 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/InputUpdateFromSolutionx)
+# }}}
+# CORE_SOURCES {{{
+set(CORE_SOURCES $ENV{ISSM_DIR}/src/c/modules/InputUpdateFromSolutionx/InputUpdateFromSolutionx.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/modules/InputUpdateFromVectorDakotax/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/InputUpdateFromVectorDakotax/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/InputUpdateFromVectorDakotax/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,8 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/InputUpdateFromVectorDakotax)
+# }}}
+# DAKOTA_SOURCES {{{
+set(DAKOTA_SOURCES $ENV{ISSM_DIR}/src/c/modules/InputUpdateFromVectorDakotax/InputUpdateFromVectorDakotax.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/modules/InputUpdateFromVectorx/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/InputUpdateFromVectorx/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/InputUpdateFromVectorx/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,8 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/InputUpdateFromVectorx)
+# }}}
+# CORE_SOURCES {{{
+set(CORE_SOURCES $ENV{ISSM_DIR}/src/c/modules/InputUpdateFromVectorx/InputUpdateFromVectorx.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/modules/InterpFromGridToMeshx/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/InterpFromGridToMeshx/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/InterpFromGridToMeshx/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,5 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/InterpFromGridToMeshx)
+# }}}
Index: /issm/trunk/src/c/modules/InterpFromMesh2dx/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/InterpFromMesh2dx/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/InterpFromMesh2dx/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,5 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/InterpFromMesh2dx)
+# }}}
Index: /issm/trunk/src/c/modules/InterpFromMeshToGridx/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/InterpFromMeshToGridx/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/InterpFromMeshToGridx/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,5 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/InterpFromMeshToGridx)
+# }}}
Index: /issm/trunk/src/c/modules/InterpFromMeshToMesh2dx/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/InterpFromMeshToMesh2dx/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/InterpFromMeshToMesh2dx/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,5 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/InterpFromMeshToMesh2dx)
+# }}}
Index: /issm/trunk/src/c/modules/InterpFromMeshToMesh3dx/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/InterpFromMeshToMesh3dx/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/InterpFromMeshToMesh3dx/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,5 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/InterpFromMeshToMesh3dx)
+# }}}
Index: /issm/trunk/src/c/modules/IoModelToConstraintsx/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/IoModelToConstraintsx/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/IoModelToConstraintsx/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,8 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/IoModelToConstraintsx)
+# }}}
+# CORE_SOURCES {{{
+set(CORE_SOURCES $ENV{ISSM_DIR}/src/c/modules/IoModelToConstraintsx/IoModelToConstraintsx.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/modules/KMLFileReadx/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/KMLFileReadx/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/KMLFileReadx/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,8 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/KMLFileReadx)
+# }}}
+# KML_SOURCES {{{
+set(KML_SOURCES $ENV{ISSM_DIR}/src/c/modules/KMLFileReadx/KMLFileReadx.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/modules/KMLMeshWritex/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/KMLMeshWritex/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/KMLMeshWritex/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,8 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/KMLMeshWritex)
+# }}}
+# KML_SOURCES {{{
+set(KML_SOURCES $ENV{ISSM_DIR}/src/c/modules/KMLMeshWritex/KMLMeshWritex.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/modules/KMLOverlayx/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/KMLOverlayx/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/KMLOverlayx/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,8 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/KMLOverlayx)
+# }}}
+# KML_SOURCES {{{
+set(KML_SOURCES $ENV{ISSM_DIR}/src/c/modules/KMLOverlayx/KMLOverlayx.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/modules/Kml2Expx/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/Kml2Expx/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/Kml2Expx/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,8 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/Kml2Expx)
+# }}}
+# KML_SOURCES {{{
+set(KML_SOURCES $ENV{ISSM_DIR}/src/c/modules/Kml2Expx/Kml2Expx.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/modules/Krigingx/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/Krigingx/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/Krigingx/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,11 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/Krigingx)
+# }}}
+# KRIGING_SOURCES {{{
+set(KRIGING_SOURCES $ENV{ISSM_DIR}/src/c/modules/Krigingx/Krigingx.cpp PARENT_SCOPE)
+# }}}
+# PKRIGING_SOURCES {{{
+set(PKRIGING_SOURCES $ENV{ISSM_DIR}/src/c/modules/Krigingx/pKrigingx.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/modules/Krigingx/Krigingx.cpp
===================================================================
--- /issm/trunk/src/c/modules/Krigingx/Krigingx.cpp	(revision 14309)
+++ /issm/trunk/src/c/modules/Krigingx/Krigingx.cpp	(revision 14310)
@@ -57,4 +57,22 @@
 	else if(strcmp(output,"variomap")==0){
 		observations->Variomap(predictions,x_interp,n_interp);
+	}
+	else if(strcmp(output,"distance")==0){
+		/*initialize thread parameters: */
+		gate.n_interp     = n_interp;
+		gate.x_interp     = x_interp;
+		gate.y_interp     = y_interp;
+		gate.radius       = radius;
+		gate.mindata      = mindata;
+		gate.maxdata      = maxdata;
+		gate.variogram    = variogram;
+		gate.observations = observations;
+		gate.predictions  = predictions;
+		gate.error        = error;
+		gate.numdone      = xNewZeroInit<int>(num);
+
+		/*launch the thread manager with Krigingxt as a core: */
+		LaunchThread(Distancest,(void*)&gate,num);
+		xDelete<int>(gate.numdone);
 	}
 	else if(strcmp(output,"delaunay")==0){
@@ -360,4 +378,38 @@
 	return NULL;
 }/*}}}*/
+/*FUNCTION Distancest{{{*/
+void* Distancest(void* vpthread_handle){
+
+	/*gate variables :*/
+	KrigingxThreadStruct *gate        = NULL;
+	pthread_handle       *handle      = NULL;
+	int my_thread;
+	int num_threads;
+	int i0,i1;
+
+	/*recover handle and gate: */
+	handle      = (pthread_handle*)vpthread_handle;
+	gate        = (KrigingxThreadStruct*)handle->gate;
+	my_thread   = handle->id;
+	num_threads = handle->num;
+
+	/*recover parameters :*/
+	int           n_interp     = gate->n_interp;
+	double       *x_interp     = gate->x_interp;
+	double       *y_interp     = gate->y_interp;
+	double        radius       = gate->radius;
+	int           mindata      = gate->mindata;
+	int           maxdata      = gate->maxdata;
+	Variogram    *variogram    = gate->variogram;
+	Observations *observations = gate->observations;
+	double       *predictions  = gate->predictions;
+	double       *error        = gate->error;
+	int          *numdone      = gate->numdone;
+
+	/*partition loop across threads: */
+	PartitionRange(&i0,&i1,n_interp,num_threads,my_thread);
+	observations->Distances(&predictions[i0],&x_interp[i0],&y_interp[i0],i1-i0,radius);
+	return NULL;
+}/*}}}*/
 
 void ProcessVariogram(Variogram **pvariogram,Options* options){/*{{{*/
Index: /issm/trunk/src/c/modules/Krigingx/Krigingx.h
===================================================================
--- /issm/trunk/src/c/modules/Krigingx/Krigingx.h	(revision 14309)
+++ /issm/trunk/src/c/modules/Krigingx/Krigingx.h	(revision 14310)
@@ -36,3 +36,4 @@
 void* idwt(void*);
 void* v4t(void*);
+void* Distancest(void*);
 #endif /* _KRIGINGX_H */
Index: /issm/trunk/src/c/modules/Ll2xyx/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/Ll2xyx/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/Ll2xyx/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,5 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/Ll2xyx)
+# }}}
Index: /issm/trunk/src/c/modules/Mergesolutionfromftogx/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/Mergesolutionfromftogx/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/Mergesolutionfromftogx/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,8 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/Mergesolutionfromftogx)
+# }}}
+# CORE_SOURCES {{{
+set(CORE_SOURCES $ENV{ISSM_DIR}/src/c/modules/Mergesolutionfromftogx/Mergesolutionfromftogx.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/modules/MeshPartitionx/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/MeshPartitionx/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/MeshPartitionx/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,5 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/MeshPartitionx)
+# }}}
Index: /issm/trunk/src/c/modules/MeshProfileIntersectionx/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/MeshProfileIntersectionx/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/MeshProfileIntersectionx/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,5 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/MeshProfileIntersectionx)
+# }}}
Index: sm/trunk/src/c/modules/MeshProfileIntersectionx/ElementSegment.cpp
===================================================================
--- /issm/trunk/src/c/modules/MeshProfileIntersectionx/ElementSegment.cpp	(revision 14309)
+++ 	(revision )
@@ -1,90 +1,0 @@
-/*! \file  ElementSegment.cpp
- */
-
-#include "./MeshProfileIntersectionx.h"
-
-void ElementSegment(DataSet* segments_dataset,int el,double* xnodes,double* ynodes,double* xsegment,double* ysegment){
-
-	/*We have a tria element (xnodes,ynodes) and a segment (xsegment,ysegment). Find whether they intersect. 
-	 * If they do, create a Segment object with the intersection, and add to segments_dataset dataset: */
-
-	double alpha1,alpha2;
-	double beta1,beta2;
-	double gamma1,gamma2;
-
-	int    edge1,edge2,edge3;
-
-	double xel[2],yel[2];
-	double coord1,coord2;
-	double xfinal[2],yfinal[2];
-
-	/*edge 1: */
-	xel[0]=xnodes[0];  yel[0]=ynodes[0]; xel[1]=xnodes[1];  yel[1]=ynodes[1];
-	edge1=SegmentIntersect(&alpha1,&alpha2, xel,yel,xsegment,ysegment); //alpha1: segment coordinate of intersection. alpha2: same thing for second interesection if it exists (colinear edges)
-
-	/*edge 2: */
-	xel[0]=xnodes[1];  yel[0]=ynodes[1]; xel[1]=xnodes[2];  yel[1]=ynodes[2];
-	edge2=SegmentIntersect(&beta1,&beta2, xel,yel,xsegment,ysegment);
-
-	/*edge 3: */
-	xel[0]=xnodes[2];  yel[0]=ynodes[2]; xel[1]=xnodes[0];  yel[1]=ynodes[0];
-	edge3=SegmentIntersect(&gamma1,&gamma2, xel,yel,xsegment,ysegment);
-
-	/*edge can be either IntersectEnum (one iand only one intersection between the edge and the segment), ColinearEnum (edge and segment are collinear) and SeparateEnum (no intersection): */
-
-	if(    (edge1==IntersectEnum) && (edge2==IntersectEnum) && (edge3==IntersectEnum)   ){
-		/*This case is impossible: */
-		_error_("error: a line cannot go through 3 different vertices!");
-	}
-	else if(    ((edge1==IntersectEnum) && (edge2==IntersectEnum)) || ((edge2==IntersectEnum) && (edge3==IntersectEnum)) || ((edge3==IntersectEnum) && (edge1==IntersectEnum))   ){
-
-		/*segment interscts 2 opposite edges of our triangle, at 2 segment coordinates, pick up the lowest (coord1) and highest (coord2): */
-		if((edge1==IntersectEnum) && (edge2==IntersectEnum)) {coord1=min(alpha1,beta1); coord2=max(alpha1,beta1);}
-		if((edge2==IntersectEnum) && (edge3==IntersectEnum)) {coord1=min(beta1,gamma1); coord2=max(beta1,gamma1);}
-		if((edge3==IntersectEnum) && (edge1==IntersectEnum)) {coord1=min(gamma1,alpha1); coord2=max(gamma1,alpha1);}
-
-		/*check this segment did not intersect at a vertex of the tria: */
-		if(coord1!=coord2){
-
-			xfinal[0]=xsegment[0]+coord1*(xsegment[1]-xsegment[0]);
-			xfinal[1]=xsegment[0]+coord2*(xsegment[1]-xsegment[0]);
-			yfinal[0]=ysegment[0]+coord1*(ysegment[1]-ysegment[0]);
-			yfinal[1]=ysegment[0]+coord2*(ysegment[1]-ysegment[0]);
-
-			segments_dataset->AddObject(new  Segment<double>(el+1,xfinal[0],yfinal[0],xfinal[1],yfinal[1]));
-		}
-		else{
-			/*the segment intersected at the vertex, do not bother with this "0" length segment!:*/
-		}
-	}
-	else if(  (edge1==IntersectEnum) || (edge2==IntersectEnum) || (edge3==IntersectEnum)   ){
-
-		/*segment intersect only 1 edge. Figure out where the first point in the segment is, inside or outside the element, 
-		 * this will decide the coordinate: */
-		if (NodeInElement(xnodes,ynodes,xsegment[0],ysegment[0])){
-			coord1=0;
-			if(edge1==IntersectEnum){coord2=alpha1;}
-			if(edge2==IntersectEnum){coord2=beta1;}
-			if(edge3==IntersectEnum){coord2=gamma1;}
-		}
-		else{
-			if(edge1==IntersectEnum){coord1=alpha1;}
-			if(edge2==IntersectEnum){coord1=beta1;}
-			if(edge3==IntersectEnum){coord1=gamma1;}
-			coord2=1.0;
-		}
-
-		xfinal[0]=xsegment[0]+coord1*(xsegment[1]-xsegment[0]);
-		xfinal[1]=xsegment[0]+coord2*(xsegment[1]-xsegment[0]);
-		yfinal[0]=ysegment[0]+coord1*(ysegment[1]-ysegment[0]);
-		yfinal[1]=ysegment[0]+coord2*(ysegment[1]-ysegment[0]);
-
-		segments_dataset->AddObject(new  Segment<double>(el+1,xfinal[0],yfinal[0],xfinal[1],yfinal[1]));
-	}
-	else{
-		/*No interesections, but the segment might be entirely inside this triangle!: */
-		if ( (NodeInElement(xnodes,ynodes,xsegment[0],ysegment[0])) && (NodeInElement(xnodes,ynodes,xsegment[1],ysegment[1])) ){
-			segments_dataset->AddObject(new  Segment<double>(el+1,xsegment[0],ysegment[0],xsegment[1],ysegment[1]));
-		}
-	}
-}
Index: sm/trunk/src/c/modules/MeshProfileIntersectionx/ElementSegmentsIntersection.cpp
===================================================================
--- /issm/trunk/src/c/modules/MeshProfileIntersectionx/ElementSegmentsIntersection.cpp	(revision 14309)
+++ 	(revision )
@@ -1,23 +1,0 @@
-/*! \file  ElementSegmentsIntersection.cpp
- */
-
-#include "./MeshProfileIntersectionx.h"
-
-void ElementSegmentsIntersection(DataSet* segments_dataset,int el, double* xnodes,double* ynodes,double* xc,double* yc,int numnodes){
-
-	int i;
-	double xsegment[2];
-	double ysegment[2];
-
-	/*Loop through contour: */
-	for(i=0;i<numnodes-1;i++){
-
-		xsegment[0]=xc[i];
-		xsegment[1]=xc[i+1];
-		ysegment[0]=yc[i];
-		ysegment[1]=yc[i+1];
-
-		ElementSegment(segments_dataset,el, xnodes,ynodes,xsegment,ysegment);
-
-	}
-}
Index: /issm/trunk/src/c/modules/MeshProfileIntersectionx/MeshProfileIntersectionx.cpp
===================================================================
--- /issm/trunk/src/c/modules/MeshProfileIntersectionx/MeshProfileIntersectionx.cpp	(revision 14309)
+++ /issm/trunk/src/c/modules/MeshProfileIntersectionx/MeshProfileIntersectionx.cpp	(revision 14310)
@@ -4,5 +4,5 @@
 #include "./MeshProfileIntersectionx.h"
 
-void MeshProfileIntersectionx( double** psegments, int* pnumsegs, int* index, double* x, double* y, int nel, int nods,  Contour<IssmPDouble>** contours,int numcontours){
+void MeshProfileIntersectionx(double** psegments, int* pnumsegs, int* index, double* x, double* y, int nel, int nods,  Contour<IssmPDouble>** contours,int numcontours){/*{{{*/
 
 	int i,j,k;
@@ -20,8 +20,8 @@
 	/*intermediary: */
 	double** allsegments=NULL;
-	double* segmentsi=NULL;
-	int*    allnumsegs=NULL;
-	int     numsegsi;
-	int     count;
+	double*  segmentsi=NULL;
+	int*     allnumsegs=NULL;
+	int      numsegsi;
+	int      count;
 
 	/*Allocate: */
@@ -69,3 +69,278 @@
 	*psegments=segments;
 	*pnumsegs=numsegs;
-}
+}/*}}}*/
+void MeshSegmentsIntersection(double** psegments, int* pnumsegs,int* index, double* x, double* y, int nel, int nods, double* xc, double* yc, int numnodes){/*{{{*/
+
+	int      i,j;
+
+	/*output: */
+	double*  segments=NULL;
+	Segment<double>* segment=NULL;
+	int     numsegs;
+
+	/*intermediary: */
+	DataSet* segments_dataset=NULL;
+	double   xnodes[3];
+	double   ynodes[3];
+
+	/*We don't know how many segments  we are going to get, so have a dynamic container: */
+	segments_dataset=new DataSet();
+
+	/*Go through elements, and call ElementSegmentsIntersection routine: */
+	for(i=0;i<nel;i++){
+		for(j=0;j<3;j++){
+			xnodes[j]=x[*(index+3*i+j)];
+			ynodes[j]=y[*(index+3*i+j)];
+		}
+		ElementSegmentsIntersection(segments_dataset,i,xnodes,ynodes,xc,yc,numnodes);
+	}
+
+	/*Using the segments_dataset dataset, create segments: */
+	numsegs=segments_dataset->Size();
+	segments=xNew<double>(5*numsegs);
+	for(i=0;i<numsegs;i++){
+		Segment<double>* segment=(Segment<double>*)segments_dataset->GetObjectByOffset(i);
+
+		/*x1,y1,x2,y2 then element_id: */
+		segments[5*i+0]=segment->x1;
+		segments[5*i+1]=segment->y1;
+		segments[5*i+2]=segment->x2;
+		segments[5*i+3]=segment->y2;
+		segments[5*i+4]=(double)segment->eid;
+	}
+
+	/*Free ressources:*/
+	delete segments_dataset;
+
+	/*Assign output pointers:*/
+	*psegments=segments;
+	*pnumsegs=numsegs;
+}/*}}}*/
+
+/*Utilities*/
+void ElementSegmentsIntersection(DataSet* segments_dataset,int el, double* xnodes,double* ynodes,double* xc,double* yc,int numnodes){/*{{{*/
+
+	double xsegment[2];
+	double ysegment[2];
+
+	/*Loop through contour: */
+	for(int i=0;i<numnodes-1;i++){
+		xsegment[0]=xc[i];
+		xsegment[1]=xc[i+1];
+		ysegment[0]=yc[i];
+		ysegment[1]=yc[i+1];
+		ElementSegment(segments_dataset,el, xnodes,ynodes,xsegment,ysegment);
+	}
+}/*}}}*/
+void ElementSegment(DataSet* segments_dataset,int el,double* xnodes,double* ynodes,double* xsegment,double* ysegment){/*{{{*/
+
+	/*We have a tria element (xnodes,ynodes) and a segment (xsegment,ysegment). Find whether they intersect. 
+	 * If they do, create a Segment object with the intersection, and add to segments_dataset dataset: */
+
+	double alpha1,alpha2;
+	double beta1,beta2;
+	double gamma1,gamma2;
+
+	int    edge1,edge2,edge3;
+
+	double xel[2],yel[2];
+	double coord1,coord2;
+	double xfinal[2],yfinal[2];
+
+	/*edge 1: */
+	xel[0]=xnodes[0];  yel[0]=ynodes[0]; xel[1]=xnodes[1];  yel[1]=ynodes[1];
+	edge1=SegmentIntersect(&alpha1,&alpha2, xel,yel,xsegment,ysegment); //alpha1: segment coordinate of intersection. alpha2: same thing for second interesection if it exists (colinear edges)
+
+	/*edge 2: */
+	xel[0]=xnodes[1];  yel[0]=ynodes[1]; xel[1]=xnodes[2];  yel[1]=ynodes[2];
+	edge2=SegmentIntersect(&beta1,&beta2, xel,yel,xsegment,ysegment);
+
+	/*edge 3: */
+	xel[0]=xnodes[2];  yel[0]=ynodes[2]; xel[1]=xnodes[0];  yel[1]=ynodes[0];
+	edge3=SegmentIntersect(&gamma1,&gamma2, xel,yel,xsegment,ysegment);
+
+	/*edge can be either IntersectEnum (one iand only one intersection between the edge and the segment), ColinearEnum (edge and segment are collinear) and SeparateEnum (no intersection): */
+
+	if(    (edge1==IntersectEnum) && (edge2==IntersectEnum) && (edge3==IntersectEnum)   ){
+		/*This case is impossible: */
+		_error_("error: a line cannot go through 3 different vertices!");
+	}
+	else if(    ((edge1==IntersectEnum) && (edge2==IntersectEnum)) || ((edge2==IntersectEnum) && (edge3==IntersectEnum)) || ((edge3==IntersectEnum) && (edge1==IntersectEnum))   ){
+
+		/*segment interscts 2 opposite edges of our triangle, at 2 segment coordinates, pick up the lowest (coord1) and highest (coord2): */
+		if((edge1==IntersectEnum) && (edge2==IntersectEnum)) {coord1=min(alpha1,beta1); coord2=max(alpha1,beta1);}
+		if((edge2==IntersectEnum) && (edge3==IntersectEnum)) {coord1=min(beta1,gamma1); coord2=max(beta1,gamma1);}
+		if((edge3==IntersectEnum) && (edge1==IntersectEnum)) {coord1=min(gamma1,alpha1); coord2=max(gamma1,alpha1);}
+
+		/*check this segment did not intersect at a vertex of the tria: */
+		if(coord1!=coord2){
+
+			xfinal[0]=xsegment[0]+coord1*(xsegment[1]-xsegment[0]);
+			xfinal[1]=xsegment[0]+coord2*(xsegment[1]-xsegment[0]);
+			yfinal[0]=ysegment[0]+coord1*(ysegment[1]-ysegment[0]);
+			yfinal[1]=ysegment[0]+coord2*(ysegment[1]-ysegment[0]);
+
+			segments_dataset->AddObject(new  Segment<double>(el+1,xfinal[0],yfinal[0],xfinal[1],yfinal[1]));
+		}
+		else{
+			/*the segment intersected at the vertex, do not bother with this "0" length segment!:*/
+		}
+	}
+	else if(  (edge1==IntersectEnum) || (edge2==IntersectEnum) || (edge3==IntersectEnum)   ){
+
+		/*segment intersect only 1 edge. Figure out where the first point in the segment is, inside or outside the element, 
+		 * this will decide the coordinate: */
+		if (NodeInElement(xnodes,ynodes,xsegment[0],ysegment[0])){
+			coord1=0;
+			if(edge1==IntersectEnum){coord2=alpha1;}
+			if(edge2==IntersectEnum){coord2=beta1;}
+			if(edge3==IntersectEnum){coord2=gamma1;}
+		}
+		else{
+			if(edge1==IntersectEnum){coord1=alpha1;}
+			if(edge2==IntersectEnum){coord1=beta1;}
+			if(edge3==IntersectEnum){coord1=gamma1;}
+			coord2=1.0;
+		}
+
+		xfinal[0]=xsegment[0]+coord1*(xsegment[1]-xsegment[0]);
+		xfinal[1]=xsegment[0]+coord2*(xsegment[1]-xsegment[0]);
+		yfinal[0]=ysegment[0]+coord1*(ysegment[1]-ysegment[0]);
+		yfinal[1]=ysegment[0]+coord2*(ysegment[1]-ysegment[0]);
+
+		segments_dataset->AddObject(new  Segment<double>(el+1,xfinal[0],yfinal[0],xfinal[1],yfinal[1]));
+	}
+	else{
+		/*No interesections, but the segment might be entirely inside this triangle!: */
+		if ( (NodeInElement(xnodes,ynodes,xsegment[0],ysegment[0])) && (NodeInElement(xnodes,ynodes,xsegment[1],ysegment[1])) ){
+			segments_dataset->AddObject(new  Segment<double>(el+1,xsegment[0],ysegment[0],xsegment[1],ysegment[1]));
+		}
+	}
+}/*}}}*/
+bool NodeInElement(double* xnodes, double* ynodes, double x, double y){/*{{{*/
+
+	double x1,y1;
+	double x2,y2;
+	double x3,y3;
+	double lambda1,lambda2,lambda3;
+	double det;
+
+	x1=xnodes[0];
+	x2=xnodes[1];
+	x3=xnodes[2];
+	y1=ynodes[0];
+	y2=ynodes[1];
+	y3=ynodes[2];
+
+	/*compute determinant: */
+	det=x1*y2-x1*y3-x3*y2-x2*y1+x2*y3+x3*y1;
+
+	/*area coordinates: */
+	lambda1=((y2-y3)*(x-x3)+(x3-x2)*(y-y3))/det;
+	lambda2=((y3-y1)*(x-x3)+(x1-x3)*(y-y3))/det;
+	lambda3=1-lambda1-lambda2;
+
+	if( ((lambda1<=1) && (lambda1>=0)) && ((lambda2<=1) && (lambda2>=0)) && ((lambda3<=1) && (lambda3>=0))  )return true;
+	else return false;
+
+}/*}}}*/
+int SegmentIntersect(double* palpha, double* pbeta, double* x1, double* y1, double* x2, double* y2){/*{{{*/
+
+	/*See ISSM_DIR/src/m/utils/Geometry/SegIntersect.m for matlab routine from which we take this routine: */
+
+	/*output: */
+	double alpha=-1;
+	double beta=-1;
+
+	double xA,xB,xC,xD,yA,yB,yC,yD;
+	double O2A[2],O2B[2],O1C[2],O1D[2];
+	double n1[2],n2[2];
+	double test1, test2, test3, test4;
+	double det;
+	double O2O1[2];
+	double pO1A,pO1B,pO1C,pO1D;
+
+	xA=x1[0]; yA=y1[0];
+	xB=x1[1]; yB=y1[1];
+	xC=x2[0]; yC=y2[0];
+	xD=x2[1]; yD=y2[1];
+
+	O2A[0]=xA -(xD/2+xC/2); O2A[1]=yA -(yD/2+yC/2);
+	O2B[0]=xB -(xD/2+xC/2); O2B[1]=yB -(yD/2+yC/2);
+	O1C[0]=xC -(xA/2+xB/2); O1C[1]=yC -(yA/2+yB/2);
+	O1D[0]=xD -(xA/2+xB/2); O1D[1]=yD -(yA/2+yB/2);
+
+	n1[0]=yA-yB; n1[1]=xB-xA;  //normal vector to segA
+	n2[0]=yC-yD; n2[1]=xD-xC;  //normal vector to segB
+
+	test1=n2[0]*O2A[0]+n2[1]*O2A[1];
+	test2=n2[0]*O2B[0]+n2[1]*O2B[1];
+
+	if (test1*test2>0){
+		return SeparateEnum;
+	}
+
+	test3=n1[0]*O1C[0]+n1[1]*O1C[1];
+	test4=n1[0]*O1D[0]+n1[1]*O1D[1];
+
+	if (test3*test4>0){
+		return SeparateEnum;
+	}
+
+	/*If colinear: */
+	det=n1[0]*n2[1]-n2[0]*n1[1];
+
+	if(test1*test2==0 && test3*test4==0 && det==0){
+
+		//projection on the axis O1O2
+		O2O1[0]=(xA/2+xB/2)-(xD/2+xC/2);
+		O2O1[1]=(yA/2+yB/2)-(yD/2+yC/2);
+
+		pO1A=O2O1[0]*(O2A[0]-O2O1[0])+O2O1[1]*(O2A[1]-O2O1[1]);
+		pO1B=O2O1[0]*(O2B[0]-O2O1[0])+O2O1[1]*(O2B[1]-O2O1[1]);
+		pO1C=O2O1[0]*O1C[0]+O2O1[1]*O1C[1];
+		pO1D=O2O1[0]*O1D[0]+O2O1[1]*O1D[1];
+
+		//test if one point is included in the other segment (->intersects=true)
+		if ((pO1C-pO1A)*(pO1D-pO1A)<0){
+			alpha=0; beta=0;
+			*palpha=alpha;*pbeta=beta;
+			return ColinearEnum;
+		}
+		if ((pO1C-pO1B)*(pO1D-pO1B)<0){
+			alpha=0; beta=0;
+			*palpha=alpha;*pbeta=beta;
+			return ColinearEnum;
+		}
+		if ((pO1A-pO1C)*(pO1B-pO1C)<0){
+			alpha=0; beta=0;
+			*palpha=alpha;*pbeta=beta;
+			return ColinearEnum;
+		}
+		if ((pO1A-pO1D)*(pO1B-pO1D)<0){
+			alpha=0; beta=0;
+			*palpha=alpha;*pbeta=beta;
+			return ColinearEnum;
+		}
+
+		//test if the 2 segments have the same middle (->intersects=true)
+		if (O2O1==0){
+			alpha=0; beta=0;
+			*palpha=alpha;*pbeta=beta;
+			return ColinearEnum;
+		}
+
+		//if we are here, both segments are colinear, but do not interset:
+		alpha=-1; beta=-1;
+		*palpha=alpha;*pbeta=beta;
+		return SeparateEnum;
+	}
+
+	/*if we are here, both segments intersect. Determine where in the segment coordinate 
+	 * system: */
+	beta=-1;
+	alpha=-(xA*yB-xC*yB+yC*xB-yC*xA+xC*yA-yA*xB)/(-xD*yB+xD*yA+xC*yB-xC*yA-yD*xA+yD*xB+yC*xA-yC*xB); //from intersect.m in formal calculus
+
+	*palpha=alpha;*pbeta=beta;
+	return IntersectEnum;
+}/*}}}*/
Index: /issm/trunk/src/c/modules/MeshProfileIntersectionx/MeshProfileIntersectionx.h
===================================================================
--- /issm/trunk/src/c/modules/MeshProfileIntersectionx/MeshProfileIntersectionx.h	(revision 14309)
+++ /issm/trunk/src/c/modules/MeshProfileIntersectionx/MeshProfileIntersectionx.h	(revision 14310)
@@ -10,5 +10,5 @@
 
 /* local prototypes: */
-void MeshProfileIntersectionx( double** psegments, int* pnumseg, int* index, double* x, double* y, int nel, int nods,  Contour<IssmPDouble>** contours,int numcontours);
+void MeshProfileIntersectionx(double** psegments, int* pnumseg, int* index, double* x, double* y, int nel, int nods,  Contour<IssmPDouble>** contours,int numcontours);
 void MeshSegmentsIntersection(double** psegments, int* pnumsegs,int* index, double* x, double* y, int nel, int nods, double* xc, double* yc, int numnodes);
 void ElementSegmentsIntersection(DataSet* segments_dataset,int el, double* xnodes,double* ynodes,double* xc,double* yc,int numnodes);
Index: sm/trunk/src/c/modules/MeshProfileIntersectionx/MeshSegmentsIntersection.cpp
===================================================================
--- /issm/trunk/src/c/modules/MeshProfileIntersectionx/MeshSegmentsIntersection.cpp	(revision 14309)
+++ 	(revision )
@@ -1,52 +1,0 @@
-/*! \file  MeshSegmentsIntersectionx.c
- */
-
-#include "./MeshProfileIntersectionx.h"
-
-void MeshSegmentsIntersection(double** psegments, int* pnumsegs,int* index, double* x, double* y, int nel, int nods, double* xc, double* yc, int numnodes){
-
-	int      i,j;
-
-	/*output: */
-	double*  segments=NULL;
-	Segment<double>* segment=NULL;
-	int     numsegs;
-
-	/*intermediary: */
-	DataSet* segments_dataset=NULL;
-	double   xnodes[3];
-	double   ynodes[3];
-
-	/*We don't know how many segments  we are going to get, so have a dynamic container: */
-	segments_dataset=new DataSet();
-
-	/*Go through elements, and call ElementSegmentsIntersection routine: */
-	for(i=0;i<nel;i++){
-		for(j=0;j<3;j++){
-			xnodes[j]=x[*(index+3*i+j)];
-			ynodes[j]=y[*(index+3*i+j)];
-		}
-		ElementSegmentsIntersection(segments_dataset,i,xnodes,ynodes,xc,yc,numnodes);
-	}
-
-	/*Using the segments_dataset dataset, create segments: */
-	numsegs=segments_dataset->Size();
-	segments=xNew<double>(5*numsegs);
-	for(i=0;i<numsegs;i++){
-		Segment<double>* segment=(Segment<double>*)segments_dataset->GetObjectByOffset(i);
-
-		/*x1,y1,x2,y2 then element_id: */
-		*(segments+5*i+0)=segment->x1;
-		*(segments+5*i+1)=segment->y1;
-		*(segments+5*i+2)=segment->x2;
-		*(segments+5*i+3)=segment->y2;
-		*(segments+5*i+4)=(double)segment->eid;
-	}
-
-	/*Free ressources:*/
-	delete segments_dataset;
-
-	/*Assign output pointers:*/
-	*psegments=segments;
-	*pnumsegs=numsegs;
-}
Index: sm/trunk/src/c/modules/MeshProfileIntersectionx/NodeInElement.cpp
===================================================================
--- /issm/trunk/src/c/modules/MeshProfileIntersectionx/NodeInElement.cpp	(revision 14309)
+++ 	(revision )
@@ -1,32 +1,0 @@
-/*! \file  NodeInElement.cpp
-*/
-
-#include "./MeshProfileIntersectionx.h"
-
-bool NodeInElement(double* xnodes, double* ynodes, double x, double y){
-
-	double x1,y1;
-	double x2,y2;
-	double x3,y3;
-	double lambda1,lambda2,lambda3;
-	double det;
-
-	x1=xnodes[0];
-	x2=xnodes[1];
-	x3=xnodes[2];
-	y1=ynodes[0];
-	y2=ynodes[1];
-	y3=ynodes[2];
-
-	/*compute determinant: */
-	det=x1*y2-x1*y3-x3*y2-x2*y1+x2*y3+x3*y1;
-
-	/*area coordinates: */
-	lambda1=((y2-y3)*(x-x3)+(x3-x2)*(y-y3))/det;
-	lambda2=((y3-y1)*(x-x3)+(x1-x3)*(y-y3))/det;
-	lambda3=1-lambda1-lambda2;
-
-	if( ((lambda1<=1) && (lambda1>=0)) && ((lambda2<=1) && (lambda2>=0)) && ((lambda3<=1) && (lambda3>=0))  )return true;
-	else return false;
-
-}
Index: sm/trunk/src/c/modules/MeshProfileIntersectionx/SegmentIntersect.cpp
===================================================================
--- /issm/trunk/src/c/modules/MeshProfileIntersectionx/SegmentIntersect.cpp	(revision 14309)
+++ 	(revision )
@@ -1,105 +1,0 @@
-/*! \file  SegmentIntersect.cpp
-*/
-
-#include "./MeshProfileIntersectionx.h"
-
-int SegmentIntersect(double* palpha, double* pbeta, double* x1, double* y1, double* x2, double* y2){
-
-	/*See ISSM_DIR/src/m/utils/Geometry/SegIntersect.m for matlab routine from which we take this routine: */
-
-	/*output: */
-	double alpha=-1;
-	double beta=-1;
-
-	double xA,xB,xC,xD,yA,yB,yC,yD;
-	double O2A[2],O2B[2],O1C[2],O1D[2];
-	double n1[2],n2[2];
-	double test1, test2, test3, test4;
-	double det;
-	double O2O1[2];
-	double pO1A,pO1B,pO1C,pO1D;
-
-	xA=x1[0]; yA=y1[0];
-	xB=x1[1]; yB=y1[1];
-	xC=x2[0]; yC=y2[0];
-	xD=x2[1]; yD=y2[1];
-
-	O2A[0]=xA -(xD/2+xC/2); O2A[1]=yA -(yD/2+yC/2);
-	O2B[0]=xB -(xD/2+xC/2); O2B[1]=yB -(yD/2+yC/2);
-	O1C[0]=xC -(xA/2+xB/2); O1C[1]=yC -(yA/2+yB/2);
-	O1D[0]=xD -(xA/2+xB/2); O1D[1]=yD -(yA/2+yB/2);
-
-	n1[0]=yA-yB; n1[1]=xB-xA;  //normal vector to segA
-	n2[0]=yC-yD; n2[1]=xD-xC;  //normal vector to segB
-
-	test1=n2[0]*O2A[0]+n2[1]*O2A[1];
-	test2=n2[0]*O2B[0]+n2[1]*O2B[1];
-
-	if (test1*test2>0){
-		return SeparateEnum;
-	}
-
-	test3=n1[0]*O1C[0]+n1[1]*O1C[1];
-	test4=n1[0]*O1D[0]+n1[1]*O1D[1];
-
-	if (test3*test4>0){
-		return SeparateEnum;
-	}
-
-	/*If colinear: */
-	det=n1[0]*n2[1]-n2[0]*n1[1];
-
-	if(test1*test2==0 && test3*test4==0 && det==0){
-
-		//projection on the axis O1O2
-		O2O1[0]=(xA/2+xB/2)-(xD/2+xC/2);
-		O2O1[1]=(yA/2+yB/2)-(yD/2+yC/2);
-
-		pO1A=O2O1[0]*(O2A[0]-O2O1[0])+O2O1[1]*(O2A[1]-O2O1[1]);
-		pO1B=O2O1[0]*(O2B[0]-O2O1[0])+O2O1[1]*(O2B[1]-O2O1[1]);
-		pO1C=O2O1[0]*O1C[0]+O2O1[1]*O1C[1];
-		pO1D=O2O1[0]*O1D[0]+O2O1[1]*O1D[1];
-
-		//test if one point is included in the other segment (->intersects=true)
-		if ((pO1C-pO1A)*(pO1D-pO1A)<0){
-			alpha=0; beta=0;
-			*palpha=alpha;*pbeta=beta;
-			return ColinearEnum;
-		}
-		if ((pO1C-pO1B)*(pO1D-pO1B)<0){
-			alpha=0; beta=0;
-			*palpha=alpha;*pbeta=beta;
-			return ColinearEnum;
-		}
-		if ((pO1A-pO1C)*(pO1B-pO1C)<0){
-			alpha=0; beta=0;
-			*palpha=alpha;*pbeta=beta;
-			return ColinearEnum;
-		}
-		if ((pO1A-pO1D)*(pO1B-pO1D)<0){
-			alpha=0; beta=0;
-			*palpha=alpha;*pbeta=beta;
-			return ColinearEnum;
-		}
-
-		//test if the 2 segments have the same middle (->intersects=true)
-		if (O2O1==0){
-			alpha=0; beta=0;
-			*palpha=alpha;*pbeta=beta;
-			return ColinearEnum;
-		}
-
-		//if we are here, both segments are colinear, but do not interset:
-		alpha=-1; beta=-1;
-		*palpha=alpha;*pbeta=beta;
-		return SeparateEnum;
-	}
-
-	/*if we are here, both segments intersect. Determine where in the segment coordinate 
-	 * system: */
-	beta=-1;
-	alpha=-(xA*yB-xC*yB+yC*xB-yC*xA+xC*yA-yA*xB)/(-xD*yB+xD*yA+xC*yB-xC*yA-yD*xA+yD*xB+yC*xA-yC*xB); //from intersect.m in formal calculus
-
-	*palpha=alpha;*pbeta=beta;
-	return IntersectEnum;
-}
Index: sm/trunk/src/c/modules/MeshProfileIntersectionx/intersect.m
===================================================================
--- /issm/trunk/src/c/modules/MeshProfileIntersectionx/intersect.m	(revision 14309)
+++ 	(revision )
@@ -1,12 +1,0 @@
-syms xA yA xB yB xC yC xD yD alpha beta x y
-
-A=[xA;yA];
-B=[xB;yB];
-C=[xC;yC];
-D=[xD;yD];
-
-
-Eq=C+alpha*(D-C)-A+beta*(B-A); 
-
-%from Eq, we specify the system to solve: 
-S=solve( xC+alpha*(xD-xC)-xA+beta*(xB-xA), yC+alpha*(yD-yC)-yA+beta*(yB-yA),alpha,beta);
Index: /issm/trunk/src/c/modules/ModelProcessorx/Autodiff/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/ModelProcessorx/Autodiff/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/ModelProcessorx/Autodiff/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,5 @@
+# Subdirectories {{{
+# }}}
+# CORE_SOURCES {{{
+set(CORE_SOURCES $ENV{ISSM_DIR}/src/c/modules/ModelProcessorx/Autodiff/CreateParametersAutodiff.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/modules/ModelProcessorx/Balancethickness/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/ModelProcessorx/Balancethickness/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/ModelProcessorx/Balancethickness/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,8 @@
+# Subdirectories {{{
+# }}}
+# BALANCED_SOURCES {{{
+set(BALANCED_SOURCES $ENV{ISSM_DIR}/src/c/modules/ModelProcessorx/Balancethickness/CreateConstraintsBalancethickness.cpp
+                           $ENV{ISSM_DIR}/src/c/modules/ModelProcessorx/Balancethickness/CreateLoadsBalancethickness.cpp
+                           $ENV{ISSM_DIR}/src/c/modules/ModelProcessorx/Balancethickness/CreateNodesBalancethickness.cpp
+                        $ENV{ISSM_DIR}/src/c/modules/ModelProcessorx/Balancethickness/UpdateElementsBalancethickness.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/modules/ModelProcessorx/BedSlope/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/ModelProcessorx/BedSlope/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/ModelProcessorx/BedSlope/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,8 @@
+# Subdirectories {{{
+# }}}
+# SLOPE_SOURCES {{{
+set(SLOPE_SOURCES $ENV{ISSM_DIR}/src/c/modules/ModelProcessorx/BedSlope/CreateConstraintsBedSlope.cpp
+                        $ENV{ISSM_DIR}/src/c/modules/ModelProcessorx/BedSlope/CreateLoadsBedSlope.cpp
+                        $ENV{ISSM_DIR}/src/c/modules/ModelProcessorx/BedSlope/CreateNodesBedSlope.cpp
+                     $ENV{ISSM_DIR}/src/c/modules/ModelProcessorx/BedSlope/UpdateElementsBedSlope.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/modules/ModelProcessorx/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/ModelProcessorx/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/ModelProcessorx/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,33 @@
+# Subdirectories {{{
+add_subdirectory(Autodiff)
+add_subdirectory(Balancethickness)
+add_subdirectory(BedSlope)
+add_subdirectory(Control)
+add_subdirectory(Dakota)
+add_subdirectory(DiagnosticHoriz)
+add_subdirectory(DiagnosticHutter)
+add_subdirectory(DiagnosticVert)
+add_subdirectory(Enthalpy)
+add_subdirectory(Hydrology)
+add_subdirectory(Melting)
+add_subdirectory(Prognostic)
+add_subdirectory(SurfaceSlope)
+add_subdirectory(Thermal)
+add_subdirectory(Transient)
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/ModelProcessorx)
+# }}}
+# CORE_SOURCES {{{
+set(CORE_SOURCES $ENV{ISSM_DIR}/src/c/modules/ModelProcessorx/CreateDataSets.cpp
+$ENV{ISSM_DIR}/src/c/modules/ModelProcessorx/CreateElementsVerticesAndMaterials.cpp
+$ENV{ISSM_DIR}/src/c/modules/ModelProcessorx/CreateNumberNodeToElementConnectivity.cpp
+               $ENV{ISSM_DIR}/src/c/modules/ModelProcessorx/CreateParameters.cpp
+$ENV{ISSM_DIR}/src/c/modules/ModelProcessorx/CreateSingleNodeToElementConnectivity.cpp
+              $ENV{ISSM_DIR}/src/c/modules/ModelProcessorx/DistributeNumDofs.cpp
+$ENV{ISSM_DIR}/src/c/modules/ModelProcessorx/ElementsAndVerticesPartitioning.cpp
+                $ENV{ISSM_DIR}/src/c/modules/ModelProcessorx/ModelProcessorx.cpp
+              $ENV{ISSM_DIR}/src/c/modules/ModelProcessorx/NodesPartitioning.cpp
+                   $ENV{ISSM_DIR}/src/c/modules/ModelProcessorx/SortDataSets.cpp
+                 $ENV{ISSM_DIR}/src/c/modules/ModelProcessorx/UpdateCounters.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/modules/ModelProcessorx/Control/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/ModelProcessorx/Control/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/ModelProcessorx/Control/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,2 @@
+# Subdirectories {{{
+# }}}
Index: /issm/trunk/src/c/modules/ModelProcessorx/Control/CreateParametersControl.cpp
===================================================================
--- /issm/trunk/src/c/modules/ModelProcessorx/Control/CreateParametersControl.cpp	(revision 14309)
+++ /issm/trunk/src/c/modules/ModelProcessorx/Control/CreateParametersControl.cpp	(revision 14310)
@@ -15,5 +15,5 @@
 
 	Parameters *parameters       = NULL;
-	bool        control_analysis;
+	bool        control_analysis,tao_analysis;
 	int         nsteps;
 	int         num_control_type;
@@ -30,4 +30,5 @@
 	/*retrieve some parameters: */
 	iomodel->Constant(&control_analysis,InversionIscontrolEnum);
+	iomodel->Constant(&tao_analysis,InversionTaoEnum);
 
 	if(control_analysis){
@@ -37,7 +38,9 @@
 		parameters->AddObject(iomodel->CopyConstantObject(InversionNumCostFunctionsEnum));
 		parameters->AddObject(iomodel->CopyConstantObject(InversionNstepsEnum));
-		parameters->AddObject(iomodel->CopyConstantObject(InversionCostFunctionThresholdEnum));
-		parameters->AddObject(iomodel->CopyConstantObject(InversionGradientOnlyEnum));
 		parameters->AddObject(iomodel->CopyConstantObject(InversionIncompleteAdjointEnum));
+		if(!tao_analysis){
+			parameters->AddObject(iomodel->CopyConstantObject(InversionCostFunctionThresholdEnum));
+			parameters->AddObject(iomodel->CopyConstantObject(InversionGradientOnlyEnum));
+		}
 
 		/*What solution type?*/
@@ -52,13 +55,21 @@
 		iomodel->FetchData(&control_type,NULL,&num_control_type,InversionControlParametersEnum);
 		iomodel->FetchData(&cm_responses,&nsteps,&num_cm_responses,InversionCostFunctionsEnum);
-		iomodel->FetchData(&cm_jump,&nsteps,NULL,InversionStepThresholdEnum);
-		iomodel->FetchData(&optscal,NULL,NULL,InversionGradientScalingEnum);
-		iomodel->FetchData(&maxiter,NULL,NULL,InversionMaxiterPerStepEnum);
+		if(!tao_analysis){
+			iomodel->FetchData(&cm_jump,&nsteps,NULL,InversionStepThresholdEnum);
+			iomodel->FetchData(&optscal,NULL,NULL,InversionGradientScalingEnum);
+			iomodel->FetchData(&maxiter,NULL,NULL,InversionMaxiterPerStepEnum);
+		}
 
-		parameters->AddObject(new IntVecParam(InversionControlParametersEnum,control_type,num_control_type));
-		parameters->AddObject(new DoubleMatParam(InversionGradientScalingEnum,optscal,nsteps,num_control_type));
-		parameters->AddObject(new DoubleMatParam(InversionCostFunctionsEnum,cm_responses,nsteps,num_cm_responses));
-		parameters->AddObject(new DoubleVecParam(InversionStepThresholdEnum,cm_jump,nsteps));
-		parameters->AddObject(new DoubleVecParam(InversionMaxiterPerStepEnum,maxiter,nsteps));
+		if(tao_analysis){
+			parameters->AddObject(new IntVecParam(InversionControlParametersEnum,control_type,num_control_type));
+			parameters->AddObject(new DoubleVecParam(InversionCostFunctionsEnum,cm_responses,num_cm_responses));
+		}
+		else{
+			parameters->AddObject(new IntVecParam(InversionControlParametersEnum,control_type,num_control_type));
+			parameters->AddObject(new DoubleMatParam(InversionGradientScalingEnum,optscal,nsteps,num_control_type));
+			parameters->AddObject(new DoubleMatParam(InversionCostFunctionsEnum,cm_responses,nsteps,num_cm_responses));
+			parameters->AddObject(new DoubleVecParam(InversionStepThresholdEnum,cm_jump,nsteps));
+			parameters->AddObject(new DoubleVecParam(InversionMaxiterPerStepEnum,maxiter,nsteps));
+		}
 
 		xDelete<int>(control_type);
Index: /issm/trunk/src/c/modules/ModelProcessorx/Control/UpdateElementsAndMaterialsControl.cpp
===================================================================
--- /issm/trunk/src/c/modules/ModelProcessorx/Control/UpdateElementsAndMaterialsControl.cpp	(revision 14309)
+++ /issm/trunk/src/c/modules/ModelProcessorx/Control/UpdateElementsAndMaterialsControl.cpp	(revision 14310)
@@ -45,7 +45,8 @@
 			case VxEnum:   iomodel->FetchData(1,VxEnum); break;
 			case VyEnum:   iomodel->FetchData(1,VyEnum); break;
-			case FrictionCoefficientEnum: iomodel->FetchData(1,FrictionCoefficientEnum); break;
-			case MaterialsRheologyBbarEnum:    iomodel->FetchData(1,MaterialsRheologyBEnum); break;
-			case MaterialsRheologyZbarEnum:    iomodel->FetchData(1,MaterialsRheologyZEnum); break;
+			case ThicknessEnum:             iomodel->FetchData(1,ThicknessEnum); break;
+			case FrictionCoefficientEnum:   iomodel->FetchData(1,FrictionCoefficientEnum); break;
+			case MaterialsRheologyBbarEnum: iomodel->FetchData(1,MaterialsRheologyBEnum); break;
+			case MaterialsRheologyZbarEnum: iomodel->FetchData(1,MaterialsRheologyZEnum); break;
 			default: _error_("Control " << EnumToStringx(reCast<int,IssmDouble>(iomodel->Data(InversionControlParametersEnum)[i])) << " not implemented yet");
 		}
Index: /issm/trunk/src/c/modules/ModelProcessorx/Dakota/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/ModelProcessorx/Dakota/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/ModelProcessorx/Dakota/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,5 @@
+# Subdirectories {{{
+# }}}
+# DAKOTA_SOURCES {{{
+set(DAKOTA_SOURCES $ENV{ISSM_DIR}/src/c/modules/ModelProcessorx/Dakota/CreateParametersDakota.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHoriz/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHoriz/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHoriz/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,8 @@
+# Subdirectories {{{
+# }}}
+# DIAGNOSTIC_SOURCES {{{
+set(DIAGNOSTIC_SOURCES $ENV{ISSM_DIR}/src/c/modules/ModelProcessorx/DiagnosticHoriz/CreateConstraintsDiagnosticHoriz.cpp
+                             $ENV{ISSM_DIR}/src/c/modules/ModelProcessorx/DiagnosticHoriz/CreateLoadsDiagnosticHoriz.cpp
+                             $ENV{ISSM_DIR}/src/c/modules/ModelProcessorx/DiagnosticHoriz/CreateNodesDiagnosticHoriz.cpp
+                          $ENV{ISSM_DIR}/src/c/modules/ModelProcessorx/DiagnosticHoriz/UpdateElementsDiagnosticHoriz.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHoriz/UpdateElementsDiagnosticHoriz.cpp
===================================================================
--- /issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHoriz/UpdateElementsDiagnosticHoriz.cpp	(revision 14309)
+++ /issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHoriz/UpdateElementsDiagnosticHoriz.cpp	(revision 14310)
@@ -2,4 +2,9 @@
  * UpdateElementsDiagnosticHoriz:
  */
+#ifdef HAVE_CONFIG_H
+	#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
 
 #include "../../../Container/Container.h"
@@ -85,4 +90,8 @@
 	elements->InputDuplicate(VxEnum,InversionVxObsEnum);
 	if(dakota_analysis)elements->InputDuplicate(VxEnum,QmuVxEnum);
+	
+	#ifdef _HAVE_ANDROID_
+	elements->InputDuplicate(FrictionCoefficientEnum,AndroidFrictionCoefficientEnum);
+	#endif
 
 	elements->InputDuplicate(VyEnum,VyPicardEnum);
Index: /issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHutter/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHutter/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHutter/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,8 @@
+# Subdirectories {{{
+# }}}
+# DIAGNOSTIC_SOURCES {{{
+set(DIAGNOSTIC_SOURCES $ENV{ISSM_DIR}/src/c/modules/ModelProcessorx/DiagnosticHutter/CreateConstraintsDiagnosticHutter.cpp
+                             $ENV{ISSM_DIR}/src/c/modules/ModelProcessorx/DiagnosticHutter/CreateLoadsDiagnosticHutter.cpp
+                             $ENV{ISSM_DIR}/src/c/modules/ModelProcessorx/DiagnosticHutter/CreateNodesDiagnosticHutter.cpp
+                          $ENV{ISSM_DIR}/src/c/modules/ModelProcessorx/DiagnosticHutter/UpdateElementsDiagnosticHutter.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/modules/ModelProcessorx/DiagnosticVert/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/ModelProcessorx/DiagnosticVert/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/ModelProcessorx/DiagnosticVert/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,8 @@
+# Subdirectories {{{
+# }}}
+# DIAGNOSTIC_SOURCES {{{
+set(DIAGNOSTIC_SOURCES $ENV{ISSM_DIR}/src/c/modules/ModelProcessorx/DiagnosticVert/CreateConstraintsDiagnosticVert.cpp
+                             $ENV{ISSM_DIR}/src/c/modules/ModelProcessorx/DiagnosticVert/CreateLoadsDiagnosticVert.cpp
+                             $ENV{ISSM_DIR}/src/c/modules/ModelProcessorx/DiagnosticVert/CreateNodesDiagnosticVert.cpp
+                          $ENV{ISSM_DIR}/src/c/modules/ModelProcessorx/DiagnosticVert/UpdateElementsDiagnosticVert.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/modules/ModelProcessorx/Enthalpy/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/ModelProcessorx/Enthalpy/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/ModelProcessorx/Enthalpy/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,8 @@
+# Subdirectories {{{
+# }}}
+# THERMAL_SOURCES {{{
+set(THERMAL_SOURCES $ENV{ISSM_DIR}/src/c/modules/ModelProcessorx/Enthalpy/CreateConstraintsEnthalpy.cpp
+                          $ENV{ISSM_DIR}/src/c/modules/ModelProcessorx/Enthalpy/CreateLoadsEnthalpy.cpp
+                          $ENV{ISSM_DIR}/src/c/modules/ModelProcessorx/Enthalpy/CreateNodesEnthalpy.cpp
+                       $ENV{ISSM_DIR}/src/c/modules/ModelProcessorx/Enthalpy/UpdateElementsEnthalpy.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/modules/ModelProcessorx/Hydrology/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/ModelProcessorx/Hydrology/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/ModelProcessorx/Hydrology/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,8 @@
+# Subdirectories {{{
+# }}}
+# HYDROLOGY_SOURCES {{{
+set(HYDROLOGY_SOURCES $ENV{ISSM_DIR}/src/c/modules/ModelProcessorx/Hydrology/CreateConstraintsHydrology.cpp
+                            $ENV{ISSM_DIR}/src/c/modules/ModelProcessorx/Hydrology/CreateLoadsHydrology.cpp
+                            $ENV{ISSM_DIR}/src/c/modules/ModelProcessorx/Hydrology/CreateNodesHydrology.cpp
+                         $ENV{ISSM_DIR}/src/c/modules/ModelProcessorx/Hydrology/UpdateElementsHydrology.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/modules/ModelProcessorx/Melting/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/ModelProcessorx/Melting/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/ModelProcessorx/Melting/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,8 @@
+# Subdirectories {{{
+# }}}
+# THERMAL_SOURCES {{{
+set(THERMAL_SOURCES $ENV{ISSM_DIR}/src/c/modules/ModelProcessorx/Melting/CreateConstraintsMelting.cpp
+                          $ENV{ISSM_DIR}/src/c/modules/ModelProcessorx/Melting/CreateLoadsMelting.cpp
+                          $ENV{ISSM_DIR}/src/c/modules/ModelProcessorx/Melting/CreateNodesMelting.cpp
+                       $ENV{ISSM_DIR}/src/c/modules/ModelProcessorx/Melting/UpdateElementsMelting.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/modules/ModelProcessorx/Prognostic/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/ModelProcessorx/Prognostic/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/ModelProcessorx/Prognostic/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,8 @@
+# Subdirectories {{{
+# }}}
+# PROGNOSTIC_SOURCES {{{
+set(PROGNOSTIC_SOURCES $ENV{ISSM_DIR}/src/c/modules/ModelProcessorx/Prognostic/CreateConstraintsPrognostic.cpp
+                             $ENV{ISSM_DIR}/src/c/modules/ModelProcessorx/Prognostic/CreateLoadsPrognostic.cpp
+                             $ENV{ISSM_DIR}/src/c/modules/ModelProcessorx/Prognostic/CreateNodesPrognostic.cpp
+                          $ENV{ISSM_DIR}/src/c/modules/ModelProcessorx/Prognostic/UpdateElementsPrognostic.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/modules/ModelProcessorx/Prognostic/UpdateElementsPrognostic.cpp
===================================================================
--- /issm/trunk/src/c/modules/ModelProcessorx/Prognostic/UpdateElementsPrognostic.cpp	(revision 14309)
+++ /issm/trunk/src/c/modules/ModelProcessorx/Prognostic/UpdateElementsPrognostic.cpp	(revision 14310)
@@ -72,12 +72,7 @@
 	}
 	if(issmbgradients){
-	        iomodel->FetchDataToInput(elements,SurfaceforcingsHcEnum);
 	        iomodel->FetchDataToInput(elements,SurfaceforcingsHrefEnum);
 	        iomodel->FetchDataToInput(elements,SurfaceforcingsSmbrefEnum);
-	        iomodel->FetchDataToInput(elements,SurfaceforcingsSmbPosMaxEnum);
-	        iomodel->FetchDataToInput(elements,SurfaceforcingsSmbPosMinEnum);
-	        iomodel->FetchDataToInput(elements,SurfaceforcingsAPosEnum);
 	        iomodel->FetchDataToInput(elements,SurfaceforcingsBPosEnum);
-	        iomodel->FetchDataToInput(elements,SurfaceforcingsANegEnum);
 	        iomodel->FetchDataToInput(elements,SurfaceforcingsBNegEnum);
 	}
Index: /issm/trunk/src/c/modules/ModelProcessorx/SurfaceSlope/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/ModelProcessorx/SurfaceSlope/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/ModelProcessorx/SurfaceSlope/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,8 @@
+# Subdirectories {{{
+# }}}
+# SLOPE_SOURCES {{{
+set(SLOPE_SOURCES $ENV{ISSM_DIR}/src/c/modules/ModelProcessorx/SurfaceSlope/CreateConstraintsSurfaceSlope.cpp
+                        $ENV{ISSM_DIR}/src/c/modules/ModelProcessorx/SurfaceSlope/CreateLoadsSurfaceSlope.cpp
+                        $ENV{ISSM_DIR}/src/c/modules/ModelProcessorx/SurfaceSlope/CreateNodesSurfaceSlope.cpp
+                     $ENV{ISSM_DIR}/src/c/modules/ModelProcessorx/SurfaceSlope/UpdateElementsSurfaceSlope.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/modules/ModelProcessorx/Thermal/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/ModelProcessorx/Thermal/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/ModelProcessorx/Thermal/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,8 @@
+# Subdirectories {{{
+# }}}
+# THERMAL_SOURCES {{{
+set(THERMAL_SOURCES $ENV{ISSM_DIR}/src/c/modules/ModelProcessorx/Thermal/CreateConstraintsThermal.cpp
+                          $ENV{ISSM_DIR}/src/c/modules/ModelProcessorx/Thermal/CreateLoadsThermal.cpp
+                          $ENV{ISSM_DIR}/src/c/modules/ModelProcessorx/Thermal/CreateNodesThermal.cpp
+                       $ENV{ISSM_DIR}/src/c/modules/ModelProcessorx/Thermal/UpdateElementsThermal.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/modules/ModelProcessorx/Transient/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/ModelProcessorx/Transient/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/ModelProcessorx/Transient/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,5 @@
+# Subdirectories {{{
+# }}}
+# TRANSIENT_SOURCES {{{
+set(TRANSIENT_SOURCES $ENV{ISSM_DIR}/src/c/modules/ModelProcessorx/Transient/UpdateElementsTransient.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/modules/NodalValuex/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/NodalValuex/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/NodalValuex/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,8 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/NodalValuex)
+# }}}
+# CORE_SOURCES {{{
+set(CORE_SOURCES $ENV{ISSM_DIR}/src/c/modules/NodalValuex/NodalValuex.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/modules/NodeConnectivityx/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/NodeConnectivityx/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/NodeConnectivityx/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,5 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/NodeConnectivityx)
+# }}}
Index: /issm/trunk/src/c/modules/NodeConnectivityx/NodeConnectivityx.cpp
===================================================================
--- /issm/trunk/src/c/modules/NodeConnectivityx/NodeConnectivityx.cpp	(revision 14309)
+++ /issm/trunk/src/c/modules/NodeConnectivityx/NodeConnectivityx.cpp	(revision 14310)
@@ -21,5 +21,5 @@
 
 	int i,j,n;
-	const int maxels=25;
+	const int maxels=50;
 	const int width=maxels+1;
 
Index: /issm/trunk/src/c/modules/NodesDofx/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/NodesDofx/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/NodesDofx/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,8 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/NodesDofx)
+# }}}
+# CORE_SOURCES {{{
+set(CORE_SOURCES $ENV{ISSM_DIR}/src/c/modules/NodesDofx/NodesDofx.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/modules/Orthx/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/Orthx/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/Orthx/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,5 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/Orthx)
+# }}}
Index: /issm/trunk/src/c/modules/OutputResultsx/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/OutputResultsx/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/OutputResultsx/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,8 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/OutputResultsx)
+# }}}
+# CORE_SOURCES {{{
+set(CORE_SOURCES $ENV{ISSM_DIR}/src/c/modules/OutputResultsx/OutputResultsx.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/modules/OutputResultsx/OutputResultsx.cpp
===================================================================
--- /issm/trunk/src/c/modules/OutputResultsx/OutputResultsx.cpp	(revision 14309)
+++ /issm/trunk/src/c/modules/OutputResultsx/OutputResultsx.cpp	(revision 14310)
@@ -56,5 +56,5 @@
 
 		/*We don't have a file pointer. Retrieve the output file name and open it for writing:*/
-		parameters->FindParam(&outputfilename,OutputfilenameEnum);
+		parameters->FindParam(&outputfilename,OutputFileNameEnum);
 
 		/*What strategy? : */
Index: /issm/trunk/src/c/modules/OutputRiftsx/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/OutputRiftsx/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/OutputRiftsx/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,5 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/OutputRiftsx)
+# }}}
Index: /issm/trunk/src/c/modules/ParsePetscOptionsx/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/ParsePetscOptionsx/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/ParsePetscOptionsx/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,8 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/ParsePetscOptionsx)
+# }}}
+# CORE_SOURCES {{{
+set(CORE_SOURCES $ENV{ISSM_DIR}/src/c/modules/ParsePetscOptionsx/ParsePetscOptionsx.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/modules/PointCloudFindNeighborsx/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/PointCloudFindNeighborsx/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/PointCloudFindNeighborsx/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,5 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/PointCloudFindNeighborsx)
+# }}}
Index: /issm/trunk/src/c/modules/PositiveDegreeDayx/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/PositiveDegreeDayx/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/PositiveDegreeDayx/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,8 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/PositiveDegreeDayx)
+# }}}
+# CORE_SOURCES {{{
+set(CORE_SOURCES $ENV{ISSM_DIR}/src/c/modules/PositiveDegreeDayx/PositiveDegreeDayx.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/modules/PropagateFlagsFromConnectivityx/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/PropagateFlagsFromConnectivityx/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/PropagateFlagsFromConnectivityx/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,5 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/PropagateFlagsFromConnectivityx)
+# }}}
Index: /issm/trunk/src/c/modules/Reduceloadx/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/Reduceloadx/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/Reduceloadx/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,8 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/Reduceloadx)
+# }}}
+# CORE_SOURCES {{{
+set(CORE_SOURCES $ENV{ISSM_DIR}/src/c/modules/Reduceloadx/Reduceloadx.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/modules/Reducevectorgtofx/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/Reducevectorgtofx/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/Reducevectorgtofx/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,8 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/Reducevectorgtofx)
+# }}}
+# CORE_SOURCES {{{
+set(CORE_SOURCES $ENV{ISSM_DIR}/src/c/modules/Reducevectorgtofx/Reducevectorgtofx.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/modules/Reducevectorgtosx/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/Reducevectorgtosx/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/Reducevectorgtosx/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,5 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/Reducevectorgtosx)
+# }}}
Index: /issm/trunk/src/c/modules/ResetConstraintsx/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/ResetConstraintsx/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/ResetConstraintsx/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,11 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/ResetConstraintsx)
+# }}}
+# CORE_SOURCES {{{
+set(CORE_SOURCES $ENV{ISSM_DIR}/src/c/modules/ResetConstraintsx/ResetConstraintsx.cpp PARENT_SCOPE)
+# }}}
+# THERMAL_SOURCES {{{
+set(THERMAL_SOURCES $ENV{ISSM_DIR}/src/c/modules/ResetConstraintsx/ThermalConstraintsReset.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/modules/ResetCoordinateSystemx/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/ResetCoordinateSystemx/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/ResetCoordinateSystemx/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,8 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/ResetCoordinateSystemx)
+# }}}
+# CORE_SOURCES {{{
+set(CORE_SOURCES $ENV{ISSM_DIR}/src/c/modules/ResetCoordinateSystemx/ResetCoordinateSystemx.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/modules/RheologyBbarAbsGradientx/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/RheologyBbarAbsGradientx/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/RheologyBbarAbsGradientx/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,5 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/RheologyBbarAbsGradientx)
+# }}}
Index: /issm/trunk/src/c/modules/Scotchx/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/Scotchx/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/Scotchx/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,5 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/Scotchx)
+# }}}
Index: /issm/trunk/src/c/modules/SetControlInputsFromVectorx/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/SetControlInputsFromVectorx/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/SetControlInputsFromVectorx/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,5 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/SetControlInputsFromVectorx)
+# }}}
Index: /issm/trunk/src/c/modules/Shp2Expx/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/Shp2Expx/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/Shp2Expx/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,8 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/Shp2Expx)
+# }}}
+# KML_SOURCES {{{
+set(KML_SOURCES $ENV{ISSM_DIR}/src/c/modules/Shp2Expx/Shp2Expx.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/modules/Shp2Expx/Shp2Expx.cpp
===================================================================
--- /issm/trunk/src/c/modules/Shp2Expx/Shp2Expx.cpp	(revision 14310)
+++ /issm/trunk/src/c/modules/Shp2Expx/Shp2Expx.cpp	(revision 14310)
@@ -0,0 +1,629 @@
+/*!\file Shp2Expx
+ * \brief shp to exp conversion routines.
+ */
+
+#include "./Shp2Expx.h"
+#include "../../shared/shared.h"
+#include "../../include/include.h"
+#include "../../io/io.h"
+#include "../../toolkits/toolkits.h"
+#include "../../EnumDefinitions/EnumDefinitions.h"
+#include "../modules.h"
+
+int Shp2Expx(char* filshp,char* filexp){
+
+	#ifdef _HAVE_SHAPELIB_ //only works if Shapelib library has been compiled in.
+
+	return(Shp2Expx(filshp,filexp,
+					0));
+
+	#else //ifdef _HAVE_SHAPELIB_
+	return 0;
+	#endif
+}
+
+int Shp2Expx(char* filshp,char* filexp,
+			 int sgn){
+
+	#ifdef _HAVE_SHAPELIB_ //only works if Shapelib library has been compiled in.
+
+	double  cm,sp;
+
+	if (sgn)
+		Xy2lldef(&cm,&sp,sgn);
+
+	return(Shp2Expx(filshp,filexp,
+					sgn,cm,sp));
+
+	#else //ifdef _HAVE_SHAPELIB_
+	return 0;
+	#endif
+}
+
+int Shp2Expx(char* filshp,char* filexp,
+			 int sgn,double cm,double sp){
+
+	#ifdef _HAVE_SHAPELIB_ //only works if Shapelib library has been compiled in.
+
+	int     i,j,k,iret=0;
+	int     lwidth=1;
+	double  popac=0.50;
+	int     nshape,ncoord;
+	double  cpsum;
+	int     *pstype = NULL, *pnpart=NULL,**ppstrt=NULL,**pptype=NULL,*pnvert=NULL;
+	double **pshapx = NULL,**pshapy=NULL,**pshapz=NULL,**pshapm=NULL;
+	double  *lat    = NULL, *lon=NULL;
+
+	SHPHandle   hSHP;
+	int     nShapeType, nEntities, iPart, bValidate = 0,nInvalidCount=0;
+	const char  *pszPlus;
+	double  adfMinBound[4], adfMaxBound[4];
+
+	char    indent[81]="";
+	KML_File          *kfile  = NULL;
+	KML_Document      *kdoc   = NULL;
+	KML_Style         *kstyle = NULL;
+	KML_LineStyle     *klsty  = NULL;
+	KML_PolyStyle     *kpsty  = NULL;
+	KML_Folder        *kfold  = NULL;
+	KML_Placemark     *kplace = NULL;
+	KML_MultiGeometry *kmulti = NULL;
+	KML_Polygon       *kpoly  = NULL;
+	KML_LinearRing    *kring  = NULL;
+	KML_LineString    *kline  = NULL;
+	KML_Point         *kpoint = NULL;
+	FILE              *fid    = NULL;
+
+	clock_t clock0,clock1;
+	time_t  time0, time1;
+
+	clock0=clock();
+	time0 =time(NULL);
+	_pprintString_("\nShp2Expx Module -- " << ctime(&time0));
+
+/*  note that much of the following code is taken from shpdump.c in shapelib.  */
+
+/*  open shp/shx files  */
+
+	hSHP = SHPOpen( filshp, "rb" );
+	if (!hSHP) _error_("Error opening shp/shx files.");
+
+/*  read header and print out file bounds  */
+
+	SHPGetInfo( hSHP, &nEntities, &nShapeType, adfMinBound, adfMaxBound );
+
+	printf( "Shapefile Type: %s   # of Shapes: %d\n\n",
+			SHPTypeName( nShapeType ), nEntities );
+
+	printf( "File Bounds: (%12.3f,%12.3f,%g,%g)\n"
+			"         to  (%12.3f,%12.3f,%g,%g)\n",
+			adfMinBound[0],
+			adfMinBound[1],
+			adfMinBound[2],
+			adfMinBound[3],
+			adfMaxBound[0],
+			adfMaxBound[1],
+			adfMaxBound[2],
+			adfMaxBound[3] );
+
+	nshape=nEntities;
+	pstype=xNew<int>(nshape);
+	pnpart=xNew<int>(nshape);
+	ppstrt=xNew<int*>(nshape);
+	pptype=xNew<int*>(nshape);
+	pnvert=xNew<int>(nshape);
+	pshapx=xNew<double*>(nshape);
+	pshapy=xNew<double*>(nshape);
+	pshapz=xNew<double*>(nshape);
+	pshapm=xNew<double*>(nshape);
+
+/*  loop over the list of shapes  */
+
+	for( i = 0; i < nEntities; i++ )
+	{
+//	int     j;
+		SHPObject   *psShape;
+
+	psShape = SHPReadObject( hSHP, i );
+
+	printf( "\nShape:%d (%s)  nVertices=%d, nParts=%d\n"
+				"  Bounds:(%12.3f,%12.3f, %g, %g)\n"
+				"      to (%12.3f,%12.3f, %g, %g)\n",
+			i, SHPTypeName(psShape->nSHPType),
+				psShape->nVertices, psShape->nParts,
+				psShape->dfXMin, psShape->dfYMin,
+				psShape->dfZMin, psShape->dfMMin,
+				psShape->dfXMax, psShape->dfYMax,
+				psShape->dfZMax, psShape->dfMMax );
+
+	pstype[i]=psShape->nSHPType;
+	pnpart[i]=psShape->nParts;
+	if (pnpart[i]) {
+		ppstrt[i]=xNew<int>(pnpart[i]);
+		pptype[i]=xNew<int>(pnpart[i]);
+	}
+	else {
+		ppstrt[i]=NULL;
+		pptype[i]=NULL;
+	}
+	pnvert[i]=psShape->nVertices;
+	if (pnvert[i]) {
+		pshapx[i]=xNew<double>(pnvert[i]);
+		pshapy[i]=xNew<double>(pnvert[i]);
+		pshapz[i]=xNew<double>(pnvert[i]);
+		pshapm[i]=xNew<double>(pnvert[i]);
+	}
+	else {
+		pshapx[i]=NULL;
+		pshapy[i]=NULL;
+		pshapz[i]=NULL;
+		pshapm[i]=NULL;
+	}
+
+	for( j = 0, iPart = 1; j < psShape->nVertices; j++ )
+	{
+			const char  *pszPartType = "";
+
+			if( j == 0 && psShape->nParts > 0 )
+			{
+				pszPartType = SHPPartTypeName( psShape->panPartType[0] );
+				ppstrt[i][0]=psShape->panPartStart[0];
+				pptype[i][0]=psShape->panPartType[0];
+			}
+
+		if( iPart < psShape->nParts
+				&& psShape->panPartStart[iPart] == j )
+		{
+				pszPartType = SHPPartTypeName( psShape->panPartType[iPart] );
+				ppstrt[i][iPart]=psShape->panPartStart[iPart];
+				pptype[i][iPart]=psShape->panPartType[iPart];
+		iPart++;
+		pszPlus = "+";
+		}
+		else
+			pszPlus = " ";
+
+//		printf("   %s (%12.3f,%12.3f, %g, %g) %s \n",
+//				   pszPlus,
+//				   psShape->padfX[j],
+//				   psShape->padfY[j],
+//				   psShape->padfZ[j],
+//				   psShape->padfM[j],
+//				   pszPartType );
+
+		pshapx[i][j]=psShape->padfX[j];
+		pshapy[i][j]=psShape->padfY[j];
+		pshapz[i][j]=psShape->padfZ[j];
+		pshapm[i][j]=psShape->padfM[j];
+	}
+
+		if( bValidate )
+		{
+			int nAltered = SHPRewindObject( hSHP, psShape );
+
+			if( nAltered > 0 )
+			{
+				printf( "  %d rings wound in the wrong direction.\n",
+						nAltered );
+				nInvalidCount++;
+			}
+		}
+
+		SHPDestroyObject( psShape );
+	}
+
+/*  close shp/shx files  */
+
+	SHPClose( hSHP );
+
+/*  construct kml file  */
+
+	kfile =new KML_File();
+	kfile->AddAttrib("xmlns","http://www.opengis.net/kml/2.2");
+
+/*  construct kml document  */
+
+	kdoc  =new KML_Document();
+	sprintf(kdoc->name      ,"Shp2Kmlx Module -- %s",ctime(&time0));
+	kdoc->open      =1;
+
+/*  construct style templates for defaults  */
+
+	klsty =new KML_LineStyle();
+	sprintf(klsty->color     ,"ff000000");
+	sprintf(klsty->colormode ,"normal");
+	klsty->width     =lwidth;
+	kpsty =new KML_PolyStyle();
+	sprintf(kpsty->color     ,"%02xffffff",(int)floor(popac*255+0.5));
+	sprintf(kpsty->colormode ,"random");
+	kstyle=new KML_Style();
+	kstyle->AddAttrib("id","BlackLineRandomPoly");
+	kstyle->line      =klsty;
+	kstyle->poly      =kpsty;
+	(kdoc->style     )->AddObject((Object*)kstyle);
+
+	klsty =new KML_LineStyle();
+	sprintf(klsty->color     ,"ff000000");
+	sprintf(klsty->colormode ,"normal");
+	klsty->width     ,lwidth;
+	kpsty =new KML_PolyStyle();
+	sprintf(kpsty->color     ,"00ffffff");
+	sprintf(kpsty->colormode ,"random");
+	kstyle=new KML_Style();
+	kstyle->AddAttrib("id","BlackLineEmptyPoly");
+	kstyle->line      =klsty;
+	kstyle->poly      =kpsty;
+	(kdoc->style     )->AddObject((Object*)kstyle);
+
+	klsty =new KML_LineStyle();
+	sprintf(klsty->color     ,"%02xffffff",(int)floor(popac*255+0.5));
+	sprintf(klsty->colormode ,"random");
+	klsty->width     =lwidth*2;
+	kpsty =new KML_PolyStyle();
+	sprintf(kpsty->color     ,"00ffffff");
+	sprintf(kpsty->colormode ,"random");
+	kstyle=new KML_Style();
+	kstyle->AddAttrib("id","RandomLineEmptyPoly");
+	kstyle->line      =klsty;
+	kstyle->poly      =kpsty;
+	(kdoc->style     )->AddObject((Object*)kstyle);
+
+/*  construct kml folder for shapes  */
+
+	kfold =new KML_Folder();
+	sprintf(kfold->name      ,"Shapefile: %s  Type: %s  nShapes: %d",
+			filshp, SHPTypeName( nShapeType ), nEntities );
+	kfold->open      =1;
+
+/*  loop over the list of shapes  */
+
+	for (i=0; i<nshape; i++) {
+
+/*  null type  */
+
+		if      (pstype[i] == SHPT_NULL) {
+			;
+		}
+
+/*  point types  */
+
+		else if (pstype[i] == SHPT_POINT ||
+			  	 pstype[i] == SHPT_POINTZ ||
+			 	 pstype[i] == SHPT_POINTM) {
+			kplace=new KML_Placemark();
+
+			sprintf(kplace->name      ,"Shape:%d (%s)  nVertices=%d, nParts=%d",
+					i,SHPTypeName(pstype[i]),pnvert[i],pnpart[i]);
+			kplace->visibility=true;
+			sprintf(kplace->styleurl  ,"#RandomLineEmptyPoly");
+
+			if (pnpart[i] > 0)
+				_printf_(true,"Warning -- Shape %d of type \"%s\" should not have %d > 0 parts.\n",
+						 i,SHPTypeName( pstype[i] ),pnpart[i]);
+			if (pnvert[i] > 1)
+				_printf_(true,"Warning -- Shape %d of type \"%s\" should not have %d > 1 vertices.\n",
+						 i,SHPTypeName( pstype[i] ),pnvert[i]);
+
+			kpoint=new KML_Point();
+
+			lat=xNew<double>(pnvert[i]);
+			lon=xNew<double>(pnvert[i]);
+			if (sgn) {
+				Xy2llx(lat,lon,pshapx[i],pshapy[i],pnvert[i],sgn,cm,sp);
+			}
+			else  {
+				memcpy(lon,pshapx[i],pnvert[i]*sizeof(double));
+				memcpy(lat,pshapy[i],pnvert[i]*sizeof(double));
+			}
+
+			kpoint->coords[0]=lon      [0];
+			kpoint->coords[1]=lat      [0];
+			kpoint->coords[2]=pshapz[i][0];
+
+			xDelete<double>(lon);
+			xDelete<double>(lat);
+
+			(kplace->geometry  )->AddObject((Object*)kpoint);
+			kpoint=NULL;
+			(kfold ->feature   )->AddObject((Object*)kplace);
+			kplace=NULL;
+		}
+
+/*  polyline types  */
+
+		else if (pstype[i] == SHPT_ARC ||
+				 pstype[i] == SHPT_ARCZ ||
+				 pstype[i] == SHPT_ARCM) {
+			kplace=new KML_Placemark();
+
+			sprintf(kplace->name      ,"Shape:%d (%s)  nVertices=%d, nParts=%d",
+					i,SHPTypeName(pstype[i]),pnvert[i],pnpart[i]);
+			kplace->visibility=true;
+			sprintf(kplace->styleurl  ,"#RandomLineEmptyPoly");
+
+/*  create a multigeometry to hold all the lines  */
+
+			kmulti=new KML_MultiGeometry();
+
+/*  convert to lat/lon, if necessary  */
+
+			lat=xNew<double>(pnvert[i]);
+			lon=xNew<double>(pnvert[i]);
+			if (sgn) {
+				Xy2llx(lat,lon,pshapx[i],pshapy[i],pnvert[i],sgn,cm,sp);
+			}
+			else  {
+				memcpy(lon,pshapx[i],pnvert[i]*sizeof(double));
+				memcpy(lat,pshapy[i],pnvert[i]*sizeof(double));
+			}
+
+/*  loop over the lines  */
+
+			for (j=0; j<pnpart[i]; j++) {
+				kline =new KML_LineString();
+
+				kline->ncoord    =(j<pnpart[i]-1 ? ppstrt[i][j+1]-ppstrt[i][j] : pnvert[i]-ppstrt[i][j]);
+				kline->coords    =xNew<double>(kline->ncoord*3);
+				for (k=0; k<kline->ncoord; k++) {
+					kline->coords[3*k+0]=lon      [ppstrt[i][j]+k];
+					kline->coords[3*k+1]=lat      [ppstrt[i][j]+k];
+					kline->coords[3*k+2]=pshapz[i][ppstrt[i][j]+k];
+				}
+				(kmulti->geometry  )->AddObject((Object*)kline);
+				kline = NULL;
+			}
+
+			xDelete<double>(lon);
+			xDelete<double>(lat);
+
+			(kplace->geometry)->AddObject((Object*)kmulti);
+			kmulti=NULL;
+			(kfold ->feature )->AddObject((Object*)kplace);
+			kplace=NULL;
+		}
+
+/*  polygon types  */
+
+		else if (pstype[i] == SHPT_POLYGON ||
+				 pstype[i] == SHPT_POLYGONZ ||
+				 pstype[i] == SHPT_POLYGONM) {
+
+/*  the shp format specifies that outer rings are cw, while inner rings are ccw.  there
+	may be multiple outer rings and inner rings in any order.  the kml format specifies
+	all rings are ccw (right-hand rule).  there may be only one outer ring with multiple
+	inner rings, and rings are differentiated by keyword.
+
+	at least for now, assume that each cw ring forms a new kml polygon, and each ccw
+	ring forms an inner ring for the most recent outer ring.  a more elaborate solution
+	would be for each inner ring to search in which outer ring it occurs.  */
+
+			kplace=new KML_Placemark();
+
+			sprintf(kplace->name      ,"Shape:%d (%s)  nVertices=%d, nParts=%d",
+					i,SHPTypeName(pstype[i]),pnvert[i],pnpart[i]);
+			kplace->visibility=true;
+			sprintf(kplace->styleurl  ,"#BlackLineRandomPoly");
+
+/*  create a multigeometry to hold all the polygons  */
+
+			kmulti=new KML_MultiGeometry();
+
+/*  convert to lat/lon, if necessary  */
+
+			lat=xNew<double>(pnvert[i]);
+			lon=xNew<double>(pnvert[i]);
+			if (sgn) {
+				Xy2llx(lat,lon,pshapx[i],pshapy[i],pnvert[i],sgn,cm,sp);
+			}
+			else  {
+				memcpy(lon,pshapx[i],pnvert[i]*sizeof(double));
+				memcpy(lat,pshapy[i],pnvert[i]*sizeof(double));
+			}
+
+/*  loop over the polygons  */
+
+			for (j=0; j<pnpart[i]; j++) {
+
+/*  check if polygon is ccw or cw by computing sum of cross products (twice the area)  */
+
+				ncoord=(j<pnpart[i]-1 ? ppstrt[i][j+1]-ppstrt[i][j] : pnvert[i]-ppstrt[i][j]);
+				cpsum =0.;
+
+				for (k=ppstrt[i][j]; k<ppstrt[i][j]+ncoord-1; k++)
+					cpsum +=pshapx[i][k]*pshapy[i][k+1         ]-pshapy[i][k]*pshapx[i][k+1         ];
+				cpsum +=pshapx[i][k]*pshapy[i][ppstrt[i][j]]-pshapy[i][k]*pshapx[i][ppstrt[i][j]];
+
+/*  outer ring (cw) (allow exception for single-part shapes)  */
+
+				if (cpsum < 0 || pnpart[i] == 1) {
+					if (kpoly) {
+						(kmulti->geometry  )->AddObject((Object*)kpoly);
+						kpoly =NULL;
+					}
+
+/*  create a new polygon from the outer ring (reversing cw to ccw)  */
+
+					kpoly =new KML_Polygon();
+					kring =new KML_LinearRing();
+
+					kring->ncoord    =(j<pnpart[i]-1 ? ppstrt[i][j+1]-ppstrt[i][j] : pnvert[i]-ppstrt[i][j]);
+					kring->coords    =xNew<double>(kring->ncoord*3);
+					if (cpsum < 0)
+						for (k=0; k<kring->ncoord; k++) {
+							kring->coords[3*(kring->ncoord-1-k)+0]=lon      [ppstrt[i][j]+k];
+							kring->coords[3*(kring->ncoord-1-k)+1]=lat      [ppstrt[i][j]+k];
+							kring->coords[3*(kring->ncoord-1-k)+2]=pshapz[i][ppstrt[i][j]+k];
+						}
+					else
+						for (k=0; k<kring->ncoord; k++) {
+							kring->coords[3*k+0]=lon      [ppstrt[i][j]+k];
+							kring->coords[3*k+1]=lat      [ppstrt[i][j]+k];
+							kring->coords[3*k+2]=pshapz[i][ppstrt[i][j]+k];
+						}
+
+					(kpoly ->outer     )->AddObject((Object*)kring);
+					kring =NULL;
+				}
+
+/*  inner ring (ccw)  */
+
+				else {
+					if (!kpoly) {
+						_printf_(true,"Warning -- Shape %d of type \"%s\", part %d, expected to be outer loop (cw).\n",
+								 i,SHPTypeName( pstype[i] ),j);
+						continue;
+					}
+
+/*  add the inner ring to the current polygon  */
+
+					kring =new KML_LinearRing();
+
+					kring->ncoord    =(j<pnpart[i]-1 ? ppstrt[i][j+1]-ppstrt[i][j] : pnvert[i]-ppstrt[i][j]);
+					kring->coords    =xNew<double>(kring->ncoord*3);
+					for (k=0; k<kring->ncoord; k++) {
+						kring->coords[3*k+0]=lon      [ppstrt[i][j]+k];
+						kring->coords[3*k+1]=lat      [ppstrt[i][j]+k];
+						kring->coords[3*k+2]=pshapz[i][ppstrt[i][j]+k];
+					}
+
+					(kpoly ->inner     )->AddObject((Object*)kring);
+					kring =NULL;
+				}
+			}
+
+			if (kpoly) {
+				(kmulti->geometry  )->AddObject((Object*)kpoly);
+				kpoly =NULL;
+			}
+
+			xDelete<double>(lon);
+			xDelete<double>(lat);
+
+			(kplace->geometry  )->AddObject((Object*)kmulti);
+			kmulti=NULL;
+			(kfold ->feature   )->AddObject((Object*)kplace);
+			kplace=NULL;
+		}
+
+/*  multipoint types  */
+
+		else if (pstype[i] == SHPT_MULTIPOINT ||
+				 pstype[i] == SHPT_MULTIPOINTZ ||
+				 pstype[i] == SHPT_MULTIPOINTM) {
+			kplace=new KML_Placemark();
+
+			sprintf(kplace->name      ,"Shape:%d (%s)  nVertices=%d, nParts=%d",
+					i,SHPTypeName(pstype[i]),pnvert[i],pnpart[i]);
+			kplace->visibility=true;
+			sprintf(kplace->styleurl  ,"#RandomLineEmptyPoly");
+
+			if (pnpart[i] > 0)
+				_printf_(true,"Warning -- Shape %d of type \"%s\" should not have %d > 0 parts.\n",
+						 i,SHPTypeName( pstype[i] ),pnpart[i]);
+
+/*  create a multigeometry to hold all the points  */
+
+			kmulti=new KML_MultiGeometry();
+
+/*  convert to lat/lon, if necessary  */
+
+			lat=xNew<double>(pnvert[i]);
+			lon=xNew<double>(pnvert[i]);
+			if (sgn) {
+				Xy2llx(lat,lon,pshapx[i],pshapy[i],pnvert[i],sgn,cm,sp);
+			}
+			else  {
+				memcpy(lon,pshapx[i],pnvert[i]*sizeof(double));
+				memcpy(lat,pshapy[i],pnvert[i]*sizeof(double));
+			}
+
+/*  loop over the points  */
+
+			for (j=0; j<pnvert[i]; j++) {
+				kpoint=new KML_Point();
+
+				kpoint->coords[0]=lon      [j];
+				kpoint->coords[1]=lat      [j];
+				kpoint->coords[2]=pshapz[i][j];
+
+				(kmulti->geometry  )->AddObject((Object*)kpoint);
+				kpoint=NULL;
+			}
+
+			xDelete<double>(lon);
+			xDelete<double>(lat);
+
+			(kplace->geometry  )->AddObject((Object*)kmulti);
+			kmulti=NULL;
+			(kfold ->feature   )->AddObject((Object*)kplace);
+			kplace=NULL;
+		}
+
+/*  multipatch types  */
+
+		else if (pstype[i] == SHPT_MULTIPATCH) {
+			_printf_(true,"Warning -- Shape %d of type \"%s\" will be ignored.\n",
+					 i,SHPTypeName( pstype[i] ));
+			continue;
+		}
+
+/*  unknown type  */
+
+		else {
+			_printf_(true,"Warning -- Shape %d of type \"%s\" will be ignored.\n",
+					 i,SHPTypeName( pstype[i] ));
+		}
+	}
+
+/*  assemble the rest of the kml hierarchy  */
+
+	(kdoc ->feature   )->AddObject((Object*)kfold);
+	kfold=NULL;
+	(kfile->kmlobj    )->AddObject((Object*)kdoc);
+	kdoc =NULL;
+
+/*  open exp file  */
+
+	_pprintLine_("Writing exp profiles to file.");
+	fid=fopen(filexp,"w");
+
+/*  write the polygons and linestrings  */
+
+	kfile->WriteExp(fid,"",sgn,cm,sp);
+
+/*  close exp file  */
+
+	fclose(fid);
+
+	delete kfile;
+	for (i=nshape-1; i>=0; i--) {
+		xDelete<double>((pshapm[i]));
+		xDelete<double>((pshapz[i]));
+		xDelete<double>((pshapy[i]));
+		xDelete<double>((pshapx[i]));
+	}
+	xDelete<double*>(pshapm);
+	xDelete<double*>(pshapz);
+	xDelete<double*>(pshapy);
+	xDelete<double*>(pshapx);
+	xDelete<int>(pnvert);
+	for (i=nshape-1; i>=0; i--) {
+		xDelete<int>((pptype[i]));
+		xDelete<int>((ppstrt[i]));
+	}
+	xDelete<int*>(pptype);
+	xDelete<int*>(ppstrt);
+	xDelete<int>(pnpart);
+	xDelete<int>(pstype);
+
+	clock1=clock();
+	time1 =time(NULL);
+	_printf_(true,"Shp2Expx Module -- %f CPU seconds; %f elapsed seconds.\n\n",
+			 ((double)(clock1-clock0))/CLOCKS_PER_SEC,difftime(time1,time0));
+
+	return(iret);
+
+	#else //ifdef _HAVE_SHAPELIB_
+	return 0;
+	#endif
+}
Index: /issm/trunk/src/c/modules/Shp2Expx/Shp2Expx.h
===================================================================
--- /issm/trunk/src/c/modules/Shp2Expx/Shp2Expx.h	(revision 14310)
+++ /issm/trunk/src/c/modules/Shp2Expx/Shp2Expx.h	(revision 14310)
@@ -0,0 +1,28 @@
+/*!\file:  Shp2Expx.h
+ * \brief header file for shp to exp conversion routines.
+ */ 
+
+#ifndef _SHP2EXPX_H
+#define _SHP2EXPX_H
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+#ifdef _HAVE_SHAPELIB_ //only works if Shapelib library has been compiled in.
+
+#include "shapefil.h"
+
+#endif
+
+#include "../../Container/Container.h"
+#include "../../classes/objects/objects.h"
+
+/* local prototypes: */
+int Shp2Expx(char* filshp,char* filexp);
+int Shp2Expx(char* filshp,char* filexp, int sgn);
+int Shp2Expx(char* filshp,char* filexp, int sgn,double cm,double sp);
+
+#endif  /* _SHP2EXPX_H */
Index: /issm/trunk/src/c/modules/Shp2Kmlx/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/Shp2Kmlx/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/Shp2Kmlx/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,8 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/Shp2Kmlx)
+# }}}
+# KML_SOURCES {{{
+set(KML_SOURCES $ENV{ISSM_DIR}/src/c/modules/Shp2Kmlx/Shp2Kmlx.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/modules/SmbGradientsx/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/SmbGradientsx/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/SmbGradientsx/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,8 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/SmbGradientsx)
+# }}}
+# CORE_SOURCES {{{
+set(CORE_SOURCES $ENV{ISSM_DIR}/src/c/modules/SmbGradientsx/SmbGradientsx.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/modules/Solverx/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/Solverx/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/Solverx/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,9 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/Solverx)
+# }}}
+# CORE_SOURCES {{{
+set(CORE_SOURCES $ENV{ISSM_DIR}/src/c/modules/Solverx/Solverx.cpp
+              $ENV{ISSM_DIR}/src/c/modules/Solverx/SolverxSeq.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/modules/SpcNodesx/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/SpcNodesx/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/SpcNodesx/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,8 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/SpcNodesx)
+# }}}
+# CORE_SOURCES {{{
+set(CORE_SOURCES $ENV{ISSM_DIR}/src/c/modules/SpcNodesx/SpcNodesx.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/modules/StringToEnumx/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/StringToEnumx/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/StringToEnumx/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,8 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/StringToEnumx)
+# }}}
+# CORE_SOURCES {{{
+set(CORE_SOURCES $ENV{ISSM_DIR}/src/c/modules/StringToEnumx/StringToEnumx.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/modules/StringToEnumx/StringToEnumx.cpp
===================================================================
--- /issm/trunk/src/c/modules/StringToEnumx/StringToEnumx.cpp	(revision 14309)
+++ /issm/trunk/src/c/modules/StringToEnumx/StringToEnumx.cpp	(revision 14310)
@@ -205,12 +205,7 @@
 	      else if (strcmp(name,"SurfaceforcingsIssmbgradients")==0) return SurfaceforcingsIssmbgradientsEnum;
 	      else if (strcmp(name,"SurfaceforcingsMonthlytemperatures")==0) return SurfaceforcingsMonthlytemperaturesEnum;
-	      else if (strcmp(name,"SurfaceforcingsHc")==0) return SurfaceforcingsHcEnum;
 	      else if (strcmp(name,"SurfaceforcingsHref")==0) return SurfaceforcingsHrefEnum;
 	      else if (strcmp(name,"SurfaceforcingsSmbref")==0) return SurfaceforcingsSmbrefEnum;
-	      else if (strcmp(name,"SurfaceforcingsSmbPosMax")==0) return SurfaceforcingsSmbPosMaxEnum;
-	      else if (strcmp(name,"SurfaceforcingsSmbPosMin")==0) return SurfaceforcingsSmbPosMinEnum;
-	      else if (strcmp(name,"SurfaceforcingsAPos")==0) return SurfaceforcingsAPosEnum;
 	      else if (strcmp(name,"SurfaceforcingsBPos")==0) return SurfaceforcingsBPosEnum;
-	      else if (strcmp(name,"SurfaceforcingsANeg")==0) return SurfaceforcingsANegEnum;
 	      else if (strcmp(name,"SurfaceforcingsBNeg")==0) return SurfaceforcingsBNegEnum;
 	      else if (strcmp(name,"ThermalMaxiter")==0) return ThermalMaxiterEnum;
@@ -242,4 +237,6 @@
 	      else if (strcmp(name,"BalancethicknessAnalysis")==0) return BalancethicknessAnalysisEnum;
 	      else if (strcmp(name,"BalancethicknessSolution")==0) return BalancethicknessSolutionEnum;
+	      else if (strcmp(name,"WeakBalancethicknessAnalysis")==0) return WeakBalancethicknessAnalysisEnum;
+	      else if (strcmp(name,"WeakBalancethicknessSolution")==0) return WeakBalancethicknessSolutionEnum;
 	      else if (strcmp(name,"BedSlopeAnalysis")==0) return BedSlopeAnalysisEnum;
 	      else if (strcmp(name,"BedSlopeSolution")==0) return BedSlopeSolutionEnum;
@@ -261,11 +258,11 @@
 	      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 stage=3;
    }
    if(stage==3){
-	      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;
+	      if (strcmp(name,"SurfaceSlopeYAnalysis")==0) return SurfaceSlopeYAnalysisEnum;
 	      else if (strcmp(name,"ThermalAnalysis")==0) return ThermalAnalysisEnum;
 	      else if (strcmp(name,"ThermalSolution")==0) return ThermalSolutionEnum;
@@ -353,4 +350,5 @@
 	      else if (strcmp(name,"Adjointy")==0) return AdjointyEnum;
 	      else if (strcmp(name,"Adjointz")==0) return AdjointzEnum;
+	      else if (strcmp(name,"BalancethicknessMisfit")==0) return BalancethicknessMisfitEnum;
 	      else if (strcmp(name,"BedSlopeX")==0) return BedSlopeXEnum;
 	      else if (strcmp(name,"BedSlopeY")==0) return BedSlopeYEnum;
@@ -380,13 +378,14 @@
 	      else if (strcmp(name,"QmuSurface")==0) return QmuSurfaceEnum;
 	      else if (strcmp(name,"QmuMelting")==0) return QmuMeltingEnum;
+	      else if (strcmp(name,"AndroidFrictionCoefficient")==0) return AndroidFrictionCoefficientEnum;
 	      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 stage=4;
    }
    if(stage==4){
-	      if (strcmp(name,"SurfaceAverageVelMisfit")==0) return SurfaceAverageVelMisfitEnum;
-	      else if (strcmp(name,"SurfaceLogVelMisfit")==0) return SurfaceLogVelMisfitEnum;
+	      if (strcmp(name,"SurfaceLogVelMisfit")==0) return SurfaceLogVelMisfitEnum;
 	      else if (strcmp(name,"SurfaceLogVxVyMisfit")==0) return SurfaceLogVxVyMisfitEnum;
 	      else if (strcmp(name,"SurfaceRelVelMisfit")==0) return SurfaceRelVelMisfitEnum;
@@ -426,5 +425,4 @@
 	      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;
@@ -507,10 +505,10 @@
 	      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 stage=5;
    }
    if(stage==5){
-	      if (strcmp(name,"Scaled")==0) return ScaledEnum;
-	      else if (strcmp(name,"Separate")==0) return SeparateEnum;
-	      else if (strcmp(name,"Sset")==0) return SsetEnum;
+	      if (strcmp(name,"Sset")==0) return SsetEnum;
 	      else if (strcmp(name,"Verbose")==0) return VerboseEnum;
 	      else if (strcmp(name,"TriangleInterp")==0) return TriangleInterpEnum;
Index: /issm/trunk/src/c/modules/SurfaceAbsVelMisfitx/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/SurfaceAbsVelMisfitx/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/SurfaceAbsVelMisfitx/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,5 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/SurfaceAbsVelMisfitx)
+# }}}
Index: /issm/trunk/src/c/modules/SurfaceAreax/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/SurfaceAreax/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/SurfaceAreax/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,8 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/SurfaceAreax)
+# }}}
+# CORE_SOURCES {{{
+set(CORE_SOURCES $ENV{ISSM_DIR}/src/c/modules/SurfaceAreax/SurfaceAreax.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/modules/SurfaceAverageVelMisfitx/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/SurfaceAverageVelMisfitx/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/SurfaceAverageVelMisfitx/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,5 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/SurfaceAverageVelMisfitx)
+# }}}
Index: /issm/trunk/src/c/modules/SurfaceLogVelMisfitx/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/SurfaceLogVelMisfitx/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/SurfaceLogVelMisfitx/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,5 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/SurfaceLogVelMisfitx)
+# }}}
Index: /issm/trunk/src/c/modules/SurfaceLogVxVyMisfitx/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/SurfaceLogVxVyMisfitx/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/SurfaceLogVxVyMisfitx/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,5 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/SurfaceLogVxVyMisfitx)
+# }}}
Index: /issm/trunk/src/c/modules/SurfaceRelVelMisfitx/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/SurfaceRelVelMisfitx/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/SurfaceRelVelMisfitx/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,5 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/SurfaceRelVelMisfitx)
+# }}}
Index: /issm/trunk/src/c/modules/ThicknessAbsMisfitx/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/ThicknessAbsMisfitx/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/ThicknessAbsMisfitx/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,5 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/ThicknessAbsMisfitx)
+# }}}
Index: /issm/trunk/src/c/modules/ThicknessAcrossGradientx/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/ThicknessAcrossGradientx/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/ThicknessAcrossGradientx/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,5 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/ThicknessAcrossGradientx)
+# }}}
Index: /issm/trunk/src/c/modules/ThicknessAlongGradientx/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/ThicknessAlongGradientx/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/ThicknessAlongGradientx/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,5 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/ThicknessAlongGradientx)
+# }}}
Index: /issm/trunk/src/c/modules/TriMeshProcessRiftsx/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/TriMeshProcessRiftsx/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/TriMeshProcessRiftsx/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,5 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/TriMeshProcessRiftsx)
+# }}}
Index: /issm/trunk/src/c/modules/TriMeshProcessRiftsx/TriMeshProcessRiftsx.cpp
===================================================================
--- /issm/trunk/src/c/modules/TriMeshProcessRiftsx/TriMeshProcessRiftsx.cpp	(revision 14309)
+++ /issm/trunk/src/c/modules/TriMeshProcessRiftsx/TriMeshProcessRiftsx.cpp	(revision 14310)
@@ -9,13 +9,13 @@
 #include "../../toolkits/toolkits.h"
 
-void TriMeshProcessRiftsx(double** pindex, int* pnel,double** px,double** py,int* pnods,double** psegments,double** psegmentmarkers,int *pnum_seg,RiftStruct **priftstruct){
+void TriMeshProcessRiftsx(int** pindex, int* pnel,double** px,double** py,int* pnods,int** psegments,int** psegmentmarkers,int *pnum_seg,RiftStruct **priftstruct){
 
 	/*Output*/
 	int      numrifts,numrifts0;
 	int     *riftsnumsegments     = NULL;
-	double **riftssegments        = NULL;
+	int    **riftssegments        = NULL;
 	int     *riftsnumpairs        = NULL;
-	double **riftspairs           = NULL;
-	double  *riftstips            = NULL;
+	int    **riftspairs           = NULL;
+	int     *riftstips            = NULL;
 	double **riftspenaltypairs    = NULL;
 	int     *riftsnumpenaltypairs = NULL;
@@ -23,10 +23,10 @@
 	/*Recover initial mesh*/
 	int     nel            = *pnel;
-	double *index          = *pindex;
+	int    *index          = *pindex;
 	double *x              = *px;
 	double *y              = *py;
 	int     nods           = *pnods;
-	double *segments       = *psegments;
-	double *segmentmarkers = *psegmentmarkers;
+	int    *segments       = *psegments;
+	int    *segmentmarkers = *psegmentmarkers;
 	int     num_seg        = *pnum_seg;
 
Index: /issm/trunk/src/c/modules/TriMeshProcessRiftsx/TriMeshProcessRiftsx.h
===================================================================
--- /issm/trunk/src/c/modules/TriMeshProcessRiftsx/TriMeshProcessRiftsx.h	(revision 14309)
+++ /issm/trunk/src/c/modules/TriMeshProcessRiftsx/TriMeshProcessRiftsx.h	(revision 14310)
@@ -8,5 +8,5 @@
 class RiftStruct;
 
-void TriMeshProcessRiftsx(double** pindex, int* pnel,double** px,double** py,int* pnods,double** psegments,double** psegmentmarkers,int *pnum_seg,RiftStruct **priftstruct);
+void TriMeshProcessRiftsx(int** pindex,int* pnel,double** px,double** py,int* pnods,int** psegments,int** psegmentmarkers,int *pnum_seg,RiftStruct **priftstruct);
 
 #endif  /* _TRIMESHPROCESSRIFTX_H*/
Index: /issm/trunk/src/c/modules/TriMeshx/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/TriMeshx/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/TriMeshx/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,5 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/TriMeshx)
+# }}}
Index: /issm/trunk/src/c/modules/TriMeshx/TriMeshx.cpp
===================================================================
--- /issm/trunk/src/c/modules/TriMeshx/TriMeshx.cpp	(revision 14309)
+++ /issm/trunk/src/c/modules/TriMeshx/TriMeshx.cpp	(revision 14310)
@@ -22,5 +22,5 @@
 /*}}}*/
 
-void TriMeshx(SeqMat<IssmPDouble>** pindex,SeqVec<IssmPDouble>** px,SeqVec<IssmPDouble>** py,SeqMat<IssmPDouble>** psegments,SeqVec<IssmPDouble>** psegmentmarkerlist,DataSet* domain,DataSet* rifts,double area){
+void TriMeshx(SeqMat<int>** pindex,SeqVec<IssmPDouble>** px,SeqVec<IssmPDouble>** py,SeqMat<int>** psegments,SeqVec<int>** psegmentmarkerlist,DataSet* domain,DataSet* rifts,double area){
 
 #if !defined(_HAVE_TRIANGLE_)
@@ -31,11 +31,11 @@
 
 	/*output: */
-	IssmPDouble         *index             = NULL;
-	SeqMat<IssmPDouble> *index_matrix      = NULL;
-	double              *x                 = NULL;
-	double              *y                 = NULL;
-	double              *segments          = NULL;
-	SeqMat<IssmPDouble> *segments_matrix   = NULL;
-	double              *segmentmarkerlist = NULL;
+	int         *index             = NULL;
+	SeqMat<int> *index_matrix      = NULL;
+	double      *x                 = NULL;
+	double      *y                 = NULL;
+	int         *segments          = NULL;
+	SeqMat<int> *segments_matrix   = NULL;
+	int         *segmentmarkerlist = NULL;
 
 	/*intermediary: */
@@ -169,23 +169,23 @@
 
 	/*Allocate index, x and y: */
-	index=xNew<double>(3*out.numberoftriangles);
+	index=xNew<int>(3*out.numberoftriangles);
 	x=xNew<double>(out.numberofpoints);
 	y=xNew<double>(out.numberofpoints);
-	segments=xNew<double>(3*out.numberofsegments);
-	segmentmarkerlist=xNew<double>(out.numberofsegments);
+	segments=xNew<int>(3*out.numberofsegments);
+	segmentmarkerlist=xNew<int>(out.numberofsegments);
 
 	for (i = 0; i< out.numberoftriangles; i++) {
 		for (j = 0; j < out.numberofcorners; j++) {
-			index[3*i+j]=(double)out.trianglelist[i*out.numberofcorners+j]+1;
+			index[3*i+j]=(int)out.trianglelist[i*out.numberofcorners+j]+1;
 		}
 	}
 	for (i = 0; i< out.numberofpoints; i++){
-		x[i]=out.pointlist[i*2+0];
-		y[i]=out.pointlist[i*2+1];
+		x[i]=(double)out.pointlist[i*2+0];
+		y[i]=(double)out.pointlist[i*2+1];
 	}
 	for (i = 0; i<out.numberofsegments;i++){
-		segments[3*i+0]=(double)out.segmentlist[i*2+0]+1;
-		segments[3*i+1]=(double)out.segmentlist[i*2+1]+1;
-		segmentmarkerlist[i]=(double)out.segmentmarkerlist[i];
+		segments[3*i+0]=(int)out.segmentlist[i*2+0]+1;
+		segments[3*i+1]=(int)out.segmentlist[i*2+1]+1;
+		segmentmarkerlist[i]=(int)out.segmentmarkerlist[i];
 	}
 
@@ -197,13 +197,13 @@
 
 	/*Output : */
-	index_matrix=new SeqMat<IssmPDouble>(index,out.numberoftriangles,3,1.0);
+	index_matrix=new SeqMat<int>(index,out.numberoftriangles,3,1);
 	*pindex=index_matrix;
 
-	segments_matrix=new SeqMat<IssmPDouble>(segments,out.numberofsegments,3,1.0);
+	segments_matrix=new SeqMat<int>(segments,out.numberofsegments,3,1);
 	*psegments=segments_matrix;
 
 	*px=new SeqVec<IssmPDouble>(x,out.numberofpoints);
 	*py=new SeqVec<IssmPDouble>(y,out.numberofpoints);
-	*psegmentmarkerlist=new SeqVec<IssmPDouble>(segmentmarkerlist,out.numberofsegments);
+	*psegmentmarkerlist=new SeqVec<int>(segmentmarkerlist,out.numberofsegments);
 #endif
 }
Index: /issm/trunk/src/c/modules/TriMeshx/TriMeshx.h
===================================================================
--- /issm/trunk/src/c/modules/TriMeshx/TriMeshx.h	(revision 14309)
+++ /issm/trunk/src/c/modules/TriMeshx/TriMeshx.h	(revision 14310)
@@ -11,5 +11,5 @@
 
 /* local prototypes: */
-void TriMeshx(SeqMat<IssmPDouble>** pindex,SeqVec<IssmPDouble>** px,SeqVec<IssmPDouble>** py,SeqMat<IssmPDouble>** psegments,SeqVec<IssmPDouble>** psegmentmarkerlist,DataSet* domain,DataSet* rifts,double area);
+void TriMeshx(SeqMat<int>** pindex,SeqVec<IssmPDouble>** px,SeqVec<IssmPDouble>** py,SeqMat<int>** psegments,SeqVec<int>** psegmentmarkerlist,DataSet* domain,DataSet* rifts,double area);
 
 #endif  /* _TRIMESHX_H */
Index: /issm/trunk/src/c/modules/TriaSearchx/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/TriaSearchx/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/TriaSearchx/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,5 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/TriaSearchx)
+# }}}
Index: /issm/trunk/src/c/modules/UpdateDynamicConstraintsx/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/UpdateDynamicConstraintsx/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/UpdateDynamicConstraintsx/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,8 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/UpdateDynamicConstraintsx)
+# }}}
+# CORE_SOURCES {{{
+set(CORE_SOURCES $ENV{ISSM_DIR}/src/c/modules/UpdateDynamicConstraintsx/UpdateDynamicConstraintsx.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/modules/VecMergex/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/VecMergex/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/VecMergex/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,8 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/VecMergex)
+# }}}
+# CORE_SOURCES {{{
+set(CORE_SOURCES $ENV{ISSM_DIR}/src/c/modules/VecMergex/VecMergex.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/modules/VerticesDofx/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/VerticesDofx/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/VerticesDofx/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,8 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/VerticesDofx)
+# }}}
+# CORE_SOURCES {{{
+set(CORE_SOURCES $ENV{ISSM_DIR}/src/c/modules/VerticesDofx/VerticesDofx.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/modules/Xy2llx/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/modules/Xy2llx/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/modules/Xy2llx/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,5 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/modules/Xy2llx)
+# }}}
Index: /issm/trunk/src/c/modules/modules.h
===================================================================
--- /issm/trunk/src/c/modules/modules.h	(revision 14309)
+++ /issm/trunk/src/c/modules/modules.h	(revision 14310)
@@ -60,5 +60,4 @@
 #include "./Kml2Expx/Kml2Expx.h"
 #include "./Krigingx/Krigingx.h"
-#include "./Shp2Kmlx/Shp2Kmlx.h"
 #include "./Mergesolutionfromftogx/Mergesolutionfromftogx.h"
 #include "./MeshPartitionx/MeshPartitionx.h"
@@ -87,4 +86,6 @@
 #include "./RheologyBbarAbsGradientx/RheologyBbarAbsGradientx.h"
 #include "./Scotchx/Scotchx.h"
+#include "./Shp2Expx/Shp2Expx.h"
+#include "./Shp2Kmlx/Shp2Kmlx.h"
 #include "./SmbGradientsx/SmbGradientsx.h"
 #include "./Solverx/Solverx.h"
Index: /issm/trunk/src/c/shared/Alloc/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/shared/Alloc/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/shared/Alloc/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,8 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/shared/Alloc)
+# }}}
+# CORE_SOURCES {{{
+set(CORE_SOURCES $ENV{ISSM_DIR}/src/c/shared/Alloc/alloc.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/shared/Bamg/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/shared/Bamg/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/shared/Bamg/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,8 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/shared/Bamg)
+# }}}
+# BAMG_SOURCES {{{
+set(BAMG_SOURCES $ENV{ISSM_DIR}/src/c/shared/Bamg/BigPrimeNumber.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/shared/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/shared/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/shared/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,17 @@
+# Subdirectories {{{
+add_subdirectory(Alloc)
+add_subdirectory(Bamg)
+add_subdirectory(Elements)
+add_subdirectory(Exceptions)
+add_subdirectory(Exp)
+add_subdirectory(Matrix)
+add_subdirectory(MemOps)
+add_subdirectory(Numerics)
+add_subdirectory(Sorting)
+add_subdirectory(String)
+add_subdirectory(Threads)
+add_subdirectory(TriMesh)
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/shared)
+# }}}
Index: /issm/trunk/src/c/shared/Elements/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/shared/Elements/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/shared/Elements/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,23 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/shared/Elements)
+# }}}
+# CORE_SOURCES {{{
+set(CORE_SOURCES $ENV{ISSM_DIR}/src/c/shared/Elements/Arrhenius.cpp
+$ENV{ISSM_DIR}/src/c/shared/Elements/ComputeDelta18oTemperaturePrecipitation.cpp
+          $ENV{ISSM_DIR}/src/c/shared/Elements/GetGlobalDofList.cpp
+           $ENV{ISSM_DIR}/src/c/shared/Elements/GetLocalDofList.cpp
+           $ENV{ISSM_DIR}/src/c/shared/Elements/GetNumberOfDofs.cpp
+    $ENV{ISSM_DIR}/src/c/shared/Elements/GetVerticesCoordinates.cpp
+                  $ENV{ISSM_DIR}/src/c/shared/Elements/Paterson.cpp
+     $ENV{ISSM_DIR}/src/c/shared/Elements/PddSurfaceMassBalance.cpp
+               $ENV{ISSM_DIR}/src/c/shared/Elements/PrintArrays.cpp PARENT_SCOPE)
+# }}}
+# DIAGNOSTIC_SOURCES {{{
+set(DIAGNOSTIC_SOURCES $ENV{ISSM_DIR}/src/c/shared/Elements/CoordinateSystemTransform.cpp
+                $ENV{ISSM_DIR}/src/c/shared/Elements/TransformInvStiffnessMatrixCoord.cpp
+                        $ENV{ISSM_DIR}/src/c/shared/Elements/TransformLoadVectorCoord.cpp
+                          $ENV{ISSM_DIR}/src/c/shared/Elements/TransformSolutionCoord.cpp
+                   $ENV{ISSM_DIR}/src/c/shared/Elements/TransformStiffnessMatrixCoord.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/shared/Elements/PrintArrays.cpp
===================================================================
--- /issm/trunk/src/c/shared/Elements/PrintArrays.cpp	(revision 14309)
+++ /issm/trunk/src/c/shared/Elements/PrintArrays.cpp	(revision 14310)
@@ -39,4 +39,13 @@
 	_printLine_("");
 }
+void printarray(bool* array,int lines,int cols){
+	_printLine_("");
+	for(int i=0;i<lines;i++){  
+		_printString_("   [ ");
+		for(int j=0;j<cols;j++) _printString_( " " << array[i*cols+j]?1:0);
+		_printLine_(" ]");
+	}  
+	_printLine_("");
+}
 void printbinary(int n){
 	unsigned int i=1L<<(sizeof(n)*8-1);
Index: /issm/trunk/src/c/shared/Elements/elements.h
===================================================================
--- /issm/trunk/src/c/shared/Elements/elements.h	(revision 14309)
+++ /issm/trunk/src/c/shared/Elements/elements.h	(revision 14310)
@@ -40,4 +40,5 @@
 void printarray(IssmPDouble* array,int lines,int cols=1);
 void printarray(int* array,int lines,int cols=1);
+void printarray(bool* array,int lines,int cols=1);
 void printsparsity(IssmPDouble* array,int lines,int cols=1);
 void printbinary(int n);
Index: /issm/trunk/src/c/shared/Exceptions/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/shared/Exceptions/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/shared/Exceptions/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,9 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/shared/Exceptions)
+# }}}
+# CORE_SOURCES {{{
+set(CORE_SOURCES $ENV{ISSM_DIR}/src/c/shared/Exceptions/Exceptions.cpp
+                   $ENV{ISSM_DIR}/src/c/shared/Exceptions/exprintf.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/shared/Exp/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/shared/Exp/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/shared/Exp/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,5 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/shared/Exp)
+# }}}
Index: sm/trunk/src/c/shared/Exp/DomainOutlineWrite.cpp
===================================================================
--- /issm/trunk/src/c/shared/Exp/DomainOutlineWrite.cpp	(revision 14309)
+++ 	(revision )
@@ -1,56 +1,0 @@
-/*!\file:  DomainOutlineWrite.cpp
- * \brief DomainOutlineWrite.c: write the vertex coordinates defined in a domain 
- * outline from Argus (.exp file). The first contour in the file is for 
- * the outside domain outline. The following contours represent holes in
- * the domain.
- */
-
-#include <stdio.h>
-#include "../Alloc/alloc.h"
-#include "../../include/include.h"
-#include "../Exceptions/exceptions.h"
-
-int DomainOutlineWrite(int nprof,int* profnvertices,double** pprofx,double** pprofy,bool* closed,char* domainname){
-
-	/*Error management: */
-	int noerr=1;
-	int i,counter;
-
-	/*I/O: */
-	FILE* fid=NULL;
-
-	/*open domain outline file for writing: */
-	if ((fid=fopen(domainname,"w"))==NULL){
-		_error_("could not open domain file " << domainname); 
-		noerr=0; goto cleanupandreturn;
-	}
-
-	/*Start writing profiles: */
-	for(counter=0;counter<nprof;counter++){
-
-		/*Write header: */
-		fprintf(fid,"%s %s\n","##","Name:");
-		fprintf(fid,"%s %s\n","##","Icon:0");
-		fprintf(fid,"%s %s %s %s\n","#","Points","Count","Value");
-
-		/*Write number of profile vertices: */
-		fprintf(fid,"%u %s\n",profnvertices[counter]  ,"1.");
-
-		/*Write next line: */
-		fprintf(fid,"%s %s %s %s %s\n","#","X","pos","Y","pos");
-
-		/*Write vertices: */
-		for (i=0;i<profnvertices[counter];i++){
-			fprintf(fid,"%lf\t%lf\n",pprofx[counter][i],pprofy[counter][i]);
-		}
-
-		/*Write blank line: */
-		if(counter < nprof-1) fprintf(fid,"\n");
-	}
-
-	/*close domain outline file: */
-	fclose(fid);
-
-	cleanupandreturn: 
-	return noerr;
-}
Index: /issm/trunk/src/c/shared/Exp/ExpWrite.cpp
===================================================================
--- /issm/trunk/src/c/shared/Exp/ExpWrite.cpp	(revision 14310)
+++ /issm/trunk/src/c/shared/Exp/ExpWrite.cpp	(revision 14310)
@@ -0,0 +1,77 @@
+/*!\file:  Exp.cpp
+ * \brief Exp.cpp: write the vertex coordinates defined in a domain 
+ * outline from Argus (.exp file). The first contour in the file is for 
+ * the outside domain outline. 
+ */
+#include <stdio.h>
+#include "../Alloc/alloc.h"
+#include "../../include/include.h"
+#include "../Exceptions/exceptions.h"
+#include "../../Container/DataSet.h"
+#include "../../classes/objects/Contour.h"
+
+int ExpWrite(int nprof,int* profnvertices,double** pprofx,double** pprofy,char* domainname){/*{{{*/
+
+	/*I/O: */
+	FILE* fid=NULL;
+
+	/*open domain outline file for writing: */
+	if((fid=fopen(domainname,"w"))==NULL) _error_("could not open domain file " << domainname); 
+
+	/*Start writing profiles: */
+	for(int counter=0;counter<nprof;counter++){
+
+		/*Write header: */
+		fprintf(fid,"## Name:%s\n",domainname);
+		fprintf(fid,"## Icon:0\n");
+		fprintf(fid,"# Points Count	Value\n");
+		fprintf(fid,"%u %s\n",profnvertices[counter]  ,"1.");
+		fprintf(fid,"# X pos	Y pos\n");
+
+		/*Write vertices: */
+		for(int i=0;i<profnvertices[counter];i++){
+			fprintf(fid,"%lf\t%lf\n",pprofx[counter][i],pprofy[counter][i]);
+		}
+
+		/*Write blank line: */
+		if(counter<nprof-1) fprintf(fid,"\n");
+	}
+
+	/*close Exp file: */
+	fclose(fid);
+
+	return 1;
+}/*}}}*/
+int ExpWrite(DataSet* contours,char* domainname){/*{{{*/
+
+	/*I/O: */
+	FILE* fid=NULL;
+	Contour<double>* contour = NULL;
+
+	/*open domain outline file for writing: */
+	if((fid=fopen(domainname,"w"))==NULL) _error_("could not open domain file " << domainname); 
+
+	for(int counter=0;counter<contours->Size();counter++){
+		contour=(Contour<double>*)contours->GetObjectByOffset(counter);
+
+		/*Write header: */
+		fprintf(fid,"## Name:%s\n",domainname);
+		fprintf(fid,"## Icon:0\n");
+		fprintf(fid,"# Points Count	Value\n");
+		fprintf(fid,"%u %s\n",contour->nods  ,"1.");
+		fprintf(fid,"# X pos	Y pos\n");
+
+		/*Write vertices: */
+		for(int i=0;i<contour->nods;i++){
+			fprintf(fid,"%lf\t%lf\n",contour->x[i],contour->y[i]);
+		}
+
+		/*Write blank line: */
+		if(counter<contours->Size()-1) fprintf(fid,"\n");
+	}
+
+	/*close Exp file: */
+	fclose(fid);
+
+	return 1;
+}/*}}}*/
Index: /issm/trunk/src/c/shared/Exp/exp.h
===================================================================
--- /issm/trunk/src/c/shared/Exp/exp.h	(revision 14309)
+++ /issm/trunk/src/c/shared/Exp/exp.h	(revision 14310)
@@ -12,5 +12,6 @@
 
 int IsInPolySerial(double* in,double* xc,double* yc,int numvertices,double* x,double* y,int nods, int edgevalue);
-int DomainOutlineWrite(int nprof,int* profnvertices,double** pprofx,double** pprofy,bool* closed,char* domainname);
+int ExpWrite(int nprof,int* profnvertices,double** pprofx,double** pprofy,char* domainname);
+int ExpWrite(DataSet* contours,char* domainname);
 int pnpoly(int npol, double *xp, double *yp, double x, double y, int edgevalue);
 
Index: /issm/trunk/src/c/shared/Matrix/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/shared/Matrix/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/shared/Matrix/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,8 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/shared/Matrix)
+# }}}
+# CORE_SOURCES {{{
+set(CORE_SOURCES $ENV{ISSM_DIR}/src/c/shared/Matrix/MatrixUtils.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/shared/MemOps/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/shared/MemOps/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/shared/MemOps/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,5 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/shared/MemOps)
+# }}}
Index: /issm/trunk/src/c/shared/Numerics/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/shared/Numerics/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/shared/Numerics/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,17 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/shared/Numerics)
+# }}}
+# CORE_SOURCES {{{
+set(CORE_SOURCES $ENV{ISSM_DIR}/src/c/shared/Numerics/cross.cpp
+                 $ENV{ISSM_DIR}/src/c/shared/Numerics/cubic.cpp
+               $ENV{ISSM_DIR}/src/c/shared/Numerics/extrema.cpp
+           $ENV{ISSM_DIR}/src/c/shared/Numerics/GaussPoints.cpp
+      $ENV{ISSM_DIR}/src/c/shared/Numerics/IsInputConverged.cpp
+                 $ENV{ISSM_DIR}/src/c/shared/Numerics/isnan.cpp
+   $ENV{ISSM_DIR}/src/c/shared/Numerics/OptionsFromAnalysis.cpp
+        $ENV{ISSM_DIR}/src/c/shared/Numerics/UnitConversion.cpp
+             $ENV{ISSM_DIR}/src/c/shared/Numerics/Verbosity.cpp
+$ENV{ISSM_DIR}/src/c/shared/Numerics/XZvectorsToCoordinateSystem.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/shared/Numerics/UnitConversion.cpp
===================================================================
--- /issm/trunk/src/c/shared/Numerics/UnitConversion.cpp	(revision 14309)
+++ /issm/trunk/src/c/shared/Numerics/UnitConversion.cpp	(revision 14310)
@@ -65,9 +65,5 @@
 		case SurfaceforcingsPrecipitationEnum:       scale=yts;break;     //m/yr
 		case SurfaceforcingsMassBalanceEnum:         scale=yts;break;     //m/yr
-		case SurfaceforcingsSmbPosMaxEnum:				scale=yts;break;     //m/yr
-		case SurfaceforcingsSmbPosMinEnum:				scale=yts;break;     //m/yr
-		case SurfaceforcingsAPosEnum:						scale=yts;break;     //m/yr
 		case SurfaceforcingsBPosEnum:						scale=yts;break;     //m/yr
-		case SurfaceforcingsANegEnum:						scale=yts;break;     //m/yr
 		case SurfaceforcingsBNegEnum:						scale=yts;break;     //m/yr
 		case SurfaceforcingsSmbrefEnum:					scale=yts;break;     //m/yr
Index: /issm/trunk/src/c/shared/Sorting/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/shared/Sorting/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/shared/Sorting/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,8 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/shared/Sorting)
+# }}}
+# CORE_SOURCES {{{
+set(CORE_SOURCES $ENV{ISSM_DIR}/src/c/shared/Sorting/binary_search.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/shared/String/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/shared/String/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/shared/String/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,8 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/shared/String)
+# }}}
+# CORE_SOURCES {{{
+set(CORE_SOURCES $ENV{ISSM_DIR}/src/c/shared/String/DescriptorIndex.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/shared/Threads/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/shared/Threads/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/shared/Threads/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,5 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/shared/Threads)
+# }}}
Index: /issm/trunk/src/c/shared/TriMesh/AssociateSegmentToElement.cpp
===================================================================
--- /issm/trunk/src/c/shared/TriMesh/AssociateSegmentToElement.cpp	(revision 14309)
+++ /issm/trunk/src/c/shared/TriMesh/AssociateSegmentToElement.cpp	(revision 14310)
@@ -5,27 +5,20 @@
 #include "./trimesh.h"
 
-int AssociateSegmentToElement(double** psegments,int nseg, double* index,int nel){
-
-	/*Error management: */
-	int i;
-	int noerr=1;
-
-	/*Input: */
-	double* segments=NULL;
+int AssociateSegmentToElement(int** psegments,int nseg,int* index,int nel){
 
 	/*node indices: */
-	double A,B;
+	int A,B;
 
 	/*Recover segments: */
-	segments=*psegments;
+	int* segments=*psegments;
 
-	for (i=0;i<nseg;i++){
-		A=*(segments+3*i+0);
-		B=*(segments+3*i+1);
-		*(segments+3*i+2)=FindElement(A,B,index,nel)+1; //matlab indexing.
+	for(int i=0;i<nseg;i++){
+		A=segments[3*i+0];
+		B=segments[3*i+1];
+		segments[3*i+2]=FindElement(A,B,index,nel)+1; //matlab indexing.
 	}
 
 	/*Assign output pointers: */
 	*psegments=segments;
-	return noerr;
+	return 1;
 }
Index: /issm/trunk/src/c/shared/TriMesh/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/shared/TriMesh/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/shared/TriMesh/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,5 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/shared/TriMesh)
+# }}}
Index: /issm/trunk/src/c/shared/TriMesh/OrderSegments.cpp
===================================================================
--- /issm/trunk/src/c/shared/TriMesh/OrderSegments.cpp	(revision 14309)
+++ /issm/trunk/src/c/shared/TriMesh/OrderSegments.cpp	(revision 14310)
@@ -5,25 +5,19 @@
 #include "./trimesh.h"
 
-int OrderSegments(double** psegments,int nseg, double* index,int nel){
-
-	/*Error management: */
-	int i;
-	int noerr=1;
-
-	/*Input: */
-	double* segments=NULL;
+int OrderSegments(int** psegments,int nseg,int* index,int nel){
 
 	/*vertex indices: */
-	double A,B;
-	/*element indices: */
+	int A,B;
+
+	/*element index*/
 	int el;
 
 	/*Recover segments: */
-	segments=*psegments;
+	int* segments=*psegments;
 
-	for (i=0;i<nseg;i++){
+	for(int i=0;i<nseg;i++){
 		A=segments[3*i+0];
 		B=segments[3*i+1];
-		el=(int)segments[3*i+2]-1; //after AssociateSegmentToElement, el was a matlab index, we need the c index now.
+		el=segments[3*i+2]-1; //after AssociateSegmentToElement, el was a matlab index, we need the c index now.
 
 		if (index[3*el+0]==A){
@@ -49,4 +43,4 @@
 	/*Assign output pointers: */
 	*psegments=segments;
-	return noerr;
+	return 1;
 }
Index: /issm/trunk/src/c/shared/TriMesh/SplitMeshForRifts.cpp
===================================================================
--- /issm/trunk/src/c/shared/TriMesh/SplitMeshForRifts.cpp	(revision 14309)
+++ /issm/trunk/src/c/shared/TriMesh/SplitMeshForRifts.cpp	(revision 14310)
@@ -6,5 +6,5 @@
 #include "../Alloc/alloc.h"
 
-int SplitMeshForRifts(int* pnel,double** pindex,int* pnods,double** px,double** py,int* pnsegs,double** psegments,double** psegmentmarkerlist){
+int SplitMeshForRifts(int* pnel,int** pindex,int* pnods,double** px,double** py,int* pnsegs,int** psegments,int** psegmentmarkerlist){
 
 	/*Some notes on dimensions: 
@@ -13,37 +13,22 @@
 	segments of size nsegsx3*/
 
-	/*Error management: */
-	int noerr=1;
-
 	int i,j,k,l;
 	int node;
 	int el;
-
 	int  nriftsegs;
 	int* riftsegments=NULL; 
 	int* flags=NULL;
-
 	int  NumGridElementListOnOneSideOfRift;
 	int* GridElementListOnOneSideOfRift=NULL;
 
-	/*Input: */
-	int     nel;
-	double* index=NULL;
-	int     nods;
-	double* x=NULL;
-	double* y=NULL;
-	double* segments=NULL;
-	double*    segmentmarkerlist=NULL;
-	int     nsegs;
-
 	/*Recover input: */
-	nel=*pnel;
-	index=*pindex;
-	nods=*pnods;
-	x=*px;
-	y=*py;
-	nsegs=*pnsegs;
-	segments=*psegments;
-	segmentmarkerlist=*psegmentmarkerlist;
+	int     nel               = *pnel;
+	int    *index             = *pindex;
+	int     nods              = *pnods;
+	double *x                 = *px;
+	double *y                 = *py;
+	int     nsegs             = *pnsegs;
+	int    *segments          = *psegments;
+	int    *segmentmarkerlist = *psegmentmarkerlist;
 
 	/*Establish list of segments that belong to a rift: */
@@ -90,5 +75,5 @@
 					el=GridElementListOnOneSideOfRift[k];
 					for (l=0;l<3;l++){
-						if (*(index+3*el+l)==node)*(index+3*el+l)=nods; //again, matlab indexing.
+						if (index[3*el+l]==node) index[3*el+l]=nods; //again, matlab indexing.
 					}
 				}
@@ -109,4 +94,4 @@
 	*psegments=segments;
 	*psegmentmarkerlist=segmentmarkerlist;
-	return noerr;
+	return 1;
 }
Index: /issm/trunk/src/c/shared/TriMesh/TriMeshUtils.cpp
===================================================================
--- /issm/trunk/src/c/shared/TriMesh/TriMeshUtils.cpp	(revision 14309)
+++ /issm/trunk/src/c/shared/TriMesh/TriMeshUtils.cpp	(revision 14310)
@@ -36,5 +36,5 @@
 }/*}}}*/
 /*FUNCTION GridElementsList{{{*/
-int GridElementsList(int** pGridElements, int* pNumGridElements,int node,double * index,int nel){
+int GridElementsList(int** pGridElements, int* pNumGridElements,int node,int* index,int nel){
 
 	/*From a node, recover all the elements that are connected to it: */
@@ -58,5 +58,5 @@
 	for (i=0;i<nel;i++){
 		for (j=0;j<3;j++){
-			if ((int)*(index+3*i+j)==node){
+			if (index[3*i+j]==node){
 				if (NumGridElements<=(current_size-1)){
 					GridElements[NumGridElements]=i;
@@ -90,5 +90,5 @@
 }/*}}}*/
 /*FUNCTION IsNeighbor{{{*/
-int IsNeighbor(int el1,int el2,double* index){
+int IsNeighbor(int el1,int el2,int* index){
 	/*From a triangulation held in index, figure out if elements 1 and 2 have two nodes in common: */
 	int i,j;
@@ -96,5 +96,5 @@
 	for (i=0;i<3;i++){
 		for (j=0;j<3;j++){
-			if (*(index+3*el1+i)==*(index+3*el2+j))count++;
+			if (index[3*el1+i]==index[3*el2+j])count++;
 		}
 	}
@@ -118,5 +118,5 @@
 }/*}}}*/
 /*FUNCTION RiftSegmentsFromSegments{{{*/
-void RiftSegmentsFromSegments(int* pnriftsegs, int** priftsegments, int nel, double* index, int nsegs,double* segments){
+void RiftSegmentsFromSegments(int* pnriftsegs, int** priftsegments, int nel,int* index,int nsegs,int* segments){
 
 	int i,counter;
@@ -126,5 +126,5 @@
 	int* riftsegments=NULL;
 	int* riftsegments_uncompressed=NULL; 
-	double element_nodes[3];
+	int  element_nodes[3];
 
 	/*Allocate segmentflags: */
@@ -143,23 +143,23 @@
 		element_nodes[2]=*(index+3*el+2);
 
-		*(index+3*el+0)=-1;
-		*(index+3*el+1)=-1;
-		*(index+3*el+2)=-1;
+		index[3*el+0]=-1;
+		index[3*el+1]=-1;
+		index[3*el+2]=-1;
 
 		el2=FindElement(*(segments+3*i+0),*(segments+3*i+1),index,nel); 
 
 		/*Restore index: */
-		*(index+3*el+0)=element_nodes[0];
-		*(index+3*el+1)=element_nodes[1];
-		*(index+3*el+2)=element_nodes[2];
+		index[3*el+0]=element_nodes[0];
+		index[3*el+1]=element_nodes[1];
+		index[3*el+2]=element_nodes[2];
 
 		if (el2!=-1){
 			/*el and el2 are on a segment rift, facing one another, plug them into riftsegments_uncompressed: */
-		    *(riftsegments_uncompressed+5*i+0)=1;
-		    *(riftsegments_uncompressed+5*i+1)=el;
-		    *(riftsegments_uncompressed+5*i+2)=el2;
-		    *(riftsegments_uncompressed+5*i+3)=(int)*(segments+3*i+0);
-		    *(riftsegments_uncompressed+5*i+4)=(int)*(segments+3*i+1);
-			nriftsegs++;
+		    riftsegments_uncompressed[5*i+0]=1;
+		    riftsegments_uncompressed[5*i+1]=el;
+		    riftsegments_uncompressed[5*i+2]=el2;
+		    riftsegments_uncompressed[5*i+3]=segments[3*i+0];
+			 riftsegments_uncompressed[5*i+4]=segments[3*i+1];
+			 nriftsegs++;
 		}
 	}
@@ -169,13 +169,12 @@
 	counter=0;
 	for (i=0;i<nsegs;i++){
-		if (*(riftsegments_uncompressed+5*i+0)){
-			*(riftsegments+counter*4+0)=*(riftsegments_uncompressed+5*i+1);
-			*(riftsegments+counter*4+1)=*(riftsegments_uncompressed+5*i+2);
-			*(riftsegments+counter*4+2)=*(riftsegments_uncompressed+5*i+3);
-			*(riftsegments+counter*4+3)=*(riftsegments_uncompressed+5*i+4);
+		if (riftsegments_uncompressed[5*i+0]){
+			riftsegments[counter*4+0]=riftsegments_uncompressed[5*i+1];
+			riftsegments[counter*4+1]=riftsegments_uncompressed[5*i+2];
+			riftsegments[counter*4+2]=riftsegments_uncompressed[5*i+3];
+			riftsegments[counter*4+3]=riftsegments_uncompressed[5*i+4];
 			counter++;
 		}
 	}
-
 	xDelete<int>(riftsegments_uncompressed);
 
@@ -185,5 +184,5 @@
 }/*}}}*/
 /*FUNCTION DetermineGridElementListOnOneSideOfRift{{{*/
-int DetermineGridElementListOnOneSideOfRift(int* pNumGridElementListOnOneSideOfRift, int** pGridElementListOnOneSideOfRift, int segmentnumber, int nriftsegs, int* riftsegments, int node,double* index,int nel){
+int DetermineGridElementListOnOneSideOfRift(int* pNumGridElementListOnOneSideOfRift, int** pGridElementListOnOneSideOfRift, int segmentnumber, int nriftsegs, int* riftsegments, int node,int* index,int nel){
 
 	int noerr=1;
@@ -249,5 +248,5 @@
 }/*}}}*/
 /*FUNCTION UpdateSegments{{{*/
-int UpdateSegments(double** psegments,double** psegmentmarkerlist, int* pnsegs, double* index, double* x,double* y,int* riftsegments,int nriftsegs,int nods,int nel){
+int UpdateSegments(int** psegments,int** psegmentmarkerlist, int* pnsegs,int* index, double* x,double* y,int* riftsegments,int nriftsegs,int nods,int nel){
 
 	int noerr=1;
@@ -255,7 +254,7 @@
 	int el1,el2;
 
-	double *segments          = NULL;
-	double *segmentmarkerlist = NULL;
-	int     nsegs;
+	int *segments          = NULL;
+	int *segmentmarkerlist = NULL;
+	int  nsegs;
 
 	/*Recover input: */
@@ -265,6 +264,6 @@
 
 	/*Reallocate segments: */
-	segments         =xReNew<double>(segments,         nsegs*3,(nsegs+nriftsegs)*3);
-	segmentmarkerlist=xReNew<double>(segmentmarkerlist,nsegs,(nsegs+nriftsegs));
+	segments         =xReNew<int>(segments,         nsegs*3,(nsegs+nriftsegs)*3);
+	segmentmarkerlist=xReNew<int>(segmentmarkerlist,nsegs,(nsegs+nriftsegs));
 
 	/*First, update the existing segments to the new nodes :*/
@@ -278,5 +277,5 @@
 				 *we can only rely on the position (x,y) of the rift nodes to create a segment:*/
 				for (k=0;k<3;k++){
-					if ((x[(int)*(index+el1*3+k)-1]==x[(int)*(segments+3*j+0)-1]) && (y[(int)*(index+el1*3+k)-1]==y[(int)*(segments+3*j+0)-1])){
+					if ((x[*(index+el1*3+k)-1]==x[*(segments+3*j+0)-1]) && (y[*(index+el1*3+k)-1]==y[*(segments+3*j+0)-1])){
 						*(segments+3*j+0)=*(index+el1*3+k); _assert_(segments[3*j+0]<nods+1);
 						break;
@@ -284,5 +283,5 @@
 				}
 				for (k=0;k<3;k++){
-					if ((x[(int)*(index+el1*3+k)-1]==x[(int)*(segments+3*j+1)-1])  && (y[(int)*(index+el1*3+k)-1]==y[(int)*(segments+3*j+1)-1])){
+					if ((x[*(index+el1*3+k)-1]==x[*(segments+3*j+1)-1])  && (y[*(index+el1*3+k)-1]==y[*(segments+3*j+1)-1])){
 						*(segments+3*j+1)=*(index+el1*3+k); _assert_(segments[3*j+1]<nods+1);
 						break;
@@ -293,5 +292,5 @@
 				*(segmentmarkerlist+(nsegs+i))=*(segmentmarkerlist+j);
 				for (k=0;k<3;k++){
-					if ((x[(int)*(index+el2*3+k)-1]==x[(int)*(segments+3*j+0)-1]) && (y[(int)*(index+el2*3+k)-1]==y[(int)*(segments+3*j+0)-1])){
+					if ((x[*(index+el2*3+k)-1]==x[*(segments+3*j+0)-1]) && (y[*(index+el2*3+k)-1]==y[*(segments+3*j+0)-1])){
 						*(segments+3*(nsegs+i)+0)=*(index+el2*3+k); _assert_(segments[3*(nsegs+i)+0]<nods+1);
 						break;
@@ -299,5 +298,5 @@
 				}
 				for (k=0;k<3;k++){
-					if ((x[(int)*(index+el2*3+k)-1]==x[(int)*(segments+3*j+1)-1]) && (y[(int)*(index+el2*3+k)-1]==y[(int)*(segments+3*j+1)-1])){
+					if ((x[*(index+el2*3+k)-1]==x[*(segments+3*j+1)-1]) && (y[*(index+el2*3+k)-1]==y[*(segments+3*j+1)-1])){
 						*(segments+3*(nsegs+i)+1)=*(index+el2*3+k); _assert_(segments[3*(nsegs+i)+1]<nods+1);
 						break;
@@ -309,5 +308,5 @@
 				/*Let's update segments[j][:] using  element el2 and the corresponding rift segment: */
 				for (k=0;k<3;k++){
-					if ((x[(int)*(index+el2*3+k)-1]==x[(int)*(segments+3*j+0)-1]) && (y[(int)*(index+el2*3+k)-1]==y[(int)*(segments+3*j+0)-1])){
+					if ((x[*(index+el2*3+k)-1]==x[*(segments+3*j+0)-1]) && (y[*(index+el2*3+k)-1]==y[*(segments+3*j+0)-1])){
 						*(segments+3*j+0)=*(index+el2*3+k); _assert_(segments[3*j+0]<nods+1);
 						break;
@@ -315,5 +314,5 @@
 				}
 				for (k=0;k<3;k++){
-					if ((x[(int)*(index+el2*3+k)-1]==x[(int)*(segments+3*j+1)-1]) && (y[(int)*(index+el2*3+k)-1]==y[(int)*(segments+3*j+1)-1])){
+					if ((x[*(index+el2*3+k)-1]==x[*(segments+3*j+1)-1]) && (y[*(index+el2*3+k)-1]==y[*(segments+3*j+1)-1])){
 						*(segments+3*j+1)=*(index+el2*3+k);_assert_(segments[3*j+1]<nods+1);
 						break;
@@ -324,5 +323,5 @@
 				*(segmentmarkerlist+(nsegs+i))=*(segmentmarkerlist+j);
 				for (k=0;k<3;k++){
-					if ((x[(int)*(index+el1*3+k)-1]==x[(int)*(segments+3*j+0)-1]) && (y[(int)*(index+el1*3+k)-1]==y[(int)*(segments+3*j+0)-1])){
+					if ((x[*(index+el1*3+k)-1]==x[*(segments+3*j+0)-1]) && (y[*(index+el1*3+k)-1]==y[*(segments+3*j+0)-1])){
 						*(segments+3*(nsegs+i)+0)=*(index+el1*3+k);_assert_(segments[3*(nsegs+i)+0]<nods+1);
 						break;
@@ -330,5 +329,5 @@
 				}
 				for (k=0;k<3;k++){
-					if ((x[(int)*(index+el1*3+k)-1]==x[(int)*(segments+3*j+1)-1]) && (y[(int)*(index+el1*3+k)-1]==y[(int)*(segments+3*j+1)-1])){
+					if ((x[*(index+el1*3+k)-1]==x[*(segments+3*j+1)-1]) && (y[*(index+el1*3+k)-1]==y[*(segments+3*j+1)-1])){
 						*(segments+3*(nsegs+i)+1)=*(index+el1*3+k);_assert_(segments[3*(nsegs+i)+1]<nods+1);
 						break;
@@ -348,10 +347,9 @@
 }/*}}}*/
 /*FUNCTION FindElement{{{*/
-int FindElement(double A,double B,double* index,int nel){
-
-	int n;
+int FindElement(int A,int B,int* index,int nel){
+
 	int el=-1;
-	for (n=0;n<nel;n++){
-		if (((*(index+3*n+0)==A)  || (*(index+3*n+1)==A) || (*(index+3*n+2)==A) ) && ((*(index+3*n+0)==B)  || (*(index+3*n+1)==B) || (*(index+3*n+2)==B))){
+	for (int n=0;n<nel;n++){
+		if(((index[3*n+0]==A) || (index[3*n+1]==A) || (index[3*n+2]==A)) && ((index[3*n+0]==B) || (index[3*n+1]==B) || (index[3*n+2]==B))){
 			el=n;
 			break;
@@ -361,5 +359,5 @@
 }/*}}}*/
 /*FUNCTION SplitRiftSegments{{{*/
-int SplitRiftSegments(double** psegments,double** psegmentmarkerlist, int* pnumsegs, int* pnumrifts,int** priftsnumsegs,double*** priftssegments,int numrifts,int nods,int nel){
+int SplitRiftSegments(int** psegments,int** psegmentmarkerlist, int* pnumsegs, int* pnumrifts,int** priftsnumsegs,int*** priftssegments,int numrifts,int nods,int nel){
 
 	/*Using segment markers, wring out the rift segments from the segments. Rift markers are 
@@ -370,22 +368,22 @@
 
 	/*input: */
-	double *segments          = NULL;
-	double *segmentmarkerlist = NULL;
+	int *segments          = NULL;
+	int *segmentmarkerlist = NULL;
 	int numsegs;
 
 	/*output: */
-	int      new_numsegs;
-	int     *riftsnumsegs       = NULL;
-	double **riftssegments      = NULL;
-	double  *new_segments       = NULL;
-	double  *new_segmentmarkers = NULL;
+	int   new_numsegs;
+	int  *riftsnumsegs       = NULL;
+	int **riftssegments      = NULL;
+	int  *new_segments       = NULL;
+	int  *new_segmentmarkers = NULL;
 
 	/*intermediary: */
-	double* riftsegment=NULL;
+	int* riftsegment=NULL;
 
 	/*Recover input arguments: */
-	segments=*psegments;
-	numsegs=*pnumsegs;
-	segmentmarkerlist=*psegmentmarkerlist;
+	segments          = *psegments;
+	numsegs           = *pnumsegs;
+	segmentmarkerlist = *psegmentmarkerlist;
 
 	/*First, figure out  how many segments will be left in 'segments': */
@@ -396,6 +394,6 @@
 	/*Allocate new segments: */
 	new_numsegs=counter;
-	new_segments=xNew<double>(new_numsegs*3);
-	new_segmentmarkers=xNew<double>(new_numsegs);
+	new_segments=xNew<int>(new_numsegs*3);
+	new_segmentmarkers=xNew<int>(new_numsegs);
 
 	/*Copy new segments info : */
@@ -413,5 +411,5 @@
 	/*Now deal with rift segments: */
 	riftsnumsegs=xNew<int>(numrifts);
-	riftssegments=xNew<double*>(numrifts);
+	riftssegments=xNew<int*>(numrifts);
 	for (i=0;i<numrifts;i++){
 		/*Figure out how many segments for rift i: */
@@ -421,5 +419,5 @@
 		}
 		riftsnumsegs[i]=counter;
-		riftsegment=xNew<double>(counter*3);
+		riftsegment=xNew<int>(counter*3);
 		/*Copy new segments info :*/
 		counter=0;
@@ -436,5 +434,5 @@
 
 	/*Free ressources: */
-	xDelete<double>(segments);
+	xDelete<int>(segments);
 
 	/*Assign output pointers: */
@@ -448,5 +446,5 @@
 }/*}}}*/
 /*FUNCTION PairRiftElements{{{*/
-int PairRiftElements(int** priftsnumpairs, double*** priftspairs,int numrifts,int* riftsnumsegments, double** riftssegments,double* x,double* y){
+int PairRiftElements(int** priftsnumpairs,int*** priftspairs,int numrifts,int* riftsnumsegments,int** riftssegments,double* x,double* y){
 
 	int noerr=1;
@@ -454,32 +452,32 @@
 
 	/*output: */
-	int     *riftsnumpairs = NULL;
-	double **riftspairs    = NULL;
+	int  *riftsnumpairs = NULL;
+	int **riftspairs    = NULL;
 
 	/*intermediary :*/
-	int     numsegs;
-	double* segments=NULL;
-	double* pairs=NULL;
-	int     node1,node2,node3,node4;
+	int  numsegs;
+	int* segments=NULL;
+	int* pairs=NULL;
+	int  node1,node2,node3,node4;
 
 	riftsnumpairs=xNew<int>(numrifts);
-	riftspairs=xNew<double*>(numrifts);
+	riftspairs=xNew<int*>(numrifts);
 	for (i=0;i<numrifts;i++){
 		segments=riftssegments[i];
-		numsegs=riftsnumsegments[i];
+		numsegs =riftsnumsegments[i];
 		riftsnumpairs[i]=numsegs;
-		pairs=xNew<double>(2*numsegs);
+		pairs=xNew<int>(2*numsegs);
 		for (j=0;j<numsegs;j++){
-			*(pairs+2*j+0)=*(segments+3*j+2); //retrieve element to which this segment belongs.
-			node1=(int)*(segments+3*j+0)-1; node2=(int)*(segments+3*j+1)-1;
+			pairs[2*j+0]=segments[3*j+2]; //retrieve element to which this segment belongs.
+			node1=segments[3*j+0]-1; node2=segments[3*j+1]-1;
 			/*Find element facing on other side of rift: */
 			for (k=0;k<numsegs;k++){
 				if (k==j)continue;
-				node3=(int)*(segments+3*k+0)-1; node4=(int)*(segments+3*k+1)-1;
+				node3=segments[3*k+0]-1; node4=segments[3*k+1]-1;
 				/*We are trying to find 2 elements, where position of node3 == position of node1, and position of node4 == position of node2*/
 				if (   (x[node3]==x[node1]) && (y[node3]==y[node1]) && (x[node4]==x[node2]) && (y[node4]==y[node2])
 				    || (x[node3]==x[node2]) && (y[node3]==y[node2]) && (x[node4]==x[node1]) && (y[node4]==y[node1])  ){
 					/*We found the corresponding element: */
-					*(pairs+2*j+1)=*(segments+3*k+2);
+					pairs[2*j+1]=segments[3*k+2];
 					break;
 				}
@@ -495,22 +493,14 @@
 }/*}}}*/
 /*FUNCTION RemoveRifts{{{*/
-int RemoveRifts(double** pindex,double** px,double** py,int* pnods,double** psegments,int* pnumsegs,int numrifts1,int* rifts1numsegs,double** rifts1segments,double** rifts1pairs,int nel){
+int RemoveRifts(int** pindex,double** px,double** py,int* pnods,int** psegments,int* pnumsegs,int numrifts1,int* rifts1numsegs,int** rifts1segments,int** rifts1pairs,int nel){
 
 	int noerr=1;
 	int i,j,k,counter,counter1,counter2;
 
-	/*input: */
-	double* index=NULL;
-	double* x=NULL;
-	double* y=NULL;
-	int     nods;
-	double* segments=NULL;
-	int     numsegs;
-
 	/*intermediary: */
-	double *riftsegments = NULL;
-	double *riftpairs    = NULL;
+	int    *riftsegments = NULL;
+	int    *riftpairs    = NULL;
 	int     node1,node2,node3,node4,temp_node;
-	double  el2;
+	int     el2;
 	int     newnods; //temporary # node counter.
 	double  xmin,ymin;
@@ -523,10 +513,10 @@
 
 	/*Recover input: */
-	index=*pindex;
-	x=*px;
-	y=*py;
-	nods=*pnods;;
-	segments=*psegments;
-	numsegs=*pnumsegs;
+	int    *index    = *pindex;
+	double *x        = *px;
+	double *y        = *py;
+	int     nods     = *pnods;     ;
+	int    *segments = *psegments;
+	int     numsegs  = *pnumsegs;
 
 	/*initialize newnods : */
@@ -558,5 +548,5 @@
 		riftpairs=rifts1pairs[i];
 		for (j=0;j<rifts1numsegs[i];j++){
-			el2=*(riftpairs+2*j+1);
+			el2=riftpairs[2*j+1];
 			node1=(int)*(riftsegments+3*j+0);
 			node2=(int)*(riftsegments+3*j+1);
@@ -565,6 +555,6 @@
 			for (k=0;k<rifts1numsegs[i];k++){
 				if (*(riftsegments+3*k+2)==el2){
-					node3=(int)*(riftsegments+3*k+0);
-					node4=(int)*(riftsegments+3*k+1);
+					node3=*(riftsegments+3*k+0);
+					node4=*(riftsegments+3*k+1);
 					break;
 				}
@@ -677,5 +667,5 @@
 }/*}}}*/
 /*FUNCTION IsRiftPresent{{{*/
-int IsRiftPresent(int* priftflag,int* pnumrifts, double* segmentmarkerlist,int nsegs){
+int IsRiftPresent(int* priftflag,int* pnumrifts,int* segmentmarkerlist,int nsegs){
 
 	int i;
@@ -686,5 +676,5 @@
 	int numrifts=0;
 
-	double maxmark=1; //default marker for regular segments
+	int maxmark=1; //default marker for regular segments
 
 	/*Any marker >=2 indicates a certain rift: */
@@ -696,5 +686,5 @@
 		}
 	}
-	if (numrifts)riftflag=1;
+	if(numrifts)riftflag=1;
 
 	/*Assign output pointers:*/
@@ -704,5 +694,5 @@
 }/*}}}*/
 /*FUNCTION OrderRifts{{{*/
-int OrderRifts(double** priftstips, double** riftssegments,double** riftspairs,int numrifts,int* riftsnumsegments,double* x,double* y,int nods,int nels){
+int OrderRifts(int** priftstips,int** riftssegments,int** riftspairs,int numrifts,int* riftsnumsegments,double* x,double* y,int nods,int nels){
 
 	int noerr=1;
@@ -710,34 +700,34 @@
 
 	/*intermediary: */
-	double *riftsegments = NULL;
-	double *riftpairs    = NULL;
+	int *riftsegments = NULL;
+	int *riftpairs    = NULL;
 	int numsegs;
 
 	/*ordering and copy: */
-	int    *order             = NULL;
-	double *riftsegments_copy = NULL;
-	double *riftpairs_copy    = NULL;
+	int *order             = NULL;
+	int *riftsegments_copy = NULL;
+	int *riftpairs_copy    = NULL;
 
 	/*node and element manipulation: */
-	int     node1,node2,node3,node4,temp_node,tip1,tip2,node;
-	double  el2;
-	int     already_ordered=0;
+	int node1,node2,node3,node4,temp_node,tip1,tip2,node;
+	int el2;
+	int already_ordered=0;
 
 	/*output: */
-	double* riftstips=NULL;
+	int* riftstips=NULL;
 
 	/*Allocate byproduct of this routine, riftstips: */
-	riftstips=xNew<double>(numrifts*2);
+	riftstips=xNew<int>(numrifts*2);
 
 	/*Go through all rifts: */
 	for (i=0;i<numrifts;i++){
-		riftsegments=riftssegments[i];
-		riftpairs=riftspairs[i];
-		numsegs=riftsnumsegments[i];
+		riftsegments = riftssegments[i];
+		riftpairs    = riftspairs[i];
+		numsegs      = riftsnumsegments[i];
 
 		/*Allocate copy of riftsegments and riftpairs, 
 		 *as well as ordering vector: */
-		riftsegments_copy=xNew<double>(numsegs*3);
-		riftpairs_copy=xNew<double>(numsegs*2);
+		riftsegments_copy=xNew<int>(numsegs*3);
+		riftpairs_copy=xNew<int>(numsegs*2);
 		order=xNew<int>(numsegs);
 
@@ -748,12 +738,12 @@
 		for (j=0;j<numsegs;j++){
 			el2=*(riftpairs+2*j+1);
-			node1=(int)*(riftsegments+3*j+0);
-			node2=(int)*(riftsegments+3*j+1);
+			node1=*(riftsegments+3*j+0);
+			node2=*(riftsegments+3*j+1);
 			/*Summary, el1 and el2 are facing one another across the rift. node1 and node2 belong to el1 and 
 			 *are located on the rift. Find node3 and node4, nodes belonging to el2 and located on the rift: */
 			for (k=0;k<numsegs;k++){
 				if (*(riftsegments+3*k+2)==el2){
-					node3=(int)*(riftsegments+3*k+0);
-					node4=(int)*(riftsegments+3*k+1);
+					node3=*(riftsegments+3*k+0);
+					node4=*(riftsegments+3*k+1);
 					break;
 				}
@@ -796,6 +786,6 @@
 
 		/*Record tips in riftstips: */
-		*(riftstips+2*i+0)=(double)tip1;
-		*(riftstips+2*i+1)=(double)tip2;
+		*(riftstips+2*i+0)=tip1;
+		*(riftstips+2*i+1)=tip2;
 
 		/*We have the two tips for this rift.  Go from tip1 to tip2, and figure out the order in which segments are sequential. 
@@ -804,6 +794,6 @@
 		for (counter=0;counter<numsegs;counter++){
 			for (j=0;j<numsegs;j++){
-				node1=(int)*(riftsegments+3*j+0);
-				node2=(int)*(riftsegments+3*j+1);
+				node1=*(riftsegments+3*j+0);
+				node2=*(riftsegments+3*j+1);
 
 				if ((node1==node) || (node2==node)){
@@ -849,6 +839,6 @@
 
 		xDelete<int>(order);
-		xDelete<double>(riftsegments_copy);
-		xDelete<double>(riftpairs_copy);
+		xDelete<int>(riftsegments_copy);
+		xDelete<int>(riftpairs_copy);
 
 	}
@@ -859,6 +849,6 @@
 }/*}}}*/
 /*FUNCTION PenaltyPairs{{{*/
-int PenaltyPairs(double*** priftspenaltypairs,int** priftsnumpenaltypairs,int numrifts,double** riftssegments,
-		int* riftsnumsegs,double** riftspairs,double* riftstips,double* x,double* y){
+int PenaltyPairs(double*** priftspenaltypairs,int** priftsnumpenaltypairs,int numrifts,int** riftssegments,
+		int* riftsnumsegs,int** riftspairs,int* riftstips,double* x,double* y){
 
 	int noerr=1;
@@ -875,6 +865,6 @@
 	/*intermediary: */
 	int numsegs;
-	double* riftsegments=NULL;
-	double* riftpairs=NULL;
+	int* riftsegments=NULL;
+	int* riftpairs=NULL;
 	int counter;
 	double normal[2];
@@ -980,5 +970,5 @@
 		/*Renormalize normals: */
 		for(j=0;j<counter;j++){
-			double magnitude=sqrt(pow( *(riftpenaltypairs+j*7+4),2) + pow( *(riftpenaltypairs+j*7+5),2) );
+			double magnitude=sqrt(pow( double(riftpenaltypairs[j*7+4]),2) + pow( double(riftpenaltypairs[j*7+5]),2) );
 			*(riftpenaltypairs+j*7+4)=*(riftpenaltypairs+j*7+4)/magnitude;
 			*(riftpenaltypairs+j*7+5)=*(riftpenaltypairs+j*7+5)/magnitude;
@@ -993,23 +983,11 @@
 	*priftsnumpenaltypairs=riftsnumpenaltypairs;
 	return noerr;
-}
-
-/******************************************************************************************************************************
-                                   RemoveCorners
-******************************************************************************************************************************/
-
-int RemoveCornersFromRifts(double** pindex,int* pnel,double** px,double** py,int* pnods, double* segments,double* segmentmarkers,int num_seg){
+}/*}}}*/
+int RemoveCornersFromRifts(int** pindex,int* pnel,double** px,double** py,int* pnods,int* segments,int* segmentmarkers,int num_seg){/*{{{*/
 
 	int noerr=1;
 	int i,j,k;
-	double node1,node2,node3;
+	int node1,node2,node3;
 	int el;
-
-	/*input: */
-	double* index=NULL;
-	int     nel;
-	double* x=NULL;
-	double* y=NULL;
-	int     nods;
 	double  pair[2];
 	int     pair_count=0;
@@ -1017,9 +995,9 @@
 
 	/*Recover input: */
-	index=*pindex;
-	nel=*pnel;
-	x=*px;
-	y=*py;
-	nods=*pnods;
+	int    *index = *pindex;
+	int     nel   = *pnel;
+	double *x     = *px;
+	double *y     = *py;
+	int     nods  = *pnods;
 
 	for (i=0;i<num_seg;i++){
@@ -1083,5 +1061,5 @@
 					x[nods]=(x[(int)node1-1]+x[(int)node2-1]+x[(int)node3-1])/3;
 					y[nods]=(y[(int)node1-1]+y[(int)node2-1]+y[(int)node3-1])/3;
-					index=xReNew<double>(index,nel*3,(nel+2*3));
+					index=xReNew<int>(index,nel*3,(nel+2*3));
 					/*First, reassign element el: */
 					*(index+3*el+0)=node1;
@@ -1098,8 +1076,8 @@
 					/*we need  to change the segment elements corresponding to el: */
 					for (k=0;k<num_seg;k++){
-						if (*(segments+3*k+2)==(double)(el+1)){
-							if ( ((*(segments+3*k+0)==node1) && (*(segments+3*k+1)==node2)) || ((*(segments+3*k+0)==node2) && (*(segments+3*k+1)==node1))) *(segments+3*k+2)=(double)(el+1);
-							if ( ((*(segments+3*k+0)==node2) && (*(segments+3*k+1)==node3)) || ((*(segments+3*k+0)==node3) && (*(segments+3*k+1)==node2))) *(segments+3*k+2)=(double)(nel+1);
-							if ( ((*(segments+3*k+0)==node3) && (*(segments+3*k+1)==node1)) || ((*(segments+3*k+0)==node1) && (*(segments+3*k+1)==node3))) *(segments+3*k+2)=(double)(nel+2);
+						if (*(segments+3*k+2)==(el+1)){
+							if ( ((*(segments+3*k+0)==node1) && (*(segments+3*k+1)==node2)) || ((*(segments+3*k+0)==node2) && (*(segments+3*k+1)==node1))) *(segments+3*k+2)=el+1;
+							if ( ((*(segments+3*k+0)==node2) && (*(segments+3*k+1)==node3)) || ((*(segments+3*k+0)==node3) && (*(segments+3*k+1)==node2))) *(segments+3*k+2)=nel+1;
+							if ( ((*(segments+3*k+0)==node3) && (*(segments+3*k+1)==node1)) || ((*(segments+3*k+0)==node1) && (*(segments+3*k+1)==node3))) *(segments+3*k+2)=nel+2;
 						}
 					}
@@ -1121,3 +1099,3 @@
 	*pnods=nods;
 	return noerr;
-}
+}/*}}}*/
Index: /issm/trunk/src/c/shared/TriMesh/trimesh.h
===================================================================
--- /issm/trunk/src/c/shared/TriMesh/trimesh.h	(revision 14309)
+++ /issm/trunk/src/c/shared/TriMesh/trimesh.h	(revision 14310)
@@ -10,25 +10,25 @@
 
 //#define REAL double //took  it out because it may conflict with stdlib.h defines. put back if necessary
-int AssociateSegmentToElement(double** psegments,int nseg, double* index,int nel);
-int OrderSegments(double** psegments,int nseg, double* index,int nel);
+int AssociateSegmentToElement(int** psegments,int nseg,int* index,int nel);
+int OrderSegments(int** psegments,int nseg, int* index,int nel);
 int GridInsideHole(double* px0,double* py0,int n,double* x,double* y);
-int FindElement(double A,double B,double* index,int nel);
-int SplitMeshForRifts(int* pnel,double** pindex,int* pnods,double** px,double** py,int* pnsegs,double** psegments,double** psegmentmarkerlist);
+int FindElement(int A,int B,int* index,int nel);
+int SplitMeshForRifts(int* pnel,int** pindex,int* pnods,double** px,double** py,int* pnsegs,int** psegments,int** psegmentmarkerlist);
 int IsGridOnRift(int* riftsegments, int nriftsegs, int node);
 int GridElementsList(int** pGridElements, int* pNumGridElements,int node,double * index,int nel);
-int IsNeighbor(int el1,int el2,double* index);
+int IsNeighbor(int el1,int el2,int* index);
 int IsOnRift(int el,int nriftsegs,int* riftsegments);
-void RiftSegmentsFromSegments(int* pnriftsegs, int** priftsegments, int nel, double* index, int nsegs,double* segments);
-int DetermineGridElementListOnOneSideOfRift(int* pNumGridElementListOnOneSideOfRift, int** pGridElementListOnOneSideOfRift, int segmentnumber, int nriftsegs, int* riftsegments, int node,double* index,int nel);
-int UpdateSegments(double** psegments,double** psegmentmarkerlist, int* pnsegs, double* index, double* x,double* y,int* riftsegments,int nriftsegs,int nods,int nel);
-int FindElement(double A,double B,double* index,int nel);
-int RemoveRifts(double** pindex,double** px,double** py,int* pnods,double** psegments,int* pnumsegs,int numrifts1,int* rifts1numsegs,double** rifts1segments,double** rifts1pairs,int nel);
-int IsRiftPresent(int* priftflag,int* pnumrifts, double* segmentmarkerlist,int nsegs);
-int SplitRiftSegments(double** psegments,double** psegmentmarkerlist, int* pnumsegs, int* pnumrifts,int** priftsnumsegs,double*** priftssegments,int numrifts,int nods,int nels);
-int OrderRifts(double** priftstips, double** riftssegments,double** riftspairs,int numrifts,int* riftsnumsegments,double* x,double* y,int nods,int nels);
-int PenaltyPairs(double*** priftspenaltypairs,int** priftsnumpenaltypairs,int numrifts,double**  riftssegments,
-		int* riftsnumsegments,double** riftspairs,double* riftstips,double* x,double* y);
-int RemoveCornersFromRifts(double** pindex,int* pnel,double** px,double** py,int* pnods, double* segments,double* segmentmarkers,int num_seg);
-int PairRiftElements(int** priftsnumpairs, double*** priftspairs,int numrifts,int* riftsnumsegments, double** riftssegments,double* x,double* y);
+void RiftSegmentsFromSegments(int* pnriftsegs, int** priftsegments, int nel,int* index, int nsegs,int* segments);
+int DetermineGridElementListOnOneSideOfRift(int* pNumGridElementListOnOneSideOfRift, int** pGridElementListOnOneSideOfRift,int segmentnumber, int nriftsegs,int* riftsegments, int node,int* index,int nel);
+int UpdateSegments(int** psegments,int** psegmentmarkerlist, int* pnsegs,int* index, double* x,double* y,int* riftsegments,int nriftsegs,int nods,int nel);
+int FindElement(double A,double B,int* index,int nel);
+int RemoveRifts(int** pindex,double** px,double** py,int* pnods,int** psegments,int* pnumsegs,int numrifts1,int* rifts1numsegs,int** rifts1segments,double** rifts1pairs,int nel);
+int IsRiftPresent(int* priftflag,int* pnumrifts,int* segmentmarkerlist,int nsegs);
+int SplitRiftSegments(int** psegments,int** psegmentmarkerlist, int* pnumsegs, int* pnumrifts,int** priftsnumsegs,int*** priftssegments,int numrifts,int nods,int nels);
+int OrderRifts(int** priftstips,int** riftssegments,int** riftspairs,int numrifts,int* riftsnumsegments,double* x,double* y,int nods,int nels);
+int PenaltyPairs(double*** priftspenaltypairs,int** priftsnumpenaltypairs,int numrifts,int**  riftssegments,
+		int* riftsnumsegments,int** riftspairs,int* riftstips,double* x,double* y);
+int RemoveCornersFromRifts(int** pindex,int* pnel,double** px,double** py,int* pnods,int* segments,int* segmentmarkers,int num_seg);
+int PairRiftElements(int** priftsnumpairs,int*** priftspairs,int numrifts,int* riftsnumsegments,int** riftssegments,double* x,double* y);
 
 #endif  /* _SHARED_TRIMESH_H */
Index: /issm/trunk/src/c/solutions/AdjointCorePointerFromSolutionEnum.cpp
===================================================================
--- /issm/trunk/src/c/solutions/AdjointCorePointerFromSolutionEnum.cpp	(revision 14309)
+++ /issm/trunk/src/c/solutions/AdjointCorePointerFromSolutionEnum.cpp	(revision 14310)
@@ -34,4 +34,7 @@
 			adjointcore=&adjointbalancethickness_core;
 			break;
+		case WeakBalancethicknessSolutionEnum:
+			adjointcore=&dummy_core;
+			break;
 		default:
 			_error_("No adjoint has been implemented for solution " << EnumToStringx(solutiontype) << " yet");
Index: /issm/trunk/src/c/solutions/AnalysisConfiguration.cpp
===================================================================
--- /issm/trunk/src/c/solutions/AnalysisConfiguration.cpp	(revision 14309)
+++ /issm/trunk/src/c/solutions/AnalysisConfiguration.cpp	(revision 14310)
@@ -83,4 +83,10 @@
 			break;
 
+		case WeakBalancethicknessSolutionEnum:
+			numanalyses=1;
+			analyses=xNew<int>(numanalyses);
+			analyses[0]=BalancethicknessAnalysisEnum;
+			break;
+
 		case SurfaceSlopeSolutionEnum:
 			numanalyses=1;
Index: /issm/trunk/src/c/solutions/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/solutions/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/solutions/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,61 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/solutions)
+# }}}
+# CORE_SOURCES {{{
+set(CORE_SOURCES $ENV{ISSM_DIR}/src/c/solutions/ad_core.cpp
+   $ENV{ISSM_DIR}/src/c/solutions/AnalysisConfiguration.cpp
+             $ENV{ISSM_DIR}/src/c/solutions/convergence.cpp
+$ENV{ISSM_DIR}/src/c/solutions/CorePointerFromSolutionEnum.cpp
+     $ENV{ISSM_DIR}/src/c/solutions/EnvironmentFinalize.cpp
+         $ENV{ISSM_DIR}/src/c/solutions/EnvironmentInit.cpp
+        $ENV{ISSM_DIR}/src/c/solutions/ProcessArguments.cpp
+ $ENV{ISSM_DIR}/src/c/solutions/ResetBoundaryConditions.cpp
+$ENV{ISSM_DIR}/src/c/solutions/WrapperCorePointerFromSolutionEnum.cpp PARENT_SCOPE)
+# }}}
+# DAKOTA_SOURCES {{{
+set(DAKOTA_SOURCES $ENV{ISSM_DIR}/src/c/solutions/dakota_core.cpp
+               $ENV{ISSM_DIR}/src/c/solutions/DakotaSpawnCore.cpp PARENT_SCOPE)
+# }}}
+# TRANSIENT_SOURCES {{{
+set(TRANSIENT_SOURCES $ENV{ISSM_DIR}/src/c/solutions/transient_core.cpp PARENT_SCOPE)
+# }}}
+# STEADYSTATE_SOURCES {{{
+set(STEADYSTATE_SOURCES $ENV{ISSM_DIR}/src/c/solutions/steadystate_core.cpp
+                  $ENV{ISSM_DIR}/src/c/solutions/steadystateconvergence.cpp PARENT_SCOPE)
+# }}}
+# PROGNOSTIC_SOURCES {{{
+set(PROGNOSTIC_SOURCES $ENV{ISSM_DIR}/src/c/solutions/prognostic_core.cpp PARENT_SCOPE)
+# }}}
+# THERMAL_SOURCES {{{
+set(THERMAL_SOURCES $ENV{ISSM_DIR}/src/c/solutions/enthalpy_core.cpp
+                     $ENV{ISSM_DIR}/src/c/solutions/thermal_core.cpp PARENT_SCOPE)
+# }}}
+# HYDROLOGY_SOURCES {{{
+set(HYDROLOGY_SOURCES $ENV{ISSM_DIR}/src/c/solutions/hydrology_core.cpp
+                 $ENV{ISSM_DIR}/src/c/solutions/hydrology_core_step.cpp PARENT_SCOPE)
+# }}}
+# DIAGNOSTIC_SOURCES {{{
+set(DIAGNOSTIC_SOURCES $ENV{ISSM_DIR}/src/c/solutions/diagnostic_core.cpp PARENT_SCOPE)
+# }}}
+# BALANCED_SOURCES {{{
+set(BALANCED_SOURCES $ENV{ISSM_DIR}/src/c/solutions/balancethickness_core.cpp
+                                $ENV{ISSM_DIR}/src/c/solutions/dummy_core.cpp PARENT_SCOPE)
+# }}}
+# SLOPE_SOURCES {{{
+set(SLOPE_SOURCES $ENV{ISSM_DIR}/src/c/solutions/bedslope_core.cpp
+              $ENV{ISSM_DIR}/src/c/solutions/surfaceslope_core.cpp PARENT_SCOPE)
+# }}}
+# LIBISSM_LA_SOURCES {{{
+set(LIBISSM_LA_SOURCES $ENV{ISSM_DIR}/src/c/solutions/issm.cpp PARENT_SCOPE)
+# }}}
+# ISSM_SOURCES {{{
+set(ISSM_SOURCES $ENV{ISSM_DIR}/src/c/solutions/issm.cpp PARENT_SCOPE)
+# }}}
+# KRIGING_SOURCES {{{
+set(KRIGING_SOURCES $ENV{ISSM_DIR}/src/c/solutions/kriging.cpp PARENT_SCOPE)
+# }}}
+# ISSMROSE_EXE_SOURCES {{{
+set(ISSMROSE_EXE_SOURCES $ENV{ISSM_DIR}/src/c/solutions/issm.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/solutions/CorePointerFromSolutionEnum.cpp
===================================================================
--- /issm/trunk/src/c/solutions/CorePointerFromSolutionEnum.cpp	(revision 14309)
+++ /issm/trunk/src/c/solutions/CorePointerFromSolutionEnum.cpp	(revision 14310)
@@ -60,4 +60,11 @@
 			#endif
 			break;
+		case WeakBalancethicknessSolutionEnum:
+			#ifdef _HAVE_BALANCED_
+			solutioncore=&dummy_core;
+			#else
+			_error_("ISSM was not compiled with balanced capabilities. Exiting");
+			#endif
+			break;
 		case HydrologySolutionEnum:
 			#ifdef _HAVE_HYDROLOGY_
Index: /issm/trunk/src/c/solutions/EnvironmentInit.cpp
===================================================================
--- /issm/trunk/src/c/solutions/EnvironmentInit.cpp	(revision 14309)
+++ /issm/trunk/src/c/solutions/EnvironmentInit.cpp	(revision 14310)
@@ -31,5 +31,5 @@
 	if(!my_rank) printf("\n");
 	if(!my_rank) printf("Ice Sheet System Model (%s) version  %s\n",PACKAGE_NAME,PACKAGE_VERSION);
-	if(!my_rank) printf("(website: %s contact: %s\n",PACKAGE_URL,PACKAGE_BUGREPORT);
+	if(!my_rank) printf("(website: %s contact: %s)\n",PACKAGE_URL,PACKAGE_BUGREPORT);
 	if(!my_rank) printf("\n");
 
Index: /issm/trunk/src/c/solutions/controltao_core.cpp
===================================================================
--- /issm/trunk/src/c/solutions/controltao_core.cpp	(revision 14309)
+++ /issm/trunk/src/c/solutions/controltao_core.cpp	(revision 14310)
@@ -49,7 +49,6 @@
 	femmodel->parameters->FindParam(&control_list,NULL,InversionControlParametersEnum);
 	femmodel->parameters->FindParam(&nsteps,InversionNstepsEnum);
-	femmodel->parameters->FindParam(&dummy,NULL,NULL,InversionMaxiterPerStepEnum);
 	femmodel->parameters->SetParam(false,SaveResultsEnum);
-	maxiter=nsteps*(int)dummy[0]; xDelete<IssmDouble>(dummy);
+	maxiter=nsteps*10;
 
 	/*Initialize TAO*/
Index: /issm/trunk/src/c/solutions/convergence.cpp
===================================================================
--- /issm/trunk/src/c/solutions/convergence.cpp	(revision 14309)
+++ /issm/trunk/src/c/solutions/convergence.cpp	(revision 14310)
@@ -65,4 +65,5 @@
 
 	//compute K[n]U[n-1]F = K[n]U[n-1] - F
+	_assert_(uf); _assert_(Kff);
 	KUold=uf->Duplicate(); Kff->MatMult(old_uf,KUold);
 	KUoldF=KUold->Duplicate();KUold->Copy(KUoldF); KUoldF->AYPX(pf,-1.0);
Index: /issm/trunk/src/c/solutions/dummy_core.cpp
===================================================================
--- /issm/trunk/src/c/solutions/dummy_core.cpp	(revision 14310)
+++ /issm/trunk/src/c/solutions/dummy_core.cpp	(revision 14310)
@@ -0,0 +1,19 @@
+/*!\file: dummy_core.cpp
+ * \brief: dummy core (nothing done)
+ */ 
+
+#include "../toolkits/toolkits.h"
+#include "../classes/objects/objects.h"
+#include "../shared/shared.h"
+#include "../io/io.h"
+#include "../include/include.h"
+#include "../EnumDefinitions/EnumDefinitions.h"
+#include "./solutions.h"
+#include "../modules/modules.h"
+#include "../solvers/solvers.h"
+
+void dummy_core(FemModel* femmodel){
+
+	/*We do not do anything*/
+
+}
Index: /issm/trunk/src/c/solutions/objectivefunction.cpp
===================================================================
--- /issm/trunk/src/c/solutions/objectivefunction.cpp	(revision 14309)
+++ /issm/trunk/src/c/solutions/objectivefunction.cpp	(revision 14310)
@@ -46,4 +46,7 @@
 		femmodel->SetCurrentConfiguration(BalancethicknessAnalysisEnum);
 	}
+	else if (solution_type==WeakBalancethicknessSolutionEnum){
+		femmodel->SetCurrentConfiguration(BalancethicknessAnalysisEnum);
+	}
 	else{
 		_error_("Solution " << EnumToStringx(solution_type) << " not implemented yet");
@@ -63,4 +66,7 @@
 		solver_linear(femmodel); 
 	}
+	else if (solution_type==WeakBalancethicknessSolutionEnum){
+		/*Don't do anything*/
+	}
 	else{
 		_error_("Solution " << EnumToStringx(solution_type) << " not implemented yet");
Index: /issm/trunk/src/c/solutions/solutions.h
===================================================================
--- /issm/trunk/src/c/solutions/solutions.h	(revision 14309)
+++ /issm/trunk/src/c/solutions/solutions.h	(revision 14310)
@@ -33,4 +33,5 @@
 void dakota_core(FemModel* femmodel);
 void ad_core(FemModel* femmodel);
+void dummy_core(FemModel* femmodel);
 IssmDouble objectivefunction(IssmDouble search_scalar,OptArgs* optargs);
 
Index: /issm/trunk/src/c/solvers/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/solvers/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/solvers/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,16 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/solvers)
+# }}}
+# CORE_SOURCES {{{
+set(CORE_SOURCES $ENV{ISSM_DIR}/src/c/solvers/solver_linear.cpp
+                 $ENV{ISSM_DIR}/src/c/solvers/solver_newton.cpp
+              $ENV{ISSM_DIR}/src/c/solvers/solver_nonlinear.cpp PARENT_SCOPE)
+# }}}
+# THERMAL_SOURCES {{{
+set(THERMAL_SOURCES $ENV{ISSM_DIR}/src/c/solvers/solver_thermal_nonlinear.cpp PARENT_SCOPE)
+# }}}
+# DIAGNOSTIC_SOURCES {{{
+set(DIAGNOSTIC_SOURCES $ENV{ISSM_DIR}/src/c/solvers/solver_stokescoupling_nonlinear.cpp PARENT_SCOPE)
+# }}}
Index: /issm/trunk/src/c/solvers/solver_newton.cpp
===================================================================
--- /issm/trunk/src/c/solvers/solver_newton.cpp	(revision 14309)
+++ /issm/trunk/src/c/solvers/solver_newton.cpp	(revision 14310)
@@ -56,10 +56,30 @@
 
 		/*Solver forward model*/
-		femmodel->SystemMatricesx(&Kff, &Kfs, &pf, &df, NULL);
+		if(count==1){
+			femmodel->SystemMatricesx(&Kff, &Kfs, &pf, &df, NULL);
+			CreateNodalConstraintsx(&ys,femmodel->nodes,configuration_type);
+			Reduceloadx(pf,Kfs,ys);xdelete(&Kfs);
+			Solverx(&uf,Kff,pf,old_uf,df,femmodel->parameters);xdelete(&df);
+			Mergesolutionfromftogx(&ug,uf,ys,femmodel->nodes,femmodel->parameters);xdelete(&ys);
+			InputUpdateFromSolutionx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,ug);xdelete(&ug);
+			xdelete(&old_ug);old_ug=ug;
+			xdelete(&old_uf);old_uf=uf;
+		}
+		uf=old_uf->Duplicate(); old_uf->Copy(uf);
+
+		/*Prepare next iteration using Newton's method*/
+		femmodel->SystemMatricesx(&Kff, &Kfs, &pf, &df, NULL);xdelete(&df);
 		CreateNodalConstraintsx(&ys,femmodel->nodes,configuration_type);
-		Reduceloadx(pf,Kfs,ys);xdelete(&Kfs);
-		Solverx(&uf,Kff,pf,old_uf,df,femmodel->parameters);xdelete(&df);
+		Reduceloadx(pf,Kfs,ys);   xdelete(&Kfs);
+
+		pJf=pf->Duplicate();
+		Kff->MatMult(uf,pJf);// xdelete(&Kff);
+		pJf->Scale(-1.0); pJf->AXPY(pf,+1.0);     //xdelete(&pf);
+
+		femmodel->CreateJacobianMatrixx(&Jff,kmax);
+		Solverx(&duf,Jff,pJf,NULL,NULL,femmodel->parameters); xdelete(&Jff); xdelete(&pJf);
+		uf->AXPY(duf, 1.0); xdelete(&duf);
 		Mergesolutionfromftogx(&ug,uf,ys,femmodel->nodes,femmodel->parameters);xdelete(&ys);
-		InputUpdateFromSolutionx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,ug);xdelete(&ug);
+		InputUpdateFromSolutionx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,ug);
 
 		/*Check convergence*/
@@ -82,18 +102,4 @@
 		}
 
-		/*Prepare next iteration using Newton's method*/
-		femmodel->SystemMatricesx(&Kff, &Kfs, &pf, &df, NULL);
-		CreateNodalConstraintsx(&ys,femmodel->nodes,configuration_type);
-		Reduceloadx(pf,Kfs,ys);   xdelete(&Kfs);
-
-		pJf=pf->Duplicate(); Kff->MatMult(uf,pJf); xdelete(&Kff);
-		pJf->Scale(-1.0); pJf->AXPY(pf,+1.0);     xdelete(&pf);
-
-		femmodel->CreateJacobianMatrixx(&Jff,kmax);
-		Solverx(&duf,Jff,pJf,NULL,NULL,femmodel->parameters); xdelete(&Jff); xdelete(&pJf);
-		uf->AXPY(duf, 1.0); xdelete(&duf);
-		Mergesolutionfromftogx(&ug,uf,ys,femmodel->nodes,femmodel->parameters);xdelete(&ys);
-		InputUpdateFromSolutionx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,ug);
-
 		count++;
 	}
Index: /issm/trunk/src/c/solvers/solver_thermal_nonlinear.cpp
===================================================================
--- /issm/trunk/src/c/solvers/solver_thermal_nonlinear.cpp	(revision 14309)
+++ /issm/trunk/src/c/solvers/solver_thermal_nonlinear.cpp	(revision 14310)
@@ -33,10 +33,8 @@
 	/*parameters:*/
 	int kflag,pflag;
-	bool lowmem=0;
 	int  configuration_type;
 
 	/*Recover parameters: */
 	kflag=1; pflag=1;
-	femmodel->parameters->FindParam(&lowmem,SettingsLowmemEnum);
 	femmodel->parameters->FindParam(&thermal_penalty_threshold,ThermalPenaltyThresholdEnum);
 	femmodel->parameters->FindParam(&configuration_type,ConfigurationTypeEnum);
Index: /issm/trunk/src/c/toolkits/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/toolkits/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/toolkits/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,12 @@
+# Subdirectories {{{
+add_subdirectory(issm)
+add_subdirectory(metis)
+add_subdirectory(mpi)
+add_subdirectory(petsc)
+add_subdirectory(plapack)
+add_subdirectory(scalapack)
+add_subdirectory(triangle)
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/toolkits)
+# }}}
Index: /issm/trunk/src/c/toolkits/issm/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/toolkits/issm/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/toolkits/issm/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,5 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/toolkits/issm)
+# }}}
Index: /issm/trunk/src/c/toolkits/metis/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/toolkits/metis/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/toolkits/metis/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,6 @@
+# Subdirectories {{{
+add_subdirectory(patches)
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/toolkits/metis)
+# }}}
Index: /issm/trunk/src/c/toolkits/metis/patches/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/toolkits/metis/patches/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/toolkits/metis/patches/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,5 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/toolkits/metis/patches)
+# }}}
Index: /issm/trunk/src/c/toolkits/mpi/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/toolkits/mpi/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/toolkits/mpi/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,6 @@
+# Subdirectories {{{
+add_subdirectory(patches)
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/toolkits/mpi)
+# }}}
Index: /issm/trunk/src/c/toolkits/mpi/patches/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/toolkits/mpi/patches/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/toolkits/mpi/patches/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,5 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/toolkits/mpi/patches)
+# }}}
Index: /issm/trunk/src/c/toolkits/petsc/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/toolkits/petsc/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/toolkits/petsc/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,7 @@
+# Subdirectories {{{
+add_subdirectory(objects)
+add_subdirectory(patches)
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/toolkits/petsc)
+# }}}
Index: /issm/trunk/src/c/toolkits/petsc/objects/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/toolkits/petsc/objects/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/toolkits/petsc/objects/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,5 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/toolkits/petsc/objects)
+# }}}
Index: /issm/trunk/src/c/toolkits/petsc/patches/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/toolkits/petsc/patches/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/toolkits/petsc/patches/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,5 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/toolkits/petsc/patches)
+# }}}
Index: /issm/trunk/src/c/toolkits/plapack/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/toolkits/plapack/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/toolkits/plapack/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,6 @@
+# Subdirectories {{{
+add_subdirectory(patches)
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/toolkits/plapack)
+# }}}
Index: /issm/trunk/src/c/toolkits/plapack/patches/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/toolkits/plapack/patches/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/toolkits/plapack/patches/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,5 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/toolkits/plapack/patches)
+# }}}
Index: /issm/trunk/src/c/toolkits/scalapack/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/toolkits/scalapack/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/toolkits/scalapack/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,5 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/toolkits/scalapack)
+# }}}
Index: /issm/trunk/src/c/toolkits/triangle/CMakeLists.txt
===================================================================
--- /issm/trunk/src/c/toolkits/triangle/CMakeLists.txt	(revision 14310)
+++ /issm/trunk/src/c/toolkits/triangle/CMakeLists.txt	(revision 14310)
@@ -0,0 +1,5 @@
+# Subdirectories {{{
+# }}}
+# Include Directory {{{
+include_directories(AFTER $ENV{ISSM_DIR}/src/c/toolkits/triangle)
+# }}}
Index: /issm/trunk/src/m/boundaryconditions/SetIceShelfBC.py
===================================================================
--- /issm/trunk/src/m/boundaryconditions/SetIceShelfBC.py	(revision 14309)
+++ /issm/trunk/src/m/boundaryconditions/SetIceShelfBC.py	(revision 14310)
@@ -25,5 +25,5 @@
 		if not os.path.exists(icefrontfile):
 			raise IOError("SetIceShelfBC error message: ice front file '%s' not found." % icefrontfile)
-		[nodeinsideicefront,dum]=ContourToMesh(md.mesh.elements,md.mesh.x.reshape(-1,1),md.mesh.y.reshape(-1,1),icefrontfile,'node',2)
+		[nodeinsideicefront,dum]=ContourToMesh(md.mesh.elements,md.mesh.x,md.mesh.y,icefrontfile,'node',2)
 		nodeonicefront=numpy.logical_and(md.mesh.vertexonboundary,nodeinsideicefront.reshape(-1))
 	else:
Index: /issm/trunk/src/m/boundaryconditions/SetMarineIceSheetBC.py
===================================================================
--- /issm/trunk/src/m/boundaryconditions/SetMarineIceSheetBC.py	(revision 14309)
+++ /issm/trunk/src/m/boundaryconditions/SetMarineIceSheetBC.py	(revision 14310)
@@ -27,5 +27,5 @@
 		if not os.path.exists(icefrontfile):
 			raise IOError("SetMarineIceSheetBC error message: ice front file '%s' not found." % icefrontfile)
-		[nodeinsideicefront,dum]=ContourToMesh(md.mesh.elements,md.mesh.x.reshape(-1,1),md.mesh.y.reshape(-1,1),icefrontfile,'node',2)
+		[nodeinsideicefront,dum]=ContourToMesh(md.mesh.elements,md.mesh.x,md.mesh.y,icefrontfile,'node',2)
 		vertexonicefront=numpy.logical_and(md.mesh.vertexonboundary,nodeinsideicefront.reshape(-1))
 	else:
Index: /issm/trunk/src/m/classes/autodiff.m
===================================================================
--- /issm/trunk/src/m/classes/autodiff.m	(revision 14309)
+++ /issm/trunk/src/m/classes/autodiff.m	(revision 14310)
@@ -43,5 +43,5 @@
 		end % }}}
 		function disp(obj) % {{{
-			disp(sprintf('      automatic differentiation parameters:'));
+			disp(sprintf('   automatic differentiation parameters:'));
 			fielddisplay(obj,'isautodiff','indicates if the automatic differentiation is activated');
 			fielddisplay(obj,'dependents','list of dependent variables');
Index: /issm/trunk/src/m/classes/balancethickness.py
===================================================================
--- /issm/trunk/src/m/classes/balancethickness.py	(revision 14309)
+++ /issm/trunk/src/m/classes/balancethickness.py	(revision 14310)
@@ -29,5 +29,5 @@
 		string='   balance thickness solution parameters:' 
 		
-		string="%s\n\n%s"%(string,fielddisplay(self,'spcthickness','thickness constraints (NaN means no constraint)'))
+		string="%s\n%s"%(string,fielddisplay(self,'spcthickness','thickness constraints (NaN means no constraint)'))
 		string="%s\n%s"%(string,fielddisplay(self,'thickening_rate','ice thickening rate used in the mass conservation (dh/dt)'))
 		string="%s\n%s"%(string,fielddisplay(self,'stabilization',"0: None, 1: SU, 2: MacAyeal's artificial diffusivity, 3:DG"))
Index: /issm/trunk/src/m/classes/basalforcings.py
===================================================================
--- /issm/trunk/src/m/classes/basalforcings.py	(revision 14309)
+++ /issm/trunk/src/m/classes/basalforcings.py	(revision 14310)
@@ -28,5 +28,5 @@
 		string="   basal forcings parameters:"
 
-		string="%s\n\n%s"%(string,fielddisplay(self,"melting_rate","basal melting rate (positive if melting)"))
+		string="%s\n%s"%(string,fielddisplay(self,"melting_rate","basal melting rate (positive if melting)"))
 		string="%s\n%s"%(string,fielddisplay(self,"melting_rate_correction","additional melting applied when the grounding line retreats"))
 		string="%s\n%s"%(string,fielddisplay(self,"geothermalflux","geothermal heat flux [W/m^2]"))
Index: /issm/trunk/src/m/classes/constants.py
===================================================================
--- /issm/trunk/src/m/classes/constants.py	(revision 14309)
+++ /issm/trunk/src/m/classes/constants.py	(revision 14310)
@@ -27,12 +27,11 @@
 		# {{{ Display
 		string="   constants parameters:"
-		string="%s\n\n%s"%(string,fielddisplay(self,"g","gravitational acceleration"))
+
+		string="%s\n%s"%(string,fielddisplay(self,"g","gravitational acceleration"))
 		string="%s\n%s"%(string,fielddisplay(self,"yts","number of seconds in a year"))
 		string="%s\n%s"%(string,fielddisplay(self,"referencetemperature","reference temperature used in the enthalpy model"))
 
-
 		return string
 		#}}}
-		
 	def setdefaultparameters(self):
 		# {{{setdefaultparameters
Index: /issm/trunk/src/m/classes/debug.py
===================================================================
--- /issm/trunk/src/m/classes/debug.py	(revision 14309)
+++ /issm/trunk/src/m/classes/debug.py	(revision 14310)
@@ -26,5 +26,5 @@
 		string="   debug parameters:"
 
-		string="%s\n\n%s"%(string,fielddisplay(self,"valgrind","use Valgrind to debug (0 or 1)"))
+		string="%s\n%s"%(string,fielddisplay(self,"valgrind","use Valgrind to debug (0 or 1)"))
 		string="%s\n%s"%(string,fielddisplay(self,"gprof","use gnu-profiler to find out where the time is spent"))
 		string="%s\n%s"%(string,fielddisplay(self,'profiling','enables profiling (memory, flops, time)'))
Index: /issm/trunk/src/m/classes/diagnostic.py
===================================================================
--- /issm/trunk/src/m/classes/diagnostic.py	(revision 14309)
+++ /issm/trunk/src/m/classes/diagnostic.py	(revision 14310)
@@ -45,6 +45,6 @@
 		# {{{ Display
 		
-		string='\n   Diagnostic solution parameters:'
-		string="%s\n\n%s"%(string,'      Convergence criteria:')
+		string='   Diagnostic solution parameters:'
+		string="%s\n%s"%(string,'      Convergence criteria:')
 			
 		string="%s\n%s"%(string,fielddisplay(self,'restol','mechanical equilibrium residual convergence criterion'))
@@ -55,5 +55,5 @@
 		string="%s\n%s"%(string,fielddisplay(self,'viscosity_overshoot','over-shooting constant new=new+C*(new-old)'))
 
-		string="%s\n%s"%(string,'      boundary conditions:')
+		string="%s\n%s"%(string,'\n      boundary conditions:')
 
 		string="%s\n%s"%(string,fielddisplay(self,'spcvx','x-axis velocity constraint (NaN means no constraint)'))
@@ -62,13 +62,13 @@
 		string="%s\n%s"%(string,fielddisplay(self,'icefront','segments on ice front list (last column 0-> Air, 1-> Water, 2->Ice'))
 
-		string="%s\n%s"%(string,'      Rift options:')
+		string="%s\n%s"%(string,'\n      Rift options:')
 		string="%s\n%s"%(string,fielddisplay(self,'rift_penalty_threshold','threshold for instability of mechanical constraints'))
 		string="%s\n%s"%(string,fielddisplay(self,'rift_penalty_lock','number of iterations before rift penalties are locked'))
 
-		string="%s\n%s"%(string,'      Penalty options:')
+		string="%s\n%s"%(string,'\n      Penalty options:')
 		string="%s\n%s"%(string,fielddisplay(self,'penalty_factor','offset used by penalties: penalty = Kmax*10^offset'))
 		string="%s\n%s"%(string,fielddisplay(self,'vertex_pairing','pairs of vertices that are penalized'))
 
-		string="%s\n%s"%(string,'      Other:')
+		string="%s\n%s"%(string,'\n      Other:')
 		string="%s\n%s"%(string,fielddisplay(self,'shelf_dampening','use dampening for floating ice ? Only for Stokes model'))
 		string="%s\n%s"%(string,fielddisplay(self,'stokesreconditioning','multiplier for incompressibility equation. Only for Stokes model'))
Index: /issm/trunk/src/m/classes/flowequation.py
===================================================================
--- /issm/trunk/src/m/classes/flowequation.py	(revision 14309)
+++ /issm/trunk/src/m/classes/flowequation.py	(revision 14310)
@@ -37,5 +37,5 @@
 		string='   flow equation parameters:'
 
-		string="%s\n\n%s"%(string,fielddisplay(self,'ismacayealpattyn',"is the macayeal or pattyn approximation used ?"))
+		string="%s\n%s"%(string,fielddisplay(self,'ismacayealpattyn',"is the macayeal or pattyn approximation used ?"))
 		string="%s\n%s"%(string,fielddisplay(self,'ishutter',"is the shallow ice approximation used ?"))
 		string="%s\n%s"%(string,fielddisplay(self,'isl1l2',"are l1l2 equations used ?"))
Index: /issm/trunk/src/m/classes/friction.py
===================================================================
--- /issm/trunk/src/m/classes/friction.py	(revision 14309)
+++ /issm/trunk/src/m/classes/friction.py	(revision 14310)
@@ -27,5 +27,6 @@
 		# {{{ Display
 		string="Sigma= drag^2 * Neff ^r * u ^s, with Neff=rho_ice*g*thickness+rho_water*g*bed, r=q/p and s=1/p"
-		string="%s\n\n%s"%(string,fielddisplay(self,"coefficient","friction coefficient [SI]"))
+
+		string="%s\n%s"%(string,fielddisplay(self,"coefficient","friction coefficient [SI]"))
 		string="%s\n%s"%(string,fielddisplay(self,"p","p exponent"))
 		string="%s\n%s"%(string,fielddisplay(self,"q","q exponent"))
Index: /issm/trunk/src/m/classes/geometry.py
===================================================================
--- /issm/trunk/src/m/classes/geometry.py	(revision 14309)
+++ /issm/trunk/src/m/classes/geometry.py	(revision 14310)
@@ -31,5 +31,5 @@
 		string="   geometry parameters:"
 
-		string="%s\n\n%s"%(string,fielddisplay(self,'surface','surface elevation'))
+		string="%s\n%s"%(string,fielddisplay(self,'surface','surface elevation'))
 		string="%s\n%s"%(string,fielddisplay(self,'thickness','ice thickness'))
 		string="%s\n%s"%(string,fielddisplay(self,'bed','bed elevation'))
Index: /issm/trunk/src/m/classes/groundingline.py
===================================================================
--- /issm/trunk/src/m/classes/groundingline.py	(revision 14309)
+++ /issm/trunk/src/m/classes/groundingline.py	(revision 14310)
@@ -30,5 +30,5 @@
 		string='   grounding line solution parameters:'
 
-		string="%s\n\n%s"%(string,fielddisplay(self,'migration','type of grounding line migration: ''SoftMigration'',''AgressiveMigration'' or ''None'''))
+		string="%s\n%s"%(string,fielddisplay(self,'migration','type of grounding line migration: ''SoftMigration'',''AgressiveMigration'' or ''None'''))
 		string="%s\n%s"%(string,fielddisplay(self,'melting_rate','melting rate applied when previously grounded parts start floating'))
 		return string
Index: /issm/trunk/src/m/classes/hydrology.py
===================================================================
--- /issm/trunk/src/m/classes/hydrology.py	(revision 14309)
+++ /issm/trunk/src/m/classes/hydrology.py	(revision 14310)
@@ -32,5 +32,5 @@
 		
 		string='   hydrology solution parameters:'
-		string="%s\n\n%s"%(string,fielddisplay(self,'spcwatercolumn','water thickness constraints (NaN means no constraint)'))
+		string="%s\n%s"%(string,fielddisplay(self,'spcwatercolumn','water thickness constraints (NaN means no constraint)'))
 		string="%s\n%s"%(string,fielddisplay(self,'n','Manning roughness coefficient'))
 		string="%s\n%s"%(string,fielddisplay(self,'CR','tortuosity parameter'))
Index: /issm/trunk/src/m/classes/initialization.py
===================================================================
--- /issm/trunk/src/m/classes/initialization.py	(revision 14309)
+++ /issm/trunk/src/m/classes/initialization.py	(revision 14310)
@@ -90,6 +90,4 @@
 		WriteData(fid,'data',self.pressure,'format','DoubleMat','mattype',1,'enum',PressureEnum())
 		WriteData(fid,'data',self.temperature,'format','DoubleMat','mattype',1,'enum',TemperatureEnum())
-		WriteData(fid,'data',self.surfacetemp,'format','DoubleMat','mattype',1,'enum',TemperatureSurfaceEnum()) 
-		WriteData(fid,'data',self.basaltemp,'format','DoubleMat','mattype',1,'enum',TemperatureBasalEnum())
 		WriteData(fid,'data',self.watercolumn,'format','DoubleMat','mattype',1,'enum',WatercolumnEnum())
 		WriteData(fid,'data',self.waterfraction,'format','DoubleMat','mattype',1,'enum',WaterfractionEnum())
Index: /issm/trunk/src/m/classes/inversion.m
===================================================================
--- /issm/trunk/src/m/classes/inversion.m	(revision 14309)
+++ /issm/trunk/src/m/classes/inversion.m	(revision 14310)
@@ -31,4 +31,28 @@
 				case 0
 					obj=setdefaultparameters(obj);
+				case 1
+					if isa(varargin{1},'taoinversion'),
+						disp('converting taoinversion to inversion');
+						in=varargin{1};
+						obj.iscontrol                   = in.iscontrol;
+						obj.tao                         = 1;
+						obj.incomplete_adjoint          = in.incomplete_adjoint;
+						obj.control_parameters          = in.control_parameters;
+						obj.nsteps                      = in.nsteps;
+						obj.maxiter_per_step            = 10*ones(in.nsteps,1);
+						obj.cost_functions              = repmat(in.cost_functions,in.nsteps,1);
+						obj.cost_functions_coefficients = in.cost_functions_coefficients;
+						obj.gradient_scaling            = 100*ones(in.nsteps,1);
+						obj.cost_function_threshold     = NaN;
+						obj.min_parameters              = in.min_parameters;
+						obj.max_parameters              = in.max_parameters;
+						obj.step_threshold              = .99*ones(in.nsteps,1);
+						obj.vx_obs                      = in.vx_obs;
+						obj.gradient_only               = 0;
+						obj.vy_obs                      = in.vy_obs;
+						obj.vz_obs                      = in.vz_obs;
+						obj.vel_obs                     = in.vel_obs;
+						obj.thickness_obs               = in.thickness_obs;
+					end
 				otherwise
 					error('constructor not supported');
@@ -86,9 +110,10 @@
 			md = checkfield(md,'inversion.tao','values',[0 1]);
 			md = checkfield(md,'inversion.incomplete_adjoint','values',[0 1]);
-			md = checkfield(md,'inversion.control_parameters','cell',1,'values',{'BalancethicknessThickeningRate' 'FrictionCoefficient' 'MaterialsRheologyBbar' 'MaterialsRheologyZbar' 'Vx' 'Vy'});
+			md = checkfield(md,'inversion.control_parameters','cell',1,'values',...
+				{'BalancethicknessThickeningRate' 'FrictionCoefficient' 'MaterialsRheologyBbar' 'MaterialsRheologyZbar' 'Vx' 'Vy' 'Thickness'});
 			md = checkfield(md,'inversion.nsteps','numel',1,'>=',1);
 			md = checkfield(md,'inversion.maxiter_per_step','size',[md.inversion.nsteps 1],'>=',0);
 			md = checkfield(md,'inversion.step_threshold','size',[md.inversion.nsteps 1]);
-			md = checkfield(md,'inversion.cost_functions','size',[md.inversion.nsteps num_costfunc],'values',[101:105 201 501:505]);
+			md = checkfield(md,'inversion.cost_functions','size',[md.inversion.nsteps num_costfunc],'values',[101:105 201 501:506]);
 			md = checkfield(md,'inversion.cost_functions_coefficients','size',[md.mesh.numberofvertices num_costfunc],'>=',0);
 			md = checkfield(md,'inversion.gradient_only','values',[0 1]);
@@ -99,4 +124,6 @@
 			if solution==BalancethicknessSolutionEnum()
 				md = checkfield(md,'inversion.thickness_obs','size',[md.mesh.numberofvertices 1],'NaN',1);
+			elseif solution==WeakBalancethicknessSolutionEnum()
+				md = checkfield(md,'inversion.thickness_obs','size',[md.mesh.numberofvertices 1],'NaN',1);
 			else
 				md = checkfield(md,'inversion.vx_obs','size',[md.mesh.numberofvertices 1],'NaN',1);
@@ -105,4 +132,5 @@
 		end % }}}
 		function disp(obj) % {{{
+			disp(sprintf('   inversion parameters:'));
 			fielddisplay(obj,'iscontrol','is inversion activated?');
 			fielddisplay(obj,'incomplete_adjoint','do we assume linear viscosity?');
@@ -176,4 +204,5 @@
 			pos=find(data==504); data(pos)=ThicknessAlongGradientEnum();
 			pos=find(data==505); data(pos)=ThicknessAcrossGradientEnum();
+			pos=find(data==506); data(pos)=BalancethicknessMisfitEnum();
 			WriteData(fid,'data',data,'enum',InversionCostFunctionsEnum(),'format','DoubleMat','mattype',3);
 			WriteData(fid,'data',num_cost_functions,'enum',InversionNumCostFunctionsEnum(),'format','Integer');
Index: /issm/trunk/src/m/classes/inversion.py
===================================================================
--- /issm/trunk/src/m/classes/inversion.py	(revision 14309)
+++ /issm/trunk/src/m/classes/inversion.py	(revision 14310)
@@ -45,5 +45,5 @@
 	def __repr__(self):
 		# {{{ Display
-		string='\n   Inversion parameters:'
+		string='   inversion parameters:'
 		string="%s\n%s"%(string,fielddisplay(self,'iscontrol','is inversion activated?'))
 		string="%s\n%s"%(string,fielddisplay(self,'incomplete_adjoint','do we assume linear viscosity?'))
Index: /issm/trunk/src/m/classes/mask.m
===================================================================
--- /issm/trunk/src/m/classes/mask.m	(revision 14309)
+++ /issm/trunk/src/m/classes/mask.m	(revision 14310)
@@ -12,4 +12,5 @@
 		vertexongroundedice  = NaN;
 		vertexonwater        = NaN;
+		vertexonrock        = NaN;
 	end
 	methods
@@ -33,12 +34,16 @@
 			md = checkfield(md,'mask.vertexongroundedice','size',[md.mesh.numberofvertices 1],'values',[0 1]);
 			md = checkfield(md,'mask.vertexonwater'      ,'size',[md.mesh.numberofvertices 1],'values',[0 1]);
+			md = checkfield(md,'mask.vertexonrock'      ,'size',[md.mesh.numberofvertices 1],'values',[0 1]);
 		end % }}}
 		function disp(obj) % {{{
+			disp(sprintf('   masks:'));
+
 			fielddisplay(obj,'elementonfloatingice','element on floating ice flags list');
 			fielddisplay(obj,'vertexonfloatingice','vertex on floating ice flags list');
 			fielddisplay(obj,'elementongroundedice','element on grounded ice  list');
 			fielddisplay(obj,'vertexongroundedice','vertex on grounded ice flags list');
-			fielddisplay(obj,'elementonwater','element on water flags list');
+			fielddisplay(obj,'elementonwater','element on rock flags list');
 			fielddisplay(obj,'vertexonwater','vertex on water flags list');
+			fielddisplay(obj,'vertexonrock','vertex on rock flags list');
 		end % }}}
 		function marshall(obj,fid) % {{{
Index: /issm/trunk/src/m/classes/mask.py
===================================================================
--- /issm/trunk/src/m/classes/mask.py	(revision 14309)
+++ /issm/trunk/src/m/classes/mask.py	(revision 14310)
@@ -29,6 +29,6 @@
 	def __repr__(self):
 		# {{{ Display
+		string="   masks:"
 
-		string="";
 		string="%s\n%s"%(string,fielddisplay(self,"elementonfloatingice","element on floating ice flags list"))
 		string="%s\n%s"%(string,fielddisplay(self,"vertexonfloatingice","vertex on floating ice flags list"))
Index: /issm/trunk/src/m/classes/matice.m
===================================================================
--- /issm/trunk/src/m/classes/matice.m	(revision 14309)
+++ /issm/trunk/src/m/classes/matice.m	(revision 14310)
@@ -89,5 +89,5 @@
 		end % }}}
 		function disp(obj) % {{{
-			disp(sprintf('   Materials:\n'));
+			disp(sprintf('   Materials:'));
 
 			fielddisplay(obj,'rho_ice','ice density [kg/m^3]');
Index: /issm/trunk/src/m/classes/matice.py
===================================================================
--- /issm/trunk/src/m/classes/matice.py	(revision 14309)
+++ /issm/trunk/src/m/classes/matice.py	(revision 14310)
@@ -38,5 +38,5 @@
 		string="   Materials:"
 
-		string="%s\n\n%s"%(string,fielddisplay(self,"rho_ice","ice density [kg/m^3]"))
+		string="%s\n%s"%(string,fielddisplay(self,"rho_ice","ice density [kg/m^3]"))
 		string="%s\n%s"%(string,fielddisplay(self,"rho_water","water density [kg/m^3]"))
 		string="%s\n%s"%(string,fielddisplay(self,"rho_freshwater","fresh water density [kg/m^3]"))
Index: /issm/trunk/src/m/classes/mesh.py
===================================================================
--- /issm/trunk/src/m/classes/mesh.py	(revision 14309)
+++ /issm/trunk/src/m/classes/mesh.py	(revision 14310)
@@ -63,7 +63,9 @@
 	def __repr__(self):
 		# {{{ Display
+		string="   Mesh:" 
+
 
 		if self.dimension==3:
-			string="\n%s"%("      Elements and vertices of the original 2d mesh:")
+			string="%s\n%s"%(string,"\n      Elements and vertices of the original 2d mesh:")
 			
 			string="%s\n%s"%(string,fielddisplay(self,"numberofelements2d","number of elements"))
@@ -73,7 +75,7 @@
 			string="%s\n%s"%(string,fielddisplay(self,"y2d","vertices y coordinate"))
 
-			string="%s\n%s" %(string,"Elements and vertices of the extruded 3d mesh:")
+			string="%s\n%s"%(string,"\n\n      Elements and vertices of the extruded 3d mesh:")
 		else:
-			string="\n%s"%("      Elements and vertices:")
+			string="%s\n%s"%(string,"\n      Elements and vertices:")
 		string="%s\n%s"%(string,fielddisplay(self,"numberofelements","number of elements"))
 		string="%s\n%s"%(string,fielddisplay(self,"numberofvertices","number of vertices"))
@@ -85,5 +87,5 @@
 		string="%s\n%s"%(string,fielddisplay(self,"numberofedges","number of edges of the 2d mesh"))
 
-		string="%s%s"%(string,"\n      Properties:")
+		string="%s%s"%(string,"\n\n      Properties:")
 		string="%s\n%s"%(string,fielddisplay(self,"dimension","mesh dimension (2d or 3d)"))
 		string="%s\n%s"%(string,fielddisplay(self,"numberoflayers","number of extrusion layers"))
@@ -103,9 +105,9 @@
 		string="%s\n%s"%(string,fielddisplay(self,"average_vertex_connectivity","average number of vertices connected to one vertex"))
 
-		string="%s%s"%(string,"\n      Extracted model:")
+		string="%s%s"%(string,"\n\n      Extracted model:")
 		string="%s\n%s"%(string,fielddisplay(self,"extractedvertices","vertices extracted from the model"))
 		string="%s\n%s"%(string,fielddisplay(self,"extractedelements","elements extracted from the model"))
 
-		string="%s%s"%(string,"\n      Projection:")
+		string="%s%s"%(string,"\n\n      Projection:")
 		string="%s\n%s"%(string,fielddisplay(self,"lat","vertices latitude"))
 		string="%s\n%s"%(string,fielddisplay(self,"long","vertices longitude"))
Index: /issm/trunk/src/m/classes/miscellaneous.py
===================================================================
--- /issm/trunk/src/m/classes/miscellaneous.py	(revision 14309)
+++ /issm/trunk/src/m/classes/miscellaneous.py	(revision 14310)
@@ -29,5 +29,5 @@
 		string='   miscellaneous parameters:'
 
-		string="%s\n\n%s"%(string,fielddisplay(self,'notes','notes in a cell of strings'))
+		string="%s\n%s"%(string,fielddisplay(self,'notes','notes in a cell of strings'))
 		string="%s\n%s"%(string,fielddisplay(self,'name','model name'))
 		string="%s\n%s"%(string,fielddisplay(self,'dummy','empty field to store some data'))
Index: /issm/trunk/src/m/classes/model/model.m
===================================================================
--- /issm/trunk/src/m/classes/model/model.m	(revision 14309)
+++ /issm/trunk/src/m/classes/model/model.m	(revision 14310)
@@ -212,4 +212,5 @@
 			md.mask.elementonwater=project2d(md,md.mask.elementonwater,1);
 			md.mask.vertexonwater=project2d(md,md.mask.vertexonwater,1);
+			md.mask.vertexonrock=project2d(md,md.mask.vertexonrock,1);
 
 			%lat long
@@ -502,14 +503,25 @@
 				solutionfields=fields(md1.results);
 				for i=1:length(solutionfields),
-					%get subfields
-					solutionsubfields=fields(md1.results.(solutionfields{i}));
-					for j=1:length(solutionsubfields),
-						field=md1.results.(solutionfields{i}).(solutionsubfields{j});
+					if isstruct(md1.results.(solutionfields{i}))
+						%get subfields
+						solutionsubfields=fields(md1.results.(solutionfields{i}));
+						for j=1:length(solutionsubfields),
+							field=md1.results.(solutionfields{i}).(solutionsubfields{j});
+							if length(field)==numberofvertices1,
+								md2.results.(solutionfields{i}).(solutionsubfields{j})=field(pos_node);
+							elseif length(field)==numberofelements1,
+								md2.results.(solutionfields{i}).(solutionsubfields{j})=field(pos_elem);
+							else
+								md2.results.(solutionfields{i}).(solutionsubfields{j})=field;
+							end
+						end
+					else
+						field=md1.results.(solutionfields{i});
 						if length(field)==numberofvertices1,
-							md2.results.(solutionfields{i}).(solutionsubfields{j})=field(pos_node);
+							md2.results.(solutionfields{i})=field(pos_node);
 						elseif length(field)==numberofelements1,
-							md2.results.(solutionfields{i}).(solutionsubfields{j})=field(pos_elem);
+							md2.results.(solutionfields{i})=field(pos_elem);
 						else
-							md2.results.(solutionfields{i}).(solutionsubfields{j})=field;
+							md2.results.(solutionfields{i})=field;
 						end
 					end
@@ -744,4 +756,5 @@
 			md.mask.elementonwater=project3d(md,'vector',md.mask.elementonwater,'type','element');
 			md.mask.vertexonwater=project3d(md,'vector',md.mask.vertexonwater,'type','node');
+			md.mask.vertexonrock=project3d(md,'vector',md.mask.vertexonrock,'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;
 			if ~isnan(md.inversion.min_parameters),md.inversion.min_parameters=project3d(md,'vector',md.inversion.min_parameters,'type','node');end;
@@ -1120,4 +1133,20 @@
 			disp(sprintf('%19s: %-22s -- %s','miscellaneous'   ,['[1x1 ' class(obj.miscellaneous) ']'],'miscellaneous fields'));
 		end % }}}
+		function memory(obj) % {{{
+			
+		disp(sprintf('\nMemory imprint: '));
+
+		objects=fields(obj);
+		memory=0;
+		
+		for i=1:length(objects),
+			field=objects{i};
+			realobject=obj.(field);
+			s=whos('realobject'); 
+			memory=memory+s.bytes/1e6;
+			disp(sprintf('%19s: %g Mb',field,s.bytes/1e6));
+		end
+		disp(sprintf('Overall: %g Mb',memory));
+		end % }}}
 	end
  end
Index: /issm/trunk/src/m/classes/model/model.py
===================================================================
--- /issm/trunk/src/m/classes/model/model.py	(revision 14309)
+++ /issm/trunk/src/m/classes/model/model.py	(revision 14310)
@@ -45,4 +45,5 @@
 from ElementConnectivity import *
 from contourenvelope import *
+from PythonFuncs import *
 #}}}
 
@@ -407,5 +408,5 @@
 				md2.diagnostic.icefront[:,2]=Pnode[md1.diagnostic.icefront[:,2].astype(int)-1]
 				md2.diagnostic.icefront[:,3]=Pnode[md1.diagnostic.icefront[:,3].astype(int)-1]
-			md2.diagnostic.icefront=md2.diagnostic.icefront[numpy.nonzero(numpy.logical_and(numpy.logical_and(md2.diagnostic.icefront[:,0],md2.diagnostic.icefront[:,1]),md2.diagnostic.icefront[:,-1]))[0],:]
+			md2.diagnostic.icefront=md2.diagnostic.icefront[numpy.nonzero(logical_and_n(md2.diagnostic.icefront[:,0],md2.diagnostic.icefront[:,1],md2.diagnostic.icefront[:,-1]))[0],:]
 
 		#Results fields
Index: /issm/trunk/src/m/classes/organizer.m
===================================================================
--- /issm/trunk/src/m/classes/organizer.m	(revision 14309)
+++ /issm/trunk/src/m/classes/organizer.m	(revision 14310)
@@ -13,5 +13,5 @@
 %      org = organizer('repository','Models/','prefix','AGU2015','steps',0);  %build an empty organizer object with a given repository
 
-classdef organizer
+classdef organizer < handle
     properties (SetAccess=private) 
 		% {{{
@@ -112,4 +112,30 @@
 			end
 		end%}}}
+		function md=loaddata(org,string),% {{{
+
+			%Get model path
+			if ~ischar(string), error('argument provided is not a string'); end
+			path=[org.repository '/' org.prefix string];
+
+			%figure out if the data is there, otherwise, we have to use the default path supplied by user.
+			if exist(path,'file') | exist([path '.mat'],'file'),
+				evalin('caller',['load -mat ' path]);
+				return;
+			end
+
+			%If we are here, the data has not been found. Try trunk prefix if provided
+			if ~isempty(org.trunkprefix),
+				path2=[org.repository '/' org.trunkprefix string];
+				if ~exist(path2,'file'),
+					error(['Could find neither ' path ', nor ' path2]);
+				else
+					disp(['--> Branching ' org.prefix ' from trunk ' org.trunkprefix]);
+					evalin('caller',['load -mat ' path2]);
+					return;
+				end
+			else
+				error(['Could not find ' path ]);
+			end
+		end%}}}
 		function bool=perform(org,string) % {{{
 
@@ -142,7 +168,4 @@
 			end
 
-			%assign org back to calling workspace
-			assignin('caller',inputname(1),org);
-
 		end%}}}
 		function savemodel(org,md) % {{{
@@ -162,4 +185,24 @@
 			save(name,'md','-v7.3');
 		end%}}}
+		function savedata(org,varargin) % {{{
+
+			%check
+			if (org.currentstep==0), error('Cannot save data because organizer (org) is empty! Make sure you did not skip any perform call'); end
+			if (org.currentstep>length(org.steps)), error('Cannot save data because organizer (org) is not up to date!'); end
+
+			name=[org.repository '/' org.prefix org.steps(org.currentstep).string ];
+			disp(['saving data in: ' name]);
+
+			%check that md is a model
+			if (org.currentstep>length(org.steps)), error(['organizer error message: element with id ' num2str(org.currentstep) ' not found']); end
+
+			%list of variable names: 
+			variables='';
+			for i=2:nargin, 
+				variables=[variables ',' '''' inputname(i) ''''];
+				eval([inputname(i) '= varargin{' num2str(i-1) '};']);
+			end
+			eval(['save(''' name '''' variables ',''-v7.3'');']);
+		end%}}}
 	end
 end
Index: /issm/trunk/src/m/classes/pairoptions.m
===================================================================
--- /issm/trunk/src/m/classes/pairoptions.m	(revision 14309)
+++ /issm/trunk/src/m/classes/pairoptions.m	(revision 14310)
@@ -5,8 +5,8 @@
 %      pairoptions=pairoptions('module',true,'solver',false);
 
-classdef pairoptions
+classdef pairoptions < handle
 	properties (SetAccess = private,GetAccess = private) 
 		functionname = '';
-		list         = cell(0,2);
+		list         = cell(0,3);
 	end
 	methods
@@ -38,5 +38,5 @@
 
 			%Allocate memory
-			obj.list=cell(numoptions,2);
+			obj.list=cell(numoptions,3);
 
 			%go through varargin and build list of obj
@@ -45,4 +45,5 @@
 					obj.list{i,1}=varargin{2*i-1};
 					obj.list{i,2}=varargin{2*i};
+					obj.list{i,3}=false; %used?
 				else
 					%option is not a string, ignore it
@@ -57,4 +58,5 @@
 				obj.list{end+1,1} = field;
 				obj.list{end,2}   = value;
+				obj.list{end,3}   = false;
 			end
 		end % }}}
@@ -65,4 +67,5 @@
 					obj.list{end+1,1} = field;
 					obj.list{end,2}   = value;
+					obj.list{end,3}   = true;  %It is a default so user will not be notified if not used
 				end
 			end
@@ -84,5 +87,5 @@
 		%CHANGEOPTIONVALUE - change the value of an option in an option list
 
-			%track occurance of field
+			%track occurrence of field
 			lines=find(strcmpi(obj.list(:,1),field));
 
@@ -91,4 +94,5 @@
 				%add new field if not found
 				obj=addfield(obj,field,newvalue);
+				obj.list{end,3}=true; % do not notify user if unused
 			else
 				for i=1:length(lines),
@@ -100,5 +104,5 @@
 		%DELETEDUPLICATES - delete duplicates in an option list
 
-			%track the first occurance of each option
+			%track the first occurrence of each option
 			[dummy lines]=unique(obj.list(:,1),'first');
 			clear dummy
@@ -109,5 +113,5 @@
 				for i=1:numoptions,
 					if ~ismember(i,lines),
-						disp(['WARNING: option ' obj.list{i,1} ' appeared more than once. Only its first occurence will be kept'])
+						disp(['WARNING: option ' obj.list{i,1} ' appeared more than once. Only its first occurrence will be kept'])
 					end
 				end
@@ -116,4 +120,14 @@
 			%remove duplicates from the options list
 			obj.list=obj.list(lines,:);
+		end % }}}
+		function displayunused(obj) % {{{
+			%DISPLAYUNUSED - display unused options
+
+			numoptions=size(obj.list,1);
+			for i=1:numoptions,
+				if ~obj.list{i,3},
+					disp(['WARNING: option ' obj.list{i,1} ' was not used'])
+				end
+			end
 		end % }}}
 		function disp(obj) % {{{
@@ -137,5 +151,5 @@
 		end % }}}
 		function bool = exist(obj,field) % {{{
-		%EXIST - check if the option exist
+		%EXIST - check if the option exists
 
 			%some argument checking: 
@@ -148,15 +162,21 @@
 
 			%Recover option
-			bool=any(strcmpi(field,obj.list(:,1)));
-		end % }}}
-		function num = fieldoccurences(obj,field), % {{{
-		%FIELDOCCURENCES - get number of occurence of a field
+			pos=find(strcmpi(field,obj.list(:,1)));
+			if ~isempty(pos),
+				bool=true;
+				obj.list{pos,3}   = true;  %It is a default so user will not be notified if not used
+			else
+				bool=false;
+			end
+		end % }}}
+		function num = fieldoccurrences(obj,field), % {{{
+		%FIELDOCCURRENCES - get number of occurrence of a field
 
 			%check input 
 			if ~ischar(field),
-				error('fieldoccurences error message: field should be a string');
-			end
-
-			%get number of occurence
+				error('fieldoccurrences error message: field should be a string');
+			end
+
+			%get number of occurrence
 			num=sum(strcmpi(field,obj.list(:,1)));
 		end % }}}
@@ -187,5 +207,6 @@
 			pos=find(strcmpi(obj.list(:,1),field));
 			if ~isempty(pos),
-				value=obj.list{pos(1),2}; %ignore extra entry
+				value=obj.list{pos(1),2}; % ignore extra entry
+				obj.list{pos(1),3}=true;  % option used
 				return;
 			end
@@ -204,5 +225,5 @@
 		%      obj=removefield(obj,field,warn)
 		%
-		%   if warn==1 display an info message to wan user that
+		%   if warn==1 display an info message to warn user that
 		%   some of his options have been removed.
 
Index: /issm/trunk/src/m/classes/pairoptions.py
===================================================================
--- /issm/trunk/src/m/classes/pairoptions.py	(revision 14309)
+++ /issm/trunk/src/m/classes/pairoptions.py	(revision 14310)
@@ -78,5 +78,5 @@
 #	%DELETEDUPLICATES - delete duplicates in an option list
 #
-#		%track the first occurance of each option
+#		%track the first occurrence of each option
 #		[dummy lines]=unique(obj.list(:,1),'first');
 #		clear dummy
@@ -87,5 +87,5 @@
 #			for i=1:numoptions,
 #				if ~ismember(i,lines),
-#					disp(['WARNING: option ' obj.list{i,1} ' appeared more than once. Only its first occurence will be kept'])
+#					disp(['WARNING: option ' obj.list{i,1} ' appeared more than once. Only its first occurrence will be kept'])
 #				end
 #			end
@@ -128,14 +128,14 @@
 	# }}}
 
-	#def fieldoccurences(self,field): #{{{
+	#def fieldoccurrences(self,field): #{{{
 	#	'''
-	#	FIELDOCCURENCES - get number of occurence of a field
+	#	FIELDOCCURRENCES - get number of occurrence of a field
 	#	'''
 	#
 	#	#check input 
 	#	if not isinstance(field,(str,unicode)):
-	#		raise TypeError("fieldoccurences error message: field should be a string")
-
-	#	#get number of occurence
+	#		raise TypeError("fieldoccurrences error message: field should be a string")
+
+	#	#get number of occurrence
 	#	# ??
 	#	#return num
Index: /issm/trunk/src/m/classes/plotoptions.m
===================================================================
--- /issm/trunk/src/m/classes/plotoptions.m	(revision 14309)
+++ /issm/trunk/src/m/classes/plotoptions.m	(revision 14310)
@@ -68,5 +68,5 @@
 
 			 %get number of data to be plotted
-			 numberofplots=fieldoccurences(rawoptions,'data');
+			 numberofplots=fieldoccurrences(rawoptions,'data');
 			 opt.numberofplots=numberofplots;
 
@@ -112,5 +112,5 @@
 							 continue;
 
-							 %#all
+							 %pound all
 						 elseif strcmpi(plotnum,'all');
 							 for j=1:numberofplots,
@@ -118,5 +118,5 @@
 							 end
 
-							 %#i-j
+							 %pound i-j
 						 elseif ismember('-',plotnum)
 							 nums=strsplit(plotnum,'-');
@@ -129,5 +129,5 @@
 							 end
 
-							 %#i
+							 %pound i
 						 else
 							 %assign to subplot
Index: /issm/trunk/src/m/classes/prognostic.py
===================================================================
--- /issm/trunk/src/m/classes/prognostic.py	(revision 14309)
+++ /issm/trunk/src/m/classes/prognostic.py	(revision 14310)
@@ -32,5 +32,5 @@
 		# {{{ Display
 		string='   Prognostic solution parameters:'
-		string="%s\n\n%s"%(string,fielddisplay(self,'spcthickness','thickness constraints (NaN means no constraint)'))
+		string="%s\n%s"%(string,fielddisplay(self,'spcthickness','thickness constraints (NaN means no constraint)'))
 		string="%s\n%s"%(string,fielddisplay(self,'min_thickness','minimum ice thickness allowed'))
 		string="%s\n%s"%(string,fielddisplay(self,'hydrostatic_adjustment','adjustment of ice shelves surface and bed elevations: ''Incremental'' or ''Absolute'' '))
Index: /issm/trunk/src/m/classes/qmu/@dakota_method/dakota_method.m
===================================================================
--- /issm/trunk/src/m/classes/qmu/@dakota_method/dakota_method.m	(revision 14309)
+++ /issm/trunk/src/m/classes/qmu/@dakota_method/dakota_method.m	(revision 14310)
@@ -620,4 +620,5 @@
                                 dm.params.seed=false;
                                 dm.params.fixed_seed=false;
+                                dm.params.rng=false;
                                 dm.params.samples=false;
                                 dm.params.sample_type='lhs';
Index: /issm/trunk/src/m/classes/qmu/@dakota_method/dmeth_params_write.m
===================================================================
--- /issm/trunk/src/m/classes/qmu/@dakota_method/dmeth_params_write.m	(revision 14309)
+++ /issm/trunk/src/m/classes/qmu/@dakota_method/dmeth_params_write.m	(revision 14310)
@@ -350,4 +350,7 @@
                 param_write(fid,sbeg,'seed','             = ','\n',dm.params);
                 param_write(fid,sbeg,'fixed_seed','','\n',dm.params);
+                if (str2num(dakotaversion())>4.2)
+                    param_write(fid,sbeg,'rng','                ','\n',dm.params);
+                end
                 param_write(fid,sbeg,'samples','          = ','\n',dm.params);
                 param_write(fid,sbeg,'sample_type','        ','\n',dm.params);
Index: /issm/trunk/src/m/classes/radaroverlay.py
===================================================================
--- /issm/trunk/src/m/classes/radaroverlay.py	(revision 14309)
+++ /issm/trunk/src/m/classes/radaroverlay.py	(revision 14310)
@@ -24,5 +24,5 @@
 		# {{{ Display
 		string='   radaroverlay parameters:'
-		string="%s\n\n%s"%(string,fielddisplay(self,'pwr','radar power image (matrix)'))
+		string="%s\n%s"%(string,fielddisplay(self,'pwr','radar power image (matrix)'))
 		string="%s\n%s"%(string,fielddisplay(self,'x','corresponding x coordinates'))
 		string="%s\n%s"%(string,fielddisplay(self,'y','corresponding y coordinates'))
Index: /issm/trunk/src/m/classes/rifts.py
===================================================================
--- /issm/trunk/src/m/classes/rifts.py	(revision 14309)
+++ /issm/trunk/src/m/classes/rifts.py	(revision 14310)
@@ -29,5 +29,5 @@
 		string='   rifts parameters:'
 
-		string="%s\n\n%s"%(string,fielddisplay(self,'riftstruct','structure containing all rift information (vertices coordinates, segments, type of melange, ...)'))
+		string="%s\n%s"%(string,fielddisplay(self,'riftstruct','structure containing all rift information (vertices coordinates, segments, type of melange, ...)'))
 		string="%s\n%s"%(string,fielddisplay(self,'riftproperties',''))
 		return string
Index: /issm/trunk/src/m/classes/settings.m
===================================================================
--- /issm/trunk/src/m/classes/settings.m	(revision 14309)
+++ /issm/trunk/src/m/classes/settings.m	(revision 14310)
@@ -38,5 +38,5 @@
 			%onto the model after a parallel run by waiting for the lock file
 			%N minutes that is generated once the solution has converged
-			%0 to desactivate
+			%0 to deactivate
 			obj.waitonlock=Inf;
 		end % }}}
@@ -65,5 +65,9 @@
 			WriteData(fid,'object',obj,'fieldname','results_as_patches','format','Boolean');
 			WriteData(fid,'object',obj,'fieldname','output_frequency','format','Integer');
-			WriteData(fid,'object',obj,'fieldname','waitonlock','format','Boolean');
+			if obj.waitonlock>0,
+				WriteData(fid,'enum',SettingsWaitonlockEnum(),'data',true,'format','Boolean');
+			else
+				WriteData(fid,'enum',SettingsWaitonlockEnum(),'data',false,'format','Boolean');
+			end
 		end % }}}
 	end
Index: /issm/trunk/src/m/classes/settings.py
===================================================================
--- /issm/trunk/src/m/classes/settings.py	(revision 14309)
+++ /issm/trunk/src/m/classes/settings.py	(revision 14310)
@@ -56,6 +56,6 @@
 		#onto the model after a parallel run by waiting for the lock file
 		#N minutes that is generated once the solution has converged
-		#0 to desactivate
-		self.waitonlock=float('Inf')
+		#0 to deactivate
+		self.waitonlock=2**31-1
 
 		return self
@@ -77,5 +77,8 @@
 		WriteData(fid,'object',self,'fieldname','results_as_patches','format','Boolean')
 		WriteData(fid,'object',self,'fieldname','output_frequency','format','Integer')
-		WriteData(fid,'object',self,'fieldname','waitonlock','format','Boolean')
+		if self.waitonlock>0:
+			WriteData(fid,'enum',SettingsWaitonlockEnum(),'data',True,'format','Boolean');
+		else:
+			WriteData(fid,'enum',SettingsWaitonlockEnum(),'data',False,'format','Boolean');
 	# }}}
 
Index: /issm/trunk/src/m/classes/solver.py
===================================================================
--- /issm/trunk/src/m/classes/solver.py	(revision 14309)
+++ /issm/trunk/src/m/classes/solver.py	(revision 14310)
@@ -3,7 +3,8 @@
 from iluasmoptions import *
 from EnumToString import EnumToString
-from MatlabFuncs import *
+from fielddisplay import fielddisplay
 from EnumDefinitions import *
 from checkfield import *
+from MatlabFuncs import *
 
 class solver(object):
@@ -48,6 +49,5 @@
 		s ="List of solver options per analysis:\n\n"
 		for analysis in vars(self).iterkeys():
-			s+="%s :\n" % analysis
-			s+="%s\n" % getattr(self,analysis)
+			s+="%s\n" % fielddisplay(self,analysis,'')
 
 		return s
Index: /issm/trunk/src/m/classes/surfaceforcings.m
===================================================================
--- /issm/trunk/src/m/classes/surfaceforcings.m	(revision 14309)
+++ /issm/trunk/src/m/classes/surfaceforcings.m	(revision 14310)
@@ -11,12 +11,7 @@
 		issmbgradients = 0;
 		isdelta18o = 0;
-		hc = NaN;
 		href = NaN;
 		smbref = NaN;
-		smb_pos_max = NaN;
-		smb_pos_min = NaN;
-		a_pos = NaN;
 		b_pos = NaN;
-		a_neg = NaN;
 		b_neg = NaN;
 		monthlytemperatures = NaN;
@@ -61,12 +56,7 @@
 					end
 				elseif(obj.issmbgradients)
-					md = checkfield(md,'surfaceforcings.hc','forcing',1,'NaN',1);
 					md = checkfield(md,'surfaceforcings.href','forcing',1,'NaN',1);
 					md = checkfield(md,'surfaceforcings.smbref','forcing',1,'NaN',1);
-					md = checkfield(md,'surfaceforcings.smb_pos_max','forcing',1,'NaN',1);
-					md = checkfield(md,'surfaceforcings.smb_pos_min','forcing',1,'NaN',1);
-					md = checkfield(md,'surfaceforcings.a_pos','forcing',1,'NaN',1);
 					md = checkfield(md,'surfaceforcings.b_pos','forcing',1,'NaN',1);
-					md = checkfield(md,'surfaceforcings.a_neg','forcing',1,'NaN',1);
 					md = checkfield(md,'surfaceforcings.b_neg','forcing',1,'NaN',1);
 				else
@@ -92,12 +82,7 @@
 			fielddisplay(obj,'delta18o_surface','surface elevation of the delta18o site, required if pdd is activated and delta18o activated');
 			fielddisplay(obj,'issmbgradients','is smb gradients method activated (0 or 1, default is 0)');
-			fielddisplay(obj,'hc',' elevation of intersection between accumulation and ablation regime required if smb gradients is activated');
 			fielddisplay(obj,'href',' reference elevation from which deviation is used to calculate SMB adjustment in smb gradients method');
 			fielddisplay(obj,'smbref',' reference smb from which deviation is calculated in smb gradients method');
-			fielddisplay(obj,'smb_pos_max',' maximum value of positive smb required if smb gradients is activated');
-			fielddisplay(obj,'smb_pos_min',' minimum value of positive smb required if smb gradients is activated');
-			fielddisplay(obj,'a_pos',' intercept of hs - smb regression line for accumulation regime required if smb gradients is activated');
 			fielddisplay(obj,'b_pos',' slope of hs - smb regression line for accumulation regime required if smb gradients is activated');
-			fielddisplay(obj,'a_neg',' intercept of hs - smb regression line for ablation regime required if smb gradients is activated');
 			fielddisplay(obj,'b_neg',' slope of hs - smb regression line for ablation regime required if smb gradients is activated');
 
@@ -122,12 +107,7 @@
 			WriteData(fid,'object',obj,'fieldname','issmbgradients','format','Boolean');
 			if obj.issmbgradients,
-				WriteData(fid,'object',obj,'fieldname','hc','format','DoubleMat','mattype',1);
 				WriteData(fid,'object',obj,'fieldname','href','format','DoubleMat','mattype',1);
 				WriteData(fid,'object',obj,'fieldname','smbref','format','DoubleMat','mattype',1);
-				WriteData(fid,'object',obj,'fieldname','smb_pos_max','format','DoubleMat','mattype',1);
-				WriteData(fid,'object',obj,'fieldname','smb_pos_min','format','DoubleMat','mattype',1);
-				WriteData(fid,'object',obj,'fieldname','a_pos','format','DoubleMat','mattype',1);
 				WriteData(fid,'object',obj,'fieldname','b_pos','format','DoubleMat','mattype',1);
-				WriteData(fid,'object',obj,'fieldname','a_neg','format','DoubleMat','mattype',1);
 				WriteData(fid,'object',obj,'fieldname','b_neg','format','DoubleMat','mattype',1);
 			end
Index: /issm/trunk/src/m/classes/surfaceforcings.py
===================================================================
--- /issm/trunk/src/m/classes/surfaceforcings.py	(revision 14309)
+++ /issm/trunk/src/m/classes/surfaceforcings.py	(revision 14310)
@@ -21,12 +21,7 @@
 		self.issmbgradients = 0
 		self.isdelta18o = 0
-		self.hc = float('NaN')
 		self.href = float('NaN')
 		self.smbref = float('NaN')
-		self.smb_pos_max = float('NaN')
-		self.smb_pos_min = float('NaN')
-		self.a_pos = float('NaN')
 		self.b_pos = float('NaN')
-		self.a_neg = float('NaN')
 		self.b_neg = float('NaN')
 		self.monthlytemperatures = float('NaN')
@@ -45,5 +40,5 @@
 		string="   surface forcings parameters:"
 
-		string="%s\n\n%s"%(string,fielddisplay(self,'precipitation','surface precipitation [m/yr water eq]'))
+		string="%s\n%s"%(string,fielddisplay(self,'precipitation','surface precipitation [m/yr water eq]'))
 		string="%s\n%s"%(string,fielddisplay(self,'mass_balance','surface mass balance [m/yr ice eq]'))
 		string="%s\n%s"%(string,fielddisplay(self,'ispdd','is pdd activated (0 or 1, default is 0)'))
@@ -57,17 +52,11 @@
 		string="%s\n%s"%(string,fielddisplay(self,'delta18o_surface','surface elevation of the delta18o site, required if pdd is activated and delta18o activated'))
 		string="%s\n%s"%(string,fielddisplay(self,'issmbgradients','is smb gradients method activated (0 or 1, default is 0)'))
-		string="%s\n%s"%(string,fielddisplay(self,'hc',' elevation of intersection between accumulation and ablation regime required if smb gradients is activated'))
 		string="%s\n%s"%(string,fielddisplay(self,'href',' reference elevation from which deviation is used to calculate SMB adjustment in smb gradients method'))
 		string="%s\n%s"%(string,fielddisplay(self,'smbref',' reference smb from which deviation is calculated in smb gradients method'))
-		string="%s\n%s"%(string,fielddisplay(self,'smb_pos_max',' maximum value of positive smb required if smb gradients is activated'))
-		string="%s\n%s"%(string,fielddisplay(self,'smb_pos_min',' minimum value of positive smb required if smb gradients is activated'))
-		string="%s\n%s"%(string,fielddisplay(self,'a_pos',' intercept of hs - smb regression line for accumulation regime required if smb gradients is activated'))
 		string="%s\n%s"%(string,fielddisplay(self,'b_pos',' slope of hs - smb regression line for accumulation regime required if smb gradients is activated'))
-		string="%s\n%s"%(string,fielddisplay(self,'a_neg',' intercept of hs - smb regression line for ablation regime required if smb gradients is activated'))
 		string="%s\n%s"%(string,fielddisplay(self,'b_neg',' slope of hs - smb regression line for ablation regime required if smb gradients is activated'))
 
 		return string
 		#}}}
-		
 	def setdefaultparameters(self):
 		# {{{setdefaultparameters
@@ -97,12 +86,7 @@
 					md = checkfield(md,'surfaceforcings.precipitations_presentday','size',[md.mesh.numberofvertices+1,12],'NaN',1)
 			elif self.issmbgradients:
-				md = checkfield(md,'surfaceforcings.hc','forcing',1,'NaN',1)
 				md = checkfield(md,'surfaceforcings.href','forcing',1,'NaN',1)
 				md = checkfield(md,'surfaceforcings.smbref','forcing',1,'NaN',1)
-				md = checkfield(md,'surfaceforcings.smb_pos_max','forcing',1,'NaN',1)
-				md = checkfield(md,'surfaceforcings.smb_pos_min','forcing',1,'NaN',1)
-				md = checkfield(md,'surfaceforcings.a_pos','forcing',1,'NaN',1)
 				md = checkfield(md,'surfaceforcings.b_pos','forcing',1,'NaN',1)
-				md = checkfield(md,'surfaceforcings.a_neg','forcing',1,'NaN',1)
 				md = checkfield(md,'surfaceforcings.b_neg','forcing',1,'NaN',1)
 			else:
@@ -135,12 +119,7 @@
 
 		if self.issmbgradients:
-			WriteData(fid,'object',self,'fieldname','hc','format','DoubleMat','mattype',1)
 			WriteData(fid,'object',self,'fieldname','href','format','DoubleMat','mattype',1)
 			WriteData(fid,'object',self,'fieldname','smbref','format','DoubleMat','mattype',1)
-			WriteData(fid,'object',self,'fieldname','smb_pos_max','format','DoubleMat','mattype',1)
-			WriteData(fid,'object',self,'fieldname','smb_pos_min','format','DoubleMat','mattype',1)
-			WriteData(fid,'object',self,'fieldname','a_pos','format','DoubleMat','mattype',1)
 			WriteData(fid,'object',self,'fieldname','b_pos','format','DoubleMat','mattype',1)
-			WriteData(fid,'object',self,'fieldname','a_neg','format','DoubleMat','mattype',1)
 			WriteData(fid,'object',self,'fieldname','b_neg','format','DoubleMat','mattype',1)
 	# }}}
Index: /issm/trunk/src/m/classes/taoinversion.m
===================================================================
--- /issm/trunk/src/m/classes/taoinversion.m	(revision 14310)
+++ /issm/trunk/src/m/classes/taoinversion.m	(revision 14310)
@@ -0,0 +1,160 @@
+%INVERSION class definition
+%
+%   Usage:
+%      taoinversion=taoinversion();
+
+classdef taoinversion
+	properties (SetAccess=public) 
+		iscontrol                   = 0
+		incomplete_adjoint          = 0
+		control_parameters          = NaN
+		nsteps                      = 0
+		cost_functions              = NaN
+		cost_functions_coefficients = NaN
+		min_parameters              = NaN
+		max_parameters              = NaN
+		vx_obs                      = NaN
+		vy_obs                      = NaN
+		vz_obs                      = NaN
+		vel_obs                     = NaN
+		thickness_obs               = NaN
+	end
+	methods
+		function obj = taoinversion(varargin) % {{{
+			switch nargin
+				case 0
+					obj=setdefaultparameters(obj);
+				case 1
+					if isa(varargin{1},'inversion'),
+						disp('converting inversion to taoinversion');
+						in=varargin{1};
+						obj.iscontrol                   = in.iscontrol;
+						obj.incomplete_adjoint          = in.incomplete_adjoint;
+						obj.control_parameters          = in.control_parameters;
+						obj.nsteps                      = in.nsteps;
+						obj.cost_functions              = in.cost_functions(1,:); %Keep first line only
+						obj.cost_functions_coefficients = in.cost_functions_coefficients;
+						obj.min_parameters              = in.min_parameters;
+						obj.max_parameters              = in.max_parameters;
+						obj.vx_obs                      = in.vx_obs;
+						obj.vy_obs                      = in.vy_obs;
+						obj.vz_obs                      = in.vz_obs;
+						obj.vel_obs                     = in.vel_obs;
+						obj.thickness_obs               = in.thickness_obs;
+					end
+				otherwise
+					error('constructor not supported');
+			end
+		end % }}}
+		function obj = setdefaultparameters(obj) % {{{
+
+			%default is incomplete adjoint for now
+			obj.incomplete_adjoint=1;
+
+			%parameter to be inferred by control methods (only
+			%drag and B are supported yet)
+			obj.control_parameters={'FrictionCoefficient'};
+
+			%number of steps in the control methods
+			obj.nsteps=20;
+
+			%several responses can be used:
+			obj.cost_functions=101*ones(obj.nsteps,1);
+
+		end % }}}
+		function md = checkconsistency(obj,md,solution,analyses) % {{{
+
+			%Early return
+			if ~obj.iscontrol, return; end
+
+			num_controls=numel(md.inversion.control_parameters);
+			num_costfunc=size(md.inversion.cost_functions,2);
+
+			md = checkfield(md,'inversion.iscontrol','values',[0 1]);
+			md = checkfield(md,'inversion.incomplete_adjoint','values',[0 1]);
+			md = checkfield(md,'inversion.control_parameters','cell',1,'values',...
+				{'BalancethicknessThickeningRate' 'FrictionCoefficient' 'MaterialsRheologyBbar' 'MaterialsRheologyZbar' 'Vx' 'Vy' 'Thickness'});
+			md = checkfield(md,'inversion.nsteps','numel',1,'>=',1);
+			md = checkfield(md,'inversion.cost_functions','size',[1 num_costfunc],'values',[101:105 201 501:506]);
+			md = checkfield(md,'inversion.cost_functions_coefficients','size',[md.mesh.numberofvertices num_costfunc],'>=',0);
+			md = checkfield(md,'inversion.min_parameters','size',[md.mesh.numberofvertices num_controls]);
+			md = checkfield(md,'inversion.max_parameters','size',[md.mesh.numberofvertices num_controls]);
+
+			if solution==BalancethicknessSolutionEnum()
+				md = checkfield(md,'inversion.thickness_obs','size',[md.mesh.numberofvertices 1],'NaN',1);
+			elseif solution==WeakBalancethicknessSolutionEnum()
+				md = checkfield(md,'inversion.thickness_obs','size',[md.mesh.numberofvertices 1],'NaN',1);
+			else
+				md = checkfield(md,'inversion.vx_obs','size',[md.mesh.numberofvertices 1],'NaN',1);
+				md = checkfield(md,'inversion.vy_obs','size',[md.mesh.numberofvertices 1],'NaN',1);
+			end
+		end % }}}
+		function disp(obj) % {{{
+			disp(sprintf('   taoinversion parameters:'));
+			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');
+			fielddisplay(obj,'cost_functions','indicate the type of response for each optimization step');
+			fielddisplay(obj,'cost_functions_coefficients','cost_functions_coefficients applied to the misfit of each vertex and for each control_parameter');
+			fielddisplay(obj,'min_parameters','absolute minimum acceptable value of the inversed parameter on each vertex');
+			fielddisplay(obj,'max_parameters','absolute maximum acceptable value of the inversed parameter on each vertex');
+			fielddisplay(obj,'vx_obs','observed velocity x component [m/a]');
+			fielddisplay(obj,'vy_obs','observed velocity y component [m/a]');
+			fielddisplay(obj,'vel_obs','observed velocity magnitude [m/a]');
+			fielddisplay(obj,'thickness_obs','observed thickness [m]');
+			disp('Available cost functions:');
+			disp('   101: SurfaceAbsVelMisfit');
+			disp('   102: SurfaceRelVelMisfit');
+			disp('   103: SurfaceLogVelMisfit');
+			disp('   104: SurfaceLogVxVyMisfit');
+			disp('   105: SurfaceAverageVelMisfit');
+			disp('   201: ThicknessAbsMisfit');
+			disp('   501: DragCoefficientAbsGradient');
+			disp('   502: RheologyBbarAbsGradient');
+			disp('   503: ThicknessAbsGradient');
+		end % }}}
+		function marshall(obj,fid) % {{{
+
+			WriteData(fid,'object',obj,'class','inversion','fieldname','iscontrol','format','Boolean');
+			WriteData(fid,'enum',InversionTaoEnum(),'data',true,'format','Boolean');
+			if ~obj.iscontrol, return; end
+			WriteData(fid,'object',obj,'class','inversion','fieldname','incomplete_adjoint','format','Boolean');
+			WriteData(fid,'object',obj,'class','inversion','fieldname','nsteps','format','Integer');
+			WriteData(fid,'object',obj,'class','inversion','fieldname','cost_functions_coefficients','format','DoubleMat','mattype',1);
+			WriteData(fid,'object',obj,'class','inversion','fieldname','min_parameters','format','DoubleMat','mattype',3);
+			WriteData(fid,'object',obj,'class','inversion','fieldname','max_parameters','format','DoubleMat','mattype',3);
+			WriteData(fid,'object',obj,'class','inversion','fieldname','vx_obs','format','DoubleMat','mattype',1);
+			WriteData(fid,'object',obj,'class','inversion','fieldname','vy_obs','format','DoubleMat','mattype',1);
+			WriteData(fid,'object',obj,'class','inversion','fieldname','vz_obs','format','DoubleMat','mattype',1);
+			WriteData(fid,'object',obj,'class','inversion','fieldname','thickness_obs','format','DoubleMat','mattype',1);
+
+			%process control parameters
+			num_control_parameters=numel(obj.control_parameters);
+			data=zeros(1,num_control_parameters);
+			for i=1:num_control_parameters,
+				data(i)=StringToEnum(obj.control_parameters{i});
+			end
+			WriteData(fid,'data',data,'enum',InversionControlParametersEnum(),'format','DoubleMat','mattype',3);
+			WriteData(fid,'data',num_control_parameters,'enum',InversionNumControlParametersEnum(),'format','Integer');
+
+			%process cost functions
+			num_cost_functions=size(obj.cost_functions,2);
+			data=obj.cost_functions;
+			pos=find(data==101); data(pos)=SurfaceAbsVelMisfitEnum();
+			pos=find(data==102); data(pos)=SurfaceRelVelMisfitEnum();
+			pos=find(data==103); data(pos)=SurfaceLogVelMisfitEnum();
+			pos=find(data==104); data(pos)=SurfaceLogVxVyMisfitEnum();
+			pos=find(data==105); data(pos)=SurfaceAverageVelMisfitEnum();
+			pos=find(data==201); data(pos)=ThicknessAbsMisfitEnum();
+			pos=find(data==501); data(pos)=DragCoefficientAbsGradientEnum();
+			pos=find(data==502); data(pos)=RheologyBbarAbsGradientEnum();
+			pos=find(data==503); data(pos)=ThicknessAbsGradientEnum();
+			pos=find(data==504); data(pos)=ThicknessAlongGradientEnum();
+			pos=find(data==505); data(pos)=ThicknessAcrossGradientEnum();
+			pos=find(data==506); data(pos)=BalancethicknessMisfitEnum();
+			WriteData(fid,'data',data,'enum',InversionCostFunctionsEnum(),'format','DoubleMat','mattype',3);
+			WriteData(fid,'data',num_cost_functions,'enum',InversionNumCostFunctionsEnum(),'format','Integer');
+		end % }}}
+	end
+end
Index: /issm/trunk/src/m/classes/thermal.py
===================================================================
--- /issm/trunk/src/m/classes/thermal.py	(revision 14309)
+++ /issm/trunk/src/m/classes/thermal.py	(revision 14310)
@@ -32,5 +32,5 @@
 		# {{{ Display
 		string='   Thermal solution parameters:'
-		string="%s\n\n%s"%(string,fielddisplay(self,'spctemperature','temperature constraints (NaN means no constraint)'))
+		string="%s\n%s"%(string,fielddisplay(self,'spctemperature','temperature constraints (NaN means no constraint)'))
 		string="%s\n%s"%(string,fielddisplay(self,'stabilization','0->no, 1->artificial_diffusivity, 2->SUPG'))
 		string="%s\n%s"%(string,fielddisplay(self,'maxiter','maximum number of non linear iterations'))
Index: /issm/trunk/src/m/classes/timestepping.m
===================================================================
--- /issm/trunk/src/m/classes/timestepping.m	(revision 14309)
+++ /issm/trunk/src/m/classes/timestepping.m	(revision 14310)
@@ -6,9 +6,9 @@
 classdef timestepping
 	properties (SetAccess=public) 
-		start_time      = 0;
-		final_time      = 0;
-		time_step       = 0;
+		start_time      = 0.;
+		final_time      = 0.;
+		time_step       = 0.;
 		time_adapt      = 0;
-		cfl_coefficient = 0;
+		cfl_coefficient = 0.;
 	end
 	methods
@@ -24,12 +24,12 @@
 
 			%time between 2 time steps
-			obj.time_step=1/2;
+			obj.time_step=1./2.;
 
 			%final time
-			obj.final_time=10*obj.time_step;
+			obj.final_time=10.*obj.time_step;
 
 			%time adaptation? 
 			obj.time_adapt=0;
-			obj.cfl_coefficient=.5;
+			obj.cfl_coefficient=0.5;
 		end % }}}
 		function md = checkconsistency(obj,md,solution,analyses) % {{{
Index: /issm/trunk/src/m/classes/timestepping.py
===================================================================
--- /issm/trunk/src/m/classes/timestepping.py	(revision 14309)
+++ /issm/trunk/src/m/classes/timestepping.py	(revision 14310)
@@ -16,9 +16,9 @@
 	def __init__(self):
 		# {{{ Properties
-		self.start_time      = 0
-		self.final_time      = 0
-		self.time_step       = 0
+		self.start_time      = 0.
+		self.final_time      = 0.
+		self.time_step       = 0.
 		self.time_adapt      = 0
-		self.cfl_coefficient = 0
+		self.cfl_coefficient = 0.
 		
 		#set defaults
@@ -29,5 +29,5 @@
 		# {{{ Display
 		string="   timestepping parameters:"
-		string="%s\n\n%s"%(string,fielddisplay(self,"start_time","simulation starting time [yrs]"))
+		string="%s\n%s"%(string,fielddisplay(self,"start_time","simulation starting time [yrs]"))
 		string="%s\n%s"%(string,fielddisplay(self,"final_time","final time to stop the simulation [yrs]"))
 		string="%s\n%s"%(string,fielddisplay(self,"time_step","length of time steps [yrs]"))
@@ -41,12 +41,12 @@
 		
 		#time between 2 time steps
-		self.time_step=1/2
+		self.time_step=1./2.
 
 		#final time
-		self.final_time=10*self.time_step
+		self.final_time=10.*self.time_step
 
 		#time adaptation? 
 		self.time_adapt=0
-		self.cfl_coefficient=.5
+		self.cfl_coefficient=0.5
 
 		return self
Index: /issm/trunk/src/m/consistency/ismodelselfconsistent.m
===================================================================
--- /issm/trunk/src/m/consistency/ismodelselfconsistent.m	(revision 14309)
+++ /issm/trunk/src/m/consistency/ismodelselfconsistent.m	(revision 14310)
@@ -69,4 +69,8 @@
 		analyses=[BalancethicknessAnalysisEnum()];
 
+	case WeakBalancethicknessSolutionEnum(),
+		numanalyses=1; 
+		analyses=[BalancethicknessAnalysisEnum()];
+
 	case SurfaceSlopeSolutionEnum(),
 		numanalyses=1; 
Index: /issm/trunk/src/m/contrib/bamg/YamsCall.m
===================================================================
--- /issm/trunk/src/m/contrib/bamg/YamsCall.m	(revision 14309)
+++ /issm/trunk/src/m/contrib/bamg/YamsCall.m	(revision 14310)
@@ -16,5 +16,5 @@
 
 %2d geometric parameter (do not change)
-scale=2/9; 
+scale=2./9.;
 
 %Compute Hessian
@@ -60,5 +60,5 @@
 	triangles=[];
 	for i=1:size(md.rifts.riftstruct,1),
-		triangles=[triangles md.rifts(i).segments(:,3)'];
+		triangles=[triangles md.rifts(i).riftstruct.segments(:,3)'];
 	end
 
@@ -76,5 +76,5 @@
 	%windows
 	system(['yams2-win -O 1 -v -0 -ecp -hgrad ' num2str(gradation)  ' carre0 carre1']);
-elseif ismac
+elseif ismac()
 	%Macosx
 	system(['yams2-osx -O 1 -v -0 -ecp -hgrad ' num2str(gradation)  ' carre0 carre1']);
Index: /issm/trunk/src/m/contrib/bamg/YamsCall.py
===================================================================
--- /issm/trunk/src/m/contrib/bamg/YamsCall.py	(revision 14310)
+++ /issm/trunk/src/m/contrib/bamg/YamsCall.py	(revision 14310)
@@ -0,0 +1,128 @@
+import numpy
+import time
+import subprocess
+import os
+from ComputeHessian import *
+from ComputeMetric import *
+from MatlabFuncs import *
+
+def YamsCall(md,field,hmin,hmax,gradation,epsilon):
+	"""
+	YAMSCALL - call yams
+
+	   build a metric using the Hessian of the given field
+	   call Yams and the output mesh is plugged onto the model
+	   -hmin = minimum edge length (m)
+	   -hmax = maximum edge length (m)
+	   -gradation = maximum edge length gradation between 2 elements
+	   -epsilon = average error on each element (m/yr)
+
+	   Usage:
+	      md=YamsCall(md,field,hmin,hmax,gradation,epsilon);
+
+	   Example:
+	      md=YamsCall(md,md.inversion.vel_obs,1500,10^8,1.3,0.9);
+	"""
+
+	#2d geometric parameter (do not change)
+	scale=2./9.
+
+	#Compute Hessian
+	t1=time.time()
+	print "%s" % '      computing Hessian...'
+	hessian=ComputeHessian(md.mesh.elements,md.mesh.x,md.mesh.y,field,'node')
+	t2=time.time()
+	print "%s%d%s\n" % (' done (',t2-t1,' seconds)')
+
+	#Compute metric
+	t1=time.time()
+	print "%s" % '      computing metric...'
+	if numpy.size(md.mask.vertexonwater)==md.mesh.numberofvertices:
+		pos=numpy.nonzero(md.mask.vertexonwater)[0]
+	else:
+		pos=numpy.empty(0,int)
+	metric=ComputeMetric(hessian,scale,epsilon,hmin,hmax,pos)
+	t2=time.time()
+	print "%s%d%s\n" % (' done (',t2-t1,' seconds)')
+
+	#write files
+	t1=time.time()
+	print "%s" % '      writing initial mesh files...'
+	numpy.savetxt('carre0.met',metric)
+
+	f=open('carre0.mesh','w')
+
+	#initialiation
+	f.write("\n%s\n%i\n" % ('MeshVersionFormatted',1))
+
+	#dimension
+	f.write("\n%s\n%i\n" % ('Dimension',2))
+
+	#Vertices
+	f.write("\n%s\n%i\n\n" % ('Vertices',md.mesh.numberofvertices))
+	for i in xrange(0,md.mesh.numberofvertices):
+		f.write("%8g %8g %i\n" % (md.mesh.x[i],md.mesh.y[i],0))
+
+	#Triangles
+	f.write("\n\n%s\n%i\n\n" % ('Triangles',md.mesh.numberofelements))
+	for i in xrange(0,md.mesh.numberofelements):
+		f.write("%i %i %i %i\n" % (md.mesh.elements[i,0],md.mesh.elements[i,1],md.mesh.elements[i,2],0))
+	numberofelements1=md.mesh.numberofelements
+
+	#Deal with rifts
+	if numpy.any(not numpy.isnan(md.rifts.riftstruct)):
+
+		#we have the list of triangles that make up the rift. keep those triangles around during refinement.
+		triangles=numpy.empty(0,int)
+		for riftstruct in md.rifts.riftstruct:
+			triangles=numpy.concatenate((triangles,riftstruct.segments[:,2]))
+
+		f.write("\n\n%s\n%i\n\n" % ('RequiredTriangles',numpy.size(triangles)))
+		for triangle in triangles:
+			f.write("%i\n" % triangle)
+
+	#close
+	f.close()
+	t2=time.time()
+	print "%s%d%s\n" % (' done (',t2-t1,' seconds)')
+
+	#call yams
+	print "%s\n" % '      call Yams...'
+	if   ispc():
+		#windows
+		subprocess.call('yams2-win -O 1 -v -0 -ecp -hgrad %g carre0 carre1' % gradation,shell=True)
+	elif ismac():
+		#Macosx
+		subprocess.call('yams2-osx -O 1 -v -0 -ecp -hgrad %g carre0 carre1' % gradation,shell=True)
+	else:
+		#Linux
+		subprocess.call('yams2-linux -O 1 -v -0 -ecp -hgrad %g carre0 carre1' % gradation,shell=True)
+
+	#plug new mesh
+	t1=time.time()
+	print "\n%s" % '      reading final mesh files...'
+	Tria=numpy.loadtxt('carre1.tria',int)
+	Coor=numpy.loadtxt('carre1.coor',float)
+	md.mesh.x=Coor[:,0]
+	md.mesh.y=Coor[:,1]
+	md.mesh.z=numpy.zeros((numpy.size(Coor,axis=0),1))
+	md.mesh.elements=Tria
+	md.mesh.numberofvertices=numpy.size(Coor,axis=0)
+	md.mesh.numberofelements=numpy.size(Tria,axis=0)
+	numberofelements2=md.mesh.numberofelements
+	t2=time.time()
+	print "%s%d%s\n\n" % (' done (',t2-t1,' seconds)')
+
+	#display number of elements
+	print "\n%s %i" % ('      inital number of elements:',numberofelements1)
+	print "\n%s %i\n\n" % ('      new    number of elements:',numberofelements2)
+
+	#clean up:
+	os.remove('carre0.mesh')
+	os.remove('carre0.met')
+	os.remove('carre1.tria')
+	os.remove('carre1.coor')
+	os.remove('carre1.meshb')
+
+	return md
+
Index: /issm/trunk/src/m/enum/AndroidFrictionCoefficientEnum.m
===================================================================
--- /issm/trunk/src/m/enum/AndroidFrictionCoefficientEnum.m	(revision 14310)
+++ /issm/trunk/src/m/enum/AndroidFrictionCoefficientEnum.m	(revision 14310)
@@ -0,0 +1,11 @@
+function macro=AndroidFrictionCoefficientEnum()
+%ANDROIDFRICTIONCOEFFICIENTENUM - Enum of AndroidFrictionCoefficient
+%
+%   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=AndroidFrictionCoefficientEnum()
+
+macro=StringToEnum('AndroidFrictionCoefficient');
Index: /issm/trunk/src/m/enum/BalancethicknessMisfitEnum.m
===================================================================
--- /issm/trunk/src/m/enum/BalancethicknessMisfitEnum.m	(revision 14310)
+++ /issm/trunk/src/m/enum/BalancethicknessMisfitEnum.m	(revision 14310)
@@ -0,0 +1,11 @@
+function macro=BalancethicknessMisfitEnum()
+%BALANCETHICKNESSMISFITENUM - Enum of BalancethicknessMisfit
+%
+%   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=BalancethicknessMisfitEnum()
+
+macro=StringToEnum('BalancethicknessMisfit');
Index: /issm/trunk/src/m/enum/EnumDefinitions.py
===================================================================
--- /issm/trunk/src/m/enum/EnumDefinitions.py	(revision 14309)
+++ /issm/trunk/src/m/enum/EnumDefinitions.py	(revision 14310)
@@ -1849,14 +1849,4 @@
 	return StringToEnum('SurfaceforcingsMonthlytemperatures')[0]
 
-def SurfaceforcingsHcEnum():
-	"""
-	SURFACEFORCINGSHCENUM - Enum of SurfaceforcingsHc
-
-	   Usage:
-	      macro=SurfaceforcingsHcEnum()
-	"""
-
-	return StringToEnum('SurfaceforcingsHc')[0]
-
 def SurfaceforcingsHrefEnum():
 	"""
@@ -1879,34 +1869,4 @@
 	return StringToEnum('SurfaceforcingsSmbref')[0]
 
-def SurfaceforcingsSmbPosMaxEnum():
-	"""
-	SURFACEFORCINGSSMBPOSMAXENUM - Enum of SurfaceforcingsSmbPosMax
-
-	   Usage:
-	      macro=SurfaceforcingsSmbPosMaxEnum()
-	"""
-
-	return StringToEnum('SurfaceforcingsSmbPosMax')[0]
-
-def SurfaceforcingsSmbPosMinEnum():
-	"""
-	SURFACEFORCINGSSMBPOSMINENUM - Enum of SurfaceforcingsSmbPosMin
-
-	   Usage:
-	      macro=SurfaceforcingsSmbPosMinEnum()
-	"""
-
-	return StringToEnum('SurfaceforcingsSmbPosMin')[0]
-
-def SurfaceforcingsAPosEnum():
-	"""
-	SURFACEFORCINGSAPOSENUM - Enum of SurfaceforcingsAPos
-
-	   Usage:
-	      macro=SurfaceforcingsAPosEnum()
-	"""
-
-	return StringToEnum('SurfaceforcingsAPos')[0]
-
 def SurfaceforcingsBPosEnum():
 	"""
@@ -1919,14 +1879,4 @@
 	return StringToEnum('SurfaceforcingsBPos')[0]
 
-def SurfaceforcingsANegEnum():
-	"""
-	SURFACEFORCINGSANEGENUM - Enum of SurfaceforcingsANeg
-
-	   Usage:
-	      macro=SurfaceforcingsANegEnum()
-	"""
-
-	return StringToEnum('SurfaceforcingsANeg')[0]
-
 def SurfaceforcingsBNegEnum():
 	"""
@@ -2219,4 +2169,24 @@
 	return StringToEnum('BalancethicknessSolution')[0]
 
+def WeakBalancethicknessAnalysisEnum():
+	"""
+	WEAKBALANCETHICKNESSANALYSISENUM - Enum of WeakBalancethicknessAnalysis
+
+	   Usage:
+	      macro=WeakBalancethicknessAnalysisEnum()
+	"""
+
+	return StringToEnum('WeakBalancethicknessAnalysis')[0]
+
+def WeakBalancethicknessSolutionEnum():
+	"""
+	WEAKBALANCETHICKNESSSOLUTIONENUM - Enum of WeakBalancethicknessSolution
+
+	   Usage:
+	      macro=WeakBalancethicknessSolutionEnum()
+	"""
+
+	return StringToEnum('WeakBalancethicknessSolution')[0]
+
 def BedSlopeAnalysisEnum():
 	"""
@@ -3299,4 +3269,14 @@
 	return StringToEnum('Adjointz')[0]
 
+def BalancethicknessMisfitEnum():
+	"""
+	BALANCETHICKNESSMISFITENUM - Enum of BalancethicknessMisfit
+
+	   Usage:
+	      macro=BalancethicknessMisfitEnum()
+	"""
+
+	return StringToEnum('BalancethicknessMisfit')[0]
+
 def BedSlopeXEnum():
 	"""
@@ -3569,4 +3549,14 @@
 	return StringToEnum('QmuMelting')[0]
 
+def AndroidFrictionCoefficientEnum():
+	"""
+	ANDROIDFRICTIONCOEFFICIENTENUM - Enum of AndroidFrictionCoefficient
+
+	   Usage:
+	      macro=AndroidFrictionCoefficientEnum()
+	"""
+
+	return StringToEnum('AndroidFrictionCoefficient')[0]
+
 def ResetPenaltiesEnum():
 	"""
@@ -3999,14 +3989,4 @@
 	return StringToEnum('TransientInput')[0]
 
-def OutputfilenameEnum():
-	"""
-	OUTPUTFILENAMEENUM - Enum of Outputfilename
-
-	   Usage:
-	      macro=OutputfilenameEnum()
-	"""
-
-	return StringToEnum('Outputfilename')[0]
-
 def WaterfractionEnum():
 	"""
@@ -4997,4 +4977,4 @@
 	"""
 
-	return 498
-
+	return 496
+
Index: /issm/trunk/src/m/enum/MaximumNumberOfEnums.m
===================================================================
--- /issm/trunk/src/m/enum/MaximumNumberOfEnums.m	(revision 14309)
+++ /issm/trunk/src/m/enum/MaximumNumberOfEnums.m	(revision 14310)
@@ -9,3 +9,3 @@
 %      macro=MaximumNumberOfEnums()
 
-macro=498;
+macro=496;
Index: /issm/trunk/src/m/enum/OutputFileNameEnum.m
===================================================================
--- /issm/trunk/src/m/enum/OutputFileNameEnum.m	(revision 14310)
+++ /issm/trunk/src/m/enum/OutputFileNameEnum.m	(revision 14310)
@@ -0,0 +1,11 @@
+function macro=OutputFileNameEnum()
+%OUTPUTFILENAMEENUM - Enum of OutputFileName
+%
+%   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=OutputFileNameEnum()
+
+macro=StringToEnum('OutputFileName');
Index: sm/trunk/src/m/enum/OutputfilenameEnum.m
===================================================================
--- /issm/trunk/src/m/enum/OutputfilenameEnum.m	(revision 14309)
+++ 	(revision )
@@ -1,11 +1,0 @@
-function macro=OutputFileNameEnum()
-%OUTPUTFILENAMEENUM - Enum of OutputFileName
-%
-%   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=OutputFileNameEnum()
-
-macro=StringToEnum('OutputFileName');
Index: sm/trunk/src/m/enum/SurfaceforcingsANegEnum.m
===================================================================
--- /issm/trunk/src/m/enum/SurfaceforcingsANegEnum.m	(revision 14309)
+++ 	(revision )
@@ -1,11 +1,0 @@
-function macro=SurfaceforcingsANegEnum()
-%SURFACEFORCINGSANEGENUM - Enum of SurfaceforcingsANeg
-%
-%   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=SurfaceforcingsANegEnum()
-
-macro=StringToEnum('SurfaceforcingsANeg');
Index: sm/trunk/src/m/enum/SurfaceforcingsAPosEnum.m
===================================================================
--- /issm/trunk/src/m/enum/SurfaceforcingsAPosEnum.m	(revision 14309)
+++ 	(revision )
@@ -1,11 +1,0 @@
-function macro=SurfaceforcingsAPosEnum()
-%SURFACEFORCINGSAPOSENUM - Enum of SurfaceforcingsAPos
-%
-%   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=SurfaceforcingsAPosEnum()
-
-macro=StringToEnum('SurfaceforcingsAPos');
Index: sm/trunk/src/m/enum/SurfaceforcingsHcEnum.m
===================================================================
--- /issm/trunk/src/m/enum/SurfaceforcingsHcEnum.m	(revision 14309)
+++ 	(revision )
@@ -1,11 +1,0 @@
-function macro=SurfaceforcingsHcEnum()
-%SURFACEFORCINGSHCENUM - Enum of SurfaceforcingsHc
-%
-%   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=SurfaceforcingsHcEnum()
-
-macro=StringToEnum('SurfaceforcingsHc');
Index: sm/trunk/src/m/enum/SurfaceforcingsSmbPosMaxEnum.m
===================================================================
--- /issm/trunk/src/m/enum/SurfaceforcingsSmbPosMaxEnum.m	(revision 14309)
+++ 	(revision )
@@ -1,11 +1,0 @@
-function macro=SurfaceforcingsSmbPosMaxEnum()
-%SURFACEFORCINGSSMBPOSMAXENUM - Enum of SurfaceforcingsSmbPosMax
-%
-%   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=SurfaceforcingsSmbPosMaxEnum()
-
-macro=StringToEnum('SurfaceforcingsSmbPosMax');
Index: sm/trunk/src/m/enum/SurfaceforcingsSmbPosMinEnum.m
===================================================================
--- /issm/trunk/src/m/enum/SurfaceforcingsSmbPosMinEnum.m	(revision 14309)
+++ 	(revision )
@@ -1,11 +1,0 @@
-function macro=SurfaceforcingsSmbPosMinEnum()
-%SURFACEFORCINGSSMBPOSMINENUM - Enum of SurfaceforcingsSmbPosMin
-%
-%   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=SurfaceforcingsSmbPosMinEnum()
-
-macro=StringToEnum('SurfaceforcingsSmbPosMin');
Index: /issm/trunk/src/m/enum/WeakBalancethicknessAnalysisEnum.m
===================================================================
--- /issm/trunk/src/m/enum/WeakBalancethicknessAnalysisEnum.m	(revision 14310)
+++ /issm/trunk/src/m/enum/WeakBalancethicknessAnalysisEnum.m	(revision 14310)
@@ -0,0 +1,11 @@
+function macro=WeakBalancethicknessAnalysisEnum()
+%WEAKBALANCETHICKNESSANALYSISENUM - Enum of WeakBalancethicknessAnalysis
+%
+%   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=WeakBalancethicknessAnalysisEnum()
+
+macro=StringToEnum('WeakBalancethicknessAnalysis');
Index: /issm/trunk/src/m/enum/WeakBalancethicknessSolutionEnum.m
===================================================================
--- /issm/trunk/src/m/enum/WeakBalancethicknessSolutionEnum.m	(revision 14310)
+++ /issm/trunk/src/m/enum/WeakBalancethicknessSolutionEnum.m	(revision 14310)
@@ -0,0 +1,11 @@
+function macro=WeakBalancethicknessSolutionEnum()
+%WEAKBALANCETHICKNESSSOLUTIONENUM - Enum of WeakBalancethicknessSolution
+%
+%   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=WeakBalancethicknessSolutionEnum()
+
+macro=StringToEnum('WeakBalancethicknessSolution');
Index: /issm/trunk/src/m/exp/expwrite.m
===================================================================
--- /issm/trunk/src/m/exp/expwrite.m	(revision 14309)
+++ /issm/trunk/src/m/exp/expwrite.m	(revision 14310)
@@ -15,4 +15,16 @@
 %   See also EXPDOC, EXPREAD, EXPWRITEASVERTICES
 
+%check input variable
+if ~isstruct(a),
+	error('first argument is not a structure');
+end
+
+%Add density if it's not there
+if ~isfield(a,'density'),
+	for n=1:length(a),
+		a(n).density=1;
+	end
+end
+
 fid=fopen(filename,'w');
 for n=1:length(a),
@@ -22,11 +34,7 @@
 
 	if isfield(a,'name'),
-		if ~isempty(a(n).name),
-			fprintf(fid,'%s%s\n','## Name:',a(n).name);
-		else
-			fprintf(fid,'%s\n','## Name:');
-		end
+		fprintf(fid,'%s%s\n','## Name:',a(n).name);
 	else
-		fprintf(fid,'%s\n','## Name:');
+		fprintf(fid,'%s%s\n','## Name:',filename);
 	end
 
@@ -35,5 +43,5 @@
 	fprintf(fid,'%i %f\n',[length(a(n).x) a(n).density]);
 	fprintf(fid,'%s\n','# X pos Y pos');
-	fprintf(fid,'%10.10f %10.10f\n',[a(n).x a(n).y]');
+	fprintf(fid,'%10.10f %10.10f\n',[a(n).x(:) a(n).y(:)]');
 	fprintf(fid,'\n');
 
Index: /issm/trunk/src/m/exp/expwrite.py
===================================================================
--- /issm/trunk/src/m/exp/expwrite.py	(revision 14309)
+++ /issm/trunk/src/m/exp/expwrite.py	(revision 14310)
@@ -25,11 +25,12 @@
    
 		if 'name' in contour:
-			if contour['name']:
-				fid.write("%s%s\n" % ('## Name:',contour['name']))
-			else:
-				fid.write("%s\n" % '## Name:')
+			fid.write("%s%s\n" % ('## Name:',contour['name']))
 		else:
-			fid.write("%s\n" % '## Name:')
+			fid.write("%s%s\n" % ('## Name:',filename))
    
+		#Add density if it's not there
+		if 'density' not in contour:
+			contour['density']=1
+
 		fid.write("%s\n" % '## Icon:0')
 		fid.write("%s\n" % '# Points Count Value')
Index: /issm/trunk/src/m/exp/flowlines.m
===================================================================
--- /issm/trunk/src/m/exp/flowlines.m	(revision 14309)
+++ /issm/trunk/src/m/exp/flowlines.m	(revision 14310)
@@ -38,5 +38,6 @@
 
 %check seed points
-tria=TriaSearch(index,x,y,x0,y0);
+%tria=TriaSearch(index,x,y,x0,y0);
+tria=tsearch(x,y,index,x0,y0);
 pos=find(isnan(tria));
 x0(pos)=[];
@@ -69,5 +70,6 @@
 	%find current triangle
 	queue=find(~done);
-	tria=TriaSearch(index,x,y,X(queue),Y(queue));
+	%tria=TriaSearch(index,x,y,X(queue),Y(queue));
+	tria=tsearch(x,y,index,X(queue),Y(queue));
 
 	%check that the point is actually inside a triangle of the mesh
@@ -118,5 +120,6 @@
 	%find current triangle
 	queue=find(~done);
-	tria=TriaSearch(index,x,y,X(queue),Y(queue));
+	%tria=TriaSearch(index,x,y,X(queue),Y(queue));
+	tria=tsearch(x,y,index,X(queue),Y(queue));
 
 	%check that the point is actually inside a triangle of the mesh
Index: /issm/trunk/src/m/geometry/FlagElements.py
===================================================================
--- /issm/trunk/src/m/geometry/FlagElements.py	(revision 14309)
+++ /issm/trunk/src/m/geometry/FlagElements.py	(revision 14310)
@@ -4,4 +4,5 @@
 from ContourToMesh import *
 from MatlabFuncs import *
+from PythonFuncs import *
 
 def FlagElements(md,region):
@@ -43,9 +44,9 @@
 				raise RuntimeError("FlagElements.py calling basinzoom.py is not complete.")
 				xlim,ylim=basinzoom('basin',region)
-				flag_nodes=numpy.logical_and(numpy.logical_and(md.mesh.x<xlim[1],md.mesh.x>xlim[0]),numpy.logical_and(md.mesh.y<ylim[1],md.mesh.y>ylim[0]))
+				flag_nodes=logical_and_n(md.mesh.x<xlim[1],md.mesh.x>xlim[0],md.mesh.y<ylim[1],md.mesh.y>ylim[0])
 				flag=numpy.prod(flag_nodes[md.mesh.elements],axis=1).astype(bool)
 			else:
 				#ok, flag elements
-				[flag,dum]=ContourToMesh(md.mesh.elements[:,0:3].copy(),md.mesh.x.reshape(-1,1),md.mesh.y.reshape(-1,1),region,'element',1)
+				[flag,dum]=ContourToMesh(md.mesh.elements[:,0:3].copy(),md.mesh.x,md.mesh.y,region,'element',1)
 				flag=flag.astype(bool)
 
Index: /issm/trunk/src/m/io/getShapeTypeInfo.m
===================================================================
--- /issm/trunk/src/m/io/getShapeTypeInfo.m	(revision 14310)
+++ /issm/trunk/src/m/io/getShapeTypeInfo.m	(revision 14310)
@@ -0,0 +1,181 @@
+function result = getShapeTypeInfo(shapeTypeCode,requestOrQuery)
+
+% CAUTION:  This file contains experimental code that has had only
+%           minimal, informal testing.
+%
+%GETSHAPETYPEINFO   Get information about a shape type.
+%   Returns a single value, based on the second argument:
+%     'TypeString'             -- Return a string
+%     'IsValid'                -- Return a scalar logical
+%     'IsSupported'            -- Return a scalar logical
+%     'BoundingBoxSubscripts'  -- Return a 1-by-n double array
+%     'ShapeRecordReadFcn'     -- Return a function handle
+%     'ShapeDataFieldNames'    -- Return a cell array of string.
+
+% Copyright 1996-2010 The MathWorks, Inc.
+% $Revision$  $Date$
+
+lutFields = { 'TypeCode',...
+              'TypeString',...
+              'IsValid',...
+              'IsSupported',...
+              'BoundingBoxSubscripts',...
+              'ShapeRecordReadFcn',...
+              'ShapeDataFieldNames' };
+
+% Three kinds of bounding box subscripts
+bbs2D = [1 2; 3 4];
+bbsZ  = [1 2 5; 3 4 6]; % Ignore M for now, otherwise use [1 2 5 7; 3 4 6 8]
+bbsM  = [1 2 7; 3 4 8];
+
+typeLUT = {...
+   -1, 'Not Valid',   false, false, [],    [], {''};... 
+    0, 'Null Shape',  true,  true,  [],    [], {''};... 
+    1, 'Point',       true,  true,  bbs2D, @readPoint,      {'Geometry','X','Y'};... 
+    3, 'PolyLine',    true,  true,  bbs2D, @readPolyLine,   {'Geometry','BoundingBox','X','Y'};...
+    5, 'Polygon',     true,  true,  bbs2D, @readPolygon,    {'Geometry','BoundingBox','X','Y'};...
+    8, 'MultiPoint',  true,  true,  bbs2D, @readMultiPoint, {'Geometry','BoundingBox','X','Y'};...
+   11, 'PointZ',      true,  false, bbsZ,  [], {''};...
+   13, 'PolyLineZ',   true,  true,  bbsZ,  @readPolyLineZ,  {'Geometry','BoundingBox','X','Y','Z'};... 
+   15, 'PolygonZ',    true,  true,  bbsZ,  @readPolygonZ,   {'Geometry','BoundingBox','X','Y','Z'};... 
+   18, 'MultiPointZ', true,  false, bbsZ,  [], {''};... 
+   21, 'PointM',      true,  false, bbsM,  [], {''};... 
+   23, 'PolyLineM',   true,  false, bbsM,  [], {''};... 
+   25, 'PolygonM',    true,  false, bbsM,  [], {''};... 
+   28, 'MultiPointM', true,  false, bbsM,  [], {''};... 
+   31, 'MultiPatch',  true,  false, bbsZ,  [], {''};... 
+  };
+notValidRow = 1;
+types = [typeLUT{:,1}];
+
+% MAINTENANCE NOTE: To add support for additional types, add more rows
+% to the type look up table (typeLUT), but be sure to keep 'Not Valid'
+% in the first row.
+
+row = find(shapeTypeCode == types);
+if length(row) ~= 1
+    row = notValidRow;
+end
+
+col = strmatch(lower(requestOrQuery),lower(lutFields));
+if length(col) ~= 1;
+    eid = sprintf('%s:%s:internalProblem',getcomp,mfilename);
+    error(eid,'Internal error: Invalid second argument in private function.');
+end
+
+result = typeLUT{row,col};
+
+%---------------------------------------------------------------------------
+function shp = readPoint(fid)
+
+point = fread(fid,[2 1],'double','ieee-le');
+shp = {'Point', point(1), point(2)};
+
+%---------------------------------------------------------------------------
+function shp = readMultiPoint(fid)
+
+boundingBox    = fread(fid,4,'double','ieee-le');
+numPoints      = fread(fid,1,'uint32','ieee-le');
+points         = fread(fid,[2 numPoints],'double','ieee-le')';
+shp = {'MultiPoint', boundingBox([1 2; 3 4]), points(:,1)', points(:,2)'};
+
+%---------------------------------------------------------------------------
+function shp = readPolyLine(fid)
+
+boundingBox    = fread(fid,4,'double','ieee-le');
+numPartsPoints = fread(fid,2,'uint32','ieee-le');
+partOffsets    = fread(fid,[1 numPartsPoints(1)],'uint32','ieee-le');
+points         = fread(fid,[2 numPartsPoints(2)],'double','ieee-le')';
+[x,y] = organizeParts2D(partOffsets,points);
+shp = {'Line', boundingBox([1 2; 3 4]), x, y};
+
+%---------------------------------------------------------------------------
+function shp = readPolygon(fid)
+
+boundingBox    = fread(fid,4,'double','ieee-le');
+numPartsPoints = fread(fid,2,'uint32','ieee-le');
+partOffsets    = fread(fid,[1 numPartsPoints(1)],'uint32','ieee-le');
+points         = fread(fid,[2 numPartsPoints(2)],'double','ieee-le')';
+[x,y] = organizeParts2D(partOffsets,points);
+shp = {'Polygon', boundingBox([1 2; 3 4]), x, y};
+
+%---------------------------------------------------------------------------
+function [x,y] = organizeParts2D(partOffsets,points)
+
+numParts  = size(partOffsets,2);
+numPoints = size(points,1);
+% Initialize x and y to be row vectors of NaN
+% with length numPoints * numParts
+x = NaN + zeros(1, numPoints + numParts);
+y = x;
+if numParts == 1
+    x(1, 1:numPoints) = points(:,1);
+    y(1, 1:numPoints) = points(:,2);
+else
+    partStart = 1 + partOffsets;
+    partEnd   = [partOffsets(2:end) numPoints];
+    for k = 1:numParts
+        xyStart = partStart(k) + (k - 1);
+        xyEnd   = partEnd(k)   + (k - 1);
+        x(1, xyStart:xyEnd) = points(partStart(k):partEnd(k), 1);
+        y(1, xyStart:xyEnd) = points(partStart(k):partEnd(k), 2);
+    end
+end
+
+%---------------------------------------------------------------------------
+function shp = readPolyLineZ(fid)
+
+boundingBox    = fread(fid,4,'double','ieee-le');
+numPartsPoints = fread(fid,2,'uint32','ieee-le');
+partOffsets    = fread(fid,[1 numPartsPoints(1)],'uint32','ieee-le');
+points         = fread(fid,[2 numPartsPoints(2)],'double','ieee-le')';
+zRange         = fread(fid,2,'double','ieee-le'); %#ok
+zArray         = fread(fid, numPartsPoints(2), 'double', 'ieee-le');
+[x,y,z] = organizeParts3D(partOffsets,points,zArray);
+% shp = {'Line', [boundingBox([1 2; 3 4]) zRange], x, y, z};
+% Note:
+%   Keep bounding box 2-D for now for compatibility with
+%   mapshow and geoshow.
+shp = {'Line', boundingBox([1 2; 3 4]), x, y, z};
+
+%---------------------------------------------------------------------------
+function shp = readPolygonZ(fid)
+
+boundingBox    = fread(fid,4,'double','ieee-le');
+numPartsPoints = fread(fid,2,'uint32','ieee-le');
+partOffsets    = fread(fid,[1 numPartsPoints(1)],'uint32','ieee-le');
+points         = fread(fid,[2 numPartsPoints(2)],'double','ieee-le')';
+zRange         = fread(fid,2,'double','ieee-le'); %#ok
+zArray         = fread(fid, numPartsPoints(2), 'double', 'ieee-le');
+[x,y,z] = organizeParts3D(partOffsets,points,zArray);
+% shp = {'Polygon', [boundingBox([1 2; 3 4]) zRange], x, y, z};
+% Note:
+%   Keep bounding box 2-D for now for compatibility with
+%   mapshow and geoshow.
+shp = {'Polygon', boundingBox([1 2; 3 4]), x, y, z};
+
+%---------------------------------------------------------------------------
+function [x,y,z] = organizeParts3D(partOffsets,points,zArray)
+
+numParts  = size(partOffsets,2);
+numPoints = size(points,1);
+% Initialize x and y to be row vectors of NaN
+% with length numPoints * numParts
+x = NaN + zeros(1, numPoints + numParts);
+y = x;
+z = x;
+if numParts == 1
+    x(1, 1:numPoints) = points(:,1);
+    y(1, 1:numPoints) = points(:,2);
+    z(1, 1:numPoints) = zArray(:,1);
+else
+    partStart = 1 + partOffsets;
+    partEnd   = [partOffsets(2:end) numPoints];
+    for k = 1:numParts
+        xyzStart = partStart(k) + (k - 1);
+        xyzEnd   = partEnd(k)   + (k - 1);
+        x(1, xyzStart:xyzEnd) = points(partStart(k):partEnd(k), 1);
+        y(1, xyzStart:xyzEnd) = points(partStart(k):partEnd(k), 2);
+        z(1, xyzStart:xyzEnd) = zArray(partStart(k):partEnd(k), 1);
+    end
+end
Index: sm/trunk/src/m/kml/exp2kml.m
===================================================================
--- /issm/trunk/src/m/kml/exp2kml.m	(revision 14309)
+++ 	(revision )
@@ -1,17 +1,0 @@
-function exp2kml(input,output)
-%EXP2KML: transform Argus exp file to kml
-%
-% Usage:    exp2kml('temp.exp','temp2.kml')
-%
-%
-
-%First, read exp file
-domain=expread(input);
-
-%then transform: 
-string=ge_plot(domain.x,domain.y,'name',domain.name);
-
-%open kml file for writing: 
-fid=fopen(output,'w');
-fprintf(fid,'%s',string);
-fclose(fid);
Index: /issm/trunk/src/m/mech/mechanicalproperties.m
===================================================================
--- /issm/trunk/src/m/mech/mechanicalproperties.m	(revision 14309)
+++ /issm/trunk/src/m/mech/mechanicalproperties.m	(revision 14310)
@@ -119,10 +119,10 @@
 
 strainrate=struct('xx',[],'yy',[],'xy',[],'principalvalue1',[],'principalaxis1',[],'principalvalue2',[],'principalaxis2',[],'effectivevalue',[]);
-strainrate.xx=ux;
-strainrate.yy=vy;
-strainrate.xy=uyvx;
-strainrate.principalvalue1=valuesstrain(:,1)*(365.25*24*3600); %strain rate in 1/a instead of 1/s
+strainrate.xx=ux*md.constants.yts; %strain rate in 1/a instead of 1/s
+strainrate.yy=vy*md.constants.yts; 
+strainrate.xy=uyvx*md.constants.yts; 
+strainrate.principalvalue1=valuesstrain(:,1)*md.constants.yts; 
 strainrate.principalaxis1=directionsstrain(:,1:2);
-strainrate.principalvalue2=valuesstrain(:,2)*(365.25*24*3600); %strain rate in 1/a instead of 1/s
+strainrate.principalvalue2=valuesstrain(:,2)*md.constants.yts; 
 strainrate.principalaxis2=directionsstrain(:,3:4);
 strainrate.effectivevalue=1/sqrt(2)*sqrt(strainrate.xx.^2+strainrate.yy.^2+2*strainrate.xy.^2);
Index: /issm/trunk/src/m/mech/strainrateuncert.m
===================================================================
--- /issm/trunk/src/m/mech/strainrateuncert.m	(revision 14310)
+++ /issm/trunk/src/m/mech/strainrateuncert.m	(revision 14310)
@@ -0,0 +1,71 @@
+function md=strainratuncert(md,vx,vy,dvx,dvy)
+%STRAINRATEUNCERT - compute uncertainty in strain rate components
+%
+%   this routine computes the uncertainties in the strain rate tensor
+%	 components given the uncertainty in surface velocity data.
+%   The results are stored in md.results
+%
+%	 'dvx' and 'dvy' are velocity errors in x and y components.  These 
+%	 can either be scalars or arrays of length md.mesh.numberofvertices
+%
+%   Usage:
+%      md=strainrateuncert(md,vx,vy,dv)
+%
+%   Example:
+%      md=mechanicalproperties(md,md.initialization.vx,md.initialization.vy,5);
+%      md=mechanicalproperties(md,md.inversion.vx_obs,md.inversion.vy_obs,dv);
+
+%some checks
+if length(vx)~=md.mesh.numberofvertices | length(vy)~=md.mesh.numberofvertices,
+	error(['the input velocity should be of size ' num2str(md.mesh.numberofvertices) '!'])
+end
+if length(dvx)==1,
+	dvx=dvx*ones(md.mesh.numberofelements,1);
+end
+if length(dvx)~=md.mesh.numberofelements,
+	error(['the velocity error dvx should be of size ' num2str(md.mesh.numberofelements) ' or 1!'])
+end
+if length(dvy)==1,
+	dvy=dvy*ones(md.mesh.numberofelements,1);
+end
+if length(dvy)~=md.mesh.numberofelements,
+	error(['the velocity error dvy should be of size ' num2str(md.mesh.numberofelements) ' or 1!'])
+end
+if ~(md.mesh.dimension==2)
+	error('only 2d model supported yet');
+end
+if any(md.flowequation.element_equation~=2),
+	disp('Warning: the model has some non macayeal elements. These will be treated like MacAyeal''s elements');
+end
+
+%initialization
+index=md.mesh.elements;
+summation=[1;1;1];
+
+%compute nodal functions coefficients N(x,y)=alpha x + beta y +gamma
+[alpha beta]=GetNodalFunctionsCoeff(index,md.mesh.x,md.mesh.y);
+
+strainrateuncert=struct('xx',[],'yy',[],'xy',[],'principalvalue1',[],'principalvalue2',[],'effectivevalue',[]);
+
+strainrateuncert.xx=dvx.*sqrt(alpha.^2*summation);
+strainrateuncert.yy=dvy.*sqrt(beta.^2*summation);
+strainrateuncert.xy=0.5*sqrt(dvx.^2.*(beta.^2*summation)+dvy.^2.*(alpha.^2*summation));
+
+exx=md.results.strainrate.xx;
+eyy=md.results.strainrate.yy;
+exy=md.results.strainrate.xy;
+p1a=strainrateuncert.xx.*(0.5+0.25*(0.5*((exx-eyy)/2).^2+exy.^2).^(-1./2).*(exx-eyy));
+p2a=strainrateuncert.yy.*(0.5-0.25*(0.5*((exx-eyy)/2).^2+exy.^2).^(-1./2).*(exx-eyy));
+p3a=strainrateuncert.xy.*(((exx-eyy)/2).^(2)+exy.^2).^(-1./2).*exy;
+p1b=strainrateuncert.xx.*(0.5-0.25*(0.5*((exx-eyy)/2).^2+exy.^2).^(-1./2).*(exx-eyy));
+p2b=strainrateuncert.yy.*(0.5+0.25*(0.5*((exx-eyy)/2).^2+exy.^2).^(-1./2).*(exx-eyy));
+p3b=strainrateuncert.xy.*(-(((exx-eyy)/2).^(2)+exy.^2).^(-1./2).*exy);
+strainrateuncert.principalvalue1=sqrt(p1a.^2+p2a.^2+p3a.^2);
+strainrateuncert.principalvalue2=sqrt(p1b.^2+p2b.^2+p3b.^2);
+
+effa=strainrateuncert.xx/sqrt(2).*(exx.^2+eyy.^2+2*exy.^2).^(-1./2).*exx;
+effb=strainrateuncert.yy/sqrt(2).*(exx.^2+eyy.^2+2*exy.^2).^(-1./2).*eyy;
+effc=2*strainrateuncert.xy/sqrt(2).*(exx.^2+eyy.^2+2*exy.^2).^(-1./2).*exy;
+strainrateuncert.effectivevalue=sqrt(effa.^2+effb.^2+effc.^2);
+
+md.results.strainrateuncert=strainrateuncert;
Index: /issm/trunk/src/m/mesh/ComputeMetric.m
===================================================================
--- /issm/trunk/src/m/mesh/ComputeMetric.m	(revision 14309)
+++ /issm/trunk/src/m/mesh/ComputeMetric.m	(revision 14310)
@@ -13,7 +13,7 @@
 lambda1=0.5*((a+d)+sqrt(4.*b.^2+(a-d).^2));
 lambda2=0.5*((a+d)-sqrt(4.*b.^2+(a-d).^2));
-pos1=find(lambda1==0);
-pos2=find(lambda2==0);
-pos3=find(b==0 & lambda1==lambda2);
+pos1=find(lambda1==0.);
+pos2=find(lambda2==0.);
+pos3=find(b==0. & lambda1==lambda2);
 
 %Modify the eigen values to control the shape of the elements
Index: /issm/trunk/src/m/mesh/ComputeMetric.py
===================================================================
--- /issm/trunk/src/m/mesh/ComputeMetric.py	(revision 14309)
+++ /issm/trunk/src/m/mesh/ComputeMetric.py	(revision 14310)
@@ -19,7 +19,7 @@
 	lambda1=0.5*((a+d)+numpy.sqrt(4.*b**2+(a-d)**2))
 	lambda2=0.5*((a+d)-numpy.sqrt(4.*b**2+(a-d)**2))
-	pos1=numpy.nonzero(lambda1==0)[0]
-	pos2=numpy.nonzero(lambda2==0)[0]
-	pos3=numpy.nonzero(numpy.logical_and(b==0,lambda1==lambda2))[0]
+	pos1=numpy.nonzero(lambda1==0.)[0]
+	pos2=numpy.nonzero(lambda2==0.)[0]
+	pos3=numpy.nonzero(numpy.logical_and(b==0.,lambda1==lambda2))[0]
 
 	#Modify the eigen values to control the shape of the elements
@@ -54,5 +54,5 @@
 	#take care of NaNs if any (use Numpy eig in a loop)
 	pos=numpy.nonzero(numpy.isnan(metric))[0]
-	if pos:
+	if numpy.size(pos):
 		print(" %i NaN found in the metric. Use Numpy routine..." % numpy.size(pos))
 		for posi in pos:
Index: /issm/trunk/src/m/mesh/ElementsFromEdge.py
===================================================================
--- /issm/trunk/src/m/mesh/ElementsFromEdge.py	(revision 14309)
+++ /issm/trunk/src/m/mesh/ElementsFromEdge.py	(revision 14310)
@@ -1,3 +1,4 @@
 import numpy
+from PythonFuncs import *
 
 def ElementsFromEdge(elements,A,B):
@@ -12,14 +13,10 @@
 
 	edgeelements=numpy.nonzero(\
-		numpy.logical_or( \
-		numpy.logical_or( \
-		numpy.logical_or(numpy.logical_and(elements[:,0]==A,elements[:,1]==B), \
-						 numpy.logical_and(elements[:,0]==A,elements[:,2]==B)) \
-		, \
-		numpy.logical_or(numpy.logical_and(elements[:,1]==A,elements[:,2]==B), \
-						 numpy.logical_and(elements[:,1]==A,elements[:,0]==B)) \
-		), \
-		numpy.logical_or(numpy.logical_and(elements[:,2]==A,elements[:,0]==B), \
-						 numpy.logical_and(elements[:,2]==A,elements[:,1]==B)) \
+		logical_or_n(numpy.logical_and(elements[:,0]==A,elements[:,1]==B), \
+					 numpy.logical_and(elements[:,0]==A,elements[:,2]==B), \
+					 numpy.logical_and(elements[:,1]==A,elements[:,2]==B), \
+					 numpy.logical_and(elements[:,1]==A,elements[:,0]==B), \
+					 numpy.logical_and(elements[:,2]==A,elements[:,0]==B), \
+					 numpy.logical_and(elements[:,2]==A,elements[:,1]==B), \
 		))[0]+1
 
Index: /issm/trunk/src/m/mesh/bamg.py
===================================================================
--- /issm/trunk/src/m/mesh/bamg.py	(revision 14309)
+++ /issm/trunk/src/m/mesh/bamg.py	(revision 14310)
@@ -92,5 +92,5 @@
 			#Checks that all holes are INSIDE the principle domain outline
 			if i:
-				flags=ContourToNodes(domaini['x'].reshape(-1,1),domaini['y'].reshape(-1,1),domainfile,0)
+				flags=ContourToNodes(domaini['x'],domaini['y'],domainfile,0)
 				if numpy.any(numpy.logical_not(flags)):
 					raise RuntimeError("bamg error message: All holes should be strictly inside the principal domain")
@@ -118,5 +118,5 @@
 
 				#detect whether all points of the rift are inside the domain
-				flags=ContourToNodes(rifti['x'].reshape(-1,1),rifti['y'].reshape(-1,1),domain[0],0)
+				flags=ContourToNodes(rifti['x'],rifti['y'],domain[0],0)
 				if numpy.all(numpy.logical_not(flags)):
 					raise RuntimeError("one rift has all its points outside of the domain outline")
Index: /issm/trunk/src/m/mesh/rifts/meshprocessoutsiderifts.py
===================================================================
--- /issm/trunk/src/m/mesh/rifts/meshprocessoutsiderifts.py	(revision 14309)
+++ /issm/trunk/src/m/mesh/rifts/meshprocessoutsiderifts.py	(revision 14310)
@@ -16,5 +16,5 @@
 	
 		#first, flag nodes that belong to the domain outline
-		flags=ContourToMesh(md.mesh.elements,md.mesh.x.reshape(-1,1),md.mesh.y.reshape(-1,1),domainoutline,'node',0)
+		flags=ContourToMesh(md.mesh.elements,md.mesh.x,md.mesh.y,domainoutline,'node',0)
 
 		tips=rift.tips
Index: /issm/trunk/src/m/mesh/rifts/meshprocessrifts.py
===================================================================
--- /issm/trunk/src/m/mesh/rifts/meshprocessrifts.py	(revision 14309)
+++ /issm/trunk/src/m/mesh/rifts/meshprocessrifts.py	(revision 14310)
@@ -49,5 +49,5 @@
 
 	#In case we have rifts that open up the domain outline, we need to open them: 
-	[flags,dum]=ContourToMesh(md.mesh.elements,md.mesh.x.reshape(-1,1),md.mesh.y.reshape(-1,1),domainoutline,'node',0)
+	[flags,dum]=ContourToMesh(md.mesh.elements,md.mesh.x,md.mesh.y,domainoutline,'node',0)
 	found=0
 	for rift in md.rifts.riftstruct:
Index: /issm/trunk/src/m/mesh/squaremesh.m
===================================================================
--- /issm/trunk/src/m/mesh/squaremesh.m	(revision 14309)
+++ /issm/trunk/src/m/mesh/squaremesh.m	(revision 14310)
@@ -15,5 +15,4 @@
 
 %initialization
-segments=zeros(0,3);
 index=zeros(nel,3);
 x=zeros(nx*ny,1);
@@ -23,6 +22,6 @@
 for n=1:nx,
 	for m=1:ny,
-		x((n-1)*ny+m)=(n-1);
-		y((n-1)*ny+m)=(m-1);
+		x((n-1)*ny+m)=(n-1.);
+		y((n-1)*ny+m)=(m-1.);
 	end
 end
Index: /issm/trunk/src/m/mesh/squaremesh.py
===================================================================
--- /issm/trunk/src/m/mesh/squaremesh.py	(revision 14310)
+++ /issm/trunk/src/m/mesh/squaremesh.py	(revision 14310)
@@ -0,0 +1,83 @@
+import numpy
+from NodeConnectivity import *
+from ElementConnectivity import *
+
+def squaremesh(md,Lx,Ly,nx,ny):
+	"""
+	SQUAREMESH - create a structured square mesh 
+
+	   This script will generate a structured square mesh
+	   Lx and Ly are the dimension of the domain (in meters)
+	   nx anx ny are the number of nodes in the x and y direction
+	   The coordinates x and y returned are in meters.
+
+	   Usage:
+	      [md]=squaremesh(md,Lx,Ly,nx,ny)
+	"""
+
+	#get number of elements and number of nodes
+	nel=(nx-1)*(ny-1)*2
+	nods=nx*ny
+
+	#initialization
+	index=numpy.zeros((nel,3),int)
+	x=numpy.zeros((nx*ny))
+	y=numpy.zeros((nx*ny))
+
+	#create coordinates
+	for n in xrange(0,nx):
+		for m in xrange(0,ny):
+			x[n*ny+m]=float(n)
+			y[n*ny+m]=float(m)
+
+	#create index
+	for n in xrange(0,nx-1):
+		for m in xrange(0,ny-1):
+			A=n*ny+(m+1)
+			B=A+1
+			C=(n+1)*ny+(m+1)
+			D=C+1
+			index[n*(ny-1)*2+2*m,:]=[A,C,B]
+			index[n*(ny-1)*2+2*(m+1)-1,:]=[B,C,D]
+
+	#Scale  x and y
+	x=x/numpy.max(x)*Lx
+	y=y/numpy.max(y)*Ly
+
+	#create segments
+	segments=numpy.zeros((2*(nx-1)+2*(ny-1),3),int)
+	#left edge:
+	segments[0:ny-1,:]=numpy.hstack((numpy.arange(2,ny+1).reshape(-1,1),numpy.arange(1,ny).reshape(-1,1),(2*numpy.arange(1,ny)-1).reshape(-1,1)))
+	#right edge:
+	segments[ny-1:2*(ny-1),:]=numpy.hstack((numpy.arange(ny*(nx-1)+1,nx*ny).reshape(-1,1),numpy.arange(ny*(nx-1)+2,nx*ny+1).reshape(-1,1),2*numpy.arange((ny-1)*(nx-2)+1,(nx-1)*(ny-1)+1).reshape(-1,1)))
+	#front edge:
+	segments[2*(ny-1):2*(ny-1)+(nx-1),:]=numpy.hstack((numpy.arange(2*ny,ny*nx+1,ny).reshape(-1,1),numpy.arange(ny,ny*(nx-1)+1,ny).reshape(-1,1),numpy.arange(2*(ny-1),2*(nx-1)*(ny-1)+1,2*(ny-1)).reshape(-1,1)))
+	#back edge
+	segments[2*(ny-1)+(nx-1):2*(nx-1)+2*(ny-1),:]=numpy.hstack((numpy.arange(1,(nx-2)*ny+2,ny).reshape(-1,1),numpy.arange(ny+1,ny*(nx-1)+2,ny).reshape(-1,1),numpy.arange(1,2*(nx-2)*(ny-1)+2,2*(ny-1)).reshape(-1,1)))
+
+	#plug coordinates and nodes
+	md.mesh.x=x
+	md.mesh.y=y
+	md.mesh.z=numpy.zeros((nods))
+	md.mesh.numberofvertices=nods
+	md.mesh.vertexonboundary=numpy.zeros((nods),bool)
+	md.mesh.vertexonboundary[segments[:,0:2]-1]=True
+	md.mesh.vertexonbed=numpy.ones((nods),bool)
+	md.mesh.vertexonsurface=numpy.ones((nods),bool)
+
+	#plug elements
+	md.mesh.elements=index
+	md.mesh.segments=segments
+	md.mesh.numberofelements=nel
+	md.mesh.elementonbed=numpy.ones((nel),bool)
+	md.mesh.elementonsurface=numpy.ones((nel),bool)
+
+	#Now, build the connectivity tables for this mesh.
+	[md.mesh.vertexconnectivity]=NodeConnectivity(md.mesh.elements,md.mesh.numberofvertices)
+	[md.mesh.elementconnectivity]=ElementConnectivity(md.mesh.elements,md.mesh.vertexconnectivity)
+
+	#plug other field
+	md.mesh.dimension=2
+
+	return md
+
Index: /issm/trunk/src/m/miscellaneous/MatlabFuncs.py
===================================================================
--- /issm/trunk/src/m/miscellaneous/MatlabFuncs.py	(revision 14309)
+++ /issm/trunk/src/m/miscellaneous/MatlabFuncs.py	(revision 14310)
@@ -8,4 +8,12 @@
 
 	if 'Windows' in platform.system():
+		return True
+	else:
+		return False
+
+def ismac():
+	import platform
+
+	if 'Darwin' in platform.system():
 		return True
 	else:
@@ -89,2 +97,11 @@
 	return a
 
+def heaviside(x):
+	import numpy
+
+	y=numpy.zeros_like(x)
+	y[numpy.nonzero(x> 0.)]=1.
+	y[numpy.nonzero(x==0.)]=0.5
+
+	return y
+
Index: /issm/trunk/src/m/miscellaneous/PythonFuncs.py
===================================================================
--- /issm/trunk/src/m/miscellaneous/PythonFuncs.py	(revision 14310)
+++ /issm/trunk/src/m/miscellaneous/PythonFuncs.py	(revision 14310)
@@ -0,0 +1,24 @@
+def logical_and_n(*arg):
+	from numpy import logical_and
+
+	if len(arg):
+		result=arg[0]
+		for item in arg[1:]:
+			result=logical_and(result,item)
+		return result
+
+	else:
+		return None
+
+def logical_or_n(*arg):
+	from numpy import logical_or
+
+	if len(arg):
+		result=arg[0]
+		for item in arg[1:]:
+			result=logical_or(result,item)
+		return result
+
+	else:
+		return None
+
Index: /issm/trunk/src/m/miscellaneous/normcdf_issm.m
===================================================================
--- /issm/trunk/src/m/miscellaneous/normcdf_issm.m	(revision 14310)
+++ /issm/trunk/src/m/miscellaneous/normcdf_issm.m	(revision 14310)
@@ -0,0 +1,9 @@
+%
+%  wrapper for normcdf to avoid using the matlab statistics toolbox.
+%
+function [p]=normcdf_issm(x,mu,sigma)
+
+	p=(1.+erf((x-mu)/(sigma*sqrt(2.))))/2.;
+
+end
+
Index: /issm/trunk/src/m/miscellaneous/normfit_issm.m
===================================================================
--- /issm/trunk/src/m/miscellaneous/normfit_issm.m	(revision 14310)
+++ /issm/trunk/src/m/miscellaneous/normfit_issm.m	(revision 14310)
@@ -0,0 +1,36 @@
+%
+%  wrapper for normfit to avoid using the matlab statistics toolbox.
+%
+function [muhat,sigmahat,muci,sigmaci]=normfit_issm(x,alpha)
+
+%  remove any NaN
+
+	x=x(~isnan(x(:)));
+	n=length(x);
+
+%  explicitly calculate the moments
+
+	muhat   =mean(x);
+	sigmahat=std(x);
+
+	if (nargout>2)
+		if ~exist('alpha','var')
+			alpha=0.05;
+		end
+		prob=1.-alpha/2.;
+
+		try
+			muci(1,1)   =muhat-tinv(prob,n-1)*sigmahat/sqrt(n);
+			muci(2,1)   =muhat+tinv(prob,n-1)*sigmahat/sqrt(n);
+			sigmaci(1,1)=sigmahat*sqrt((n-1)/chi2inv(prob   ,n-1));
+			sigmaci(2,1)=sigmahat*sqrt((n-1)/chi2inv(1.-prob,n-1));
+		catch me
+			muci(1,1)   =muhat;
+			muci(2,1)   =muhat;
+			sigmaci(1,1)=sigmahat;
+			sigmaci(2,1)=sigmahat;
+		end
+	end
+
+end
+
Index: /issm/trunk/src/m/miscellaneous/norminv_issm.m
===================================================================
--- /issm/trunk/src/m/miscellaneous/norminv_issm.m	(revision 14310)
+++ /issm/trunk/src/m/miscellaneous/norminv_issm.m	(revision 14310)
@@ -0,0 +1,9 @@
+%
+%  wrapper for norminv to avoid using the matlab statistics toolbox.
+%
+function [x]=norminv_issm(p,mu,sigma)
+
+	x=mu+sigma*sqrt(2.)*erfinv(2.*p-1.);
+
+end
+
Index: /issm/trunk/src/m/miscellaneous/prctile_issm.m
===================================================================
--- /issm/trunk/src/m/miscellaneous/prctile_issm.m	(revision 14310)
+++ /issm/trunk/src/m/miscellaneous/prctile_issm.m	(revision 14310)
@@ -0,0 +1,87 @@
+%
+%  wrapper for prctile to avoid using the matlab statistics toolbox.
+%
+function [y]=prctile_issm(x,p,dim)
+
+	try
+		y=prctile(argin{:});
+
+	catch me
+
+		if length(size(x)) > 2
+			error('Number of dimensions %d not implemented.',length(size(x)));
+		end
+		if ~exist('dim','var')
+			dim=0;
+			for i=1:length(size(x))
+				if ~dim && size(x,i)>1
+					dim=i;
+				end
+			end
+			if ~dim
+				dim=1;
+			end
+		end
+
+		psize=size(p);
+		if size(p,2)>1
+			p=transp(p);
+		end
+
+		xsize=size(x);
+		if dim==2
+			x=transp(x);
+		end
+
+%  check for any NaN in any columns
+
+		if ~any(isnan(x))
+			x=sort(x,1);
+			n=size(x,1);
+
+%  branch based on number of elements
+
+			if     n>1
+
+%  set up percent values and interpolate
+
+				xi=transp(100.*([1:n]-0.5)/n);
+				y=interp1q(xi,x,p);
+
+%  fill in high and low values
+
+				y(p<xi(1),:)=repmat(x(1,:),nnz(p<xi(1)),1);
+				y(p>xi(n),:)=repmat(x(n,:),nnz(p>xi(n)),1);
+
+%  if one value, just copy it
+
+			elseif n==1
+				y=repmat(x(1,:),length(p),1);
+
+%  if no values, use NaN
+
+			else
+				y=repmat(NaN,size(p,1),size(x,2));
+			end
+
+		else
+
+%  must loop over columns, since number of elements could be different
+
+			y=zeros(size(p,1),size(x,2));
+			for j=1:size(x,2)
+
+%  remove any NaN and recursively call column
+
+				y(:,j)=prctile_issm(x(~isnan(x(:,j)),j),p);
+			end
+		end
+
+		if (min(xsize)==1 && xsize(dim)>1 && psize(2)>1) || ...
+		   (min(xsize)> 1 && dim==2)
+			y=transp(y);
+		end
+	end
+
+end
+
Index: /issm/trunk/src/m/os/dakotaversion.m
===================================================================
--- /issm/trunk/src/m/os/dakotaversion.m	(revision 14310)
+++ /issm/trunk/src/m/os/dakotaversion.m	(revision 14310)
@@ -0,0 +1,26 @@
+function DAKOTA_VERSION=dakotaversion()
+%DAKOTAVERSION - recover dakota version number, inside config.h file
+%
+%   Usage:
+%       DAKOTA_VERSION=dakotaversion();
+
+%default
+DAKOTA_VERSION='';
+
+configfile=[issmdir() '/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
+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,'#define DAKOTA_VERSION',22),
+		DAKOTA_VERSION=strtrim(strrep(tline(24:end),'"',''));
+	end
+end
+fclose(fid);
Index: /issm/trunk/src/m/os/dakotaversion.py
===================================================================
--- /issm/trunk/src/m/os/dakotaversion.py	(revision 14310)
+++ /issm/trunk/src/m/os/dakotaversion.py	(revision 14310)
@@ -0,0 +1,34 @@
+import os
+from issmdir import *
+from MatlabFuncs import *
+
+def dakotaversion():
+	"""
+	DAKOTAVERSION - recover dakota version number, inside config.h file
+ 
+	   Usage:
+	      DAKOTA_VERSION=dakotaversion();
+	"""
+
+	#default
+	DAKOTA_VERSION=''
+
+	configfile=os.path.join(issmdir(),'config.h')
+	if not os.path.exists(configfile):
+		raise RuntimeError("File '%s' not found. ISSM has not been configured yet!" % configfile)
+
+	#go through the file, and recover the line we want
+	try:
+		fid=open(configfile,'r')
+	except IOError as e:
+		raise IOerror("could not open file: '%s'" % configfile)
+
+	for tline in fid:
+		if strncmp(tline,'#define DAKOTA_VERSION',22):
+			DAKOTA_VERSION=tline[23:].replace('"','').strip()
+			break
+
+	fid.close()
+
+	return DAKOTA_VERSION
+
Index: /issm/trunk/src/m/parameterization/contourenvelope.m
===================================================================
--- /issm/trunk/src/m/parameterization/contourenvelope.m	(revision 14309)
+++ /issm/trunk/src/m/parameterization/contourenvelope.m	(revision 14310)
@@ -101,5 +101,5 @@
 	els2=mesh.elementconnectivity(el1,find(mesh.elementconnectivity(el1,:)));
 	if length(els2)>1,
-		flag=intersect(mesh.elements(els2(1),:),mesh.elements(els2(2),:));
+		flag=intersect(intersect(mesh.elements(els2(1),:),mesh.elements(els2(2),:)),mesh.elements(el1,:));
 		nods1=mesh.elements(el1,:);
 		nods1(find(nods1==flag))=[];
Index: /issm/trunk/src/m/parameterization/contourenvelope.py
===================================================================
--- /issm/trunk/src/m/parameterization/contourenvelope.py	(revision 14309)
+++ /issm/trunk/src/m/parameterization/contourenvelope.py	(revision 14310)
@@ -99,5 +99,5 @@
 		els2=mesh.elementconnectivity[el1,numpy.nonzero(mesh.elementconnectivity[el1,:])[0]]-1
 		if numpy.size(els2)>1:
-			flag=numpy.intersect1d(mesh.elements[els2[0],:],mesh.elements[els2[1],:])
+			flag=numpy.intersect1d(numpy.intersect1d(mesh.elements[els2[0],:],mesh.elements[els2[1],:]),mesh.elements[el1,:])
 			nods1=mesh.elements[el1,:]
 			nods1=numpy.delete(nods1,numpy.nonzero(nods1==flag))
Index: /issm/trunk/src/m/parameterization/setflowequation.py
===================================================================
--- /issm/trunk/src/m/parameterization/setflowequation.py	(revision 14309)
+++ /issm/trunk/src/m/parameterization/setflowequation.py	(revision 14310)
@@ -3,4 +3,5 @@
 from pairoptions import *
 from MatlabFuncs import *
+from PythonFuncs import *
 from FlagElements import *
 
@@ -50,9 +51,9 @@
 	#Flag the elements that have not been flagged as filltype
 	if   strcmpi(filltype,'hutter'):
-		hutterflag[numpy.nonzero(numpy.logical_not(numpy.logical_or(macayealflag,pattynflag)))]=True
+		hutterflag[numpy.nonzero(numpy.logical_not(logical_or_n(macayealflag,pattynflag)))]=True
 	elif strcmpi(filltype,'macayeal'):
-		macayealflag[numpy.nonzero(numpy.logical_not(numpy.logical_or(hutterflag,numpy.logical_or(pattynflag,stokesflag))))]=True
+		macayealflag[numpy.nonzero(numpy.logical_not(logical_or_n(hutterflag,pattynflag,stokesflag)))]=True
 	elif strcmpi(filltype,'pattyn'):
-		pattynflag[numpy.nonzero(numpy.logical_not(numpy.logical_or(hutterflag,numpy.logical_or(macayealflag,stokesflag))))]=True
+		pattynflag[numpy.nonzero(numpy.logical_not(logical_or_n(hutterflag,macayealflag,stokesflag)))]=True
 
 	#check that each element has at least one flag
@@ -69,5 +70,5 @@
 	#Check that no pattyn or stokes for 2d mesh
 	if md.mesh.dimension==2:
-		if numpy.any(numpy.logical_or(l1l2flag,stokesflag,pattynflag)):
+		if numpy.any(logical_or_n(l1l2flag,stokesflag,pattynflag)):
 			raise TypeError("stokes and pattyn elements not allowed in 2d mesh, extrude it first")
 
Index: /issm/trunk/src/m/plot/applyoptions.m
===================================================================
--- /issm/trunk/src/m/plot/applyoptions.m	(revision 14309)
+++ /issm/trunk/src/m/plot/applyoptions.m	(revision 14310)
@@ -331,50 +331,4 @@
 end
 
-%position of figure
-if exist(options,'figposition'),
-
-	figposition=getfieldvalue(options,'figposition');
-	if ischar(figposition),
-		if strcmpi(figposition,'larour'),
-			set(gcf,'Position',[1604 4 1594 1177]);
-		elseif strcmpi(figposition,'larour2'),
-			set(gcf,'Position',[756    62   827   504]);
-		elseif strcmpi(figposition,'mathieu'),
-			set(gcf,'Position',[300 1 1580 1150]);
-		elseif strcmpi(figposition,'fullscreen'),
-			set(gcf,'Position',get(0,'ScreenSize'));
-		elseif strcmpi(figposition,'halfright'),
-			screen=get(0,'ScreenSize');
-			left=screen(1); bott=screen(2); widt=screen(3); heig=screen(4)-25;
-			set(gcf,'Position',fix([left+widt/2 bott widt/2 heig]));
-		elseif strcmpi(figposition,'halfleft'),
-			screen=get(0,'ScreenSize');
-			left=screen(1); bott=screen(2); widt=screen(3); heig=screen(4)-25;
-			set(gcf,'Position',fix([left bott widt/2 heig]));
-		elseif strcmpi(figposition,'square'),
-			screen=get(0,'ScreenSize');
-			left=screen(1); bott=screen(2); widt=min(screen(3)-25,screen(4)-25);
-			set(gcf,'Position',fix([left+(screen(3)-widt) bott widt widt]));
-		elseif strcmpi(figposition,'portrait'),
-			%reformat with letter paper size (8.5" x 11")
-			screen=get(0,'ScreenSize');
-			left=screen(1); bott=screen(2); widt=screen(3); heig=screen(4)-25;
-			portrait=fix([left+widt-(heig*8.5/11) bott heig*8.5/11 heig]);
-			set(gcf,'Position',portrait)
-		elseif strcmpi(figposition,'landscape'),
-			%reformat with letter paper size (8.5" x 11")
-			screen=get(0,'ScreenSize');
-			left=screen(1); bott=screen(2); widt=screen(3); heig=screen(4)-25;
-			landscape=fix([left+widt-(heig*11/8.5) bott heig*11/8.5 heig]);
-			set(gcf,'Position',landscape)
-		else
-			disp('''figposition'' string not supported yet');
-		end
-	else
-		set(gcf,'Position',figposition);
-	end
-
-end
-
 %axes position
 if exist(options,'axesPosition')
@@ -446,7 +400,4 @@
 set(gca,'color',getfieldvalue(options,'backgroundcolor','none'));
 
-%figurebackgrounbcolor
-set(gcf,'color',getfieldvalue(options,'figurebackgroundcolor','w'));
-
 %lighting
 if strcmpi(getfieldvalue(options,'light','off'),'on'),
Index: /issm/trunk/src/m/plot/applyoptions.py
===================================================================
--- /issm/trunk/src/m/plot/applyoptions.py	(revision 14309)
+++ /issm/trunk/src/m/plot/applyoptions.py	(revision 14310)
@@ -1,2 +1,3 @@
+from matplotlib.ticker import MaxNLocator
 
 try:
@@ -107,4 +108,8 @@
 	#}}}
 
+	#ticklabel notation {{{
+	p.gca().ticklabel_format(style='sci',scilimits=(0,0))
+	#}}}
+
 	#ticklabelfontsize {{{
 	if options.exist('ticklabelfontsize'):
@@ -116,4 +121,5 @@
 				label.set_fontsize(options.getfieldvalue('ticklabelfontsize'))
 	#}}}
+
 	#view
 
@@ -137,5 +143,12 @@
 	#ShowBasins
 
-	#Caxis
+	#clim {{{
+	if options.exist('clim'):
+		lims=options.getfieldvalue('clim')
+		if len(lims)!=2:
+			print 'WARNING: clim should be passed as a list of length 2'
+		else:
+			p.clim(lims[0],lims[1])
+	#}}}
 
 	#shading
@@ -152,6 +165,11 @@
 
 	#colorbar {{{
-	if 'on' in options.getfieldvalue('colorbar','off'):
-		p.colorbar()
+	if options.getfieldvalue('colorbar','off')==1:
+		cb=p.colorbar()
+		cb.locator=MaxNLocator(nbins=5) # default 5 ticks
+		cb.update_ticks()
+		if options.exist('colorbarnumticks'):
+			cb.locator=MaxNLocator(nbins=options.getfieldvalue('colorbarnumticks',5))
+			cb.update_ticks()
 	#}}}
 
Index: /issm/trunk/src/m/plot/checkplotoptions.m
===================================================================
--- /issm/trunk/src/m/plot/checkplotoptions.m	(revision 14309)
+++ /issm/trunk/src/m/plot/checkplotoptions.m	(revision 14310)
@@ -81,4 +81,5 @@
 	end
 	textweightvalues=repmat(textweightvalues,1,numtext); textweightvalues(numtext+1:end)=[];
+
 	%3: textsize
 	if exist(options,'textsize'),
@@ -107,5 +108,5 @@
 	end
 	textcolorvalues=repmat(textcolorvalues,1,numtext); textcolorvalues(numtext+1:end)=[];
-	%4: textposition
+	%5: textposition
 	if exist(options,'textposition'),
 		textpositionvalues=getfieldvalue(options,'textposition');
@@ -191,5 +192,5 @@
 	if strcmpi(getfieldvalue(options,'scaleruler'),'on')
 		%default values
-		Lx=max(md.mesh.y)-min(md.mesh.y);
+		Lx=max(md.mesh.x)-min(md.mesh.x);
 		Ly=max(md.mesh.y)-min(md.mesh.y);
 		%default values
Index: /issm/trunk/src/m/plot/checkplotoptions.py
===================================================================
--- /issm/trunk/src/m/plot/checkplotoptions.py	(revision 14309)
+++ /issm/trunk/src/m/plot/checkplotoptions.py	(revision 14310)
@@ -1,2 +1,4 @@
+import numpy as npy
+
 def checkplotoptions(md,options):
 	'''
@@ -11,5 +13,129 @@
 	'''
 
-	print "WARNING: checkplotoptions not implemented: options returned as passed"
+
+	#units
+	if options.exist('unit'):
+		if 'km' in options.getfieldvalue('unit','km'):
+			options.changefieldvalue('unit',10**-3)
+		if '100km' in options.getfieldvalue('unit','100km'):
+			options.changefieldvalue('unit',10**-5)
+	
+	#density
+	if options.exist('density'):
+		density=options.getfieldvalue('density')
+		options.changefieldvalue('density',abs(ceil(density)))
+	
+	#show section
+	if options.exist('showsection'):
+		if 'on' in options.getfieldvalue('showsection','on'):
+			options.changefieldvalue('showsection',4)
+	
+	#smooth values
+	if options.exist('smooth'):
+		if 'on' in options.getfieldvalue('smooth','on'):
+			options.changefieldvalue('smooth',0)
+
+	#contouronly values
+	if options.exist('contouronly'):
+		if 'on' in options.getfieldvalue('contouronly','on'):
+			options.changefieldvalue('contouronly',1)
+
+	#colorbar
+	if options.exist('colorbar'):
+		if 'on' in options.getfieldvalue('colorbar','on'):
+			options.changefieldvalue('colorbar',1)
+		elif 'off' in options.getfieldvalue('colorbar','off'):
+			options.changefieldvalue('colorbar',0)
+
+	#text
+	if options.exist('text'):
+		#1: textvalue
+		textvalues=options.getfieldvalue('text')
+		numtext=len(textvalues)
+
+		#2: textweight
+		if options.exist('textweight'):
+			textweightvalues=options.getfieldvalue('textweight')
+		else:
+			textweightvalues='n'
+		textweightvalues=npy.tile(textweightvalues,numtext)
+
+		#3 textsize
+		if options.exist('textsize'):
+			textsizevalues=options.getfieldvalue('textsize')
+		else:
+			textsizevalues=14
+		textsizevalues=npy.tile(textsizevalues,numtext)
+
+		#4 textcolor
+		if options.exist('textcolor'):
+			textcolorvalues=options.getfieldvalue('textcolor')
+		else:
+			textcolorvalues='k'
+		textcolorvalues=npy.tile(textsizevalues,numtext)
+
+		#5 textposition
+		if options.exist('textposition'):
+			options.getfieldvalue('textposition')
+		else:
+			raise Exception("plotmodel error message: 'textposition' option is missing")
+
+		#6 textrotation
+		if options.exist('textrotation'):
+			textrotationvalues=options.getfieldvalue('textrotation')
+		else:
+			textrotationvalues=0
+		textrotationvalues=npy.tile(textrotationvalues,numtext)
+
+		options.changfieldvalue('text',textvalues)
+		options.changfieldvalue('textsize',textsizevalues)
+		options.changfieldvalue('textweight',textweightvalues)
+		options.changfieldvalue('textcolor',textcolorvalues)
+		options.changfieldvalue('textposition',textpositionvalues)
+		options.changfieldvalue('textrotation',textrotationvalues)
+
+	#expdisp
+	expdispvaluesarray=[0,0]
+	expstylevaluesarray=[0,0]
+	expstylevalues=[0,0]
+	if options.exist('expstyle'):
+		expstylevalues=options.getfieldvalue('expstyle')
+	if options.exist('expdisp'):
+		expdispvalues=options.getfieldvalue('expdisp')
+		for i in npy.arange(len(expdispvalues)):
+			expdispvaluesarray.append(expdispvalues[i])
+			if len(expstylevalues)>i+1:
+				expstylevaluesarray.append(expstylevalues[i])
+			else:
+				expstylevaluesarray.append('-k')
+
+	options.changefieldvalue('expstyle',expstylevaluesarray)
+	options.changefieldvalue('expdisp',expdispvaluesarray)
+
+	#latlonnumbering
+	if options.exist('latlonclick'):
+		if 'on' in options.getfieldvalue('latlonclick','on'):
+			options.changefieldvalue('latlonclick',1)
+
+	#northarrow
+	if options.exist('northarrow'):
+		if 'on' in options.getfieldvalue('northarrow','on'):
+			#default values
+			Lx=max(md.mesh.x)-min(md.mesh.x)
+			Ly=max(md.mesh.y)-min(md.mesh.y)
+			options.changefieldvalue('northarrow',[min(md.mesh.x)+1./6.*Lx, min(md.mesh.y)+5./6.*Ly, 1./15.*Ly, 0.25, 1./250.*Ly])
+
+	#scale ruler
+	if options.exist('scaleruler'):
+		if 'on' in options.exist('scaleruler','on'):
+			Lx=max(md.mesh.x)-min(md.mesh.x)
+			Ly=max(md.mesh.y)-min(md.mesh.y)
+			options.changefieldvalue('scaleruler',[min(md.mesh.x)+6./8.*Lx, min(md.mesh.y)+1./10.*Ly, 10**(ceil(log10(Lx)))/5, floor(Lx/100), 5])
+
+	#log scale
+	if options.exist('log'):
+		if options.exist('caxis'):
+			options.changefieldvalue('caxis',log(options.getfieldvalue('caxis'))/log(options.getfieldvalue('log')))
+		options.changefieldvalue('cutoff',log(options.getfieldvalue('cutoff',1.5))/log(options.getfieldvalue('log')))
+
 	return options
-
Index: /issm/trunk/src/m/plot/colormaps/demmap.m
===================================================================
--- /issm/trunk/src/m/plot/colormaps/demmap.m	(revision 14310)
+++ /issm/trunk/src/m/plot/colormaps/demmap.m	(revision 14310)
@@ -0,0 +1,62 @@
+function cmap = demmap(ncolors,minZ,maxZ);
+%DEMMAP - concatenate sea and land color depending on zmin and zmax
+%
+%   Usage:
+%      cmap = demmap(n,zmin,zmax)
+
+if nargin<3,
+	help landseacolor
+	error('3 arguments necessary');
+end
+
+if minZ == maxZ;
+	maxZ = minZ+1;
+end
+
+% determine appropriate number of sea and land colors
+if minZ == maxZ;
+	maxZ = minZ+1;
+end
+
+cmn = minZ;
+cmx = maxZ;
+
+% determine appropriate number of sea and land colors
+if minZ >= 0
+	nsea = 0;
+	nland = ncolors;
+elseif maxZ <= 0
+	nland = 0;
+	nsea = ncolors;
+else
+	% find optimal ratio of land to sea colors
+	maxminratio = maxZ/abs(minZ);
+	n1 = floor(ncolors/2);
+	n2 = ceil(ncolors/2);
+	if maxminratio>1
+		sea = (1:n1)';
+		land = (ncolors-1:-1:n2)';
+	else
+		land = (1:n1)';
+		sea = (ncolors-1:-1:n2)';
+	end
+	ratio = land./sea;
+	errors = abs(ratio - maxminratio) / maxminratio;
+	indx = find(errors == min(min(errors)));
+	nsea = sea(indx);
+	nland = land(indx);
+
+	% determine color limits
+	seaint = abs(minZ)/nsea;
+	landint = maxZ/nland;
+	if seaint >= landint
+		interval = seaint;
+	else
+		interval = landint;
+	end
+	cmn = -nsea*interval*(1 + 1e-9);      % zero values treated as land
+	cmx = nland*interval;
+end
+
+clim = [cmn cmx];
+cmap = [seacolor(nsea);landcolor(nland).^1.3];
Index: /issm/trunk/src/m/plot/colormaps/landcolor.m
===================================================================
--- /issm/trunk/src/m/plot/colormaps/landcolor.m	(revision 14310)
+++ /issm/trunk/src/m/plot/colormaps/landcolor.m	(revision 14310)
@@ -0,0 +1,77 @@
+function y = landcolor(n)
+%LANDCOLOR Land colormap
+%
+%	Author: Francois Beauducel <beauducel@ipgp.fr>
+%	$Revision: 1.0.0 $   $Date: 2012/05/17 11:22:44 $
+
+J = [ ...
+0.095678 0.53427 0.21682 
+0.15785 0.5979 0.23274 
+0.21286 0.64673 0.2514 
+0.26411 0.68789 0.27268 
+0.32959 0.72416 0.31308 
+0.39794 0.75695 0.36038 
+0.46153 0.7871 0.40624 
+0.52108 0.81516 0.45135 
+0.57702 0.84152 0.49547 
+0.62973 0.86645 0.53891 
+0.67946 0.89016 0.58187 
+0.72647 0.91282 0.62427 
+0.77095 0.93455 0.66619 
+0.81306 0.95546 0.70772 
+0.85292 0.97563 0.7489 
+0.89066 0.99514 0.78976 
+0.88379 0.98595 0.77038 
+0.86389 0.96758 0.73236 
+0.84615 0.94972 0.69623 
+0.8303 0.93233 0.66186 
+0.81612 0.91536 0.6291 
+0.80341 0.8988 0.59784 
+0.79201 0.8826 0.56795 
+0.78191 0.86676 0.53946 
+0.7729 0.85123 0.51224 
+0.76479 0.83602 0.48615 
+0.75747 0.8211 0.46111 
+0.75084 0.80645 0.43704 
+0.74506 0.79206 0.41414 
+0.73981 0.77792 0.39211 
+0.73501 0.76401 0.37089 
+0.73068 0.75033 0.35052 
+0.72683 0.73685 0.33106 
+0.72042 0.72074 0.31228 
+0.71032 0.70085 0.29417 
+0.69761 0.67821 0.27694 
+0.68489 0.65558 0.26026 
+0.67235 0.63313 0.24418 
+0.65997 0.61082 0.22889 
+0.64775 0.58874 0.21406 
+0.63568 0.56689 0.19983 
+0.62376 0.54527 0.18622 
+0.61197 0.52391 0.17299 
+0.60033 0.50283 0.16046 
+0.58881 0.48203 0.14832 
+0.57742 0.46151 0.13667 
+0.56616 0.44133 0.12555 
+0.55502 0.4214 0.11472 
+0.54398 0.4019 0.10456 
+0.53306 0.38266 0.094633 
+0.52226 0.36382 0.085242 
+0.51155 0.3453 0.076179 
+0.50095 0.32714 0.067515 
+0.49045 0.30938 0.059259 
+0.48005 0.29193 0.051294 
+0.46973 0.27495 0.043796 
+0.45951 0.25823 0.0365 
+0.44938 0.24206 0.029715 
+0.43934 0.22609 0.023063 
+0.42938 0.21074 0.016949 
+0.41951 0.19556 0.010917 
+0.40971 0.18105 0.0054326 
+0.4 0.16667 0 
+];
+
+l = length(J);
+if nargin < 1
+	n = 256;
+end
+y = interp1(1:l,J,linspace(1,l,n),'*linear');
Index: /issm/trunk/src/m/plot/colormaps/seacolor.m
===================================================================
--- /issm/trunk/src/m/plot/colormaps/seacolor.m	(revision 14310)
+++ /issm/trunk/src/m/plot/colormaps/seacolor.m	(revision 14310)
@@ -0,0 +1,58 @@
+function y = seacolor(n)
+%SEACOLOR Sea colormap adapted from NGDC ETOPO1
+%
+%	Author: Francois Beauducel <beauducel@ipgp.fr>
+
+J = [ ...
+    0.0392         0    0.4745
+    0.1020         0    0.5373
+    0.1020         0    0.5373
+    0.1490         0    0.5961
+    0.1490         0    0.5961
+    0.1059    0.0118    0.6510
+    0.1059    0.0118    0.6510
+    0.0627    0.0235    0.7059
+    0.0627    0.0235    0.7059
+    0.0196    0.0353    0.7569
+    0.0196    0.0353    0.7569
+         0    0.0549    0.7961
+         0    0.0549    0.7961
+         0    0.0863    0.8235
+         0    0.0863    0.8235
+         0    0.1176    0.8471
+         0    0.1176    0.8471
+         0    0.1529    0.8745
+         0    0.1529    0.8745
+    0.0471    0.2667    0.9059
+    0.0471    0.2667    0.9059
+    0.1020    0.4000    0.9412
+    0.1020    0.4000    0.9412
+    0.0745    0.4588    0.9569
+    0.0745    0.4588    0.9569
+    0.0549    0.5216    0.9765
+    0.0549    0.5216    0.9765
+    0.0824    0.6196    0.9882
+    0.0824    0.6196    0.9882
+    0.1176    0.6980    1.0000
+    0.1176    0.6980    1.0000
+    0.1686    0.7294    1.0000
+    0.1686    0.7294    1.0000
+    0.2157    0.7569    1.0000
+    0.2157    0.7569    1.0000
+    0.2549    0.7843    1.0000
+    0.2549    0.7843    1.0000
+    0.3098    0.8235    1.0000
+    0.3098    0.8235    1.0000
+    0.3686    0.8745    1.0000
+    0.3686    0.8745    1.0000
+    0.5412    0.8902    1.0000
+    0.5412    0.8902    1.0000
+    0.7373    0.9020    1.0000
+];
+
+l = length(J);
+if nargin < 1
+	n = 256;
+end
+y = interp1(1:l,J,linspace(1,l,n),'*linear');
+
Index: /issm/trunk/src/m/plot/kmlgridded.m
===================================================================
--- /issm/trunk/src/m/plot/kmlgridded.m	(revision 14310)
+++ /issm/trunk/src/m/plot/kmlgridded.m	(revision 14310)
@@ -0,0 +1,145 @@
+function kmlgridded(md,data,varargin)
+
+%process options
+options=pairoptions(varargin{:});
+
+%process options
+options=changefieldvalue(options,'coord','latlon');
+
+%process mesh and data
+[x y z elements is2d isplanet]=processmesh(md,[],options);
+[data datatype]=processdata(md,data,options);
+
+%check is2d
+if ~is2d, 
+	error('buildgridded error message: gridded not supported for 3d meshes, project on a layer');
+end
+
+%Get xlim and ylim (used to extract radar image)
+xlim=[min(x) max(x)];
+ylim=[min(y) max(y)];
+post=getfieldvalue(options,'posting',diff(xlim)/1000);
+if(diff(xlim)/post>10000),
+	error(['posting too large']);
+end
+
+%Interpolating data on grid
+[x_m y_m data_grid]=InterpFromMeshToGrid(elements,x,y,data,xlim(1),ylim(2),post,post,round(diff(ylim)/post),round(diff(xlim)/post),NaN);
+if size(data_grid,1)<3 | size(data_grid,2)<3,
+	error('data_grid size too small, check posting and units');
+end
+pos=find(isinf(data_grid));
+if ~isempty(pos),
+	disp('Warning: removing Infs from vector (probably log(0)?)');
+	data_grid(pos)=NaN;
+end
+
+%Process data_grid: add white in NaN and correct caxis accordingly
+data_nan=find(isnan(data_grid));
+data_min=min(data_grid(:));
+data_max=max(data_grid(:));
+if exist(options,'caxis'),
+	caxis_opt=getfieldvalue(options,'caxis');
+	data_grid(find(data_grid<caxis_opt(1)))=caxis_opt(1);
+	data_grid(find(data_grid>caxis_opt(2)))=caxis_opt(2);
+	data_min=caxis_opt(1);
+	data_max=caxis_opt(2);
+end
+
+%Get colormap
+colorm = getcolormap(options);
+len    = size(colorm,1);
+ind = ceil((len-1)*(data_grid-data_min)/(data_max - data_min + eps) +1);
+ind(find(ind>len))=len;
+ind(find(ind<1)  )=1;
+ind(find(isnan(ind)))=1;
+image_rgb=zeros(size(data_grid,1),size(data_grid,2),3);
+r=colorm(:,1); image_rgb(:,:,1)=r(ind); clear r;
+g=colorm(:,2); image_rgb(:,:,2)=g(ind); clear g;
+b=colorm(:,3); image_rgb(:,:,3)=b(ind); clear b;
+
+%Deal with alpha
+alpha=getfieldvalue(options,'alpha',.8);
+alphaMatrix = alpha*ones(size(data_grid));
+alphaMatrix(data_nan) = 0;
+
+%write kml
+kmlfilename=getfieldvalue(options,'kmlfilename','tempfile.kml');
+kmlroot=getfieldvalue(options,'kmlroot','./');
+kmlimagename=getfieldvalue(options,'kmlimagename','tempimage');
+kmlresolution=getfieldvalue(options,'kmlresolution',1);
+kmlfolder=getfieldvalue(options,'kmlfolder','Ground Overlay');
+kmlfolderdescription=getfieldvalue(options,'kmlfolderdescription','');
+kmlgroundoverlayname=getfieldvalue(options,'kmlgroundoverlayname','ground overlay');
+kmlgroundoverlaydescription=getfieldvalue(options,'kmlgroundoverlaydescription','description');
+
+%write png
+imwrite(image_rgb,[kmlimagename '.png'],'png','alpha',alphaMatrix);
+clear image_rgb alphaMatrix
+
+%prepare colorbar
+iscolorbar=0;
+if strcmpi(getfieldvalue(options,'colorbar','on'),'on'),
+	X = linspace(0,1,len)';
+	Xlab = round(linspace(data_min,data_max,len+1));
+	html = ['<TABLE border=' num2str(1) ' bgcolor=#FFFFFF>',10];
+
+	for k=len:-1:1
+		f = (Xlab(k)-data_min)/(data_max-data_min);
+		if f<0, f=0; end
+		if f>1, f=1; end
+		polyColor(1,1) = interp1(X,colorm(:,1),f);
+		polyColor(1,2) = interp1(X,colorm(:,2),f);
+		polyColor(1,3) = interp1(X,colorm(:,3),f);
+		polyColorStr(1:2) = dec2hex(round(polyColor(1)*255),2);
+		polyColorStr(3:4) = dec2hex(round(polyColor(2)*255),2);
+		polyColorStr(5:6) = dec2hex(round(polyColor(3)*255),2);
+		html = [html,'<TR><TD width="15px" bgcolor=#',polyColorStr, '>&nbsp;</TD>','<TD bgcolor=#FFFFFF>'];
+		if k==1
+			html=[html,'&lt;= ',num2str(Xlab(k),'%g')];
+		elseif k==len
+			html=[html,'&gt;= ',num2str(Xlab(k),'%g')];
+		else
+			html=[html,num2str(Xlab(k),'%g'),' to ',num2str(Xlab(k+1),'%g'),'</TD>'];
+		end
+		html = [html,'</TR>',10];
+	end
+	html = [html,'</TABLE>'];
+	iscolorbar = 1;
+end
+
+%now write kml file
+fid=fopen([kmlroot '/' kmlfilename],'w');
+fprintf(fid,'%s\n','<?xml version="1.0" encoding="UTF-8"?>');
+fprintf(fid,'%s\n','<kml xmlns="http://earth.google.com/kml/2.1">');
+fprintf(fid,'%s\n','<Document>');
+fprintf(fid,'%s%s%s\n','<name>',kmlfilename,'</name>');
+if iscolorbar,
+	fprintf(fid,'<Placemark id="colorbar">\n');
+	fprintf(fid,'%s%s%s\n','<name>','click the icon to see the colorbar','</name>');
+	fprintf(fid,'%s%s%s\n','<description>','Ground overlay colorbar','</description>');
+	fprintf(fid,'<visibility>1</visibility>\n');
+	fprintf(fid,['<description>',10,'<![CDATA[' html ']]>',10,'</description>',10,'\n']);
+	fprintf(fid,['<Style><IconStyle><scale>1</scale><Icon><href>http://maps.google.com/mapfiles/kml/shapes/donut.png</href></Icon></IconStyle><ListStyle></ListStyle></Style><Point id="poly_colorbar">\n']);
+	fprintf(fid,'<altitudeMode>clampToGround</altitudeMode>\n');
+	fprintf(fid,'<extrude>1</extrude>\n');
+	fprintf(fid,'<tessellate>1</tessellate>\n');
+	fprintf(fid,'%s%g,%g%s\n','<coordinates>',max(x),mean(y),'</coordinates>');
+	fprintf(fid,'</Point>\n');
+	fprintf(fid,'</Placemark>\n');
+end
+fprintf(fid,'%s\n','<GroundOverlay id="groundoverlay">');
+fprintf(fid,'%s%s%s\n','<name>',kmlgroundoverlayname,'</name>');
+fprintf(fid,'%s\n','<description>',kmlgroundoverlaydescription,'</description>');
+fprintf(fid,'%s%s.%s%s\n','<Icon>',kmlimagename,'png','</Icon>');
+fprintf(fid,'%s\n','<LatLonBox>');
+fprintf(fid,'%s%f%s\n','<north>',max(y_m),'</north>');
+fprintf(fid,'%s%f%s\n','<south>',min(y_m),'</south>');
+fprintf(fid,'%s%f%s\n','<east>',max(x_m),'</east>');
+fprintf(fid,'%s%f%s\n','<west>',min(x_m),'</west>');
+fprintf(fid,'%s\n','<rotation>0</rotation>');
+fprintf(fid,'%s\n','</LatLonBox>');
+fprintf(fid,'%s\n','</GroundOverlay>');
+fprintf(fid,'%s\n','</Document>');
+fprintf(fid,'%s\n','</kml>');
+fclose(fid);
Index: /issm/trunk/src/m/plot/kmlgroundoverlay.m
===================================================================
--- /issm/trunk/src/m/plot/kmlgroundoverlay.m	(revision 14309)
+++ /issm/trunk/src/m/plot/kmlgroundoverlay.m	(revision 14310)
@@ -34,5 +34,6 @@
 
 %print image at high resolution
-printmodel([kmlroot '/' kmlimagename],kmlimagetype,'trim','on','resolution',kmlresolution,'margin','off','frame','off');
+export_fig([kmlroot '/' kmlimagename],'-transparent','-zbuffer'); %zbuffer to avoid "Bad data returned by HARDCOPY. Not calling IMWRITE"
+%printmodel([kmlroot '/' kmlimagename],kmlimagetype,'trim','on','resolution',kmlresolution,'margin','off','frame','off');
 
 %now write kml file
Index: /issm/trunk/src/m/plot/latlonoverlay.m
===================================================================
--- /issm/trunk/src/m/plot/latlonoverlay.m	(revision 14309)
+++ /issm/trunk/src/m/plot/latlonoverlay.m	(revision 14310)
@@ -87,6 +87,6 @@
 		if (xcorner>xlimits(1) & xcorner<xlimits(2) & ycorner>ylimits(1) & ycorner<ylimits(2)),
 			angle=mod((180)/pi*atan2((ycorner2-ycorner),(xcorner2-xcorner))+latangle,360);
-			if lat<0, label=[num2str(abs(lat)) '^{\circ}S'];
-			else      label=[num2str(abs(lat)) '^{\circ}N']; end
+			if lat<0, label=[num2str(abs(lat)) '^{\circ} S'];
+			else      label=[num2str(abs(lat)) '^{\circ} N']; end
 			th=text(xcorner,ycorner,label);
 			set(th,'Color',colornumber,'Rotation',angle,'FontSize',fontsize,'HorizontalAlignment','center','VerticalAlignment','middle','Clipping','on');
@@ -130,6 +130,6 @@
 		if (xcorner>xlimits(1) & xcorner<xlimits(2) & ycorner>ylimits(1) & ycorner<ylimits(2)),
 			angle=mod((180)/pi*atan2((ycorner2-ycorner),(xcorner2-xcorner))+lonangle,360);
-			if lon<0, label=[num2str(abs(lon)) '^{\circ}W'];
-			else      label=[num2str(abs(lon)) '^{\circ}E']; end
+			if lon<0, label=[num2str(abs(lon)) '^{\circ} W'];
+			else      label=[num2str(abs(lon)) '^{\circ} E']; end
 			th=text(xcorner,ycorner,label);
 			set(th,'Color',colornumber,'Rotation',angle,'FontSize',fontsize,'HorizontalAlignment','center','VerticalAlignment','middle','Clipping','on');
Index: /issm/trunk/src/m/plot/plot_BC.m
===================================================================
--- /issm/trunk/src/m/plot/plot_BC.m	(revision 14309)
+++ /issm/trunk/src/m/plot/plot_BC.m	(revision 14310)
@@ -7,29 +7,34 @@
 
 %plot dirichlets
-h1=plot3(...
-	md.mesh.x(find(~isnan(md.diagnostic.spcvx(1:md.mesh.numberofvertices,1)))),...
-	md.mesh.y(find(~isnan(md.diagnostic.spcvx(1:md.mesh.numberofvertices,1)))),...
-	md.mesh.z(find(~isnan(md.diagnostic.spcvx(1:md.mesh.numberofvertices,1)))),...
-	'ro','MarkerSize',14,'MarkerFaceColor','r');
-h2=plot3(...
-	md.mesh.x(find(~isnan(md.diagnostic.spcvy(1:md.mesh.numberofvertices,1)))),...
-	md.mesh.y(find(~isnan(md.diagnostic.spcvy(1:md.mesh.numberofvertices,1)))),...
-	md.mesh.z(find(~isnan(md.diagnostic.spcvy(1:md.mesh.numberofvertices,1)))),...
-	'bo','MarkerSize',10,'MarkerFaceColor','b');
-h3=plot3(...
-	md.mesh.x(find(~isnan(md.diagnostic.spcvz(1:md.mesh.numberofvertices,1)))),...
-	md.mesh.y(find(~isnan(md.diagnostic.spcvz(1:md.mesh.numberofvertices,1)))),...
-	md.mesh.z(find(~isnan(md.diagnostic.spcvz(1:md.mesh.numberofvertices,1)))),...
-	'yo','MarkerSize',6 ,'MarkerFaceColor','y');
+dirichleton=getfieldvalue(options,'dirichlet','on');
+if strcmpi(dirichleton,'on'),
+	h1=plot3(...
+		md.mesh.x(find(~isnan(md.diagnostic.spcvx(1:md.mesh.numberofvertices,1)))),...
+		md.mesh.y(find(~isnan(md.diagnostic.spcvx(1:md.mesh.numberofvertices,1)))),...
+		md.mesh.z(find(~isnan(md.diagnostic.spcvx(1:md.mesh.numberofvertices,1)))),...
+		'ro','MarkerSize',14,'MarkerFaceColor','r');
+	h2=plot3(...
+		md.mesh.x(find(~isnan(md.diagnostic.spcvy(1:md.mesh.numberofvertices,1)))),...
+		md.mesh.y(find(~isnan(md.diagnostic.spcvy(1:md.mesh.numberofvertices,1)))),...
+		md.mesh.z(find(~isnan(md.diagnostic.spcvy(1:md.mesh.numberofvertices,1)))),...
+		'bo','MarkerSize',10,'MarkerFaceColor','b');
+	h3=plot3(...
+		md.mesh.x(find(~isnan(md.diagnostic.spcvz(1:md.mesh.numberofvertices,1)))),...
+		md.mesh.y(find(~isnan(md.diagnostic.spcvz(1:md.mesh.numberofvertices,1)))),...
+		md.mesh.z(find(~isnan(md.diagnostic.spcvz(1:md.mesh.numberofvertices,1)))),...
+		'yo','MarkerSize',6 ,'MarkerFaceColor','y');
+end
 
 %update legend
 [legend_h,object_h,plot_h,text_strings]=legend();
 legend('off');
-text_strings{end+1}='vx Dirichlet';
-text_strings{end+1}='vy Dirichlet';
-if h3, text_strings{end+1}='vz Dirichlet'; end
-plot_h(end+1)=h1;
-plot_h(end+1)=h2;
-if h3, plot_h(end+1)=h3; end
+if strcmpi(dirichleton,'on'),
+	text_strings{end+1}='vx Dirichlet';
+	text_strings{end+1}='vy Dirichlet';
+	if h3, text_strings{end+1}='vz Dirichlet'; end
+	plot_h(end+1)=h1;
+	plot_h(end+1)=h2;
+	if h3, plot_h(end+1)=h3; end
+end
 legend(plot_h,text_strings,'location','NorthEast')
 
Index: /issm/trunk/src/m/plot/plot_gridded.m
===================================================================
--- /issm/trunk/src/m/plot/plot_gridded.m	(revision 14309)
+++ /issm/trunk/src/m/plot/plot_gridded.m	(revision 14310)
@@ -24,5 +24,5 @@
 [x_m y_m data_grid]=InterpFromMeshToGrid(elements,x,y,data,xlim(1),ylim(2),post,post,round(diff(ylim)/post),round(diff(xlim)/post),NaN);
 if size(data_grid,1)<3 | size(data_grid,2)<3,
-	error('data_grid size too small in plot_gridded, check posting and uni');
+	error('data_grid size too small in plot_gridded, check posting and units');
 end
 
Index: /issm/trunk/src/m/plot/plot_manager.py
===================================================================
--- /issm/trunk/src/m/plot/plot_manager.py	(revision 14309)
+++ /issm/trunk/src/m/plot/plot_manager.py	(revision 14310)
@@ -57,5 +57,5 @@
 
 	#standard plot
-	p.subplot(nlines,ncols,i)
+	p.subplot(nlines,ncols,i,aspect='equal')
 
 	#plot unit
@@ -64,4 +64,4 @@
 	#apply all options
 	applyoptions(md,data2,options)
-
+	
 	#ground overlay on kml plot_unit
Index: /issm/trunk/src/m/plot/plot_mesh.py
===================================================================
--- /issm/trunk/src/m/plot/plot_mesh.py	(revision 14309)
+++ /issm/trunk/src/m/plot/plot_mesh.py	(revision 14310)
@@ -21,5 +21,5 @@
 
 	if is2d:
-		p.subplot(nlines,ncols,i)
+		p.subplot(nlines,ncols,i,aspect='equal')
 		p.triplot(x,y,elements)
 	else:
Index: /issm/trunk/src/m/plot/plotboxpos.m
===================================================================
--- /issm/trunk/src/m/plot/plotboxpos.m	(revision 14310)
+++ /issm/trunk/src/m/plot/plotboxpos.m	(revision 14310)
@@ -0,0 +1,91 @@
+function pos = plotboxpos(h)
+%PLOTBOXPOS Returns the position of the plotted axis region
+%
+% pos = plotboxpos(h)
+%
+% This function returns the position of the plotted region of an axis,
+% which may differ from the actual axis position, depending on the axis
+% limits, data aspect ratio, and plot box aspect ratio.  The position is
+% returned in the same units as the those used to define the axis itself.
+% This function can only be used for a 2D plot.  
+%
+% Input variables:
+%
+%   h:      axis handle of a 2D axis (if ommitted, current axis is used).
+%
+% Output variables:
+%
+%   pos:    four-element position vector, in same units as h
+
+% Copyright 2010 Kelly Kearney
+
+% Check input
+
+if nargin < 1
+    h = gca;
+end
+
+if ~ishandle(h) || ~strcmp(get(h,'type'), 'axes')
+    error('Input must be an axis handle');
+end
+
+% Get position of axis in pixels
+
+currunit = get(h, 'units');
+set(h, 'units', 'pixels');
+axisPos = get(h, 'Position');
+set(h, 'Units', currunit);
+
+% Calculate box position based axis limits and aspect ratios
+
+darismanual  = strcmpi(get(h, 'DataAspectRatioMode'),    'manual');
+pbarismanual = strcmpi(get(h, 'PlotBoxAspectRatioMode'), 'manual');
+
+if ~darismanual && ~pbarismanual
+    
+    pos = axisPos;
+    
+else
+
+    dx = diff(get(h, 'XLim'));
+    dy = diff(get(h, 'YLim'));
+    dar = get(h, 'DataAspectRatio');
+    pbar = get(h, 'PlotBoxAspectRatio');
+
+    limDarRatio = (dx/dar(1))/(dy/dar(2));
+    pbarRatio = pbar(1)/pbar(2);
+    axisRatio = axisPos(3)/axisPos(4);
+
+    if darismanual
+        if limDarRatio > axisRatio
+            pos(1) = axisPos(1);
+            pos(3) = axisPos(3);
+            pos(4) = axisPos(3)/limDarRatio;
+            pos(2) = (axisPos(4) - pos(4))/2 + axisPos(2);
+        else
+            pos(2) = axisPos(2);
+            pos(4) = axisPos(4);
+            pos(3) = axisPos(4) * limDarRatio;
+            pos(1) = (axisPos(3) - pos(3))/2 + axisPos(1);
+        end
+    elseif pbarismanual
+        if pbarRatio > axisRatio
+            pos(1) = axisPos(1);
+            pos(3) = axisPos(3);
+            pos(4) = axisPos(3)/pbarRatio;
+            pos(2) = (axisPos(4) - pos(4))/2 + axisPos(2);
+        else
+            pos(2) = axisPos(2);
+            pos(4) = axisPos(4);
+            pos(3) = axisPos(4) * pbarRatio;
+            pos(1) = (axisPos(3) - pos(3))/2 + axisPos(1);
+        end
+    end
+end
+
+% Convert plot box position to the units used by the axis
+
+temp = axes('Units', 'Pixels', 'Position', pos, 'Visible', 'off', 'parent', get(h, 'parent'));
+set(temp, 'Units', currunit);
+pos = get(temp, 'position');
+delete(temp);
Index: /issm/trunk/src/m/plot/plotmodel.m
===================================================================
--- /issm/trunk/src/m/plot/plotmodel.m	(revision 14309)
+++ /issm/trunk/src/m/plot/plotmodel.m	(revision 14310)
@@ -34,13 +34,54 @@
 
 	%Create figure 
+	f=figure(figurenumber);clf;
 	if strcmpi(getfieldvalue(options.list{1},'visible','on'),'off'),
-		F=figure(figurenumber);clf;
-		set(F,'Visible','Off');
-	else
-		figure(figurenumber);clf;
+		set(f,'Visible','Off');
 	end
 
-	%Use zbuffer renderer (snoother colors)
-	set(gcf,'Renderer','zbuffer');
+	if exist(options.list{1},'figposition'), % {{{
+		figposition=getfieldvalue(options.list{1},'figposition');
+		if ischar(figposition),
+			if strcmpi(figposition,'larour'),
+				set(gcf,'Position',[1604 4 1594 1177]);
+			elseif strcmpi(figposition,'larour2'),
+				set(gcf,'Position',[756    62   827   504]);
+			elseif strcmpi(figposition,'mathieu'),
+				set(gcf,'Position',[300 1 1580 1150]);
+			elseif strcmpi(figposition,'fullscreen'),
+				set(gcf,'Position',get(0,'ScreenSize'));
+			elseif strcmpi(figposition,'halfright'),
+				screen=get(0,'ScreenSize');
+				left=screen(1); bott=screen(2); widt=screen(3); heig=screen(4)-25;
+				set(gcf,'Position',fix([left+widt/2 bott widt/2 heig]));
+			elseif strcmpi(figposition,'halfleft'),
+				screen=get(0,'ScreenSize');
+				left=screen(1); bott=screen(2); widt=screen(3); heig=screen(4)-25;
+				set(gcf,'Position',fix([left bott widt/2 heig]));
+			elseif strcmpi(figposition,'square'),
+				screen=get(0,'ScreenSize');
+				left=screen(1); bott=screen(2); widt=min(screen(3)-25,screen(4)-25);
+				set(gcf,'Position',fix([left+(screen(3)-widt) bott widt widt]));
+			elseif strcmpi(figposition,'portrait'),
+				%reformat with letter paper size (8.5" x 11")
+				screen=get(0,'ScreenSize');
+				left=screen(1); bott=screen(2); widt=screen(3); heig=screen(4)-25;
+				portrait=fix([left+widt-(heig*8.5/11) bott heig*8.5/11 heig]);
+				set(gcf,'Position',portrait)
+			elseif strcmpi(figposition,'landscape'),
+				%reformat with letter paper size (8.5" x 11")
+				screen=get(0,'ScreenSize');
+				left=screen(1); bott=screen(2); widt=screen(3); heig=screen(4)-25;
+				landscape=fix([left+widt-(heig*11/8.5) bott heig*11/8.5 heig]);
+				set(gcf,'Position',landscape)
+			else
+				disp('''figposition'' string not supported yet');
+			end
+		else
+			set(gcf,'Position',figposition);
+		end
+	end % }}}
+
+	%Use zbuffer renderer (snoother colors) and white background
+	set(f,'Renderer','zbuffer','color',getfieldvalue(options.list{1},'figurebackgroundcolor','w'));
 
 	%Go through all data plottable and close window if an error occurs
@@ -48,4 +89,6 @@
 		for i=1:numberofplots,
 			plot_manager(getfieldvalue(options.list{i},'model',md),options.list{i},subplotwidth,nlines,ncols,i);
+			%List all unused options
+			displayunused(options.list{i})
 		end
 	catch me,
Index: /issm/trunk/src/m/plot/plotmodel.py
===================================================================
--- /issm/trunk/src/m/plot/plotmodel.py	(revision 14309)
+++ /issm/trunk/src/m/plot/plotmodel.py	(revision 14310)
@@ -1,2 +1,3 @@
+import numpy as npy
 
 try:
@@ -21,4 +22,8 @@
 	subplotwidth=ceil(sqrt(options.numberofplots))
 	
+	#Get figure number and number of plots
+	figurenumber=options.figurenumber
+	numberofplots=options.numberofplots
+
 	#if nlines and ncols specified, then bypass
 	if options.list[0].exist('nlines'):
@@ -26,5 +31,5 @@
 		nl=True
 	else:
-		nlines=subplotwidth
+		nlines=npy.ceil(numberofplots/subplotwidth)
 		nl=False
 	
@@ -40,7 +45,4 @@
 		raise StandardError('error: nlines and ncols need to be specified together, or not at all')
 	
-	#Get figure number and number of plots
-	figurenumber=options.figurenumber
-	numberofplots=options.numberofplots
 	
 	#Go through plots
@@ -60,8 +62,7 @@
 		#try:
 		for i in xrange(numberofplots):
-			plot_manager(options.list[i].getfieldvalue('model',md),options.list[i],subplotwidth,nlines,ncols,i)
+			plot_manager(options.list[i].getfieldvalue('model',md),options.list[i],subplotwidth,nlines,ncols,i+1)
 		#except StandardError:
 		#	print 'error in plot_manager'
 	else:
 		raise StandardError('plotmodel error message: no output data found.')
-			
Index: /issm/trunk/src/m/qmu/dakota_cdfs.m
===================================================================
--- /issm/trunk/src/m/qmu/dakota_cdfs.m	(revision 14309)
+++ /issm/trunk/src/m/qmu/dakota_cdfs.m	(revision 14310)
@@ -247,5 +247,5 @@
         irow=irow+1;
         cdf(irow,1)=resp(i);
-        cdf(irow,2)=normcdf(resp(i),mu,sigma);
+        cdf(irow,2)=normcdf_issm(resp(i),mu,sigma);
         cdf(irow,3)=(mu-resp(i))/sigma;
         cdf(irow,4)=(mu-resp(i))/sigma;
@@ -256,8 +256,8 @@
     for i=1:length(prob)
         irow=irow+1;
-        cdf(irow,1)=norminv(prob(i),mu,sigma);
+        cdf(irow,1)=norminv_issm(prob(i),mu,sigma);
         cdf(irow,2)=prob(i);
-        cdf(irow,3)=-norminv(prob(i),0,1);
-        cdf(irow,4)=-norminv(prob(i),0,1);
+        cdf(irow,3)=-norminv_issm(prob(i),0,1);
+        cdf(irow,4)=-norminv_issm(prob(i),0,1);
     end
 
@@ -267,5 +267,5 @@
         irow=irow+1;
         cdf(irow,1)=mu-sigma*rel(i);
-        cdf(irow,2)=normcdf(-rel(i),0,1);
+        cdf(irow,2)=normcdf_issm(-rel(i),0,1);
         cdf(irow,3)=rel(i);
         cdf(irow,4)=rel(i);
@@ -277,5 +277,5 @@
         irow=irow+1;
         cdf(irow,1)=mu-sigma*grel(i);
-        cdf(irow,2)=normcdf(-grel(i),0,1);
+        cdf(irow,2)=normcdf_issm(-grel(i),0,1);
         cdf(irow,3)=grel(i);
         cdf(irow,4)=grel(i);
Index: /issm/trunk/src/m/qmu/dakota_moments.m
===================================================================
--- /issm/trunk/src/m/qmu/dakota_moments.m	(revision 14309)
+++ /issm/trunk/src/m/qmu/dakota_moments.m	(revision 14310)
@@ -133,8 +133,15 @@
     sigma=std(samp);
 
-    muci(1)   =mu-tinv(prob,nsamp-1)*sigma/sqrt(nsamp);
-    muci(2)   =mu+tinv(prob,nsamp-1)*sigma/sqrt(nsamp);
-    sigmaci(1)=sigma*sqrt((nsamp-1)/chi2inv(prob  ,nsamp-1));
-    sigmaci(2)=sigma*sqrt((nsamp-1)/chi2inv(1-prob,nsamp-1));
+	try
+        muci(1,1)   =mu-tinv(prob,nsamp-1)*sigma/sqrt(nsamp);
+        muci(2,1)   =mu+tinv(prob,nsamp-1)*sigma/sqrt(nsamp);
+        sigmaci(1,1)=sigma*sqrt((nsamp-1)/chi2inv(prob  ,nsamp-1));
+        sigmaci(2,1)=sigma*sqrt((nsamp-1)/chi2inv(1-prob,nsamp-1));
+	catch me
+        muci(1,1)   =mu;
+        muci(2,1)   =mu;
+        sigmaci(1,1)=sigma;
+        sigmaci(2,1)=sigma;
+	end
 
 end
Index: /issm/trunk/src/m/qmu/dakota_out_parse.m
===================================================================
--- /issm/trunk/src/m/qmu/dakota_out_parse.m	(revision 14309)
+++ /issm/trunk/src/m/qmu/dakota_out_parse.m	(revision 14310)
@@ -112,8 +112,13 @@
     elseif strncmp(fline,'Moments for each response function',34)
         [dresp]=moments_read(fidi,dresp,fline);
+    elseif strncmp(fline,'Moment-based statistics for each response function',50)
+        [dresp]=mbstats_read(fidi,dresp,fline);
     elseif strncmp(fline,'95% confidence intervals for each response function',51)
         [dresp]=cis_read(fidi,dresp,fline);
-    elseif strncmp(fline,'Probabilities for each response function',40)
+    elseif strncmp(fline,'Probabilities for each response function',40) || ...
+           strncmp(fline,'Level mappings for each response function',41)
         [dresp]=cdfs_read(fidi,dresp,fline);
+    elseif strncmp(fline,'Probability Density Function (PDF) histograms for each response function',72)
+        [dresp]=pdfs_read(fidi,dresp,fline);
     elseif strncmp(fline,'Simple Correlation Matrix',25)
         [scm]=corrmat_read(fidi,'Simple Correlation Matrix',fline);
@@ -137,5 +142,4 @@
     else
         display(['Unexpected line: ' deblank(fline)]);
-        fline=fgetl(fidi);
     end
     fline=fgetl(fidi);
@@ -198,5 +202,5 @@
     %dstddev=std    (data,0);
     [dmean,dstddev,dmeanci,dstddevci]=...
-        normfit(data,0.05);
+        normfit_issm(data,0.05);
 else
     dmean    =zeros(1,size(data,2));
@@ -206,13 +210,13 @@
     for i=1:size(data,2)
         [dmean(1,i),dstddev(1,i),dmeanci(:,i),dstddevci(:,i)]=...
-            normfit(data(:,i),0.05);
-    end
-end
-
-dmin   =min    (data,[],1);
-dquart1=prctile(data,25,1);
-dmedian=median (data,1);
-dquart3=prctile(data,75,1);
-dmax   =max    (data,[],1);
+            normfit_issm(data(:,i),0.05);
+    end
+end
+
+dmin   =min         (data,[],1);
+dquart1=prctile_issm(data,25,1);
+dmedian=median      (data,1);
+dquart3=prctile_issm(data,75,1);
+dmax   =max         (data,[],1);
 
 %  same as Dakota scm, Excel correl
@@ -316,4 +320,43 @@
 end
 
+%%  function to find and read the moment-based statistics
+
+function [dresp]=mbstats_read(fidi,dresp,fline)
+
+if ~exist('fline','var') || isempty(fline) || ~ischar(fline)
+    [fline]=findline(fidi,'Moment-based statistics for each response function');
+    if ~ischar(fline)
+        return
+    end
+end
+
+display('Reading moment-based statistics for response functions:');
+
+%  skip column headings of moment-based statistics
+
+    fline=fgetl(fidi);
+
+while 1
+    fline=fgetl(fidi);
+    if isempty(fline)
+        break;
+    end
+    [ntokens,tokens]=fltokens(fline);
+
+%  add new response function and moment-based statistics
+
+    dresp(end+1).descriptor=tokens{1}{ 1};
+    display(sprintf('  %s',dresp(end).descriptor));
+    dresp(end  ).mean      =tokens{1}{ 2};
+    dresp(end  ).stddev    =tokens{1}{ 3};
+    dresp(end  ).skewness  =tokens{1}{ 4};
+    dresp(end  ).kurtosis  =tokens{1}{ 5};
+end
+
+display(sprintf('  Number of Dakota response functions=%d.',...
+    length(dresp)));
+
+end
+
 %%  function to find and read the confidence intervals
 
@@ -336,4 +379,14 @@
     end
     [ntokens,tokens]=fltokens(fline);
+
+%  check for column headings in Dakota 5.2
+
+    if (ntokens == 4)
+        fline=fgetl(fidi);
+        if isempty(fline)
+            break;
+        end
+        [ntokens,tokens]=fltokens(fline);
+    end
 
 %  find response function associated with confidence intervals
@@ -354,8 +407,15 @@
 %  add confidence intervals to response functions
 
-    dresp(i).meanci  (1,1)=tokens{1}{ 5};
-    dresp(i).meanci  (2,1)=tokens{1}{ 6};
-    dresp(i).stddevci(1,1)=tokens{1}{12};
-    dresp(i).stddevci(2,1)=tokens{1}{13};
+    if (ntokens == 14)
+        dresp(i).meanci  (1,1)=tokens{1}{ 5};
+        dresp(i).meanci  (2,1)=tokens{1}{ 6};
+        dresp(i).stddevci(1,1)=tokens{1}{12};
+        dresp(i).stddevci(2,1)=tokens{1}{13};
+    else
+        dresp(i).meanci  (1,1)=tokens{1}{ 2};
+        dresp(i).meanci  (2,1)=tokens{1}{ 3};
+        dresp(i).stddevci(1,1)=tokens{1}{ 4};
+        dresp(i).stddevci(2,1)=tokens{1}{ 5};
+    end
 end
 
@@ -372,5 +432,8 @@
     [fline]=findline(fidi,'Probabilities for each response function');
     if ~ischar(fline)
-        return
+        [fline]=findline(fidi,'Level mappings for each response function');
+        if ~ischar(fline)
+            return
+        end
     end
 end
@@ -425,5 +488,71 @@
                     dresp(idresp).cdf(icdf,i)=tokens{1}{itoken};
                 end
-            end;
+            end
+            fline=fgetl(fidi);
+        end
+    end
+end
+
+display(sprintf('  Number of Dakota response functions=%d.',...
+    length(dresp)));
+
+end
+
+%%  function to find and read the pdf's
+
+function [dresp]=pdfs_read(fidi,dresp,fline)
+
+if ~exist('fline','var') || isempty(fline) || ~ischar(fline)
+    [fline]=findline(fidi,'Probability Density Function (PDF) histograms for each response function');
+    if ~ischar(fline)
+        return
+    end
+end
+
+display('Reading PDF''s for response functions:');
+
+while ischar(fline) && ~isempty(fline)
+    fline=fgetl(fidi);
+    if ~ischar(fline)
+        break;
+    end
+
+%  process header line of pdf
+
+    while ischar(fline) && ~isempty(fline)
+        [ntokens,tokens]=fltokens(fline);
+
+%  find response function associated with pdf
+
+        idresp=0;
+        for i=1:length(dresp)
+            if strcmpi(tokens{1}{ 3},dresp(i).descriptor)
+                idresp=i;
+                break;
+            end
+        end
+        if ~idresp
+            idresp=length(dresp)+1;
+            dresp(idresp).descriptor=tokens{1}{ 3};
+            display(sprintf('  %s',dresp(idresp).descriptor));
+        end
+
+%  skip column headings of pdf
+
+        fline=fgetl(fidi);
+        fline=fgetl(fidi);
+
+%  read and add pdf table to response function
+
+        fline=fgetl(fidi);
+        ipdf=0;
+        while ischar(fline) && ~isempty(fline) && ...
+              ~strncmpi(fline,'PDF for', 7)
+            [ntokens,tokens]=fltokens(fline);
+            ipdf=ipdf+1;
+            dresp(idresp).pdf(ipdf,1:3)=NaN;
+            for i=1:3
+                dresp(idresp).pdf(ipdf,i)=tokens{1}{i};
+            end
             fline=fgetl(fidi);
         end
Index: /issm/trunk/src/m/qmu/plot/plot_cdf.m
===================================================================
--- /issm/trunk/src/m/qmu/plot/plot_cdf.m	(revision 14309)
+++ /issm/trunk/src/m/qmu/plot/plot_cdf.m	(revision 14310)
@@ -139,7 +139,7 @@
         if strncmpi(cplot,'p',1) && ...
            exist('ynorm','var') && strncmpi(ynorm,'y',1)
-             ydata(1:lcdfr(i),i)=norminv(dresp(i).cdf(:,iplot),0,1);
+             ydata(1:lcdfr(i),i)=norminv_issm(dresp(i).cdf(:,iplot),0,1);
         else
-             ydata(1:lcdfr(i),i)=        dresp(i).cdf(:,iplot);
+             ydata(1:lcdfr(i),i)=             dresp(i).cdf(:,iplot);
         end
     end
@@ -237,5 +237,5 @@
     end
 
-    tick  = norminv(yprob,0,1);
+    tick  = norminv_issm(yprob,0,1);
     set(ax1,'YTick',tick,'YTickLabel',label);
     ylim([tick(1) tick(end)])
Index: /issm/trunk/src/m/qmu/plot/plot_hist_norm.m
===================================================================
--- /issm/trunk/src/m/qmu/plot/plot_hist_norm.m	(revision 14309)
+++ /issm/trunk/src/m/qmu/plot/plot_hist_norm.m	(revision 14310)
@@ -224,9 +224,9 @@
 if exist('mu','var') && exist('sigma','var')
     for i=1:ncol
-        dbelow(end+1)=normcdf(edges(  1),mu(i),sigma(i));
+        dbelow(end+1)=normcdf_issm(edges(  1),mu(i),sigma(i));
         dhistc(1:size(dhistc,1)-1,end+1)=...
-            normcdf(edges(2:end  ),mu(i),sigma(i))-...
-            normcdf(edges(1:end-1),mu(i),sigma(i));
-        dabove(end+1)=norminv(edges(end),mu(i),sigma(i));
+            normcdf_issm(edges(2:end  ),mu(i),sigma(i))-...
+            normcdf_issm(edges(1:end-1),mu(i),sigma(i));
+        dabove(end+1)=norminv_issm(edges(end),mu(i),sigma(i));
         if exist('descr','var')
             descr(end+1)={[descr{i} ' norm']};
Index: /issm/trunk/src/m/qmu/plot/plot_hist_norm_ci.m
===================================================================
--- /issm/trunk/src/m/qmu/plot/plot_hist_norm_ci.m	(revision 14309)
+++ /issm/trunk/src/m/qmu/plot/plot_hist_norm_ci.m	(revision 14310)
@@ -129,5 +129,5 @@
 %  calculate 95% confidence intervals (same as dakota)
         [mu(i),sigma(i),muci(:,i),sigmaci(:,i)]=...
-            normfit(sampr(:,i),0.05);
+            normfit_issm(sampr(:,i),0.05);
     end
     display('Using calculated normal fits.')
@@ -191,9 +191,9 @@
 if exist('mu','var') && exist('sigma','var')
     for i=1:ncol
-        dbelow(end+1)=normcdf(edges(  1),mu(i),sigma(i));
+        dbelow(end+1)=normcdf_issm(edges(  1),mu(i),sigma(i));
         dhistc(1:size(dhistc,1)-1,end+1)=...
-            normcdf(edges(2:end  ),mu(i),sigma(i))-...
-            normcdf(edges(1:end-1),mu(i),sigma(i));
-        dabove(end+1)=norminv(edges(end),mu(i),sigma(i));
+            normcdf_issm(edges(2:end  ),mu(i),sigma(i))-...
+            normcdf_issm(edges(1:end-1),mu(i),sigma(i));
+        dabove(end+1)=norminv_issm(edges(end),mu(i),sigma(i));
         if exist('descr','var')
             descr(end+1)={[descr{i} ' norm']};
@@ -204,9 +204,9 @@
 if exist('muci','var') && exist('sigmaci','var')
     for i=1:ncol
-        dbelow(end+1)=normcdf(edges(  1),muci(1,i),sigmaci(2,i));
+        dbelow(end+1)=normcdf_issm(edges(  1),muci(1,i),sigmaci(2,i));
         dhistc(1:size(dhistc,1)-1,end+1)=...
-            normcdf(edges(2:end  ),muci(1,i),sigmaci(2,i))-...
-            normcdf(edges(1:end-1),muci(1,i),sigmaci(2,i));
-        dabove(end+1)=norminv(edges(end),muci(1,i),sigmaci(2,i));
+            normcdf_issm(edges(2:end  ),muci(1,i),sigmaci(2,i))-...
+            normcdf_issm(edges(1:end-1),muci(1,i),sigmaci(2,i));
+        dabove(end+1)=norminv_issm(edges(end),muci(1,i),sigmaci(2,i));
         if exist('descr','var')
             descr(end+1)={[descr{i} ' norm-+']};
@@ -214,9 +214,9 @@
     end
     for i=1:ncol
-        dbelow(end+1)=normcdf(edges(  1),muci(1,i),sigmaci(1,i));
+        dbelow(end+1)=normcdf_issm(edges(  1),muci(1,i),sigmaci(1,i));
         dhistc(1:size(dhistc,1)-1,end+1)=...
-            normcdf(edges(2:end  ),muci(1,i),sigmaci(1,i))-...
-            normcdf(edges(1:end-1),muci(1,i),sigmaci(1,i));
-        dabove(end+1)=norminv(edges(end),muci(1,i),sigmaci(1,i));
+            normcdf_issm(edges(2:end  ),muci(1,i),sigmaci(1,i))-...
+            normcdf_issm(edges(1:end-1),muci(1,i),sigmaci(1,i));
+        dabove(end+1)=norminv_issm(edges(end),muci(1,i),sigmaci(1,i));
         if exist('descr','var')
             descr(end+1)={[descr{i} ' norm--']};
@@ -224,9 +224,9 @@
     end
     for i=1:ncol
-        dbelow(end+1)=normcdf(edges(  1),muci(2,i),sigmaci(1,i));
+        dbelow(end+1)=normcdf_issm(edges(  1),muci(2,i),sigmaci(1,i));
         dhistc(1:size(dhistc,1)-1,end+1)=...
-            normcdf(edges(2:end  ),muci(2,i),sigmaci(1,i))-...
-            normcdf(edges(1:end-1),muci(2,i),sigmaci(1,i));
-        dabove(end+1)=norminv(edges(end),muci(2,i),sigmaci(1,i));
+            normcdf_issm(edges(2:end  ),muci(2,i),sigmaci(1,i))-...
+            normcdf_issm(edges(1:end-1),muci(2,i),sigmaci(1,i));
+        dabove(end+1)=norminv_issm(edges(end),muci(2,i),sigmaci(1,i));
         if exist('descr','var')
             descr(end+1)={[descr{i} ' norm+-']};
@@ -234,9 +234,9 @@
     end
     for i=1:ncol
-        dbelow(end+1)=normcdf(edges(  1),muci(2,i),sigmaci(2,i));
+        dbelow(end+1)=normcdf_issm(edges(  1),muci(2,i),sigmaci(2,i));
         dhistc(1:size(dhistc,1)-1,end+1)=...
-            normcdf(edges(2:end  ),muci(2,i),sigmaci(2,i))-...
-            normcdf(edges(1:end-1),muci(2,i),sigmaci(2,i));
-        dabove(end+1)=norminv(edges(end),muci(2,i),sigmaci(2,i));
+            normcdf_issm(edges(2:end  ),muci(2,i),sigmaci(2,i))-...
+            normcdf_issm(edges(1:end-1),muci(2,i),sigmaci(2,i));
+        dabove(end+1)=norminv_issm(edges(end),muci(2,i),sigmaci(2,i));
         if exist('descr','var')
             descr(end+1)={[descr{i} ' norm++']};
Index: /issm/trunk/src/m/qmu/plot/plot_normdist_bars.m
===================================================================
--- /issm/trunk/src/m/qmu/plot/plot_normdist_bars.m	(revision 14309)
+++ /issm/trunk/src/m/qmu/plot/plot_normdist_bars.m	(revision 14310)
@@ -126,5 +126,5 @@
 if ~isfield(dresp,'mean') || ~isfield(dresp,'stddev')
     for i=1:length(dresp)
-        [dresp(i).mean,dresp(i).stddev]=normfit(dresp(i).sample);
+        [dresp(i).mean,dresp(i).stddev]=normfit_issm(dresp(i).sample);
     end
 end
@@ -141,5 +141,5 @@
 for i=1:length(dresp)
     descr(i)=cellstr(dresp(i).descriptor);
-    data(i,:)=norminv(prob,dresp(i).mean,dresp(i).stddev);
+    data(i,:)=norminv_issm(prob,dresp(i).mean,dresp(i).stddev);
 end
 
Index: /issm/trunk/src/m/qmu/plot/plot_rlev_bars_ci.m
===================================================================
--- /issm/trunk/src/m/qmu/plot/plot_rlev_bars_ci.m	(revision 14309)
+++ /issm/trunk/src/m/qmu/plot/plot_rlev_bars_ci.m	(revision 14310)
@@ -133,5 +133,5 @@
         [dresp(i).mean,dresp(i).stddev,...
          dresp(i).meanci,dresp(i).stddevci]=...
-            normfit(sampr(:,i),0.05);
+            normfit_issm(sampr(:,i),0.05);
         display('Using calculated normal fits from sample data.')
     end
@@ -140,7 +140,7 @@
 %  use minus/plus integer standard deviations
         sdvect=[-4 -3 -2 -1 0 1 2 3 4];
-        dresp(i).cdf(:,2)=normcdf(sdvect,0,1);
-        dresp(i).cdf(:,1)=norminv(dresp(i).cdf(:,2),...
-                                  dresp(i).mean,dresp(i).stddev);
+        dresp(i).cdf(:,2)=normcdf_issm(sdvect,0,1);
+        dresp(i).cdf(:,1)=norminv_issm(dresp(i).cdf(:,2),...
+                                       dresp(i).mean,dresp(i).stddev);
         display('Using integer standard deviations for percentages.')
 
@@ -176,5 +176,5 @@
            isfield(dresp(i),'stddev') && ~isempty(dresp(i).stddev)
             descr(end+1)=cellstr([dresp(i).descriptor ' norm']);
-            cdfr(end+1,:)=norminv(dresp(i).cdf(:,2),dresp(i).mean,dresp(i).stddev);
+            cdfr(end+1,:)=norminv_issm(dresp(i).cdf(:,2),dresp(i).mean,dresp(i).stddev);
         end
         if isfield(dresp(i),'meanci'  ) && ~isempty(dresp(i).meanci  ) && ...
@@ -184,8 +184,8 @@
             descr(end+1)=cellstr([dresp(i).descriptor ' norm+-']);
             descr(end+1)=cellstr([dresp(i).descriptor ' norm++']);
-            cdfr(end+1,:)=norminv(dresp(i).cdf(:,2),dresp(i).meanci(1),dresp(i).stddevci(2));
-            cdfr(end+1,:)=norminv(dresp(i).cdf(:,2),dresp(i).meanci(1),dresp(i).stddevci(1));
-            cdfr(end+1,:)=norminv(dresp(i).cdf(:,2),dresp(i).meanci(2),dresp(i).stddevci(1));
-            cdfr(end+1,:)=norminv(dresp(i).cdf(:,2),dresp(i).meanci(2),dresp(i).stddevci(2));
+            cdfr(end+1,:)=norminv_issm(dresp(i).cdf(:,2),dresp(i).meanci(1),dresp(i).stddevci(2));
+            cdfr(end+1,:)=norminv_issm(dresp(i).cdf(:,2),dresp(i).meanci(1),dresp(i).stddevci(1));
+            cdfr(end+1,:)=norminv_issm(dresp(i).cdf(:,2),dresp(i).meanci(2),dresp(i).stddevci(1));
+            cdfr(end+1,:)=norminv_issm(dresp(i).cdf(:,2),dresp(i).meanci(2),dresp(i).stddevci(2));
         end
     end
Index: /issm/trunk/src/m/qmu/plot/plot_sampdist_bars.m
===================================================================
--- /issm/trunk/src/m/qmu/plot/plot_sampdist_bars.m	(revision 14309)
+++ /issm/trunk/src/m/qmu/plot/plot_sampdist_bars.m	(revision 14310)
@@ -127,9 +127,9 @@
    ~isfield(dresp,'max')
     for i=1:length(dresp)
-        dresp(i).min   =min    (dresp(i).sample);
-        dresp(i).quart1=prctile(dresp(i).sample,25);
-        dresp(i).median=median (dresp(i).sample);
-        dresp(i).quart3=prctile(dresp(i).sample,75);
-        dresp(i).max   =max    (dresp(i).sample);
+        dresp(i).min   =min         (dresp(i).sample);
+        dresp(i).quart1=prctile_issm(dresp(i).sample,25);
+        dresp(i).median=median      (dresp(i).sample);
+        dresp(i).quart3=prctile_issm(dresp(i).sample,75);
+        dresp(i).max   =max         (dresp(i).sample);
     end
 end
Index: /issm/trunk/src/m/solve/parseresultsfromdisk.py
===================================================================
--- /issm/trunk/src/m/solve/parseresultsfromdisk.py	(revision 14309)
+++ /issm/trunk/src/m/solve/parseresultsfromdisk.py	(revision 14310)
@@ -43,8 +43,10 @@
 	result=ReadData(fid)
 	while result:
-		if result['step'] > len(results):
+		if   result['step'] > len(results):
 			for i in xrange(len(results),result['step']-1):
 				results.append(None)
 			results.append(resultsclass.results())
+		elif results[result['step']-1] is None:
+			results[result['step']-1]=resultsclass.results()
 		#Get time and step
 		setattr(results[result['step']-1],'step',result['step'])
Index: /issm/trunk/src/m/solve/process_solve_options.m
===================================================================
--- /issm/trunk/src/m/solve/process_solve_options.m	(revision 14309)
+++ /issm/trunk/src/m/solve/process_solve_options.m	(revision 14310)
@@ -11,5 +11,6 @@
 if ~ismember(solution_type,[DiagnosticSolutionEnum(),PrognosticSolutionEnum(),ThermalSolutionEnum(),...
 		SteadystateSolutionEnum(),TransientSolutionEnum(),EnthalpySolutionEnum(),...
-		BalancethicknessSolutionEnum(),BedSlopeSolutionEnum(),SurfaceSlopeSolutionEnum(),HydrologySolutionEnum(),FlaimSolutionEnum()]),
+		BalancethicknessSolutionEnum(),WeakBalancethicknessSolutionEnum(),BedSlopeSolutionEnum(),...
+		SurfaceSlopeSolutionEnum(),HydrologySolutionEnum(),FlaimSolutionEnum()]),
 	error(['process_solve_options error message: solution_type ' EnumToString(solution_type) ' not supported yet!']);
 end
Index: /issm/trunk/src/wrappers/Exp2Kml/Exp2Kml.h
===================================================================
--- /issm/trunk/src/wrappers/Exp2Kml/Exp2Kml.h	(revision 14309)
+++ /issm/trunk/src/wrappers/Exp2Kml/Exp2Kml.h	(revision 14310)
@@ -51,3 +51,2 @@
 
 #endif
-
Index: /issm/trunk/src/wrappers/ExpSimplify/ExpSimplify.cpp
===================================================================
--- /issm/trunk/src/wrappers/ExpSimplify/ExpSimplify.cpp	(revision 14310)
+++ /issm/trunk/src/wrappers/ExpSimplify/ExpSimplify.cpp	(revision 14310)
@@ -0,0 +1,196 @@
+/*\file ExpSimplify.c
+ *\brief: exp to kml file conversion mex module.
+ */
+#include "./ExpSimplify.h"
+
+void ExpSimplifyUsage(void){/*{{{*/
+	_pprintLine_("ExpSimplify - Simplify Exp contour");
+	_pprintLine_("");
+	_pprintLine_("   Recursive Douglas-Peucker Polygon Simplification");
+	_pprintLine_("");
+	_pprintLine_("   Usage:");
+	_pprintLine_("      ExpSimplify(expfile,tol);");
+	_pprintLine_("      - expfile: name of the exp file");
+	_pprintLine_("      - tol:  tolerance (maximal euclidean distance allowed between the new line and a vertex)");
+	_pprintLine_("");
+	_pprintLine_("   Example:");
+	_pprintLine_("      ExpSimplify('file.exp',100);");
+}/*}}}*/
+void simplify(Contour<double>* contour,bool* flags,int ind0,int ind1,double tolerance){/*{{{*/
+
+	bool    closed    = false;
+	double  distance,beta,dx,dy;
+	double  maxdistance;
+	int     index;
+	double *x      = contour->x;
+	double *y      = contour->y;
+
+	/*Some checks*/
+	_assert_(ind0>=0 && ind0<contour->nods);
+	_assert_(ind1>=0 && ind1<contour->nods);
+	_assert_(ind1-ind0>=0);
+
+	/*Check wether this portion is closed*/
+	if(x[ind0]==x[ind1] && y[ind0]==y[ind1]) closed=true;
+
+	if(closed){
+
+		/*calculate the shortest distance of all vertices between ind0 and ind1*/
+		for(int i=ind0;i<ind1;i++){
+			distance = sqrt((x[i]-x[i+1])*(x[i]-x[i+1]) + (y[i]-y[i+1])*(y[i]-y[i+1]));
+			if(i==ind0 || distance>maxdistance){
+				maxdistance=distance;
+				index = i;
+			}
+		}
+	}
+	else{
+		/*calculate shortest distance of all points to the line from ind0 to ind1
+		 * subtract starting point from other locations
+		 *
+		 * d = || (x-x0) - beta (xend - x0) ||
+		 * <x-x0,xend-x0>      = ||x-x0|| ||xend-x0|| cos(alpha)
+		 * beta ||xend-x0|| = ||x-x0|| cos(alpha)
+		 *
+		 * So: beta = <x-x0,xend-x0>/<xend-x0,xend-x0>  */
+		 
+		for(int i=ind0+1;i<ind1;i++){
+			beta = ((x[i]-x[ind0])*(x[ind1]-x[ind0]) + (y[i]-y[ind0])*(y[ind1]-y[ind0]))/((x[ind1]-x[ind0])*(x[ind1]-x[ind0])+(y[ind1]-y[ind0])*(y[ind1]-y[ind0]));
+			dx   = x[i]-beta*x[ind1]+(beta-1.)*x[ind0];
+			dy   = y[i]-beta*y[ind1]+(beta-1.)*y[ind0];
+			distance = sqrt(dx*dx + dy*dy);
+			if(i==ind0+1 || distance>maxdistance){
+				maxdistance = distance;
+				index       = i;
+			}
+		}
+
+	}
+
+	/*if the maximum distance is smaller than the tolerance remove vertices between ind0 and ind1*/
+	if(maxdistance<tolerance){
+		if(ind0!=ind1-1){
+			for(int i=ind0+1;i<ind1;i++) flags[i]=false;
+		}
+	}
+	else{
+		/*if not, call simplifyrec for the segments between ind0 and index
+		 * (index and ind1)*/
+		simplify(contour,flags,ind0 ,index,tolerance);
+		simplify(contour,flags,index,ind1, tolerance);
+	}
+
+
+}/*}}}*/
+WRAPPER(ExpSimplify){
+
+	int i,verbose=1;
+
+	/*input: */
+	char*    expfile  = NULL;
+	double   tolerance;
+
+	/*output*/
+	DataSet* oldcontours = NULL;
+	DataSet* newcontours = NULL;
+
+	/*Boot module: */
+	MODULEBOOT();
+
+	/*checks on arguments: */
+	CHECKARGUMENTS(NLHS,NRHS,&ExpSimplifyUsage);
+
+	/*Input datasets: */
+	FetchData(&expfile,  EXPFILE);
+	FetchData(&tolerance,TOLERANCE);
+
+	/*some checks*/
+	if(tolerance<0) _error_("tolerance must be a positivve scalar");
+
+	/* Run core computations: */
+	Contour<double>* contour = NULL;
+	Contour<double>* newcontour = NULL;
+	int     nods,newnods;
+	bool*   flags = NULL;
+	double* x = NULL;
+	double* y = NULL;
+	double distance;
+
+	/*Read old contours and allocate new contours*/
+	oldcontours=DomainOutlineRead<double>(expfile);
+	newcontours=new DataSet(0);
+	for(int counter=0;counter<oldcontours->Size();counter++){
+
+		/*Get single contour*/
+		contour = (Contour<double>*)oldcontours->GetObjectByOffset(counter);
+		nods    = contour->nods;
+		x       = contour->x;
+		y       = contour->y;
+		printf("   Initial number of vertices in contour #%i: %i\n",counter+1,nods);
+
+		/*Allocate flags (1=keep, 0=remove)*/
+		if(nods>0) flags   = xNew<bool>(nods);
+
+		if(nods==0){
+			/*Don't do anything*/
+		}
+		else if(nods==1){
+			flags[0] = true;
+		}
+		else if(nods==2){
+			/*check if the distance between both is less than the tolerance
+			 * If so, return the center*/
+			distance = sqrt((x[1]-x[0])*(x[1]-x[0]) + (y[1]-y[0])*(y[1]-y[0]));
+			if(distance<=tolerance){
+				x[0]=(x[0]+x[1])/2.;
+				y[0]=(y[0]+y[1])/2.;
+				flags[0] = true;
+				flags[1] = false;
+			}
+			else{
+				flags[0] = true;
+				flags[1] = true;
+			}
+		}
+		else{
+			/*Start recursive call to simplify*/
+			for(int i=0;i<nods;i++) flags[i]=true;
+			simplify(contour,flags,0,nods-1,tolerance);
+		}
+
+		/*Add new contour to newcontours*/
+		newnods = 0;
+		for(int i=0;i<nods;i++) if(flags[i]) newnods++;
+		printf("   New     number of vertices in contour #%i: %i\n",counter+1,newnods);
+		if(newnods){
+			newcontour       = xNew<Contour<double> >(1);
+			newcontour->nods = newnods;
+			newcontour->x    = xNew<double>(newnods);
+			newcontour->y    = xNew<double>(newnods);
+			newnods = 0;
+			for(int i=0;i<nods;i++){
+				if(flags[i]){
+					newcontour->x[newnods] = contour->x[i];
+					newcontour->y[newnods] = contour->y[i];
+					newnods++;
+				}
+			}
+			_assert_(newnods==newcontour->nods);
+
+			/*Add to main dataset*/
+			newcontours->AddObject(newcontour);
+		}
+
+		/*cleanup*/
+		xDelete<bool>(flags);
+	}
+
+	/*Write data: */
+	ExpWrite(newcontours,expfile);
+
+	/*Clean-up*/
+	xDelete<char>(expfile);
+
+	/*end module: */
+	MODULEEND();
+}
Index: /issm/trunk/src/wrappers/ExpSimplify/ExpSimplify.h
===================================================================
--- /issm/trunk/src/wrappers/ExpSimplify/ExpSimplify.h	(revision 14310)
+++ /issm/trunk/src/wrappers/ExpSimplify/ExpSimplify.h	(revision 14310)
@@ -0,0 +1,47 @@
+/*!\file ExpSimplify.h
+ * \brief: prototype for exp to kml file conversion mex module.
+ */
+
+#ifndef _EXPSIMPLIFY_H
+#define _EXPSIMPLIFY_H
+
+#ifdef HAVE_CONFIG_H
+	#include <config.h>
+#else
+	#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+/*For python modules: needs to come before header files inclusion*/
+#ifdef _HAVE_PYTHON_
+#define PY_ARRAY_UNIQUE_SYMBOL PythonIOSymbol
+#endif
+
+#include "../../c/include/globals.h"
+#include "../../c/modules/modules.h"
+#include "../../c/Container/Container.h"
+#include "../../c/shared/shared.h"
+#include "../bindings.h"
+
+#undef __FUNCT__ 
+#define __FUNCT__  "ExpSimplify"
+
+#ifdef _HAVE_MATLAB_MODULES_
+/* serial input macros: */
+#define EXPFILE   prhs[0]
+#define TOLERANCE prhs[1]
+/* serial output macros: */
+#endif
+
+#ifdef _HAVE_PYTHON_MODULES_
+/* serial input macros: */
+#define EXPFILE   PyTuple_GetItem(args,0)
+#define TOLERANCE PyTuple_GetItem(args,1)
+#endif
+
+/* serial arg counts: */
+#undef NRHS
+#define NRHS  2
+#undef NLHS
+#define NLHS  0
+
+#endif
Index: /issm/trunk/src/wrappers/InternalFront/InternalFront.cpp
===================================================================
--- /issm/trunk/src/wrappers/InternalFront/InternalFront.cpp	(revision 14309)
+++ /issm/trunk/src/wrappers/InternalFront/InternalFront.cpp	(revision 14310)
@@ -14,5 +14,4 @@
 	bool*   elementonwater=NULL;
 	int*    elements=NULL;
-	int*    connectivity=NULL;
 	int*    elementconnectivity=NULL;
 	int*    front=NULL;
@@ -20,22 +19,17 @@
 	bool    found;
 	int     numberofelements,numberofsegments;
-	int     N,M;
 	int     i,j,ii,jj,id;
+	int     dummy;
 
 	/*Boot module: */
 	MODULEBOOT();
 
-	/*checks on arguments on the matlab side: */
-	CheckNumMatlabArguments(nlhs,NLHS,nrhs,NRHS,__FUNCT__,&InternalFrontUsage);
+	/*checks on arguments: */
+	CHECKARGUMENTS(NLHS,NRHS,&InternalFrontUsage);
 
-	/*Fetch required fields*/
-	FetchData(&numberofelements,mxGetAssignedField(MODEL,0,"numberofelements"));
-	if(numberofelements<=0) _error_("No elements found in the model");
-	FetchData(&elements,&M,&N,mxGetAssignedField(MODEL,0,"elements"));
-	if(M!=numberofelements || N!=3) _error_("Field 'elements' should be of size [md.numberofelements 3]");
-	FetchData(&elementonwater,&M,&N,mxGetAssignedField(MODEL,0,"elementonwater"));
-	if(M!=numberofelements || N!=1) _error_("Field 'elementonwater' should be of size [md.numberofelements 1]");
-	FetchData(&elementconnectivity,&M,&N,mxGetAssignedField(MODEL,0,"elementconnectivity"));
-	if(M!=numberofelements || N!=3) _error_("Field 'elementconnectivity' should be of size [md.numberofelements 3]");
+	/*Fetch inputs: */
+	FetchData(&elements,&numberofelements,&dummy,ELEMENTS);
+	FetchData(&elementonwater,&dummy,&dummy,ELEMENTONWATER);
+	FetchData(&elementconnectivity,&dummy,&dummy,ELEMENTCONNECTIVITY);
 
 	/*Allocate and initialize all variables*/
Index: /issm/trunk/src/wrappers/InternalFront/InternalFront.h
===================================================================
--- /issm/trunk/src/wrappers/InternalFront/InternalFront.h	(revision 14309)
+++ /issm/trunk/src/wrappers/InternalFront/InternalFront.h	(revision 14310)
@@ -27,5 +27,7 @@
 #ifdef _HAVE_MATLAB_MODULES_
 /* serial input macros: */
-#define MODEL prhs[0]
+#define ELEMENTS prhs[0]
+#define ELEMENTONWATER prhs[1]
+#define ELEMENTCONNECTIVITY prhs[2]
 /* serial output macros: */
 #define FRONT (mxArray**)&plhs[0]
@@ -34,5 +36,7 @@
 #ifdef _HAVE_PYTHON_MODULES_
 /* serial input macros: */
-#define MODEL PyTuple_GetItem(args,0)
+#define ELEMENTS PyTuple_GetItem(args,0)
+#define ELEMENTONWATER PyTuple_GetItem(args,1)
+#define ELEMENTCONNECTIVITY PyTuple_GetItem(args,2)
 /* serial output macros: */
 #define FRONT output,0]
@@ -43,5 +47,5 @@
 #define NLHS  1
 #undef NRHS
-#define NRHS  1
+#define NRHS  3
 
 #endif
Index: /issm/trunk/src/wrappers/MeshProfileIntersection/MeshProfileIntersection.cpp
===================================================================
--- /issm/trunk/src/wrappers/MeshProfileIntersection/MeshProfileIntersection.cpp	(revision 14309)
+++ /issm/trunk/src/wrappers/MeshProfileIntersection/MeshProfileIntersection.cpp	(revision 14310)
@@ -45,8 +45,8 @@
 	
 	//contours
-	DataSet *domain = NULL;
-	Contour<double>** contours=NULL;
-	int       numcontours;
-	Contour<double>*  contouri=NULL;
+	DataSet          *domain      = NULL;
+	Contour<double> **contours=NULL;
+	int               numcontours;
+	Contour<double>  *contouri=NULL;
 
 	/* output: */
@@ -82,15 +82,4 @@
 		*(contours+i)=(Contour<double>*)domain->GetObjectByOffset(i);
 
-	/* Debugging of contours :{{{1*/
-	/*for(i=0;i<numcontours;i++){
-		_printLine_("\nContour echo: contour number  " << i+1 << " / " << numcontours);
-		contouri=*(contours+i);
-		_printLine_("   Number of vertices " << contouri->nods);
-		for (j=0;j<contouri->nods;j++){
-			_printLine_("   " << *(contouri->x+j) << "f " << *(contouri->y+j) << "f");
-		}
-	}*/
-	/*}}}*/
-
 	/*Run interpolation routine: */
 	MeshProfileIntersectionx(&segments,&numsegs,index,x,y,nel,nods,contours,numcontours);
Index: /issm/trunk/src/wrappers/Shp2Exp/Shp2Exp.cpp
===================================================================
--- /issm/trunk/src/wrappers/Shp2Exp/Shp2Exp.cpp	(revision 14310)
+++ /issm/trunk/src/wrappers/Shp2Exp/Shp2Exp.cpp	(revision 14310)
@@ -0,0 +1,71 @@
+/*\file Shp2Exp.c
+ *\brief: shp to exp file conversion mex module.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+#include "./Shp2Exp.h"
+
+void Shp2ExpUsage(void){/*{{{*/
+	_pprintLine_("Shp2Exp - shp to exp file conversion module:");
+	_pprintLine_("");
+	_pprintLine_("   This module converts a file from shp to exp format.");
+	_pprintLine_("");
+	_pprintLine_("   Usage:");
+	_pprintLine_("      [ret]=Shp2Exp(filshp,filexp,sgn,'param name',param,...);");
+	_pprintLine_("");
+	_pprintLine_("      filshp      file name of shp file to be read (char, extension optional)");
+	_pprintLine_("      filexp      file name of exp file to be written (char)");
+	_pprintLine_("");
+	_pprintLine_("      ret         return code (non-zero for warning)");
+	_pprintLine_("");
+	_pprintLine_("   Examples:");
+	_pprintLine_("      [ret]=Shp2Exp('file.shp','file.exp');");
+	_pprintLine_("");
+}/*}}}*/
+WRAPPER(Shp2Exp){
+
+	int i,verbose=1;
+
+	/*input: */
+	char    *filshp=NULL,*filexp=NULL;
+
+	/* output: */
+	int     iret=0;
+
+	#ifndef _HAVE_SHAPELIB_ //only works if shapelib library has been compiled in.
+	_error_("Shapelib not available! Cannot carry out shp file translation!");
+	#endif
+
+	/*Boot module: */
+	MODULEBOOT();
+
+	/*checks on arguments on the matlab side: */
+	if (nlhs > NLHS) {
+		Shp2ExpUsage(); _error_("Shp2Exp usage error");
+	}
+	if (nrhs < NRHS) {
+		Shp2ExpUsage(); _error_("Shp2Exp usage error");
+	}
+
+	/*Input datasets: */
+	FetchData(&filshp,SHP_IN);
+	FetchData(&filexp,EXP_IN);
+
+	/* Run core computations: */
+	iret=Shp2Expx(filshp,filexp);
+
+	/*Write data: */
+	WriteData(RET_OUT,iret);
+
+	/*Clean-up*/
+	xDelete<char>(filexp);
+	xDelete<char>(filshp);
+
+	/*end module: */
+	MODULEEND();
+}
Index: /issm/trunk/src/wrappers/Shp2Exp/Shp2Exp.h
===================================================================
--- /issm/trunk/src/wrappers/Shp2Exp/Shp2Exp.h	(revision 14310)
+++ /issm/trunk/src/wrappers/Shp2Exp/Shp2Exp.h	(revision 14310)
@@ -0,0 +1,51 @@
+/*!\file Shp2Exp.h
+ * \brief: prototype for shp to exp file conversion mex module.
+ */
+
+#ifndef _SHP2EXP_H
+#define _SHP2EXP_H
+
+#ifdef HAVE_CONFIG_H
+	#include <config.h>
+#else
+	#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+/*For python modules: needs to come before header files inclusion*/
+#ifdef _HAVE_PYTHON_
+#define PY_ARRAY_UNIQUE_SYMBOL PythonIOSymbol
+#endif
+
+#include "../../c/include/globals.h"
+#include "../../c/modules/modules.h"
+#include "../../c/Container/Container.h"
+#include "../../c/shared/shared.h"
+#include "../bindings.h"
+
+#undef __FUNCT__ 
+#define __FUNCT__  "Shp2Exp"
+
+#ifdef _HAVE_MATLAB_MODULES_
+/* serial input macros: */
+#define SHP_IN  prhs[0]
+#define EXP_IN  prhs[1]
+/* serial output macros: */
+#define RET_OUT (mxArray**)&plhs[0]
+#endif
+
+#ifdef _HAVE_PYTHON_MODULES_
+/* serial input macros: */
+#define SHP_IN PyTuple_GetItem(args,0)
+#define EXP_IN PyTuple_GetItem(args,1)
+/* serial output macros: */
+#define RET_OUT output,0
+#endif
+
+/* serial arg counts: */
+#undef NRHS
+#define NRHS  2
+#undef NLHS
+#define NLHS  1
+
+#endif
+
Index: /issm/trunk/src/wrappers/TriMesh/TriMesh.cpp
===================================================================
--- /issm/trunk/src/wrappers/TriMesh/TriMesh.cpp	(revision 14309)
+++ /issm/trunk/src/wrappers/TriMesh/TriMesh.cpp	(revision 14310)
@@ -22,9 +22,9 @@
 
 	/* output: */
-	SeqMat<double> *index             = NULL;
+	SeqMat<int>    *index             = NULL;
 	SeqVec<double> *x                 = NULL;
 	SeqVec<double> *y                 = NULL;
-	SeqMat<double> *segments          = NULL;
-	SeqVec<double> *segmentmarkerlist = NULL;
+	SeqMat<int>    *segments          = NULL;
+	SeqVec<int>    *segmentmarkerlist = NULL;
 
 	/*Boot module: */
Index: /issm/trunk/src/wrappers/TriMeshProcessRifts/TriMeshProcessRifts.cpp
===================================================================
--- /issm/trunk/src/wrappers/TriMeshProcessRifts/TriMeshProcessRifts.cpp	(revision 14309)
+++ /issm/trunk/src/wrappers/TriMeshProcessRifts/TriMeshProcessRifts.cpp	(revision 14310)
@@ -18,9 +18,9 @@
 	/* input: */
 	int     nel,nods;
-	double *index          = NULL;
+	int    *index          = NULL;
 	double *x              = NULL;
 	double *y              = NULL;
-	double *segments       = NULL;
-	double *segmentmarkers = NULL;
+	int    *segments       = NULL;
+	int    *segmentmarkers = NULL;
 	int     num_seg;
 
Index: /issm/trunk/src/wrappers/matlab/Makefile.am
===================================================================
--- /issm/trunk/src/wrappers/matlab/Makefile.am	(revision 14309)
+++ /issm/trunk/src/wrappers/matlab/Makefile.am	(revision 14310)
@@ -48,4 +48,5 @@
 						 ElementConnectivity.la\
 						 EnumToString.la\
+						 ExpSimplify.la\
 						 HoleFiller.la\
 						 InternalFront.la\
@@ -76,7 +77,8 @@
 				   KMLMeshWrite.la\
 				   KMLOverlay.la\
-				   Shp2Kml.la\
 				   Exp2Kml.la\
-				   Kml2Exp.la
+				   Kml2Exp.la\
+				   Shp2Exp.la\
+				   Shp2Kml.la
 endif
 endif 
@@ -210,4 +212,8 @@
 Ll2xy_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB)
 
+ExpSimplify_la_SOURCES = ../ExpSimplify/ExpSimplify.cpp\
+							../ExpSimplify/ExpSimplify.h
+ExpSimplify_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB)
+
 Exp2Kml_la_SOURCES = ../Exp2Kml/Exp2Kml.cpp\
 							../Exp2Kml/Exp2Kml.h
@@ -246,4 +252,8 @@
 Scotch_la_LIBADD = ${deps} $(SCOTCHLIB) $(MPILIB)
 
+Shp2Exp_la_SOURCES = ../Shp2Exp/Shp2Exp.cpp\
+							../Shp2Exp/Shp2Exp.h
+Shp2Exp_la_LIBADD = ${deps} $(SHAPELIBLIB) $(MPILIB) $(PETSCLIB)
+
 Shp2Kml_la_SOURCES = ../Shp2Kml/Shp2Kml.cpp\
 							../Shp2Kml/Shp2Kml.h
Index: /issm/trunk/src/wrappers/matlab/include/wrapper_macros.h
===================================================================
--- /issm/trunk/src/wrappers/matlab/include/wrapper_macros.h	(revision 14309)
+++ /issm/trunk/src/wrappers/matlab/include/wrapper_macros.h	(revision 14310)
@@ -19,5 +19,5 @@
  * will be trapped*/
 #define MODULEBOOT(); try{ \
-	IssmComm::SetComm(-1);
+	IssmComm::SetComm();
 
 #define MODULEEND(); }\
Index: /issm/trunk/src/wrappers/matlab/io/WriteMatlabData.cpp
===================================================================
--- /issm/trunk/src/wrappers/matlab/io/WriteMatlabData.cpp	(revision 14309)
+++ /issm/trunk/src/wrappers/matlab/io/WriteMatlabData.cpp	(revision 14310)
@@ -290,4 +290,73 @@
 }
 /*}}}*/
+/*FUNCTION WriteData(mxArray** pdataref,SeqMat<int>* matrix){{{*/
+void WriteData(mxArray** pdataref,SeqMat<int>* matrix){
+
+	int      i,j;
+	int      rows,cols;
+	mxArray *dataref     = NULL;
+	int     *matrix_ptr  = NULL;
+	double  *tmatrix_ptr = NULL;
+
+	if(matrix){
+
+		matrix_ptr=matrix->ToSerial();
+		matrix->GetSize(&rows,&cols);
+
+		/*Now transpose the matrix and allocate with Matlab's memory manager: */
+		tmatrix_ptr=(double*)mxMalloc(rows*cols*sizeof(double));
+		for(i=0;i<rows;i++){
+			for(j=0;j<cols;j++){
+				tmatrix_ptr[j*rows+i]=(double)matrix_ptr[i*cols+j];
+			}
+		}
+
+		/*create matlab matrix: */
+		dataref=mxCreateDoubleMatrix(0,0,mxREAL);
+		mxSetM(dataref,rows); 
+		mxSetN(dataref,cols);
+		mxSetPr(dataref,tmatrix_ptr);
+
+		/*Free ressources:*/
+		xDelete<int>(matrix_ptr);
+	}
+	else{
+		dataref = mxCreateDoubleMatrix(0,0,mxREAL);
+	}
+
+	*pdataref=dataref;
+}
+/*}}}*/
+/*FUNCTION WriteData(mxArray** pdataref,SeqVec<int>* vector){{{*/
+void WriteData(mxArray** pdataref,SeqVec<int>* vector){
+
+	mxArray* dataref=NULL;
+	int*     vector_ptr=NULL;
+	double*  vector_matlab=NULL;
+	int      rows;
+
+	if(vector){
+		/*call toolkit routine: */
+		vector_ptr=vector->ToMPISerial();
+		vector->GetSize(&rows);
+
+		/*now create the matlab vector with Matlab's memory manager */
+		vector_matlab=(double*)mxMalloc(rows*sizeof(double));
+		for(int i=0;i<rows;i++) vector_matlab[i]=(double)vector_ptr[i];
+
+		dataref = mxCreateDoubleMatrix(0,0,mxREAL);                         
+		mxSetM(dataref,rows);
+		mxSetN(dataref,1);                                                                                          
+		mxSetPr(dataref,vector_matlab);           
+	}
+	else{
+		dataref = mxCreateDoubleMatrix(0,0,mxREAL);
+	}
+
+	/*Clean-up and return*/
+	xDelete<int>(vector_ptr);
+	*pdataref=dataref;
+}
+/*}}}*/
 /*FUNCTION WriteData(mxArray** pdataref,RiftStruct* riftstruct){{{*/
 void WriteData(mxArray** pdataref,RiftStruct* riftstruct){
@@ -363,4 +432,16 @@
 }
 /*}}}*/
+/*FUNCTION SetStructureFieldi(mxArray* dataref,int i,const char* fieldname,int M,int N,int* fieldpointer){{{*/
+void SetStructureFieldi(mxArray* dataref,int i,const char* fieldname,int M,int N,int* fieldpointer){
+
+	mxArray* field = NULL;
+
+	/*Convert field*/
+	WriteData(&field,fieldpointer,M,N);
+
+	/*Assign to structure*/
+	mxSetField(dataref,i,fieldname,field);
+}
+/*}}}*/
 /*FUNCTION SetStructureFieldi(mxArray* dataref,int i,const char* fieldname,int field){{{*/
 void SetStructureFieldi(mxArray* dataref,int i,const char* fieldname,int fieldin){
Index: /issm/trunk/src/wrappers/matlab/io/matlabio.h
===================================================================
--- /issm/trunk/src/wrappers/matlab/io/matlabio.h	(revision 14309)
+++ /issm/trunk/src/wrappers/matlab/io/matlabio.h	(revision 14310)
@@ -17,7 +17,9 @@
 #include "../../c/include/include.h"
 
+void WriteData(mxArray** pdataref,SeqMat<int>* matrix);
 void WriteData(mxArray** pdataref,SeqMat<double>* matrix);
 void WriteData(mxArray** pdataref,double* matrix, int M,int N);
 void WriteData(mxArray** pdataref,int*    matrix, int M,int N);
+void WriteData(mxArray** pdataref,SeqVec<int>* vector);
 void WriteData(mxArray** pdataref,SeqVec<double>* vector);
 void WriteData(mxArray** pdataref,double* vector, int M);
@@ -64,4 +66,5 @@
 void SetStructureField(mxArray* dataref,const char* fieldname,int fieldrows,int fieldcols,double* fieldpointer);
 void SetStructureFieldi(mxArray* dataref,int i,const char* fieldname,int fieldrows,int fieldcols,double* fieldpointer);
+void SetStructureFieldi(mxArray* dataref,int i,const char* fieldname,int fieldrows,int fieldcols,int*    fieldpointer);
 void SetStructureFieldi(mxArray* dataref,int i,const char* fieldname,int field);
 void SetStructureFieldi(mxArray* dataref,int i,const char* fieldname,double field);
Index: /issm/trunk/src/wrappers/python/include/wrapper_macros.h
===================================================================
--- /issm/trunk/src/wrappers/python/include/wrapper_macros.h	(revision 14309)
+++ /issm/trunk/src/wrappers/python/include/wrapper_macros.h	(revision 14310)
@@ -23,5 +23,5 @@
 	if(!output) return NULL;\
 	try{ \
-	IssmComm::SetComm(-1);
+	IssmComm::SetComm();
 
 #define MODULEEND(); }\
Index: /issm/trunk/src/wrappers/python/io/FetchPythonData.cpp
===================================================================
--- /issm/trunk/src/wrappers/python/io/FetchPythonData.cpp	(revision 14309)
+++ /issm/trunk/src/wrappers/python/io/FetchPythonData.cpp	(revision 14310)
@@ -20,39 +20,72 @@
 void FetchData(double* pscalar,PyObject* py_float){
 
-	double scalar;
+	double dscalar;
 
 	/*return internal value: */
-	scalar=PyFloat_AsDouble(py_float);
-
-	/*output: */
-	*pscalar=scalar;
-}
-/*}}}*/
-/*FUNCTION FetchData(int* pinteger,PyObject* py_long){{{*/
-void FetchData(int* pinteger, PyObject* py_long){
-
-	int integer;
+	if      (PyFloat_Check(py_float))
+		dscalar=PyFloat_AsDouble(py_float);
+	else if (PyInt_Check(py_float))
+		dscalar=(double)PyInt_AsLong(py_float);
+	else if (PyLong_Check(py_float))
+		dscalar=PyLong_AsDouble(py_float);
+	else if (PyBool_Check(py_float))
+		dscalar=(double)PyLong_AsLong(py_float);
+	else if (PyTuple_Check(py_float) && (int)PyTuple_Size(py_float)==1)
+		FetchData(&dscalar,PyTuple_GetItem(py_float,(Py_ssize_t)0));
+	else if (PyList_Check(py_float) && (int)PyList_Size(py_float)==1)
+		FetchData(&dscalar,PyList_GetItem(py_float,(Py_ssize_t)0));
+	else
+		_error_("unrecognized float type in input!");
+
+	/*output: */
+	*pscalar=dscalar;
+}
+/*}}}*/
+/*FUNCTION FetchData(int* pscalar,PyObject* py_long){{{*/
+void FetchData(int* pscalar, PyObject* py_long){
+
+	int iscalar;
 
 	/*return internal value: */
-	integer=(int)PyLong_AsLong(py_long);
-
-	/*output: */
-	*pinteger=integer;
-}
-/*}}}*/
-/*FUNCTION FetchData(bool* pboolean,PyObject* py_boolean){{{*/
-void FetchData(bool* pboolean,PyObject* py_boolean){
-
-	bool boolean;
-
-	/*check this is indeed a subtype of long type: */
-	if(!PyBool_Check(py_boolean))_error_("expecting a boolean in input!");
-
-	/*extract boolean: */
-	boolean=(bool)PyLong_AsLong(py_boolean);
-
-	/*simple copy: */
-	*pboolean=boolean;
-
+	if      (PyInt_Check(py_long))
+		iscalar=(int)PyInt_AsLong(py_long);
+	else if (PyLong_Check(py_long))
+		iscalar=(int)PyLong_AsLong(py_long);
+	else if (PyFloat_Check(py_long))
+		iscalar=(int)PyFloat_AsDouble(py_long);
+	else if (PyBool_Check(py_long))
+		iscalar=(int)PyLong_AsLong(py_long);
+	else if (PyTuple_Check(py_long) && (int)PyTuple_Size(py_long)==1)
+		FetchData(&iscalar,PyTuple_GetItem(py_long,(Py_ssize_t)0));
+	else if (PyList_Check(py_long) && (int)PyList_Size(py_long)==1)
+		FetchData(&iscalar,PyList_GetItem(py_long,(Py_ssize_t)0));
+	else
+		_error_("unrecognized long type in input!");
+
+	/*output: */
+	*pscalar=iscalar;
+}
+/*}}}*/
+/*FUNCTION FetchData(bool* pscalar,PyObject* py_boolean){{{*/
+void FetchData(bool* pscalar,PyObject* py_boolean){
+
+	bool bscalar;
+
+	/*return internal value: */
+	if      (PyBool_Check(py_boolean))
+		bscalar=(bool)PyLong_AsLong(py_boolean);
+	else if (PyInt_Check(py_boolean))
+		bscalar=(bool)PyInt_AsLong(py_boolean);
+	else if (PyLong_Check(py_boolean))
+		bscalar=(bool)PyLong_AsLong(py_boolean);
+	else if (PyTuple_Check(py_boolean) && (int)PyTuple_Size(py_boolean)==1)
+		FetchData(&bscalar,PyTuple_GetItem(py_boolean,(Py_ssize_t)0));
+	else if (PyList_Check(py_boolean) && (int)PyList_Size(py_boolean)==1)
+		FetchData(&bscalar,PyList_GetItem(py_boolean,(Py_ssize_t)0));
+	else
+		_error_("unrecognized boolean type in input!");
+
+	/*output: */
+	*pscalar=bscalar;
 }
 /*}}}*/
@@ -72,43 +105,59 @@
 	int i;
 
-	/*retrieve dimensions: */
-	ndim=PyArray_NDIM((const PyArrayObject*)py_matrix);
-	if(ndim!=2)_error_("expecting an MxN matrix in input!");
-	dims=PyArray_DIMS((PyArrayObject*)py_matrix);
-	M=dims[0]; N=dims[1];
-
-	if (M && N) {
-		if      (PyArray_TYPE((PyArrayObject*)py_matrix) == NPY_DOUBLE) {
-			/*retrieve internal value: */
-			dmatrix=(double*)PyArray_DATA((PyArrayObject*)py_matrix);
-
-			/*copy matrix: */
-			matrix=xNew<double>(M*N);
-			memcpy(matrix,dmatrix,(M*N)*sizeof(double));
-		}
-
-		else if (PyArray_TYPE((PyArrayObject*)py_matrix) == NPY_INT64) {
-			/*retrieve internal value: */
-			lmatrix=(long*)PyArray_DATA((PyArrayObject*)py_matrix);
-
-			/*transform into double matrix: */
-			matrix=xNew<double>(M*N);
-			for(i=0;i<M*N;i++)matrix[i]=(double)lmatrix[i];
-		}
-
-		else if (PyArray_TYPE((PyArrayObject*)py_matrix) == NPY_BOOL) {
-			/*retrieve internal value: */
-			bmatrix=(bool*)PyArray_DATA((PyArrayObject*)py_matrix);
-
-			/*transform into double matrix: */
-			matrix=xNew<double>(M*N);
-			for(i=0;i<M*N;i++)matrix[i]=(double)bmatrix[i];
-		}
-
-		else
-			_error_("unrecognized matrix type in input!");
-	}
-	else
-		matrix=NULL;
+	if     (PyArray_Check((PyArrayObject*)py_matrix)) {
+		/*retrieve dimensions: */
+		ndim=PyArray_NDIM((const PyArrayObject*)py_matrix);
+		if      (ndim==2) {
+			dims=PyArray_DIMS((PyArrayObject*)py_matrix);
+			M=dims[0]; N=dims[1];
+		}
+		else if (ndim==1) {
+			dims=PyArray_DIMS((PyArrayObject*)py_matrix);
+			M=dims[0]; N=1;
+		}
+		else
+			_error_("expecting an MxN matrix or M vector in input!");
+
+		if (M && N) {
+			if      (PyArray_TYPE((PyArrayObject*)py_matrix) == NPY_DOUBLE) {
+				/*retrieve internal value: */
+				dmatrix=(double*)PyArray_DATA((PyArrayObject*)py_matrix);
+
+				/*copy matrix: */
+				matrix=xNew<double>(M*N);
+				memcpy(matrix,dmatrix,(M*N)*sizeof(double));
+			}
+
+			else if (PyArray_TYPE((PyArrayObject*)py_matrix) == NPY_INT64) {
+				/*retrieve internal value: */
+				lmatrix=(long*)PyArray_DATA((PyArrayObject*)py_matrix);
+
+				/*transform into double matrix: */
+				matrix=xNew<double>(M*N);
+				for(i=0;i<M*N;i++)matrix[i]=(double)lmatrix[i];
+			}
+
+			else if (PyArray_TYPE((PyArrayObject*)py_matrix) == NPY_BOOL) {
+				/*retrieve internal value: */
+				bmatrix=(bool*)PyArray_DATA((PyArrayObject*)py_matrix);
+
+				/*transform into double matrix: */
+				matrix=xNew<double>(M*N);
+				for(i=0;i<M*N;i++)matrix[i]=(double)bmatrix[i];
+			}
+
+			else
+				_error_("unrecognized double pyarray type in input!");
+		}
+		else
+			matrix=NULL;
+	}
+
+	else {
+		M=1;
+		N=1;
+		matrix=xNew<double>(M*N);
+		FetchData(&(matrix[0]),py_matrix);
+	}
 
 	/*output: */
@@ -133,43 +182,136 @@
 	int i;
 
-	/*retrieve dimensions: */
-	ndim=PyArray_NDIM((const PyArrayObject*)py_matrix);
-	if(ndim!=2)_error_("expecting an MxN matrix in input!");
-	dims=PyArray_DIMS((PyArrayObject*)py_matrix);
-	M=dims[0]; N=dims[1];
-
-	if (M && N) {
-		if      (PyArray_TYPE((PyArrayObject*)py_matrix) == NPY_DOUBLE) {
-			/*retrieve internal value: */
-			dmatrix=(double*)PyArray_DATA((PyArrayObject*)py_matrix);
-
-			/*transform into integer matrix: */
-			matrix=xNew<int>(M*N);
-			for(i=0;i<M*N;i++)matrix[i]=(int)dmatrix[i];
-		}
-
-		else if (PyArray_TYPE((PyArrayObject*)py_matrix) == NPY_INT64) {
-			/*retrieve internal value: */
-			lmatrix=(long*)PyArray_DATA((PyArrayObject*)py_matrix);
-
-			/*transform into integer matrix: */
-			matrix=xNew<int>(M*N);
-			for(i=0;i<M*N;i++)matrix[i]=(int)lmatrix[i];
-		}
-
-		else if (PyArray_TYPE((PyArrayObject*)py_matrix) == NPY_BOOL) {
-			/*retrieve internal value: */
-			bmatrix=(bool*)PyArray_DATA((PyArrayObject*)py_matrix);
-
-			/*transform into integer matrix: */
-			matrix=xNew<int>(M*N);
-			for(i=0;i<M*N;i++)matrix[i]=(int)bmatrix[i];
-		}
-
-		else
-			_error_("unrecognized matrix type in input!");
-	}
-	else
-		matrix=NULL;
+	if     (PyArray_Check((PyArrayObject*)py_matrix)) {
+		/*retrieve dimensions: */
+		ndim=PyArray_NDIM((const PyArrayObject*)py_matrix);
+		if      (ndim==2) {
+			dims=PyArray_DIMS((PyArrayObject*)py_matrix);
+			M=dims[0]; N=dims[1];
+		}
+		else if (ndim==1) {
+			dims=PyArray_DIMS((PyArrayObject*)py_matrix);
+			M=dims[0]; N=1;
+		}
+		else
+			_error_("expecting an MxN matrix or M vector in input!");
+
+		if (M && N) {
+			if      (PyArray_TYPE((PyArrayObject*)py_matrix) == NPY_DOUBLE) {
+				/*retrieve internal value: */
+				dmatrix=(double*)PyArray_DATA((PyArrayObject*)py_matrix);
+
+				/*transform into integer matrix: */
+				matrix=xNew<int>(M*N);
+				for(i=0;i<M*N;i++)matrix[i]=(int)dmatrix[i];
+			}
+
+			else if (PyArray_TYPE((PyArrayObject*)py_matrix) == NPY_INT64) {
+				/*retrieve internal value: */
+				lmatrix=(long*)PyArray_DATA((PyArrayObject*)py_matrix);
+
+				/*transform into integer matrix: */
+				matrix=xNew<int>(M*N);
+				for(i=0;i<M*N;i++)matrix[i]=(int)lmatrix[i];
+			}
+
+			else if (PyArray_TYPE((PyArrayObject*)py_matrix) == NPY_BOOL) {
+				/*retrieve internal value: */
+				bmatrix=(bool*)PyArray_DATA((PyArrayObject*)py_matrix);
+
+				/*transform into integer matrix: */
+				matrix=xNew<int>(M*N);
+				for(i=0;i<M*N;i++)matrix[i]=(int)bmatrix[i];
+			}
+
+			else
+				_error_("unrecognized int pyarray type in input!");
+		}
+		else
+			matrix=NULL;
+	}
+
+	else {
+		M=1;
+		N=1;
+		matrix=xNew<int>(M*N);
+		FetchData(&(matrix[0]),py_matrix);
+	}
+
+	/*output: */
+	if(pM)*pM=M;
+	if(pN)*pN=N;
+	if(pmatrix)*pmatrix=matrix;
+}
+/*}}}*/
+/*FUNCTION FetchData(bool** pmatrix,int* pM, int* pN, PyObject* py_matrix){{{*/
+void FetchData(bool** pmatrix,int* pM,int *pN,PyObject* py_matrix){
+
+	/*output: */
+	bool* bmatrix=NULL;
+	bool* matrix=NULL;
+	int M,N;
+	int ndim;
+	npy_intp*  dims=NULL;
+
+	/*intermediary:*/
+	double* dmatrix=NULL;
+	long* lmatrix=NULL;
+	int i;
+
+	if     (PyArray_Check((PyArrayObject*)py_matrix)) {
+		/*retrieve dimensions: */
+		ndim=PyArray_NDIM((const PyArrayObject*)py_matrix);
+		if      (ndim==2) {
+			dims=PyArray_DIMS((PyArrayObject*)py_matrix);
+			M=dims[0]; N=dims[1];
+		}
+		else if (ndim==1) {
+			dims=PyArray_DIMS((PyArrayObject*)py_matrix);
+			M=dims[0]; N=1;
+		}
+		else
+			_error_("expecting an MxN matrix or M vector in input!");
+
+		if (M && N) {
+			if      (PyArray_TYPE((PyArrayObject*)py_matrix) == NPY_DOUBLE) {
+				/*retrieve internal value: */
+				dmatrix=(double*)PyArray_DATA((PyArrayObject*)py_matrix);
+
+				/*transform into bool matrix: */
+				matrix=xNew<bool>(M*N);
+				for(i=0;i<M*N;i++)matrix[i]=(bool)dmatrix[i];
+			}
+
+			else if (PyArray_TYPE((PyArrayObject*)py_matrix) == NPY_INT64) {
+				/*retrieve internal value: */
+				lmatrix=(long*)PyArray_DATA((PyArrayObject*)py_matrix);
+
+				/*transform into bool matrix: */
+				matrix=xNew<bool>(M*N);
+				for(i=0;i<M*N;i++)matrix[i]=(bool)lmatrix[i];
+			}
+
+			else if (PyArray_TYPE((PyArrayObject*)py_matrix) == NPY_BOOL) {
+				/*retrieve internal value: */
+				bmatrix=(bool*)PyArray_DATA((PyArrayObject*)py_matrix);
+
+				/*copy matrix: */
+				matrix=xNew<bool>(M*N);
+				memcpy(matrix,bmatrix,(M*N)*sizeof(bool));
+			}
+
+			else
+				_error_("unrecognized bool pyarray type in input!");
+		}
+		else
+			matrix=NULL;
+	}
+
+	else {
+		M=1;
+		N=1;
+		matrix=xNew<bool>(M*N);
+		FetchData(&(matrix[0]),py_matrix);
+	}
 
 	/*output: */
@@ -194,43 +336,217 @@
 	int i;
 
-	/*retrieve dimensions: */
-	ndim=PyArray_NDIM((const PyArrayObject*)py_vector);
-	if(ndim!=1)_error_("expecting an Mx1 vector in input!");
-	dims=PyArray_DIMS((PyArrayObject*)py_vector);
-	M=dims[0]; 
-
-	if (M) {
-		if      (PyArray_TYPE((PyArrayObject*)py_vector) == NPY_DOUBLE) {
-			/*retrieve internal value: */
-			dvector=(double*)PyArray_DATA((PyArrayObject*)py_vector);
-
-			/*copy vector: */
-			vector=xNew<double>(M);
-			memcpy(vector,dvector,(M)*sizeof(double));
-		}
-
-		else if (PyArray_TYPE((PyArrayObject*)py_vector) == NPY_INT64) {
-			/*retrieve internal value: */
-			lvector=(long*)PyArray_DATA((PyArrayObject*)py_vector);
-
-			/*transform into double vector: */
-			vector=xNew<double>(M);
-			for(i=0;i<M;i++)vector[i]=(double)lvector[i];
-		}
-
-		else if (PyArray_TYPE((PyArrayObject*)py_vector) == NPY_BOOL) {
-			/*retrieve internal value: */
-			bvector=(bool*)PyArray_DATA((PyArrayObject*)py_vector);
-
-			/*transform into double vector: */
-			vector=xNew<double>(M);
-			for(i=0;i<M;i++)vector[i]=(double)bvector[i];
-		}
-
-		else
-			_error_("unrecognized vector type in input!");
-	}
-	else
-		vector=NULL;
+	if     (PyArray_Check((PyArrayObject*)py_vector)) {
+		/*retrieve dimensions: */
+		ndim=PyArray_NDIM((const PyArrayObject*)py_vector);
+		if      (ndim==1) {
+			dims=PyArray_DIMS((PyArrayObject*)py_vector);
+			M=dims[0]; 
+		}
+		else if (ndim==2) {
+			dims=PyArray_DIMS((PyArrayObject*)py_vector);
+			if (dims[1]==1)
+				M=dims[0]; 
+			else
+				_error_("expecting an Mx1 matrix or M vector in input!");
+		}
+		else
+			_error_("expecting an Mx1 matrix or M vector in input!");
+
+		if (M) {
+			if      (PyArray_TYPE((PyArrayObject*)py_vector) == NPY_DOUBLE) {
+				/*retrieve internal value: */
+				dvector=(double*)PyArray_DATA((PyArrayObject*)py_vector);
+
+				/*copy vector: */
+				vector=xNew<double>(M);
+				memcpy(vector,dvector,(M)*sizeof(double));
+			}
+
+			else if (PyArray_TYPE((PyArrayObject*)py_vector) == NPY_INT64) {
+				/*retrieve internal value: */
+				lvector=(long*)PyArray_DATA((PyArrayObject*)py_vector);
+
+				/*transform into double vector: */
+				vector=xNew<double>(M);
+				for(i=0;i<M;i++)vector[i]=(double)lvector[i];
+			}
+
+			else if (PyArray_TYPE((PyArrayObject*)py_vector) == NPY_BOOL) {
+				/*retrieve internal value: */
+				bvector=(bool*)PyArray_DATA((PyArrayObject*)py_vector);
+
+				/*transform into double vector: */
+				vector=xNew<double>(M);
+				for(i=0;i<M;i++)vector[i]=(double)bvector[i];
+			}
+
+			else
+				_error_("unrecognized double pyarray type in input!");
+		}
+		else
+			vector=NULL;
+	}
+
+	else {
+		M=1;
+		vector=xNew<double>(M);
+		FetchData(&(vector[0]),py_vector);
+	}
+
+	/*output: */
+	if(pM)*pM=M;
+	if(pvector)*pvector=vector;
+}
+/*}}}*/
+/*FUNCTION FetchData(int** pvector,int* pM, PyObject* py_vector){{{*/
+void FetchData(int** pvector,int* pM,PyObject* py_vector){
+
+	/*output: */
+	int* vector=NULL;
+	int M;
+	int ndim;
+	npy_intp*  dims=NULL;
+
+	/*intermediary:*/
+	long*   lvector=NULL;
+	bool*   bvector=NULL;
+	double* dvector=NULL;
+	int i;
+
+	if     (PyArray_Check((PyArrayObject*)py_vector)) {
+		/*retrieve dimensions: */
+		ndim=PyArray_NDIM((const PyArrayObject*)py_vector);
+		if      (ndim==1) {
+			dims=PyArray_DIMS((PyArrayObject*)py_vector);
+			M=dims[0]; 
+		}
+		else if (ndim==2) {
+			dims=PyArray_DIMS((PyArrayObject*)py_vector);
+			if (dims[1]==1)
+				M=dims[0]; 
+			else
+				_error_("expecting an Mx1 matrix or M vector in input!");
+		}
+		else
+			_error_("expecting an Mx1 matrix or M vector in input!");
+
+		if (M) {
+			if      (PyArray_TYPE((PyArrayObject*)py_vector) == NPY_DOUBLE) {
+				/*retrieve internal value: */
+				dvector=(double*)PyArray_DATA((PyArrayObject*)py_vector);
+
+				/*transform into int vector: */
+				vector=xNew<int>(M);
+				for(i=0;i<M;i++)vector[i]=(int)lvector[i];
+			}
+
+			else if (PyArray_TYPE((PyArrayObject*)py_vector) == NPY_INT64) {
+				/*retrieve internal value: */
+				lvector=(long*)PyArray_DATA((PyArrayObject*)py_vector);
+
+				/*transform into int vector: */
+				vector=xNew<int>(M);
+				for(i=0;i<M;i++)vector[i]=(int)lvector[i];
+			}
+
+			else if (PyArray_TYPE((PyArrayObject*)py_vector) == NPY_BOOL) {
+				/*retrieve internal value: */
+				bvector=(bool*)PyArray_DATA((PyArrayObject*)py_vector);
+
+				/*transform into int vector: */
+				vector=xNew<int>(M);
+				for(i=0;i<M;i++)vector[i]=(int)bvector[i];
+			}
+
+			else
+			 _error_("unrecognized int pyarray type in input!");
+		}
+		else
+			vector=NULL;
+	}
+
+	else {
+		M=1;
+		vector=xNew<int>(M);
+		FetchData(&(vector[0]),py_vector);
+	}
+
+	/*output: */
+	if(pM)*pM=M;
+	if(pvector)*pvector=vector;
+}
+/*}}}*/
+/*FUNCTION FetchData(bool** pvector,int* pM, PyObject* py_vector){{{*/
+void FetchData(bool** pvector,int* pM,PyObject* py_vector){
+
+	/*output: */
+	bool* bvector=NULL;
+	bool* vector=NULL;
+	int M;
+	int ndim;
+	npy_intp*  dims=NULL;
+
+	/*intermediary:*/
+	double* dvector=NULL;
+	long* lvector=NULL;
+	int i;
+
+	if     (PyArray_Check((PyArrayObject*)py_vector)) {
+		/*retrieve dimensions: */
+		ndim=PyArray_NDIM((const PyArrayObject*)py_vector);
+		if      (ndim==1) {
+			dims=PyArray_DIMS((PyArrayObject*)py_vector);
+			M=dims[0]; 
+		}
+		else if (ndim==2) {
+			dims=PyArray_DIMS((PyArrayObject*)py_vector);
+			if (dims[1]==1)
+				M=dims[0]; 
+			else
+				_error_("expecting an Mx1 matrix or M vector in input!");
+		}
+		else
+			_error_("expecting an Mx1 matrix or M vector in input!");
+
+		if (M) {
+			if      (PyArray_TYPE((PyArrayObject*)py_vector) == NPY_DOUBLE) {
+				/*retrieve internal value: */
+				dvector=(double*)PyArray_DATA((PyArrayObject*)py_vector);
+
+				/*transform into bool vector: */
+				vector=xNew<bool>(M);
+				for(i=0;i<M;i++)vector[i]=(bool)dvector[i];
+			}
+
+			else if (PyArray_TYPE((PyArrayObject*)py_vector) == NPY_INT64) {
+				/*retrieve internal value: */
+				lvector=(long*)PyArray_DATA((PyArrayObject*)py_vector);
+
+				/*transform into bool vector: */
+				vector=xNew<bool>(M);
+				for(i=0;i<M;i++)vector[i]=(bool)lvector[i];
+			}
+
+			else if (PyArray_TYPE((PyArrayObject*)py_vector) == NPY_BOOL) {
+				/*retrieve internal value: */
+				bvector=(bool*)PyArray_DATA((PyArrayObject*)py_vector);
+
+				/*copy vector: */
+				vector=xNew<bool>(M);
+				memcpy(vector,bvector,(M)*sizeof(bool));
+			}
+
+			else
+				_error_("unrecognized bool pyarray type in input!");
+		}
+		else
+			vector=NULL;
+	}
+
+	else {
+		M=1;
+		vector=xNew<bool>(M);
+		FetchData(&(vector[0]),py_vector);
+	}
 
 	/*output: */
Index: /issm/trunk/src/wrappers/python/io/WritePythonData.cpp
===================================================================
--- /issm/trunk/src/wrappers/python/io/WritePythonData.cpp	(revision 14309)
+++ /issm/trunk/src/wrappers/python/io/WritePythonData.cpp	(revision 14310)
@@ -137,6 +137,7 @@
 	PyObject* array=NULL;
 
+	matrix->GetSize(&M,&N);
 	buffer=matrix->ToSerial();
-	matrix->GetSize(&M,&N);
+
 	dims[0]=(npy_intp)M;
 	dims[1]=(npy_intp)N;
@@ -154,8 +155,89 @@
 	PyObject* array=NULL;
 
+	vector->GetSize(&M);
 	buffer=vector->ToMPISerial();
-	vector->GetSize(&M);
+
 	dim=(npy_intp)M;
 	array=PyArray_SimpleNewFromData(1,&dim,NPY_DOUBLE,buffer);
+
+	PyTuple_SetItem(py_tuple, index, array);
+}
+/*}}}*/
+/*FUNCTION WriteData(PyObject* py_tuple,int index,SeqMat<int>* matrix){{{*/
+void WriteData(PyObject* py_tuple,int index,SeqMat<int>* matrix){
+
+	int M,N;
+	int* ibuffer=NULL;
+	npy_intp dims[2]={0,0};
+	PyObject* array=NULL;
+
+	matrix->GetSize(&M,&N);
+	ibuffer=matrix->ToSerial();
+
+	/*convert to long*/
+	long* lbuffer=xNew<long>(M*N);
+	for(int i=0;i<M*N;i++) lbuffer[i]=(long)ibuffer[i];
+	xDelete<int>(ibuffer);
+
+	dims[0]=(npy_intp)M;
+	dims[1]=(npy_intp)N;
+	array=PyArray_SimpleNewFromData(2,dims,NPY_INT64,lbuffer);
+
+	PyTuple_SetItem(py_tuple, index, array);
+
+}/*}}}*/
+/*FUNCTION WriteData(PyObject* py_tuple,int index,SeqVec<int>* vector){{{*/
+void WriteData(PyObject* py_tuple,int index,SeqVec<int>* vector){
+
+	int M;
+	int* ibuffer=NULL;
+	npy_intp dim=10;
+	PyObject* array=NULL;
+
+	vector->GetSize(&M);
+	ibuffer=vector->ToMPISerial();
+
+	/*convert to long*/
+	long* lbuffer=xNew<long>(M);
+	for(int i=0;i<M;i++) lbuffer[i]=(long)ibuffer[i];
+	xDelete<int>(ibuffer);
+
+	dim=(npy_intp)M;
+	array=PyArray_SimpleNewFromData(1,&dim,NPY_INT64,lbuffer);
+
+	PyTuple_SetItem(py_tuple, index, array);
+}
+/*}}}*/
+/*FUNCTION WriteData(PyObject* py_tuple,int index,SeqMat<bool>* matrix){{{*/
+void WriteData(PyObject* py_tuple,int index,SeqMat<bool>* matrix){
+
+	int M,N;
+	bool* buffer=NULL;
+	npy_intp dims[2]={0,0};
+	PyObject* array=NULL;
+
+	matrix->GetSize(&M,&N);
+	buffer=matrix->ToSerial();
+
+	dims[0]=(npy_intp)M;
+	dims[1]=(npy_intp)N;
+	array=PyArray_SimpleNewFromData(2,dims,NPY_BOOL,buffer);
+
+	PyTuple_SetItem(py_tuple, index, array);
+
+}/*}}}*/
+/*FUNCTION WriteData(PyObject* py_tuple,int index,SeqVec<bool>* vector){{{*/
+void WriteData(PyObject* py_tuple,int index,SeqVec<bool>* vector){
+
+	int M;
+	bool* buffer=NULL;
+	npy_intp dim=10;
+	PyObject* array=NULL;
+
+	vector->GetSize(&M);
+	buffer=vector->ToMPISerial();
+
+	dim=(npy_intp)M;
+	array=PyArray_SimpleNewFromData(1,&dim,NPY_BOOL,buffer);
 
 	PyTuple_SetItem(py_tuple, index, array);
@@ -225,2 +307,34 @@
 }
 /*}}}*/
+/*FUNCTION PyArrayFromCopiedData(int dimi,int dimj,int* data){{{*/
+PyObject* PyArrayFromCopiedData(int dimi,int dimj,int* data){
+
+	long* pydata;
+	npy_intp pydims[2]={0,0};
+
+	/*  note that PyArray_SimpleNewFromData does not copy the data, so that when the original
+		 object (e.g. bamggeom,bamgmesh) is deleted, the data is gone.  */
+
+	pydims[0]=(npy_intp)dimi;
+	pydims[1]=(npy_intp)dimj;
+	pydata=xNew<long>(dimi*dimj);
+	for(int i=0;i<dimi*dimj;i++) pydata[i]=(long)data[i];
+	return PyArray_SimpleNewFromData(2,pydims,NPY_INT64,pydata);
+}
+/*}}}*/
+/*FUNCTION PyArrayFromCopiedData(int dimi,int dimj,bool* data){{{*/
+PyObject* PyArrayFromCopiedData(int dimi,int dimj,bool* data){
+
+	bool* pydata;
+	npy_intp pydims[2]={0,0};
+
+	/*  note that PyArray_SimpleNewFromData does not copy the data, so that when the original
+		 object (e.g. bamggeom,bamgmesh) is deleted, the data is gone.  */
+
+	pydims[0]=(npy_intp)dimi;
+	pydims[1]=(npy_intp)dimj;
+	pydata=xNew<bool>(dimi*dimj);
+	memcpy(pydata,data,dimi*dimj*sizeof(bool));
+	return PyArray_SimpleNewFromData(2,pydims,NPY_BOOL,pydata);
+}
+/*}}}*/
Index: /issm/trunk/src/wrappers/python/io/pythonio.h
===================================================================
--- /issm/trunk/src/wrappers/python/io/pythonio.h	(revision 14309)
+++ /issm/trunk/src/wrappers/python/io/pythonio.h	(revision 14310)
@@ -25,14 +25,21 @@
 void WriteData(PyObject* py_tuple,int index, SeqMat<double>* matrix);
 void WriteData(PyObject* py_tuple,int index, SeqVec<double>* vector);
+void WriteData(PyObject* py_tuple,int index, SeqMat<int>* matrix);
+void WriteData(PyObject* py_tuple,int index, SeqVec<int>* vector);
+void WriteData(PyObject* py_tuple,int index, SeqMat<bool>* matrix);
+void WriteData(PyObject* py_tuple,int index, SeqVec<bool>* vector);
 void WriteData(PyObject* py_tuple,int index, BamgGeom* bamggeom);
 void WriteData(PyObject* py_tuple,int index, BamgMesh* bamgmesh);
 void WriteData(PyObject* py_tuple,int index, RiftStruct* riftstruct);
 
-void FetchData(double** pvector,int* pM,PyObject* py_ref);
 void FetchData(double** pmatrix,int* pM,int *pN,PyObject* py_array);
 void FetchData(int** pmatrix,int* pM,int *pN,PyObject* py_matrix);
+void FetchData(bool** pmatrix,int* pM,int *pN,PyObject* py_matrix);
+void FetchData(double** pvector,int* pM,PyObject* py_ref);
+void FetchData(int** pvector,int* pM,PyObject* py_ref);
+void FetchData(bool** pvector,int* pM,PyObject* py_ref);
 void FetchData(char** pstring,PyObject* py_unicode);
 void FetchData(double* pscalar,PyObject* py_float);
-void FetchData(int* pinteger,PyObject* py_long);
+void FetchData(int* pscalar,PyObject* py_long);
 void FetchData(bool* pbool,PyObject* py_boolean);
 void FetchData(BamgGeom** bamggeom,PyObject* py_dict);
@@ -47,4 +54,6 @@
 PyObject* PyArrayFromCopiedData(int dims[2],double* data);
 PyObject* PyArrayFromCopiedData(int dimi,int dimj,double* data);
+PyObject* PyArrayFromCopiedData(int dimi,int dimj,int* data);
+PyObject* PyArrayFromCopiedData(int dimi,int dimj,bool* data);
 
 #endif	/* _IO_H_ */
Index: /issm/trunk/startup.m
===================================================================
--- /issm/trunk/startup.m	(revision 14309)
+++ /issm/trunk/startup.m	(revision 14310)
@@ -36,5 +36,7 @@
 addpath(recursivepath([ISSM_DIR '/externalpackages/export_fig']));
 addpath(recursivepath([ISSM_DIR '/externalpackages/googleearthtoolbox']));
+addpath(recursivepath([ISSM_DIR '/externalpackages/howatmask']));
 addpath(recursivepath([ISSM_DIR '/externalpackages/cm_and_cb_utilities']));
+addpath(recursivepath([ISSM_DIR '/externalpackages/dem']));
 
 clear ISSM_DIR;
Index: /issm/trunk/test/NightlyRun/android.m
===================================================================
--- /issm/trunk/test/NightlyRun/android.m	(revision 14310)
+++ /issm/trunk/test/NightlyRun/android.m	(revision 14310)
@@ -0,0 +1,32 @@
+md=triangle(model(),'../Exp/Square.exp',100000.);
+md=setmask(md,'all','');
+md=parameterize(md,'../Par/SquareShelfConstrained.par');
+md=setflowequation(md,'macayeal','all');
+md.cluster=generic('name',oshostname(),'np',3);
+md.verbose=verbose('mprocessor',true,'module',true,'solution',true,'solver',true,'convergence',true,'control',true,'qmu',true,'autodiff',true);
+md.diagnostic.requested_outputs=StressTensorEnum();
+md=solve(md,DiagnosticSolutionEnum());
+
+	
+index=md.mesh.elements;
+nel=length(index);
+x=md.mesh.x;
+y=md.mesh.y;
+z=md.mesh.z;
+vel=md.results.DiagnosticSolution.Vel;
+
+patch=zeros(nel,12);
+for i=1:nel,
+	patch(i,1)=x(index(i,1));
+	patch(i,2)=y(index(i,1));
+	patch(i,3)=z(index(i,1));
+	patch(i,4)=x(index(i,2));
+	patch(i,5)=y(index(i,2));
+	patch(i,6)=z(index(i,2));
+	patch(i,7)=x(index(i,3));
+	patch(i,8)=y(index(i,3));
+	patch(i,9)=z(index(i,3));
+	patch(i,10)=vel(index(i,1));
+	patch(i,11)=vel(index(i,2));
+	patch(i,12)=vel(index(i,3));
+end
Index: /issm/trunk/test/NightlyRun/python_skipped_tests.txt
===================================================================
--- /issm/trunk/test/NightlyRun/python_skipped_tests.txt	(revision 14309)
+++ /issm/trunk/test/NightlyRun/python_skipped_tests.txt	(revision 14310)
@@ -11,2 +11,12 @@
 test418    needs Dakota
 test420    needs Dakota
+
+test1401,test1402
+Roundoff error in ComputeHessian and ComputeMetric causes different meshes
+from matlab, specifically in the handling of 0/0=nan, eps/0=inf, etc.  Since
+the mesh is of a different size, NR fails.  (Note Matlab test1402 currently
+fails.)
+
+test1109,test1110
+Ugly crashes in solver, but same behavior as Matlab.
+
Index: /issm/trunk/test/NightlyRun/runme.m
===================================================================
--- /issm/trunk/test/NightlyRun/runme.m	(revision 14309)
+++ /issm/trunk/test/NightlyRun/runme.m	(revision 14310)
@@ -79,5 +79,10 @@
 			strncmp(fliplr(flist(i).name),fliplr('.m'),2)&...           %File name must end by '.m'
 			~strcmp(flist(i).name,'test.m'))                            %File name must be different than 'test.m'
-		list_ids(end+1)=eval(flist(i).name(5:end-2));                  %Keep test id only (skip 'test' and '.m')
+		id=str2num(flist(i).name(5:end-2));
+		if isempty(id),
+			disp(['WARNING: ignore file ' flist(i).name ]);
+		else
+			list_ids(end+1)=eval(flist(i).name(5:end-2));                  %Keep test id only (skip 'test' and '.m')
+		end
 	end
 end
Index: /issm/trunk/test/NightlyRun/test1101.m
===================================================================
--- /issm/trunk/test/NightlyRun/test1101.m	(revision 14309)
+++ /issm/trunk/test/NightlyRun/test1101.m	(revision 14310)
@@ -1,7 +1,7 @@
-%This test is a test from the ISMP-HOM Intercomparison project
+%This test is a test from the ISMP-HOM Intercomparison project.
 %Pattyn and Payne 2006
 printingflag=false;
 
-L_list={5000,10000,20000,40000,80000,160000};
+L_list={5000.,10000.,20000.,40000.,80000.,160000.};
 results={};
 minvx=[];
@@ -26,13 +26,13 @@
 
 	pos=find(md.mesh.vertexonbed);
-	md.diagnostic.spcvx(pos)=0;
-	md.diagnostic.spcvy(pos)=0;
+	md.diagnostic.spcvx(pos)=0.;
+	md.diagnostic.spcvy(pos)=0.;
 
 	%Create MPCs to have periodic boundary conditions
-	posx=find(md.mesh.x==0);
+	posx=find(md.mesh.x==0.);
 	posx2=find(md.mesh.x==max(md.mesh.x));
 
-	posy=find(md.mesh.y==0 & md.mesh.x~=0 & md.mesh.x~=max(md.mesh.x)); %Don't take the same nodes two times
-	posy2=find(md.mesh.y==max(md.mesh.y) & md.mesh.x~=0 & md.mesh.x~=max(md.mesh.x));
+	posy=find(md.mesh.y==0. & md.mesh.x~=0. & md.mesh.x~=max(md.mesh.x)); %Don't take the same nodes two times
+	posy2=find(md.mesh.y==max(md.mesh.y) & md.mesh.x~=0. & md.mesh.x~=max(md.mesh.x));
 
 	md.diagnostic.vertex_pairing=[posx,posx2;posy,posy2];
@@ -55,5 +55,5 @@
 		set(gcf,'Color','w')
 		printmodel(['ismipapattynvx' num2str(L)],'png','margin','on','marginsize',25,'frame','off','resolution',1.5,'hardcopy','off');
-		system(['mv ismipapattynvx' num2str(L) '.png ' ISSM_DIR '/website/doc_pdf/validation/Images/ISMIP/TestA ']);
+		system(['mv ismipapattynvx' num2str(L) '.png ' ISSM_DIR '/website/doc_pdf/validation/Images/ISMIP/TestA']);
 	end
 	plotmodel(md,'data',vy,'layer#all',md.mesh.numberoflayers,'xlim',[0 L/10^3],'ylim',[0 L/10^3],'unit','km')
@@ -61,5 +61,5 @@
 		set(gcf,'Color','w')
 		printmodel(['ismipapattynvy' num2str(L)],'png','margin','on','marginsize',25,'frame','off','resolution',1.5,'hardcopy','off');
-		system(['mv ismipapattynvy' num2str(L) '.png ' ISSM_DIR '/website/doc_pdf/validation/Images/ISMIP/TestA ']);
+		system(['mv ismipapattynvy' num2str(L) '.png ' ISSM_DIR '/website/doc_pdf/validation/Images/ISMIP/TestA']);
 	end
 	plotmodel(md,'data',vz,'layer#all',md.mesh.numberoflayers,'xlim',[0 L/10^3],'ylim',[0 L/10^3],'unit','km')
@@ -67,23 +67,23 @@
 		set(gcf,'Color','w')
 		printmodel(['ismipapattynvz' num2str(L)],'png','margin','on','marginsize',25,'frame','off','resolution',1.5,'hardcopy','off');
-		system(['mv ismipapattynvz' num2str(L) '.png ' ISSM_DIR '/website/doc_pdf/validation/Images/ISMIP/TestA ']);
+		system(['mv ismipapattynvz' num2str(L) '.png ' ISSM_DIR '/website/doc_pdf/validation/Images/ISMIP/TestA']);
 	end
 
-	if(L==5000),
+	if(L==5000.),
 		plotmodel(md,'data',vx,'sectionvalue','../Exp/ISMIP5000.exp','layer',md.mesh.numberoflayers,...
 			'resolution',[10 10],'ylim',[10 18],'xlim',[0 5000],'title','','xlabel','')
-	elseif(L==10000),
+	elseif(L==10000.),
 		plotmodel(md,'data',vx,'sectionvalue','../Exp/ISMIP10000.exp','layer',md.mesh.numberoflayers,...
 			'resolution',[10 10],'ylim',[10 30],'xlim',[0 10000],'title','','xlabel','')
-	elseif(L==20000),
+	elseif(L==20000.),
 		plotmodel(md,'data',vx,'sectionvalue','../Exp/ISMIP20000.exp','layer',md.mesh.numberoflayers,...
 			'resolution',[10 10],'ylim',[0 50],'xlim',[0 20000],'title','','xlabel','')
-	elseif(L==40000),
+	elseif(L==40000.),
 		plotmodel(md,'data',vx,'sectionvalue','../Exp/ISMIP40000.exp','layer',md.mesh.numberoflayers,...
 			'resolution',[10 10],'ylim',[0 80],'xlim',[0 40000],'title','','xlabel','')
-	elseif(L==80000),
+	elseif(L==80000.),
 		plotmodel(md,'data',vx,'sectionvalue','../Exp/ISMIP80000.exp','layer',md.mesh.numberoflayers,...
 			'resolution',[10 10],'ylim',[0 100],'xlim',[0 80000],'title','','xlabel','')
-	elseif(L==160000),
+	elseif(L==160000.),
 		plotmodel(md,'data',vx,'sectionvalue','../Exp/ISMIP160000.exp','layer',md.mesh.numberoflayers,...
 			'resolution',[10 10],'ylim',[0 120],'xlim',[0 160000],'title','','xlabel','')
@@ -92,5 +92,5 @@
 		set(gcf,'Color','w')
 		printmodel(['ismipapattynvxsec' num2str(L)],'png','margin','on','marginsize',25,'frame','off','resolution',1.5,'hardcopy','off');
-		system(['mv ismipapattynvxsec' num2str(L) '.png ' ISSM_DIR '/website/doc_pdf/validation/Images/ISMIP/TestA ']);
+		system(['mv ismipapattynvxsec' num2str(L) '.png ' ISSM_DIR '/website/doc_pdf/validation/Images/ISMIP/TestA']);
 	end
 end
@@ -101,5 +101,5 @@
 	set(gcf,'Color','w')
 	printmodel('ismipapattynminvx','png','margin','on','marginsize',25,'frame','off','resolution',1.5,'hardcopy','off');
-	system(['mv ismipapattynminvx.png ' ISSM_DIR '/website/doc_pdf/validation/Images/ISMIP/TestA ']);
+	system(['mv ismipapattynminvx.png ' ISSM_DIR '/website/doc_pdf/validation/Images/ISMIP/TestA']);
 end
 plot([5 10 20 40 80 160],maxvx);ylim([0 120]);xlim([0 160])
@@ -107,8 +107,9 @@
 	set(gcf,'Color','w')
 	printmodel('ismipapattynmaxvx','png','margin','on','marginsize',25,'frame','off','resolution',1.5,'hardcopy','off');
-	system(['mv ismipapattynmaxvx.png ' ISSM_DIR '/website/doc_pdf/validation/Images/ISMIP/TestA ']);
+	system(['mv ismipapattynmaxvx.png ' ISSM_DIR '/website/doc_pdf/validation/Images/ISMIP/TestA']);
 end
+
 %Fields and tolerances to track changes
-field_names     ={ ...
+field_names     ={...
 	'Vx5km','Vy5km','Vz5km',...
 	'Vx10km','Vy10km','Vz10km',...
Index: /issm/trunk/test/NightlyRun/test1101.py
===================================================================
--- /issm/trunk/test/NightlyRun/test1101.py	(revision 14310)
+++ /issm/trunk/test/NightlyRun/test1101.py	(revision 14310)
@@ -0,0 +1,153 @@
+import numpy
+import shutil
+from model import *
+from squaremesh import *
+from setmask import *
+from parameterize import *
+from setflowequation import *
+from EnumDefinitions import *
+from solve import *
+from MatlabFuncs import *
+from PythonFuncs import *
+
+"""
+This test is a test from the ISMP-HOM Intercomparison project.
+Pattyn and Payne 2006
+"""
+
+printingflag=False
+
+L_list=[5000.,10000.,20000.,40000.,80000.,160000.]
+results=[]
+minvx=[]
+maxvx=[]
+
+for L in L_list:
+	nx=20    #numberof nodes in x direction
+	ny=20
+	md=model()
+	md=squaremesh(md,L,L,nx,ny)
+	md=setmask(md,'','')    #ice sheet test
+	md=parameterize(md,'../Par/ISMIPA.py')
+	md.extrude(9,1.)
+
+	md=setflowequation(md,'pattyn','all')
+
+	#Create dirichlet on the bed only
+	md.diagnostic.spcvx=float('NaN')*numpy.ones((md.mesh.numberofvertices,1))
+	md.diagnostic.spcvy=float('NaN')*numpy.ones((md.mesh.numberofvertices,1))
+	md.diagnostic.spcvz=float('NaN')*numpy.ones((md.mesh.numberofvertices,1))
+
+	pos=numpy.nonzero(md.mesh.vertexonbed)
+	md.diagnostic.spcvx[pos]=0.
+	md.diagnostic.spcvy[pos]=0.
+
+	#Create MPCs to have periodic boundary conditions
+	posx=numpy.nonzero(md.mesh.x==0.)[0]
+	posx2=numpy.nonzero(md.mesh.x==numpy.max(md.mesh.x))[0]
+
+	posy=numpy.nonzero(logical_and_n(md.mesh.y==0.,md.mesh.x!=0.,md.mesh.x!=numpy.max(md.mesh.x)))[0]    #Don't take the same nodes two times
+	posy2=numpy.nonzero(logical_and_n(md.mesh.y==numpy.max(md.mesh.y),md.mesh.x!=0.,md.mesh.x!=numpy.max(md.mesh.x)))[0]
+
+	md.diagnostic.vertex_pairing=numpy.vstack((numpy.hstack((posx.reshape(-1,1)+1,posx2.reshape(-1,1)+1)),numpy.hstack((posy.reshape(-1,1)+1,posy2.reshape(-1,1)+1))))
+
+	#Compute the diagnostic
+	md.cluster=generic('name',oshostname(),'np',8)
+	md=solve(md,DiagnosticSolutionEnum())
+
+	#Plot the results and save them
+	vx=md.results.DiagnosticSolution.Vx
+	vy=md.results.DiagnosticSolution.Vy
+	vz=md.results.DiagnosticSolution.Vz
+	results.append(md.results.DiagnosticSolution)
+	minvx.append(numpy.min(vx[-md.mesh.numberofvertices2d:]))
+	maxvx.append(numpy.max(vx[-md.mesh.numberofvertices2d:]))
+
+	#Now plot vx, vy, vz and vx on a cross section
+#	plotmodel(md,'data',vx,'layer#all',md.mesh.numberoflayers,'xlim',[0 L/10^3],'ylim',[0 L/10^3],'unit','km')
+	if printingflag:
+		pass
+#		set(gcf,'Color','w')
+#		printmodel(['ismipapattynvx' num2str(L)],'png','margin','on','marginsize',25,'frame','off','resolution',1.5,'hardcopy','off');
+#		shutil.move("ismipapattynvx%d.png" % L,ISSM_DIR+'/website/doc_pdf/validation/Images/ISMIP/TestA')
+#	plotmodel(md,'data',vy,'layer#all',md.mesh.numberoflayers,'xlim',[0 L/10^3],'ylim',[0 L/10^3],'unit','km')
+	if printingflag:
+		pass
+#		set(gcf,'Color','w')
+#		printmodel(['ismipapattynvy' num2str(L)],'png','margin','on','marginsize',25,'frame','off','resolution',1.5,'hardcopy','off');
+#		shutil.move("ismipapattynvy%d.png" % L,ISSM_DIR+'/website/doc_pdf/validation/Images/ISMIP/TestA')
+#	plotmodel(md,'data',vz,'layer#all',md.mesh.numberoflayers,'xlim',[0 L/10^3],'ylim',[0 L/10^3],'unit','km')
+	if printingflag:
+		pass
+#		set(gcf,'Color','w')
+#		printmodel(['ismipapattynvz' num2str(L)],'png','margin','on','marginsize',25,'frame','off','resolution',1.5,'hardcopy','off');
+#		shutil.move("ismipapattynvz%d.png" % L,ISSM_DIR+'/website/doc_pdf/validation/Images/ISMIP/TestA')
+
+	if   (L==5000.):
+		pass
+#		plotmodel(md,'data',vx,'sectionvalue','../Exp/ISMIP5000.exp','layer',md.mesh.numberoflayers,...
+#			'resolution',[10 10],'ylim',[10 18],'xlim',[0 5000],'title','','xlabel','')
+	elif (L==10000.):
+		pass
+#		plotmodel(md,'data',vx,'sectionvalue','../Exp/ISMIP10000.exp','layer',md.mesh.numberoflayers,...
+#			'resolution',[10 10],'ylim',[10 30],'xlim',[0 10000],'title','','xlabel','')
+	elif (L==20000.):
+		pass
+#		plotmodel(md,'data',vx,'sectionvalue','../Exp/ISMIP20000.exp','layer',md.mesh.numberoflayers,...
+#			'resolution',[10 10],'ylim',[0 50],'xlim',[0 20000],'title','','xlabel','')
+	elif (L==40000.):
+		pass
+#		plotmodel(md,'data',vx,'sectionvalue','../Exp/ISMIP40000.exp','layer',md.mesh.numberoflayers,...
+#			'resolution',[10 10],'ylim',[0 80],'xlim',[0 40000],'title','','xlabel','')
+	elif (L==80000.):
+		pass
+#		plotmodel(md,'data',vx,'sectionvalue','../Exp/ISMIP80000.exp','layer',md.mesh.numberoflayers,...
+#			'resolution',[10 10],'ylim',[0 100],'xlim',[0 80000],'title','','xlabel','')
+	elif (L==160000.):
+		pass
+#		plotmodel(md,'data',vx,'sectionvalue','../Exp/ISMIP160000.exp','layer',md.mesh.numberoflayers,...
+#			'resolution',[10 10],'ylim',[0 120],'xlim',[0 160000],'title','','xlabel','')
+	if printingflag:
+		pass
+#		set(gcf,'Color','w')
+#		printmodel(['ismipapattynvxsec' num2str(L)],'png','margin','on','marginsize',25,'frame','off','resolution',1.5,'hardcopy','off');
+#		shutil.move("ismipapattynvxsec%d.png" % L,ISSM_DIR+'/website/doc_pdf/validation/Images/ISMIP/TestA')
+
+#Now plot the min and max values of vx for each size of the square
+#plot([5 10 20 40 80 160],minvx);ylim([0 18]);xlim([0 160])
+if printingflag:
+	pass
+#	set(gcf,'Color','w')
+#	printmodel('ismipapattynminvx','png','margin','on','marginsize',25,'frame','off','resolution',1.5,'hardcopy','off');
+#	shutil.move('ismipapattynminvx.png',ISSM_DIR+'/website/doc_pdf/validation/Images/ISMIP/TestA')
+#plot([5 10 20 40 80 160],maxvx);ylim([0 120]);xlim([0 160])
+if printingflag:
+	pass
+#	set(gcf,'Color','w')
+#	printmodel('ismipapattynmaxvx','png','margin','on','marginsize',25,'frame','off','resolution',1.5,'hardcopy','off');
+#	shutil.move('ismipapattynmaxvx.png',ISSM_DIR+'/website/doc_pdf/validation/Images/ISMIP/TestA')
+
+#Fields and tolerances to track changes
+field_names     =[\
+	'Vx5km','Vy5km','Vz5km',\
+	'Vx10km','Vy10km','Vz10km',\
+	'Vx20km','Vy20km','Vz20km',\
+	'Vx40km','Vy40km','Vz40km',\
+	'Vx80km','Vy80km','Vz80km',\
+	'Vx160km','Vy160km','Vz160km'
+]
+field_tolerances=[\
+	1e-09,1e-09,1e-09,\
+	1e-10,1e-10,1e-09,\
+	1e-09,1e-09,1e-09,\
+	1e-09,1e-08,1e-09,\
+	1e-08,1e-08,1e-08,\
+	1e-08,1e-07,1e-08,\
+]
+field_values=[]
+for result in results:
+	field_values=field_values+[\
+		result.Vx,\
+		result.Vy,\
+		result.Vz,\
+		]
Index: /issm/trunk/test/NightlyRun/test1102.m
===================================================================
--- /issm/trunk/test/NightlyRun/test1102.m	(revision 14309)
+++ /issm/trunk/test/NightlyRun/test1102.m	(revision 14310)
@@ -1,7 +1,7 @@
-%This test is a test from the ISMP-HOM Intercomparison project
+%This test is a test from the ISMP-HOM Intercomparison project.
 %Pattyn and Payne 2006
 printingflag=false;
 
-L_list={5000,10000,20000,40000,80000,160000};
+L_list={5000.,10000.,20000.,40000.,80000.,160000.};
 results={};
 minvx=[];
@@ -17,5 +17,5 @@
 
 %	%Find elements at the corner and extract model
-%	posnodes=find((md.mesh.x==0 | md.mesh.x==max(md.mesh.x)) & (md.mesh.y==0 | md.mesh.y==max(md.mesh.y)));
+%	posnodes=find((md.mesh.x==0. | md.mesh.x==max(md.mesh.x)) & (md.mesh.y==0. | md.mesh.y==max(md.mesh.y)));
 %	[a,b]=find(ismember(md.mesh.elements,posnodes));
 %	elements=ones(md.mesh.numberofelements,1);
@@ -29,23 +29,23 @@
 	%Create dirichlet on the bed only
 	pos=find(md.mesh.vertexonbed);
-	md.diagnostic.spcvx(pos)=0;
-	md.diagnostic.spcvy(pos)=0;
-	md.diagnostic.spcvz(pos)=0;
+	md.diagnostic.spcvx(pos)=0.;
+	md.diagnostic.spcvy(pos)=0.;
+	md.diagnostic.spcvz(pos)=0.;
 
-	%Create MPCs to have periodic boundary conditions
-	%posx=find(md.mesh.x==0);
-	%posx2=find(md.mesh.x==max(md.mesh.x));
-	%posx=find(md.mesh.x==0 & md.mesh.y~=0 & md.mesh.y~=max(md.mesh.y) & ~md.mesh.vertexonbed);
-	%posx2=find(md.mesh.x==max(md.mesh.x) &  md.mesh.y~=0 & md.mesh.y~=max(md.mesh.y) & ~md.mesh.vertexonbed);
+%	%Create MPCs to have periodic boundary conditions
+%	posx=find(md.mesh.x==0.);
+%	posx2=find(md.mesh.x==max(md.mesh.x));
+%	posx=find(md.mesh.x==0. & md.mesh.y~=0. & md.mesh.y~=max(md.mesh.y) & ~md.mesh.vertexonbed);
+%	posx2=find(md.mesh.x==max(md.mesh.x) &  md.mesh.y~=0. & md.mesh.y~=max(md.mesh.y) & ~md.mesh.vertexonbed);
 
-	%posy=find(md.mesh.y==0 & md.mesh.x~=0 & md.mesh.x~=max(md.mesh.x) & ~md.mesh.vertexonbed); %Don't take the same nodes two times
-	%posy2=find(md.mesh.y==max(md.mesh.y) & md.mesh.x~=0 & md.mesh.x~=max(md.mesh.x) & ~md.mesh.vertexonbed);
+%	posy=find(md.mesh.y==0. & md.mesh.x~=0. & md.mesh.x~=max(md.mesh.x) & ~md.mesh.vertexonbed); %Don't take the same nodes two times
+%	posy2=find(md.mesh.y==max(md.mesh.y) & md.mesh.x~=0. & md.mesh.x~=max(md.mesh.x) & ~md.mesh.vertexonbed);
 
-	%md.diagnostic.vertex_pairing=[posx,posx2;posy,posy2];
+%	md.diagnostic.vertex_pairing=[posx,posx2;posy,posy2];
 
 	%Compute the diagnostic
 	md.diagnostic.abstol=NaN;
 	md.diagnostic.reltol=NaN;
-	md.diagnostic.restol=1;
+	md.diagnostic.restol=1.;
 	md.cluster=generic('name',oshostname(),'np',8);
 	md=solve(md,DiagnosticSolutionEnum());
@@ -62,45 +62,45 @@
 	%Now plot vx, vy, vz and vx on a cross section
 	plotmodel(md,'data',vx,'layer#all',md.mesh.numberoflayers,'xlim',[0 L/10^3],'ylim',[0 L/10^3],'unit','km','figure',2)
-	if printingflag, 
+	if printingflag,
 		set(gcf,'Color','w')
 		printmodel(['ismipastokesvx' num2str(L)],'png','margin','on','marginsize',25,'frame','off','resolution',1.5,'hardcopy','off');
-		system(['mv ismipastokesvx' num2str(L) '.png ' ISSM_DIR '/website/doc_pdf/validation/Images/ISMIP/TestA ']);
+		system(['mv ismipastokesvx' num2str(L) '.png ' ISSM_DIR '/website/doc_pdf/validation/Images/ISMIP/TestA']);
 	end
 	plotmodel(md,'data',vy,'layer#all',md.mesh.numberoflayers,'xlim',[0 L/10^3],'ylim',[0 L/10^3],'unit','km','figure',3)
-	if printingflag, 
+	if printingflag,
 		set(gcf,'Color','w')
 		printmodel(['ismipastokesvy' num2str(L)],'png','margin','on','marginsize',25,'frame','off','resolution',1.5,'hardcopy','off');
-		system(['mv ismipastokesvy' num2str(L) '.png ' ISSM_DIR '/website/doc_pdf/validation/Images/ISMIP/TestA ']);
+		system(['mv ismipastokesvy' num2str(L) '.png ' ISSM_DIR '/website/doc_pdf/validation/Images/ISMIP/TestA']);
 	end
 	plotmodel(md,'data',vz,'layer#all',md.mesh.numberoflayers,'xlim',[0 L/10^3],'ylim',[0 L/10^3],'unit','km','figure',4)
-	if printingflag, 
+	if printingflag,
 		set(gcf,'Color','w')
 		printmodel(['ismipastokesvz' num2str(L)],'png','margin','on','marginsize',25,'frame','off','resolution',1.5,'hardcopy','off');
-		system(['mv ismipastokesvz' num2str(L) '.png ' ISSM_DIR '/website/doc_pdf/validation/Images/ISMIP/TestA ']);
+		system(['mv ismipastokesvz' num2str(L) '.png ' ISSM_DIR '/website/doc_pdf/validation/Images/ISMIP/TestA']);
 	end
 
-	if(L==5000),
+	if(L==5000.),
 		plotmodel(md,'data',vx,'sectionvalue','../Exp/ISMIP5000.exp','layer',md.mesh.numberoflayers,...
 			'resolution',[10 10],'ylim',[10 18],'xlim',[0 5000],'title','','xlabel','')
-	elseif(L==10000),
+	elseif(L==10000.),
 		plotmodel(md,'data',vx,'sectionvalue','../Exp/ISMIP10000.exp','layer',md.mesh.numberoflayers,...
 			'resolution',[10 10],'ylim',[10 30],'xlim',[0 10000],'title','','xlabel','')
-	elseif(L==20000),
+	elseif(L==20000.),
 		plotmodel(md,'data',vx,'sectionvalue','../Exp/ISMIP20000.exp','layer',md.mesh.numberoflayers,...
 			'resolution',[10 10],'ylim',[0 50],'xlim',[0 20000],'title','','xlabel','')
-	elseif(L==40000),
+	elseif(L==40000.),
 		plotmodel(md,'data',vx,'sectionvalue','../Exp/ISMIP40000.exp','layer',md.mesh.numberoflayers,...
 			'resolution',[10 10],'ylim',[0 80],'xlim',[0 40000],'title','','xlabel','')
-	elseif(L==80000),
+	elseif(L==80000.),
 		plotmodel(md,'data',vx,'sectionvalue','../Exp/ISMIP80000.exp','layer',md.mesh.numberoflayers,...
 			'resolution',[10 10],'ylim',[0 100],'xlim',[0 80000],'title','','xlabel','')
-	elseif(L==160000),
+	elseif(L==160000.),
 		plotmodel(md,'data',vx,'sectionvalue','../Exp/ISMIP160000.exp','layer',md.mesh.numberoflayers,...
 			'resolution',[10 10],'ylim',[0 120],'xlim',[0 160000],'title','','xlabel','')
 	end
-	if printingflag, 
+	if printingflag,
 		set(gcf,'Color','w')
 		printmodel(['ismipastokesvxsec' num2str(L)],'png','margin','on','marginsize',25,'frame','off','resolution',1.5,'hardcopy','off');
-		system(['mv ismipastokesvxsec' num2str(L) '.png ' ISSM_DIR '/website/doc_pdf/validation/Images/ISMIP/TestA ']);
+		system(['mv ismipastokesvxsec' num2str(L) '.png ' ISSM_DIR '/website/doc_pdf/validation/Images/ISMIP/TestA']);
 	end
 end
@@ -108,15 +108,16 @@
 %Now plot the min and max values of vx for each size of the square
 plot([5 10 20 40 80 160],minvx);ylim([0 18])
-if printingflag, 
+if printingflag,
 	set(gcf,'Color','w')
 	printmodel('ismipastokesminvx','png','margin','on','marginsize',25,'frame','off','resolution',1.5,'hardcopy','off');
-	system(['mv ismipastokesminvx.png ' ISSM_DIR '/website/doc_pdf/validation/Images/ISMIP/TestA ']);
+	system(['mv ismipastokesminvx.png ' ISSM_DIR '/website/doc_pdf/validation/Images/ISMIP/TestA']);
 end
 plot([5 10 20 40 80 160],maxvx);ylim([0 120])
-if printingflag, 
+if printingflag,
 	set(gcf,'Color','w')
 	printmodel('ismipastokesmaxvx','png','margin','on','marginsize',25,'frame','off','resolution',1.5,'hardcopy','off');
-	system(['mv ismipastokesmaxvx.png ' ISSM_DIR '/website/doc_pdf/validation/Images/ISMIP/TestA ']);
+	system(['mv ismipastokesmaxvx.png ' ISSM_DIR '/website/doc_pdf/validation/Images/ISMIP/TestA']);
 end
+
 %Fields and tolerances to track changes
 field_names     ={...
@@ -127,5 +128,5 @@
 	'Vx80km','Vy80km','Vz80km',...
 	'Vx160km','Vy160km','Vz160km'
-}
+};
 field_tolerances={...
 	1e-12,1e-12,1e-12,...
Index: /issm/trunk/test/NightlyRun/test1102.py
===================================================================
--- /issm/trunk/test/NightlyRun/test1102.py	(revision 14310)
+++ /issm/trunk/test/NightlyRun/test1102.py	(revision 14310)
@@ -0,0 +1,163 @@
+import numpy
+import shutil
+from model import *
+from squaremesh import *
+from setmask import *
+from parameterize import *
+from setflowequation import *
+from EnumDefinitions import *
+from solve import *
+from MatlabFuncs import *
+from PythonFuncs import *
+
+"""
+This test is a test from the ISMP-HOM Intercomparison project.
+Pattyn and Payne 2006
+"""
+
+printingflag=False
+
+L_list=[5000.,10000.,20000.,40000.,80000.,160000.]
+results=[]
+minvx=[]
+maxvx=[]
+
+for L in L_list:
+	nx=20    #numberof nodes in x direction
+	ny=20
+	md=model()
+	md=squaremesh(md,L,L,nx,ny)
+	md=setmask(md,'','')    #ice sheet test
+
+#	#Find elements at the corner and extract model
+#	posnodes=numpy.nonzero(numpy.logical_and(numpy.logical_or(md.mesh.x==0.,md.mesh.x==numpy.max(md.mesh.x)),numpy.logical_or(md.mesh.y==0.,md.mesh.y==numpy.max(md.mesh.y))))
+#	a=numpy.nonzero(ismember(md.mesh.elements,posnodes))[0]
+#	elements=numpy.ones((md.mesh.numberofelements),int)
+#	elements[a]=0
+#	md.modelextract(elements)
+
+	md=parameterize(md,'../Par/ISMIPA.py')
+	md.extrude(10,1.)
+	md=setflowequation(md,'stokes','all')
+
+	#Create dirichlet on the bed only
+	pos=numpy.nonzero(md.mesh.vertexonbed)
+	md.diagnostic.spcvx[pos]=0.
+	md.diagnostic.spcvy[pos]=0.
+	md.diagnostic.spcvz[pos]=0.
+
+#	#Create MPCs to have periodic boundary conditions
+#	posx=numpy.nonzero(md.mesh.x==0.)[0]
+#	posx2=numpy.nonzero(md.mesh.x==numpy.max(md.mesh.x))[0]
+#	posx=numpy.nonzero(logical_and_n(md.mesh.x==0.,md.mesh.y!=0.,md.mesh.y!=numpy.max(md.mesh.y),numpy.logical_not(md.mesh.vertexonbed)))[0]
+#	posx2=numpy.nonzero(logical_and_n(md.mesh.x==numpy.max(md.mesh.x),md.mesh.y!=0.,md.mesh.y!=numpy.max(md.mesh.y),numpy.logical_not(md.mesh.vertexonbed)))[0]
+
+#	posy=numpy.nonzero(logical_and_n(md.mesh.y==0.,md.mesh.x!=0.,md.mesh.x!=numpy.max(md.mesh.x),numpy.logical_not(md.mesh.vertexonbed)))[0]    #Don't take the same nodes two times
+#	posy2=numpy.nonzero(logical_and_n(md.mesh.y==numpy.max(md.mesh.y),md.mesh.x!=0.,md.mesh.x!=numpy.max(md.mesh.x),numpy.logical_not(md.mesh.vertexonbed)))[0]
+
+#	md.diagnostic.vertex_pairing=numpy.vstack((numpy.hstack((posx.reshape(-1,1)+1,posx2.reshape(-1,1)+1)),numpy.hstack((posy.reshape(-1,1)+1,posy2.reshape(-1,1)+1))))
+
+	#Compute the diagnostic
+	md.diagnostic.abstol=float('NaN')
+	md.diagnostic.reltol=float('NaN')
+	md.diagnostic.restol=1.
+	md.cluster=generic('name',oshostname(),'np',8)
+	md=solve(md,DiagnosticSolutionEnum())
+
+	#Plot the results and save them
+	vx=md.results.DiagnosticSolution.Vx
+	vy=md.results.DiagnosticSolution.Vy
+	vz=md.results.DiagnosticSolution.Vz
+	pressure=md.results.DiagnosticSolution.Pressure
+	results.append(md.results.DiagnosticSolution)
+	minvx.append(numpy.min(vx[-md.mesh.numberofvertices2d:]))
+	maxvx.append(numpy.max(vx[-md.mesh.numberofvertices2d:]))
+
+	#Now plot vx, vy, vz and vx on a cross section
+#	plotmodel(md,'data',vx,'layer#all',md.mesh.numberoflayers,'xlim',[0 L/10^3],'ylim',[0 L/10^3],'unit','km','figure',2)
+	if printingflag:
+		pass
+#		set(gcf,'Color','w')
+#		printmodel(['ismipastokesvx' num2str(L)],'png','margin','on','marginsize',25,'frame','off','resolution',1.5,'hardcopy','off');
+#		shutil.move("ismipastokesvx%d.png" % L,ISSM_DIR+'/website/doc_pdf/validation/Images/ISMIP/TestA')
+#	plotmodel(md,'data',vy,'layer#all',md.mesh.numberoflayers,'xlim',[0 L/10^3],'ylim',[0 L/10^3],'unit','km','figure',3)
+	if printingflag:
+		pass
+#		set(gcf,'Color','w')
+#		printmodel(['ismipastokesvy' num2str(L)],'png','margin','on','marginsize',25,'frame','off','resolution',1.5,'hardcopy','off');
+#		shutil.move("ismipastokesvy%d.png" % L,ISSM_DIR+'/website/doc_pdf/validation/Images/ISMIP/TestA')
+#	plotmodel(md,'data',vz,'layer#all',md.mesh.numberoflayers,'xlim',[0 L/10^3],'ylim',[0 L/10^3],'unit','km','figure',4)
+	if printingflag:
+		pass
+#		set(gcf,'Color','w')
+#		printmodel(['ismipastokesvz' num2str(L)],'png','margin','on','marginsize',25,'frame','off','resolution',1.5,'hardcopy','off');
+#		shutil.move("ismipastokesvz%d.png" % L,ISSM_DIR+'/website/doc_pdf/validation/Images/ISMIP/TestA')
+
+	if   (L==5000.):
+		pass
+#		plotmodel(md,'data',vx,'sectionvalue','../Exp/ISMIP5000.exp','layer',md.mesh.numberoflayers,...
+#			'resolution',[10 10],'ylim',[10 18],'xlim',[0 5000],'title','','xlabel','')
+	elif (L==10000.):
+		pass
+#		plotmodel(md,'data',vx,'sectionvalue','../Exp/ISMIP10000.exp','layer',md.mesh.numberoflayers,...
+#			'resolution',[10 10],'ylim',[10 30],'xlim',[0 10000],'title','','xlabel','')
+	elif (L==20000.):
+		pass
+#		plotmodel(md,'data',vx,'sectionvalue','../Exp/ISMIP20000.exp','layer',md.mesh.numberoflayers,...
+#			'resolution',[10 10],'ylim',[0 50],'xlim',[0 20000],'title','','xlabel','')
+	elif (L==40000.):
+		pass
+#		plotmodel(md,'data',vx,'sectionvalue','../Exp/ISMIP40000.exp','layer',md.mesh.numberoflayers,...
+#			'resolution',[10 10],'ylim',[0 80],'xlim',[0 40000],'title','','xlabel','')
+	elif (L==80000.):
+		pass
+#		plotmodel(md,'data',vx,'sectionvalue','../Exp/ISMIP80000.exp','layer',md.mesh.numberoflayers,...
+#			'resolution',[10 10],'ylim',[0 100],'xlim',[0 80000],'title','','xlabel','')
+	elif (L==160000.):
+		pass
+#		plotmodel(md,'data',vx,'sectionvalue','../Exp/ISMIP160000.exp','layer',md.mesh.numberoflayers,...
+#			'resolution',[10 10],'ylim',[0 120],'xlim',[0 160000],'title','','xlabel','')
+	if printingflag:
+		pass
+#		set(gcf,'Color','w')
+#		printmodel(['ismipastokesvxsec' num2str(L)],'png','margin','on','marginsize',25,'frame','off','resolution',1.5,'hardcopy','off');
+#		shutil.move("ismipastokesvxsec.png" % L,ISSM_DIR+'/website/doc_pdf/validation/Images/ISMIP/TestA')
+
+#Now plot the min and max values of vx for each size of the square
+#plot([5 10 20 40 80 160],minvx);ylim([0 18])
+if printingflag:
+	pass
+#	set(gcf,'Color','w')
+#	printmodel('ismipastokesminvx','png','margin','on','marginsize',25,'frame','off','resolution',1.5,'hardcopy','off');
+#	shutil.move('ismipastokesminvx.png',ISSM_DIR+'/website/doc_pdf/validation/Images/ISMIP/TestA')
+#plot([5 10 20 40 80 160],maxvx);ylim([0 120])
+if printingflag:
+	pass
+#	set(gcf,'Color','w')
+#	printmodel('ismipastokesmaxvx','png','margin','on','marginsize',25,'frame','off','resolution',1.5,'hardcopy','off');
+#	shutil.move('ismipastokesmaxvx.png',ISSM_DIR+'/website/doc_pdf/validation/Images/ISMIP/TestA')
+
+#Fields and tolerances to track changes
+field_names     =[\
+	'Vx5km','Vy5km','Vz5km',\
+	'Vx10km','Vy10km','Vz10km',\
+	'Vx20km','Vy20km','Vz20km',\
+	'Vx40km','Vy40km','Vz40km',\
+	'Vx80km','Vy80km','Vz80km',\
+	'Vx160km','Vy160km','Vz160km'
+]
+field_tolerances=[\
+	1e-12,1e-12,1e-12,\
+	1e-12,1e-12,1e-12,\
+	1e-12,1e-11,1e-12,\
+	1e-12,1e-11,1e-12,\
+	1e-12,1e-11,1e-12,\
+	1e-12,1e-11,1e-12,\
+]
+field_values=[]
+for result in results:
+	field_values=field_values+[\
+		result.Vx,\
+		result.Vy,\
+		result.Vz,\
+		]
Index: /issm/trunk/test/NightlyRun/test1103.m
===================================================================
--- /issm/trunk/test/NightlyRun/test1103.m	(revision 14309)
+++ /issm/trunk/test/NightlyRun/test1103.m	(revision 14310)
@@ -1,8 +1,10 @@
-%This test is a test from the ISMP-HOM Intercomparison project
+%This test is a test from the ISMP-HOM Intercomparison project.
 %Pattyn and Payne 2006
 printingflag=false;
 
-L_list={5000,10000,20000,40000,80000,160000};
+L_list={5000.,10000.,20000.,40000.,80000.,160000.};
 results={};
+minvx=[];
+maxvx=[];
 
 for i=1:length(L_list),
@@ -23,13 +25,13 @@
 	md.diagnostic.spcvz=NaN*ones(md.mesh.numberofvertices,1);
 	pos=find(md.mesh.vertexonbed);
-	md.diagnostic.spcvx(pos)=0;
-	md.diagnostic.spcvy(pos)=0;
+	md.diagnostic.spcvx(pos)=0.;
+	md.diagnostic.spcvy(pos)=0.;
 
 	%Create MPCs to have periodic boundary conditions
-	posx=find(md.mesh.x==0);
+	posx=find(md.mesh.x==0.);
 	posx2=find(md.mesh.x==max(md.mesh.x));
 
-	posy=find(md.mesh.y==0 & md.mesh.x~=0 & md.mesh.x~=max(md.mesh.x)); %Don't take the same nodes two times
-	posy2=find(md.mesh.y==max(md.mesh.y) & md.mesh.x~=0 & md.mesh.x~=max(md.mesh.x));
+	posy=find(md.mesh.y==0. & md.mesh.x~=0. & md.mesh.x~=max(md.mesh.x)); %Don't take the same nodes two times
+	posy2=find(md.mesh.y==max(md.mesh.y) & md.mesh.x~=0. & md.mesh.x~=max(md.mesh.x));
 
 	md.diagnostic.vertex_pairing=[posx,posx2;posy,posy2];
@@ -49,39 +51,39 @@
 	%Now plot vx, vy, vz and vx on a cross section
 	plotmodel(md,'data',vx,'layer#all',md.mesh.numberoflayers,'xlim',[0 L/10^3],'ylim',[0 L/10^3],'unit','km')
-	if printingflag, 
+	if printingflag,
 		set(gcf,'Color','w')
 		printmodel(['ismipbpattynvx' num2str(L)],'png','margin','on','marginsize',25,'frame','off','resolution',1.5,'hardcopy','off');
-		system(['mv ismipbpattynvx' num2str(L) '.png ' ISSM_DIR '/website/doc_pdf/validation/Images/ISMIP/TestB ']);
+		system(['mv ismipbpattynvx' num2str(L) '.png ' ISSM_DIR '/website/doc_pdf/validation/Images/ISMIP/TestB']);
 	end
 	plotmodel(md,'data',vz,'layer#all',md.mesh.numberoflayers,'xlim',[0 L/10^3],'ylim',[0 L/10^3],'unit','km')
-	if printingflag, 
+	if printingflag,
 		set(gcf,'Color','w')
 		printmodel(['ismipbpattynvz' num2str(L)],'png','margin','on','marginsize',25,'frame','off','resolution',1.5,'hardcopy','off');
-		system(['mv ismipbpattynvz' num2str(L) '.png ' ISSM_DIR '/website/doc_pdf/validation/Images/ISMIP/TestB ']);
+		system(['mv ismipbpattynvz' num2str(L) '.png ' ISSM_DIR '/website/doc_pdf/validation/Images/ISMIP/TestB']);
 	end
 
-	if(L==5000),
+	if(L==5000.),
 		plotmodel(md,'data',vx,'sectionvalue','../Exp/ISMIP5000.exp','layer',md.mesh.numberoflayers,...
 			'resolution',[10 10],'ylim',[6 16],'xlim',[0 5000],'title','','xlabel','')
-	elseif(L==10000),
+	elseif(L==10000.),
 		plotmodel(md,'data',vx,'sectionvalue','../Exp/ISMIP10000.exp','layer',md.mesh.numberoflayers,...
 			'resolution',[10 10],'ylim',[0 40],'xlim',[0 10000],'title','','xlabel','')
-	elseif(L==20000),
+	elseif(L==20000.),
 		plotmodel(md,'data',vx,'sectionvalue','../Exp/ISMIP20000.exp','layer',md.mesh.numberoflayers,...
 			'resolution',[10 10],'ylim',[0 60],'xlim',[0 20000],'title','','xlabel','')
-	elseif(L==40000),
+	elseif(L==40000.),
 		plotmodel(md,'data',vx,'sectionvalue','../Exp/ISMIP40000.exp','layer',md.mesh.numberoflayers,...
 			'resolution',[10 10],'ylim',[0 100],'xlim',[0 40000],'title','','xlabel','')
-	elseif(L==80000),
+	elseif(L==80000.),
 		plotmodel(md,'data',vx,'sectionvalue','../Exp/ISMIP80000.exp','layer',md.mesh.numberoflayers,...
 			'resolution',[10 10],'ylim',[0 120],'xlim',[0 80000],'title','','xlabel','')
-	elseif(L==160000),
+	elseif(L==160000.),
 		plotmodel(md,'data',vx,'sectionvalue','../Exp/ISMIP160000.exp','layer',md.mesh.numberoflayers,...
 			'resolution',[10 10],'ylim',[0 120],'xlim',[0 160000],'title','','xlabel','')
 	end
-	if printingflag, 
+	if printingflag,
 		set(gcf,'Color','w')
 		printmodel(['ismipbpattynvxsec' num2str(L)],'png','margin','on','marginsize',25,'frame','off','resolution',1.5,'hardcopy','off');
-		system(['mv ismipbpattynvxsec' num2str(L) '.png ' ISSM_DIR '/website/doc_pdf/validation/Images/ISMIP/TestB ']);
+		system(['mv ismipbpattynvxsec' num2str(L) '.png ' ISSM_DIR '/website/doc_pdf/validation/Images/ISMIP/TestB']);
 	end
 end
@@ -89,15 +91,16 @@
 %Now plot the min and max values of vx for each size of the square
 plot([5 10 20 40 80 160],minvx);ylim([0 14]);xlim([0 160])
-if printingflag, 
+if printingflag,
 	set(gcf,'Color','w')
 	printmodel('ismipbpattynminvx','png','margin','on','marginsize',25,'frame','off','resolution',1.5,'hardcopy','off');
-	system(['mv ismipbpattynminvx.png ' ISSM_DIR '/website/doc_pdf/validation/Images/ISMIP/TestB ']);
+	system(['mv ismipbpattynminvx.png ' ISSM_DIR '/website/doc_pdf/validation/Images/ISMIP/TestB']);
 end
 plot([5 10 20 40 80 160],maxvx);ylim([0 120]);xlim([0 160])
-if printingflag, 
+if printingflag,
 	set(gcf,'Color','w')
 	printmodel('ismipbpattynmaxvx','png','margin','on','marginsize',25,'frame','off','resolution',1.5,'hardcopy','off');
-	system(['mv ismipbpattynmaxvx.png ' ISSM_DIR '/website/doc_pdf/validation/Images/ISMIP/TestB ']);
+	system(['mv ismipbpattynmaxvx.png ' ISSM_DIR '/website/doc_pdf/validation/Images/ISMIP/TestB']);
 end
+
 %Fields and tolerances to track changes
 field_names     ={...
Index: /issm/trunk/test/NightlyRun/test1103.py
===================================================================
--- /issm/trunk/test/NightlyRun/test1103.py	(revision 14310)
+++ /issm/trunk/test/NightlyRun/test1103.py	(revision 14310)
@@ -0,0 +1,146 @@
+import numpy
+import shutil
+from model import *
+from squaremesh import *
+from setmask import *
+from parameterize import *
+from setflowequation import *
+from EnumDefinitions import *
+from solve import *
+from MatlabFuncs import *
+from PythonFuncs import *
+
+"""
+This test is a test from the ISMP-HOM Intercomparison project.
+Pattyn and Payne 2006
+"""
+
+printingflag=False
+
+L_list=[5000.,10000.,20000.,40000.,80000.,160000.]
+results=[]
+minvx=[]
+maxvx=[]
+
+for L in L_list:
+	nx=20    #numberof nodes in x direction
+	ny=20
+	md=model()
+	md=squaremesh(md,L,L,nx,ny)
+	md=setmask(md,'','')    #ice sheet test
+	md=parameterize(md,'../Par/ISMIPB.py')
+	md.extrude(10,1.)
+
+	md=setflowequation(md,'pattyn','all')
+
+	#Create dirichlet on the bed only
+	md.diagnostic.spcvx=float('NaN')*numpy.ones((md.mesh.numberofvertices,1))
+	md.diagnostic.spcvy=float('NaN')*numpy.ones((md.mesh.numberofvertices,1))
+	md.diagnostic.spcvz=float('NaN')*numpy.ones((md.mesh.numberofvertices,1))
+	pos=numpy.nonzero(md.mesh.vertexonbed)
+	md.diagnostic.spcvx[pos]=0.
+	md.diagnostic.spcvy[pos]=0.
+
+	#Create MPCs to have periodic boundary conditions
+	posx=numpy.nonzero(md.mesh.x==0.)[0]
+	posx2=numpy.nonzero(md.mesh.x==numpy.max(md.mesh.x))[0]
+
+	posy=numpy.nonzero(logical_and_n(md.mesh.y==0.,md.mesh.x!=0.,md.mesh.x!=numpy.max(md.mesh.x)))[0]    #Don't take the same nodes two times
+	posy2=numpy.nonzero(logical_and_n(md.mesh.y==numpy.max(md.mesh.y),md.mesh.x!=0.,md.mesh.x!=numpy.max(md.mesh.x)))[0]
+
+	md.diagnostic.vertex_pairing=numpy.vstack((numpy.hstack((posx.reshape(-1,1)+1,posx2.reshape(-1,1)+1)),numpy.hstack((posy.reshape(-1,1)+1,posy2.reshape(-1,1)+1))))
+
+	#Compute the diagnostic
+	md.cluster=generic('name',oshostname(),'np',8)
+	md=solve(md,DiagnosticSolutionEnum())
+
+	#Plot the results and save them
+	vx=md.results.DiagnosticSolution.Vx
+	vy=md.results.DiagnosticSolution.Vy
+	vz=md.results.DiagnosticSolution.Vz
+	results.append(md.results.DiagnosticSolution)
+	minvx.append(numpy.min(vx[md.mesh.numberofvertices2d:]))
+	maxvx.append(numpy.max(vx[md.mesh.numberofvertices2d:]))
+
+	#Now plot vx, vy, vz and vx on a cross section
+#	plotmodel(md,'data',vx,'layer#all',md.mesh.numberoflayers,'xlim',[0 L/10^3],'ylim',[0 L/10^3],'unit','km')
+	if printingflag:
+		pass
+#		set(gcf,'Color','w')
+#		printmodel(['ismipbpattynvx' num2str(L)],'png','margin','on','marginsize',25,'frame','off','resolution',1.5,'hardcopy','off');
+#		shutil.move("ismipbpattynvx%d.png" % L,ISSM_DIR+'/website/doc_pdf/validation/Images/ISMIP/TestB')
+#	plotmodel(md,'data',vz,'layer#all',md.mesh.numberoflayers,'xlim',[0 L/10^3],'ylim',[0 L/10^3],'unit','km')
+	if printingflag:
+		pass
+#		set(gcf,'Color','w')
+#		printmodel(['ismipbpattynvz' num2str(L)],'png','margin','on','marginsize',25,'frame','off','resolution',1.5,'hardcopy','off');
+#		shutil.move("ismipbpattynvz%d.png" % L,ISSM_DIR+'/website/doc_pdf/validation/Images/ISMIP/TestB')
+
+	if   (L==5000.):
+		pass
+#		plotmodel(md,'data',vx,'sectionvalue','../Exp/ISMIP5000.exp','layer',md.mesh.numberoflayers,...
+#			'resolution',[10 10],'ylim',[6 16],'xlim',[0 5000],'title','','xlabel','')
+	elif (L==10000.):
+		pass
+#		plotmodel(md,'data',vx,'sectionvalue','../Exp/ISMIP10000.exp','layer',md.mesh.numberoflayers,...
+#			'resolution',[10 10],'ylim',[0 40],'xlim',[0 10000],'title','','xlabel','')
+	elif (L==20000.):
+		pass
+#		plotmodel(md,'data',vx,'sectionvalue','../Exp/ISMIP20000.exp','layer',md.mesh.numberoflayers,...
+#			'resolution',[10 10],'ylim',[0 60],'xlim',[0 20000],'title','','xlabel','')
+	elif (L==40000.):
+		pass
+#		plotmodel(md,'data',vx,'sectionvalue','../Exp/ISMIP40000.exp','layer',md.mesh.numberoflayers,...
+#			'resolution',[10 10],'ylim',[0 100],'xlim',[0 40000],'title','','xlabel','')
+	elif (L==80000.):
+		pass
+#		plotmodel(md,'data',vx,'sectionvalue','../Exp/ISMIP80000.exp','layer',md.mesh.numberoflayers,...
+#			'resolution',[10 10],'ylim',[0 120],'xlim',[0 80000],'title','','xlabel','')
+	elif (L==160000.):
+		pass
+#		plotmodel(md,'data',vx,'sectionvalue','../Exp/ISMIP160000.exp','layer',md.mesh.numberoflayers,...
+#			'resolution',[10 10],'ylim',[0 120],'xlim',[0 160000],'title','','xlabel','')
+	if printingflag:
+		pass
+#		set(gcf,'Color','w')
+#		printmodel(['ismipbpattynvxsec' num2str(L)],'png','margin','on','marginsize',25,'frame','off','resolution',1.5,'hardcopy','off');
+#		shutil.move("ismipbpattynvxsec%d.png" % L,ISSM_DIR+'/website/doc_pdf/validation/Images/ISMIP/TestB')
+
+#Now plot the min and max values of vx for each size of the square
+#plot([5 10 20 40 80 160],minvx);ylim([0 14]);xlim([0 160])
+if printingflag:
+	pass
+#	set(gcf,'Color','w')
+#	printmodel('ismipbpattynminvx','png','margin','on','marginsize',25,'frame','off','resolution',1.5,'hardcopy','off');
+#	shutil.move('ismipbpattynminvx.png',ISSM_DIR+'/website/doc_pdf/validation/Images/ISMIP/TestB')
+#plot([5 10 20 40 80 160],maxvx);ylim([0 120]);xlim([0 160])
+if printingflag:
+	pass
+#	set(gcf,'Color','w')
+#	printmodel('ismipbpattynmaxvx','png','margin','on','marginsize',25,'frame','off','resolution',1.5,'hardcopy','off');
+#	shutil.move('ismipbpattynmaxvx.png',ISSM_DIR+'/website/doc_pdf/validation/Images/ISMIP/TestB')
+
+#Fields and tolerances to track changes
+field_names     =[\
+	'Vx5km','Vy5km','Vz5km',\
+	'Vx10km','Vy10km','Vz10km',\
+	'Vx20km','Vy20km','Vz20km',\
+	'Vx40km','Vy40km','Vz40km',\
+	'Vx80km','Vy80km','Vz80km',\
+	'Vx160km','Vy160km','Vz160km'
+]
+field_tolerances=[\
+	1e-09,1e-09,1e-09,\
+	1e-09,1e-09,1e-09,\
+	1e-09,1e-09,1e-09,\
+	1e-08,1e-08,1e-08,\
+	1e-08,1e-07,1e-07,\
+	1e-07,1e-06,1e-07,\
+]
+field_values=[]
+for result in results:
+	field_values=field_values+[\
+		result.Vx,\
+		result.Vy,\
+		result.Vz,\
+		]
Index: /issm/trunk/test/NightlyRun/test1104.m
===================================================================
--- /issm/trunk/test/NightlyRun/test1104.m	(revision 14309)
+++ /issm/trunk/test/NightlyRun/test1104.m	(revision 14310)
@@ -1,6 +1,6 @@
-%This test is a test from the ISMP-HOM Intercomparison project
+%This test is a test from the ISMP-HOM Intercomparison project.
 %Pattyn and Payne 2006
 
-L_list={5000,10000,20000,40000,80000,160000};
+L_list={5000.,10000.,20000.,40000.,80000.,160000.};
 results={};
 
@@ -22,13 +22,13 @@
 
 	pos=find(md.mesh.vertexonbed);
-	md.diagnostic.spcvx(pos)=0;
-	md.diagnostic.spcvy(pos)=0;
+	md.diagnostic.spcvx(pos)=0.;
+	md.diagnostic.spcvy(pos)=0.;
 
 	%Create MPCs to have periodic boundary conditions
-	posx=find(md.mesh.x==0);
+	posx=find(md.mesh.x==0.);
 	posx2=find(md.mesh.x==max(md.mesh.x));
 
-	posy=find(md.mesh.y==0 & md.mesh.x~=0 & md.mesh.x~=max(md.mesh.x)); %Don't take the same nodes two times
-	posy2=find(md.mesh.y==max(md.mesh.y) & md.mesh.x~=0 & md.mesh.x~=max(md.mesh.x));
+	posy=find(md.mesh.y==0. & md.mesh.x~=0. & md.mesh.x~=max(md.mesh.x)); %Don't take the same nodes two times
+	posy2=find(md.mesh.y==max(md.mesh.y) & md.mesh.x~=0. & md.mesh.x~=max(md.mesh.x));
 
 	md.diagnostic.vertex_pairing=[posx,posx2;posy,posy2];
@@ -38,5 +38,5 @@
 	md.cluster=generic('name',oshostname(),'np',8);
 	md=solve(md,DiagnosticSolutionEnum());
-	pos=find(md.mesh.x==0 | md.mesh.y==0 | md.mesh.x==max(md.mesh.x) | md.mesh.y==max(md.mesh.y));
+	pos=find(md.mesh.x==0. | md.mesh.y==0. | md.mesh.x==max(md.mesh.x) | md.mesh.y==max(md.mesh.y));
 	md.diagnostic.spcvx(pos)=md.results.DiagnosticSolution.Vx(pos);
 	md.diagnostic.spcvy(pos)=md.results.DiagnosticSolution.Vy(pos);
Index: /issm/trunk/test/NightlyRun/test1104.py
===================================================================
--- /issm/trunk/test/NightlyRun/test1104.py	(revision 14310)
+++ /issm/trunk/test/NightlyRun/test1104.py	(revision 14310)
@@ -0,0 +1,90 @@
+import numpy
+from model import *
+from squaremesh import *
+from setmask import *
+from parameterize import *
+from setflowequation import *
+from EnumDefinitions import *
+from solve import *
+from MatlabFuncs import *
+from PythonFuncs import *
+
+"""
+This test is a test from the ISMP-HOM Intercomparison project.
+Pattyn and Payne 2006
+"""
+
+L_list=[5000.,10000.,20000.,40000.,80000.,160000.]
+results=[]
+
+for L in L_list:
+	nx=20    #numberof nodes in x direction
+	ny=20
+	md=model()
+	md=squaremesh(md,L,L,nx,ny)
+	md=setmask(md,'','')    #ice sheet test
+	md=parameterize(md,'../Par/ISMIPB.py')
+	md.extrude(10,1.)
+	md=setflowequation(md,'pattyn','all')
+
+	#Create dirichlet on the bed only
+	md.diagnostic.spcvx=float('NaN')*numpy.ones((md.mesh.numberofvertices,1))
+	md.diagnostic.spcvy=float('NaN')*numpy.ones((md.mesh.numberofvertices,1))
+	md.diagnostic.spcvz=float('NaN')*numpy.ones((md.mesh.numberofvertices,1))
+
+	pos=numpy.nonzero(md.mesh.vertexonbed)
+	md.diagnostic.spcvx[pos]=0.
+	md.diagnostic.spcvy[pos]=0.
+
+	#Create MPCs to have periodic boundary conditions
+	posx=numpy.nonzero(md.mesh.x==0.)[0]
+	posx2=numpy.nonzero(md.mesh.x==numpy.max(md.mesh.x))[0]
+
+	posy=numpy.nonzero(logical_and_n(md.mesh.y==0.,md.mesh.x!=0.,md.mesh.x!=numpy.max(md.mesh.x)))[0]    #Don't take the same nodes two times
+	posy2=numpy.nonzero(logical_and_n(md.mesh.y==numpy.max(md.mesh.y),md.mesh.x!=0.,md.mesh.x!=numpy.max(md.mesh.x)))[0]
+
+	md.diagnostic.vertex_pairing=numpy.vstack((numpy.hstack((posx.reshape(-1,1)+1,posx2.reshape(-1,1)+1)),numpy.hstack((posy.reshape(-1,1)+1,posy2.reshape(-1,1)+1))))
+
+	#Compute the diagnostic
+	md.diagnostic.abstol=float('NaN')
+	md.cluster=generic('name',oshostname(),'np',8)
+	md=solve(md,DiagnosticSolutionEnum())
+	pos=numpy.nonzero(logical_or_n(md.mesh.x==0.,md.mesh.y==0.,md.mesh.x==numpy.max(md.mesh.x),md.mesh.y==numpy.max(md.mesh.y)))
+	md.diagnostic.spcvx[pos]=md.results.DiagnosticSolution.Vx[pos]
+	md.diagnostic.spcvy[pos]=md.results.DiagnosticSolution.Vy[pos]
+	md.diagnostic.vertex_pairing=numpy.empty((0,2),int)
+	md=setflowequation(md,'stokes','all')
+	md=solve(md,DiagnosticSolutionEnum())
+
+	#Plot the results and save them
+	vx=md.results.DiagnosticSolution.Vx
+	vy=md.results.DiagnosticSolution.Vy
+	vz=md.results.DiagnosticSolution.Vz
+	results.append(md.results.DiagnosticSolution)
+
+#	plotmodel(md,'data',vx,'data',vy,'data',vz,'layer#all',md.mesh.numberoflayers)
+
+#Fields and tolerances to track changes
+field_names     =[\
+	'Vx5km','Vy5km','Vz5km',\
+	'Vx10km','Vy10km','Vz10km',\
+	'Vx20km','Vy20km','Vz20km',\
+	'Vx40km','Vy40km','Vz40km',\
+	'Vx80km','Vy80km','Vz80km',\
+	'Vx160km','Vy160km','Vz160km'
+]
+field_tolerances=[\
+	1e-08,1e-08,1e-08,\
+	1e-08,1e-08,1e-08,\
+	1e-08,1e-08,1e-08,\
+	1e-08,1e-08,1e-08,\
+	1e-08,1e-07,1e-08,\
+	1e-07,1e-07,1e-07,\
+]
+field_values=[]
+for result in results:
+	field_values=field_values+[\
+		result.Vx,\
+		result.Vy,\
+		result.Vz,\
+		]
Index: /issm/trunk/test/NightlyRun/test1105.m
===================================================================
--- /issm/trunk/test/NightlyRun/test1105.m	(revision 14309)
+++ /issm/trunk/test/NightlyRun/test1105.m	(revision 14310)
@@ -1,7 +1,7 @@
-%This test is a test from the ISMP-HOM Intercomparison project
+%This test is a test from the ISMP-HOM Intercomparison project.
 %Pattyn and Payne 2006
 printingflag=false;
 
-L_list={5000,10000,20000,40000,80000,160000};
+L_list={5000.,10000.,20000.,40000.,80000.,160000.};
 results={};
 minvx=[];
@@ -9,5 +9,5 @@
 
 for i=1:length(L_list),
-	L=L_list{i};  %in m (3 times the desired lenght for BC problems)  
+	L=L_list{i};  %in m (3 times the desired length for BC problems)  
 	nx=30; %number of nodes in x direction
 	ny=30;
@@ -18,5 +18,5 @@
 	md=extrude(md,10,1.);
 
-	md=setflowequation(md,'pattyn','all'); 
+	md=setflowequation(md,'pattyn','all');
 
 	%Create MPCs to have periodic boundary conditions
@@ -25,32 +25,32 @@
 	md.diagnostic.spcvz=NaN*ones(md.mesh.numberofvertices,1);
 
-	posx=find(md.mesh.x==0 & md.mesh.y~=0 & md.mesh.y~=L);
-	posx2=find(md.mesh.x==L & md.mesh.y~=0 & md.mesh.y~=L);
+	posx=find(md.mesh.x==0. & md.mesh.y~=0. & md.mesh.y~=L);
+	posx2=find(md.mesh.x==L & md.mesh.y~=0. & md.mesh.y~=L);
 
-	posy=find(md.mesh.y==0 & md.mesh.x~=0 & md.mesh.x~=L); %Don't take the same nodes two times
-	posy2=find(md.mesh.y==L & md.mesh.x~=0 & md.mesh.x~=L);
+	posy=find(md.mesh.y==0. & md.mesh.x~=0. & md.mesh.x~=L); %Don't take the same nodes two times
+	posy2=find(md.mesh.y==L & md.mesh.x~=0. & md.mesh.x~=L);
 
 	md.diagnostic.vertex_pairing=[posx,posx2;posy,posy2];
 
 	%Add spc on the corners
-	pos=find((md.mesh.x==0 | md.mesh.x==L) & (md.mesh.y==0 | md.mesh.y==L) & md.mesh.vertexonbed);
-	md.diagnostic.spcvx(pos)=0;
-	md.diagnostic.spcvy(pos)=0;
-	if(L==5000),
+	pos=find((md.mesh.x==0. | md.mesh.x==L) & (md.mesh.y==0. | md.mesh.y==L) & md.mesh.vertexonbed);
+	md.diagnostic.spcvx(pos)=0.;
+	md.diagnostic.spcvy(pos)=0.;
+	if(L==5000.),
 		md.diagnostic.spcvx(pos)=15.66;
 		md.diagnostic.spcvy(pos)=-0.1967;
-	elseif(L==10000),
+	elseif(L==10000.),
 		md.diagnostic.spcvx(pos)=16.04;
 		md.diagnostic.spcvy(pos)=-0.1977;
-	elseif(L==20000),
+	elseif(L==20000.),
 		md.diagnostic.spcvx(pos)=16.53;
 		md.diagnostic.spcvy(pos)=-1.27;
-	elseif(L==40000),
+	elseif(L==40000.),
 		md.diagnostic.spcvx(pos)=17.23;
 		md.diagnostic.spcvy(pos)=-3.17;
-	elseif(L==80000),
+	elseif(L==80000.),
 		md.diagnostic.spcvx(pos)=16.68;
 		md.diagnostic.spcvy(pos)=-2.69;
-	elseif(L==160000),
+	elseif(L==160000.),
 		md.diagnostic.spcvx(pos)=16.03;
 		md.diagnostic.spcvy(pos)=-1.27;
@@ -59,5 +59,5 @@
 	%Spc the bed at zero for vz
 	pos=find(md.mesh.vertexonbed);
-	md.diagnostic.spcvz(pos)=0;
+	md.diagnostic.spcvz(pos)=0.;
 
 	%Compute the diagnostic
@@ -75,45 +75,45 @@
 	%Now plot vx, vy, vz and vx on a cross section
 	plotmodel(md,'data',vx,'layer#all',md.mesh.numberoflayers,'xlim',[0 L/10^3],'ylim',[0 L/10^3],'unit','km','figure',2)
-	if printingflag, 
+	if printingflag,
 		set(gcf,'Color','w')
 		printmodel(['ismipcpattynvx' num2str(L)],'png','margin','on','marginsize',25,'frame','off','resolution',1.5,'hardcopy','off');
-		system(['mv ismipcpattynvx' num2str(L) '.png ' ISSM_DIR '/website/doc_pdf/validation/Images/ISMIP/TestC ']);
+		system(['mv ismipcpattynvx' num2str(L) '.png ' ISSM_DIR '/website/doc_pdf/validation/Images/ISMIP/TestC']);
 	end
 	plotmodel(md,'data',vy,'layer#all',md.mesh.numberoflayers,'xlim',[0 L/10^3],'ylim',[0 L/10^3],'unit','km','figure',3)
-	if printingflag, 
+	if printingflag,
 		set(gcf,'Color','w')
 		printmodel(['ismipcpattynvy' num2str(L)],'png','margin','on','marginsize',25,'frame','off','resolution',1.5,'hardcopy','off');
-		system(['mv ismipcpattynvy' num2str(L) '.png ' ISSM_DIR '/website/doc_pdf/validation/Images/ISMIP/TestC ']);
+		system(['mv ismipcpattynvy' num2str(L) '.png ' ISSM_DIR '/website/doc_pdf/validation/Images/ISMIP/TestC']);
 	end
 	plotmodel(md,'data',vz,'layer#all',md.mesh.numberoflayers,'xlim',[0 L/10^3],'ylim',[0 L/10^3],'unit','km','figure',4)
-	if printingflag, 
+	if printingflag,
 		set(gcf,'Color','w')
 		printmodel(['ismipcpattynvz' num2str(L)],'png','margin','on','marginsize',25,'frame','off','resolution',1.5,'hardcopy','off');
-		system(['mv ismipcpattynvz' num2str(L) '.png ' ISSM_DIR '/website/doc_pdf/validation/Images/ISMIP/TestC ']);
+		system(['mv ismipcpattynvz' num2str(L) '.png ' ISSM_DIR '/website/doc_pdf/validation/Images/ISMIP/TestC']);
 	end
 
-	if(L==5000),
+	if(L==5000.),
 		plotmodel(md,'data',vx,'sectionvalue','../Exp/ISMIP5000.exp','layer',md.mesh.numberoflayers,...
 			'resolution',[10 10],'ylim',[0 20],'xlim',[0 5000],'title','','xlabel','','figure',5)
-	elseif(L==10000),
+	elseif(L==10000.),
 		plotmodel(md,'data',vx,'sectionvalue','../Exp/ISMIP10000.exp','layer',md.mesh.numberoflayers,...
 			'resolution',[10 10],'ylim',[13 18],'xlim',[0 10000],'title','','xlabel','')
-	elseif(L==20000),
+	elseif(L==20000.),
 		plotmodel(md,'data',vx,'sectionvalue','../Exp/ISMIP20000.exp','layer',md.mesh.numberoflayers,...
 			'resolution',[10 10],'ylim',[14 22],'xlim',[0 20000],'title','','xlabel','')
-	elseif(L==40000),
+	elseif(L==40000.),
 		plotmodel(md,'data',vx,'sectionvalue','../Exp/ISMIP40000.exp','layer',md.mesh.numberoflayers,...
 			'resolution',[10 10],'ylim',[10 40],'xlim',[0 40000],'title','','xlabel','')
-	elseif(L==80000),
+	elseif(L==80000.),
 		plotmodel(md,'data',vx,'sectionvalue','../Exp/ISMIP80000.exp','layer',md.mesh.numberoflayers,...
 			'resolution',[10 10],'ylim',[0 80],'xlim',[0 80000],'title','','xlabel','')
-	elseif(L==160000),
+	elseif(L==160000.),
 		plotmodel(md,'data',vx,'sectionvalue','../Exp/ISMIP160000.exp','layer',md.mesh.numberoflayers,...
 			'resolution',[10 10],'ylim',[0 200],'xlim',[0 160000],'title','','xlabel','')
 	end
-	if printingflag, 
+	if printingflag,
 		set(gcf,'Color','w')
 		printmodel(['ismipcpattynvxsec' num2str(L)],'png','margin','on','marginsize',25,'frame','off','resolution',1.5,'hardcopy','off');
-		system(['mv ismipcpattynvxsec' num2str(L) '.png ' ISSM_DIR '/website/doc_pdf/validation/Images/ISMIP/TestC ']);
+		system(['mv ismipcpattynvxsec' num2str(L) '.png ' ISSM_DIR '/website/doc_pdf/validation/Images/ISMIP/TestC']);
 	end
 end
@@ -121,15 +121,16 @@
 %Now plot the min and max values of vx for each size of the square
 plot([5 10 20 40 80 160],minvx);ylim([4 18]);xlim([0 160])
-if printingflag, 
+if printingflag,
 	set(gcf,'Color','w')
 	printmodel('ismipcpattynminvx','png','margin','on','marginsize',25,'frame','off','resolution',1.5,'hardcopy','off');
-	system(['mv ismipcpattynminvx.png ' ISSM_DIR '/website/doc_pdf/validation/Images/ISMIP/TestC ']);
+	system(['mv ismipcpattynminvx.png ' ISSM_DIR '/website/doc_pdf/validation/Images/ISMIP/TestC']);
 end
 plot([5 10 20 40 80 160],maxvx);ylim([0 200]); xlim([0 160])
-if printingflag, 
+if printingflag,
 	set(gcf,'Color','w')
 	printmodel('ismipcpattynmaxvx','png','margin','on','marginsize',25,'frame','off','resolution',1.5,'hardcopy','off');
-	system(['mv ismipcpattynmaxvx.png ' ISSM_DIR '/website/doc_pdf/validation/Images/ISMIP/TestC ']);
+	system(['mv ismipcpattynmaxvx.png ' ISSM_DIR '/website/doc_pdf/validation/Images/ISMIP/TestC']);
 end
+
 %Fields and tolerances to track changes
 field_names     ={...
Index: /issm/trunk/test/NightlyRun/test1105.py
===================================================================
--- /issm/trunk/test/NightlyRun/test1105.py	(revision 14310)
+++ /issm/trunk/test/NightlyRun/test1105.py	(revision 14310)
@@ -0,0 +1,175 @@
+import numpy
+import shutil
+from model import *
+from squaremesh import *
+from setmask import *
+from parameterize import *
+from setflowequation import *
+from EnumDefinitions import *
+from solve import *
+from MatlabFuncs import *
+from PythonFuncs import *
+
+"""
+This test is a test from the ISMP-HOM Intercomparison project.
+Pattyn and Payne 2006
+"""
+
+printingflag=False
+
+L_list=[5000.,10000.,20000.,40000.,80000.,160000.]
+results=[]
+minvx=[]
+maxvx=[]
+
+for L in L_list:    #in m (3 times the desired length for BC problems)  
+	nx=30    #number of nodes in x direction
+	ny=30
+	md=model()
+	md=squaremesh(md,L,L,nx,ny)
+	md=setmask(md,'','')    #ice sheet test
+	md=parameterize(md,'../Par/ISMIPC.py')
+	md.extrude(10,1.)
+
+	md=setflowequation(md,'pattyn','all')
+
+	#Create MPCs to have periodic boundary conditions
+	md.diagnostic.spcvx=float('NaN')*numpy.ones((md.mesh.numberofvertices,1))
+	md.diagnostic.spcvy=float('NaN')*numpy.ones((md.mesh.numberofvertices,1))
+	md.diagnostic.spcvz=float('NaN')*numpy.ones((md.mesh.numberofvertices,1))
+
+	posx=numpy.nonzero(logical_and_n(md.mesh.x==0.,md.mesh.y!=0.,md.mesh.y!=L))[0]
+	posx2=numpy.nonzero(logical_and_n(md.mesh.x==L,md.mesh.y!=0.,md.mesh.y!=L))[0]
+
+	posy=numpy.nonzero(logical_and_n(md.mesh.y==0.,md.mesh.x!=0.,md.mesh.x!=L))[0]    #Don't take the same nodes two times
+	posy2=numpy.nonzero(logical_and_n(md.mesh.y==L,md.mesh.x!=0.,md.mesh.x!=L))[0]
+
+	md.diagnostic.vertex_pairing=numpy.vstack((numpy.hstack((posx.reshape(-1,1)+1,posx2.reshape(-1,1)+1)),numpy.hstack((posy.reshape(-1,1)+1,posy2.reshape(-1,1)+1))))
+
+	#Add spc on the corners
+	pos=numpy.nonzero(logical_and_n(numpy.logical_or(md.mesh.x==0.,md.mesh.x==L),numpy.logical_or(md.mesh.y==0.,md.mesh.y==L),md.mesh.vertexonbed))
+	md.diagnostic.spcvx[pos]=0.
+	md.diagnostic.spcvy[pos]=0.
+	if   (L==5000.):
+		md.diagnostic.spcvx[pos]=15.66
+		md.diagnostic.spcvy[pos]=-0.1967
+	elif (L==10000.):
+		md.diagnostic.spcvx[pos]=16.04
+		md.diagnostic.spcvy[pos]=-0.1977
+	elif (L==20000.):
+		md.diagnostic.spcvx[pos]=16.53
+		md.diagnostic.spcvy[pos]=-1.27
+	elif (L==40000.):
+		md.diagnostic.spcvx[pos]=17.23
+		md.diagnostic.spcvy[pos]=-3.17
+	elif (L==80000.):
+		md.diagnostic.spcvx[pos]=16.68
+		md.diagnostic.spcvy[pos]=-2.69
+	elif (L==160000.):
+		md.diagnostic.spcvx[pos]=16.03
+		md.diagnostic.spcvy[pos]=-1.27
+	
+	#Spc the bed at zero for vz
+	pos=numpy.nonzero(md.mesh.vertexonbed)
+	md.diagnostic.spcvz[pos]=0.
+
+	#Compute the diagnostic
+	md.cluster=generic('name',oshostname(),'np',8)
+	md=solve(md,DiagnosticSolutionEnum())
+
+	#Plot the results and save them
+	vx=md.results.DiagnosticSolution.Vx
+	vy=md.results.DiagnosticSolution.Vy
+	vz=md.results.DiagnosticSolution.Vz
+	results.append(md.results.DiagnosticSolution)
+	minvx.append(numpy.min(vx[-md.mesh.numberofvertices2d:]))
+	maxvx.append(numpy.max(vx[-md.mesh.numberofvertices2d:]))
+
+	#Now plot vx, vy, vz and vx on a cross section
+#	plotmodel(md,'data',vx,'layer#all',md.mesh.numberoflayers,'xlim',[0 L/10^3],'ylim',[0 L/10^3],'unit','km','figure',2)
+	if printingflag:
+		pass
+#		set(gcf,'Color','w')
+#		printmodel(['ismipcpattynvx' num2str(L)],'png','margin','on','marginsize',25,'frame','off','resolution',1.5,'hardcopy','off');
+#		shutil.move("ismipcpattynvx%d.png" % L,ISSM_DIR+'/website/doc_pdf/validation/Images/ISMIP/TestC')
+#	plotmodel(md,'data',vy,'layer#all',md.mesh.numberoflayers,'xlim',[0 L/10^3],'ylim',[0 L/10^3],'unit','km','figure',3)
+	if printingflag:
+		pass
+#		set(gcf,'Color','w')
+#		printmodel(['ismipcpattynvy' num2str(L)],'png','margin','on','marginsize',25,'frame','off','resolution',1.5,'hardcopy','off');
+#		shutil.move("ismipcpattynvy%d.png" % L,ISSM_DIR+'/website/doc_pdf/validation/Images/ISMIP/TestC')
+#	plotmodel(md,'data',vz,'layer#all',md.mesh.numberoflayers,'xlim',[0 L/10^3],'ylim',[0 L/10^3],'unit','km','figure',4)
+	if printingflag:
+		pass
+#		set(gcf,'Color','w')
+#		printmodel(['ismipcpattynvz' num2str(L)],'png','margin','on','marginsize',25,'frame','off','resolution',1.5,'hardcopy','off');
+#		shutil.move("ismipcpattynvz%d.png" % L,ISSM_DIR+'/website/doc_pdf/validation/Images/ISMIP/TestC')
+
+	if   (L==5000.):
+		pass
+#		plotmodel(md,'data',vx,'sectionvalue','../Exp/ISMIP5000.exp','layer',md.mesh.numberoflayers,...
+#			'resolution',[10 10],'ylim',[0 20],'xlim',[0 5000],'title','','xlabel','','figure',5)
+	elif (L==10000.):
+		pass
+#		plotmodel(md,'data',vx,'sectionvalue','../Exp/ISMIP10000.exp','layer',md.mesh.numberoflayers,...
+#			'resolution',[10 10],'ylim',[13 18],'xlim',[0 10000],'title','','xlabel','')
+	elif (L==20000.):
+		pass
+#		plotmodel(md,'data',vx,'sectionvalue','../Exp/ISMIP20000.exp','layer',md.mesh.numberoflayers,...
+#			'resolution',[10 10],'ylim',[14 22],'xlim',[0 20000],'title','','xlabel','')
+	elif (L==40000.):
+		pass
+#		plotmodel(md,'data',vx,'sectionvalue','../Exp/ISMIP40000.exp','layer',md.mesh.numberoflayers,...
+#			'resolution',[10 10],'ylim',[10 40],'xlim',[0 40000],'title','','xlabel','')
+	elif (L==80000.):
+		pass
+#		plotmodel(md,'data',vx,'sectionvalue','../Exp/ISMIP80000.exp','layer',md.mesh.numberoflayers,...
+#			'resolution',[10 10],'ylim',[0 80],'xlim',[0 80000],'title','','xlabel','')
+	elif (L==160000.):
+		pass
+#		plotmodel(md,'data',vx,'sectionvalue','../Exp/ISMIP160000.exp','layer',md.mesh.numberoflayers,...
+#			'resolution',[10 10],'ylim',[0 200],'xlim',[0 160000],'title','','xlabel','')
+	if printingflag:
+		pass
+#		set(gcf,'Color','w')
+#		printmodel(['ismipcpattynvxsec' num2str(L)],'png','margin','on','marginsize',25,'frame','off','resolution',1.5,'hardcopy','off');
+#		shutil.move("ismipcpattynvxsec%d.png" % L,ISSM_DIR+'/website/doc_pdf/validation/Images/ISMIP/TestC')
+
+#Now plot the min and max values of vx for each size of the square
+#plot([5 10 20 40 80 160],minvx);ylim([4 18]);xlim([0 160])
+if printingflag:
+	pass
+#	set(gcf,'Color','w')
+#	printmodel('ismipcpattynminvx','png','margin','on','marginsize',25,'frame','off','resolution',1.5,'hardcopy','off');
+#	shutil.move('ismipcpattynminvx.png',ISSM_DIR+'/website/doc_pdf/validation/Images/ISMIP/TestC')
+#plot([5 10 20 40 80 160],maxvx);ylim([0 200]); xlim([0 160])
+if printingflag:
+	pass
+#	set(gcf,'Color','w')
+#	printmodel('ismipcpattynmaxvx','png','margin','on','marginsize',25,'frame','off','resolution',1.5,'hardcopy','off');
+#	shutil.move('ismipcpattynmaxvx.png',ISSM_DIR+'/website/doc_pdf/validation/Images/ISMIP/TestC')
+
+#Fields and tolerances to track changes
+field_names     =[\
+	'Vx5km','Vy5km','Vz5km',\
+	'Vx10km','Vy10km','Vz10km',\
+	'Vx20km','Vy20km','Vz20km',\
+	'Vx40km','Vy40km','Vz40km',\
+	'Vx80km','Vy80km','Vz80km',\
+	'Vx160km','Vy160km','Vz160km'
+]
+field_tolerances=[\
+	1e-08,1e-07,1e-07,\
+	1e-09,1e-07,1e-07,\
+	1e-09,1e-09,1e-07,\
+	1e-09,1e-09,1e-08,\
+	1e-09,1e-08,1e-08,\
+	1e-09,1e-08,1e-08,\
+]
+field_values=[]
+for result in results:
+	field_values=field_values+[\
+		result.Vx,\
+		result.Vy,\
+		result.Vz,\
+		]
Index: /issm/trunk/test/NightlyRun/test1106.m
===================================================================
--- /issm/trunk/test/NightlyRun/test1106.m	(revision 14309)
+++ /issm/trunk/test/NightlyRun/test1106.m	(revision 14310)
@@ -1,6 +1,6 @@
-%This test is a test from the ISMP-HOM Intercomparison project
+%This test is a test from the ISMP-HOM Intercomparison project.
 %Pattyn and Payne 2006
 
-L_list={5000,10000,20000,40000,80000,160000};
+L_list={5000.,10000.,20000.,40000.,80000.,160000.};
 results={};
 
@@ -10,32 +10,32 @@
 	md=setmask(md,'',''); %ice sheet test
 	md=parameterize(md,'../Par/ISMIPC.par');
-	md.friction.coefficient=sqrt(md.constants.yts.*(1000+1000*sin(md.mesh.x*2*pi/L).*sin(md.mesh.y*2*pi/L)));
+	md.friction.coefficient=sqrt(md.constants.yts.*(1000.+1000.*sin(md.mesh.x*2.*pi/L).*sin(md.mesh.y*2.*pi/L)));
 	md=extrude(md,10,1.);
 
 	%Add spc on the borders
-	pos=find((md.mesh.x==0 | md.mesh.x==max(md.mesh.x) | md.mesh.y==0 | md.mesh.y==max(md.mesh.y)));
-	md.diagnostic.spcvx(pos)=0;
-	md.diagnostic.spcvy(pos)=0;
-	if(L==5000),
+	pos=find(md.mesh.x==0. | md.mesh.x==max(md.mesh.x) | md.mesh.y==0. | md.mesh.y==max(md.mesh.y));
+	md.diagnostic.spcvx(pos)=0.;
+	md.diagnostic.spcvy(pos)=0.;
+	if(L==5000.),
 		md.diagnostic.spcvx(pos)=15.66;
 		md.diagnostic.spcvy(pos)=-0.1967;
-	elseif(L==10000),
+	elseif(L==10000.),
 		md.diagnostic.spcvx(pos)=16.04;
 		md.diagnostic.spcvy(pos)=-0.1977;
-	elseif(L==20000),
+	elseif(L==20000.),
 		md.diagnostic.spcvx(pos)=16.53;
 		md.diagnostic.spcvy(pos)=-1.27;
-	elseif(L==40000),
+	elseif(L==40000.),
 		md.diagnostic.spcvx(pos)=17.23;
 		md.diagnostic.spcvy(pos)=-3.17;
-	elseif(L==80000),
+	elseif(L==80000.),
 		md.diagnostic.spcvx(pos)=16.68;
 		md.diagnostic.spcvy(pos)=-2.69;
-	elseif(L==160000),
+	elseif(L==160000.),
 		md.diagnostic.spcvx(pos)=16.03;
 		md.diagnostic.spcvy(pos)=-1.27;
 	end
 
-	md=setflowequation(md,'stokes','all'); 
+	md=setflowequation(md,'stokes','all');
 
 	%Compute the diagnostic
Index: /issm/trunk/test/NightlyRun/test1106.py
===================================================================
--- /issm/trunk/test/NightlyRun/test1106.py	(revision 14310)
+++ /issm/trunk/test/NightlyRun/test1106.py	(revision 14310)
@@ -0,0 +1,87 @@
+import numpy
+from model import *
+from triangle import *
+from setmask import *
+from parameterize import *
+from setflowequation import *
+from EnumDefinitions import *
+from solve import *
+from MatlabFuncs import *
+from PythonFuncs import *
+
+"""
+This test is a test from the ISMP-HOM Intercomparison project.
+Pattyn and Payne 2006
+"""
+
+L_list=[5000.,10000.,20000.,40000.,80000.,160000.]
+results=[]
+
+for L in L_list:
+	md=triangle(model(),"../Exp/Square_%d.exp" % L,L/10.)    #size 3*L 
+	md=setmask(md,'','')    #ice sheet test
+	md=parameterize(md,'../Par/ISMIPC.py')
+	md.friction.coefficient=numpy.sqrt(md.constants.yts*(1000.+1000.*numpy.sin(md.mesh.x.reshape(-1,1)*2.*numpy.pi/L)*numpy.sin(md.mesh.y.reshape(-1,1)*2.*numpy.pi/L)))
+	md.extrude(10,1.)
+
+	#Add spc on the borders
+	pos=numpy.nonzero(logical_or_n(md.mesh.x==0.,md.mesh.x==numpy.max(md.mesh.x),md.mesh.y==0.,md.mesh.y==numpy.max(md.mesh.y)))
+	md.diagnostic.spcvx[pos]=0.
+	md.diagnostic.spcvy[pos]=0.
+	if   (L==5000.):
+		md.diagnostic.spcvx[pos]=15.66
+		md.diagnostic.spcvy[pos]=-0.1967
+	elif (L==10000.):
+		md.diagnostic.spcvx[pos]=16.04
+		md.diagnostic.spcvy[pos]=-0.1977
+	elif (L==20000.):
+		md.diagnostic.spcvx[pos]=16.53
+		md.diagnostic.spcvy[pos]=-1.27
+	elif (L==40000.):
+		md.diagnostic.spcvx[pos]=17.23
+		md.diagnostic.spcvy[pos]=-3.17
+	elif (L==80000.):
+		md.diagnostic.spcvx[pos]=16.68
+		md.diagnostic.spcvy[pos]=-2.69
+	elif (L==160000.):
+		md.diagnostic.spcvx[pos]=16.03
+		md.diagnostic.spcvy[pos]=-1.27
+
+	md=setflowequation(md,'stokes','all')
+
+	#Compute the diagnostic
+	md.cluster=generic('name',oshostname(),'np',8)
+	md=solve(md,DiagnosticSolutionEnum())
+
+	#Plot the results and save them
+	vx=md.results.DiagnosticSolution.Vx
+	vy=md.results.DiagnosticSolution.Vy
+	vz=md.results.DiagnosticSolution.Vz
+	results.append(md.results.DiagnosticSolution)
+
+#	plotmodel(md,'data',vx,'data',vy,'data',vz,'layer#all',md.mesh.numberoflayers)
+
+#Fields and tolerances to track changes
+field_names     =[\
+	'Vx5km','Vy5km','Vz5km',\
+	'Vx10km','Vy10km','Vz10km',\
+	'Vx20km','Vy20km','Vz20km',\
+	'Vx40km','Vy40km','Vz40km',\
+	'Vx80km','Vy80km','Vz80km',\
+	'Vx160km','Vy160km','Vz160km'
+]
+field_tolerances=[\
+	1e-12,1e-12,1e-11,\
+	1e-12,1e-12,1e-12,\
+	1e-12,1e-12,1e-12,\
+	1e-12,1e-12,1e-12,\
+	1e-12,1e-12,1e-12,\
+	1e-12,1e-11,1e-12,\
+]
+field_values=[]
+for result in results:
+	field_values=field_values+[\
+		result.Vx,\
+		result.Vy,\
+		result.Vz,\
+		]
Index: /issm/trunk/test/NightlyRun/test1107.m
===================================================================
--- /issm/trunk/test/NightlyRun/test1107.m	(revision 14309)
+++ /issm/trunk/test/NightlyRun/test1107.m	(revision 14310)
@@ -1,7 +1,7 @@
-%This test is a test from the ISMP-HOM Intercomparison project
+%This test is a test from the ISMP-HOM Intercomparison project.
 %Pattyn and Payne 2006
 printingflag=false;
 
-L_list={5000,10000,20000,40000,80000,160000};
+L_list={5000.,10000.,20000.,40000.,80000.,160000.};
 results={};
 minvx=[];
@@ -26,27 +26,27 @@
 
 	%Create MPCs to have periodic boundary conditions
-	posx=find(md.mesh.x==0 & ~(md.mesh.y==0 & md.mesh.vertexonbed) & ~(md.mesh.y==L & md.mesh.vertexonbed));
-	posx2=find(md.mesh.x==max(md.mesh.x) & ~(md.mesh.y==0 & md.mesh.vertexonbed) & ~(md.mesh.y==L & md.mesh.vertexonbed));
+	posx=find(md.mesh.x==0. & ~(md.mesh.y==0. & md.mesh.vertexonbed) & ~(md.mesh.y==L & md.mesh.vertexonbed));
+	posx2=find(md.mesh.x==max(md.mesh.x) & ~(md.mesh.y==0. & md.mesh.vertexonbed) & ~(md.mesh.y==L & md.mesh.vertexonbed));
 
-	posy=find(md.mesh.y==0 & md.mesh.x~=0 & md.mesh.x~=max(md.mesh.x)); %Don't take the same nodes two times
-	posy2=find(md.mesh.y==max(md.mesh.y) & md.mesh.x~=0 & md.mesh.x~=max(md.mesh.x));
+	posy=find(md.mesh.y==0. & md.mesh.x~=0. & md.mesh.x~=max(md.mesh.x)); %Don't take the same nodes two times
+	posy2=find(md.mesh.y==max(md.mesh.y) & md.mesh.x~=0. & md.mesh.x~=max(md.mesh.x));
 
 	md.diagnostic.vertex_pairing=[posx,posx2;posy,posy2];
 
 	%Add spc on the corners
-	pos=find((md.mesh.x==0 | md.mesh.x==L) & (md.mesh.y==0 | md.mesh.y==L) & md.mesh.vertexonbed);
-	md.diagnostic.spcvy(:)=0;
-	md.diagnostic.spcvx(pos)=0;
-	if(L==5000),
+	pos=find((md.mesh.x==0. | md.mesh.x==L) & (md.mesh.y==0. | md.mesh.y==L) & md.mesh.vertexonbed);
+	md.diagnostic.spcvy(:)=0.;
+	md.diagnostic.spcvx(pos)=0.;
+	if(L==5000.),
 		md.diagnostic.spcvx(pos)=16.0912;
-	elseif(L==10000),
+	elseif(L==10000.),
 		md.diagnostic.spcvx(pos)=16.52;
-	elseif(L==20000),
+	elseif(L==20000.),
 		md.diagnostic.spcvx(pos)=17.77;
-	elseif(L==40000),
+	elseif(L==40000.),
 		md.diagnostic.spcvx(pos)=19.88;
-	elseif(L==80000),
+	elseif(L==80000.),
 		md.diagnostic.spcvx(pos)=18.65;
-	elseif(L==160000),
+	elseif(L==160000.),
 		md.diagnostic.spcvx(pos)=16.91;
 	end
@@ -54,5 +54,5 @@
 	%Spc the bed at zero for vz
 	pos=find(md.mesh.vertexonbed);
-	md.diagnostic.spcvz(pos)=0;
+	md.diagnostic.spcvz(pos)=0.;
 
 	%Compute the diagnostic
@@ -70,39 +70,39 @@
 	%Now plot vx, vy, vz and vx on a cross section
 	plotmodel(md,'data',vx,'layer#all',md.mesh.numberoflayers,'xlim',[0 L/10^3],'ylim',[0 L/10^3],'unit','km','figure',2)
-	if printingflag, 
+	if printingflag,
 		set(gcf,'Color','w')
 		printmodel(['ismipdpattynvx' num2str(L)],'png','margin','on','marginsize',25,'frame','off','resolution',1.5,'hardcopy','off');
-		system(['mv ismipdpattynvx' num2str(L) '.png ' ISSM_DIR '/website/doc_pdf/validation/Images/ISMIP/TestD ']);
+		system(['mv ismipdpattynvx' num2str(L) '.png ' ISSM_DIR '/website/doc_pdf/validation/Images/ISMIP/TestD']);
 	end
 	plotmodel(md,'data',vz,'layer#all',md.mesh.numberoflayers,'xlim',[0 L/10^3],'ylim',[0 L/10^3],'unit','km','figure',3)
-	if printingflag, 
+	if printingflag,
 		set(gcf,'Color','w')
 		printmodel(['ismipdpattynvz' num2str(L)],'png','margin','on','marginsize',25,'frame','off','resolution',1.5,'hardcopy','off');
-		system(['mv ismipdpattynvz' num2str(L) '.png ' ISSM_DIR '/website/doc_pdf/validation/Images/ISMIP/TestD ']);
+		system(['mv ismipdpattynvz' num2str(L) '.png ' ISSM_DIR '/website/doc_pdf/validation/Images/ISMIP/TestD']);
 	end
 
-	if(L==5000),
+	if(L==5000.),
 		plotmodel(md,'data',vx,'sectionvalue','../Exp/ISMIP5000.exp','layer',md.mesh.numberoflayers,...
 			'resolution',[10 10],'ylim',[0 20],'xlim',[0 5000],'title','','xlabel','','figure',4)
-	elseif(L==10000),
+	elseif(L==10000.),
 		plotmodel(md,'data',vx,'sectionvalue','../Exp/ISMIP10000.exp','layer',md.mesh.numberoflayers,...
 			'resolution',[10 10],'ylim',[0 20],'xlim',[0 10000],'title','','xlabel','','figure',4)
-	elseif(L==20000),
+	elseif(L==20000.),
 		plotmodel(md,'data',vx,'sectionvalue','../Exp/ISMIP20000.exp','layer',md.mesh.numberoflayers,...
 			'resolution',[10 10],'ylim',[0 30],'xlim',[0 20000],'title','','xlabel','','figure',4)
-	elseif(L==40000),
+	elseif(L==40000.),
 		plotmodel(md,'data',vx,'sectionvalue','../Exp/ISMIP40000.exp','layer',md.mesh.numberoflayers,...
 			'resolution',[10 10],'ylim',[10 60],'xlim',[0 40000],'title','','xlabel','','figure',4)
-	elseif(L==80000),
+	elseif(L==80000.),
 		plotmodel(md,'data',vx,'sectionvalue','../Exp/ISMIP80000.exp','layer',md.mesh.numberoflayers,...
 			'resolution',[10 10],'ylim',[0 200],'xlim',[0 80000],'title','','xlabel','','figure',4)
-	elseif(L==160000),
+	elseif(L==160000.),
 		plotmodel(md,'data',vx,'sectionvalue','../Exp/ISMIP160000.exp','layer',md.mesh.numberoflayers,...
 			'resolution',[10 10],'ylim',[0 400],'xlim',[0 160000],'title','','xlabel','','figure',4)
 	end
-	if printingflag, 
+	if printingflag,
 		set(gcf,'Color','w')
 		printmodel(['ismipdpattynvxsec' num2str(L)],'png','margin','on','marginsize',25,'frame','off','resolution',1.5,'hardcopy','off');
-		system(['mv ismipdpattynvxsec' num2str(L) '.png ' ISSM_DIR '/website/doc_pdf/validation/Images/ISMIP/TestD ']);
+		system(['mv ismipdpattynvxsec' num2str(L) '.png ' ISSM_DIR '/website/doc_pdf/validation/Images/ISMIP/TestD']);
 	end
 end
@@ -110,15 +110,16 @@
 %Now plot the min and max values of vx for each size of the square
 plot([5 10 20 40 80 160],minvx);ylim([2 18]);xlim([0 160])
-if printingflag, 
+if printingflag,
 	set(gcf,'Color','w')
 	printmodel('ismipdpattynminvx','png','margin','on','marginsize',25,'frame','off','resolution',1.5,'hardcopy','off');
-	system(['mv ismipdpattynminvx.png ' ISSM_DIR '/website/doc_pdf/validation/Images/ISMIP/TestD ']);
+	system(['mv ismipdpattynminvx.png ' ISSM_DIR '/website/doc_pdf/validation/Images/ISMIP/TestD']);
 end
 plot([5 10 20 40 80 160],maxvx);ylim([0 300]);xlim([0 160])
-if printingflag, 
+if printingflag,
 	set(gcf,'Color','w')
 	printmodel('ismipdpattynmaxvx','png','margin','on','marginsize',25,'frame','off','resolution',1.5,'hardcopy','off');
-	system(['mv ismipdpattynmaxvx.png ' ISSM_DIR '/website/doc_pdf/validation/Images/ISMIP/TestD ']);
+	system(['mv ismipdpattynmaxvx.png ' ISSM_DIR '/website/doc_pdf/validation/Images/ISMIP/TestD']);
 end
+
 %Fields and tolerances to track changes
 field_names     ={...
Index: /issm/trunk/test/NightlyRun/test1107.py
===================================================================
--- /issm/trunk/test/NightlyRun/test1107.py	(revision 14310)
+++ /issm/trunk/test/NightlyRun/test1107.py	(revision 14310)
@@ -0,0 +1,166 @@
+import numpy
+import shutil
+from model import *
+from squaremesh import *
+from setmask import *
+from parameterize import *
+from setflowequation import *
+from EnumDefinitions import *
+from solve import *
+from MatlabFuncs import *
+from PythonFuncs import *
+
+"""
+This test is a test from the ISMP-HOM Intercomparison project.
+Pattyn and Payne 2006
+"""
+
+printingflag=False
+
+L_list=[5000.,10000.,20000.,40000.,80000.,160000.]
+results=[]
+minvx=[]
+maxvx=[]
+
+for L in L_list:
+	nx=30    #numberof nodes in x direction
+	ny=30
+	md=model()
+	md=squaremesh(md,L,L,nx,ny)
+	md=setmask(md,'','')    #ice sheet test
+	md=parameterize(md,'../Par/ISMIPD.py')
+	md.extrude(10,1.)
+
+	md=setflowequation(md,'pattyn','all')
+
+	#We need one grd on dirichlet: the 4 corners are set to zero
+	md.diagnostic.spcvx=float('NaN')*numpy.ones((md.mesh.numberofvertices,1))
+	md.diagnostic.spcvy=float('NaN')*numpy.ones((md.mesh.numberofvertices,1))
+	md.diagnostic.spcvz=float('NaN')*numpy.ones((md.mesh.numberofvertices,1))
+
+	#Create MPCs to have periodic boundary conditions
+#	posx=find(md.mesh.x==0. & ~(md.mesh.y==0. & md.mesh.vertexonbed) & ~(md.mesh.y==L & md.mesh.vertexonbed));
+	posx=numpy.nonzero(logical_and_n(md.mesh.x==0.,numpy.logical_not(numpy.logical_and(md.mesh.y==0.,md.mesh.vertexonbed)),numpy.logical_not(numpy.logical_and(md.mesh.y==L,md.mesh.vertexonbed))))[0]
+#	posx2=find(md.mesh.x==max(md.mesh.x) & ~(md.mesh.y==0. & md.mesh.vertexonbed) & ~(md.mesh.y==L & md.mesh.vertexonbed));
+	posx2=numpy.nonzero(logical_and_n(md.mesh.x==numpy.max(md.mesh.x),numpy.logical_not(numpy.logical_and(md.mesh.y==0.,md.mesh.vertexonbed)),numpy.logical_not(numpy.logical_and(md.mesh.y==L,md.mesh.vertexonbed))))[0]
+
+	posy=numpy.nonzero(logical_and_n(md.mesh.y==0.,md.mesh.x!=0.,md.mesh.x!=numpy.max(md.mesh.x)))[0]    #Don't take the same nodes two times
+	posy2=numpy.nonzero(logical_and_n(md.mesh.y==numpy.max(md.mesh.y),md.mesh.x!=0.,md.mesh.x!=numpy.max(md.mesh.x)))[0]
+
+	md.diagnostic.vertex_pairing=numpy.vstack((numpy.hstack((posx.reshape(-1,1)+1,posx2.reshape(-1,1)+1)),numpy.hstack((posy.reshape(-1,1)+1,posy2.reshape(-1,1)+1))))
+
+	#Add spc on the corners
+	pos=numpy.nonzero(logical_and_n(numpy.logical_or(md.mesh.x==0.,md.mesh.x==L),numpy.logical_or(md.mesh.y==0.,md.mesh.y==L),md.mesh.vertexonbed))
+	md.diagnostic.spcvy[:]=0.
+	md.diagnostic.spcvx[pos]=0.
+	if   (L==5000.):
+		md.diagnostic.spcvx[pos]=16.0912
+	elif (L==10000.):
+		md.diagnostic.spcvx[pos]=16.52
+	elif (L==20000.):
+		md.diagnostic.spcvx[pos]=17.77
+	elif (L==40000.):
+		md.diagnostic.spcvx[pos]=19.88
+	elif (L==80000.):
+		md.diagnostic.spcvx[pos]=18.65
+	elif (L==160000.):
+		md.diagnostic.spcvx[pos]=16.91
+	
+	#Spc the bed at zero for vz
+	pos=numpy.nonzero(md.mesh.vertexonbed)
+	md.diagnostic.spcvz[pos]=0.
+
+	#Compute the diagnostic
+	md.cluster=generic('name',oshostname(),'np',8)
+	md=solve(md,DiagnosticSolutionEnum())
+
+	#Plot the results and save them
+	vx=md.results.DiagnosticSolution.Vx
+	vy=md.results.DiagnosticSolution.Vy
+	vz=md.results.DiagnosticSolution.Vz
+	results.append(md.results.DiagnosticSolution)
+	minvx.append(numpy.min(vx[-md.mesh.numberofvertices2d:]))
+	maxvx.append(numpy.max(vx[-md.mesh.numberofvertices2d:]))
+
+	#Now plot vx, vy, vz and vx on a cross section
+#	plotmodel(md,'data',vx,'layer#all',md.mesh.numberoflayers,'xlim',[0 L/10^3],'ylim',[0 L/10^3],'unit','km','figure',2)
+	if printingflag:
+		pass
+#		set(gcf,'Color','w')
+#		printmodel(['ismipdpattynvx' num2str(L)],'png','margin','on','marginsize',25,'frame','off','resolution',1.5,'hardcopy','off');
+#		shutil.move("ismipdpattynvx%d.png" % L,ISSM_DIR+'/website/doc_pdf/validation/Images/ISMIP/TestD')
+#	plotmodel(md,'data',vz,'layer#all',md.mesh.numberoflayers,'xlim',[0 L/10^3],'ylim',[0 L/10^3],'unit','km','figure',3)
+	if printingflag:
+		pass
+#		set(gcf,'Color','w')
+#		printmodel(['ismipdpattynvz' num2str(L)],'png','margin','on','marginsize',25,'frame','off','resolution',1.5,'hardcopy','off');
+#		shutil.move("ismipdpattynvz%d.png" % L,ISSM_DIR+'/website/doc_pdf/validation/Images/ISMIP/TestD')
+
+	if   (L==5000.):
+		pass
+#		plotmodel(md,'data',vx,'sectionvalue','../Exp/ISMIP5000.exp','layer',md.mesh.numberoflayers,...
+#			'resolution',[10 10],'ylim',[0 20],'xlim',[0 5000],'title','','xlabel','','figure',4)
+	elif (L==10000.):
+		pass
+#		plotmodel(md,'data',vx,'sectionvalue','../Exp/ISMIP10000.exp','layer',md.mesh.numberoflayers,...
+#			'resolution',[10 10],'ylim',[0 20],'xlim',[0 10000],'title','','xlabel','','figure',4)
+	elif (L==20000.):
+		pass
+#		plotmodel(md,'data',vx,'sectionvalue','../Exp/ISMIP20000.exp','layer',md.mesh.numberoflayers,...
+#			'resolution',[10 10],'ylim',[0 30],'xlim',[0 20000],'title','','xlabel','','figure',4)
+	elif (L==40000.):
+		pass
+#		plotmodel(md,'data',vx,'sectionvalue','../Exp/ISMIP40000.exp','layer',md.mesh.numberoflayers,...
+#			'resolution',[10 10],'ylim',[10 60],'xlim',[0 40000],'title','','xlabel','','figure',4)
+	elif (L==80000.):
+		pass
+#		plotmodel(md,'data',vx,'sectionvalue','../Exp/ISMIP80000.exp','layer',md.mesh.numberoflayers,...
+#			'resolution',[10 10],'ylim',[0 200],'xlim',[0 80000],'title','','xlabel','','figure',4)
+	elif (L==160000.):
+		pass
+#		plotmodel(md,'data',vx,'sectionvalue','../Exp/ISMIP160000.exp','layer',md.mesh.numberoflayers,...
+#			'resolution',[10 10],'ylim',[0 400],'xlim',[0 160000],'title','','xlabel','','figure',4)
+	if printingflag:
+		pass
+#		set(gcf,'Color','w')
+#		printmodel(['ismipdpattynvxsec' num2str(L)],'png','margin','on','marginsize',25,'frame','off','resolution',1.5,'hardcopy','off');
+#		shutil.move("ismipdpattynvxsec%d.png" % L,ISSM_DIR+'/website/doc_pdf/validation/Images/ISMIP/TestD')
+
+#Now plot the min and max values of vx for each size of the square
+#plot([5 10 20 40 80 160],minvx);ylim([2 18]);xlim([0 160])
+if printingflag:
+	pass
+#	set(gcf,'Color','w')
+#	printmodel('ismipdpattynminvx','png','margin','on','marginsize',25,'frame','off','resolution',1.5,'hardcopy','off');
+#	shutil.move('ismipdpattynminvx.png',ISSM_DIR+'/website/doc_pdf/validation/Images/ISMIP/TestD')
+#plot([5 10 20 40 80 160],maxvx);ylim([0 300]);xlim([0 160])
+if printingflag:
+	pass
+#	set(gcf,'Color','w')
+#	printmodel('ismipdpattynmaxvx','png','margin','on','marginsize',25,'frame','off','resolution',1.5,'hardcopy','off');
+#	shutil.move('ismipdpattynmaxvx.png',ISSM_DIR+'/website/doc_pdf/validation/Images/ISMIP/TestD')
+
+#Fields and tolerances to track changes
+field_names     =[\
+	'Vx5km','Vy5km','Vz5km',\
+	'Vx10km','Vy10km','Vz10km',\
+	'Vx20km','Vy20km','Vz20km',\
+	'Vx40km','Vy40km','Vz40km',\
+	'Vx80km','Vy80km','Vz80km',\
+	'Vx160km','Vy160km','Vz160km'
+]
+field_tolerances=[\
+	1e-07,1e-08,1e-06,\
+	1e-08,1e-08,1e-06,\
+	1e-08,1e-08,1e-07,\
+	1e-08,1e-08,1e-07,\
+	1e-08,1e-08,1e-07,\
+	1e-07,1e-08,1e-06,\
+]
+field_values=[]
+for result in results:
+	field_values=field_values+[\
+		result.Vx,\
+		result.Vy,\
+		result.Vz,\
+		]
Index: /issm/trunk/test/NightlyRun/test1108.m
===================================================================
--- /issm/trunk/test/NightlyRun/test1108.m	(revision 14309)
+++ /issm/trunk/test/NightlyRun/test1108.m	(revision 14310)
@@ -1,6 +1,6 @@
-%This test is a test from the ISMP-HOM Intercomparison project
+%This test is a test from the ISMP-HOM Intercomparison project.
 %Pattyn and Payne 2006
 
-L_list={5000,10000,20000,40000,80000,160000};
+L_list={5000.,10000.,20000.,40000.,80000.,160000.};
 results={};
 
@@ -17,20 +17,20 @@
 	md=setflowequation(md,'pattyn','all');
 
-	%We need one grd on dirichlet: the 4 corners are set to zero
+	%We need one grid on dirichlet: the 4 corners are set to zero
 	md.diagnostic.spcvx=NaN*ones(md.mesh.numberofvertices,1);
 	md.diagnostic.spcvy=NaN*ones(md.mesh.numberofvertices,1);
 	md.diagnostic.spcvz=NaN*ones(md.mesh.numberofvertices,1);
 	
-	pos=find(md.mesh.vertexonbed & (md.mesh.x==0 | md.mesh.x==max(md.mesh.x)) & (md.mesh.y==0 | md.mesh.y==max(md.mesh.y)));
-	md.diagnostic.spcvx(pos)=0;
-	md.diagnostic.spcvy(pos)=0;
-	md.diagnostic.spcvz(pos)=0;
+	pos=find(md.mesh.vertexonbed & (md.mesh.x==0. | md.mesh.x==max(md.mesh.x)) & (md.mesh.y==0. | md.mesh.y==max(md.mesh.y)));
+	md.diagnostic.spcvx(pos)=0.;
+	md.diagnostic.spcvy(pos)=0.;
+	md.diagnostic.spcvz(pos)=0.;
 
 	%Create MPCs to have periodic boundary conditions
-	posx=find(md.mesh.x==0);
+	posx=find(md.mesh.x==0.);
 	posx2=find(md.mesh.x==max(md.mesh.x));
 
-	posy=find(md.mesh.y==0 & md.mesh.x~=0 & md.mesh.x~=max(md.mesh.x)); %Don't take the same nodes two times
-	posy2=find(md.mesh.y==max(md.mesh.y) & md.mesh.x~=0 & md.mesh.x~=max(md.mesh.x));
+	posy=find(md.mesh.y==0. & md.mesh.x~=0. & md.mesh.x~=max(md.mesh.x)); %Don't take the same nodes two times
+	posy2=find(md.mesh.y==max(md.mesh.y) & md.mesh.x~=0. & md.mesh.x~=max(md.mesh.x));
 
 	md.diagnostic.vertex_pairing=[posx,posx2;posy,posy2];
@@ -47,5 +47,5 @@
 	md.diagnostic.spcvy=NaN*ones(md.mesh.numberofvertices,1);
 	md.diagnostic.spcvz=NaN*ones(md.mesh.numberofvertices,1);
-	pos=find(md.mesh.y==0 | md.mesh.x==0 | md.mesh.x==max(md.mesh.x) | md.mesh.y==max(md.mesh.y)); %Don't take the same nodes two times
+	pos=find(md.mesh.y==0. | md.mesh.x==0. | md.mesh.x==max(md.mesh.x) | md.mesh.y==max(md.mesh.y)); %Don't take the same nodes two times
 	md.diagnostic.spcvx(pos)=md.results.DiagnosticSolution.Vx(pos);
 	md.diagnostic.spcvy(pos)=md.results.DiagnosticSolution.Vy(pos);
Index: /issm/trunk/test/NightlyRun/test1108.py
===================================================================
--- /issm/trunk/test/NightlyRun/test1108.py	(revision 14310)
+++ /issm/trunk/test/NightlyRun/test1108.py	(revision 14310)
@@ -0,0 +1,98 @@
+import numpy
+from model import *
+from bamg import *
+from setmask import *
+from parameterize import *
+from setflowequation import *
+from EnumDefinitions import *
+from solve import *
+from MatlabFuncs import *
+from PythonFuncs import *
+
+"""
+This test is a test from the ISMP-HOM Intercomparison project.
+Pattyn and Payne 2006
+"""
+
+L_list=[5000.,10000.,20000.,40000.,80000.,160000.]
+results=[]
+
+for L in L_list:
+	nx=30    #numberof nodes in x direction
+	ny=30
+	md=model()
+	md=squaremesh(md,L,L,nx,ny)
+	md=setmask(md,'','')    #ice sheet test
+	md=parameterize(md,'../Par/ISMIPD.py')
+	md.extrude(10,1.)
+
+	md=setflowequation(md,'pattyn','all')
+
+	#We need one grd on dirichlet: the 4 corners are set to zero
+	md.diagnostic.spcvx=float('NaN')*numpy.ones((md.mesh.numberofvertices,1))
+	md.diagnostic.spcvy=float('NaN')*numpy.ones((md.mesh.numberofvertices,1))
+	md.diagnostic.spcvz=float('NaN')*numpy.ones((md.mesh.numberofvertices,1))
+	
+	pos=numpy.nonzero(logical_and_n(md.mesh.vertexonbed,numpy.logical_or(md.mesh.x==0.,md.mesh.x==numpy.max(md.mesh.x)),numpy.logical_or(md.mesh.y==0.,md.mesh.y==numpy.max(md.mesh.y))))
+	md.diagnostic.spcvx[pos]=0.
+	md.diagnostic.spcvy[pos]=0.
+	md.diagnostic.spcvz[pos]=0.
+
+	#Create MPCs to have periodic boundary conditions
+	posx=numpy.nonzero(md.mesh.x==0.)[0]
+	posx2=numpy.nonzero(md.mesh.x==numpy.max(md.mesh.x))[0]
+
+	posy=numpy.nonzero(logical_and_n(md.mesh.y==0.,md.mesh.x!=0.,md.mesh.x!=numpy.max(md.mesh.x)))[0]    #Don't take the same nodes two times
+	posy2=numpy.nonzero(logical_and_n(md.mesh.y==numpy.max(md.mesh.y),md.mesh.x!=0.,md.mesh.x!=numpy.max(md.mesh.x)))[0]
+
+	md.diagnostic.vertex_pairing=numpy.vstack((numpy.hstack((posx.reshape(-1,1)+1,posx2.reshape(-1,1)+1)),numpy.hstack((posy.reshape(-1,1)+1,posy2.reshape(-1,1)+1))))
+
+	#Compute the diagnostic
+	md.cluster=generic('name',oshostname(),'np',8)
+	md.verbose=verbose('convergence',True)
+	md=solve(md,DiagnosticSolutionEnum())
+	md.diagnostic.reltol=float('NaN')
+	md.diagnostic.abstol=float('NaN')
+	md.diagnostic.vertex_pairing=numpy.empty((0,2))
+	#We need one grid on dirichlet: the 4 corners are set to zero
+	md.diagnostic.spcvx=float('NaN')*numpy.ones((md.mesh.numberofvertices,1))
+	md.diagnostic.spcvy=float('NaN')*numpy.ones((md.mesh.numberofvertices,1))
+	md.diagnostic.spcvz=float('NaN')*numpy.ones((md.mesh.numberofvertices,1))
+	pos=numpy.nonzero(logical_or_n(md.mesh.y==0.,md.mesh.x==0.,md.mesh.x==numpy.max(md.mesh.x),md.mesh.y==numpy.max(md.mesh.y)))    #Don't take the same nodes two times
+	md.diagnostic.spcvx[pos]=md.results.DiagnosticSolution.Vx[pos]
+	md.diagnostic.spcvy[pos]=md.results.DiagnosticSolution.Vy[pos]
+	md=setflowequation(md,'stokes','all')
+	md=solve(md,DiagnosticSolutionEnum())
+
+	#Plot the results and save them
+	vx=md.results.DiagnosticSolution.Vx
+	vy=md.results.DiagnosticSolution.Vy
+	vz=md.results.DiagnosticSolution.Vz
+	results.append(md.results.DiagnosticSolution)
+
+#	plotmodel(md,'data',vx,'data',vy,'data',vz,'layer#all',md.mesh.numberoflayers)
+
+#Fields and tolerances to track changes
+field_names     =[\
+	'Vx5km','Vy5km','Vz5km',\
+	'Vx10km','Vy10km','Vz10km',\
+	'Vx20km','Vy20km','Vz20km',\
+	'Vx40km','Vy40km','Vz40km',\
+	'Vx80km','Vy80km','Vz80km',\
+	'Vx160km','Vy160km','Vz160km'
+]
+field_tolerances=[\
+	1e-07,1e-07,1e-07,\
+	1e-08,1e-08,1e-08,\
+	1e-08,1e-07,1e-07,\
+	1e-08,1e-08,1e-08,\
+	1e-08,1e-07,1e-07,\
+	1e-07,1e-06,1e-07,\
+]
+field_values=[]
+for result in results:
+	field_values=field_values+[\
+		result.Vx,\
+		result.Vy,\
+		result.Vz,\
+		]
Index: /issm/trunk/test/NightlyRun/test1109.m
===================================================================
--- /issm/trunk/test/NightlyRun/test1109.m	(revision 14309)
+++ /issm/trunk/test/NightlyRun/test1109.m	(revision 14310)
@@ -1,3 +1,3 @@
-%This test is a test from the ISMP-HOM Intercomparison project
+%This test is a test from the ISMP-HOM Intercomparison project.
 %TestE 
 %Four tests to run: - Pattyn frozen
@@ -9,6 +9,6 @@
 
 for i=1:4,
-	Lx=10; %in m
-	Ly=5000; %in m
+	Lx=10.; %in m
+	Ly=5000.; %in m
 	nx=3; %number of nodes in x direction
 	ny=51;
@@ -26,5 +26,5 @@
 
 	%Create MPCs to have periodic boundary conditions
-	posx=find(md.mesh.x==0);
+	posx=find(md.mesh.x==0.);
 	posx2=find(md.mesh.x==max(md.mesh.x));
 	md.diagnostic.vertex_pairing=[posx,posx2];
@@ -35,7 +35,7 @@
 	md.diagnostic.spcvy=NaN*ones(md.mesh.numberofvertices,1);
 	md.diagnostic.spcvz=NaN*ones(md.mesh.numberofvertices,1);
-	md.diagnostic.spcvx(pos)=0;
-	md.diagnostic.spcvy(pos)=0;
-	md.diagnostic.spcvz(pos)=0;
+	md.diagnostic.spcvx(pos)=0.;
+	md.diagnostic.spcvy(pos)=0.;
+	md.diagnostic.spcvz(pos)=0.;
 
 	%Remove the spc where there is some sliding (case 3 and 4):
@@ -58,34 +58,35 @@
 	if i==1,
 		plotmodel(md,'data',vy,'ylim',[-10 80],'layer',md.mesh.numberoflayers,'sectionvalue','../Exp/ISMIPE.exp','resolution',[10 10],'title','','xlabel','')
-		if printingflag, 
+		if printingflag,
 			set(gcf,'Color','w')
 			printmodel('ismipepattynvxfrozen','png','margin','on','marginsize',25,'frame','off','resolution',1.5,'hardcopy','off');
-			system(['mv ismipepattynvxfrozen.png ' ISSM_DIR '/website/doc_pdf/validation/Images/ISMIP/TestE ']);
+			system(['mv ismipepattynvxfrozen.png ' ISSM_DIR '/website/doc_pdf/validation/Images/ISMIP/TestE']);
 		end
 	elseif i==2,
 		plotmodel(md,'data',vy,'ylim',[-10 80],'layer',md.mesh.numberoflayers,'sectionvalue','../Exp/ISMIPE.exp','resolution',[10 10],'title','','xlabel','')
-		if printingflag, 
+		if printingflag,
 			set(gcf,'Color','w')
 			printmodel('ismipestokesvxfrozen','png','margin','on','marginsize',25,'frame','off','resolution',1.5,'hardcopy','off');
-			system(['mv ismipestokesvxfrozen.png ' ISSM_DIR '/website/doc_pdf/validation/Images/ISMIP/TestE ']);
+			system(['mv ismipestokesvxfrozen.png ' ISSM_DIR '/website/doc_pdf/validation/Images/ISMIP/TestE']);
 		end
 	elseif i==3,
 		plotmodel(md,'data',vy,'ylim',[-50 200],'layer',md.mesh.numberoflayers,'sectionvalue','../Exp/ISMIPE.exp','resolution',[10 10],'title','','xlabel','')
-		if printingflag, 
+		if printingflag,
 			set(gcf,'Color','w')
 			printmodel('ismipepattynvxsliding','png','margin','on','marginsize',25,'frame','off','resolution',1.5,'hardcopy','off');
-			system(['mv ismipepattynvxsliding.png ' ISSM_DIR '/website/doc_pdf/validation/Images/ISMIP/TestE ']);
+			system(['mv ismipepattynvxsliding.png ' ISSM_DIR '/website/doc_pdf/validation/Images/ISMIP/TestE']);
 		end
 	elseif i==4,
 		plotmodel(md,'data',vy,'ylim',[-50 200],'layer',md.mesh.numberoflayers,'sectionvalue','../Exp/ISMIPE.exp','resolution',[10 10],'title','','xlabel','')
-		if printingflag, 
+		if printingflag,
 			set(gcf,'Color','w')
 			printmodel('ismipestokesvxsliding','png','margin','on','marginsize',25,'frame','off','resolution',1.5,'hardcopy','off');
-			system(['mv ismipestokesvxsliding.png ' ISSM_DIR '/website/doc_pdf/validation/Images/ISMIP/TestE ']);
+			system(['mv ismipestokesvxsliding.png ' ISSM_DIR '/website/doc_pdf/validation/Images/ISMIP/TestE']);
 		end
 	end
 end
+
 %Fields and tolerances to track changes
-field_names     ={ ...
+field_names     ={...
 	'VyPattynSliding','VzPattynSliding',...
 	'VxStokesSliding','VyStokesSliding','VzStokesSliding',...
Index: /issm/trunk/test/NightlyRun/test1110.m
===================================================================
--- /issm/trunk/test/NightlyRun/test1110.m	(revision 14309)
+++ /issm/trunk/test/NightlyRun/test1110.m	(revision 14310)
@@ -1,13 +1,14 @@
-%This test is a test from the ISMP-HOM Intercomparison project
+%This test is a test from the ISMP-HOM Intercomparison project.
 %TestF 
 printingflag=false;
+results={};
 
 for i=1:4,
-	L=100000; %in m
+	L=100000.; %in m
 	nx=30; %numberof nodes in x direction
 	ny=30;
 	md=model();
 	md=squaremesh(md,L,L,nx,ny);
-	%md=triangle(md,'../Exp/SquareISMIP.exp',5500.);
+%	md=triangle(md,'../Exp/SquareISMIP.exp',5500.);
 	md=setmask(md,'',''); %ice sheet test
 	md=parameterize(md,'../Par/ISMIPF.par');
@@ -26,21 +27,21 @@
 		%Create dirichlet on the bed if no slip
 		pos=find(md.mesh.vertexonbed);
-		md.diagnostic.spcvx(pos)=0;
-		md.diagnostic.spcvy(pos)=0;
-		md.diagnostic.spcvz(pos)=0;
+		md.diagnostic.spcvx(pos)=0.;
+		md.diagnostic.spcvy(pos)=0.;
+		md.diagnostic.spcvz(pos)=0.;
 	else
-		pos=find(md.mesh.vertexonbed & (md.mesh.x==0 | md.mesh.x==max(md.mesh.x)) & (md.mesh.y==0 | md.mesh.y==max(md.mesh.y)));
-		md.diagnostic.spcvx(pos)=100; %because we need a dirichlet somewhere
-		md.diagnostic.spcvy(pos)=0;
-		md.diagnostic.spcvz(pos)=0;
+		pos=find(md.mesh.vertexonbed & (md.mesh.x==0. | md.mesh.x==max(md.mesh.x)) & (md.mesh.y==0. | md.mesh.y==max(md.mesh.y)));
+		md.diagnostic.spcvx(pos)=100.; %because we need a dirichlet somewhere
+		md.diagnostic.spcvy(pos)=0.;
+		md.diagnostic.spcvz(pos)=0.;
 	end
 	pos=find(~md.mesh.vertexonbed);
-	md.thermal.spctemperature(pos)=255;
+	md.thermal.spctemperature(pos)=255.;
 
 	%Create MPCs to have periodic boundary conditions
-	posx=find(md.mesh.x==0);
+	posx=find(md.mesh.x==0.);
 	posx2=find(md.mesh.x==max(md.mesh.x));
 
-	posy=find(md.mesh.y==0);
+	posy=find(md.mesh.y==0.);
 	posy2=find(md.mesh.y==max(md.mesh.y));
 
@@ -48,6 +49,6 @@
 	md.prognostic.vertex_pairing=[posx,posx2;posy,posy2];
 
-	md.timestepping.time_step=3;
-	md.timestepping.final_time=300;
+	md.timestepping.time_step=3.;
+	md.timestepping.final_time=300.;
 	md.settings.output_frequency=50;
 	md.prognostic.stabilization=1;
@@ -68,36 +69,36 @@
 		plotmodel(md,'data',(md.results.TransientSolution(end).Vx),'layer',md.mesh.numberoflayers,'sectionvalue','../Exp/ISMIP100000.exp','title','','xlabel','','ylabel','Velocity (m/yr)','linewidth',3,'grid','on','unit','km','ylim',[185 200])
 	end
-	if printingflag, 
+	if printingflag,
 		set(gcf,'Color','w')
 		if i==1,
 			printmodel('ismipfpattynvxfrozen','png','margin','on','marginsize',25,'frame','off','resolution',1.5,'hardcopy','off');
-			system(['mv ismipfpattynvxfrozen.png ' ISSM_DIR '/website/doc_pdf/validation/Images/ISMIP/TestF ']);
+			system(['mv ismipfpattynvxfrozen.png ' ISSM_DIR '/website/doc_pdf/validation/Images/ISMIP/TestF']);
 		elseif i==2,
 			printmodel('ismipfpattynvxsliding','png','margin','on','marginsize',25,'frame','off','resolution',1.5,'hardcopy','off');
-			system(['mv ismipfpattynvxsliding.png ' ISSM_DIR '/website/doc_pdf/validation/Images/ISMIP/TestF ']);
+			system(['mv ismipfpattynvxsliding.png ' ISSM_DIR '/website/doc_pdf/validation/Images/ISMIP/TestF']);
 		elseif i==3,
 			printmodel('ismipfstokesvxfrozen','png','margin','on','marginsize',25,'frame','off','resolution',1.5,'hardcopy','off');
-			system(['mv ismipfstokesvxfrozen.png ' ISSM_DIR '/website/doc_pdf/validation/Images/ISMIP/TestF ']);
+			system(['mv ismipfstokesvxfrozen.png ' ISSM_DIR '/website/doc_pdf/validation/Images/ISMIP/TestF']);
 		elseif i==4,
 			printmodel('ismipfstokesvxsliding','png','margin','on','marginsize',25,'frame','off','resolution',1.5,'hardcopy','off');
-			system(['mv ismipfstokesvxsliding.png ' ISSM_DIR '/website/doc_pdf/validation/Images/ISMIP/TestF ']);
+			system(['mv ismipfstokesvxsliding.png ' ISSM_DIR '/website/doc_pdf/validation/Images/ISMIP/TestF']);
 		end
 	end
 
 	plotmodel(md,'data',(md.results.TransientSolution(end).Surface)-md.geometry.surface,'layer',md.mesh.numberoflayers,'sectionvalue','../Exp/ISMIP100000.exp','title','','xlabel','','ylabel','Surface (m)','linewidth',3,'grid','on','unit','km','ylim',[-30 50])
-	if printingflag, 
+	if printingflag,
 		set(gcf,'Color','w')
 		if i==1,
 			printmodel('ismipfpattyndeltasurfacefrozen','png','margin','on','marginsize',25,'frame','off','resolution',1.5,'hardcopy','off');
-			system(['mv ismipfpattyndeltasurfacefrozen.png ' ISSM_DIR '/website/doc_pdf/validation/Images/ISMIP/TestF ']);
+			system(['mv ismipfpattyndeltasurfacefrozen.png ' ISSM_DIR '/website/doc_pdf/validation/Images/ISMIP/TestF']);
 		elseif i==2,
 			printmodel('ismipfpattyndeltasurfacesliding','png','margin','on','marginsize',25,'frame','off','resolution',1.5,'hardcopy','off');
-			system(['mv ismipfpattyndeltasurfacesliding.png ' ISSM_DIR '/website/doc_pdf/validation/Images/ISMIP/TestF ']);
+			system(['mv ismipfpattyndeltasurfacesliding.png ' ISSM_DIR '/website/doc_pdf/validation/Images/ISMIP/TestF']);
 		elseif i==3,
 			printmodel('ismipfstokesdeltasurfacefrozen','png','margin','on','marginsize',25,'frame','off','resolution',1.5,'hardcopy','off');
-			system(['mv ismipfstokesdeltasurfacefrozen.png ' ISSM_DIR '/website/doc_pdf/validation/Images/ISMIP/TestF ']);
+			system(['mv ismipfstokesdeltasurfacefrozen.png ' ISSM_DIR '/website/doc_pdf/validation/Images/ISMIP/TestF']);
 		elseif i==4,
 			printmodel('ismipfstokesdeltasurfacesliding','png','margin','on','marginsize',25,'frame','off','resolution',1.5,'hardcopy','off');
-			system(['mv ismipfstokesdeltasurfacesliding.png ' ISSM_DIR '/website/doc_pdf/validation/Images/ISMIP/TestF ']);
+			system(['mv ismipfstokesdeltasurfacesliding.png ' ISSM_DIR '/website/doc_pdf/validation/Images/ISMIP/TestF']);
 		end
 	end
@@ -105,5 +106,5 @@
 
 %Fields and tolerances to track changes
-field_names     ={ ...
+field_names     ={...
 	'VxPattynFrozen','VyPattynFrozen','VzPattynFrozen','SurfacePattynFrozen',...
 	'VxPattynSliding','VyPattynSliding','VzPattynSliding','SurfacePattynSliding',...
Index: /issm/trunk/test/NightlyRun/test1201.m
===================================================================
--- /issm/trunk/test/NightlyRun/test1201.m	(revision 14309)
+++ /issm/trunk/test/NightlyRun/test1201.m	(revision 14310)
@@ -1,3 +1,3 @@
-%This test is a test from the EISMINT for Ice shelves Vincent Rommelaere 1996
+%This test is a test from the EISMINT for Ice shelves Vincent Rommelaere 1996.
 printingflag=false;
 
@@ -6,8 +6,8 @@
 for stabilization=1:3;
 	%The goal is to test the prognostic model
-	md=bamg(model(),'domain','../Exp/SquareEISMINT.exp','hmax',3000);
+	md=bamg(model(),'domain','../Exp/SquareEISMINT.exp','hmax',3000.);
 	md=setmask(md,'all','');
 	md=parameterize(md,'../Par/SquareEISMINT.par');
-	md.surfaceforcings.mass_balance(:)=0;
+	md.surfaceforcings.mass_balance(:)=0.;
 	md=setflowequation(md,'macayeal','all');
 	md.cluster=generic('name',oshostname(),'np',8);
@@ -15,5 +15,5 @@
 	disp('      initial velocity');
 	md.initialization.vx=zeros(md.mesh.numberofvertices,1);
-	md.initialization.vy=-400*ones(md.mesh.numberofvertices,1);
+	md.initialization.vy=-400.*ones(md.mesh.numberofvertices,1);
 
 	%Stabilization
@@ -29,7 +29,7 @@
 	md.prognostic.spcthickness=NaN*ones(md.mesh.numberofvertices+1,length(times));
 	md.prognostic.spcthickness(end,:)=times;
-	md.prognostic.spcthickness(pos,:)=repmat(500+100*sin(2*pi*times/200),length(pos),1);
+	md.prognostic.spcthickness(pos,:)=repmat(500.+100.*sin(2.*pi*times/200.),length(pos),1);
 	if stabilization==3,
-		pos=find(isnan(md.prognostic.spcthickness)); md.prognostic.spcthickness(pos)=500; %No NaN for DG
+		pos=find(isnan(md.prognostic.spcthickness)); md.prognostic.spcthickness(pos)=500.; %No NaN for DG
 	end
 
@@ -43,11 +43,11 @@
 
 %plot results
-[elements,x,y,z,s,h1]=SectionValues(md,results{1},'../Exp/CrossLineEISMINT.exp',100);
-[elements,x,y,z,s,h2]=SectionValues(md,results{2},'../Exp/CrossLineEISMINT.exp',100);
-[elements,x,y,z,s,h3]=SectionValues(md,results{3},'../Exp/CrossLineEISMINT.exp',100);
-[elements,x,y,z,s,hth]=SectionValues(md, 500+100*sin(2*pi/200*(500-md.mesh.y/400)),'../Exp/CrossLineEISMINT.exp',100);
+[elements,x,y,z,s,h1]=SectionValues(md,results{1},'../Exp/CrossLineEISMINT.exp',100.);
+[elements,x,y,z,s,h2]=SectionValues(md,results{2},'../Exp/CrossLineEISMINT.exp',100.);
+[elements,x,y,z,s,h3]=SectionValues(md,results{3},'../Exp/CrossLineEISMINT.exp',100.);
+[elements,x,y,z,s,hth]=SectionValues(md, 500+100*sin(2*pi/200*(500-md.mesh.y/400)),'../Exp/CrossLineEISMINT.exp',100.);
 plot(s,h1,'r',s,h2,'b',s,h3,'g',s,hth,'k')
 legend('Art. diff.','No Art. diff.','D.G.','Theoretical')
-if printingflag, 
+if printingflag,
 	set(gcf,'Color','w')
 	export_fig([issmdir() '/website/doc_pdf/validation/Images/EISMINT/IceShelf/eismintmasscthickness.pdf']);
@@ -56,5 +56,5 @@
 %Fields and tolerances to track changes
 field_names     ={ ...
-	'ThicknessArtDigg','ThicknessNoArtDiff','ThicknessDG' ...
+	'ThicknessArtDiff','ThicknessNoArtDiff','ThicknessDG' ...
 };
 field_tolerances={...
Index: /issm/trunk/test/NightlyRun/test1201.py
===================================================================
--- /issm/trunk/test/NightlyRun/test1201.py	(revision 14310)
+++ /issm/trunk/test/NightlyRun/test1201.py	(revision 14310)
@@ -0,0 +1,78 @@
+import numpy
+from model import *
+from bamg import *
+from setmask import *
+from parameterize import *
+from setflowequation import *
+from EnumDefinitions import *
+from solve import *
+from MatlabFuncs import *
+
+"""
+This test is a test from the EISMINT for Ice shelves Vincent Rommelaere 1996.
+"""
+
+printingflag=False
+
+results=[]
+
+for stabilization in xrange(1,4):
+	#The goal is to test the prognostic model
+	md=bamg(model(),'domain','../Exp/SquareEISMINT.exp','hmax',3000.)
+	md=setmask(md,'all','')
+	md=parameterize(md,'../Par/SquareEISMINT.py')
+	md.surfaceforcings.mass_balance[:]=0.
+	md=setflowequation(md,'macayeal','all')
+	md.cluster=generic('name',oshostname(),'np',8)
+
+	print "      initial velocity"
+	md.initialization.vx=numpy.zeros((md.mesh.numberofvertices,1))
+	md.initialization.vy=-400.*numpy.ones((md.mesh.numberofvertices,1))
+
+	#Stabilization
+	if stabilization==2:
+		md.prognostic.stabilization=0
+	else:
+		md.prognostic.stabilization=stabilization
+
+	#spc thickness
+	pos=numpy.nonzero(md.mesh.y>199999.9)[0]
+	times=numpy.arange(0,501)
+	md.prognostic.spcthickness=float('NaN')*numpy.ones((md.mesh.numberofvertices+1,numpy.size(times)))
+	md.prognostic.spcthickness[-1,:]=times
+	md.prognostic.spcthickness[pos,:]=numpy.tile(500.+100.*numpy.sin(2.*numpy.pi*times/200.),(numpy.size(pos),1))
+	if stabilization==3:
+		pos=numpy.nonzero(numpy.isnan(md.prognostic.spcthickness))
+		md.prognostic.spcthickness[pos]=500.    #No NaN for DG
+
+	#solve
+	md.transient.isdiagnostic=False
+	md.settings.output_frequency=500    #keep only last step
+	md.verbose=verbose()
+	md=solve(md,TransientSolutionEnum())
+	results.append(md.results.TransientSolution[-1].Thickness)
+
+#plot results
+#[elements,x,y,z,s,h1]=SectionValues(md,results[0],'../Exp/CrossLineEISMINT.exp',100.);
+#[elements,x,y,z,s,h2]=SectionValues(md,results[1],'../Exp/CrossLineEISMINT.exp',100.);
+#[elements,x,y,z,s,h3]=SectionValues(md,results[2],'../Exp/CrossLineEISMINT.exp',100.);
+#[elements,x,y,z,s,hth]=SectionValues(md, 500+100*sin(2*pi/200*(500-md.mesh.y/400)),'../Exp/CrossLineEISMINT.exp',100.);
+#plot(s,h1,'r',s,h2,'b',s,h3,'g',s,hth,'k')
+#legend('Art. diff.','No Art. diff.','D.G.','Theoretical')
+if printingflag:
+	pass
+#	set(gcf,'Color','w')
+#	export_fig([issmdir() '/website/doc_pdf/validation/Images/EISMINT/IceShelf/eismintmasscthickness.pdf']);
+
+#Fields and tolerances to track changes
+field_names     =[ \
+	'ThicknessArtDiff','ThicknessNoArtDiff','ThicknessDG' \
+]
+field_tolerances=[\
+	1e-13, 1e-13, 1e-13\
+]
+field_values=[
+	results[0], \
+	results[1], \
+	results[2], \
+]
Index: /issm/trunk/test/NightlyRun/test1202.m
===================================================================
--- /issm/trunk/test/NightlyRun/test1202.m	(revision 14309)
+++ /issm/trunk/test/NightlyRun/test1202.m	(revision 14310)
@@ -1,3 +1,3 @@
-%Test on the diagnostic model and the prognostic in 2d
+%Test on the diagnostic model and the prognostic in 2d.
 printingflag=false;
 
@@ -19,5 +19,5 @@
 plotmodel(md,'data',vx,'contourlevels',{0,20,40,60,60,100,120,140,160,180,-20,-40,-60,-80,-100,-120,-140,-160,-180}, ...
 	'contourcolor','k')
-if printingflag, 
+if printingflag,
 	set(gcf,'Color','w')
 	printmodel('eismintdiag1vx','png','margin','on','marginsize',25,'frame','off','resolution',2,'hardcopy','off');
@@ -27,5 +27,5 @@
 plotmodel(md,'data',vy,'contourlevels',{-100,-200,-300,-400,-500,-600,-700,-800,-900,-1000},...
 	'contourcolor','k')
-if printingflag, 
+if printingflag,
 	set(gcf,'Color','w')
 	printmodel('eismintdiag1vy','png','margin','on','marginsize',25,'frame','off','resolution',2,'hardcopy','off');
Index: /issm/trunk/test/NightlyRun/test1202.py
===================================================================
--- /issm/trunk/test/NightlyRun/test1202.py	(revision 14310)
+++ /issm/trunk/test/NightlyRun/test1202.py	(revision 14310)
@@ -0,0 +1,54 @@
+import numpy
+from model import *
+from triangle import *
+from setmask import *
+from parameterize import *
+from setflowequation import *
+from EnumDefinitions import *
+from solve import *
+from MatlabFuncs import *
+
+"""
+Test on the diagnostic model and the prognostic in 2d
+"""
+
+printingflag=False
+
+#tests 3 and 4: using Glen's flow law
+md=model()
+md=triangle(md,'../Exp/SquareEISMINT.exp',3550.)
+md=setmask(md,'all','')
+md=parameterize(md,'../Par/SquareEISMINT.py')
+md=setflowequation(md,'macayeal','all')    #MacAyeal's model and 2d
+
+#Compute solution for MacAyeal's model 
+md.cluster=generic('name',oshostname(),'np',8)
+md=solve(md,DiagnosticSolutionEnum())
+
+#plot results
+vx=md.results.DiagnosticSolution.Vx
+vy=md.results.DiagnosticSolution.Vy
+
+#plotmodel(md,'data',vx,'contourlevels',{0,20,40,60,60,100,120,140,160,180,-20,-40,-60,-80,-100,-120,-140,-160,-180}, ...
+#	'contourcolor','k')
+if printingflag:
+	pass
+#	set(gcf,'Color','w')
+#	printmodel('eismintdiag1vx','png','margin','on','marginsize',25,'frame','off','resolution',2,'hardcopy','off');
+#	system(['mv eismintdiag1vx.png ' ISSM_DIR '/website/doc_pdf/validation/Images/EISMINT/IceShelf ']);
+
+#plotmodel(md,'data',vy,'contourlevels',{-100,-200,-300,-400,-500,-600,-700,-800,-900,-1000},...
+#	'contourcolor','k')
+if printingflag:
+	pass
+#	set(gcf,'Color','w')
+#	printmodel('eismintdiag1vy','png','margin','on','marginsize',25,'frame','off','resolution',2,'hardcopy','off');
+#	system(['mv eismintdiag1vy.png ' ISSM_DIR '/website/doc_pdf/validation/Images/EISMINT/IceShelf ']);
+
+#Fields and tolerances to track changes
+field_names     =['Vx','Vy']
+field_tolerances=[1e-13,1e-13]
+field_values=[\
+	vx, \
+	vy, \
+	]
Index: /issm/trunk/test/NightlyRun/test1203.m
===================================================================
--- /issm/trunk/test/NightlyRun/test1203.m	(revision 14309)
+++ /issm/trunk/test/NightlyRun/test1203.m	(revision 14310)
@@ -2,5 +2,5 @@
 printingflag=false;
 
-%test 5 and 6 : 
+%test 5 and 6: 
 md=model();
 md=triangle(md,'../Exp/SquareEISMINT.exp',5100.); %test3
@@ -11,5 +11,5 @@
 %Impose a non zero velocity on the upper boundary condition (y=max(y))
 pos=find(md.mesh.y==max(md.mesh.y));
-md.diagnostic.spcvy(pos)=400*(((md.mesh.x(pos)-100000)/25000).^2-ones(size(pos,1),1)).*heaviside((1+eps)*ones(size(pos,1),1)-((md.mesh.x(pos)-100000)/25000).^2);
+md.diagnostic.spcvy(pos)=400.*(((md.mesh.x(pos)-100000.)/25000.).^2-ones(size(pos,1),1)).*heaviside((1.+eps)*ones(size(pos,1),1)-((md.mesh.x(pos)-100000.)/25000.).^2);
 
 %Compute solution for MacAyeal's model 
@@ -23,5 +23,5 @@
 plotmodel(md,'data',vx,'contourlevels',{0,20,40,60,80,100,-20,-40,-60,-80,-100},...
 	'contourcolor','k')
-if printingflag, 
+if printingflag,
 	set(gcf,'Color','w')
 	printmodel('eismintdiag2vx','png','margin','on','marginsize',25,'frame','off','resolution',2,'hardcopy','off');
@@ -30,5 +30,5 @@
 plotmodel(md,'data',vy,'contourlevels',{-100,-200,-300,-400,-500,-600,-700,-800,-900,-1000},...
 	'contourcolor','k')
-if printingflag, 
+if printingflag,
 	set(gcf,'Color','w')
 	printmodel('eismintdiag2vy','png','margin','on','marginsize',25,'frame','off','resolution',2,'hardcopy','off');
Index: /issm/trunk/test/NightlyRun/test1203.py
===================================================================
--- /issm/trunk/test/NightlyRun/test1203.py	(revision 14310)
+++ /issm/trunk/test/NightlyRun/test1203.py	(revision 14310)
@@ -0,0 +1,58 @@
+import numpy
+import sys
+from model import *
+from triangle import *
+from setmask import *
+from parameterize import *
+from setflowequation import *
+from EnumDefinitions import *
+from solve import *
+from MatlabFuncs import *
+
+"""
+Test on the diagnostic model and the prognostic in 2d
+"""
+
+printingflag=False
+
+#test 5 and 6: 
+md=model()
+md=triangle(md,'../Exp/SquareEISMINT.exp',5100.)    #test3
+md=setmask(md,'all','')
+md=parameterize(md,'../Par/SquareEISMINT.py')
+md=setflowequation(md,'macayeal','all')    #MacAyeal's model and 2d
+
+#Impose a non zero velocity on the upper boundary condition (y=max(y))
+pos=numpy.nonzero(md.mesh.y==numpy.max(md.mesh.y))
+md.diagnostic.spcvy[pos]=400.*(((md.mesh.x[pos].reshape(-1,1)-100000.)/25000.)**2-numpy.ones((numpy.size(pos),1)))*heaviside((1.+sys.float_info.epsilon)*numpy.ones((numpy.size(pos),1))-((md.mesh.x[pos].reshape(-1,1)-100000.)/25000.)**2)
+
+#Compute solution for MacAyeal's model 
+md.cluster=generic('name',oshostname(),'np',8)
+md=solve(md,DiagnosticSolutionEnum())
+
+vx=md.results.DiagnosticSolution.Vx
+vy=md.results.DiagnosticSolution.Vy
+
+#plot results
+#plotmodel(md,'data',vx,'contourlevels',{0,20,40,60,80,100,-20,-40,-60,-80,-100},...
+#	'contourcolor','k')
+if printingflag:
+	pass
+#	set(gcf,'Color','w')
+#	printmodel('eismintdiag2vx','png','margin','on','marginsize',25,'frame','off','resolution',2,'hardcopy','off');
+#	system(['mv eismintdiag2vx.png ' ISSM_DIR '/website/doc_pdf/validation/Images/EISMINT/IceShelf ']);
+#plotmodel(md,'data',vy,'contourlevels',{-100,-200,-300,-400,-500,-600,-700,-800,-900,-1000},...
+#	'contourcolor','k')
+if printingflag:
+	pass
+#	set(gcf,'Color','w')
+#	printmodel('eismintdiag2vy','png','margin','on','marginsize',25,'frame','off','resolution',2,'hardcopy','off');
+#	system(['mv eismintdiag2vy.png ' ISSM_DIR '/website/doc_pdf/validation/Images/EISMINT/IceShelf ']);
+
+#Fields and tolerances to track changes
+field_names     =['Vx','Vy']
+field_tolerances=[1e-13,1e-13]
+field_values=[\
+	vx, \
+	vy, \
+	]
Index: /issm/trunk/test/NightlyRun/test1204.m
===================================================================
--- /issm/trunk/test/NightlyRun/test1204.m	(revision 14309)
+++ /issm/trunk/test/NightlyRun/test1204.m	(revision 14310)
@@ -11,5 +11,5 @@
 %Impose a non zero velocity on the upper boundary condition (y=max(y))
 pos=find(md.mesh.y==max(md.mesh.y));
-md.diagnostic.spcvy(pos)=400*(((md.mesh.x(pos)-100000)/25000).^2-ones(size(pos,1),1)).*heaviside((1+eps)*ones(size(pos,1),1)-((md.mesh.x(pos)-100000)/25000).^2);
+md.diagnostic.spcvy(pos)=400.*(((md.mesh.x(pos)-100000.)/25000.).^2-ones(size(pos,1),1)).*heaviside((1.+eps)*ones(size(pos,1),1)-((md.mesh.x(pos)-100000.)/25000.).^2);
 
 %Compute solution for MacAyeal's model 
@@ -21,11 +21,11 @@
 md.initialization.vy=(md.results.DiagnosticSolution.Vy);
 
-md.timestepping.time_step=1;
-md.timestepping.final_time=5000;
+md.timestepping.time_step=1.;
+md.timestepping.final_time=5000.;
 md.prognostic.stabilization=1;
 md=solve(md,TransientSolutionEnum());
 
 plotmodel(md,'data',(md.results.TransientSolution(end).Vx))
-if printingflag, 
+if printingflag,
 	set(gcf,'Color','w')
 	printmodel('eisminttrans2vx','png','margin','on','marginsize',25,'frame','off','resolution',2,'hardcopy','off');
@@ -34,5 +34,5 @@
 
 plotmodel(md,'data',(md.results.TransientSolution(end).Vy))
-if printingflag, 
+if printingflag,
 	set(gcf,'Color','w')
 	printmodel('eisminttrans2vy','png','margin','on','marginsize',25,'frame','off','resolution',2,'hardcopy','off');
@@ -41,5 +41,5 @@
 
 plotmodel(md,'data',(md.results.TransientSolution(end).Thickness))
-if printingflag, 
+if printingflag,
 	set(gcf,'Color','w')
 	printmodel('eisminttrans2thickness','png','margin','on','marginsize',25,'frame','off','resolution',2,'hardcopy','off');
Index: /issm/trunk/test/NightlyRun/test1204.py
===================================================================
--- /issm/trunk/test/NightlyRun/test1204.py	(revision 14310)
+++ /issm/trunk/test/NightlyRun/test1204.py	(revision 14310)
@@ -0,0 +1,70 @@
+import numpy
+import sys
+from model import *
+from triangle import *
+from setmask import *
+from parameterize import *
+from setflowequation import *
+from EnumDefinitions import *
+from solve import *
+from MatlabFuncs import *
+
+"""
+Test on the diagnostic model and the prognostic in 2d
+"""
+
+printingflag=False
+
+#tests 3 and 4: using Glen's flow law
+md=model()
+md=triangle(md,'../Exp/SquareEISMINT.exp',3550.)
+md=setmask(md,'all','')
+md=parameterize(md,'../Par/SquareEISMINT.py')
+md=setflowequation(md,'macayeal','all')    #MacAyeal's model and 2d
+
+#Impose a non zero velocity on the upper boundary condition (y=max(y))
+pos=numpy.nonzero(md.mesh.y==max(md.mesh.y))
+md.diagnostic.spcvy[pos]=400.*(((md.mesh.x[pos].reshape(-1,1)-100000.)/25000.)**2-numpy.ones((numpy.size(pos),1)))*heaviside((1.+sys.float_info.epsilon)*numpy.ones((numpy.size(pos),1))-((md.mesh.x[pos].reshape(-1,1)-100000.)/25000.)**2)
+
+#Compute solution for MacAyeal's model 
+md.cluster=generic('name',oshostname(),'np',8)
+md=solve(md,DiagnosticSolutionEnum())
+
+#plot results
+md.initialization.vx=md.results.DiagnosticSolution.Vx
+md.initialization.vy=md.results.DiagnosticSolution.Vy
+
+md.timestepping.time_step=1.
+md.timestepping.final_time=5000.
+md.prognostic.stabilization=1
+md=solve(md,TransientSolutionEnum())
+
+#plotmodel(md,'data',(md.results.TransientSolution(end).Vx))
+if printingflag:
+	pass
+#	set(gcf,'Color','w')
+#	printmodel('eisminttrans2vx','png','margin','on','marginsize',25,'frame','off','resolution',2,'hardcopy','off');
+#	system(['mv eisminttrans2vx.png ' ISSM_DIR '/website/doc_pdf/validation/Images/EISMINT/IceShelf ']);
+
+#plotmodel(md,'data',(md.results.TransientSolution(end).Vy))
+if printingflag:
+	pass
+#	set(gcf,'Color','w')
+#	printmodel('eisminttrans2vy','png','margin','on','marginsize',25,'frame','off','resolution',2,'hardcopy','off');
+#	system(['mv eisminttrans2vy.png ' ISSM_DIR '/website/doc_pdf/validation/Images/EISMINT/IceShelf ']);
+
+#plotmodel(md,'data',(md.results.TransientSolution(end).Thickness))
+if printingflag:
+	pass
+#	set(gcf,'Color','w')
+#	printmodel('eisminttrans2thickness','png','margin','on','marginsize',25,'frame','off','resolution',2,'hardcopy','off');
+#	system(['mv eisminttrans2thickness.png ' ISSM_DIR '/website/doc_pdf/validation/Images/EISMINT/IceShelf ']);
+
+#Fields and tolerances to track changes
+field_names     =['Vx','Vy','Thickness']
+field_tolerances=[1e-13,1e-13,1e-13]
+field_values=[\
+	md.results.TransientSolution[-1].Vx, \
+	md.results.TransientSolution[-1].Vy, \
+	md.results.TransientSolution[-1].Thickness, \
+	]
Index: /issm/trunk/test/NightlyRun/test1205.m
===================================================================
--- /issm/trunk/test/NightlyRun/test1205.m	(revision 14309)
+++ /issm/trunk/test/NightlyRun/test1205.m	(revision 14310)
@@ -1,11 +1,11 @@
-%The aim of this program is to compare a model with an analytical solution given in MacAyeal EISMINT : Lessons in Ice-Sheet Modeling
+%The aim of this program is to compare a model with an analytical solution given in MacAyeal EISMINT : Lessons in Ice-Sheet Modeling.
 printingflag=false;
 
 numlayers=10;
-resolution=30000;
+resolution=30000.;
 
 %To begin with the numerical model
 md=model();
-md=roundmesh(md,750000,resolution);
+md=roundmesh(md,750000.,resolution);
 md=setmask(md,'',''); %We can not test iceshelves nor ice rises with this analytical solution
 md=parameterize(md,'../Par/RoundSheetStaticEISMINT.par');
@@ -13,7 +13,7 @@
 %Calculation of the analytical 2d velocity field
 constant=0.3;
-vx_obs=constant/2*md.mesh.x.*(md.geometry.thickness).^-1;
-vy_obs=constant/2*md.mesh.y.*(md.geometry.thickness).^-1;
-vel_obs=(sqrt((md.inversion.vx_obs).^2+(md.inversion.vy_obs).^2));
+vx_obs=constant/2.*md.mesh.x.*(md.geometry.thickness).^-1;
+vy_obs=constant/2.*md.mesh.y.*(md.geometry.thickness).^-1;
+vel_obs=sqrt((md.inversion.vx_obs).^2+(md.inversion.vy_obs).^2);
 
 %We extrude the model to have a 3d model
@@ -23,7 +23,7 @@
 %Spc the nodes on the bed
 pos=find(md.mesh.vertexonbed);
-md.diagnostic.spcvx(pos)=0;
-md.diagnostic.spcvy(pos)=0;
-md.diagnostic.spcvz(pos)=0;
+md.diagnostic.spcvx(pos)=0.;
+md.diagnostic.spcvy(pos)=0.;
+md.diagnostic.spcvz(pos)=0.;
 
 %Now we can solve the problem 
@@ -36,13 +36,12 @@
 vel=zeros(md.mesh.numberofvertices2d,1);
 
-node_vel=0;
 for i=1:md.mesh.numberofvertices2d
-	for j=1:(md.mesh.numberoflayers-1)
-		node_vel=node_vel+1/(2*(md.mesh.numberoflayers-1))*(sqrt(vx(i+j*md.mesh.numberofvertices2d,1).^2+...
-			vy(i+j*md.mesh.numberofvertices2d,1).^2)+...
+	node_vel=0.;
+	for j=1:md.mesh.numberoflayers-1
+		node_vel=node_vel+1./(2.*(md.mesh.numberoflayers-1))*...
+			(sqrt(vx(i+j*md.mesh.numberofvertices2d,1).^2+vy(i+j*md.mesh.numberofvertices2d,1).^2)+...
 			sqrt(vx(i+(j-1)*md.mesh.numberofvertices2d,1).^2+vy(i+(j-1)*md.mesh.numberofvertices2d,1).^2));
 	end
 	vel(i,1)=node_vel;
-	node_vel=0;
 end
 
@@ -82,5 +81,5 @@
 caxis([0 100]);
 
-if printingflag, 
+if printingflag,
 	set(gcf,'Color','w')
 	printmodel('hutterstatic','png','margin','on','marginsize',25,'frame','off','resolution',0.7,'hardcopy','off');
@@ -92,8 +91,8 @@
 	'Vx','Vy','Vel', ...
 };
-field_tolerances={...
+field_tolerances={ ...
 	1e-13,1e-13,1e-13, ...
 };
-field_values={
+field_values={ ...
 	vx,vy,vel, ...
 };
Index: /issm/trunk/test/NightlyRun/test1205.py
===================================================================
--- /issm/trunk/test/NightlyRun/test1205.py	(revision 14310)
+++ /issm/trunk/test/NightlyRun/test1205.py	(revision 14310)
@@ -0,0 +1,109 @@
+import numpy
+from model import *
+from roundmesh import *
+from setmask import *
+from parameterize import *
+from setflowequation import *
+from EnumDefinitions import *
+from solve import *
+from MatlabFuncs import *
+
+"""
+The aim of this program is to compare a model with an analytical solution given in MacAyeal EISMINT : Lessons in Ice-Sheet Modeling.
+"""
+
+printingflag=False
+
+numlayers=10
+resolution=30000.
+
+#To begin with the numerical model
+md=model()
+md=roundmesh(md,750000.,resolution)
+md=setmask(md,'','')    #We can not test iceshelves nor ice rises with this analytical solution
+md=parameterize(md,'../Par/RoundSheetStaticEISMINT.py')
+
+#Calculation of the analytical 2d velocity field
+constant=0.3
+vx_obs=constant/2.*md.mesh.x*(md.geometry.thickness)**-1
+vy_obs=constant/2.*md.mesh.y*(md.geometry.thickness)**-1
+vel_obs=numpy.sqrt((md.inversion.vx_obs)**2+(md.inversion.vy_obs)**2)
+
+#We extrude the model to have a 3d model
+md.extrude(numlayers,1.);
+md=setflowequation(md,'hutter','all')
+
+#Spc the nodes on the bed
+pos=numpy.nonzero(md.mesh.vertexonbed)
+md.diagnostic.spcvx[pos]=0.
+md.diagnostic.spcvy[pos]=0.
+md.diagnostic.spcvz[pos]=0.
+
+#Now we can solve the problem 
+md.cluster=generic('name',oshostname(),'np',8)
+md=solve(md,DiagnosticSolutionEnum())
+
+#Calculate the depth averaged velocity field (2d):
+vx=md.results.DiagnosticSolution.Vx
+vy=md.results.DiagnosticSolution.Vy
+vel=numpy.zeros((md.mesh.numberofvertices2d,1))
+
+for i in xrange(0,md.mesh.numberofvertices2d):
+	node_vel=0.
+	for j in xrange(0,md.mesh.numberoflayers-1):
+		node_vel=node_vel+1./(2.*(md.mesh.numberoflayers-1))*\
+			(numpy.sqrt(vx[i+(j+1)*md.mesh.numberofvertices2d,0]**2+vy[i+(j+1)*md.mesh.numberofvertices2d,0]**2)+\
+			numpy.sqrt(vx[i+j*md.mesh.numberofvertices2d,0]**2+vy[i+j*md.mesh.numberofvertices2d,0]**2))
+	vel[i,0]=node_vel
+
+#Plot of the velocity from the exact and calculated solutions
+#figure(1)
+#set(gcf,'Position',[1 1 1580 1150])
+#subplot(2,2,1)
+#p=patch('Faces',md.mesh.elements2d,'Vertices',[md.mesh.x2d md.mesh.y2d],'FaceVertexCData',...
+#vel,'FaceColor','interp','EdgeColor','none');
+#title('Modelled velocity','FontSize',14,'FontWeight','bold')
+#colorbar; 
+#caxis([0 200]);
+   
+#subplot(2,2,2)
+#p=patch('Faces',md.mesh.elements2d,'Vertices',[md.mesh.x2d md.mesh.y2d],'FaceVertexCData',...
+#vel_obs,'FaceColor','interp','EdgeColor','none');
+#title('Analytical velocity','FontSize',14,'FontWeight','bold')
+#colorbar; 
+#caxis([0 200]);
+
+#subplot(2,2,3)
+#hold on;
+#plot(sqrt((md.mesh.x(1:md.mesh.numberofvertices2d)).^2+(md.mesh.y(1:md.mesh.numberofvertices2d)).^2),vel,'r.');
+#plot(sqrt((md.mesh.x2d).^2+(md.mesh.y2d).^2),vel_obs,'b.');
+#title('Analytical vs calculated velocity','FontSize',14,'FontWeight','bold');
+#xlabel('distance to the center of the icesheet [m]','FontSize',14,'FontWeight','bold');
+#ylabel('velocity [m/yr]','FontSize',14,'FontWeight','bold');
+#legend('calculated velocity','exact velocity');
+#axis([0 750000 0 200]);
+#hold off;
+
+#subplot(2,2,4)
+#p=patch('Faces',md.mesh.elements2d,'Vertices',[md.mesh.x2d md.mesh.y2d],'FaceVertexCData',...
+#abs(vel-vel_obs)./vel_obs*100,'FaceColor','interp','EdgeColor','none');
+#title('Relative misfit [%]','FontSize',14,'FontWeight','bold')
+#colorbar;
+#caxis([0 100]);
+
+if printingflag:
+	pass
+#	set(gcf,'Color','w')
+#	printmodel('hutterstatic','png','margin','on','marginsize',25,'frame','off','resolution',0.7,'hardcopy','off');
+#	system(['mv hutterstatic.png ' ISSM_DIR '/website/doc_pdf/validation/Images/EISMINT/IceSheet']);
+
+#Fields and tolerances to track changes
+field_names     =[ \
+	'Vx','Vy','Vel', \
+]
+field_tolerances=[ \
+	1e-13,1e-13,1e-13, \
+]
+field_values=[ \
+	vx,vy,vel, \
+]
Index: /issm/trunk/test/NightlyRun/test1206.m
===================================================================
--- /issm/trunk/test/NightlyRun/test1206.m	(revision 14309)
+++ /issm/trunk/test/NightlyRun/test1206.m	(revision 14310)
@@ -1,11 +1,11 @@
-%The aim of this program is to compare a model with an analytical solution given in MacAyeal EISMINT : Lessons in Ice-Sheet Modeling
+%The aim of this program is to compare a model with an analytical solution given in MacAyeal EISMINT : Lessons in Ice-Sheet Modeling.
 printingflag=false;
 
 numlayers=10;
-resolution=30000;
+resolution=30000.;
 
 %To begin with the numerical model
 md=model();
-md=roundmesh(md,750000,resolution);
+md=roundmesh(md,750000.,resolution);
 md=setmask(md,'',''); %We can not test iceshelves nor ice rises with this analytical solution
 md=parameterize(md,'../Par/RoundSheetStaticEISMINT.par');
@@ -13,7 +13,7 @@
 %Calculation of the analytical 2d velocity field
 constant=0.3;
-vx_obs=constant/2*md.mesh.x.*(md.geometry.thickness).^-1;
-vy_obs=constant/2*md.mesh.y.*(md.geometry.thickness).^-1;
-vel_obs=(sqrt((md.inversion.vx_obs).^2+(md.inversion.vy_obs).^2));
+vx_obs=constant/2.*md.mesh.x.*(md.geometry.thickness).^-1;
+vy_obs=constant/2.*md.mesh.y.*(md.geometry.thickness).^-1;
+vel_obs=sqrt((md.inversion.vx_obs).^2+(md.inversion.vy_obs).^2);
 
 %We extrude the model to have a 3d model
@@ -23,7 +23,7 @@
 %Spc the nodes on the bed
 pos=find(md.mesh.vertexonbed);
-md.diagnostic.spcvx(pos)=0;
-md.diagnostic.spcvy(pos)=0;
-md.diagnostic.spcvz(pos)=0;
+md.diagnostic.spcvx(pos)=0.;
+md.diagnostic.spcvy(pos)=0.;
+md.diagnostic.spcvz(pos)=0.;
 
 %Now we can solve the problem 
@@ -36,13 +36,12 @@
 vel=zeros(md.mesh.numberofvertices2d,1);
 
-node_vel=0;
 for i=1:md.mesh.numberofvertices2d
-	for j=1:(md.mesh.numberoflayers-1)
-		node_vel=node_vel+1/(2*(md.mesh.numberoflayers-1))*(sqrt(vx(i+j*md.mesh.numberofvertices2d,1).^2+...
-			vy(i+j*md.mesh.numberofvertices2d,1).^2)+...
+	node_vel=0.;
+	for j=1:md.mesh.numberoflayers-1
+		node_vel=node_vel+1./(2.*(md.mesh.numberoflayers-1))*...
+			(sqrt(vx(i+j*md.mesh.numberofvertices2d,1).^2+vy(i+j*md.mesh.numberofvertices2d,1).^2)+...
 			sqrt(vx(i+(j-1)*md.mesh.numberofvertices2d,1).^2+vy(i+(j-1)*md.mesh.numberofvertices2d,1).^2));
 	end
 	vel(i,1)=node_vel;
-	node_vel=0;
 end
 
@@ -81,5 +80,5 @@
 caxis([0 100]);
 
-if printingflag, 
+if printingflag,
 	set(gcf,'Color','w')
 	printmodel('pattynstatic','png','margin','on','marginsize',25,'frame','off','resolution',0.7,'hardcopy','off');
@@ -91,8 +90,8 @@
 	'Vx','Vy','Vel', ...
 };
-field_tolerances={...
+field_tolerances={ ...
 	1e-12,1e-12,1e-12, ...
 };
-field_values={
+field_values={ ...
 	vx,vy,vel, ...
 };
Index: /issm/trunk/test/NightlyRun/test1206.py
===================================================================
--- /issm/trunk/test/NightlyRun/test1206.py	(revision 14310)
+++ /issm/trunk/test/NightlyRun/test1206.py	(revision 14310)
@@ -0,0 +1,108 @@
+import numpy
+from model import *
+from roundmesh import *
+from setmask import *
+from parameterize import *
+from setflowequation import *
+from EnumDefinitions import *
+from solve import *
+from MatlabFuncs import *
+
+"""
+The aim of this program is to compare a model with an analytical solution given in MacAyeal EISMINT : Lessons in Ice-Sheet Modeling.
+"""
+
+printingflag=False
+
+numlayers=10
+resolution=30000.
+
+#To begin with the numerical model
+md=model()
+md=roundmesh(md,750000.,resolution)
+md=setmask(md,'','')    #We can not test iceshelves nor ice rises with this analytical solution
+md=parameterize(md,'../Par/RoundSheetStaticEISMINT.py')
+
+#Calculation of the analytical 2d velocity field
+constant=0.3
+vx_obs=constant/2.*md.mesh.x.reshape(-1,1)*(md.geometry.thickness)**-1
+vy_obs=constant/2.*md.mesh.y.reshape(-1,1)*(md.geometry.thickness)**-1
+vel_obs=numpy.sqrt((md.inversion.vx_obs)**2+(md.inversion.vy_obs)**2)
+
+#We extrude the model to have a 3d model
+md.extrude(numlayers,1.)
+md=setflowequation(md,'pattyn','all')
+
+#Spc the nodes on the bed
+pos=numpy.nonzero(md.mesh.vertexonbed)
+md.diagnostic.spcvx[pos]=0.
+md.diagnostic.spcvy[pos]=0.
+md.diagnostic.spcvz[pos]=0.
+
+#Now we can solve the problem 
+md.cluster=generic('name',oshostname(),'np',8)
+md=solve(md,DiagnosticSolutionEnum())
+
+#Calculate the depth averaged velocity field (2d):
+vx=md.results.DiagnosticSolution.Vx
+vy=md.results.DiagnosticSolution.Vy
+vel=numpy.zeros((md.mesh.numberofvertices2d,1))
+
+for i in xrange(0,md.mesh.numberofvertices2d):
+	node_vel=0.
+	for j in xrange(0,md.mesh.numberoflayers-1):
+		node_vel=node_vel+1./(2.*(md.mesh.numberoflayers-1))*\
+			(numpy.sqrt(vx[i+(j+1)*md.mesh.numberofvertices2d,0]**2+vy[i+(j+1)*md.mesh.numberofvertices2d,0]**2)+\
+			numpy.sqrt(vx[i+j*md.mesh.numberofvertices2d,0]**2+vy[i+j*md.mesh.numberofvertices2d,0]**2))
+	vel[i,0]=node_vel
+
+#Plot of the velocity from the exact and calculated solutions
+#figure(1)
+#subplot(2,2,1)
+#p=patch('Faces',md.mesh.elements2d,'Vertices',[md.mesh.x2d md.mesh.y2d],'FaceVertexCData',...
+#vel,'FaceColor','interp','EdgeColor','none');
+#title('Modelled velocity','FontSize',14,'FontWeight','bold')
+#colorbar; 
+#caxis([0 200]);
+   
+#subplot(2,2,2)
+#p=patch('Faces',md.mesh.elements2d,'Vertices',[md.mesh.x2d md.mesh.y2d],'FaceVertexCData',...
+#vel_obs,'FaceColor','interp','EdgeColor','none');
+#title('Analytical velocity','FontSize',14,'FontWeight','bold')
+#colorbar; 
+#caxis([0 200]);
+
+#subplot(2,2,3)
+#hold on;
+#plot(sqrt((md.mesh.x(1:md.mesh.numberofvertices2d)).^2+(md.mesh.y(1:md.mesh.numberofvertices2d)).^2),vel,'r.');
+#plot(sqrt((md.mesh.x2d).^2+(md.mesh.y2d).^2),vel_obs,'b.');
+#title('Analytical vs calculated velocity','FontSize',14,'FontWeight','bold');
+#xlabel('distance to the center of the icesheet [m]','FontSize',14,'FontWeight','bold');
+#ylabel('velocity [m/yr]','FontSize',14,'FontWeight','bold');
+#legend('calculated velocity','exact velocity');
+#axis([0 750000 0 200]);
+#hold off;
+
+#subplot(2,2,4)
+#p=patch('Faces',md.mesh.elements2d,'Vertices',[md.mesh.x2d md.mesh.y2d],'FaceVertexCData',...
+#abs(vel-vel_obs)./vel_obs*100,'FaceColor','interp','EdgeColor','none');
+#title('Relative misfit [%]','FontSize',14,'FontWeight','bold')
+#colorbar;
+#caxis([0 100]);
+
+if printingflag:
+	pass
+#	set(gcf,'Color','w')
+#	printmodel('pattynstatic','png','margin','on','marginsize',25,'frame','off','resolution',0.7,'hardcopy','off');
+#	system(['mv pattynstatic.png ' ISSM_DIR '/website/doc_pdf/validation/Images/EISMINT/IceSheet']);
+
+#Fields and tolerances to track changes
+field_names     =[ \
+	'Vx','Vy','Vel', \
+]
+field_tolerances=[ \
+	1e-12,1e-12,1e-12, \
+]
+field_values=[ \
+	vx,vy,vel, \
+]
Index: /issm/trunk/test/NightlyRun/test1207.m
===================================================================
--- /issm/trunk/test/NightlyRun/test1207.m	(revision 14309)
+++ /issm/trunk/test/NightlyRun/test1207.m	(revision 14310)
@@ -1,11 +1,11 @@
-%The aim of this program is to compare a model with an analytical solution given in MacAyeal EISMINT : Lessons in Ice-Sheet Modeling
+%The aim of this program is to compare a model with an analytical solution given in MacAyeal EISMINT : Lessons in Ice-Sheet Modeling.
 printingflag=false;
 
 numlayers=10;
-resolution=30000;
+resolution=30000.;
 
 %To begin with the numerical model
 md=model();
-md=roundmesh(md,750000,resolution);
+md=roundmesh(md,750000.,resolution);
 md=setmask(md,'',''); %We can not test iceshelves nor ice rises with this analytical solution
 md=parameterize(md,'../Par/RoundSheetStaticEISMINT.par');
@@ -13,7 +13,7 @@
 %Calculation of the analytical 2d velocity field
 constant=0.3;
-vx_obs=constant/2*md.mesh.x.*(md.geometry.thickness).^-1;
-vy_obs=constant/2*md.mesh.y.*(md.geometry.thickness).^-1;
-vel_obs=(sqrt((md.inversion.vx_obs).^2+(md.inversion.vy_obs).^2));
+vx_obs=constant/2.*md.mesh.x.*(md.geometry.thickness).^-1;
+vy_obs=constant/2.*md.mesh.y.*(md.geometry.thickness).^-1;
+vel_obs=sqrt((md.inversion.vx_obs).^2+(md.inversion.vy_obs).^2);
 
 %We extrude the model to have a 3d model
@@ -23,7 +23,7 @@
 %Spc the nodes on the bed
 pos=find(md.mesh.vertexonbed);
-md.diagnostic.spcvx(pos)=0;
-md.diagnostic.spcvy(pos)=0;
-md.diagnostic.spcvz(pos)=0;
+md.diagnostic.spcvx(pos)=0.;
+md.diagnostic.spcvy(pos)=0.;
+md.diagnostic.spcvz(pos)=0.;
 
 %Now we can solve the problem 
@@ -36,13 +36,12 @@
 vel=zeros(md.mesh.numberofvertices2d,1);
 
-node_vel=0;
 for i=1:md.mesh.numberofvertices2d
-	for j=1:(md.mesh.numberoflayers-1)
-		node_vel=node_vel+1/(2*(md.mesh.numberoflayers-1))*(sqrt(vx(i+j*md.mesh.numberofvertices2d,1).^2+...
-			vy(i+j*md.mesh.numberofvertices2d,1).^2)+...
+	node_vel=0.;
+	for j=1:md.mesh.numberoflayers-1
+		node_vel=node_vel+1./(2.*(md.mesh.numberoflayers-1))*...
+			(sqrt(vx(i+j*md.mesh.numberofvertices2d,1).^2+vy(i+j*md.mesh.numberofvertices2d,1).^2)+...
 			sqrt(vx(i+(j-1)*md.mesh.numberofvertices2d,1).^2+vy(i+(j-1)*md.mesh.numberofvertices2d,1).^2));
 	end
 	vel(i,1)=node_vel;
-	node_vel=0;
 end
 
@@ -81,5 +80,5 @@
 caxis([0 100]);
 
-if printingflag, 
+if printingflag,
 	set(gcf,'Color','w')
 	printmodel('stokesstatic','png','margin','on','marginsize',25,'frame','off','resolution',0.7,'hardcopy','off');
@@ -91,8 +90,8 @@
 	'Vx','Vy','Vel', ...
 };
-field_tolerances={...
+field_tolerances={ ...
 	1e-12,1e-12,1e-12, ...
 };
-field_values={
+field_values={ ...
 	vx,vy,vel, ...
 };
Index: /issm/trunk/test/NightlyRun/test1207.py
===================================================================
--- /issm/trunk/test/NightlyRun/test1207.py	(revision 14310)
+++ /issm/trunk/test/NightlyRun/test1207.py	(revision 14310)
@@ -0,0 +1,108 @@
+import numpy
+from model import *
+from roundmesh import *
+from setmask import *
+from parameterize import *
+from setflowequation import *
+from EnumDefinitions import *
+from solve import *
+from MatlabFuncs import *
+
+"""
+The aim of this program is to compare a model with an analytical solution given in MacAyeal EISMINT : Lessons in Ice-Sheet Modeling.
+"""
+
+printingflag=False
+
+numlayers=10
+resolution=30000.
+
+#To begin with the numerical model
+md=model()
+md=roundmesh(md,750000.,resolution)
+md=setmask(md,'','')    #We can not test iceshelves nor ice rises with this analytical solution
+md=parameterize(md,'../Par/RoundSheetStaticEISMINT.py')
+
+#Calculation of the analytical 2d velocity field
+constant=0.3
+vx_obs=constant/2.*md.mesh.x.reshape(-1,1)*(md.geometry.thickness)**-1
+vy_obs=constant/2.*md.mesh.y.reshape(-1,1)*(md.geometry.thickness)**-1
+vel_obs=numpy.sqrt((md.inversion.vx_obs)**2+(md.inversion.vy_obs)**2)
+
+#We extrude the model to have a 3d model
+md.extrude(numlayers,1.)
+md=setflowequation(md,'stokes','all')
+
+#Spc the nodes on the bed
+pos=numpy.nonzero(md.mesh.vertexonbed)
+md.diagnostic.spcvx[pos]=0.
+md.diagnostic.spcvy[pos]=0.
+md.diagnostic.spcvz[pos]=0.
+
+#Now we can solve the problem 
+md.cluster=generic('name',oshostname(),'np',8)
+md=solve(md,DiagnosticSolutionEnum())
+
+#Calculate the depth averaged velocity field (2d):
+vx=md.results.DiagnosticSolution.Vx
+vy=md.results.DiagnosticSolution.Vy
+vel=numpy.zeros((md.mesh.numberofvertices2d,1))
+
+for i in xrange(0,md.mesh.numberofvertices2d):
+	node_vel=0.
+	for j in xrange(0,md.mesh.numberoflayers-1):
+		node_vel=node_vel+1./(2.*(md.mesh.numberoflayers-1))*\
+			(numpy.sqrt(vx[i+(j+1)*md.mesh.numberofvertices2d,0]**2+vy[i+(j+1)*md.mesh.numberofvertices2d,0]**2)+\
+			numpy.sqrt(vx[i+j*md.mesh.numberofvertices2d,0]**2+vy[i+j*md.mesh.numberofvertices2d,0]**2))
+	vel[i,0]=node_vel
+
+#Plot of the velocity from the exact and calculated solutions
+#figure(1)
+#subplot(2,2,1)
+#p=patch('Faces',md.mesh.elements2d,'Vertices',[md.mesh.x2d md.mesh.y2d],'FaceVertexCData',...
+#vel,'FaceColor','interp','EdgeColor','none');
+#title('Modelled velocity','FontSize',14,'FontWeight','bold')
+#colorbar; 
+#caxis([0 200]);
+   
+#subplot(2,2,2)
+#p=patch('Faces',md.mesh.elements2d,'Vertices',[md.mesh.x2d md.mesh.y2d],'FaceVertexCData',...
+#vel_obs,'FaceColor','interp','EdgeColor','none');
+#title('Analytical velocity','FontSize',14,'FontWeight','bold')
+#colorbar; 
+#caxis([0 200]);
+
+#subplot(2,2,3)
+#hold on;
+#plot(sqrt((md.mesh.x(1:md.mesh.numberofvertices2d)).^2+(md.mesh.y(1:md.mesh.numberofvertices2d)).^2),vel,'r.');
+#plot(sqrt((md.mesh.x2d).^2+(md.mesh.y2d).^2),vel_obs,'b.');
+#title('Analytical vs calculated velocity','FontSize',14,'FontWeight','bold');
+#xlabel('distance to the center of the icesheet [m]','FontSize',14,'FontWeight','bold');
+#ylabel('velocity [m/yr]','FontSize',14,'FontWeight','bold');
+#legend('calculated velocity','exact velocity');
+#axis([0 750000 0 200]);
+#hold off;
+
+#subplot(2,2,4)
+#p=patch('Faces',md.mesh.elements2d,'Vertices',[md.mesh.x2d md.mesh.y2d],'FaceVertexCData',...
+#abs(vel-vel_obs)./vel_obs*100,'FaceColor','interp','EdgeColor','none');
+#title('Relative misfit [%]','FontSize',14,'FontWeight','bold')
+#colorbar;
+#caxis([0 100]);
+
+if printingflag:
+	pass
+#	set(gcf,'Color','w')
+#	printmodel('stokesstatic','png','margin','on','marginsize',25,'frame','off','resolution',0.7,'hardcopy','off');
+#	system(['mv stokesstatic.png ' ISSM_DIR '/website/doc_pdf/validation/Images/EISMINT/IceSheet']);
+
+#Fields and tolerances to track changes
+field_names     =[ \
+	'Vx','Vy','Vel', \
+]
+field_tolerances=[ \
+	1e-12,1e-12,1e-12, \
+]
+field_values=[ \
+	vx,vy,vel, \
+]
Index: /issm/trunk/test/NightlyRun/test1208.m
===================================================================
--- /issm/trunk/test/NightlyRun/test1208.m	(revision 14309)
+++ /issm/trunk/test/NightlyRun/test1208.m	(revision 14310)
@@ -1,5 +1,5 @@
 %EISMINT benchmark experiment A
 numlayers=8;
-resolution=50000;
+resolution=50000.;
 
 %To begin with the numerical model
@@ -14,12 +14,12 @@
 %Spc the nodes on the bed
 pos=find(md.mesh.vertexonbed);
-md.diagnostic.spcvx(pos)=0;
-md.diagnostic.spcvy(pos)=0;
-md.diagnostic.spcvz(pos)=0;
+md.diagnostic.spcvx(pos)=0.;
+md.diagnostic.spcvy(pos)=0.;
+md.diagnostic.spcvz(pos)=0.;
 
 %Adapt the time steps to the resolution
-md.timestepping.time_step=15;
+md.timestepping.time_step=15.;
 md.settings.output_frequency=500;
-md.timestepping.final_time=30000;
+md.timestepping.final_time=30000.;
 md.prognostic.stabilization=1;
 md.thermal.stabilization=1;
Index: /issm/trunk/test/NightlyRun/test1208.py
===================================================================
--- /issm/trunk/test/NightlyRun/test1208.py	(revision 14310)
+++ /issm/trunk/test/NightlyRun/test1208.py	(revision 14310)
@@ -0,0 +1,58 @@
+import numpy
+from model import *
+from triangle import *
+from setmask import *
+from parameterize import *
+from setflowequation import *
+from EnumDefinitions import *
+from solve import *
+from MatlabFuncs import *
+
+"""
+EISMINT benchmark experiment A
+"""
+
+numlayers=8
+resolution=50000.
+
+#To begin with the numerical model
+md=triangle(model(),'../Exp/SquareEISMINT750000.exp',resolution)
+md=setmask(md,'','')
+md=parameterize(md,'../Par/RoundSheetEISMINT.py')
+
+#We extrude the model to have a 3d model
+md.extrude(numlayers,1.)
+md=setflowequation(md,'hutter','all')
+
+#Spc the nodes on the bed
+pos=numpy.nonzero(md.mesh.vertexonbed)
+md.diagnostic.spcvx[pos]=0.
+md.diagnostic.spcvy[pos]=0.
+md.diagnostic.spcvz[pos]=0.
+
+#Adapt the time steps to the resolution
+md.timestepping.time_step=15.
+md.settings.output_frequency=500
+md.timestepping.final_time=30000.
+md.prognostic.stabilization=1
+md.thermal.stabilization=1
+
+#Now we can solve the problem 
+md.cluster=generic('name',oshostname(),'np',8)
+md=solve(md,TransientSolutionEnum())
+
+#Fields and tolerances to track changes
+field_names     =['Vx','Vy','Vz','Vel','Pressure','Thickness','Bed','Surface','Temperature','BasalforcingsMeltingRate']
+field_tolerances=[1e-08,1e-08,1e-07,1e-08,1e-08,1e-08,1e-08,1e-08,1e-07,1e-07]
+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].Thickness,\
+	md.results.TransientSolution[-1].Bed,\
+	md.results.TransientSolution[-1].Surface,\
+	md.results.TransientSolution[-1].Temperature,\
+	md.results.TransientSolution[-1].BasalforcingsMeltingRate,\
+	]
Index: /issm/trunk/test/NightlyRun/test1301.m
===================================================================
--- /issm/trunk/test/NightlyRun/test1301.m	(revision 14309)
+++ /issm/trunk/test/NightlyRun/test1301.m	(revision 14310)
@@ -10,5 +10,5 @@
 md=parameterize(md,'../Par/SquareThermal.par');
 md=extrude(md,3,2.);
-md=setflowequation(md,'Pattyn','all');
+md=setflowequation(md,'pattyn','all');
 
 %Some conditions specific to melting test
@@ -24,5 +24,5 @@
 melting=md.basalforcings.geothermalflux/(md.materials.rho_ice*md.materials.latentheat)*md.constants.yts;
 
-%modeled  results
+%modeled results
 md.cluster=generic('name',oshostname(),'np',2);
 md=solve(md,ThermalSolutionEnum());
@@ -30,10 +30,10 @@
 %plot results
 comp_melting=md.results.ThermalSolution.BasalforcingsMeltingRate;
-relative=abs((comp_melting-melting)./melting)*100;
-relative(find(comp_melting==melting))=0;
+relative=abs((comp_melting-melting)./melting)*100.;
+relative(find(comp_melting==melting))=0.;
 plotmodel(md,'data',comp_melting,'title','Modeled melting','data',melting,'title','Analytical melting',...
 	'data',comp_melting-melting,'title','Absolute error','data',relative,'title','Relative error [%]',...
 	'layer#all',1,'caxis#2',[1.02964 1.02966]*10^-4,'FontSize#all',20,'figposition','mathieu')
-if printingflag, 
+if printingflag,
 	set(gcf,'Color','w')
 	printmodel('thermalmelting','png','margin','on','marginsize',25,'frame','off','resolution',0.7,'hardcopy','off');
@@ -41,5 +41,4 @@
 end
 
-
 %Fields and tolerances to track changes
 field_names     ={'BasalMelting'};
Index: /issm/trunk/test/NightlyRun/test1301.py
===================================================================
--- /issm/trunk/test/NightlyRun/test1301.py	(revision 14310)
+++ /issm/trunk/test/NightlyRun/test1301.py	(revision 14310)
@@ -0,0 +1,60 @@
+import numpy
+from model import *
+from triangle import *
+from setmask import *
+from parameterize import *
+from setflowequation import *
+from paterson import *
+from EnumDefinitions import *
+from solve import *
+from MatlabFuncs import *
+
+"""
+This file can be run to check that the melting in simple conduction is correctly modeled.
+There is no velocity (no advection) the only thermal boundary conditions are an imposed temperature
+at upper surface and an impose flux at its base. The result must be a linear temperature from the upper to the lower
+surface with an imposed slope (Geothermal flux). if it is not the case, something is thermal modeling has been changed...
+"""
+
+printingflag=False
+
+md=model()
+md=triangle(md,'../Exp/Square.exp',100000.)
+md=setmask(md,'','')
+md=parameterize(md,'../Par/SquareThermal.py')
+md.extrude(3,2.)
+md=setflowequation(md,'pattyn','all')
+
+#Some conditions specific to melting test
+md.initialization.pressure=numpy.zeros((md.mesh.numberofvertices,1),int)
+md.initialization.temperature=273.15*numpy.ones((md.mesh.numberofvertices,1))
+pos=numpy.nonzero(md.mesh.vertexonsurface)[0]
+md.thermal.spctemperature[pos]=md.initialization.temperature[pos]
+md.materials.rheology_B=paterson(md.initialization.temperature)
+
+#analytical results
+#melting heat = geothermal flux
+#Mb*L*rho=G   => Mb=G/L*rho
+melting=md.basalforcings.geothermalflux/(md.materials.rho_ice*md.materials.latentheat)*md.constants.yts
+
+#modeled results
+md.cluster=generic('name',oshostname(),'np',2)
+md=solve(md,ThermalSolutionEnum())
+
+#plot results
+comp_melting=md.results.ThermalSolution.BasalforcingsMeltingRate
+relative=numpy.abs((comp_melting-melting)/melting)*100.
+relative[numpy.nonzero(comp_melting==melting)[0]]=0.
+#plotmodel(md,'data',comp_melting,'title','Modeled melting','data',melting,'title','Analytical melting',...
+#	'data',comp_melting-melting,'title','Absolute error','data',relative,'title','Relative error [%]',...
+#	'layer#all',1,'caxis#2',[1.02964 1.02966]*10^-4,'FontSize#all',20,'figposition','mathieu')
+if printingflag:
+	pass
+#	set(gcf,'Color','w')
+#	printmodel('thermalmelting','png','margin','on','marginsize',25,'frame','off','resolution',0.7,'hardcopy','off');
+#	system(['mv thermalmelting.png ' ISSM_DIR '/website/doc_pdf/validation/Images/Thermal ']);
+
+#Fields and tolerances to track changes
+field_names     =['BasalMelting']
+field_tolerances=[1e-08]
+field_values    =[comp_melting]
Index: /issm/trunk/test/NightlyRun/test1302.m
===================================================================
--- /issm/trunk/test/NightlyRun/test1302.m	(revision 14309)
+++ /issm/trunk/test/NightlyRun/test1302.m	(revision 14310)
@@ -9,9 +9,9 @@
 md=parameterize(md,'../Par/SquareThermal.par');
 md=extrude(md,30,1.);   %NB: the more one extrudes, the better (10-> relative~0.35%, 20->0.1%, 30->0.05%)
-md=setflowequation(md,'Pattyn','all'); 
+md=setflowequation(md,'pattyn','all');
 
 %Thermal boundary conditions
-pos1=find(md.mesh.elementonbed);     md.thermal.spctemperature(md.mesh.elements(pos1,1:3))=10;
-pos2=find(md.mesh.elementonsurface); md.thermal.spctemperature(md.mesh.elements(pos2,4:6))=0;
+pos1=find(md.mesh.elementonbed);     md.thermal.spctemperature(md.mesh.elements(pos1,1:3))=10.;
+pos2=find(md.mesh.elementonsurface); md.thermal.spctemperature(md.mesh.elements(pos2,4:6))=0.;
 md.initialization.vz=0.1*ones(md.mesh.numberofvertices,1);
 md.initialization.vel=sqrt( md.initialization.vx.^2+ md.initialization.vy.^2+ md.initialization.vz.^2);
@@ -22,9 +22,9 @@
 %d2T/dz2-w*rho_ice*c/k*dT/dz=0   T(surface)=0  T(bed)=10   => T=A exp(alpha z)+B
 alpha=0.1/md.constants.yts*md.materials.rho_ice*md.materials.heatcapacity/md.materials.thermalconductivity;   %alpha=w rho_ice c /k  and w=0.1m/an
-A=10/(exp(alpha*(-1000))-1);    %A=T(bed)/(exp(alpha*bed)-1)  with bed=-1000 T(bed)=10
+A=10./(exp(alpha*(-1000.))-1.);    %A=T(bed)/(exp(alpha*bed)-1)  with bed=-1000 T(bed)=10
 B=-A;
 md.initialization.temperature=A*exp(alpha*md.mesh.z)+B;
 
-%modeled  results
+%modeled results
 md.cluster=generic('name',oshostname(),'np',2);
 md=solve(md,ThermalSolutionEnum());
@@ -32,11 +32,11 @@
 %plot results
 comp_temp=md.results.ThermalSolution.Temperature;
-relative=abs((comp_temp-md.initialization.temperature)./md.initialization.temperature)*100;
-relative(find(comp_temp==md.initialization.temperature))=0;
+relative=abs((comp_temp-md.initialization.temperature)./md.initialization.temperature)*100.;
+relative(find(comp_temp==md.initialization.temperature))=0.;
 plotmodel(md,'data',comp_temp,'title','Modeled temperature [K]','data',md.initialization.temperature,'view',3,...
 	'title','Analytical temperature [K]','view',3,'data',comp_temp-md.initialization.temperature,...
 	'title','Absolute error [K]','view',3,'data',relative,'title','Relative error [%]','view',3,...
 	'figposition','mathieu','FontSize#all',20)
-if printingflag, 
+if printingflag,
 	set(gcf,'Color','w')
 	printmodel('thermaladvection','png','margin','on','marginsize',25,'frame','off','resolution',0.7,'hardcopy','off');
Index: /issm/trunk/test/NightlyRun/test1302.py
===================================================================
--- /issm/trunk/test/NightlyRun/test1302.py	(revision 14310)
+++ /issm/trunk/test/NightlyRun/test1302.py	(revision 14310)
@@ -0,0 +1,65 @@
+import numpy
+import sys
+from model import *
+from triangle import *
+from setmask import *
+from parameterize import *
+from setflowequation import *
+from EnumDefinitions import *
+from solve import *
+from MatlabFuncs import *
+
+"""
+This file can be run to check that the advection-diffusion  is correctly modeled.
+There is u=v=0 and w=cst everywhere the only thermal boundary conditions are an imposed temperature
+at upper surface and an impose flux at its base.
+"""
+
+printingflag=False
+
+md=model()
+md=triangle(md,'../Exp/Square.exp',100000.)
+md=setmask(md,'','')
+md=parameterize(md,'../Par/SquareThermal.py')
+md.extrude(30,1.)    #NB: the more one extrudes, the better (10-> relative~0.35%, 20->0.1%, 30->0.05%)
+md=setflowequation(md,'pattyn','all')
+
+#Thermal boundary conditions
+pos1=numpy.nonzero(md.mesh.elementonbed)[0]
+md.thermal.spctemperature[md.mesh.elements[pos1,0:3]-1]=10.
+pos2=numpy.nonzero(md.mesh.elementonsurface)[0]
+md.thermal.spctemperature[md.mesh.elements[pos2,3:6]-1]=0.
+md.initialization.vz=0.1*numpy.ones((md.mesh.numberofvertices,1))
+md.initialization.vel=numpy.sqrt( md.initialization.vx**2+ md.initialization.vy**2+ md.initialization.vz**2)
+md.initialization.pressure=numpy.zeros((md.mesh.numberofvertices,1),int)
+
+md.thermal.stabilization=2
+#analytical results
+#d2T/dz2-w*rho_ice*c/k*dT/dz=0   T(surface)=0  T(bed)=10   => T=A exp(alpha z)+B
+alpha=0.1/md.constants.yts*md.materials.rho_ice*md.materials.heatcapacity/md.materials.thermalconductivity    #alpha=w rho_ice c /k  and w=0.1m/an
+A=10./(numpy.exp(alpha*(-1000.))-1.)    #A=T(bed)/(exp(alpha*bed)-1)  with bed=-1000 T(bed)=10
+B=-A
+md.initialization.temperature=A*numpy.exp(alpha*md.mesh.z)+B
+
+#modeled results
+md.cluster=generic('name',oshostname(),'np',2)
+md=solve(md,ThermalSolutionEnum())
+
+#plot results
+comp_temp=md.results.ThermalSolution.Temperature
+relative=numpy.abs((comp_temp-md.initialization.temperature)/md.initialization.temperature)*100.
+relative[numpy.nonzero(comp_temp==md.initialization.temperature)[0]]=0.
+#plotmodel(md,'data',comp_temp,'title','Modeled temperature [K]','data',md.initialization.temperature,'view',3,...
+#	'title','Analytical temperature [K]','view',3,'data',comp_temp-md.initialization.temperature,...
+#	'title','Absolute error [K]','view',3,'data',relative,'title','Relative error [%]','view',3,...
+#	'figposition','mathieu','FontSize#all',20)
+if printingflag:
+	pass
+#	set(gcf,'Color','w')
+#	printmodel('thermaladvection','png','margin','on','marginsize',25,'frame','off','resolution',0.7,'hardcopy','off');
+#	system(['mv thermaladvection.png ' ISSM_DIR '/website/doc_pdf/validation/Images/EISMINT ']);
+
+#Fields and tolerances to track changes
+field_names     =['AdvectionTemperature']
+field_tolerances=[1e-13]
+field_values    =[comp_temp]
Index: /issm/trunk/test/NightlyRun/test1303.m
===================================================================
--- /issm/trunk/test/NightlyRun/test1303.m	(revision 14309)
+++ /issm/trunk/test/NightlyRun/test1303.m	(revision 14310)
@@ -10,7 +10,8 @@
 md=parameterize(md,'../Par/SquareThermal.par');
 md=extrude(md,11,2.);
-md=setflowequation(md,'Pattyn','all');
-pos1=find(md.mesh.elementonbed);     md.thermal.spctemperature(md.mesh.elements(pos1,1:3))=10;
-pos2=find(md.mesh.elementonsurface); md.thermal.spctemperature(md.mesh.elements(pos2,4:6))=0;
+md=setflowequation(md,'pattyn','all');
+
+pos1=find(md.mesh.elementonbed);     md.thermal.spctemperature(md.mesh.elements(pos1,1:3))=10.;
+pos2=find(md.mesh.elementonsurface); md.thermal.spctemperature(md.mesh.elements(pos2,4:6))=0.;
 md.initialization.pressure=zeros(md.mesh.numberofvertices,1);
 
@@ -18,7 +19,7 @@
 %d2T/dz2=0 T(bed)=10 T(surface)=0  => T=0*(z-bed)/thickness+10*(surface-z)/thickness
 %each layer of the 3d mesh must have a constant value
-md.initialization.temperature=10*(md.geometry.surface-md.mesh.z)./md.geometry.thickness;
+md.initialization.temperature=10.*(md.geometry.surface-md.mesh.z)./md.geometry.thickness;
 
-%modeled  results
+%modeled results
 md.cluster=generic('name',oshostname(),'np',2);
 md=solve(md,ThermalSolutionEnum());
@@ -26,11 +27,11 @@
 %plot results
 comp_temp=md.results.ThermalSolution.Temperature;
-relative=abs((comp_temp-md.initialization.temperature)./md.initialization.temperature)*100;
-relative(find(comp_temp==md.initialization.temperature))=0;
+relative=abs((comp_temp-md.initialization.temperature)./md.initialization.temperature)*100.;
+relative(find(comp_temp==md.initialization.temperature))=0.;
 plotmodel(md,'data',comp_temp,'title','Modeled temperature [K]','data',md.initialization.temperature,'view',3,...
 	'title','Analytical temperature [K]','view',3,'data',comp_temp-md.initialization.temperature,...
 	'title','Absolute error [K]','view',3,'data',relative,'title','Relative error [%]','view',3,...
 	'figposition','mathieu','FontSize#all',20)
-if printingflag, 
+if printingflag,
 	set(gcf,'Color','w')
 	printmodel('thermalconduction','png','margin','on','marginsize',25,'frame','off','resolution',0.7,'hardcopy','off');
Index: /issm/trunk/test/NightlyRun/test1303.py
===================================================================
--- /issm/trunk/test/NightlyRun/test1303.py	(revision 14310)
+++ /issm/trunk/test/NightlyRun/test1303.py	(revision 14310)
@@ -0,0 +1,60 @@
+import numpy
+import sys
+from model import *
+from triangle import *
+from setmask import *
+from parameterize import *
+from setflowequation import *
+from EnumDefinitions import *
+from solve import *
+from MatlabFuncs import *
+
+"""
+This file can be run to check that the conduction is correctly modeled.
+There is no velocity (no advection) the only thermal boundary conditions are an imposed temperature
+at the lower and upper surface. The result must be a linear temperature from the upper to the lower
+surface. if it is not the case, something is thermal modeling has been changed...
+"""
+
+printingflag=False
+
+md=model()
+md=triangle(md,'../Exp/Square.exp',100000.)
+md=setmask(md,'all','')
+md=parameterize(md,'../Par/SquareThermal.py')
+md.extrude(11,2.)
+md=setflowequation(md,'pattyn','all')
+
+pos1=numpy.nonzero(md.mesh.elementonbed)[0]
+md.thermal.spctemperature[md.mesh.elements[pos1,0:3]-1]=10.
+pos2=numpy.nonzero(md.mesh.elementonsurface)[0]
+md.thermal.spctemperature[md.mesh.elements[pos2,3:6]-1]=0.
+md.initialization.pressure=numpy.zeros((md.mesh.numberofvertices,1),int)
+
+#analytical results
+#d2T/dz2=0 T(bed)=10 T(surface)=0  => T=0*(z-bed)/thickness+10*(surface-z)/thickness
+#each layer of the 3d mesh must have a constant value
+md.initialization.temperature=10.*(md.geometry.surface-md.mesh.z)/md.geometry.thickness
+
+#modeled results
+md.cluster=generic('name',oshostname(),'np',2)
+md=solve(md,ThermalSolutionEnum())
+
+#plot results
+comp_temp=md.results.ThermalSolution.Temperature
+relative=numpy.abs((comp_temp-md.initialization.temperature)/md.initialization.temperature)*100.
+relative[numpy.nonzero(comp_temp==md.initialization.temperature)[0]]=0.
+#plotmodel(md,'data',comp_temp,'title','Modeled temperature [K]','data',md.initialization.temperature,'view',3,...
+#	'title','Analytical temperature [K]','view',3,'data',comp_temp-md.initialization.temperature,...
+#	'title','Absolute error [K]','view',3,'data',relative,'title','Relative error [%]','view',3,...
+#	'figposition','mathieu','FontSize#all',20)
+if printingflag:
+	pass
+#	set(gcf,'Color','w')
+#	printmodel('thermalconduction','png','margin','on','marginsize',25,'frame','off','resolution',0.7,'hardcopy','off');
+#	system(['mv thermalconduction.png ' ISSM_DIR '/website/doc_pdf/validation/Images/Thermal ']);
+
+#Fields and tolerances to track changes
+field_names     =['ConductionTemperature']
+field_tolerances=[1e-13]
+field_values    =[comp_temp]
Index: /issm/trunk/test/NightlyRun/test1304.m
===================================================================
--- /issm/trunk/test/NightlyRun/test1304.m	(revision 14309)
+++ /issm/trunk/test/NightlyRun/test1304.m	(revision 14310)
@@ -10,7 +10,7 @@
 md=parameterize(md,'../Par/SquareThermal.par');
 md=extrude(md,11,1.);
-md=setflowequation(md,'Pattyn','all');
+md=setflowequation(md,'pattyn','all');
 
-pos2=find(md.mesh.elementonsurface); md.thermal.spctemperature(md.mesh.elements(pos2,4:6))=0;
+pos2=find(md.mesh.elementonsurface); md.thermal.spctemperature(md.mesh.elements(pos2,4:6))=0.;
 md.initialization.pressure=zeros(md.mesh.numberofvertices,1);
 md.basalforcings.geothermalflux(:)=0.1; %100mW/m^2
@@ -21,5 +21,5 @@
 md.initialization.temperature=-0.1/md.materials.thermalconductivity*(md.mesh.z-md.geometry.surface); %G=0.1 W/m2
 
-%modeled  results
+%modeled results
 md.cluster=generic('name',oshostname(),'np',2);
 md=solve(md,ThermalSolutionEnum());
@@ -27,11 +27,11 @@
 %plot results
 comp_temp=md.results.ThermalSolution.Temperature;
-relative=abs((comp_temp-md.initialization.temperature)./md.initialization.temperature)*100;
-relative(find(comp_temp==md.initialization.temperature))=0;
+relative=abs((comp_temp-md.initialization.temperature)./md.initialization.temperature)*100.;
+relative(find(comp_temp==md.initialization.temperature))=0.;
 plotmodel(md,'data',comp_temp,'title','Modeled temperature [K]','data',md.initialization.temperature,'view',3,...
 	'title','Analytical temperature','view',3,'data',comp_temp-md.initialization.temperature,...
 	'title','Absolute error [K]','view',3,'data',relative,'title','Relative error [%]','view',3,...
 	'figposition','mathieu','FontSize#all',20)
-if printingflag, 
+if printingflag,
 	set(gcf,'Color','w')
 	printmodel('thermalgeothermalflux','png','margin','on','marginsize',25,'frame','off','resolution',0.7,'hardcopy','off');
Index: /issm/trunk/test/NightlyRun/test1304.py
===================================================================
--- /issm/trunk/test/NightlyRun/test1304.py	(revision 14310)
+++ /issm/trunk/test/NightlyRun/test1304.py	(revision 14310)
@@ -0,0 +1,59 @@
+import numpy
+import sys
+from model import *
+from triangle import *
+from setmask import *
+from parameterize import *
+from setflowequation import *
+from EnumDefinitions import *
+from solve import *
+from MatlabFuncs import *
+
+"""
+This file can be run to check that the geothermal flux in simple conduction is correctly modeled.
+There is no velocity (no advection) the only thermal boundary conditions are an imposed temperature
+at upper surface and an impose flux at its base. The result must be a linear temperature from the upper to the lower
+surface with an imposed slope (Geothermal flux). if it is not the case, something is thermal modeling has been changed...
+"""
+
+printingflag=False
+
+md=model()
+md=triangle(md,'../Exp/Square.exp',100000.)
+md=setmask(md,'','')
+md=parameterize(md,'../Par/SquareThermal.py')
+md.extrude(11,1.)
+md=setflowequation(md,'pattyn','all')
+
+pos2=numpy.nonzero(md.mesh.elementonsurface)[0]
+md.thermal.spctemperature[md.mesh.elements[pos2,3:6]-1]=0.
+md.initialization.pressure=numpy.zeros((md.mesh.numberofvertices,1),int)
+md.basalforcings.geothermalflux[:]=0.1    #100mW/m^2
+
+#analytical results
+#the result is linear with depth and is equal to 0 on the upper surface (See BC)
+#d2T/dz2=0  -k*dT/dz(bed)=G  T(surface)=0  => T=-G/k*(z-surface)
+md.initialization.temperature=-0.1/md.materials.thermalconductivity*(md.mesh.z-md.geometry.surface)    #G=0.1 W/m2
+
+#modeled results
+md.cluster=generic('name',oshostname(),'np',2)
+md=solve(md,ThermalSolutionEnum())
+
+#plot results
+comp_temp=md.results.ThermalSolution.Temperature
+relative=numpy.abs((comp_temp-md.initialization.temperature)/md.initialization.temperature)*100.
+relative[numpy.nonzero(comp_temp==md.initialization.temperature)[0]]=0.
+#plotmodel(md,'data',comp_temp,'title','Modeled temperature [K]','data',md.initialization.temperature,'view',3,...
+#	'title','Analytical temperature','view',3,'data',comp_temp-md.initialization.temperature,...
+#	'title','Absolute error [K]','view',3,'data',relative,'title','Relative error [%]','view',3,...
+#	'figposition','mathieu','FontSize#all',20)
+if printingflag:
+	pass
+#	set(gcf,'Color','w')
+#	printmodel('thermalgeothermalflux','png','margin','on','marginsize',25,'frame','off','resolution',0.7,'hardcopy','off');
+#	system(['mv thermalgeothermalflux.png ' ISSM_DIR '/website/doc_pdf/validation/Images/Thermal ']);
+
+#Fields and tolerances to track changes
+field_names     =['GeothermalFluxTemperature']
+field_tolerances=[1e-13]
+field_values    =[comp_temp]
Index: /issm/trunk/test/NightlyRun/test1401.m
===================================================================
--- /issm/trunk/test/NightlyRun/test1401.m	(revision 14309)
+++ /issm/trunk/test/NightlyRun/test1401.m	(revision 14310)
@@ -1,8 +1,8 @@
 %test the anisotropic mesh adaptation
-%function to capture = exp(-(sqrt((md.mesh.x+0.1).^2+(md.mesh.y+0.1).^2)-0.75).^2*10^6)+((md.mesh.x+0.1).^2+(md.mesh.y+0.1).^2)/2;
+%function to capture = exp(-(sqrt((md.mesh.x+0.1).^2+(md.mesh.y+0.1).^2)-0.75).^2*10.^6)+((md.mesh.x+0.1).^2+(md.mesh.y+0.1).^2)/2.;
 printingflag=false;
 
 %create square mesh
-L=1; %in m
+L=1.; %in m
 nx=70; %numberof nodes in x direction
 ny=70;
@@ -11,7 +11,7 @@
 %mesh adaptation loop YAMS
 md=squaremesh(md,L,L,nx,ny);
-md.inversion.vel_obs=exp(-(sqrt((md.mesh.x+0.1).^2+(md.mesh.y+0.1).^2)-0.75).^2*10^6)+((md.mesh.x+0.1).^2+(md.mesh.y+0.1).^2)/2;
+md.inversion.vel_obs=exp(-(sqrt((md.mesh.x+0.1).^2+(md.mesh.y+0.1).^2)-0.75).^2*10.^6)+((md.mesh.x+0.1).^2+(md.mesh.y+0.1).^2)/2.;
 plotmodel(md,'data',md.inversion.vel_obs,'data',md.inversion.vel_obs,'nlines',1,'ncols',2,'title','','figposition',[500 500 1000 500],'axis#all','equal','xlim#all',[0 1],'ylim#all',[0 1],'edgecolor#1','w'); pause(0.5);
-if printingflag, 
+if printingflag,
 	set(gcf,'Color','w')
 	printmodel('mesh1_yams1','png','margin','on','marginsize',25,'frame','off','resolution',1,'hardcopy','off');
@@ -19,8 +19,8 @@
 end
 
-md=YamsCall(md,md.inversion.vel_obs,0.001,0.3,1.3,10^-4);
-md.inversion.vel_obs=exp(-(sqrt((md.mesh.x+0.1).^2+(md.mesh.y+0.1).^2)-0.75).^2*10^6)+((md.mesh.x+0.1).^2+(md.mesh.y+0.1).^2)/2;
+md=YamsCall(md,md.inversion.vel_obs,0.001,0.3,1.3,10.^-4);
+md.inversion.vel_obs=exp(-(sqrt((md.mesh.x+0.1).^2+(md.mesh.y+0.1).^2)-0.75).^2*10.^6)+((md.mesh.x+0.1).^2+(md.mesh.y+0.1).^2)/2.;
 plotmodel(md,'data',md.inversion.vel_obs,'data',md.inversion.vel_obs,'nlines',1,'ncols',2,'title','','figposition',[500 500 1000 500],'axis#all','equal','xlim#all',[0 1],'ylim#all',[0 1],'edgecolor#1','w'); pause(0.5);
-if printingflag, 
+if printingflag,
 	set(gcf,'Color','w')
 	printmodel('mesh1_yams2','png','margin','on','marginsize',25,'frame','off','resolution',1,'hardcopy','off');
@@ -29,7 +29,7 @@
 
 md=YamsCall(md,md.inversion.vel_obs,0.001,0.3,2.5,0.008);
-md.inversion.vel_obs=exp(-(sqrt((md.mesh.x+0.1).^2+(md.mesh.y+0.1).^2)-0.75).^2*10^6)+((md.mesh.x+0.1).^2+(md.mesh.y+0.1).^2)/2;
+md.inversion.vel_obs=exp(-(sqrt((md.mesh.x+0.1).^2+(md.mesh.y+0.1).^2)-0.75).^2*10.^6)+((md.mesh.x+0.1).^2+(md.mesh.y+0.1).^2)/2.;
 plotmodel(md,'data',md.inversion.vel_obs,'data',md.inversion.vel_obs,'nlines',1,'ncols',2,'title','','figposition',[500 500 1000 500],'axis#all','equal','xlim#all',[0 1],'ylim#all',[0 1],'edgecolor#1','w'); pause(0.5);
-if printingflag, 
+if printingflag,
 	set(gcf,'Color','w')
 	printmodel('mesh1_yams3','png','margin','on','marginsize',25,'frame','off','resolution',1,'hardcopy','off');
@@ -41,7 +41,7 @@
 %mesh adaptation loop BAMG
 md=squaremesh(md,L,L,nx,ny);
-md.inversion.vel_obs=exp(-(sqrt((md.mesh.x+0.1).^2+(md.mesh.y+0.1).^2)-0.75).^2*10^6)+((md.mesh.x+0.1).^2+(md.mesh.y+0.1).^2)/2;
+md.inversion.vel_obs=exp(-(sqrt((md.mesh.x+0.1).^2+(md.mesh.y+0.1).^2)-0.75).^2*10.^6)+((md.mesh.x+0.1).^2+(md.mesh.y+0.1).^2)/2.;
 plotmodel(md,'data',md.inversion.vel_obs,'data',md.inversion.vel_obs,'nlines',1,'ncols',2,'title','','figposition',[500 500 1000 500],'axis#all','equal','xlim#all',[0 1],'ylim#all',[0 1],'edgecolor#1','w'); pause(0.5);
-if printingflag, 
+if printingflag,
 	set(gcf,'Color','w')
 	printmodel('mesh1_bamg1','png','margin','on','marginsize',25,'frame','off','resolution',1,'hardcopy','off');
@@ -50,8 +50,8 @@
 
 md.private.bamg=NaN;
-md=bamg(md,'field',md.inversion.vel_obs,'hmin',0.001,'hmax',0.3,'gradation',1.3,'err',10^-4);
-md.inversion.vel_obs=exp(-(sqrt((md.mesh.x+0.1).^2+(md.mesh.y+0.1).^2)-0.75).^2*10^6)+((md.mesh.x+0.1).^2+(md.mesh.y+0.1).^2)/2;
+md=bamg(md,'field',md.inversion.vel_obs,'hmin',0.001,'hmax',0.3,'gradation',1.3,'err',10.^-4);
+md.inversion.vel_obs=exp(-(sqrt((md.mesh.x+0.1).^2+(md.mesh.y+0.1).^2)-0.75).^2*10.^6)+((md.mesh.x+0.1).^2+(md.mesh.y+0.1).^2)/2.;
 plotmodel(md,'data',md.inversion.vel_obs,'data',md.inversion.vel_obs,'nlines',1,'ncols',2,'title','','figposition',[500 500 1000 500],'axis#all','equal','xlim#all',[0 1],'ylim#all',[0 1],'edgecolor#1','w'); pause(0.5);
-if printingflag, 
+if printingflag,
 	set(gcf,'Color','w')
 	printmodel('mesh1_bamg2','png','margin','on','marginsize',25,'frame','off','resolution',1,'hardcopy','off');
@@ -61,7 +61,7 @@
 md.private.bamg=NaN;
 md=bamg(md,'field',md.inversion.vel_obs,'hmin',0.001,'hmax',0.3,'gradation',2.5,'err',0.008);
-md.inversion.vel_obs=exp(-(sqrt((md.mesh.x+0.1).^2+(md.mesh.y+0.1).^2)-0.75).^2*10^6)+((md.mesh.x+0.1).^2+(md.mesh.y+0.1).^2)/2;
+md.inversion.vel_obs=exp(-(sqrt((md.mesh.x+0.1).^2+(md.mesh.y+0.1).^2)-0.75).^2*10.^6)+((md.mesh.x+0.1).^2+(md.mesh.y+0.1).^2)/2.;
 plotmodel(md,'data',md.inversion.vel_obs,'data',md.inversion.vel_obs,'nlines',1,'ncols',2,'title','','figposition',[500 500 1000 500],'axis#all','equal','xlim#all',[0 1],'ylim#all',[0 1],'edgecolor#1','w'); pause(0.5);
-if printingflag, 
+if printingflag,
 	set(gcf,'Color','w')
 	printmodel('mesh1_bamg3','png','margin','on','marginsize',25,'frame','off','resolution',1,'hardcopy','off');
Index: /issm/trunk/test/NightlyRun/test1402.m
===================================================================
--- /issm/trunk/test/NightlyRun/test1402.m	(revision 14309)
+++ /issm/trunk/test/NightlyRun/test1402.m	(revision 14310)
@@ -3,5 +3,5 @@
 
 %create square mesh
-L=1; %in m
+L=1.; %in m
 nx=30; %numberof nodes in x direction
 ny=30;
@@ -10,10 +10,10 @@
 %mesh adaptation loop YAMS
 md=squaremesh(md,L,L,nx,ny);
-u=4*md.mesh.x-2; v=4*md.mesh.y-2;
-md.inversion.vel_obs=tanh(30*(u.^2+v.^2-0.25)) ...
-	+tanh(30*((u-0.75).^2+(v-0.75).^2-0.25)) +tanh(30*((u-0.75).^2+(v+0.75).^2-0.25)) ...
-	+tanh(30*((u+0.75).^2+(v-0.75).^2-0.25)) +tanh(30*((u+0.75).^2+(v+0.75).^2-0.25)) ;
+u=4.*md.mesh.x-2.; v=4.*md.mesh.y-2.;
+md.inversion.vel_obs=tanh(30.*(u.^2+v.^2-0.25)) ...
+	+tanh(30.*((u-0.75).^2+(v-0.75).^2-0.25)) +tanh(30.*((u-0.75).^2+(v+0.75).^2-0.25)) ...
+	+tanh(30.*((u+0.75).^2+(v-0.75).^2-0.25)) +tanh(30.*((u+0.75).^2+(v+0.75).^2-0.25));
 plotmodel(md,'data',md.inversion.vel_obs,'data',md.inversion.vel_obs,'nlines',1,'ncols',2,'title','','figposition',[500 500 1000 500],'axis#all','equal','xlim#all',[0 1],'ylim#all',[0 1],'edgecolor#1','w'); pause(0.5);
-if printingflag, 
+if printingflag,
 	set(gcf,'Color','w')
 	printmodel('mesh2_yams1','png','margin','on','marginsize',25,'frame','off','resolution',1,'hardcopy','off');
@@ -21,11 +21,11 @@
 end
 
-md=YamsCall(md,md.inversion.vel_obs,0.005,0.3,2.3,10^-2);
-u=4*md.mesh.x-2; v=4*md.mesh.y-2;
-md.inversion.vel_obs=tanh(30*(u.^2+v.^2-0.25)) ...
-	+tanh(30*((u-0.75).^2+(v-0.75).^2-0.25)) +tanh(30*((u-0.75).^2+(v+0.75).^2-0.25)) ...
-	+tanh(30*((u+0.75).^2+(v-0.75).^2-0.25)) +tanh(30*((u+0.75).^2+(v+0.75).^2-0.25)) ;
+md=YamsCall(md,md.inversion.vel_obs,0.005,0.3,2.3,10.^-2);
+u=4.*md.mesh.x-2.; v=4.*md.mesh.y-2.;
+md.inversion.vel_obs=tanh(30.*(u.^2+v.^2-0.25)) ...
+	+tanh(30.*((u-0.75).^2+(v-0.75).^2-0.25)) +tanh(30.*((u-0.75).^2+(v+0.75).^2-0.25)) ...
+	+tanh(30.*((u+0.75).^2+(v-0.75).^2-0.25)) +tanh(30.*((u+0.75).^2+(v+0.75).^2-0.25));
 plotmodel(md,'data',md.inversion.vel_obs,'data',md.inversion.vel_obs,'nlines',1,'ncols',2,'title','','figposition',[500 500 1000 500],'axis#all','equal','xlim#all',[0 1],'ylim#all',[0 1],'edgecolor#1','w'); pause(0.5);
-if printingflag, 
+if printingflag,
 	set(gcf,'Color','w')
 	printmodel('mesh2_yams2','png','margin','on','marginsize',25,'frame','off','resolution',1,'hardcopy','off');
@@ -34,10 +34,10 @@
 
 md=YamsCall(md,md.inversion.vel_obs,0.005,0.3,3,0.005);
-u=4*md.mesh.x-2; v=4*md.mesh.y-2;
-md.inversion.vel_obs=tanh(30*(u.^2+v.^2-0.25)) ...
-	+tanh(30*((u-0.75).^2+(v-0.75).^2-0.25)) +tanh(30*((u-0.75).^2+(v+0.75).^2-0.25)) ...
-	+tanh(30*((u+0.75).^2+(v-0.75).^2-0.25)) +tanh(30*((u+0.75).^2+(v+0.75).^2-0.25)) ;
+u=4.*md.mesh.x-2.; v=4.*md.mesh.y-2.;
+md.inversion.vel_obs=tanh(30.*(u.^2+v.^2-0.25)) ...
+	+tanh(30.*((u-0.75).^2+(v-0.75).^2-0.25)) +tanh(30.*((u-0.75).^2+(v+0.75).^2-0.25)) ...
+	+tanh(30.*((u+0.75).^2+(v-0.75).^2-0.25)) +tanh(30.*((u+0.75).^2+(v+0.75).^2-0.25));
 plotmodel(md,'data',md.inversion.vel_obs,'data',md.inversion.vel_obs,'nlines',1,'ncols',2,'title','','figposition',[500 500 1000 500],'axis#all','equal','xlim#all',[0 1],'ylim#all',[0 1],'edgecolor#1','w'); pause(0.5);
-if printingflag, 
+if printingflag,
 	set(gcf,'Color','w')
 	printmodel('mesh2_yams3','png','margin','on','marginsize',25,'frame','off','resolution',1,'hardcopy','off');
@@ -49,10 +49,10 @@
 %mesh adaptation loop BAMG
 md=squaremesh(md,L,L,nx,ny);
-u=4*md.mesh.x-2; v=4*md.mesh.y-2;
-md.inversion.vel_obs=tanh(30*(u.^2+v.^2-0.25)) ...
-	+tanh(30*((u-0.75).^2+(v-0.75).^2-0.25)) +tanh(30*((u-0.75).^2+(v+0.75).^2-0.25)) ...
-	+tanh(30*((u+0.75).^2+(v-0.75).^2-0.25)) +tanh(30*((u+0.75).^2+(v+0.75).^2-0.25)) ;
+u=4.*md.mesh.x-2.; v=4.*md.mesh.y-2.;
+md.inversion.vel_obs=tanh(30.*(u.^2+v.^2-0.25)) ...
+	+tanh(30.*((u-0.75).^2+(v-0.75).^2-0.25)) +tanh(30.*((u-0.75).^2+(v+0.75).^2-0.25)) ...
+	+tanh(30.*((u+0.75).^2+(v-0.75).^2-0.25)) +tanh(30.*((u+0.75).^2+(v+0.75).^2-0.25));
 plotmodel(md,'data',md.inversion.vel_obs,'data',md.inversion.vel_obs,'nlines',1,'ncols',2,'title','','figposition',[500 500 1000 500],'axis#all','equal','xlim#all',[0 1],'ylim#all',[0 1],'edgecolor#1','w'); pause(0.5);
-if printingflag, 
+if printingflag,
 	set(gcf,'Color','w')
 	printmodel('mesh2_bamg1','png','margin','on','marginsize',25,'frame','off','resolution',1,'hardcopy','off');
@@ -61,11 +61,11 @@
 
 md.private.bamg=NaN;
-md=bamg(md,'field',md.inversion.vel_obs,'hmin',0.005,'hmax',0.3,'gradation',2.3,'err',10^-2);
-u=4*md.mesh.x-2; v=4*md.mesh.y-2;
-md.inversion.vel_obs=tanh(30*(u.^2+v.^2-0.25)) ...
-	+tanh(30*((u-0.75).^2+(v-0.75).^2-0.25)) +tanh(30*((u-0.75).^2+(v+0.75).^2-0.25)) ...
-	+tanh(30*((u+0.75).^2+(v-0.75).^2-0.25)) +tanh(30*((u+0.75).^2+(v+0.75).^2-0.25)) ;
+md=bamg(md,'field',md.inversion.vel_obs,'hmin',0.005,'hmax',0.3,'gradation',2.3,'err',10.^-2);
+u=4.*md.mesh.x-2.; v=4.*md.mesh.y-2.;
+md.inversion.vel_obs=tanh(30.*(u.^2+v.^2-0.25)) ...
+	+tanh(30.*((u-0.75).^2+(v-0.75).^2-0.25)) +tanh(30.*((u-0.75).^2+(v+0.75).^2-0.25)) ...
+	+tanh(30.*((u+0.75).^2+(v-0.75).^2-0.25)) +tanh(30.*((u+0.75).^2+(v+0.75).^2-0.25));
 plotmodel(md,'data',md.inversion.vel_obs,'data',md.inversion.vel_obs,'nlines',1,'ncols',2,'title','','figposition',[500 500 1000 500],'axis#all','equal','xlim#all',[0 1],'ylim#all',[0 1],'edgecolor#1','w'); pause(0.5);
-if printingflag, 
+if printingflag,
 	set(gcf,'Color','w')
 	printmodel('mesh2_bamg2','png','margin','on','marginsize',25,'frame','off','resolution',1,'hardcopy','off');
@@ -75,10 +75,10 @@
 md.private.bamg=NaN;
 md=bamg(md,'field',md.inversion.vel_obs,'hmin',0.005,'hmax',0.3,'gradation',3,'err',0.005);
-u=4*md.mesh.x-2; v=4*md.mesh.y-2;
-md.inversion.vel_obs=tanh(30*(u.^2+v.^2-0.25)) ...
-	+tanh(30*((u-0.75).^2+(v-0.75).^2-0.25)) +tanh(30*((u-0.75).^2+(v+0.75).^2-0.25)) ...
-	+tanh(30*((u+0.75).^2+(v-0.75).^2-0.25)) +tanh(30*((u+0.75).^2+(v+0.75).^2-0.25)) ;
+u=4.*md.mesh.x-2.; v=4.*md.mesh.y-2.;
+md.inversion.vel_obs=tanh(30.*(u.^2+v.^2-0.25)) ...
+	+tanh(30.*((u-0.75).^2+(v-0.75).^2-0.25)) +tanh(30.*((u-0.75).^2+(v+0.75).^2-0.25)) ...
+	+tanh(30.*((u+0.75).^2+(v-0.75).^2-0.25)) +tanh(30.*((u+0.75).^2+(v+0.75).^2-0.25));
 plotmodel(md,'data',md.inversion.vel_obs,'data',md.inversion.vel_obs,'nlines',1,'ncols',2,'title','','figposition',[500 500 1000 500],'axis#all','equal','xlim#all',[0 1],'ylim#all',[0 1],'edgecolor#1','w'); pause(0.5);
-if printingflag, 
+if printingflag,
 	set(gcf,'Color','w')
 	printmodel('mesh2_bamg3','png','margin','on','marginsize',25,'frame','off','resolution',1,'hardcopy','off');
@@ -88,10 +88,10 @@
 md.private.bamg=NaN;
 md=bamg(md,'field',md.inversion.vel_obs,'hmin',0.005,'hmax',0.3,'gradation',1.5,'err',0.003,'anisomax',1);
-u=4*md.mesh.x-2; v=4*md.mesh.y-2;
-md.inversion.vel_obs=tanh(30*(u.^2+v.^2-0.25)) ...
-	+tanh(30*((u-0.75).^2+(v-0.75).^2-0.25)) +tanh(30*((u-0.75).^2+(v+0.75).^2-0.25)) ...
-	+tanh(30*((u+0.75).^2+(v-0.75).^2-0.25)) +tanh(30*((u+0.75).^2+(v+0.75).^2-0.25)) ;
+u=4.*md.mesh.x-2.; v=4.*md.mesh.y-2.;
+md.inversion.vel_obs=tanh(30.*(u.^2+v.^2-0.25)) ...
+	+tanh(30.*((u-0.75).^2+(v-0.75).^2-0.25)) +tanh(30.*((u-0.75).^2+(v+0.75).^2-0.25)) ...
+	+tanh(30.*((u+0.75).^2+(v-0.75).^2-0.25)) +tanh(30.*((u+0.75).^2+(v+0.75).^2-0.25));
 plotmodel(md,'data',md.inversion.vel_obs,'data',md.inversion.vel_obs,'nlines',1,'ncols',2,'title','','figposition',[500 500 1000 500],'axis#all','equal','xlim#all',[0 1],'ylim#all',[0 1],'edgecolor#1','w'); pause(0.5);
-if printingflag, 
+if printingflag,
 	set(gcf,'Color','w')
 	printmodel('mesh2_bamgiso','png','margin','on','marginsize',25,'frame','off','resolution',1,'hardcopy','off');
Index: /issm/trunk/test/NightlyRun/test234.m
===================================================================
--- /issm/trunk/test/NightlyRun/test234.m	(revision 14309)
+++ /issm/trunk/test/NightlyRun/test234.m	(revision 14310)
@@ -42,4 +42,7 @@
 md.qmu.method=dakota_method('nond_samp');
 md.qmu.method(end)=dmeth_params_set(md.qmu.method(end),'seed',1234,'samples',20,'sample_type','lhs');
+if (str2num(dakotaversion())>4.2)
+	md.qmu.method(end)=dmeth_params_set(md.qmu.method(end),'rng','rnum2')
+end
 
 %parameters
@@ -59,14 +62,14 @@
 
 %Fields and tolerances to track changes
-md.results.dakota.importancefactors=[];
+md.results.dakota.moments=[];
 for i=1:8,
-	md.results.dakota.importancefactors=[md.results.dakota.importancefactors md.results.dakota.dresp_out(i).mean];
+	md.results.dakota.moments=[md.results.dakota.moments md.results.dakota.dresp_out(i).mean];
 end
 for i=1:8,
-	md.results.dakota.importancefactors=[md.results.dakota.importancefactors md.results.dakota.dresp_out(i).stddev];
+	md.results.dakota.moments=[md.results.dakota.moments md.results.dakota.dresp_out(i).stddev];
 end
-field_names     ={'importancefactors'};
+field_names     ={'moments'};
 field_tolerances={1e-11};
 field_values={...
-         md.results.dakota.importancefactors,...
+         md.results.dakota.moments,...
 	};
Index: /issm/trunk/test/NightlyRun/test235.m
===================================================================
--- /issm/trunk/test/NightlyRun/test235.m	(revision 14309)
+++ /issm/trunk/test/NightlyRun/test235.m	(revision 14310)
@@ -59,14 +59,14 @@
 
 %Fields and tolerances to track changes
-md.results.dakota.importancefactors=[];
+md.results.dakota.moments=[];
 for i=1:8,
-	md.results.dakota.importancefactors=[md.results.dakota.importancefactors md.results.dakota.dresp_out(i).mean];
+	md.results.dakota.moments=[md.results.dakota.moments md.results.dakota.dresp_out(i).mean];
 end
 for i=1:8,
-	md.results.dakota.importancefactors=[md.results.dakota.importancefactors md.results.dakota.dresp_out(i).stddev];
+	md.results.dakota.moments=[md.results.dakota.moments md.results.dakota.dresp_out(i).stddev];
 end
-field_names     ={'importancefactors'};
+field_names     ={'moments'};
 field_tolerances={1e-11};
 field_values={...
-         md.results.dakota.importancefactors,...
+         md.results.dakota.moments,...
 	};
Index: /issm/trunk/test/NightlyRun/test328.m
===================================================================
--- /issm/trunk/test/NightlyRun/test328.m	(revision 14309)
+++ /issm/trunk/test/NightlyRun/test328.m	(revision 14310)
@@ -4,21 +4,9 @@
 md=setflowequation(md,'macayeal','all');
 md.surfaceforcings.issmbgradients=1;
-md.surfaceforcings.smb_pos_max=5000. - 0.00005*md.mesh.x + 0.0001*md.mesh.y;
-md.surfaceforcings.smb_pos_min=1250. + 0.00005*md.mesh.x -0.0001*md.mesh.y;
-md.surfaceforcings.a_pos=15000. - 0.000051*md.mesh.x + 0.00011*md.mesh.y;
 md.surfaceforcings.b_pos=-100. + 0.00005*md.mesh.x - 0.0001*md.mesh.y;
-md.surfaceforcings.a_neg=-20000. - 0.00005*md.mesh.x + 0.0001*md.mesh.y;
 md.surfaceforcings.b_neg=250. + 0.000051*md.mesh.x - 0.00011*md.mesh.y;
-md.surfaceforcings.hc=(md.surfaceforcings.a_pos-md.surfaceforcings.a_neg)./(md.surfaceforcings.b_neg-md.surfaceforcings.b_pos);
+md.surfaceforcings.href=md.geometry.surface;
+md.surfaceforcings.smbref= 1000. - 0.001*md.mesh.x - 0.005*md.mesh.y;
 md.transient.requested_outputs=TotalSmbEnum();
-md.surfaceforcings.href=md.geometry.surface;
-for i=1:size(md.surfaceforcings.hc),
-	if md.geometry.surface(i)<md.surfaceforcings.hc(i)
-		smbref(i)=md.surfaceforcings.a_neg(i)+md.surfaceforcings.b_neg(i)*md.geometry.surface(i);
-	else
-		smbref(i)=md.surfaceforcings.a_pos(i)+md.surfaceforcings.b_pos(i)*md.geometry.surface(i);
-	end
-end
-md.surfaceforcings.smbref=smbref';
 md.cluster=generic('name',oshostname(),'np',3);
 md=solve(md,TransientSolutionEnum());
Index: /issm/trunk/test/NightlyRun/test328.py
===================================================================
--- /issm/trunk/test/NightlyRun/test328.py	(revision 14309)
+++ /issm/trunk/test/NightlyRun/test328.py	(revision 14310)
@@ -15,20 +15,9 @@
 md=setflowequation(md,'macayeal','all')
 md.surfaceforcings.issmbgradients=1
-md.surfaceforcings.smb_pos_max=5000. - 0.00005*md.mesh.x + 0.0001*md.mesh.y
-md.surfaceforcings.smb_pos_min=1250. + 0.00005*md.mesh.x -0.0001*md.mesh.y
-md.surfaceforcings.a_pos=15000. - 0.000051*md.mesh.x + 0.00011*md.mesh.y
 md.surfaceforcings.b_pos=-100. + 0.00005*md.mesh.x - 0.0001*md.mesh.y
-md.surfaceforcings.a_neg=-20000. - 0.00005*md.mesh.x + 0.0001*md.mesh.y
 md.surfaceforcings.b_neg=250. + 0.000051*md.mesh.x - 0.00011*md.mesh.y
-md.surfaceforcings.hc=(md.surfaceforcings.a_pos-md.surfaceforcings.a_neg)/(md.surfaceforcings.b_neg-md.surfaceforcings.b_pos)
 md.transient.requested_outputs=TotalSmbEnum()
 md.surfaceforcings.href=copy.deepcopy(md.geometry.surface).reshape(-1)
-smbref=numpy.empty_like(md.surfaceforcings.hc)
-for i in xrange(numpy.size(md.surfaceforcings.hc,axis=0)):
-	if md.geometry.surface[i]<md.surfaceforcings.hc[i]:
-		smbref[i]=md.surfaceforcings.a_neg[i]+md.surfaceforcings.b_neg[i]*md.geometry.surface[i]
-	else:
-		smbref[i]=md.surfaceforcings.a_pos[i]+md.surfaceforcings.b_pos[i]*md.geometry.surface[i]
-md.surfaceforcings.smbref=smbref
+md.surfaceforcings.smbref= 1000. - 0.001*md.mesh.x - 0.005*md.mesh.y;
 md.cluster=generic('name',oshostname(),'np',3)
 md=solve(md,TransientSolutionEnum())
Index: /issm/trunk/test/NightlyRun/test329.m
===================================================================
--- /issm/trunk/test/NightlyRun/test329.m	(revision 14309)
+++ /issm/trunk/test/NightlyRun/test329.m	(revision 14310)
@@ -5,20 +5,8 @@
 md=setflowequation(md,'pattyn','all');
 md.surfaceforcings.issmbgradients=1;
-md.surfaceforcings.smb_pos_max=5000. - 0.00005*md.mesh.x + 0.0001*md.mesh.y;
-md.surfaceforcings.smb_pos_min=1250. + 0.00005*md.mesh.x -0.0001*md.mesh.y;
-md.surfaceforcings.a_pos=15000. - 0.000051*md.mesh.x + 0.00011*md.mesh.y;
 md.surfaceforcings.b_pos=-100. + 0.00005*md.mesh.x - 0.0001*md.mesh.y;
-md.surfaceforcings.a_neg=-20000. - 0.00005*md.mesh.x + 0.0001*md.mesh.y;
 md.surfaceforcings.b_neg=250. + 0.000051*md.mesh.x - 0.00011*md.mesh.y;
-md.surfaceforcings.hc=(md.surfaceforcings.a_pos-md.surfaceforcings.a_neg)./(md.surfaceforcings.b_neg-md.surfaceforcings.b_pos);
 md.surfaceforcings.href=md.geometry.surface;
-for i=1:size(md.surfaceforcings.hc),
-	if md.geometry.surface(i)<md.surfaceforcings.hc(i)
-		smbref(i)=md.surfaceforcings.a_neg(i)+md.surfaceforcings.b_neg(i)*md.geometry.surface(i);
-	else
-		smbref(i)=md.surfaceforcings.a_pos(i)+md.surfaceforcings.b_pos(i)*md.geometry.surface(i);
-	end
-end
-md.surfaceforcings.smbref=smbref';
+md.surfaceforcings.smbref= 1000. - 0.001*md.mesh.x - 0.005*md.mesh.y;
 md.transient.requested_outputs=TotalSmbEnum();
 md.cluster=generic('name',oshostname(),'np',3);
@@ -26,5 +14,5 @@
 
 %Fields and tolerances to track changes
-field_names     ={'Vx1','Vy1','Vz1','Vel1','Bed1','Surface1','Thickness1','Temperature1','SMB1','TotalSmb1','Vx2','Vy2','Vz2','Vel2','Bed2','Surface2','Thickness2','Temperature2','SMB2','TotalSmb1','Vx3','Vy3','Vz3','Vel3','Bed3','Surface3','Thickness3','Temperature3','SMB3','TotalSmb1'};
+field_names     ={'Vx1','Vy1','Vz1','Vel1','Bed1','Surface1','Thickness1','Temperature1','SMB1','TotalSmb1','Vx2','Vy2','Vz2','Vel2','Bed2','Surface2','Thickness2','Temperature2','SMB2','TotalSmb2','Vx3','Vy3','Vz3','Vel3','Bed3','Surface3','Thickness3','Temperature3','SMB3','TotalSmb3'};
 field_tolerances={1e-09,1e-09,1e-09,1e-09,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,...
Index: /issm/trunk/test/NightlyRun/test329.py
===================================================================
--- /issm/trunk/test/NightlyRun/test329.py	(revision 14309)
+++ /issm/trunk/test/NightlyRun/test329.py	(revision 14310)
@@ -16,19 +16,8 @@
 md=setflowequation(md,'pattyn','all')
 md.surfaceforcings.issmbgradients=1
-md.surfaceforcings.smb_pos_max=5000. - 0.00005*md.mesh.x + 0.0001*md.mesh.y
-md.surfaceforcings.smb_pos_min=1250. + 0.00005*md.mesh.x -0.0001*md.mesh.y
-md.surfaceforcings.a_pos=15000. - 0.000051*md.mesh.x + 0.00011*md.mesh.y
 md.surfaceforcings.b_pos=-100. + 0.00005*md.mesh.x - 0.0001*md.mesh.y
-md.surfaceforcings.a_neg=-20000. - 0.00005*md.mesh.x + 0.0001*md.mesh.y
 md.surfaceforcings.b_neg=250. + 0.000051*md.mesh.x - 0.00011*md.mesh.y
-md.surfaceforcings.hc=(md.surfaceforcings.a_pos-md.surfaceforcings.a_neg)/(md.surfaceforcings.b_neg-md.surfaceforcings.b_pos)
 md.surfaceforcings.href=copy.deepcopy(md.geometry.surface).reshape(-1)
-smbref=numpy.empty_like(md.surfaceforcings.hc)
-for i in xrange(numpy.size(md.surfaceforcings.hc,axis=0)):
-	if md.geometry.surface[i]<md.surfaceforcings.hc[i]:
-		smbref[i]=md.surfaceforcings.a_neg[i]+md.surfaceforcings.b_neg[i]*md.geometry.surface[i]
-	else:
-		smbref[i]=md.surfaceforcings.a_pos[i]+md.surfaceforcings.b_pos[i]*md.geometry.surface[i]
-md.surfaceforcings.smbref=smbref
+md.surfaceforcings.smbref= 1000. - 0.001*md.mesh.x - 0.005*md.mesh.y;
 md.transient.requested_outputs=TotalSmbEnum()
 md.cluster=generic('name',oshostname(),'np',3)
@@ -36,5 +25,5 @@
 
 #Fields and tolerances to track changes
-field_names     =['Vx1','Vy1','Vz1','Vel1','Bed1','Surface1','Thickness1','Temperature1','SMB1','TotalSmb1','Vx2','Vy2','Vz2','Vel2','Bed2','Surface2','Thickness2','Temperature2','SMB2','TotalSmb1','Vx3','Vy3','Vz3','Vel3','Bed3','Surface3','Thickness3','Temperature3','SMB3','TotalSmb1']
+field_names     =['Vx1','Vy1','Vz1','Vel1','Bed1','Surface1','Thickness1','Temperature1','SMB1','TotalSmb1','Vx2','Vy2','Vz2','Vel2','Bed2','Surface2','Thickness2','Temperature2','SMB2','TotalSmb2','Vx3','Vy3','Vz3','Vel3','Bed3','Surface3','Thickness3','Temperature3','SMB3','TotalSmb3']
 field_tolerances=[1e-09,1e-09,1e-09,1e-09,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,\
Index: /issm/trunk/test/NightlyRun/test414.m
===================================================================
--- /issm/trunk/test/NightlyRun/test414.m	(revision 14309)
+++ /issm/trunk/test/NightlyRun/test414.m	(revision 14310)
@@ -55,16 +55,16 @@
 %we recover those mass fluxes through the mean of the response.
 %also, we recover the max velo, which should be 1m/yr. 
-%we put all that data in the importancefactors, which we will use to test for success.
+%we put all that data in the moments, which we will use to test for success.
 %also, check that the stddev are 0.
-md.results.dakota.importancefactors=[];
+md.results.dakota.moments=[];
 for i=1:8,
-	md.results.dakota.importancefactors=[md.results.dakota.importancefactors md.results.dakota.dresp_out(i).mean];
+	md.results.dakota.moments=[md.results.dakota.moments md.results.dakota.dresp_out(i).mean];
 end
 for i=1:8,
-	md.results.dakota.importancefactors=[md.results.dakota.importancefactors md.results.dakota.dresp_out(i).stddev];
+	md.results.dakota.moments=[md.results.dakota.moments md.results.dakota.dresp_out(i).stddev];
 end
-field_names     ={'importancefactors'};
+field_names     ={'moments'};
 field_tolerances={1e-11};
 field_values={...
-         md.results.dakota.importancefactors,...
+         md.results.dakota.moments,...
 	};
Index: /issm/trunk/test/Par/ISMIPA.par
===================================================================
--- /issm/trunk/test/Par/ISMIPA.par	(revision 14309)
+++ /issm/trunk/test/Par/ISMIPA.par	(revision 14310)
@@ -2,21 +2,21 @@
 
 disp('      creating thickness');
-md.geometry.surface=-md.mesh.x*tan(0.5*pi/180);
-md.geometry.bed=md.geometry.surface-1000+500*sin(md.mesh.x*2*pi/max(md.mesh.x)).*sin(md.mesh.y*2*pi/max(md.mesh.x));
+md.geometry.surface=-md.mesh.x*tan(0.5*pi/180.);
+md.geometry.bed=md.geometry.surface-1000.+500.*sin(md.mesh.x*2.*pi/max(md.mesh.x)).*sin(md.mesh.y*2.*pi/max(md.mesh.x));
 md.geometry.thickness=md.geometry.surface-md.geometry.bed;
 
 disp('      creating drag');
-md.friction.coefficient=200*ones(md.mesh.numberofvertices,1); %q=1.
+md.friction.coefficient=200.*ones(md.mesh.numberofvertices,1); %q=1.
 %Take care of iceshelves: no basal drag
 pos=find(md.mask.elementonfloatingice);
-md.friction.coefficient(md.mesh.elements(pos,:))=0;
+md.friction.coefficient(md.mesh.elements(pos,:))=0.;
 md.friction.p=ones(md.mesh.numberofelements,1);
 md.friction.q=ones(md.mesh.numberofelements,1);
 
-disp('      creating flow law paramter');
+disp('      creating flow law parameter');
 md.materials.rheology_B=6.8067*10^7*ones(md.mesh.numberofvertices,1);
-md.materials.rheology_n=3*ones(md.mesh.numberofelements,1);
+md.materials.rheology_n=3.*ones(md.mesh.numberofelements,1);
 
 disp('      boundary conditions for diagnostic model');
-%Create node on boundary fist (because we cannot use mesh)
+%Create node on boundary first (because we cannot use mesh)
 md=SetIceSheetBC(md);
Index: /issm/trunk/test/Par/ISMIPA.py
===================================================================
--- /issm/trunk/test/Par/ISMIPA.py	(revision 14310)
+++ /issm/trunk/test/Par/ISMIPA.py	(revision 14310)
@@ -0,0 +1,25 @@
+import numpy
+from SetIceSheetBC import *
+
+#Ok, start defining model parameters here
+
+print "      creating thickness"
+md.geometry.surface=-md.mesh.x.reshape(-1,1)*numpy.tan(0.5*numpy.pi/180.)
+md.geometry.bed=md.geometry.surface-1000.+500.*numpy.sin(md.mesh.x.reshape(-1,1)*2.*numpy.pi/numpy.max(md.mesh.x))*numpy.sin(md.mesh.y.reshape(-1,1)*2.*numpy.pi/numpy.max(md.mesh.x))
+md.geometry.thickness=md.geometry.surface-md.geometry.bed
+
+print "      creating drag"
+md.friction.coefficient=200.*numpy.ones((md.mesh.numberofvertices,1))    #q=1.
+#Take care of iceshelves: no basal drag
+pos=numpy.nonzero(md.mask.elementonfloatingice)[0]
+md.friction.coefficient[md.mesh.elements[pos,:]-1]=0.
+md.friction.p=numpy.ones((md.mesh.numberofelements,1))
+md.friction.q=numpy.ones((md.mesh.numberofelements,1))
+
+print "      creating flow law parameter"
+md.materials.rheology_B=6.8067*10**7*numpy.ones((md.mesh.numberofvertices,1))
+md.materials.rheology_n=3.*numpy.ones((md.mesh.numberofelements,1))
+
+print "      boundary conditions for diagnostic model"
+#Create node on boundary first (because we cannot use mesh)
+md=SetIceSheetBC(md)
Index: /issm/trunk/test/Par/ISMIPB.par
===================================================================
--- /issm/trunk/test/Par/ISMIPB.par	(revision 14309)
+++ /issm/trunk/test/Par/ISMIPB.par	(revision 14310)
@@ -2,21 +2,21 @@
 
 disp('      creating thickness');
-md.geometry.surface=-md.mesh.x*tan(0.5*pi/180);
-md.geometry.bed=md.geometry.surface-1000+500*sin(md.mesh.x*2*pi/max(md.mesh.x));
+md.geometry.surface=-md.mesh.x*tan(0.5*pi/180.);
+md.geometry.bed=md.geometry.surface-1000.+500.*sin(md.mesh.x*2.*pi/max(md.mesh.x));
 md.geometry.thickness=md.geometry.surface-md.geometry.bed;
 
 disp('      creating drag');
-md.friction.coefficient=200*ones(md.mesh.numberofvertices,1); %q=1.
+md.friction.coefficient=200.*ones(md.mesh.numberofvertices,1); %q=1.
 %Take care of iceshelves: no basal drag
 pos=find(md.mask.elementonfloatingice);
-md.friction.coefficient(md.mesh.elements(pos,:))=0;
+md.friction.coefficient(md.mesh.elements(pos,:))=0.;
 md.friction.p=ones(md.mesh.numberofelements,1);
 md.friction.q=ones(md.mesh.numberofelements,1);
 
-disp('      creating flow law paramter');
+disp('      creating flow law parameter');
 md.materials.rheology_B=6.8067*10^7*ones(md.mesh.numberofvertices,1);
-md.materials.rheology_n=3*ones(md.mesh.numberofelements,1);
+md.materials.rheology_n=3.*ones(md.mesh.numberofelements,1);
 
 disp('      boundary conditions for diagnostic model');
-%Create node on boundary fist (because we cannot use mesh)
+%Create node on boundary first (because we cannot use mesh)
 md=SetIceSheetBC(md);
Index: /issm/trunk/test/Par/ISMIPB.py
===================================================================
--- /issm/trunk/test/Par/ISMIPB.py	(revision 14310)
+++ /issm/trunk/test/Par/ISMIPB.py	(revision 14310)
@@ -0,0 +1,25 @@
+import numpy
+from SetIceSheetBC import *
+
+#Ok, start defining model parameters here
+
+print "      creating thickness"
+md.geometry.surface=-md.mesh.x.reshape(-1,1)*numpy.tan(0.5*numpy.pi/180.)
+md.geometry.bed=md.geometry.surface-1000.+500.*numpy.sin(md.mesh.x.reshape(-1,1)*2.*numpy.pi/numpy.max(md.mesh.x))
+md.geometry.thickness=md.geometry.surface-md.geometry.bed
+
+print "      creating drag"
+md.friction.coefficient=200.*numpy.ones((md.mesh.numberofvertices,1))    #q=1.
+#Take care of iceshelves: no basal drag
+pos=numpy.nonzero(md.mask.elementonfloatingice)[0]
+md.friction.coefficient[md.mesh.elements[pos,:]-1]=0.
+md.friction.p=numpy.ones((md.mesh.numberofelements,1))
+md.friction.q=numpy.ones((md.mesh.numberofelements,1))
+
+print "      creating flow law parameter"
+md.materials.rheology_B=6.8067*10**7*numpy.ones((md.mesh.numberofvertices,1))
+md.materials.rheology_n=3.*numpy.ones((md.mesh.numberofelements,1))
+
+print "      boundary conditions for diagnostic model"
+#Create node on boundary first (because we cannot use mesh)
+md=SetIceSheetBC(md)
Index: /issm/trunk/test/Par/ISMIPC.par
===================================================================
--- /issm/trunk/test/Par/ISMIPC.par	(revision 14309)
+++ /issm/trunk/test/Par/ISMIPC.par	(revision 14310)
@@ -2,22 +2,22 @@
 
 disp('      creating thickness');
-md.geometry.surface=2000-md.mesh.x*tan(0.1*pi/180); %to have z>0
-md.geometry.bed=md.geometry.surface-1000;
+md.geometry.surface=2000.-md.mesh.x*tan(0.1*pi/180.); %to have z>0
+md.geometry.bed=md.geometry.surface-1000.;
 md.geometry.thickness=md.geometry.surface-md.geometry.bed;
 
 disp('      creating drag');
-%md.friction.coefficient=sqrt(md.constants.yts.*(1000+1000*sin(md.mesh.x*2*pi/max(md.mesh.x/2)).*sin(md.mesh.y*2*pi/max(md.mesh.x/2)))./(md.constants.g*(md.materials.rho_ice*md.geometry.thickness+md.materials.rho_water*md.geometry.bed)));
-md.friction.coefficient=sqrt(md.constants.yts.*(1000+1000*sin(md.mesh.x*2*pi/max(md.mesh.x)).*sin(md.mesh.y*2*pi/max(md.mesh.x))));
+%md.friction.coefficient=sqrt(md.constants.yts.*(1000.+1000.*sin(md.mesh.x*2.*pi/max(md.mesh.x/2.)).*sin(md.mesh.y*2.*pi/max(md.mesh.x/2.)))./(md.constants.g*(md.materials.rho_ice*md.geometry.thickness+md.materials.rho_water*md.geometry.bed)));
+md.friction.coefficient=sqrt(md.constants.yts.*(1000.+1000.*sin(md.mesh.x*2.*pi/max(md.mesh.x)).*sin(md.mesh.y*2.*pi/max(md.mesh.x))));
 %Take care of iceshelves: no basal drag
 pos=find(md.mask.elementonfloatingice);
-md.friction.coefficient(md.mesh.elements(pos,:))=0;
+md.friction.coefficient(md.mesh.elements(pos,:))=0.;
 md.friction.p=ones(md.mesh.numberofelements,1);
 md.friction.q=zeros(md.mesh.numberofelements,1);
 
-disp('      creating flow law paramter');
+disp('      creating flow law parameter');
 md.materials.rheology_B=6.8067*10^7*ones(md.mesh.numberofvertices,1);
-md.materials.rheology_n=3*ones(md.mesh.numberofelements,1);
+md.materials.rheology_n=3.*ones(md.mesh.numberofelements,1);
 
-disp('      boundary conditions for diagnostic model: ');
-%Create node on boundary fist (because wi can not use mesh)
+disp('      boundary conditions for diagnostic model:');
+%Create node on boundary first (because we can not use mesh)
 md=SetIceSheetBC(md);
Index: /issm/trunk/test/Par/ISMIPC.py
===================================================================
--- /issm/trunk/test/Par/ISMIPC.py	(revision 14310)
+++ /issm/trunk/test/Par/ISMIPC.py	(revision 14310)
@@ -0,0 +1,26 @@
+import numpy
+from SetIceSheetBC import *
+
+#Ok, start defining model parameters here
+
+print "      creating thickness"
+md.geometry.surface=2000.-md.mesh.x.reshape(-1,1)*numpy.tan(0.1*numpy.pi/180.)    #to have z>0
+md.geometry.bed=md.geometry.surface-1000.
+md.geometry.thickness=md.geometry.surface-md.geometry.bed
+
+print "      creating drag"
+#md.friction.coefficient=sqrt(md.constants.yts.*(1000.+1000.*sin(md.mesh.x*2.*pi/max(md.mesh.x/2.)).*sin(md.mesh.y*2.*pi/max(md.mesh.x/2.)))./(md.constants.g*(md.materials.rho_ice*md.geometry.thickness+md.materials.rho_water*md.geometry.bed)));
+md.friction.coefficient=numpy.sqrt(md.constants.yts*(1000.+1000.*numpy.sin(md.mesh.x.reshape(-1,1)*2.*numpy.pi/numpy.max(md.mesh.x))*numpy.sin(md.mesh.y.reshape(-1,1)*2.*numpy.pi/numpy.max(md.mesh.x))))
+#Take care of iceshelves: no basal drag
+pos=numpy.nonzero(md.mask.elementonfloatingice)[0]
+md.friction.coefficient[md.mesh.elements[pos,:]-1]=0.
+md.friction.p=numpy.ones((md.mesh.numberofelements,1))
+md.friction.q=numpy.zeros((md.mesh.numberofelements,1))
+
+print "      creating flow law parameter"
+md.materials.rheology_B=6.8067*10**7*numpy.ones((md.mesh.numberofvertices,1))
+md.materials.rheology_n=3.*numpy.ones((md.mesh.numberofelements,1))
+
+print "      boundary conditions for diagnostic model:"
+#Create node on boundary first (because we can not use mesh)
+md=SetIceSheetBC(md)
Index: /issm/trunk/test/Par/ISMIPD.par
===================================================================
--- /issm/trunk/test/Par/ISMIPD.par	(revision 14309)
+++ /issm/trunk/test/Par/ISMIPD.par	(revision 14310)
@@ -2,21 +2,21 @@
 
 disp('      creating thickness');
-md.geometry.surface=2000-md.mesh.x*tan(0.1*pi/180); %to have z>0
-md.geometry.bed=md.geometry.surface-1000;
+md.geometry.surface=2000.-md.mesh.x*tan(0.1*pi/180.); %to have z>0
+md.geometry.bed=md.geometry.surface-1000.;
 md.geometry.thickness=md.geometry.surface-md.geometry.bed;
 
 disp('      creating drag');
-md.friction.coefficient=sqrt(md.constants.yts.*(1000+1000*sin(md.mesh.x*2*pi/max(md.mesh.x))));
+md.friction.coefficient=sqrt(md.constants.yts.*(1000.+1000.*sin(md.mesh.x*2.*pi/max(md.mesh.x))));
 %Take care of iceshelves: no basal drag
 pos=find(md.mask.elementonfloatingice);
-md.friction.coefficient(md.mesh.elements(pos,:))=0;
+md.friction.coefficient(md.mesh.elements(pos,:))=0.;
 md.friction.p=ones(md.mesh.numberofelements,1);
 md.friction.q=zeros(md.mesh.numberofelements,1);
 
-disp('      creating flow law paramter');
+disp('      creating flow law parameter');
 md.materials.rheology_B=6.8067*10^7*ones(md.mesh.numberofvertices,1);
-md.materials.rheology_n=3*ones(md.mesh.numberofelements,1);
+md.materials.rheology_n=3.*ones(md.mesh.numberofelements,1);
 
-disp('      boundary conditions for diagnostic model: ');
-%Create node on boundary fist (because wi can not use mesh)
+disp('      boundary conditions for diagnostic model:');
+%Create node on boundary first (because we can not use mesh)
 md=SetIceSheetBC(md);
Index: /issm/trunk/test/Par/ISMIPD.py
===================================================================
--- /issm/trunk/test/Par/ISMIPD.py	(revision 14310)
+++ /issm/trunk/test/Par/ISMIPD.py	(revision 14310)
@@ -0,0 +1,25 @@
+import numpy
+from SetIceSheetBC import *
+
+#Ok, start defining model parameters here
+
+print "      creating thickness"
+md.geometry.surface=2000.-md.mesh.x.reshape(-1,1)*numpy.tan(0.1*numpy.pi/180.)    #to have z>0
+md.geometry.bed=md.geometry.surface-1000.
+md.geometry.thickness=md.geometry.surface-md.geometry.bed
+
+print "      creating drag"
+md.friction.coefficient=numpy.sqrt(md.constants.yts*(1000.+1000.*numpy.sin(md.mesh.x.reshape(-1,1)*2.*numpy.pi/numpy.max(md.mesh.x))))
+#Take care of iceshelves: no basal drag
+pos=numpy.nonzero(md.mask.elementonfloatingice)[0]
+md.friction.coefficient[md.mesh.elements[pos,:]-1]=0.
+md.friction.p=numpy.ones((md.mesh.numberofelements,1))
+md.friction.q=numpy.zeros((md.mesh.numberofelements,1))
+
+print "      creating flow law parameter"
+md.materials.rheology_B=6.8067*10**7*numpy.ones((md.mesh.numberofvertices,1))
+md.materials.rheology_n=3.*numpy.ones((md.mesh.numberofelements,1))
+
+print "      boundary conditions for diagnostic model:"
+#Create node on boundary first (because we can not use mesh)
+md=SetIceSheetBC(md)
Index: /issm/trunk/test/Par/ISMIPE.par
===================================================================
--- /issm/trunk/test/Par/ISMIPE.par	(revision 14309)
+++ /issm/trunk/test/Par/ISMIPE.par	(revision 14310)
@@ -7,9 +7,9 @@
 for i=1:md.mesh.numberofvertices
 	y=md.mesh.y(i);
-	point1=floor(y/100)+1;
+	point1=floor(y/100.)+1;
 	point2=min(point1+1,51);
-	coeff=(y-(point1-1)*100)/100;
-	md.geometry.bed(i)=(1-coeff)*data(point1,2)+coeff*data(point2,2);
-	md.geometry.surface(i)=(1-coeff)*data(point1,3)+coeff*data(point2,3);
+	coeff=(y-(point1-1.)*100.)/100.;
+	md.geometry.bed(i)=(1.-coeff)*data(point1,2)+coeff*data(point2,2);
+	md.geometry.surface(i)=(1.-coeff)*data(point1,3)+coeff*data(point2,3);
 end
 md.geometry.thickness=md.geometry.surface-md.geometry.bed;
@@ -22,9 +22,9 @@
 md.friction.q=ones(md.mesh.numberofelements,1);
 
-disp('      creating flow law paramter');
+disp('      creating flow law parameter');
 md.materials.rheology_B=6.8067*10^7*ones(md.mesh.numberofvertices,1);
-md.materials.rheology_n=3*ones(md.mesh.numberofelements,1);
+md.materials.rheology_n=3.*ones(md.mesh.numberofelements,1);
 
-disp('      boundary conditions for diagnostic model: ');
-%Create node on boundary fist (because wi can not use mesh)
+disp('      boundary conditions for diagnostic model:');
+%Create node on boundary first (because we can not use mesh)
 md=SetIceSheetBC(md);
Index: /issm/trunk/test/Par/ISMIPE.py
===================================================================
--- /issm/trunk/test/Par/ISMIPE.py	(revision 14310)
+++ /issm/trunk/test/Par/ISMIPE.py	(revision 14310)
@@ -0,0 +1,35 @@
+import numpy
+import netCDF4
+from SetIceSheetBC import *
+
+#Ok, start defining model parameters here
+
+print "      creating thickness"
+f = netCDF4.Dataset('../Data/ISMIPE.nc','r')
+data = f.variables['data'][:]
+f.close()
+md.geometry.surface=numpy.zeros((md.mesh.numberofvertices,1))
+md.geometry.bed=numpy.zeros((md.mesh.numberofvertices,1))
+for i in xrange(0,md.mesh.numberofvertices):
+	y=md.mesh.y[i]
+	point1=numpy.floor(y/100.)
+	point2=numpy.minimum(point1+1,50)
+	coeff=(y-(point1-1.)*100.)/100.
+	md.geometry.bed[i]=(1.-coeff)*data[point1,1]+coeff*data[point2,1]
+	md.geometry.surface[i]=(1.-coeff)*data[point1,2]+coeff*data[point2,2]
+md.geometry.thickness=md.geometry.surface-md.geometry.bed
+md.geometry.thickness[numpy.nonzero(numpy.logical_not(md.geometry.thickness))]=0.01
+md.geometry.bed=md.geometry.surface-md.geometry.thickness
+
+print "      creating drag"
+md.friction.coefficient=numpy.zeros((md.mesh.numberofvertices,1))
+md.friction.p=numpy.ones((md.mesh.numberofelements,1))
+md.friction.q=numpy.ones((md.mesh.numberofelements,1))
+
+print "      creating flow law parameter"
+md.materials.rheology_B=6.8067*10**7*numpy.ones((md.mesh.numberofvertices,1))
+md.materials.rheology_n=3.*numpy.ones((md.mesh.numberofelements,1))
+
+print "      boundary conditions for diagnostic model:"
+#Create node on boundary first (because we can not use mesh)
+md=SetIceSheetBC(md)
Index: /issm/trunk/test/Par/ISMIPF.par
===================================================================
--- /issm/trunk/test/Par/ISMIPF.par	(revision 14309)
+++ /issm/trunk/test/Par/ISMIPF.par	(revision 14310)
@@ -3,23 +3,23 @@
 
 disp('      creating thickness');
-md.geometry.surface=-md.mesh.x*tan(3*pi/180);
-%md.geometry.bed=md.geometry.surface-1000;
-md.geometry.bed=md.geometry.surface-1000+100*exp(-((md.mesh.x-max(md.mesh.x)/2).^2+(md.mesh.y-max(md.mesh.y)/2).^2)/(10000^2));
+md.geometry.surface=-md.mesh.x*tan(3.*pi/180.);
+%md.geometry.bed=md.geometry.surface-1000.;
+md.geometry.bed=md.geometry.surface-1000.+100.*exp(-((md.mesh.x-max(md.mesh.x)/2.).^2+(md.mesh.y-max(md.mesh.y)/2.).^2)/(10000.^2));
 md.geometry.thickness=md.geometry.surface-md.geometry.bed;
 
 disp('      creating drag');
-md.friction.coefficient=sqrt(md.constants.yts/(2.140373*10^-7*1000))*ones(md.mesh.numberofvertices,1);
+md.friction.coefficient=sqrt(md.constants.yts/(2.140373*10^-7*1000.))*ones(md.mesh.numberofvertices,1);
 md.friction.p=ones(md.mesh.numberofelements,1);
 md.friction.q=zeros(md.mesh.numberofelements,1);
 
-disp('      creating flow law paramter');
+disp('      creating flow law parameter');
 md.materials.rheology_B=1.4734*10^14*ones(md.mesh.numberofvertices,1);
-md.materials.rheology_n=1*ones(md.mesh.numberofelements,1);
+md.materials.rheology_n=1.*ones(md.mesh.numberofelements,1);
 md.materials.rheology_law='None';
 
 disp('      boundary conditions for diagnostic model');
-%Create node on boundary fist (because we cannot use mesh)
+%Create node on boundary first (because we cannot use mesh)
 md=SetIceSheetBC(md);
-md.diagnostic.spcvx=100*ones(md.mesh.numberofvertices,1);
+md.diagnostic.spcvx=100.*ones(md.mesh.numberofvertices,1);
 md.initialization.vx=zeros(md.mesh.numberofvertices,1);
 md.initialization.vy=zeros(md.mesh.numberofvertices,1);
@@ -27,5 +27,5 @@
 md.initialization.vel=zeros(md.mesh.numberofvertices,1);
 md.initialization.pressure=zeros(md.mesh.numberofvertices,1);
-md.initialization.temperature=255*ones(md.mesh.numberofvertices,1);
+md.initialization.temperature=255.*ones(md.mesh.numberofvertices,1);
 pos=find(md.mesh.x==min(md.mesh.x) | md.mesh.x==max(md.mesh.x) | md.mesh.y==min(md.mesh.y) | md.mesh.y==max(md.mesh.y));
 md.balancethickness.spcthickness=NaN*ones(md.mesh.numberofvertices,1);
@@ -33,5 +33,5 @@
 md.prognostic.spcthickness=NaN*ones(md.mesh.numberofvertices,1);
 md.prognostic.spcthickness(pos)=md.geometry.thickness(pos);
-md.thermal.spctemperature=255*ones(md.mesh.numberofvertices,1);
+md.thermal.spctemperature=255.*ones(md.mesh.numberofvertices,1);
 md.basalforcings.geothermalflux=0.4*ones(md.mesh.numberofvertices,1);
 
@@ -40,6 +40,6 @@
 
 %Transient options
-md.timestepping.time_step=1;
-md.timestepping.final_time=10;
+md.timestepping.time_step=1.;
+md.timestepping.final_time=10.;
 md.prognostic.stabilization=1;
 md.thermal.stabilization=1;
Index: /issm/trunk/test/Par/ISMIPF.py
===================================================================
--- /issm/trunk/test/Par/ISMIPF.py	(revision 14310)
+++ /issm/trunk/test/Par/ISMIPF.py	(revision 14310)
@@ -0,0 +1,49 @@
+import numpy
+from SetIceSheetBC import *
+
+#Ok, start defining model parameters here
+md.verbose=2
+
+print "      creating thickness"
+md.geometry.surface=-md.mesh.x.reshape(-1,1)*numpy.tan(3.*numpy.pi/180.)
+#md.geometry.bed=md.geometry.surface-1000.
+md.geometry.bed=md.geometry.surface-1000.+100.*numpy.exp(-((md.mesh.x.reshape(-1,1)-numpy.max(md.mesh.x)/2.)**2+(md.mesh.y.reshape(-1,1)-numpy.max(md.mesh.y)/2.)**2)/(10000.**2))
+md.geometry.thickness=md.geometry.surface-md.geometry.bed
+
+print "      creating drag"
+md.friction.coefficient=numpy.sqrt(md.constants.yts/(2.140373*10**-7*1000.))*numpy.ones((md.mesh.numberofvertices,1))
+md.friction.p=numpy.ones((md.mesh.numberofelements,1))
+md.friction.q=numpy.zeros((md.mesh.numberofelements,1))
+
+print "      creating flow law parameter"
+md.materials.rheology_B=1.4734*10**14*numpy.ones((md.mesh.numberofvertices,1))
+md.materials.rheology_n=1.*numpy.ones((md.mesh.numberofelements,1))
+md.materials.rheology_law='None'
+
+print "      boundary conditions for diagnostic model"
+#Create node on boundary first (because we cannot use mesh)
+md=SetIceSheetBC(md)
+md.diagnostic.spcvx=100.*numpy.ones((md.mesh.numberofvertices,1))
+md.initialization.vx=numpy.zeros((md.mesh.numberofvertices,1))
+md.initialization.vy=numpy.zeros((md.mesh.numberofvertices,1))
+md.initialization.vz=numpy.zeros((md.mesh.numberofvertices,1))
+md.initialization.vel=numpy.zeros((md.mesh.numberofvertices,1))
+md.initialization.pressure=numpy.zeros((md.mesh.numberofvertices,1))
+md.initialization.temperature=255.*numpy.ones((md.mesh.numberofvertices,1))
+pos=numpy.nonzero(numpy.logical_or(numpy.logical_or(md.mesh.x==numpy.min(md.mesh.x),md.mesh.x==numpy.max(md.mesh.x)),numpy.logical_or(md.mesh.y==numpy.min(md.mesh.y),md.mesh.y==numpy.max(md.mesh.y))))
+md.balancethickness.spcthickness=float('NaN')*numpy.ones((md.mesh.numberofvertices,1))
+md.balancethickness.spcthickness[pos]=md.geometry.thickness[pos]
+md.prognostic.spcthickness=float('NaN')*numpy.ones((md.mesh.numberofvertices,1))
+md.prognostic.spcthickness[pos]=md.geometry.thickness[pos]
+md.thermal.spctemperature=255.*numpy.ones((md.mesh.numberofvertices,1))
+md.basalforcings.geothermalflux=0.4*numpy.ones((md.mesh.numberofvertices,1))
+
+#Parallel options
+md.mesh.average_vertex_connectivity=200
+
+#Transient options
+md.timestepping.time_step=1.
+md.timestepping.final_time=10.
+md.prognostic.stabilization=1
+md.thermal.stabilization=1
+md.thermal.penalty_threshold=10**5
Index: /issm/trunk/test/Par/Pig.py
===================================================================
--- /issm/trunk/test/Par/Pig.py	(revision 14309)
+++ /issm/trunk/test/Par/Pig.py	(revision 14310)
@@ -48,5 +48,5 @@
 md.prognostic.stabilization=1.
 md.verbose=verbose(0)
-md.settings.waitonlock=30.
+md.settings.waitonlock=30
 md.timestepping.time_step=1.
 md.timestepping.final_time=2.
Index: /issm/trunk/test/Par/RoundSheetEISMINT.par
===================================================================
--- /issm/trunk/test/Par/RoundSheetEISMINT.par	(revision 14309)
+++ /issm/trunk/test/Par/RoundSheetEISMINT.par	(revision 14310)
@@ -1,10 +1,10 @@
 %Ok, start defining model parameters here
 disp('      creating thickness');
-md.geometry.thickness=10*ones(md.mesh.numberofvertices,1);
+md.geometry.thickness=10.*ones(md.mesh.numberofvertices,1);
 md.geometry.bed=zeros(md.mesh.numberofvertices,1);
 md.geometry.surface=md.geometry.bed+md.geometry.thickness;
 
 disp('      creating drag');
-md.friction.coefficient=20*ones(md.mesh.numberofvertices,1); %q=1. %no drag is specified in the analytical solution
+md.friction.coefficient=20.*ones(md.mesh.numberofvertices,1); %q=1. no drag is specified in the analytical solution
 md.friction.p=ones(md.mesh.numberofelements,1);
 md.friction.q=ones(md.mesh.numberofelements,1);
@@ -12,23 +12,23 @@
 disp('      creating temperatures');
 tmin=238.15; %K
-st=1.67*10^-2/1000; %k/m;
+st=1.67*10^-2/1000.; %k/m
 radius=sqrt((md.mesh.x).^2+(md.mesh.y).^2);
 md.initialization.temperature=(tmin+st*radius);
 md.basalforcings.geothermalflux=4.2*10^-2*ones(md.mesh.numberofvertices,1);
 
-disp('      creating flow law paramter');
-md.materials.rheology_B=6.81*10^(7)*ones(md.mesh.numberofvertices,1); %to have the same B as the analytical solution 
-md.materials.rheology_n=3*ones(md.mesh.numberofelements,1);
+disp('      creating flow law parameter');
+md.materials.rheology_B=6.81*10^7*ones(md.mesh.numberofvertices,1); %to have the same B as the analytical solution 
+md.materials.rheology_n=3.*ones(md.mesh.numberofelements,1);
 
 disp('      creating surface mass balance');
 smb_max=0.5; %m/yr
-sb=10^-2/1000; %m/yr/m
-rel=450*1000; %m
+sb=10^-2/1000.; %m/yr/m
+rel=450.*1000.; %m
 md.surfaceforcings.mass_balance=min(smb_max,sb*(rel-radius));
 
 disp('      creating velocities');
 constant=0.3;
-md.inversion.vx_obs=constant/2*md.mesh.x.*(md.geometry.thickness).^-1;
-md.inversion.vy_obs=constant/2*md.mesh.y.*(md.geometry.thickness).^-1;
+md.inversion.vx_obs=constant/2.*md.mesh.x.*(md.geometry.thickness).^-1;
+md.inversion.vy_obs=constant/2.*md.mesh.y.*(md.geometry.thickness).^-1;
 md.inversion.vel_obs=(sqrt((md.inversion.vx_obs).^2+(md.inversion.vy_obs).^2));
 md.initialization.vx=zeros(md.mesh.numberofvertices,1);
@@ -38,22 +38,22 @@
 
 %Deal with boundary conditions:
-disp('      boundary conditions for diagnostic model: ');
+disp('      boundary conditions for diagnostic model:');
 md=SetMarineIceSheetBC(md,'../Exp/RoundFrontEISMINT.exp');
 
-radius=sqrt((md.mesh.x).*md.mesh.x+(md.mesh.y).*md.mesh.y);
+radius=sqrt((md.mesh.x).^2+(md.mesh.y).^2);
 pos=find(radius==min(radius));
-md.mesh.x(pos)=0; md.mesh.y(pos)=0; %the closest node to the center is changed to be exactly at the center
+md.mesh.x(pos)=0.; md.mesh.y(pos)=0.; %the closest node to the center is changed to be exactly at the center
 
-md.diagnostic.spcvx(pos)=0;
-md.diagnostic.spcvy(pos)=0;
-md.diagnostic.spcvz(pos)=0;
+md.diagnostic.spcvx(pos)=0.;
+md.diagnostic.spcvy(pos)=0.;
+md.diagnostic.spcvz(pos)=0.;
 
 %parallel options
-md.timestepping.final_time=50000;
+md.timestepping.final_time=50000.;
 
 %Constants
-md.materials.rho_ice=910;
+md.materials.rho_ice=910.;
 md.materials.thermalconductivity=2.1;
 md.materials.latentheat=3.35*10^5;
 md.materials.beta=8.66*10^-4/(md.materials.rho_ice*md.constants.g); %conversion from K/m to K/Pa
-md.constants.yts=31556926;
+md.constants.yts=31556926.;
Index: /issm/trunk/test/Par/RoundSheetEISMINT.py
===================================================================
--- /issm/trunk/test/Par/RoundSheetEISMINT.py	(revision 14310)
+++ /issm/trunk/test/Par/RoundSheetEISMINT.py	(revision 14310)
@@ -0,0 +1,63 @@
+import numpy
+from SetMarineIceSheetBC import *
+
+#Ok, start defining model parameters here
+print "      creating thickness"
+md.geometry.thickness=10.*numpy.ones((md.mesh.numberofvertices,1))
+md.geometry.bed=numpy.zeros((md.mesh.numberofvertices,1))
+md.geometry.surface=md.geometry.bed+md.geometry.thickness
+
+print "      creating drag"
+md.friction.coefficient=20.*numpy.ones((md.mesh.numberofvertices,1))    #q=1. no drag is specified in the analytical solution
+md.friction.p=numpy.ones((md.mesh.numberofelements,1))
+md.friction.q=numpy.ones((md.mesh.numberofelements,1))
+
+print "      creating temperatures"
+tmin=238.15    #K
+st=1.67*10**-2/1000.    #k/m
+radius=numpy.sqrt((md.mesh.x)**2+(md.mesh.y)**2).reshape(-1,1)
+md.initialization.temperature=tmin+st*radius
+md.basalforcings.geothermalflux=4.2*10**-2*numpy.ones((md.mesh.numberofvertices,1))
+
+print "      creating flow law parameter"
+md.materials.rheology_B=6.81*10**7*numpy.ones((md.mesh.numberofvertices,1))    #to have the same B as the analytical solution 
+md.materials.rheology_n=3.*numpy.ones((md.mesh.numberofelements,1))
+
+print "      creating surface mass balance"
+smb_max=0.5    #m/yr
+sb=10**-2/1000.    #m/yr/m
+rel=450.*1000.    #m
+md.surfaceforcings.mass_balance=numpy.minimum(smb_max*numpy.ones_like(radius),sb*(rel-radius))
+
+print "      creating velocities"
+constant=0.3
+md.inversion.vx_obs=constant/2.*md.mesh.x.reshape(-1,1)*(md.geometry.thickness)**-1
+md.inversion.vy_obs=constant/2.*md.mesh.y.reshape(-1,1)*(md.geometry.thickness)**-1
+md.inversion.vel_obs=numpy.sqrt((md.inversion.vx_obs)**2+(md.inversion.vy_obs)**2)
+md.initialization.vx=numpy.zeros((md.mesh.numberofvertices,1))
+md.initialization.vy=numpy.zeros((md.mesh.numberofvertices,1))
+md.initialization.vz=numpy.zeros((md.mesh.numberofvertices,1))
+md.initialization.pressure=numpy.zeros((md.mesh.numberofvertices,1))
+
+#Deal with boundary conditions:
+print "      boundary conditions for diagnostic model:"
+md=SetMarineIceSheetBC(md,'../Exp/RoundFrontEISMINT.exp')
+
+radius=numpy.sqrt((md.mesh.x)**2+(md.mesh.y)**2)
+pos=numpy.nonzero(radius==numpy.min(radius))[0]
+md.mesh.x[pos]=0.
+md.mesh.y[pos]=0.    #the closest node to the center is changed to be exactly at the center
+
+md.diagnostic.spcvx[pos]=0.
+md.diagnostic.spcvy[pos]=0.
+md.diagnostic.spcvz[pos]=0.
+
+#parallel options
+md.timestepping.final_time=50000.
+
+#Constants
+md.materials.rho_ice=910.
+md.materials.thermalconductivity=2.1
+md.materials.latentheat=3.35*10**5
+md.materials.beta=8.66*10**-4/(md.materials.rho_ice*md.constants.g)    #conversion from K/m to K/Pa
+md.constants.yts=31556926.
Index: /issm/trunk/test/Par/RoundSheetStaticEISMINT.par
===================================================================
--- /issm/trunk/test/Par/RoundSheetStaticEISMINT.par	(revision 14309)
+++ /issm/trunk/test/Par/RoundSheetStaticEISMINT.par	(revision 14310)
@@ -2,15 +2,16 @@
 hmin=0.01;
 hmax=2756.7;
-radius=(sqrt((md.mesh.x).^2+(md.mesh.y).^2));
+radius=sqrt((md.mesh.x).^2+(md.mesh.y).^2);
 radiusmax=max(radius);
-md.geometry.thickness=hmin*ones(size(md.mesh.x,1),1)+hmax*(4*((1/2)^(4/3)*ones(size(md.mesh.x,1),1)-((radius)./(2*radiusmax)).^(4/3))).^(3/8);
-md.geometry.bed=0*md.geometry.thickness;
+radius(find(radius>(1.-10^-9)*radiusmax))=radiusmax;    %eliminate roundoff issues in next statement
+md.geometry.thickness=hmin*ones(size(md.mesh.x,1),1)+hmax*(4.*((1./2.)^(4./3.)*ones(size(md.mesh.x,1),1)-((radius)./(2.*radiusmax)).^(4./3.))).^(3./8.);
+md.geometry.bed=0.*md.geometry.thickness;
 md.geometry.surface=md.geometry.bed+md.geometry.thickness;
 
 disp('      creating drag');
-md.friction.coefficient=20*ones(md.mesh.numberofvertices,1); %q=1. %no drag is specified in the analytical solution
+md.friction.coefficient=20.*ones(md.mesh.numberofvertices,1); %q=1. no drag is specified in the analytical solution
 %Take care of iceshelves: no basal drag
 pos=find(md.mask.elementonfloatingice);
-md.friction.coefficient(md.mesh.elements(pos,:))=0;
+md.friction.coefficient(md.mesh.elements(pos,:))=0.;
 md.friction.p=ones(md.mesh.numberofelements,1);
 md.friction.q=ones(md.mesh.numberofelements,1);
@@ -18,23 +19,23 @@
 disp('      creating temperatures');
 tmin=238.15; %K
-st=1.67*10^-2/1000; %k/m;
-md.initialization.temperature=(tmin+st*radius);
+st=1.67*10^-2/1000.; %k/m
+md.initialization.temperature=tmin+st*radius;
 md.basalforcings.geothermalflux=4.2*10^-2*ones(md.mesh.numberofvertices,1);
 
-disp('      creating flow law paramter');
-md.materials.rheology_B=6.81*10^(7)*ones(md.mesh.numberofvertices,1); %to have the same B as the analytical solution 
-md.materials.rheology_n=3*ones(md.mesh.numberofelements,1);
+disp('      creating flow law parameter');
+md.materials.rheology_B=6.81*10^7*ones(md.mesh.numberofvertices,1); %to have the same B as the analytical solution 
+md.materials.rheology_n=3.*ones(md.mesh.numberofelements,1);
 
 disp('      creating surface mass balance');
 smb_max=0.5; %m/yr
-sb=10^-2/1000; %m/yr/m
-rel=450*1000; %m
+sb=10^-2/1000.; %m/yr/m
+rel=450.*1000.; %m
 md.surfaceforcings.mass_balance=min(smb_max,sb*(rel-radius));
 
 disp('      creating velocities');
 constant=0.3;
-md.inversion.vx_obs=constant/2*md.mesh.x.*(md.geometry.thickness).^-1;
-md.inversion.vy_obs=constant/2*md.mesh.y.*(md.geometry.thickness).^-1;
-md.inversion.vel_obs=(sqrt((md.inversion.vx_obs).^2+(md.inversion.vy_obs).^2));
+md.inversion.vx_obs=constant/2.*md.mesh.x.*(md.geometry.thickness).^-1;
+md.inversion.vy_obs=constant/2.*md.mesh.y.*(md.geometry.thickness).^-1;
+md.inversion.vel_obs=sqrt((md.inversion.vx_obs).^2+(md.inversion.vy_obs).^2);
 md.initialization.vx=zeros(md.mesh.numberofvertices,1);
 md.initialization.vy=zeros(md.mesh.numberofvertices,1);
@@ -43,12 +44,12 @@
 
 %Deal with boundary conditions:
-disp('      boundary conditions for diagnostic model: ');
+disp('      boundary conditions for diagnostic model:');
 md=SetMarineIceSheetBC(md,'../Exp/RoundFrontEISMINT.exp');
 
-radius=sqrt((md.mesh.x).*md.mesh.x+(md.mesh.y).*md.mesh.y);
+radius=sqrt((md.mesh.x).^2+(md.mesh.y).^2);
 pos=find(radius==min(radius));
-md.mesh.x(pos)=0; md.mesh.y(pos)=0; %the closest node to the center is changed to be exactly at the center
+md.mesh.x(pos)=0.; md.mesh.y(pos)=0.; %the closest node to the center is changed to be exactly at the center
 
-md.diagnostic.spcvx(pos)=0;
-md.diagnostic.spcvy(pos)=0;
-md.diagnostic.spcvz(pos)=0;
+md.diagnostic.spcvx(pos)=0.;
+md.diagnostic.spcvy(pos)=0.;
+md.diagnostic.spcvz(pos)=0.;
Index: /issm/trunk/test/Par/RoundSheetStaticEISMINT.py
===================================================================
--- /issm/trunk/test/Par/RoundSheetStaticEISMINT.py	(revision 14310)
+++ /issm/trunk/test/Par/RoundSheetStaticEISMINT.py	(revision 14310)
@@ -0,0 +1,59 @@
+import numpy
+from SetMarineIceSheetBC import *
+
+print "      creating thickness"
+hmin=0.01
+hmax=2756.7
+radius=numpy.sqrt((md.mesh.x)**2+(md.mesh.y)**2).reshape(-1,1)
+radiusmax=numpy.max(radius)
+radius[numpy.nonzero(radius>(1.-10**-9)*radiusmax)]=radiusmax    #eliminate roundoff issues in next statement
+md.geometry.thickness=hmin*numpy.ones((numpy.size(md.mesh.x),1))+hmax*(4.*((1./2.)**(4./3.)*numpy.ones((numpy.size(md.mesh.x),1))-((radius)/(2.*radiusmax))**(4./3.)))**(3./8.)
+md.geometry.bed=0.*md.geometry.thickness
+md.geometry.surface=md.geometry.bed+md.geometry.thickness
+
+print "      creating drag"
+md.friction.coefficient=20.*numpy.ones((md.mesh.numberofvertices,1))    #q=1. no drag is specified in the analytical solution
+#Take care of iceshelves: no basal drag
+pos=numpy.nonzero(md.mask.elementonfloatingice)[0]
+md.friction.coefficient[md.mesh.elements[pos,:]-1]=0.
+md.friction.p=numpy.ones((md.mesh.numberofelements,1))
+md.friction.q=numpy.ones((md.mesh.numberofelements,1))
+
+print "      creating temperatures"
+tmin=238.15    #K
+st=1.67*10**-2/1000.    #k/m
+md.initialization.temperature=tmin+st*radius
+md.basalforcings.geothermalflux=4.2*10**-2*numpy.ones((md.mesh.numberofvertices,1))
+
+print "      creating flow law parameter"
+md.materials.rheology_B=6.81*10**7*numpy.ones((md.mesh.numberofvertices,1))    #to have the same B as the analytical solution 
+md.materials.rheology_n=3.*numpy.ones((md.mesh.numberofelements,1))
+
+print "      creating surface mass balance"
+smb_max=0.5    #m/yr
+sb=10**-2/1000.    #m/yr/m
+rel=450.*1000.    #m
+md.surfaceforcings.mass_balance=numpy.minimum(smb_max*numpy.ones_like(radius),sb*(rel-radius))
+
+print "      creating velocities"
+constant=0.3
+md.inversion.vx_obs=constant/2.*md.mesh.x.reshape(-1,1)*(md.geometry.thickness)**-1
+md.inversion.vy_obs=constant/2.*md.mesh.y.reshape(-1,1)*(md.geometry.thickness)**-1
+md.inversion.vel_obs=numpy.sqrt((md.inversion.vx_obs)**2+(md.inversion.vy_obs)**2)
+md.initialization.vx=numpy.zeros((md.mesh.numberofvertices,1))
+md.initialization.vy=numpy.zeros((md.mesh.numberofvertices,1))
+md.initialization.vz=numpy.zeros((md.mesh.numberofvertices,1))
+md.initialization.pressure=numpy.zeros((md.mesh.numberofvertices,1))
+
+#Deal with boundary conditions:
+print "      boundary conditions for diagnostic model:"
+md=SetMarineIceSheetBC(md,'../Exp/RoundFrontEISMINT.exp')
+
+radius=numpy.sqrt((md.mesh.x)**2+(md.mesh.y)**2)
+pos=numpy.nonzero(radius==numpy.min(radius))[0]
+md.mesh.x[pos]=0.
+md.mesh.y[pos]=0.    #the closest node to the center is changed to be exactly at the center
+
+md.diagnostic.spcvx[pos]=0.
+md.diagnostic.spcvy[pos]=0.
+md.diagnostic.spcvz[pos]=0.
Index: /issm/trunk/test/Par/SquareEISMINT.par
===================================================================
--- /issm/trunk/test/Par/SquareEISMINT.par	(revision 14309)
+++ /issm/trunk/test/Par/SquareEISMINT.par	(revision 14310)
@@ -4,18 +4,18 @@
 ymin=min(md.mesh.y);
 ymax=max(md.mesh.y);
-md.geometry.thickness=500*ones(md.mesh.numberofvertices,1);
+md.geometry.thickness=500.*ones(md.mesh.numberofvertices,1);
 md.geometry.bed=-md.materials.rho_ice/md.materials.rho_water*md.geometry.thickness;
 md.geometry.surface=md.geometry.bed+md.geometry.thickness;
 
 disp('      creating drag');
-md.friction.coefficient=200*ones(md.mesh.numberofvertices,1); %q=1.
+md.friction.coefficient=200.*ones(md.mesh.numberofvertices,1); %q=1.
 %Take care of iceshelves: no basal drag
 pos=find(md.mask.elementonfloatingice);
-md.friction.coefficient(md.mesh.elements(pos,:))=0;
+md.friction.coefficient(md.mesh.elements(pos,:))=0.;
 md.friction.p=ones(md.mesh.numberofelements,1);
 md.friction.q=ones(md.mesh.numberofelements,1);
 
 disp('      creating initial values');
-md.initialization.temperature=(273-20)*ones(md.mesh.numberofvertices,1);
+md.initialization.temperature=(273.-20.)*ones(md.mesh.numberofvertices,1);
 md.initialization.vx=zeros(md.mesh.numberofvertices,1);
 md.initialization.vy=zeros(md.mesh.numberofvertices,1);
@@ -24,23 +24,23 @@
 md.initialization.pressure=zeros(md.mesh.numberofvertices,1);
 
-disp('      creating flow law paramter');
+disp('      creating flow law parameter');
 md.materials.rheology_B=1.7687*10^8*ones(md.mesh.numberofvertices,1);
-md.materials.rheology_n=3*ones(md.mesh.numberofelements,1);
+md.materials.rheology_n=3.*ones(md.mesh.numberofelements,1);
 
 disp('      creating surface mass balance');
 md.surfaceforcings.mass_balance=0.2*ones(md.mesh.numberofvertices,1); %0m/a
-md.basalforcings.melting_rate=0*ones(md.mesh.numberofvertices,1); %0m/a
+md.basalforcings.melting_rate=0.*ones(md.mesh.numberofvertices,1); %0m/a
 
-disp('      boundary conditions ');
+disp('      boundary conditions');
 md=SetMarineIceSheetBC(md,'../Exp/SquareFrontEISMINT.exp');
 
 %Evolution of the ice shelf
-pos=find(md.mesh.y==200000); %nodes on the upper boundary condition
+pos=find(md.mesh.y==200000.); %nodes on the upper boundary condition
 md.balancethickness.spcthickness=NaN*ones(md.mesh.numberofvertices,1);
-md.balancethickness.spcthickness(pos)=500;
+md.balancethickness.spcthickness(pos)=500.;
 md.prognostic.spcthickness=NaN*ones(md.mesh.numberofvertices,1);
-md.prognostic.spcthickness(pos)=500;
+md.prognostic.spcthickness(pos)=500.;
 md.prognostic.stabilization=0; %Better result with no artificial diffusivity
-md.thermal.stabilization=0; 
-md.timestepping.final_time=500;
+md.thermal.stabilization=0;
+md.timestepping.final_time=500.;
 md.timestepping.time_step=1;
Index: /issm/trunk/test/Par/SquareEISMINT.py
===================================================================
--- /issm/trunk/test/Par/SquareEISMINT.py	(revision 14310)
+++ /issm/trunk/test/Par/SquareEISMINT.py	(revision 14310)
@@ -0,0 +1,49 @@
+import numpy
+from SetMarineIceSheetBC import *
+
+#Ok, start defining model parameters here
+
+print "      creating thickness"
+ymin=numpy.min(md.mesh.y)
+ymax=numpy.max(md.mesh.y)
+md.geometry.thickness=500.*numpy.ones((md.mesh.numberofvertices,1))
+md.geometry.bed=-md.materials.rho_ice/md.materials.rho_water*md.geometry.thickness
+md.geometry.surface=md.geometry.bed+md.geometry.thickness
+
+print "      creating drag"
+md.friction.coefficient=200.*numpy.ones((md.mesh.numberofvertices,1))    #q=1.
+#Take care of iceshelves: no basal drag
+pos=numpy.nonzero(md.mask.elementonfloatingice)[0]
+md.friction.coefficient[md.mesh.elements[pos,:]-1]=0.
+md.friction.p=numpy.ones((md.mesh.numberofelements,1))
+md.friction.q=numpy.ones((md.mesh.numberofelements,1))
+
+print "      creating initial values"
+md.initialization.temperature=(273.-20.)*numpy.ones((md.mesh.numberofvertices,1))
+md.initialization.vx=numpy.zeros((md.mesh.numberofvertices,1))
+md.initialization.vy=numpy.zeros((md.mesh.numberofvertices,1))
+md.initialization.vz=numpy.zeros((md.mesh.numberofvertices,1))
+md.initialization.vel=numpy.zeros((md.mesh.numberofvertices,1))
+md.initialization.pressure=numpy.zeros((md.mesh.numberofvertices,1))
+
+print "      creating flow law parameter"
+md.materials.rheology_B=1.7687*10**8*numpy.ones((md.mesh.numberofvertices,1))
+md.materials.rheology_n=3.*numpy.ones((md.mesh.numberofelements,1))
+
+print "      creating surface mass balance"
+md.surfaceforcings.mass_balance=0.2*numpy.ones((md.mesh.numberofvertices,1))    #0m/a
+md.basalforcings.melting_rate=0.*numpy.ones((md.mesh.numberofvertices,1))    #0m/a
+
+print "      boundary conditions"
+md=SetMarineIceSheetBC(md,'../Exp/SquareFrontEISMINT.exp')
+
+#Evolution of the ice shelf
+pos=numpy.nonzero(md.mesh.y==200000.)    #nodes on the upper boundary condition
+md.balancethickness.spcthickness=float('NaN')*numpy.ones((md.mesh.numberofvertices,1))
+md.balancethickness.spcthickness[pos]=500.
+md.prognostic.spcthickness=float('NaN')*numpy.ones((md.mesh.numberofvertices,1))
+md.prognostic.spcthickness[pos]=500.
+md.prognostic.stabilization=0    #Better result with no artificial diffusivity
+md.thermal.stabilization=0
+md.timestepping.final_time=500.
+md.timestepping.time_step=1
Index: /issm/trunk/test/Par/SquareSheetConstrained.py
===================================================================
--- /issm/trunk/test/Par/SquareSheetConstrained.py	(revision 14309)
+++ /issm/trunk/test/Par/SquareSheetConstrained.py	(revision 14310)
@@ -51,5 +51,5 @@
 md.thermal.stabilization=1.
 md.verbose=verbose(0)
-md.settings.waitonlock=30.
+md.settings.waitonlock=30
 md.diagnostic.restol=0.05
 md.steadystate.reltol=0.05
Index: /issm/trunk/test/Par/SquareSheetShelf.py
===================================================================
--- /issm/trunk/test/Par/SquareSheetShelf.py	(revision 14309)
+++ /issm/trunk/test/Par/SquareSheetShelf.py	(revision 14310)
@@ -57,5 +57,5 @@
 md.thermal.stabilization=1
 md.verbose=verbose(0)
-md.settings.waitonlock=30.
+md.settings.waitonlock=30
 md.diagnostic.restol=0.05
 md.steadystate.reltol=0.05
Index: /issm/trunk/test/Par/SquareShelf.py
===================================================================
--- /issm/trunk/test/Par/SquareShelf.py	(revision 14309)
+++ /issm/trunk/test/Par/SquareShelf.py	(revision 14310)
@@ -70,5 +70,5 @@
 md.prognostic.stabilization = 1.
 md.thermal.stabilization = 1.
-md.settings.waitonlock = 30.
+md.settings.waitonlock = 30
 md.verbose=verbose()
 md.diagnostic.restol = 0.10
Index: /issm/trunk/test/Par/SquareShelfConstrained.py
===================================================================
--- /issm/trunk/test/Par/SquareShelfConstrained.py	(revision 14309)
+++ /issm/trunk/test/Par/SquareShelfConstrained.py	(revision 14310)
@@ -55,5 +55,5 @@
 md.thermal.stabilization=1.
 md.verbose = verbose(0)
-md.settings.waitonlock=30.
+md.settings.waitonlock=30
 md.diagnostic.restol=0.05
 md.diagnostic.reltol=0.05
Index: /issm/trunk/test/Par/SquareThermal.par
===================================================================
--- /issm/trunk/test/Par/SquareThermal.par	(revision 14309)
+++ /issm/trunk/test/Par/SquareThermal.par	(revision 14310)
@@ -4,7 +4,7 @@
 
 disp('      creating thickness');
-h=1000;
+h=1000.;
 md.geometry.thickness=h*ones(md.mesh.numberofvertices,1);
-md.geometry.bed=-1000*ones(md.mesh.numberofvertices,1);
+md.geometry.bed=-1000.*ones(md.mesh.numberofvertices,1);
 md.geometry.surface=md.geometry.bed+md.geometry.thickness;
 
@@ -15,21 +15,21 @@
 
 disp('      creating drag');
-md.friction.coefficient=200*ones(md.mesh.numberofvertices,1); %q=1.
+md.friction.coefficient=200.*ones(md.mesh.numberofvertices,1); %q=1.
 %Take care of iceshelves: no basal drag
 pos=find(md.mask.elementonfloatingice);
-md.friction.coefficient(md.mesh.elements(pos,:))=0;
+md.friction.coefficient(md.mesh.elements(pos,:))=0.;
 md.friction.p=ones(md.mesh.numberofelements,1);
 md.friction.q=ones(md.mesh.numberofelements,1);
 
 disp('      creating temperatures');
-md.initialization.temperature=(273-20)*ones(md.mesh.numberofvertices,1);
+md.initialization.temperature=(273.-20.)*ones(md.mesh.numberofvertices,1);
 
-disp('      creating flow law paramter');
+disp('      creating flow law parameter');
 md.materials.rheology_B=paterson(md.initialization.temperature);
-md.materials.rheology_n=3*ones(md.mesh.numberofelements,1);
+md.materials.rheology_n=3.*ones(md.mesh.numberofelements,1);
 
 disp('      creating surface mass balance');
 md.surfaceforcings.mass_balance=ones(md.mesh.numberofvertices,1)/md.constants.yts; %1m/a
-md.basalforcings.melting_rate=0*ones(md.mesh.numberofvertices,1)/md.constants.yts; %1m/a
+md.basalforcings.melting_rate=0.*ones(md.mesh.numberofvertices,1)/md.constants.yts; %1m/a
 
 %Deal with boundary conditions:
@@ -41,3 +41,3 @@
 md.thermal.spctemperature(:)=md.initialization.temperature;
 md.basalforcings.geothermalflux=zeros(md.mesh.numberofvertices,1); 
-pos=find(md.mask.elementongroundedice);md.basalforcings.geothermalflux(md.mesh.elements(pos,:))=1*10^-3; %1 mW/m^2
+pos=find(md.mask.elementongroundedice);md.basalforcings.geothermalflux(md.mesh.elements(pos,:))=1.*10^-3; %1 mW/m^2
Index: /issm/trunk/test/Par/SquareThermal.py
===================================================================
--- /issm/trunk/test/Par/SquareThermal.py	(revision 14310)
+++ /issm/trunk/test/Par/SquareThermal.py	(revision 14310)
@@ -0,0 +1,48 @@
+import numpy
+from paterson import *
+from SetMarineIceSheetBC import *
+
+#Ok, start defining model parameters here
+
+md.timestepping.time_step=0
+
+print "      creating thickness"
+h=1000.
+md.geometry.thickness=h*numpy.ones((md.mesh.numberofvertices,1))
+md.geometry.bed=-1000.*numpy.ones((md.mesh.numberofvertices,1))
+md.geometry.surface=md.geometry.bed+md.geometry.thickness;
+
+print "      creating velocities"
+md.initialization.vx=numpy.zeros((md.mesh.numberofvertices,1))
+md.initialization.vy=numpy.zeros((md.mesh.numberofvertices,1))
+md.initialization.vz=numpy.zeros((md.mesh.numberofvertices,1))
+
+print "      creating drag"
+md.friction.coefficient=200.*numpy.ones((md.mesh.numberofvertices,1))    #q=1.
+#Take care of iceshelves: no basal drag
+pos=numpy.nonzero(md.mask.elementonfloatingice)[0]
+md.friction.coefficient[md.mesh.elements[pos,:]-1]=0.
+md.friction.p=numpy.ones((md.mesh.numberofelements,1))
+md.friction.q=numpy.ones((md.mesh.numberofelements,1))
+
+print "      creating temperatures"
+md.initialization.temperature=(273.-20.)*numpy.ones((md.mesh.numberofvertices,1))
+
+print "      creating flow law parameter"
+md.materials.rheology_B=paterson(md.initialization.temperature)
+md.materials.rheology_n=3.*numpy.ones((md.mesh.numberofelements,1))
+
+print "      creating surface mass balance"
+md.surfaceforcings.mass_balance=numpy.ones((md.mesh.numberofvertices,1))/md.constants.yts    #1m/a
+md.basalforcings.melting_rate=0.*numpy.ones((md.mesh.numberofvertices,1))/md.constants.yts    #1m/a
+
+#Deal with boundary conditions:
+
+print "      boundary conditions for diagnostic model"
+md=SetMarineIceSheetBC(md,'../Exp/SquareFront.exp')
+
+print "      boundary conditions for thermal model"
+md.thermal.spctemperature[:]=md.initialization.temperature
+md.basalforcings.geothermalflux=numpy.zeros((md.mesh.numberofvertices,1)) 
+pos=numpy.nonzero(md.mask.elementongroundedice)[0]
+md.basalforcings.geothermalflux[md.mesh.elements[pos,:]-1]=1.*10**-3    #1 mW/m^2
