Index: /issm/branches/trunk-jpl-damage/configs/config-arm-linux.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/configs/config-arm-linux.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/configs/config-arm-linux.sh	(revision 12258)
@@ -1,12 +1,13 @@
 #!/bin/sh
-
-pythonversion=2.7
 
 ./configure \
 	--prefix=$ISSM_DIR \
-	--with-python-dir=$ISSM_DIR/externalpackages/python/install\
-	--with-python-version=$pythonversion \
-	--with-python-numpy-dir=$ISSM_DIR/externalpackages/python/install/Python.framework/Versions/$pythonversion/lib/python$pythonversion/site-packages/numpy/core/include/numpy\
+    --host="arm-linux" \
+	--without-modules \
+    CC=$ANDROID_DIR/arm-linux-android-4.0/bin/arm-linux-androideabi-gcc \
+    GCC=$ANDROID_DIR/arm-linux-android-4.0/bin/arm-linux-androideabi-gcc \
+    CXX=$ANDROID_DIR/arm-linux-android-4.0/bin/arm-linux-androideabi-g++ \
 	--with-vendor=arm-linux \
 	--with-triangle-dir=$ISSM_DIR/externalpackages/triangle/install \
-	--with-gsl-dir=$ISSM_DIR/externalpackages/gsl/install
+	--with-gsl-dir=$ISSM_DIR/externalpackages/gsl/install\
+    --without-fortran-lib
Index: /issm/branches/trunk-jpl-damage/configs/config-linux64-astrid.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/configs/config-linux64-astrid.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/configs/config-linux64-astrid.sh	(revision 12258)
@@ -15,4 +15,5 @@
  --with-mpi-lib="-L$ISSM_DIR/externalpackages/mpich2/install/lib/ -lmpich -lmpl " \
  --with-petsc-arch=$ISSM_ARCH \
+ --with-gsl-dir=$ISSM_DIR/externalpackages/gsl/install \
  --with-dakota-dir=$ISSM_DIR/externalpackages/dakota/install \
  --with-blas-lapack-dir=$ISSM_DIR/externalpackages/petsc/install \
@@ -30,2 +31,3 @@
  --with-numthreads=32 \
  --enable-debugging
+ #--with-serial=no \
Index: /issm/branches/trunk-jpl-damage/configs/config-linux64-ubuntu64.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/configs/config-linux64-ubuntu64.sh	(revision 12258)
+++ /issm/branches/trunk-jpl-damage/configs/config-linux64-ubuntu64.sh	(revision 12258)
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+./configure \
+ --prefix=$ISSM_DIR \
+ --with-matlab-dir=$MATLAB_DIR \
+ --with-triangle-dir=$ISSM_DIR/externalpackages/triangle/install \
+ --with-metis-dir=$ISSM_DIR/externalpackages/metis/install \
+ --with-petsc-dir=$ISSM_DIR/externalpackages/petsc/install \
+ --with-mpi-include=$ISSM_DIR/externalpackages/mpich2/install/include  \
+ --with-mpi-lib="-L$ISSM_DIR/externalpackages/mpich2/install/lib/ -lmpich -lmpl -ldl" \
+ --with-petsc-arch=$ISSM_ARCH \
+ --with-blas-lapack-dir=$ISSM_DIR/externalpackages/petsc/install \
+ --with-plapack-lib="-L$ISSM_DIR/externalpackages/petsc/install/ -lPLAPACK" \
+ --with-plapack-include="-I$ISSM_DIR/externalpackages/petsc/install/externalpackages/PLAPACKR32-hg/INCLUDE" \
+ --with-blacs-dir=$ISSM_DIR/externalpackages/petsc/install/ \
+ --with-scalapack-dir=$ISSM_DIR/externalpackages/petsc/install/ \
+ --with-mumps-dir=$ISSM_DIR/externalpackages/petsc/install/ \
+ --with-scotch-dir="$ISSM_DIR/externalpackages/scotch/install" \
+ --with-chaco-dir="$ISSM_DIR/externalpackages/chaco/install" \
+ --with-cxxoptflags="-mtune=barcelona -ffast-math -O3 -msse4.2 -Wno-write-strings "\
+ --with-fortran-lib="-lgfortran"\
+ --with-numthreads=8 \
+ --with-dakota-dir=$ISSM_DIR/externalpackages/dakota/install \
+ --enable-debugging
+ 
+ 
Index: /issm/branches/trunk-jpl-damage/configs/config-macosx64-helene.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/configs/config-macosx64-helene.sh	(revision 12258)
+++ /issm/branches/trunk-jpl-damage/configs/config-macosx64-helene.sh	(revision 12258)
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+#petsc 3.2
+#mpich 1.4
+
+./configure \
+	--prefix=$ISSM_DIR \
+	--with-matlab-dir=$MATLAB_DIR \
+	--with-triangle-dir=$ISSM_DIR/externalpackages/triangle/install \
+	--with-metis-dir=$ISSM_DIR/externalpackages/metis/install \
+	--with-petsc-dir=$ISSM_DIR/externalpackages/petsc/install  \
+	--with-mpi-include=$ISSM_DIR/externalpackages/mpich2/install/include  \
+	--with-mpi-lib=" $ISSM_DIR/externalpackages/mpich2/install/lib/libpmpich.a $ISSM_DIR/externalpackages/mpich2/install/lib/libmpich.a" \
+	--with-petsc-arch=$ISSM_ARCH \
+	--with-dakota-dir=$ISSM_DIR/externalpackages/dakota/install \
+	--with-blas-lapack-dir=$ISSM_DIR/externalpackages/petsc/install \
+	--with-plapack-lib="-L$ISSM_DIR/externalpackages/petsc/install/ -lPLAPACK" \
+	--with-plapack-include="-I$ISSM_DIR/externalpackages/petsc/install/include/ " \
+	--with-blacs-dir=$ISSM_DIR/externalpackages/petsc/install/ \
+	--with-scalapack-dir=$ISSM_DIR/externalpackages/petsc/install/ \
+	--with-mumps-dir=$ISSM_DIR/externalpackages/petsc/install/ \
+	--with-fortran-lib="/usr/local/gfortran/lib/libgfortran.a" \
+	--with-math-lib="/usr/lib/libm.dylib" \
+	--with-graphics-lib="/usr/X11/lib/libX11.dylib" \
+	--with-cxxoptflags=" -fno-common -no-cpp-precomp -fexceptions -arch x86_64 -mmacosx-version-min=10.5  -O3 -DNDEBUG -w "\
+	--with-numthreads=8
Index: /issm/branches/trunk-jpl-damage/configure.ac
===================================================================
--- /issm/branches/trunk-jpl-damage/configure.ac	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/configure.ac	(revision 12258)
@@ -10,5 +10,5 @@
 AC_PROG_CPP
 AC_PROG_CXX([cccl cl icl g++])
-AC_PROG_F77([ifort g77 gfortran])
+#AC_PROG_F77([ifort g77 gfortran])
 #Libraries and linking
 AC_PROG_RANLIB
Index: /issm/branches/trunk-jpl-damage/cron/nightlyrun.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/cron/nightlyrun.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/cron/nightlyrun.sh	(revision 12258)
@@ -65,5 +65,4 @@
 #Export ISSM_* variables{{{1
 export ISSM_DIR
-export ISSM_TIER
 export ISSM_ARCH
 #}}}
@@ -90,5 +89,5 @@
 
 	#only update ISSM
-	cd $ISSM_TIER
+	cd $ISSM_DIR
 	svn update
 
@@ -109,9 +108,9 @@
 #Create cluster's settings{{{1
 #create simpler  cluster.rc file, with only the cluster we are interested in.
-cd $ISSM_TIER/test/NightlyRun/
+cd $ISSM_DIR/test/NightlyRun/
 if [ "$MACHINE" = "win7" ]; then
 	cat << END > $HOST_NAME"_settings.m"
 cluster.login='$USER';
-cluster.codepath='`cygpath -m $ISSM_TIER/bin`';
+cluster.codepath='`cygpath -m $ISSM_DIR/bin`';
 cluster.executionpath='`cygpath -m $EXECUTION_PATH`';
 END
@@ -119,8 +118,8 @@
 	cat << END > $HOST_NAME"_settings.m"
 cluster.login='$USER';
-cluster.codepath='$ISSM_TIER/bin';
+cluster.codepath='$ISSM_DIR/bin';
 cluster.executionpath='$EXECUTION_PATH';
 END
-   cat << END > $ISSM_TIER/externalpackages/matlab/install.sh
+   cat << END > $ISSM_DIR/externalpackages/matlab/install.sh
 #!/bin/bash
 rm -rf install
@@ -131,5 +130,5 @@
 #}}}
 #Source environment variables with new matlab path {{{1
-cd $ISSM_TIER/etc
+cd $ISSM_DIR/etc
 source environment.sh MATLAB_DIR=$MATLAB_PATH
 #}}}
@@ -138,5 +137,5 @@
 then
 	
-	cd $ISSM_TIER/externalpackages
+	cd $ISSM_DIR/externalpackages
 	#number of packages: 
 	numpackages=`echo $EXTERNALPACKAGES | wc -w`
@@ -156,5 +155,5 @@
 
 	#erase externapackages, and link with externalpackages_dir
-	cd $ISSM_TIER
+	cd $ISSM_DIR
 	rm -rf externalpackages
 	cp -Rf $EXTERNALPACKAGESDIR ./
@@ -164,5 +163,5 @@
 
 	#erase externapackages, and link with externalpackages_dir
-	cd $ISSM_TIER
+	cd $ISSM_DIR
 	rm -rf externalpackages
 	ln -s  $EXTERNALPACKAGESDIR  .
@@ -186,5 +185,5 @@
 then
 
-	cd $ISSM_TIER
+	cd $ISSM_DIR
 	make clean
 	make distclean
@@ -214,7 +213,7 @@
 #Prepare run
 #create softlink to startup {{{1
-cd $ISSM_TIER/test/NightlyRun/
+cd $ISSM_DIR/test/NightlyRun/
 rm startup.m #in case it alreade exists
-cp $ISSM_TIER/startup.m .
+cp $ISSM_DIR/startup.m .
 #}}}
 #Create nightlylog directory and info.log {{{1
@@ -222,7 +221,7 @@
 INSTALL_TIME=$(timer)
 ELAPSED_INSTALL=$(timer $START_TIME)
-rm -rf $ISSM_TIER/nightlylog
-mkdir  $ISSM_TIER/nightlylog
-cat << END > $ISSM_TIER/nightlylog/info.log
+rm -rf $ISSM_DIR/nightlylog
+mkdir  $ISSM_DIR/nightlylog
+cat << END > $ISSM_DIR/nightlylog/info.log
 today:     $(echo $TODAY)
 user:      $(echo $USER)
@@ -245,7 +244,7 @@
 #on Matlab and windows machines, we'll need a windows style path:  {{{
 if [ "$MACHINE" = "win7" ]; then
-	MATLAB_TIER=`cygpath -m $ISSM_TIER`
+	MATLAB_TIER=`cygpath -m $ISSM_DIR`
 else 
-	MATLAB_TIER=$ISSM_TIER
+	MATLAB_TIER=$ISSM_DIR
 fi
 #}}}
@@ -254,5 +253,5 @@
 do
 	#Launch matlab and the nightly run script
-	cat > $ISSM_TIER/nightlylog/matlab_run$i.m << EOF
+	cat > $ISSM_DIR/nightlylog/matlab_run$i.m << EOF
 	warning off %necessary to avoid a info.log of several Go for parallel runs
 	try,
@@ -263,5 +262,4 @@
 		echo "runme('output','nightly','rank',$i,'numprocs',$NUMCPUS_RUN);"
 	else
-		#echo "runme('id',[101 102]);" 
 		echo "runme($NROPTIONS,'output','nightly','rank',$i,'numprocs',$NUMCPUS_RUN);"
 	fi
@@ -271,5 +269,5 @@
 		message=getReport(me)
 		directory=strsplit(pwd,'/');
-		fid=fopen([ISSM_TIER '/nightlylog/matlaberror.log'], 'at');
+		fid=fopen([issmdir '/nightlylog/matlaberror.log'], 'at');
 		fprintf(fid,'\nMatlab error occured in: %s\n\n',directory{end});
 		fprintf(fid,'%s',message);
@@ -281,5 +279,5 @@
 
 	#Start run from nightlylog directory
-	cd $ISSM_TIER/nightlylog/
+	cd $ISSM_DIR/nightlylog/
 
 	MATLABBIN=$MATLAB_PATH/bin/matlab
@@ -298,5 +296,5 @@
 #}}}
 #concatenate all reports {{{1
-cd $ISSM_TIER/nightlylog/
+cd $ISSM_DIR/nightlylog/
 cp matlab_log1.log  matlab_log.log
 for (( i=2;i<=$NUMCPUS_RUN;i++ ))
@@ -315,5 +313,5 @@
 ELAPSED_RUN=$(timer $INSTALL_TIME)
 ELAPSED_TOTAL=$(timer $START_TIME)
-cat << END >>  $ISSM_TIER/nightlylog/info.log
+cat << END >>  $ISSM_DIR/nightlylog/info.log
 elapsed_run:   $(echo $ELAPSED_RUN)
 elapsed_total: $(echo $ELAPSED_TOTAL)
@@ -324,7 +322,7 @@
 #Send Report
 #Build html report {{{1
-cd $ISSM_TIER/nightlylog/
+cd $ISSM_DIR/nightlylog/
 sh ../scripts/report.sh
-echo "html report located in $ISSM_TIER/nightlylog/report.html"
+echo "html report located in $ISSM_DIR/nightlylog/report.html"
 #}}}
 #send mail if requested                  (SKIPMAIL) {{{1
@@ -332,14 +330,14 @@
 then
 	echo "sending report..."
-	source $ISSM_TIER/cron/mailinglist
+	source $ISSM_DIR/cron/mailinglist
 	for i in `echo $MAILINGLIST`; do
 
 		if [ "$MACHINE" = "win7" ]
 		then
-			email -html -s "Nightly runs on $HOST_NAME (version: $ISSM_RELEASE)" -n "ISSM Nightly run" -f echo $EMAIL_ADRESS $i < $ISSM_TIER/nightlylog/report.html
+			email -html -s "Nightly runs on $HOST_NAME (version: $ISSM_RELEASE)" -n "ISSM Nightly run" -f echo $EMAIL_ADRESS $i < $ISSM_DIR/nightlylog/report.html
 		else 
 			if [ "$MACHINE" = "astrid" ]
 			then
-cat - $ISSM_TIER/nightlylog/report.html <<HERE | /usr/lib/sendmail  -oi -t
+cat - $ISSM_DIR/nightlylog/report.html <<HERE | /usr/lib/sendmail  -oi -t
 From: "ISSM Nightly run" <$EMAIL_ADRESS>
 To: $i
@@ -349,5 +347,5 @@
 HERE
 		else
-cat - $ISSM_TIER/nightlylog/report.html <<HERE | /usr/sbin/sendmail  -oi -t
+cat - $ISSM_DIR/nightlylog/report.html <<HERE | /usr/sbin/sendmail  -oi -t
 From: "ISSM Nightly run" <$EMAIL_ADRESS>
 To: $i
Index: /issm/branches/trunk-jpl-damage/etc/environment.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/etc/environment.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/etc/environment.sh	(revision 12258)
@@ -215,5 +215,5 @@
 #APPSCAN
 export PATH="$PATH:$APPSCAN_DIR/install/bin"
-export PATH="$PATH:$APPSCAN_DIR/bin"]
+export PATH="$PATH:$APPSCAN_DIR/bin"
 
 #CPPCHECK
@@ -253,4 +253,6 @@
 #GSL
 export PATH="$PATH:$GSL_DIR/bin"
+export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$GSL_DIR/lib"
+export LD_RUN_PATH="$LD_RUN_PATH:$GSL_DIR/lib"
 
 #GMAKE
@@ -261,5 +263,9 @@
 export PYTHONPATH="$PYTHONPATH:$ISSM_DIR/src/modules/python"
 export LD_LIBRARY_PATH=$ISSM_DIR/src/modules/python:$LD_LIBRARY_PATH
+export PYTHONSTARTUP
 
 #MODELE
 export PATH="$MODELE_DIR/src/exec:$PATH"
+
+#GIT
+export PATH="$PATH:$GIT_DIR/install/bin"
Index: /issm/branches/trunk-jpl-damage/etc/environment_variables.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/etc/environment_variables.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/etc/environment_variables.sh	(revision 12258)
@@ -193,5 +193,10 @@
 #PYTHON
 PYTHON_DIR="$ISSM_DIR/externalpackages/python/install"
+PYTHONSTARTUP="$ISSM_DIR/startup.py"
 
 #MODELE
 MODELE_DIR="$ISSM_DIR/externalpackages/modelE"
+
+
+#GIT
+GIT_DIR="$ISSM_DIR/externalpackages/git"
Index: /issm/branches/trunk-jpl-damage/externalpackages/adolc/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/adolc/install.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/adolc/install.sh	(revision 12258)
@@ -5,4 +5,7 @@
 #Some cleanup
 rm -rf install ADOL-C-2.2.0 src
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/ADOL-C-2.2.0.tar.gz' 'ADOL-C-2.2.0.tar.gz'
 
 #Create install directories
Index: /issm/branches/trunk-jpl-damage/externalpackages/autoconf/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/autoconf/install.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/autoconf/install.sh	(revision 12258)
@@ -4,9 +4,12 @@
 rm -rf install autoconf-2.68 src
 
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/autoconf-2.68.tar.gz' 'autoconf-2.68.tar.gz'
+
 #Create install directories
 mkdir install
 
 #Untar 
-tar -zxvf  autoconf-2.68.tar.gz
+tar -zxvf autoconf-2.68.tar.gz
 
 #Move autoconf into src directory
Index: /issm/branches/trunk-jpl-damage/externalpackages/automake/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/automake/install.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/automake/install.sh	(revision 12258)
@@ -3,4 +3,7 @@
 #Some cleanup
 rm -rf install automake-1.11.3 src
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/automake-1.11.3.tar.gz' 'automake-1.11.3.tar.gz'
 
 #Create install directories
Index: /issm/branches/trunk-jpl-damage/externalpackages/bbftp/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/bbftp/install.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/bbftp/install.sh	(revision 12258)
@@ -3,4 +3,7 @@
 #Some cleanup
 rm -rf src install bbftp-client-3.2.0
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/bbftp-client-3.2.0.tar.gz' 'bbftp-client-3.2.0.tar.gz'
 
 #Create install directories
Index: /issm/branches/trunk-jpl-damage/externalpackages/blas/configs/linux64/make.inc
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/blas/configs/linux64/make.inc	(revision 12258)
+++ /issm/branches/trunk-jpl-damage/externalpackages/blas/configs/linux64/make.inc	(revision 12258)
@@ -0,0 +1,34 @@
+####################################################################
+#  BLAS make include file.                                         #
+#  March 2007                                                      #
+####################################################################
+#
+SHELL = /bin/sh
+#
+#  The machine (platform) identifier to append to the library names
+#
+PLAT = _LINUX
+#  
+#  Modify the FORTRAN and OPTS definitions to refer to the
+#  compiler and desired compiler options for your machine.  NOOPT
+#  refers to the compiler options desired when NO OPTIMIZATION is
+#  selected.  Define LOADER and LOADOPTS to refer to the loader and 
+#  desired load options for your machine.
+#
+FORTRAN  = gfortran
+OPTS     = -fPIC -O3
+DRVOPTS  = $(OPTS)
+NOOPT    =
+LOADER   = gfortran
+LOADOPTS =
+#
+#  The archiver and the flag(s) to use when building archive (library)
+#  If you system has no ranlib, set RANLIB = echo.
+#
+ARCH     = ar
+ARCHFLAGS= cr
+RANLIB   = ranlib
+#
+#  The location and name of the Reference BLAS library.
+#
+BLASLIB      = blas$(PLAT).a
Index: /issm/branches/trunk-jpl-damage/externalpackages/blas/install-linux64.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/blas/install-linux64.sh	(revision 12258)
+++ /issm/branches/trunk-jpl-damage/externalpackages/blas/install-linux64.sh	(revision 12258)
@@ -0,0 +1,28 @@
+#!/bin/bash
+
+#Some cleanup
+rm -rf src install BLAS blas.tgz
+mkdir install src
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/blas.tgz' 'blas.tgz'
+
+#Untar 
+tar -zxvf  blas.tgz
+
+#Move blas into install directory
+mv BLAS/* src
+rm -rf BLAS
+
+#install
+cd src 
+cp ../configs/linux64/make.inc ./
+make 
+
+#Compile 
+cd ../install
+mkdir lib
+cd lib
+cp ../../src/*.a .
+ln -s blas_LINUX.a blas.a
+ln -s blas_LINUX.a libblas.a
Index: /issm/branches/trunk-jpl-damage/externalpackages/boost/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/boost/install.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/boost/install.sh	(revision 12258)
@@ -7,9 +7,10 @@
 #to get the boost library to include python support without doing that. 
 
-
-
 #Some cleanup
 rm -rf install boost_1_49_0 src
 mkdir install src
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/boost_1_49_0.tar.gz' 'boost_1_49_0.tar.gz'
 
 #Untar 
Index: /issm/branches/trunk-jpl-damage/externalpackages/bsdtar/install-win7.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/bsdtar/install-win7.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/bsdtar/install-win7.sh	(revision 12258)
@@ -4,4 +4,7 @@
 rm -rf install src libarchive-3.0.3
 mkdir install src
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/libarchive-3.0.3.tar.gz' 'libarchive-3.0.3.tar.gz'
 
 #Untar 
Index: /issm/branches/trunk-jpl-damage/externalpackages/cccl/install-win7.orig.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/cccl/install-win7.orig.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/cccl/install-win7.orig.sh	(revision 12258)
@@ -4,4 +4,7 @@
 rm -rf src install cccl-0.03
 mkdir install src
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/cccl-0.03.tar.gz' 'cccl-0.03.tar.gz'
 
 #Untar 
Index: /issm/branches/trunk-jpl-damage/externalpackages/cccl/issm/cccl
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/cccl/issm/cccl	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/cccl/issm/cccl	(revision 12258)
@@ -74,4 +74,17 @@
     esac
 	;;
+	-fPIC)
+	#do nothing
+	;;
+	-g)
+	#do nothing
+	;;
+	-pthread)
+	#do nothing
+	;;
+	-fno-omit-frame-pointer)
+	#do nothing
+	;;
+
 	*)
 		#do nothing
@@ -83,4 +96,7 @@
     shift
 done
+			
+#Some default options:
+opts="$opts /nologo"
 
 #echo "$prog $opts"
Index: /issm/branches/trunk-jpl-damage/externalpackages/chaco/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/chaco/install.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/chaco/install.sh	(revision 12258)
@@ -6,4 +6,7 @@
 rm -rf install 
 mkdir src install 
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/Chaco-2.2.tar.gz' 'Chaco-2.2.tar.gz'
 
 # Untar 
Index: /issm/branches/trunk-jpl-damage/externalpackages/cmake/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/cmake/install.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/cmake/install.sh	(revision 12258)
@@ -4,4 +4,7 @@
 rm -rf install cmake-2.8.5
 mkdir install
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/cmake-2.8.5.tar.gz' 'cmake-2.8.5.tar.gz'
 
 #Untar 
Index: /issm/branches/trunk-jpl-damage/externalpackages/colpack/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/colpack/install.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/colpack/install.sh	(revision 12258)
@@ -3,4 +3,7 @@
 #Erase install
 rm -rf install  src ColPack
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/ColPack-1.0.3.tar.gz' 'ColPack-1.0.3.tar.gz'
 
 #install directory
Index: /issm/branches/trunk-jpl-damage/externalpackages/cppcheck/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/cppcheck/install.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/cppcheck/install.sh	(revision 12258)
@@ -5,4 +5,6 @@
 mkdir src
 
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/cppcheck-1.48.tar' 'cppcheck-1.48.tar'
 tar -xvf cppcheck-1.48.tar
 
Index: /issm/branches/trunk-jpl-damage/externalpackages/dace/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/dace/install.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/dace/install.sh	(revision 12258)
@@ -4,4 +4,7 @@
 rm -rf install dace
 mkdir install
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/dace.zip' 'dace.zip'
 
 #uncompress
Index: /issm/branches/trunk-jpl-damage/externalpackages/dakota/install-altix64-cosmos.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/dakota/install-altix64-cosmos.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/dakota/install-altix64-cosmos.sh	(revision 12258)
@@ -9,4 +9,7 @@
 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 
Index: /issm/branches/trunk-jpl-damage/externalpackages/dakota/install-linux64-astrid.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/dakota/install-linux64-astrid.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/dakota/install-linux64-astrid.sh	(revision 12258)
@@ -9,4 +9,7 @@
 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 
Index: /issm/branches/trunk-jpl-damage/externalpackages/dakota/install-linux64-murdo.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/dakota/install-linux64-murdo.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/dakota/install-linux64-murdo.sh	(revision 12258)
@@ -9,4 +9,7 @@
 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 
Index: /issm/branches/trunk-jpl-damage/externalpackages/dakota/install-macosx64.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/dakota/install-macosx64.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/dakota/install-macosx64.sh	(revision 12258)
@@ -9,4 +9,7 @@
 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 
Index: /issm/branches/trunk-jpl-damage/externalpackages/dakota/install-pleiades.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/dakota/install-pleiades.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/dakota/install-pleiades.sh	(revision 12258)
@@ -9,4 +9,7 @@
 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 
Index: /issm/branches/trunk-jpl-damage/externalpackages/distribute/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/distribute/install.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/distribute/install.sh	(revision 12258)
@@ -1,4 +1,5 @@
 #!/bin/bash
 
-curl -O http://python-distribute.org/distribute_setup.py
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://python-distribute.org/distribute_setup.py' 'distribute_setup.py'
 python distribute_setup.py
Index: /issm/branches/trunk-jpl-damage/externalpackages/findbugs/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/findbugs/install.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/findbugs/install.sh	(revision 12258)
@@ -5,4 +5,6 @@
 mkdir install
 
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/findbugs-1.3.9.tar.gz' 'findbugs-1.3.9.tar.gz'
 tar -zxvf findbugs-1.3.9.tar.gz 
 
Index: /issm/branches/trunk-jpl-damage/externalpackages/freetype/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/freetype/install.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/freetype/install.sh	(revision 12258)
@@ -6,4 +6,7 @@
 rm -rf freetype-2.4.9
 mkdir src install
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/freetype-2.4.9.tar.gz' 'freetype-2.4.9.tar.gz'
 
 #Untar 
Index: /issm/branches/trunk-jpl-damage/externalpackages/gdal/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/gdal/install.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/gdal/install.sh	(revision 12258)
@@ -6,4 +6,7 @@
 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 
Index: /issm/branches/trunk-jpl-damage/externalpackages/gdaltokmz/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/gdaltokmz/install.sh	(revision 12258)
+++ /issm/branches/trunk-jpl-damage/externalpackages/gdaltokmz/install.sh	(revision 12258)
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/gdaltokmz-1.0.tar.gz' 'gdaltokmz-1.0.tar.gz'
Index: /issm/branches/trunk-jpl-damage/externalpackages/git/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/git/install.sh	(revision 12258)
+++ /issm/branches/trunk-jpl-damage/externalpackages/git/install.sh	(revision 12258)
@@ -0,0 +1,22 @@
+#!/bin/bash
+
+#Some cleanup
+rm -rf src install git-1.7.10.2
+mkdir install src
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/git-1.7.10.2.tar.gz' 'git-1.7.10.2.tar.gz'
+
+#Untar 
+tar -zxvf  git-1.7.10.2.tar.gz
+
+#Move git into install directory
+mv git-1.7.10.2/* src
+rm -rf git-1.7.10.2
+
+#install
+cd src 
+./configure  --prefix="$ISSM_DIR/externalpackages/git/install"
+	
+#Compile
+make install
Index: /issm/branches/trunk-jpl-damage/externalpackages/gmake/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/gmake/install.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/gmake/install.sh	(revision 12258)
@@ -4,4 +4,7 @@
 rm -rf install src make-3.82
 mkdir install src
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/make-3.82.tar.gz' 'make-3.82.tar.gz'
 
 #Untar 
Index: /issm/branches/trunk-jpl-damage/externalpackages/graphviz/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/graphviz/install.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/graphviz/install.sh	(revision 12258)
@@ -4,4 +4,7 @@
 rm -rf install src
 mkdir install src
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/graphviz-2.24.0.tar.gz' 'graphviz-2.24.0.tar.gz'
 
 #Untar 
Index: /issm/branches/trunk-jpl-damage/externalpackages/gsl/install-android-4.0.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/gsl/install-android-4.0.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/gsl/install-android-4.0.sh	(revision 12258)
@@ -4,4 +4,7 @@
 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 
Index: sm/branches/trunk-jpl-damage/externalpackages/gsl/install-linux64-murdo.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/gsl/install-linux64-murdo.sh	(revision 12257)
+++ 	(revision )
@@ -1,26 +1,0 @@
-#!/bin/bash
-
-#Some cleanup
-rm -rf src install gsl-1.15
-mkdir src install
-
-#Untar 
-tar -zxvf  gsl-1.15.tar.gz
-
-#Move gsl into src directory
-mv gsl-1.15/* src
-rm -rf gsl-1.15
-
-#Configure gsl
-cd src
-
-./configure \
-	--prefix="$ISSM_DIR/externalpackages/gsl/install" 
-
-#Compile gsl
-if [ -z $1 ]; then
-	make
-else
-	make -j $1
-fi
-make install 
Index: /issm/branches/trunk-jpl-damage/externalpackages/gsl/install-linux64.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/gsl/install-linux64.sh	(revision 12258)
+++ /issm/branches/trunk-jpl-damage/externalpackages/gsl/install-linux64.sh	(revision 12258)
@@ -0,0 +1,29 @@
+#!/bin/bash
+
+#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 [ -z $1 ]; then
+	make
+else
+	make -j $1
+fi
+make install 
Index: /issm/branches/trunk-jpl-damage/externalpackages/gsl/install-macosx64.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/gsl/install-macosx64.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/gsl/install-macosx64.sh	(revision 12258)
@@ -4,4 +4,7 @@
 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 
Index: /issm/branches/trunk-jpl-damage/externalpackages/gsl/install-pleiades.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/gsl/install-pleiades.sh	(revision 12258)
+++ /issm/branches/trunk-jpl-damage/externalpackages/gsl/install-pleiades.sh	(revision 12258)
@@ -0,0 +1,29 @@
+#!/bin/bash
+
+#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 [ -z $1 ]; then
+	make
+else
+	make -j $1
+fi
+make install 
Index: /issm/branches/trunk-jpl-damage/externalpackages/ipython/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/ipython/install.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/ipython/install.sh	(revision 12258)
@@ -6,4 +6,7 @@
 rm -rf ipython-0.12
 mkdir src install
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/ipython-0.12.tar.gz' 'ipython-0.12.tar.gz'
 
 #Untar 
Index: /issm/branches/trunk-jpl-damage/externalpackages/kml/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/kml/install.sh	(revision 12258)
+++ /issm/branches/trunk-jpl-damage/externalpackages/kml/install.sh	(revision 12258)
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/kml_shapefile.zip' 'kml_shapefile.zip'
Index: /issm/branches/trunk-jpl-damage/externalpackages/lapack/configs/linux64/make.inc
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/lapack/configs/linux64/make.inc	(revision 12258)
+++ /issm/branches/trunk-jpl-damage/externalpackages/lapack/configs/linux64/make.inc	(revision 12258)
@@ -0,0 +1,71 @@
+####################################################################
+#  LAPACK make include file.                                       #
+#  LAPACK, Version 3.4.0                                           #
+#  April 2012                                                   #
+####################################################################
+#
+SHELL = /bin/sh
+#  
+#  Modify the FORTRAN and OPTS definitions to refer to the
+#  compiler and desired compiler options for your machine.  NOOPT
+#  refers to the compiler options desired when NO OPTIMIZATION is
+#  selected.  Define LOADER and LOADOPTS to refer to the loader and 
+#  desired load options for your machine.
+#
+FORTRAN  = gfortran 
+OPTS     = -fPIC -O2
+DRVOPTS  = $(OPTS)
+NOOPT    = -O0
+LOADER   = gfortran
+LOADOPTS =
+#
+# Timer for the SECOND and DSECND routines
+#
+# Default : SECOND and DSECND will use a call to the EXTERNAL FUNCTION ETIME
+#TIMER    = EXT_ETIME
+# For RS6K : SECOND and DSECND will use a call to the EXTERNAL FUNCTION ETIME_
+# TIMER    = EXT_ETIME_
+# For gfortran compiler: SECOND and DSECND will use a call to the INTERNAL FUNCTION ETIME
+TIMER    = INT_ETIME
+# If your Fortran compiler does not provide etime (like Nag Fortran Compiler, etc...)
+# SECOND and DSECND will use a call to the INTERNAL FUNCTION CPU_TIME
+# TIMER    = INT_CPU_TIME
+# If neither of this works...you can use the NONE value... In that case, SECOND and DSECND will always return 0
+# TIMER     = NONE
+#
+#  Configuration LAPACKE: Native C interface to LAPACK
+#  To generate LAPACKE library: type 'make lapackelib'
+#  Configuration file: turned off (default)
+#  Complex types: C99 (default)
+#  Name pattern: mixed case (default)
+#  (64-bit) Data model: LP64 (default)
+#
+# CC is the C compiler, normally invoked with options CFLAGS.
+#
+CC = gcc
+CFLAGS = -O3
+#
+#  The archiver and the flag(s) to use when building archive (library)
+#  If you system has no ranlib, set RANLIB = echo.
+#
+ARCH     = ar
+ARCHFLAGS= cr
+RANLIB   = ranlib
+#
+#  Location of the extended-precision BLAS (XBLAS) Fortran library
+#  used for building and testing extended-precision routines.  The
+#  relevant routines will be compiled and XBLAS will be linked only if
+#  USEXBLAS is defined.
+#
+# USEXBLAS    = Yes
+XBLASLIB     =
+# XBLASLIB    = -lxblas
+#
+#  The location of the libraries to which you will link.  (The 
+#  machine-specific, optimized BLAS library should be used whenever
+#  possible.)
+#
+BLASLIB      = ../../librefblas.a
+LAPACKLIB    = liblapack.a
+TMGLIB       = libtmglib.a
+LAPACKELIB   = liblapacke.a
Index: /issm/branches/trunk-jpl-damage/externalpackages/lapack/install-linux64.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/lapack/install-linux64.sh	(revision 12258)
+++ /issm/branches/trunk-jpl-damage/externalpackages/lapack/install-linux64.sh	(revision 12258)
@@ -0,0 +1,32 @@
+#!/bin/bash
+
+#Some cleanup
+rm -rf src install lapack-3.4.1 lapack-3.4.1.tgz
+mkdir install src
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/lapack-3.4.1.tgz' 'lapack-3.4.1.tgz'
+
+#Untar 
+tar -zxvf  lapack-3.4.1.tgz
+
+#Move lapack into install directory
+mv lapack-3.4.1/* src
+rm -rf lapack-3.4.1
+
+#install
+cd src 
+cp ../configs/linux64/make.inc ./
+
+#Compile and install lapack
+if [ -z $1 ]; then
+	make lib
+else
+	make -j $1 lib
+fi
+
+#Compile 
+cd ../install
+mkdir lib
+cd lib
+cp ../../src/liblapack.a .
Index: /issm/branches/trunk-jpl-damage/externalpackages/latex2rtf/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/latex2rtf/install.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/latex2rtf/install.sh	(revision 12258)
@@ -3,4 +3,7 @@
 #Some cleanup
 rm -rf latex2rtf-2.0.0 cfg install
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/latex2rtf-2.0.0.tar.gz' 'latex2rtf-2.0.0.tar.gz'
 
 #untar 
Index: /issm/branches/trunk-jpl-damage/externalpackages/libermate/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/libermate/install.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/libermate/install.sh	(revision 12258)
@@ -6,4 +6,7 @@
 mkdir install
 
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/libermate-0.4.tgz' 'libermate-0.4.tgz'
+
 #Untar 
 tar -zxvf  libermate-0.4.tgz
Index: /issm/branches/trunk-jpl-damage/externalpackages/libpng/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/libpng/install.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/libpng/install.sh	(revision 12258)
@@ -6,4 +6,7 @@
 rm -rf libpng-1.5.10
 mkdir src install
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/libpng-1.5.10.tar.gz' 'libpng-1.5.10.tar.gz'
 
 #Untar 
Index: /issm/branches/trunk-jpl-damage/externalpackages/libtool/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/libtool/install.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/libtool/install.sh	(revision 12258)
@@ -4,4 +4,7 @@
 rm -rf install libtool-2.2.6b src
 mkdir install
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/libtool-2.2.6b.tar.gz' 'libtool-2.2.6b.tar.gz'
 
 #Untar 
Index: /issm/branches/trunk-jpl-damage/externalpackages/m2html/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/m2html/install.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/m2html/install.sh	(revision 12258)
@@ -4,4 +4,7 @@
 rm -rf install m2html
 mkdir install
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/m2html.zip' 'm2html.zip'
 
 #uncompress
Index: /issm/branches/trunk-jpl-damage/externalpackages/matplotlib/install-osx.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/matplotlib/install-osx.sh	(revision 12258)
+++ /issm/branches/trunk-jpl-damage/externalpackages/matplotlib/install-osx.sh	(revision 12258)
@@ -0,0 +1,10 @@
+#/bin/bash
+pythonversion=2.7
+PYTHON=python${pythonversion}
+
+git clone https://github.com/matplotlib/matplotlib
+mv matplotlib src
+mkdir deps
+cd src
+make -f make.osx PREFIX=$ISSM_DIR/externalpackages/matplotlib/deps PYVERSION=$pythonversion fetch deps mpl_install_std
+${PYTHON} -c "import matplotlib; print 'Installed matplotlib', matplotlib.__version__, matplotlib.__file__"
Index: /issm/branches/trunk-jpl-damage/externalpackages/mercurial/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/mercurial/install.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/mercurial/install.sh	(revision 12258)
@@ -4,4 +4,7 @@
 rm -rf install mercurial-1.7.3
 mkdir install
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/mercurial-1.7.3.tar.gz' 'mercurial-1.7.3.tar.gz'
 
 #Untar 
Index: /issm/branches/trunk-jpl-damage/externalpackages/metis/install-4.0-altix64.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/metis/install-4.0-altix64.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/metis/install-4.0-altix64.sh	(revision 12258)
@@ -4,4 +4,7 @@
 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 
Index: /issm/branches/trunk-jpl-damage/externalpackages/metis/install-4.0-cosmos.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/metis/install-4.0-cosmos.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/metis/install-4.0-cosmos.sh	(revision 12258)
@@ -4,4 +4,7 @@
 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 
Index: /issm/branches/trunk-jpl-damage/externalpackages/metis/install-4.0-greenplanet.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/metis/install-4.0-greenplanet.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/metis/install-4.0-greenplanet.sh	(revision 12258)
@@ -4,4 +4,7 @@
 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 
Index: /issm/branches/trunk-jpl-damage/externalpackages/metis/install-4.0-linux64.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/metis/install-4.0-linux64.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/metis/install-4.0-linux64.sh	(revision 12258)
@@ -4,4 +4,7 @@
 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 
Index: /issm/branches/trunk-jpl-damage/externalpackages/metis/install-4.0-macosx32.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/metis/install-4.0-macosx32.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/metis/install-4.0-macosx32.sh	(revision 12258)
@@ -4,4 +4,7 @@
 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 
Index: /issm/branches/trunk-jpl-damage/externalpackages/metis/install-4.0-macosx64.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/metis/install-4.0-macosx64.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/metis/install-4.0-macosx64.sh	(revision 12258)
@@ -4,4 +4,7 @@
 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 
Index: /issm/branches/trunk-jpl-damage/externalpackages/metis/install-4.0-pleiades.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/metis/install-4.0-pleiades.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/metis/install-4.0-pleiades.sh	(revision 12258)
@@ -4,4 +4,7 @@
 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 
Index: /issm/branches/trunk-jpl-damage/externalpackages/metis/install-4.0-win32.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/metis/install-4.0-win32.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/metis/install-4.0-win32.sh	(revision 12258)
@@ -4,4 +4,7 @@
 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 
Index: /issm/branches/trunk-jpl-damage/externalpackages/metis/install-4.0-win7.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/metis/install-4.0-win7.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/metis/install-4.0-win7.sh	(revision 12258)
@@ -4,4 +4,7 @@
 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 
Index: /issm/branches/trunk-jpl-damage/externalpackages/metis/install-5.0.1-linux64.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/metis/install-5.0.1-linux64.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/metis/install-5.0.1-linux64.sh	(revision 12258)
@@ -5,4 +5,7 @@
 rm -rf install metis-5.0.1
 mkdir install
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/metis-5.0.1.tar.gz' 'metis-5.0.1.tar.gz'
 
 #Untar 
Index: /issm/branches/trunk-jpl-damage/externalpackages/modelE/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/modelE/install.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/modelE/install.sh	(revision 12258)
@@ -6,4 +6,7 @@
 rm -rf src install  modelE_AR5_branch
 mkdir src
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/modelE_AR5_branch.2012.03.13_10.12.21.tgz' 'modelE_AR5_branch.2012.03.13_10.12.21.tgz'
 
 #Untar 
Index: /issm/branches/trunk-jpl-damage/externalpackages/mpich2/install-1.0.2-altix64.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/mpich2/install-1.0.2-altix64.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/mpich2/install-1.0.2-altix64.sh	(revision 12258)
@@ -4,4 +4,7 @@
 rm -rf src install mpich2-1.0.2p1
 mkdir src install
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/mpich2-1.0.2p1.tar.gz' 'mpich2-1.0.2p1.tar.gz'
 
 #Untar 
Index: /issm/branches/trunk-jpl-damage/externalpackages/mpich2/install-1.0.2-linux64.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/mpich2/install-1.0.2-linux64.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/mpich2/install-1.0.2-linux64.sh	(revision 12258)
@@ -4,4 +4,7 @@
 rm -rf src install mpich2-1.0.2p1
 mkdir src install
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/mpich2-1.0.2p1.tar.gz' 'mpich2-1.0.2p1.tar.gz'
 
 #Untar 
Index: /issm/branches/trunk-jpl-damage/externalpackages/mpich2/install-1.0.2-macosx32.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/mpich2/install-1.0.2-macosx32.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/mpich2/install-1.0.2-macosx32.sh	(revision 12258)
@@ -4,4 +4,7 @@
 rm -rf src install mpich2-1.0.2p1
 mkdir src install
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/mpich2-1.0.2p1.tar.gz' 'mpich2-1.0.2p1.tar.gz'
 
 #Untar 
Index: /issm/branches/trunk-jpl-damage/externalpackages/mpich2/install-1.0.2-win32.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/mpich2/install-1.0.2-win32.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/mpich2/install-1.0.2-win32.sh	(revision 12258)
@@ -4,4 +4,7 @@
 rm -rf src install mpich2-1.0.2p1
 mkdir src install
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/mpich2-1.0.2p1.tar.gz' 'mpich2-1.0.2p1.tar.gz'
 
 #Untar 
Index: /issm/branches/trunk-jpl-damage/externalpackages/mpich2/install-1.4-linux64.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/mpich2/install-1.4-linux64.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/mpich2/install-1.4-linux64.sh	(revision 12258)
@@ -4,4 +4,7 @@
 rm -rf src install mpich2-1.4
 mkdir src install
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/mpich2-1.4.tar.gz' 'mpich2-1.4.tar.gz'
 
 #Untar 
Index: /issm/branches/trunk-jpl-damage/externalpackages/mpich2/install-1.4-macosx32.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/mpich2/install-1.4-macosx32.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/mpich2/install-1.4-macosx32.sh	(revision 12258)
@@ -4,4 +4,7 @@
 rm -rf src install mpich2-1.4
 mkdir src install
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/mpich2-1.4.tar.gz' 'mpich2-1.4.tar.gz'
 
 #Untar 
Index: /issm/branches/trunk-jpl-damage/externalpackages/mpich2/install-1.4-macosx64.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/mpich2/install-1.4-macosx64.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/mpich2/install-1.4-macosx64.sh	(revision 12258)
@@ -4,4 +4,7 @@
 rm -rf src install mpich2-1.4
 mkdir src install
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/mpich2-1.4.tar.gz' 'mpich2-1.4.tar.gz'
 
 #Untar 
Index: /issm/branches/trunk-jpl-damage/externalpackages/ncview/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/ncview/install.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/ncview/install.sh	(revision 12258)
@@ -4,4 +4,7 @@
 rm -rf install
 mkdir install
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/ncview-1.93g.tar.gz' 'ncview-1.93g.tar.gz'
 
 #Untar 
Index: /issm/branches/trunk-jpl-damage/externalpackages/netcdf/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/netcdf/install.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/netcdf/install.sh	(revision 12258)
@@ -4,4 +4,7 @@
 rm -rf install netcdf-4.0.1
 mkdir install
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/netcdf-4.0.1.tar.gz' 'netcdf-4.0.1.tar.gz'
 
 #Untar 
Index: /issm/branches/trunk-jpl-damage/externalpackages/nose/install-macosx64sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/nose/install-macosx64sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/nose/install-macosx64sh	(revision 12258)
@@ -1,3 +1,3 @@
-#/bin/bash
+#!/bin/bash
 #Install Python nose module
 
@@ -18,4 +18,6 @@
 if [[ $pythonversion == "2" ]];then
 
+	#Download from ISSM server
+	$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/nose-1.1.2.tar.gz' 'nose-1.1.2.tar.gz'
 	tar -zxvf  nose-1.1.2.tar.gz
 	mv nose-1.1.2 src
Index: /issm/branches/trunk-jpl-damage/externalpackages/oofem/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/oofem/install.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/oofem/install.sh	(revision 12258)
@@ -5,4 +5,7 @@
 rm -rf oofem-2.0
 mkdir src
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/oofem-2.0.tar.gz' 'oofem-2.0.tar.gz'
 
 #Untar 
Index: /issm/branches/trunk-jpl-damage/externalpackages/pcre/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/pcre/install.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/pcre/install.sh	(revision 12258)
@@ -5,4 +5,7 @@
 rm -rf pcre-8.21
 mkdir install
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/pcre-8.21.tar.gz' 'pcre-8.21.tar.gz'
 
 #Untar and move python into install directory
Index: /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-2.3.2-altix64-castor.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-2.3.2-altix64-castor.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-2.3.2-altix64-castor.sh	(revision 12258)
@@ -8,4 +8,7 @@
 	rm -rf install petsc-2.3.2-p3 src
 	mkdir install src
+
+	#Download from ISSM server
+	$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/petsc-2.3.2-p3.tar.gz' 'petsc-2.3.2-p3.tar.gz'
 
 	#Untar and move petsc to install directory
Index: /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-2.3.2-cosmos.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-2.3.2-cosmos.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-2.3.2-cosmos.sh	(revision 12258)
@@ -4,4 +4,7 @@
 rm -rf install petsc-2.3.2-p3 src
 mkdir install src
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/petsc-2.3.2-p3.tar.gz' 'petsc-2.3.2-p3.tar.gz'
 
 #Untar and move petsc to install directory
Index: /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-2.3.2-linux64-astrid.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-2.3.2-linux64-astrid.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-2.3.2-linux64-astrid.sh	(revision 12258)
@@ -4,4 +4,7 @@
 rm -rf install petsc-2.3.2-p3 src
 mkdir install src
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/petsc-2.3.2-p3.tar.gz' 'petsc-2.3.2-p3.tar.gz'
 
 #Untar and move petsc to install directory
Index: /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-2.3.2-macosx32-eric.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-2.3.2-macosx32-eric.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-2.3.2-macosx32-eric.sh	(revision 12258)
@@ -8,4 +8,7 @@
 	rm -rf install petsc-2.3.2-p3 src
 	mkdir install src
+
+	#Download from ISSM server
+	$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/petsc-2.3.2-p3.tar.gz' 'petsc-2.3.2-p3.tar.gz'
 
 	#Untar and move petsc to install directory
Index: /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-2.3.2-macosx32-ogive.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-2.3.2-macosx32-ogive.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-2.3.2-macosx32-ogive.sh	(revision 12258)
@@ -4,4 +4,7 @@
 rm -rf install petsc-2.3.2-p3 src
 mkdir install src
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/petsc-2.3.2-p3.tar.gz' 'petsc-2.3.2-p3.tar.gz'
 
 #Untar and move petsc to install directory
Index: /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-2.3.2-macosx64.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-2.3.2-macosx64.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-2.3.2-macosx64.sh	(revision 12258)
@@ -4,4 +4,7 @@
 rm -rf install petsc-2.3.2-p3 src
 mkdir install src
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/petsc-2.3.2-p3.tar.gz' 'petsc-2.3.2-p3.tar.gz'
 
 #Untar and move petsc to install directory
Index: /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-2.3.2-pleiades.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-2.3.2-pleiades.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-2.3.2-pleiades.sh	(revision 12258)
@@ -8,4 +8,7 @@
 	rm -rf install petsc-2.3.2-p3 src
 	mkdir install src
+
+	#Download from ISSM server
+	$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/petsc-2.3.2-p3.tar.gz' 'petsc-2.3.2-p3.tar.gz'
 
 	#Untar and move petsc to install directory
Index: /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-2.3.2-win32-eric.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-2.3.2-win32-eric.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-2.3.2-win32-eric.sh	(revision 12258)
@@ -4,4 +4,7 @@
 rm -rf install petsc-2.3.2-p3 src
 mkdir install src
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/petsc-2.3.2-p3.tar.gz' 'petsc-2.3.2-p3.tar.gz'
 
 #Untar and move petsc to install directory
Index: /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-2.3.2-win7.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-2.3.2-win7.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-2.3.2-win7.sh	(revision 12258)
@@ -4,4 +4,7 @@
 rm -rf install petsc-2.3.2-p3 src
 mkdir install src
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/petsc-2.3.2-p3.tar.gz' 'petsc-2.3.2-p3.tar.gz'
 
 #Untar and move petsc to install directory
Index: /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-3.1-altix64-castor.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-3.1-altix64-castor.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-3.1-altix64-castor.sh	(revision 12258)
@@ -8,4 +8,7 @@
 	rm -rf install petsc-3.1-p7 src
 	mkdir install src
+
+	#Download from ISSM server
+	$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/petsc-3.1-p7.tar.gz' 'petsc-3.1-p7.tar.gz'
 
 	#Untar and move petsc to install directory
Index: /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-3.1-cosmos.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-3.1-cosmos.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-3.1-cosmos.sh	(revision 12258)
@@ -4,4 +4,7 @@
 rm -rf install petsc-3.1-p7 src
 mkdir install src
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/petsc-3.1-p7.tar.gz' 'petsc-3.1-p7.tar.gz'
 
 #Untar and move petsc to install directory
Index: /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-3.1-linux64-astrid.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-3.1-linux64-astrid.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-3.1-linux64-astrid.sh	(revision 12258)
@@ -4,4 +4,7 @@
 rm -rf install petsc-3.1-p7 src
 mkdir install src
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/petsc-3.1-p7.tar.gz' 'petsc-3.1-p7.tar.gz'
 
 #Untar and move petsc to install directory
Index: /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-3.1-macosx32-mathieu.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-3.1-macosx32-mathieu.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-3.1-macosx32-mathieu.sh	(revision 12258)
@@ -4,4 +4,7 @@
 rm -rf install petsc-3.1-p7 src
 mkdir install src
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/petsc-3.1-p7.tar.gz' 'petsc-3.1-p7.tar.gz'
 
 #Untar and move petsc to install directory
Index: /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-3.1-macosx32-ogive.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-3.1-macosx32-ogive.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-3.1-macosx32-ogive.sh	(revision 12258)
@@ -4,4 +4,7 @@
 rm -rf install petsc-3.1-p7 src
 mkdir install src
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/petsc-3.1-p7.tar.gz' 'petsc-3.1-p7.tar.gz'
 
 #Untar and move petsc to install directory
Index: /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-3.1-pleiades.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-3.1-pleiades.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-3.1-pleiades.sh	(revision 12258)
@@ -8,4 +8,7 @@
 	rm -rf install petsc-3.1-p7 src
 	mkdir install src
+
+	#Download from ISSM server
+	$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/petsc-3.1-p7.tar.gz' 'petsc-3.1-p7.tar.gz'
 
 	#Untar and move petsc to install directory
Index: /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-3.1-ubuntu64.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-3.1-ubuntu64.sh	(revision 12258)
+++ /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-3.1-ubuntu64.sh	(revision 12258)
@@ -0,0 +1,39 @@
+#!/bin/bash
+
+#Some cleanup
+rm -rf install petsc-3.1-p7 src
+mkdir install src
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/petsc-3.1-p7.tar.gz' 'petsc-3.1-p7.tar.gz'
+
+#Untar and move petsc to install directory
+tar -zxvf  petsc-3.1-p7.tar.gz
+mv petsc-3.1-p7/* src/
+rm -rf petsc-3.1-p7
+
+#configure
+cd src
+./config/configure.py \
+ --prefix="$ISSM_DIR/externalpackages/petsc/install" \
+ --with-mpi-dir=$ISSM_DIR/externalpackages/mpich2/install \
+ --PETSC_ARCH=linux-gnu\
+ --PETSC_DIR="$ISSM_DIR/externalpackages/petsc/src" \
+ --with-debugging=0 \
+ --with-shared=0 \
+ --download-mumps=yes \
+ --download-scalapack=yes \
+ --download-blacs=yes \
+ --download-blas=yes \
+ --download-f-blas-lapack=yes \
+ --download-parmetis=yes \
+ --FFLAGS=-I$ISSM_DIR/externalpackages/mpich2/install/include \
+ --download-plapack=yes \
+ --COPTFLAGS="-O2" \
+ --FOPTFLAGS="-O2" \
+ --CXXOPTFLAGS="-O2" \
+ --with-pic=1
+
+#Compile petsc and install it
+make
+make install
Index: /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-3.1-win7.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-3.1-win7.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-3.1-win7.sh	(revision 12258)
@@ -4,4 +4,7 @@
 rm -rf install petsc-3.1-p7 src
 mkdir install src
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/petsc-3.1-p7.tar.gz' 'petsc-3.1-p7.tar.gz'
 
 #Untar and move petsc to install directory
Index: /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-3.2-greenplanet.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-3.2-greenplanet.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-3.2-greenplanet.sh	(revision 12258)
@@ -4,4 +4,7 @@
 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
Index: /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-3.2-linux64.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-3.2-linux64.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-3.2-linux64.sh	(revision 12258)
@@ -4,4 +4,7 @@
 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
Index: /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-3.2-macosx64.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-3.2-macosx64.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-3.2-macosx64.sh	(revision 12258)
@@ -4,4 +4,7 @@
 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
Index: /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-3.2-pleiades.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-3.2-pleiades.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/petsc/install-3.2-pleiades.sh	(revision 12258)
@@ -2,5 +2,5 @@
 #Step 1: unzip and install
 #Step 2: After Plapack implodes
-STEP=2
+STEP=1
 
 if [ $STEP -eq 1 ]; then
@@ -8,4 +8,7 @@
 	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
@@ -38,5 +41,5 @@
 		--CXXOPTFLAGS=" -O3 -xS" \
 		--with-pic=1
-	echo "== Fix Plapack compilation manually (http://issm.jpl.nasa.gov/installation/compilationtroubleshooting/petsc31/) =="
+	echo "== Fix Plapack compilation manually (http://issm.jpl.nasa.gov/documentation/faq/petsc32/) =="
 	echo "== Then run STEP=2 =="
 fi
@@ -66,4 +69,19 @@
 	 --CXXOPTFLAGS=" -O3 -xS" \
 	 --with-pic=1
+	 cat > src/script.queue << EOF
+#PBS -S /bin/bash
+#PBS -q debug 
+#PBS -l select=1:ncpus=1:model=har 
+#PBS -l walltime=200 
+#PBS -W group_list=s1010 
+#PBS -m e 
+. /usr/share/modules/init/bash 
+module load comp-intel/11.1.046 
+module load mpi/mpt.1.25 
+module load math/intel_mkl_64_10.0.011 
+export PATH="$PATH:." 
+export MPI_GROUP_MAX=64 
+mpiexec -np 1 ./conftest-linux-gnu-ia64-intel.py
+EOF
 	echo "== Follow PETSc's instructions"
 fi
Index: /issm/branches/trunk-jpl-damage/externalpackages/polygonclipper/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/polygonclipper/install.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/polygonclipper/install.sh	(revision 12258)
@@ -3,4 +3,7 @@
 #Some cleanup
 rm -rf install
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/PolygonClipper.zip' 'PolygonClipper.zip'
 
 #install
Index: /issm/branches/trunk-jpl-damage/externalpackages/pyclips/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/pyclips/install.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/pyclips/install.sh	(revision 12258)
@@ -5,4 +5,7 @@
 rm -rf pyclips-1.0.7.348
 mkdir install
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/pyclips-1.0.7.348.tar.gz' 'pyclips-1.0.7.348.tar.gz'
 
 #Untar 
Index: /issm/branches/trunk-jpl-damage/externalpackages/python/install-linux64-astrid.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/python/install-linux64-astrid.sh	(revision 12258)
+++ /issm/branches/trunk-jpl-damage/externalpackages/python/install-linux64-astrid.sh	(revision 12258)
@@ -0,0 +1,43 @@
+#!/bin/bash
+#wget http://python.org/ftp/python/version/Python-version.tgz
+
+#version=3.2.2
+version=2.7.2
+
+#Some cleanup
+rm -rf install src
+rm -rf Python-$version
+mkdir install src
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py http://issm.jpl.nasa.gov/files/externalpackages/Python-$version.tgz Python-$version.tgz
+
+#exports
+export CC
+
+#Untar and move python into install directory
+tar -zxvf  Python-$version.tgz
+mv Python-$version/* src
+rm -rf Python-$version
+
+#Configure doxygen
+cd src 
+./configure --prefix="$ISSM_DIR/externalpackages/python/install" 
+
+if [ -z $1 ]; then
+	make
+else
+	make -j $1
+fi
+make install
+
+#Some modifications to be done in case version is 3.2: 
+if [[ $version == "3.2.2" ]]; then 
+	cd install/bin
+	ln -s python3.2 python 
+	cd ../
+	ln -s Python.framework/Versions/3.2/include/python3.2m include
+	ln -s Python.framework/Versions/3.2/lib/ lib
+
+
+fi
Index: /issm/branches/trunk-jpl-damage/externalpackages/python/install-macosx-lion.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/python/install-macosx-lion.sh	(revision 12258)
+++ /issm/branches/trunk-jpl-damage/externalpackages/python/install-macosx-lion.sh	(revision 12258)
@@ -0,0 +1,42 @@
+#!/bin/bash
+#wget http://python.org/ftp/python/version/Python-version.tgz
+
+#version=3.2.2
+version=2.7.2
+
+#Some cleanup
+rm -rf install src
+rm -rf Python-$version
+mkdir install src
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py http://issm.jpl.nasa.gov/files/externalpackages/Python-$version.tgz Python-$version.tgz
+
+#exports
+export CC
+
+#Untar and move python into install directory
+tar -zxvf  Python-$version.tgz
+mv Python-$version/* src
+rm -rf Python-$version
+
+#Configure doxygen
+cd src 
+./configure --prefix="$ISSM_DIR/externalpackages/python/install" --enable-framework="$ISSM_DIR/externalpackages/python/install"
+if [ -z $1 ]; then
+	make
+else
+	make -j $1
+fi
+make install
+
+#Some modifications to be done in case version is 3.2: 
+if [[ $version == "3.2.2" ]]; then 
+	cd install/bin
+	ln -s python3.2 python 
+	cd ../
+	ln -s Python.framework/Versions/3.2/include/python3.2m include
+	ln -s Python.framework/Versions/3.2/lib/ lib
+
+
+fi
Index: /issm/branches/trunk-jpl-damage/externalpackages/python/install-macosx-snowleopard.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/python/install-macosx-snowleopard.sh	(revision 12258)
+++ /issm/branches/trunk-jpl-damage/externalpackages/python/install-macosx-snowleopard.sh	(revision 12258)
@@ -0,0 +1,41 @@
+#!/bin/bash
+#wget http://python.org/ftp/python/version/Python-version.tgz
+
+#version=3.2.2
+version=2.7.2
+
+#Some cleanup
+rm -rf install src
+rm -rf Python-$version
+mkdir install src
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py http://issm.jpl.nasa.gov/files/externalpackages/Python-$version.tgz Python-$version.tgz
+
+#exports
+export CC
+export MACOSX_DEPLOYMENT_TARGET=10.6
+
+#Untar and move python into install directory
+tar -zxvf  Python-$version.tgz
+mv Python-$version/* src
+rm -rf Python-$version
+
+#Configure doxygen
+cd src 
+./configure --prefix="$ISSM_DIR/externalpackages/python/install" --enable-framework="$ISSM_DIR/externalpackages/python/install" --enable-universalsdk --with-universal-archs="32-bit"
+if [ -z $1 ]; then
+	make
+else
+	make -j $1
+fi
+make install
+
+#Some modifications to be done in case version is 3.2: 
+if [[ $version == "3.2.2" ]]; then 
+	cd install/bin
+	ln -s python3.2 python 
+	cd ../
+	ln -s Python.framework/Versions/3.2/include/python3.2m include
+	ln -s Python.framework/Versions/3.2/lib/ lib
+fi
Index: sm/branches/trunk-jpl-damage/externalpackages/python/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/python/install.sh	(revision 12257)
+++ 	(revision )
@@ -1,39 +1,0 @@
-#!/bin/bash
-#wget http://python.org/ftp/python/version/Python-version.tgz
-
-version=3.2.2
-#version=2.7.2
-
-#Some cleanup
-rm -rf install src
-rm -rf Python-$version
-mkdir install src
-
-#exports
-export CC
-
-#Untar and move python into install directory
-tar -zxvf  Python-$version.tgz
-mv Python-$version/* src
-rm -rf Python-$version
-
-#Configure doxygen
-cd src 
-./configure --prefix="$ISSM_DIR/externalpackages/python/install" --enable-framework="$ISSM_DIR/externalpackages/python/install"
-if [ -z $1 ]; then
-	make
-else
-	make -j $1
-fi
-make install
-
-#Some modifications to be done in case version is 3.2: 
-if [[ $version == "3.2.2" ]]; then 
-	cd install/bin
-	ln -s python3.2 python 
-	cd ../
-	ln -s Python.framework/Versions/3.2/include/python3.2m include
-	ln -s Python.framework/Versions/3.2/lib/ lib
-
-
-fi
Index: /issm/branches/trunk-jpl-damage/externalpackages/qhull/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/qhull/install.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/qhull/install.sh	(revision 12258)
@@ -4,4 +4,7 @@
 rm -rf src install qhull-2003.1
 mkdir src install
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/qhull-2003.1.tar.gz' 'qhull-2003.1.tar.gz'
 
 #Untar 
Index: /issm/branches/trunk-jpl-damage/externalpackages/rats/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/rats/install.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/rats/install.sh	(revision 12258)
@@ -3,4 +3,7 @@
 #Erase install
 rm -rf install  src rats-2.3
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/rats-2.3.tar.gz' 'rats-2.3.tar.gz'
 
 #install directory
Index: /issm/branches/trunk-jpl-damage/externalpackages/readline/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/readline/install.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/readline/install.sh	(revision 12258)
@@ -5,4 +5,7 @@
 rm -rf readline-6.2.2
 mkdir src 
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/readline-6.2.2.tar.gz' 'readline-6.2.2.tar.gz'
 
 #Untar 
Index: /issm/branches/trunk-jpl-damage/externalpackages/rose/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/rose/install.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/rose/install.sh	(revision 12258)
@@ -4,4 +4,7 @@
 rm -rf source build install
 mkdir install source build
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/rose-0.9.5a-13219.tar.gz' 'rose-0.9.5a-13219.tar.gz'
 
 #Untar 
Index: /issm/branches/trunk-jpl-damage/externalpackages/satstress/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/satstress/install.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/satstress/install.sh	(revision 12258)
@@ -4,4 +4,7 @@
 rm -rf install SatStress-0.1.2
 mkdir install
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/SatStress-0.1.2.tar.gz' 'SatStress-0.1.2.tar.gz'
 
 #Untar 
Index: /issm/branches/trunk-jpl-damage/externalpackages/scipy/README
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/scipy/README	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/scipy/README	(revision 12258)
@@ -1,2 +1,2 @@
 You will find instructions on scipy at: 
-http://www.scipy.org/Installing_SciPy/Mac_OS_X#head-ba1926aec910a9a1deaf9eff99e38ee23103a3b3
+http://www.scipy.org/Installing_SciPy/Mac_OS_X
Index: /issm/branches/trunk-jpl-damage/externalpackages/scipy/install-linux64.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/scipy/install-linux64.sh	(revision 12258)
+++ /issm/branches/trunk-jpl-damage/externalpackages/scipy/install-linux64.sh	(revision 12258)
@@ -0,0 +1,49 @@
+#!/bin/bash
+
+#1: install numpy
+#2 install scipy
+#3 erase
+install=2
+
+
+export CC="gcc -fPIC"
+export CXX="g++ -fPIC"
+export F77="gfortran -fPIC"
+export FC="gfortran -fPIC"
+export FFLAGS=-ff2c
+
+
+if [[ $install == "1" ]];then 
+
+	#download numpy first
+
+	export GIT_SSL_NO_VERIFY=true 
+	git clone https://github.com/numpy/numpy.git
+
+	#install numpy
+	cd numpy
+	python setup.py build
+	python setup.py install
+
+	
+elif [[ $install == "2" ]];then 
+	
+	#download scipy
+	export GIT_SSL_NO_VERIFY=true 
+	git clone https://github.com/scipy/scipy.git
+
+	#install scipy
+	cd scipy
+	export  BLAS_SRC=$ISSM_DIR/externalpackages/blas/install/lib
+	export  BLAS=$ISSM_DIR/externalpackages/blas/install/lib
+	export  LAPACK_SRC=$ISSM_DIR/externalpackages/lapack/install/lib
+	export  LAPACK=$ISSM_DIR/externalpackages/lapack/install/lib
+
+	python setup.py build
+	python setup.py install
+
+elif [[ $install == "3" ]];then 
+	rm -rf numpy scipy
+else 
+	echo "Choice not covered"
+fi
Index: /issm/branches/trunk-jpl-damage/externalpackages/scipy/install-macosx-lion.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/scipy/install-macosx-lion.sh	(revision 12258)
+++ /issm/branches/trunk-jpl-damage/externalpackages/scipy/install-macosx-lion.sh	(revision 12258)
@@ -0,0 +1,39 @@
+#!/bin/bash
+
+#1: install numpy
+#2 install scipy
+#3 erase
+install=2
+
+
+export CC=gcc
+export CXX=g++
+export FFLAGS=-ff2c
+
+
+if [[ $install == "1" ]];then 
+
+	#download numpy first
+	git clone https://github.com/numpy/numpy.git
+
+	#install numpy
+	cd numpy
+	python setup.py build
+	python setup.py install
+
+	
+elif [[ $install == "2" ]];then 
+	
+	#download scipy
+	git clone https://github.com/scipy/scipy.git
+
+	#install scipy
+	cd scipy
+	python setup.py build
+	python setup.py install
+
+elif [[ $install == "3" ]];then 
+	rm -rf numpy scipy
+else 
+	echo "Choice not covered"
+fi
Index: /issm/branches/trunk-jpl-damage/externalpackages/scipy/install-macosx-snowleopard.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/scipy/install-macosx-snowleopard.sh	(revision 12258)
+++ /issm/branches/trunk-jpl-damage/externalpackages/scipy/install-macosx-snowleopard.sh	(revision 12258)
@@ -0,0 +1,41 @@
+#!/bin/bash
+PYVERSION=2.7
+PYTHON=python${PYVERSION}
+
+#1: install numpy
+#2 install scipy
+#3 erase
+install=2
+
+export CC=/usr/bin/gcc-4.0
+export CXX=/usr/bin/g++-4.0
+
+if [[ $install == "1" ]];then 
+
+	#download numpy first
+	git clone https://github.com/numpy/numpy.git
+
+	#install numpy
+	cd numpy
+	python setup.py build
+	python setup.py install
+	cd ..
+	${PYTHON} -c "import numpy; print 'Installed NumPy', numpy.__version__"
+	
+elif [[ $install == "2" ]];then 
+	
+	#download scipy
+	git clone https://github.com/scipy/scipy.git
+
+	#install scipy
+	cd scipy
+	python setup.py build
+	python setup.py install
+	cd ..
+	${PYTHON} -c "import scipy; print 'Installed SciPy', scipy.__version__"
+
+elif [[ $install == "3" ]];then 
+	rm -rf numpy scipy
+else 
+	echo "Choice not covered"
+fi
Index: sm/branches/trunk-jpl-damage/externalpackages/scipy/install-macosx64.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/scipy/install-macosx64.sh	(revision 12257)
+++ 	(revision )
@@ -1,39 +1,0 @@
-#!/bin/bash
-
-#1: install numpy
-#2 install scipy
-#3 erase
-install=2
-
-
-export CC=gcc
-export CXX=g++
-export FFLAGS=-ff2c
-
-
-if [[ $install == "1" ]];then 
-
-	#download numpy first
-	git clone https://github.com/numpy/numpy.git
-
-	#install numpy
-	cd numpy
-	python setup.py build
-	python setup.py install
-
-	
-elif [[ $install == "2" ]];then 
-	
-	#download scipy
-	git clone https://github.com/scipy/scipy.git
-
-	#install scipy
-	cd scipy
-	python setup.py build
-	python setup.py install
-
-elif [[ $install == "3" ]];then 
-	rm -rf numpy scipy
-else 
-	echo "Choice not covered"
-fi
Index: /issm/branches/trunk-jpl-damage/externalpackages/scotch/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/scotch/install.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/scotch/install.sh	(revision 12258)
@@ -8,4 +8,7 @@
 # Create src and install directories
 mkdir src install 
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/scotch_5.1.6.tar.gz' 'scotch_5.1.6.tar.gz'
 
 # Untar 
Index: /issm/branches/trunk-jpl-damage/externalpackages/shapelib/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/shapelib/install.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/shapelib/install.sh	(revision 12258)
@@ -6,4 +6,8 @@
 rm -rf install 
 mkdir src install 
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/shapelib-1.2.10.tar.gz' 'shapelib-1.2.10.tar.gz'
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/shape_eg_data.zip' 'shape_eg_data.zip'
 
 # Untar 
Index: /issm/branches/trunk-jpl-damage/externalpackages/slepc/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/slepc/install.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/slepc/install.sh	(revision 12258)
@@ -4,4 +4,7 @@
 rm -rf install slepc-2.3.2
 mkdir install
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/slepc-2.3.2.tgz' 'slepc-2.3.2.tgz'
 
 #Untar 
Index: /issm/branches/trunk-jpl-damage/externalpackages/swig/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/swig/install.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/swig/install.sh	(revision 12258)
@@ -5,4 +5,7 @@
 rm -rf swig-2.0.4
 mkdir install
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/swig-2.0.4.tar.gz' 'swig-2.0.4.tar.gz'
 
 #Untar and move python into install directory
Index: /issm/branches/trunk-jpl-damage/externalpackages/tao/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/tao/install.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/tao/install.sh	(revision 12258)
@@ -6,4 +6,7 @@
 rm -rf install tao-2.0-p3
 mkdir install
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/tao-2.0-p3.tar.gz' 'tao-2.0-p3.tar.gz'
 
 #Untar 
Index: /issm/branches/trunk-jpl-damage/externalpackages/tex2im/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/tex2im/install.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/tex2im/install.sh	(revision 12258)
@@ -4,4 +4,7 @@
 rm -rf install
 mkdir install
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/tex2im-1.8.tar.gz' 'tex2im-1.8.tar.gz'
 
 #Untar 
Index: /issm/branches/trunk-jpl-damage/externalpackages/triangle/install-altix64.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/triangle/install-altix64.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/triangle/install-altix64.sh	(revision 12258)
@@ -4,4 +4,7 @@
 rm -rf install triangle
 mkdir install
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/triangle.zip' 'triangle.zip'
 
 #Untar 
Index: /issm/branches/trunk-jpl-damage/externalpackages/triangle/install-android-4.0.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/triangle/install-android-4.0.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/triangle/install-android-4.0.sh	(revision 12258)
@@ -4,8 +4,10 @@
 matlab=0
 
-
 #Some cleanup 
 rm -rf install triangle
 mkdir install
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/triangle.zip' 'triangle.zip'
 
 #Untar 
Index: /issm/branches/trunk-jpl-damage/externalpackages/triangle/install-linux64.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/triangle/install-linux64.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/triangle/install-linux64.sh	(revision 12258)
@@ -4,4 +4,7 @@
 rm -rf install triangle
 mkdir install
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/triangle.zip' 'triangle.zip'
 
 #Untar 
Index: /issm/branches/trunk-jpl-damage/externalpackages/triangle/install-macosx32.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/triangle/install-macosx32.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/triangle/install-macosx32.sh	(revision 12258)
@@ -4,4 +4,7 @@
 rm -rf install triangle
 mkdir install
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/triangle.zip' 'triangle.zip'
 
 #Untar 
Index: /issm/branches/trunk-jpl-damage/externalpackages/triangle/install-macosx64.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/triangle/install-macosx64.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/triangle/install-macosx64.sh	(revision 12258)
@@ -8,4 +8,7 @@
 rm -rf install triangle
 mkdir install
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/triangle.zip' 'triangle.zip'
 
 #Untar 
Index: /issm/branches/trunk-jpl-damage/externalpackages/triangle/install-pleiades.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/triangle/install-pleiades.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/triangle/install-pleiades.sh	(revision 12258)
@@ -4,4 +4,7 @@
 rm -rf install triangle
 mkdir install
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/triangle.zip' 'triangle.zip'
 
 #Untar 
Index: /issm/branches/trunk-jpl-damage/externalpackages/triangle/install-win32.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/triangle/install-win32.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/triangle/install-win32.sh	(revision 12258)
@@ -4,4 +4,7 @@
 rm -rf install triangle
 mkdir install
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/triangle.zip' 'triangle.zip'
 
 #Untar 
Index: /issm/branches/trunk-jpl-damage/externalpackages/triangle/install-win7.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/triangle/install-win7.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/triangle/install-win7.sh	(revision 12258)
@@ -4,4 +4,7 @@
 rm -rf install triangle
 mkdir install
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/triangle.zip' 'triangle.zip'
 
 #Untar 
Index: /issm/branches/trunk-jpl-damage/externalpackages/valgrind/install-altix64.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/valgrind/install-altix64.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/valgrind/install-altix64.sh	(revision 12258)
@@ -4,4 +4,7 @@
 rm -rf install valgrind-3.7.0
 mkdir install
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/valgrind-3.7.0.tar.bz2' 'valgrind-3.7.0.tar.bz2'
 
 #Untar 
Index: /issm/branches/trunk-jpl-damage/externalpackages/valgrind/install-linux64.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/valgrind/install-linux64.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/valgrind/install-linux64.sh	(revision 12258)
@@ -4,4 +4,7 @@
 rm -rf install valgrind-3.7.0
 mkdir install
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/valgrind-3.7.0.tar.bz2' 'valgrind-3.7.0.tar.bz2'
 
 #Untar 
Index: /issm/branches/trunk-jpl-damage/externalpackages/valgrind/install-macosx32.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/valgrind/install-macosx32.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/valgrind/install-macosx32.sh	(revision 12258)
@@ -4,4 +4,7 @@
 rm -rf install valgrind-3.7.0
 mkdir install
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/valgrind-3.7.0.tar.bz2' 'valgrind-3.7.0.tar.bz2'
 
 #Untar 
Index: /issm/branches/trunk-jpl-damage/externalpackages/valgrind/install-macosx64.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/valgrind/install-macosx64.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/valgrind/install-macosx64.sh	(revision 12258)
@@ -4,4 +4,7 @@
 rm -rf install valgrind-3.7.0
 mkdir install
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/valgrind-3.7.0.tar.bz2' 'valgrind-3.7.0.tar.bz2'
 
 #Untar 
Index: /issm/branches/trunk-jpl-damage/externalpackages/valgrind/install-win32.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/valgrind/install-win32.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/valgrind/install-win32.sh	(revision 12258)
@@ -4,4 +4,7 @@
 rm -rf install valgrind-3.7.0
 mkdir install
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/valgrind-3.7.0.tar.bz2' 'valgrind-3.7.0.tar.bz2'
 
 #Untar 
Index: /issm/branches/trunk-jpl-damage/externalpackages/vim/addons/vim/syntax/c.vim
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/vim/addons/vim/syntax/c.vim	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/vim/addons/vim/syntax/c.vim	(revision 12258)
@@ -547,4 +547,10 @@
 syn keyword cType QuadTree
 syn keyword cType SetOfE4
+syn keyword cType Variogram
+syn keyword cType GaussianVariogram
+syn keyword cType ExponentialVariogram
+syn keyword cType SphericalVariogram
+syn keyword cType Quadtree
+syn keyword cType Observation
 "ISSM's objects end
 
@@ -688,4 +694,8 @@
 syn keyword cConstant SettingsResultsAsPatchesEnum
 syn keyword cConstant SettingsWaitonlockEnum
+syn keyword cConstant DebugPetscProfilingEnum
+syn keyword cConstant PetscProfilingCurrentMemEnum
+syn keyword cConstant PetscProfilingCurrentFlopsEnum
+syn keyword cConstant PetscProfilingSolutionTimeEnum
 syn keyword cConstant SteadystateMaxiterEnum
 syn keyword cConstant SteadystateNumRequestedOutputsEnum
@@ -703,6 +713,7 @@
 syn keyword cConstant ThermalIsenthalpyEnum
 syn keyword cConstant ThicknessEnum
+syn keyword cConstant TimesteppingStartTimeEnum
+syn keyword cConstant TimesteppingFinalTimeEnum
 syn keyword cConstant TimesteppingCflCoefficientEnum
-syn keyword cConstant TimesteppingFinalTimeEnum
 syn keyword cConstant TimesteppingTimeAdaptEnum
 syn keyword cConstant TimesteppingTimeStepEnum
@@ -766,4 +777,5 @@
 syn keyword cConstant BoolInputEnum
 syn keyword cConstant BoolParamEnum
+syn keyword cConstant ContourEnum
 syn keyword cConstant ControlInputEnum
 syn keyword cConstant DatasetInputEnum
@@ -906,4 +918,5 @@
 syn keyword cConstant P1Enum
 syn keyword cConstant P1DGEnum
+syn keyword cConstant SaveResultsEnum
 syn keyword cConstant BoolElementResultEnum
 syn keyword cConstant BoolExternalResultEnum
@@ -920,4 +933,5 @@
 syn keyword cConstant PetscVecExternalResultEnum
 syn keyword cConstant StringExternalResultEnum
+syn keyword cConstant StepEnum
 syn keyword cConstant TimeEnum
 syn keyword cConstant TriaP1ElementResultEnum
Index: /issm/branches/trunk-jpl-damage/externalpackages/vim/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/vim/install.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/vim/install.sh	(revision 12258)
@@ -5,4 +5,7 @@
 rm -rf vim72
 mkdir install src
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/vim-7.2.tar.bz2' 'vim-7.2.tar.bz2'
 
 #Untar 
Index: /issm/branches/trunk-jpl-damage/externalpackages/windows/InstallInstructions.txt
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/windows/InstallInstructions.txt	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/windows/InstallInstructions.txt	(revision 12258)
@@ -42,4 +42,5 @@
 python: Python language interpreter
 unzip
+cygrunsrv
 
 
@@ -144,9 +145,15 @@
 
 How to setup a Cron job? 
-Download exim and cron from cygwin setup. Run exim-config (don't forget to launch your cygwin terminal as
-Administrator). If asked for a daemon name, type ntsec. Also, if cron complains about sendmail,
-symlink /usr/lib/sendmail to /usr/sbin/sendmail.  Then link /usr/sbin/sendmail
-to /usr/bin/exim. Alternatively, if you have an smtp server, you can download and configure
-ssmtp.  Run ssmtp-config
-as Administrator and link /usr/sbin/sendmail to /usr/bin/ssmtp. After the email has been configured,
-run cron-config as Administrator.
+First, make sure you downloaded cygrunsrv, otherwise the cron setup will only work on a per-session 
+basis! Also, make sure that you have an email correctly setup.  In particular, cron relies on the
+/usr/sbin/sendmail script. If it does not exist, cron will not send emails. Most email management 
+systems will create this script, but you need to check on it. 
+Run cron-config  and fill up the questions. For daemon name, type ntsec. 
+Be careful, make sure that you are running your terminal as Administrator, 
+otherwise your settings will be only user-based. 
+How to setup email? 
+
+Preferred way is through ssmtp. Download it on cygwin, and type ssmtp-config.  If the ssmtp 
+daemon does not create /usr/sbin/sendmail, be sure to create a symlink from the email client 
+to the latter file. Be careful, make sure that you are running your terminal as Administrator, 
+otherwise your settings will be only user-based. 
Index: /issm/branches/trunk-jpl-damage/externalpackages/windows/configs/sdk7.1.win7-32.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/windows/configs/sdk7.1.win7-32.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/windows/configs/sdk7.1.win7-32.sh	(revision 12258)
@@ -1,37 +1,37 @@
 declare -x ALLUSERSPROFILE="C:\\ProgramData"
-declare -x CL="/AI C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319"
-declare -x COMMONPROGRAMFILES="C:\\Program Files (x86)\\Common Files"
+declare -x CL="/AI C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319"
+declare -x COMMONPROGRAMFILES="C:\\Program Files\\Common Files"
 declare -x COMSPEC="C:\\Windows\\system32\\cmd.exe"
-declare -x CommandPromptType="Cross"
-declare -x CommonProgramW6432="C:\\Program Files\\Common Files"
+declare -x CommandPromptType="Native"
 declare -x Configuration="Debug"
 declare -x FP_NO_HOST_CHECK="NO"
 declare -x FrameworkVersion="v4.0.30319"
 declare -x HOMEDRIVE="C:"
-declare -x INCLUDE="C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\INCLUDE;C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\INCLUDE;C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\INCLUDE\\gl;C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\ATLMFC\\INCLUDE;"
+declare -x INCLUDE="C:\\Program Files\\Microsoft Visual Studio 10.0\\VC\\INCLUDE;C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\INCLUDE;C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\INCLUDE\\gl;"
 declare -x INFOPATH="/usr/local/info:/usr/share/info:/usr/info:"
 declare -x LANG="en_US.UTF-8"
-declare -x LIB="C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\Lib;C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\Lib;C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319;C:\\Windows\\Microsoft.NET\\Framework\\v3.5;;C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\ATLMFC\\LIB;"
-declare -x LIBPATH="C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319;C:\\Windows\\Microsoft.NET\\Framework\\v3.5;;C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\Lib;"
+declare -x LIB="C:\\Program Files\\Microsoft Visual Studio 10.0\\VC\\Lib;C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\Lib;C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319;C:\\Windows\\Microsoft.NET\\Framework\\v3.5;;"
+declare -x LIBPATH="C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319;C:\\Windows\\Microsoft.NET\\Framework\\v3.5;;C:\\Program Files\\Microsoft Visual Studio 10.0\\VC\\Lib;"
 declare -x MANPATH="/usr/local/man:/usr/share/man:/usr/man:"
-declare -x PATH="/usr/local/bin:/usr/bin:/cygdrive/c/Windows/Microsoft.NET/Framework/v4.0.30319:/cygdrive/c/Windows/Microsoft.NET/Framework/v3.5:/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 10.0/Common7/IDE:/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 10.0/Common7/Tools:/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 10.0/VC/Bin:/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 10.0/VC/Bin/VCPackages:/cygdrive/c/Program Files/Microsoft SDKs/Windows/v7.1/Bin/NETFX 4.0 Tools:/cygdrive/c/Program Files/Microsoft SDKs/Windows/v7.1/Bin:/cygdrive/c/Windows/system32:/cygdrive/c/Windows:/cygdrive/c/Windows/System32/Wbem:/cygdrive/c/Windows/System32/WindowsPowerShell/v1.0:/cygdrive/c/Program Files/Microsoft Windows Performance Toolkit:/cygdrive/c/MATLAB/R2011b32/runtime/win32:/cygdrive/c/MATLAB/R2011b32/bin:/cygdrive/c/MATLAB/R2011b/runtime/win64:/cygdrive/c/MATLAB/R2011b/bin:/cygdrive/c/Program Files (x86)/Microsoft SQL Server/100/Tools/Binn:/cygdrive/c/Program Files/Microsoft SQL Server/100/Tools/Binn:/cygdrive/c/Program Files/Microsoft SQL Server/100/DTS/Binn:/cygdrive/c/Program Files/Microsoft Network Monitor 3"
+declare -x PATH="/usr/local/bin:/usr/bin:/cygdrive/c/Windows/Microsoft.NET/Framework/v4.0.30319:/cygdrive/c/Windows/Microsoft.NET/Framework/v3.5:/cygdrive/c/Program Files/Microsoft Visual Studio 10.0/Common7/IDE:/cygdrive/c/Program Files/Microsoft Visual Studio 10.0/Common7/Tools:/cygdrive/c/Program Files/Microsoft Visual Studio 10.0/VC/Bin:/cygdrive/c/Program Files/Microsoft Visual Studio 10.0/VC/Bin/VCPackages:/cygdrive/c/Program Files/Microsoft SDKs/Windows/v7.1/Bin/NETFX 4.0 Tools:/cygdrive/c/Program Files/Microsoft SDKs/Windows/v7.1/Bin:/cygdrive/c/Windows/system32:/cygdrive/c/Windows:/cygdrive/c/Windows/System32/Wbem:/cygdrive/c/Windows/System32/WindowsPowerShell/v1.0:/cygdrive/c/MATLAB/R2012a/runtime/win32:/cygdrive/c/MATLAB/R2012a/bin:/cygdrive/c/Program Files/Microsoft Windows Performance Toolkit"
 declare -x PATHEXT=".COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC"
+declare -x PRINTER="137.78.140.129#:1"
 declare -x PROCESSOR_ARCHITECTURE="x86"
-declare -x PROCESSOR_ARCHITEW6432="AMD64"
-declare -x PROCESSOR_IDENTIFIER="Intel64 Family 6 Model 42 Stepping 7, GenuineIntel"
+declare -x PROCESSOR_IDENTIFIER="x86 Family 6 Model 42 Stepping 7, GenuineIntel"
 declare -x PROCESSOR_LEVEL="6"
 declare -x PROCESSOR_REVISION="2a07"
-declare -x PROGRAMFILES="C:\\Program Files (x86)"
+declare -x PROGRAMFILES="C:\\Program Files"
 declare -x PSModulePath="C:\\Windows\\system32\\WindowsPowerShell\\v1.0\\Modules\\"
 declare -x PUBLIC="C:\\Users\\Public"
 declare -x PlatformToolset="Windows7.1SDK"
 declare -x ProgramData="C:\\ProgramData"
-declare -x ProgramW6432="C:\\Program Files"
 declare -x SHELL="/bin/bash"
 declare -x SYSTEMDRIVE="C:"
 declare -x SYSTEMROOT="C:\\Windows"
+declare -x TARGET_CPU="x86"
 declare -x TARGET_PLATFORM="WIN7"
 declare -x TERM="cygwin"
-declare -x VS100COMNTOOLS="C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\Common7\\Tools\\"
+declare -x ToolsVersion="4.0"
+declare -x VS100COMNTOOLS="C:\\Program Files\\Microsoft Visual Studio 10.0\\Common7\\Tools\\"
 declare -x WINDIR="C:\\Windows"
 declare -x WindowsSDKDir="C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\"
Index: /issm/branches/trunk-jpl-damage/externalpackages/windows/configs/sdk7.1.win7-64.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/windows/configs/sdk7.1.win7-64.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/windows/configs/sdk7.1.win7-64.sh	(revision 12258)
@@ -13,5 +13,4 @@
 declare -x LIB="C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\Lib\\amd64;C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\Lib\\X64;"
 declare -x LIBPATH="C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319;C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319;C:\\Windows\\Microsoft.NET\\Framework64\\v3.5;C:\\Windows\\Microsoft.NET\\Framework\\v3.5;;C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\Lib\\amd64;"
-declare -x LOCALAPPDATA="C:\\Users\\schlegel\\AppData\\Local"
 declare -x MANPATH="/usr/local/man:/usr/share/man:/usr/man:"
 declare -x PATH="/usr/local/bin:/usr/bin:/usr/include:/cygdrive/c/cygwin/usr/bin:/cygdrive/c/cygwin/usr/include:/cygdrive/c/Windows/Microsoft.NET/Framework64/v4.0.30319:/cygdrive/c/Windows/Microsoft.NET/Framework/v4.0.30319:/cygdrive/c/Windows/Microsoft.NET/Framework64/v3.5:/cygdrive/c/Windows/Microsoft.NET/Framework/v3.5:/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 10.0/Common7/IDE:/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 10.0/Common7/Tools:/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 10.0/VC/Bin/amd64:/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 10.0/VC/Bin/VCPackages:/cygdrive/c/Program Files/Microsoft SDKs/Windows/v7.1/Bin/NETFX 4.0 Tools/x64:/cygdrive/c/Program Files/Microsoft SDKs/Windows/v7.1/Bin/x64:/cygdrive/c/Program Files/Microsoft SDKs/Windows/v7.1/Bin:/cygdrive/c/Windows/system32:/cygdrive/c/Windows:/cygdrive/c/Windows/System32/Wbem:/cygdrive/c/Windows/System32/WindowsPowerShell/v1.0:/cygdrive/c/Program Files/Microsoft Windows Performance Toolkit:/cygdrive/c/MATLAB/R2012a/runtime/win64:/cygdrive/c/MATLAB/R2012a/bin:/cygdrive/c/MATLAB/R2012a/extern/include:/cygdrive/c/MATLAB/R2011a/runtime/win64:/cygdrive/c/MATLAB/R2011a/bin:/cygdrive/c/MATLAB/R2011a/extern/include"
@@ -41,6 +40,4 @@
 declare -x TMP="/tmp"
 declare -x ToolsVersion="4.0"
-declare -x USER="schlegel"
-declare -x USERNAME="schlegel"
 declare -x VS100COMNTOOLS="C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\Common7\\Tools\\"
 declare -x WINDIR="C:\\Windows"
Index: /issm/branches/trunk-jpl-damage/externalpackages/windows/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/windows/install.sh	(revision 12258)
+++ /issm/branches/trunk-jpl-damage/externalpackages/windows/install.sh	(revision 12258)
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/win7.sdk7.1.exe' 'win7.sdk7.1.exe'
Index: /issm/branches/trunk-jpl-damage/externalpackages/windows/windows_environment.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/windows/windows_environment.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/windows/windows_environment.sh	(revision 12258)
@@ -2,5 +2,5 @@
 
 #Where are the configuration files for each compiler: 
-config_dir="$ISSM_TIER/externalpackages/windows/configs"
+config_dir="$ISSM_DIR/externalpackages/windows/configs"
 
 #your choise of compiler: 
@@ -10,5 +10,15 @@
 # 4: intel compiler on WinXP
 
-compiler=2;
+#Determine OS version using uname: 
+version=`uname -s | grep 64`
+if [[ $version == "" ]];then
+	compiler=1
+else
+	compiler=2
+fi
+
+#If you want to override and use intel compilers: 
+#compiler=3;
+
 
 #source corresponding environment variables: 
@@ -24,5 +34,5 @@
 fi
 
-#finally, out of ISSM_TIER, we need to create an ISSM_TIER_WIN variable for Matlab to pick up on.
-ISSM_TIER_WIN=`cygpath -m $ISSM_TIER`
-export ISSM_TIER_WIN
+#finally, out of ISSM_DIR, we need to create an ISSM_DIR_WIN variable for Matlab to pick up on.
+ISSM_DIR_WIN=`cygpath -m $ISSM_DIR`
+export ISSM_DIR_WIN
Index: /issm/branches/trunk-jpl-damage/externalpackages/xerces/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/xerces/install.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/xerces/install.sh	(revision 12258)
@@ -4,4 +4,7 @@
 rm -rf install xerces-c-src_2_8_0 src
 mkdir install src
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/xerces-c-src_2_8_0.tar.gz' 'xerces-c-src_2_8_0.tar.gz'
 
 #Untar 
Index: /issm/branches/trunk-jpl-damage/externalpackages/yams/install.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/externalpackages/yams/install.sh	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/externalpackages/yams/install.sh	(revision 12258)
@@ -4,4 +4,9 @@
 rm -rf install
 mkdir install
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/yams2-linux.gz' 'yams2-linux.gz'
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/yams2-osx.gz' 'yams2-osx.gz'
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/yams2-win.exe' 'yams2-win.exe'
 
 #loop over the binaries
Index: /issm/branches/trunk-jpl-damage/m4/issm_options.m4
===================================================================
--- /issm/branches/trunk-jpl-damage/m4/issm_options.m4	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/m4/issm_options.m4	(revision 12258)
@@ -66,8 +66,10 @@
 			export CFLAGS=" -O3 -xS -D_INTEL_LINUX_ "
 		elif test $VENDOR = arm-linux; then
-			export CC=$ANDROID_DIR/arm-linux-android-4.0/bin/arm-linux-androideabi-cc
-			export CXX=$ANDROID_DIR/arm-linux-android-4.0/bin/arm-linux-androideabi-cc
-
-		else
+			export CC=$ANDROID_DIR/arm-linux-android-4.0/bin/arm-linux-androideabi-gcc
+			export GCC=$ANDROID_DIR/arm-linux-android-4.0/bin/arm-linux-androideabi-gcc
+			export CXX=$ANDROID_DIR/arm-linux-android-4.0/bin/arm-linux-androideabi-g++
+			export AR=$ANDROID_DIR/arm-linux-android-4.0/bin/arm-linux-androideabi-ar
+			export RANLIB=$ANDROID_DIR/arm-linux-android-4.0/bin/arm-linux-androideabi-ranlib
+        else
 		AC_MSG_ERROR([unknow compiler vendor!])
 		fi
@@ -949,11 +951,17 @@
 
 	dnl check that --with-fortran-lib may have been provided
+	HAVE_FORTRAN=no
 	if test -n "$FORTRAN_LIB" ; then
-		HAVE_FORTRAN=yes
-		FORTRANLIB="$FORTRAN_LIB"
-
-		AC_DEFINE([_HAVE_FORTRAN_],[1],[with FORTRAN in ISSM src])
-		AC_SUBST([FORTRANLIB])
-	fi
+        if test x$FORTRAN_LIB = xno; then
+            HAVE_FORTRAN=NO
+        else
+            HAVE_FORTRAN=yes
+            FORTRANLIB="$FORTRAN_LIB"
+
+            AC_DEFINE([_HAVE_FORTRAN_],[1],[with FORTRAN in ISSM src])
+            AC_SUBST([FORTRANLIB])
+        fi
+	fi
+	AM_CONDITIONAL([FORTRAN], [test x$HAVE_FORTRAN = xyes])
 	AC_MSG_RESULT(done)
 	dnl }}}
Index: /issm/branches/trunk-jpl-damage/scripts/DownloadExternalPackage.py
===================================================================
--- /issm/branches/trunk-jpl-damage/scripts/DownloadExternalPackage.py	(revision 12258)
+++ /issm/branches/trunk-jpl-damage/scripts/DownloadExternalPackage.py	(revision 12258)
@@ -0,0 +1,37 @@
+#!/usr/bin/env python
+# -*- coding: ISO-8859-1 -*-
+
+import os,sys
+import urllib
+
+#Check inputs
+if(len(sys.argv)!=3): raise NameError('usage: ./DownloadExternalPackage.py URL localfile')
+
+url=sys.argv[1];
+localFile=sys.argv[2]
+
+#Remove file if it already exists
+if os.path.exists(localFile):
+	print "File "+ localFile +" already exists and will not be downloaded..."
+	sys.exit()
+
+#Try to download from url
+httpfail=-1
+try:
+	print "Fetching %s" % localFile
+	urllib.urlretrieve(url,localFile)
+	httpfail=0
+except Exception, e:
+	httpfail=1
+
+#Error message in case it failed
+if (httpfail):
+	failureMessage = '''
+===========================================================================
+Unable to download package %s from: %s
+* If URL specified manually - perhaps there is a typo?
+* If your network is disconnected - please reconnect 
+* Alternatively, you can download the above URL manually
+===========================================================================
+''' % (localFile,url)
+	raise RuntimeError(failureMessage)
Index: /issm/branches/trunk-jpl-damage/src/android/test102/test102.petsc
===================================================================
--- /issm/branches/trunk-jpl-damage/src/android/test102/test102.petsc	(revision 12258)
+++ /issm/branches/trunk-jpl-damage/src/android/test102/test102.petsc	(revision 12258)
@@ -0,0 +1,19 @@
+%Petsc options file: test102.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/branches/trunk-jpl-damage/src/android/test102/test102.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/src/android/test102/test102.sh	(revision 12258)
+++ /issm/branches/trunk-jpl-damage/src/android/test102/test102.sh	(revision 12258)
@@ -0,0 +1,2 @@
+#!/bin/sh
+/Users/larour/issm-uci/trunk-jpl/bin/issm.exe DiagnosticSolution /Users/larour/issm-uci/trunk-jpl/src/android/test102 test102 
Index: /issm/branches/trunk-jpl-damage/src/c/Container/Observations.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/Container/Observations.cpp	(revision 12258)
+++ /issm/branches/trunk-jpl-damage/src/c/Container/Observations.cpp	(revision 12258)
@@ -0,0 +1,192 @@
+/*
+ * \file Observations.c
+ * \brief: implementation of the Observations class, derived from DataSet class
+ */
+
+/*Headers: {{{*/
+#ifdef HAVE_CONFIG_H
+	#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+#include <vector>
+#include <functional>
+#include <algorithm>
+#include <iostream>
+
+#include "./DataSet.h"
+#include "./Observations.h"
+#include "../shared/shared.h"
+#include "../include/include.h"
+#include "../EnumDefinitions/EnumDefinitions.h"
+
+using namespace std;
+/*}}}*/
+
+/*Object constructors and destructor*/
+/*FUNCTION Observations::Observations(){{{*/
+Observations::Observations(){
+	this->quadtree = NULL;
+	return;
+}
+/*}}}*/
+/*FUNCTION Observations::Observations(double* observations_list,double* x,double* y,int n,Options* options){{{*/
+Observations::Observations(double* observations_list,double* x,double* y,int n,Options* options){
+
+	/*Intermediaries*/
+	int          i,maxdepth,level,counter;
+	int          xi,yi;
+	double       xmin,xmax,ymin,ymax;
+	double       offset,minlength;
+	Observation *observation = NULL;
+
+	/*Get extrema*/
+	xmin=x[0]; ymin=y[0];
+	xmax=x[0]; ymax=y[0];
+	for(i=1;i<n;i++){
+		xmin=min(xmin,x[i]); ymin=min(ymin,y[i]);
+		xmax=max(xmax,x[i]); ymax=max(ymax,y[i]);
+	}
+	offset=0.05*(xmax-xmin); xmin-=offset; xmax+=offset;
+	offset=0.05*(ymax-ymin); ymin-=offset; ymax+=offset;
+
+	/*Get Minimum box size*/
+	if(options->GetOption("boxlength")){
+		options->Get(&minlength,"boxlength");
+		if(minlength<=0)_error_("boxlength should be a positive number");
+		maxdepth=int(log(max(xmax-xmin,ymax-ymin)/minlength +1)/log(2.0));
+	}
+	else{
+		maxdepth = 30;
+		minlength=max(xmax-xmin,ymax-ymin)/double((1L<<maxdepth)-1);
+	}
+
+	/*Initialize Quadtree*/
+	printf("Generating quadtree with a maximum box size %g (depth=%i)... ",minlength,maxdepth);
+	this->quadtree = new Quadtree(xmin,xmax,ymin,ymax,maxdepth);
+
+	/*Add observations one by one*/
+	counter = 0;
+	for(i=0;i<n;i++){
+		this->quadtree->IntergerCoordinates(&xi,&yi,x[i],y[i]);
+		this->quadtree->QuadtreeDepth2(&level,xi,yi);
+		if((int)level <= maxdepth){
+			observation = new Observation(x[i],y[i],xi,yi,counter++,observations_list[i]);
+			this->quadtree->Add(observation);
+			this->AddObject(observation);
+		}
+		else{
+			//We need to average with the current observations (not done yet)
+		}
+	}
+	printf("done\n");
+}
+/*}}}*/
+/*FUNCTION Observations::~Observations(){{{*/
+Observations::~Observations(){
+	delete quadtree;
+	return;
+}
+/*}}}*/
+
+/*Methods*/
+/*FUNCTION Observations::ObservationList{{{*/
+void Observations::ObservationList(double **px,double **py,double **pobs,int* pnobs,double x_interp,double y_interp,double range){
+
+	/*Output and Intermediaries*/
+	int          nobs,i,index;
+	double      *x            = NULL;
+	double      *y            = NULL;
+	double      *obs          = NULL;
+	Observation *observation  = NULL;
+	int         *indices      = NULL;
+
+	/*Treat range*/
+	if(range==0){
+		range=this->quadtree->root->length;
+	}
+
+	/*Find all observations that are in range*/
+	this->quadtree->RangeSearch(&indices,&nobs,x_interp,y_interp,range);
+
+	if(nobs==0){
+		/*No observation found, double range*/
+		//printf("No observation found within range, doubling range\n");
+		xfree((void**)&indices);
+		this->ObservationList(&x,&y,&obs,&nobs,x_interp,y_interp,range*2);
+	}
+	else{
+		//if(nobs>1000) printf("Taking more than 1000 observations\n");
+		/*Allocate vectors*/
+		x   = (double*)xmalloc(nobs*sizeof(double));
+		y   = (double*)xmalloc(nobs*sizeof(double));
+		obs = (double*)xmalloc(nobs*sizeof(double));
+
+		/*Loop over all observations and fill in x, y and obs*/
+		for (i=0;i<nobs;i++){
+			observation=(Observation*)this->GetObjectByOffset(indices[i]);
+			observation->WriteXYObs(&x[i],&y[i],&obs[i]);
+		}
+	}
+
+	/*Assign output pointer*/
+	xfree((void**)&indices);
+	*px=x;
+	*py=y;
+	*pobs=obs;
+	*pnobs=nobs;
+}/*}}}*/
+/*FUNCTION Observations::QuadtreeColoring{{{*/
+void Observations::QuadtreeColoring(double* A,double *x,double *y,int n){
+
+	int xi,yi,level;
+
+	for(int i=0;i<n;i++){
+		this->quadtree->IntergerCoordinates(&xi,&yi,x[i],y[i]);
+		this->quadtree->QuadtreeDepth(&level,xi,yi);
+		A[i]=(double)level;
+	}
+
+}/*}}}*/
+/*FUNCTION Observations::Variomap{{{*/
+void Observations::Variomap(double* gamma,double *x,int n){
+
+	/*Output and Intermediaries*/
+	int          nobs,i,j,k;
+	double       range;
+	Observation *observation1 = NULL;
+	Observation *observation2 = NULL;
+	int         *indices      = NULL;
+
+	int *counter= (int*)xmalloc(n*sizeof(int));
+	for(j=0;j<n;j++) counter[j] = 0;
+	for(j=0;j<n;j++) gamma[j]   = 0.0;
+
+	for(i=0;i<this->Size();i++){
+		observation1=(Observation*)this->GetObjectByOffset(i);
+
+		for(j=0;j<n;j++){
+			range=x[j]; _assert_(range>=0.);
+
+			/*Find all observations that are in range*/
+			this->quadtree->RangeSearch(&indices,&nobs,observation1->x,observation1->y,range);
+
+			for (k=0;k<nobs;k++){
+				observation2 = (Observation*)this->GetObjectByOffset(indices[k]);
+				gamma[j]    += 1./2.*pow(observation1->value - observation2->value,2.);
+			}
+
+			counter[j] += nobs;
+			xfree((void**)&indices);
+		}
+	}
+
+	/*Normalize semivariogram*/
+	for(j=0;j<n;j++){
+		if(counter[j]) gamma[j] = gamma[j]/double(counter[j]);
+	}
+
+	/*Assign output pointer*/
+	xfree((void**)&counter);
+}/*}}}*/
Index: /issm/branches/trunk-jpl-damage/src/c/Container/Observations.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/Container/Observations.h	(revision 12258)
+++ /issm/branches/trunk-jpl-damage/src/c/Container/Observations.h	(revision 12258)
@@ -0,0 +1,31 @@
+/*!\file: Observations.h
+ * \brief prototypes for Observations.h
+ */ 
+
+#ifndef _CONTAINER_OBSERVATIONS_H_
+#define  _CONTAINER_OBSERVATIONS_H_
+
+class Obsevration;
+class Quadtree;
+class Options;
+
+class Observations: public DataSet{
+
+	private:
+		Quadtree* quadtree;
+
+	public:
+
+		/*constructors, destructors*/
+		Observations();
+		Observations(double* observations_list,double* x,double* y,int n,Options* options);
+		~Observations();
+
+		/*Methods*/
+		void ObservationList(double **px,double **py,double **pobs,int* pnobs,double x_interp,double y_interp,double range);
+		void QuadtreeColoring(double* A,double *x,double *y,int n);
+		void Variomap(double* gamma,double *x,int n);
+
+};
+#endif //ifndef _OBSERVATIONS_H_
+
Index: /issm/branches/trunk-jpl-damage/src/c/Container/Parameters.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/Container/Parameters.h	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/src/c/Container/Parameters.h	(revision 12258)
@@ -5,4 +5,5 @@
 #ifndef _CONTAINER_PARAMETERS_H_
 #define  _CONTAINER_PARAMETERS_H_
+#include <stdio.h>
 
 /*forward declarations */
Index: /issm/branches/trunk-jpl-damage/src/c/Container/Vertices.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/Container/Vertices.h	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/src/c/Container/Vertices.h	(revision 12258)
@@ -32,6 +32,3 @@
 };
 
-
-
 #endif //ifndef _VERTICES_H_
-
Index: /issm/branches/trunk-jpl-damage/src/c/Makefile.am
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/Makefile.am	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/src/c/Makefile.am	(revision 12258)
@@ -572,6 +572,6 @@
 				./objects/Bamg/Metric.cpp\
 				./objects/Bamg/Metric.h\
-				./objects/Bamg/QuadTree.cpp\
-				./objects/Bamg/QuadTree.h\
+				./objects/Bamg/BamgQuadtree.cpp\
+				./objects/Bamg/BamgQuadtree.h\
 				./objects/Bamg/R2.h\
 				./objects/Bamg/SetOfE4.cpp\
@@ -608,4 +608,24 @@
 				./modules/BamgTriangulatex/BamgTriangulatex.cpp\
 				./modules/BamgTriangulatex/BamgTriangulatex.h
+#}}}
+#Kriging sources  {{{1
+kriging_sources = ./Container/Observations.h\
+						./Container/Observations.cpp\
+						./objects/Kriging/Variogram.h \
+						./objects/Kriging/GaussianVariogram.h\
+						./objects/Kriging/GaussianVariogram.cpp\
+						./objects/Kriging/ExponentialVariogram.h\
+						./objects/Kriging/ExponentialVariogram.cpp\
+						./objects/Kriging/SphericalVariogram.h\
+						./objects/Kriging/SphericalVariogram.cpp\
+						./objects/Kriging/PowerVariogram.h\
+						./objects/Kriging/PowerVariogram.cpp\
+						./objects/Kriging/Quadtree.h\
+						./objects/Kriging/Quadtree.cpp\
+						./objects/Kriging/Observation.h\
+						./objects/Kriging/Observation.cpp\
+						./modules/Krigingx/Krigingx.cpp\
+						./modules/Krigingx/Krigingx.h
+
 #}}}
 #Kml sources  {{{1
@@ -820,6 +840,4 @@
 			./modules/HoleFillerx/HoleFillerx.cpp\
 			./modules/HoleFillerx/HoleFillerx.h\
-			./modules/Krigingx/Krigingx.cpp\
-			./modules/Krigingx/Krigingx.h\
 			./modules/AverageFilterx/AverageFilterx.cpp\
 			./modules/AverageFilterx/AverageFilterx.h\
@@ -946,4 +964,5 @@
 libISSMModules_a_SOURCES = $(module_sources)
 libISSMModules_a_SOURCES += $(bamg_sources)
+libISSMModules_a_SOURCES += $(kriging_sources)
 libISSMModules_a_SOURCES += $(kml_sources)
 libISSMModules_a_CXXFLAGS = $(ALLCXXFLAGS)
@@ -972,5 +991,9 @@
 
 #External packages
-LDADD += $(PETSCLIB) $(TAOLIB) $(FLIBS) $(PLAPACKLIB) $(MUMPSLIB) $(SCALAPACKLIB) $(BLACSLIB) $(HYPRELIB) $(MLLIB) $(DAKOTALIB) $(METISLIB) $(CHACOLIB) $(SCOTCHLIB) $(BLASLAPACKLIB) $(MKLLIB) $(MPILIB) $(MATHLIB) $(FORTRANLIB) $(GRAPHICSLIB) $(MULTITHREADINGLIB) $(OSLIBS) $(GSLLIB)
+LDADD += $(PETSCLIB) $(TAOLIB) $(PLAPACKLIB) $(MUMPSLIB) $(SCALAPACKLIB) $(BLACSLIB) $(HYPRELIB) $(MLLIB) $(DAKOTALIB) $(METISLIB) $(CHACOLIB) $(SCOTCHLIB) $(BLASLAPACKLIB) $(MKLLIB) $(MPILIB) $(MATHLIB) $(FORTRANLIB) $(GRAPHICSLIB) $(MULTITHREADINGLIB) $(OSLIBS) $(GSLLIB)
+
+if FORTRAN
+LDADD += $(FLIBS)
+endif
 
 issm_SOURCES = solutions/issm.cpp
Index: /issm/branches/trunk-jpl-damage/src/c/matlab/io/FetchMatlabData.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/matlab/io/FetchMatlabData.cpp	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/src/c/matlab/io/FetchMatlabData.cpp	(revision 12258)
@@ -404,16 +404,6 @@
 	else if (mxIsClass(dataref,"char") ){
 
-		/*Check dataref is not pointing to NaN: */
-		if ( mxIsNaN(*(mxGetPr(dataref))) && (mxGetNumberOfElements(dataref)==1) ){
-			outmatrix_numel=0;
-			outmatrix_ndims=0;
-			outmatrix_size =NULL;
-			outmatrix=NULL;
-		}
-		else{
-
-			/*Convert matlab n-dim array to char* matrix: */
-			MatlabNArrayToNArray(&outmatrix,&outmatrix_numel,&outmatrix_ndims,&outmatrix_size,dataref);
-		}
+		/*Convert matlab n-dim array to char* matrix: */
+		MatlabNArrayToNArray(&outmatrix,&outmatrix_numel,&outmatrix_ndims,&outmatrix_size,dataref);
 	}
 	else{
Index: /issm/branches/trunk-jpl-damage/src/c/matlab/io/OptionParse.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/matlab/io/OptionParse.cpp	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/src/c/matlab/io/OptionParse.cpp	(revision 12258)
@@ -41,5 +41,5 @@
 	/*check and parse the name  */
 	ological=new OptionLogical;
-	ological->name =(char *) xmalloc((strlen(name)+1)*sizeof(char));
+	ological->name =(char*)xmalloc((strlen(name)+1)*sizeof(char));
 	memcpy(ological->name,name,(strlen(name)+1)*sizeof(char));
 
@@ -59,6 +59,6 @@
 
 	/*check and parse the name  */
-	ochar=new OptionChar;
-	ochar->name =(char *) xmalloc((strlen(name)+1)*sizeof(char));
+	ochar=new OptionChar();
+	ochar->name =(char*)xmalloc((strlen(name)+1)*sizeof(char));
 	memcpy(ochar->name,name,(strlen(name)+1)*sizeof(char));
 
Index: /issm/branches/trunk-jpl-damage/src/c/modules/Bamgx/Bamgx.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/Bamgx/Bamgx.cpp	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/Bamgx/Bamgx.cpp	(revision 12258)
@@ -92,5 +92,5 @@
 
 		//Make Quadtree from background mesh
-		BTh.MakeQuadTree();
+		BTh.MakeBamgQuadtree();
 
 		//Bound hmin and hmax
Index: /issm/branches/trunk-jpl-damage/src/c/modules/Krigingx/Krigingx.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/Krigingx/Krigingx.cpp	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/Krigingx/Krigingx.cpp	(revision 12258)
@@ -8,15 +8,241 @@
 #include "../../toolkits/toolkits.h"
 #include "../../objects/objects.h"
+#include "../../Container/Observations.h"
 #include "../modules.h"
 
-int Krigingx(double** ppredictions,double* x, double* y, double* observations, int n_obs,double* x_interp,double* y_interp,int n_interp){
+#ifdef _HAVE_GSL_
+#include <gsl/gsl_linalg.h>
+#endif
+
+#include "../../objects/Kriging/GaussianVariogram.h"
+/*FUNCTION Krigingx{{{*/
+int Krigingx(double** ppredictions,double **perror,double* obs_x, double* obs_y, double* obs_list, int obs_length,double* x_interp,double* y_interp,int n_interp,Options* options){
 
 	/*output*/
 	double *predictions = NULL;
+	double *error       = NULL;
+
+	/*Intermediaries*/
+	double        range;
+	char         *output       = NULL;
+	Variogram    *variogram    = NULL;
+	Observations *observations = NULL;
+
+	/*threading: */
+	KrigingxThreadStruct gate;
+	int num=1;
+#ifdef _MULTITHREADING_
+	num=_NUMTHREADS_;
+#endif
+
+	/*Get Variogram from Options*/
+	ProcessVariogram(&variogram,options);
+	options->Get(&range,"searchrange",0.);
+
+	/*Process observation dataset*/
+	observations=new Observations(obs_list,obs_x,obs_y,obs_length,options);
 
 	/*Allocate output*/
-	predictions=(double*)xmalloc(n_interp*sizeof(double));
+	predictions =(double*)xcalloc(n_interp,sizeof(double));
+	error       =(double*)xcalloc(n_interp,sizeof(double));
+
+	/*Get output*/
+	options->Get(&output,"output","prediction");
+
+	if(strcmp(output,"quadtree")==0){
+		observations->QuadtreeColoring(predictions,x_interp,y_interp,n_interp);
+	}
+	else if(strcmp(output,"variomap")==0){
+		observations->Variomap(predictions,x_interp,n_interp);
+	}
+	else if(strcmp(output,"prediction")==0){
+
+		/*initialize thread parameters: */
+		gate.n_interp     = n_interp;
+		gate.x_interp     = x_interp;
+		gate.y_interp     = y_interp;
+		gate.range        = range;
+		gate.variogram    = variogram;
+		gate.observations = observations;
+		gate.predictions  = predictions;
+		gate.error        = error;
+		gate.percent      = (double*)xcalloc(num,sizeof(double));
+
+		/*launch the thread manager with Krigingxt as a core: */
+		LaunchThread(Krigingxt,(void*)&gate,num);
+		printf("\r      interpolation progress:  100.00%%\n");
+		xfree((void**)&gate.percent);
+	}
+	else{
+		_error_("output '%s' not supported yet",output);
+	}
+
+	/*clean-up and Assign output pointer*/
+	delete variogram;
+	delete observations;
+	xfree((void**)&output);
+	*ppredictions = predictions;
+	*perror       = error;
+	return 1;
+}/*}}}*/
+/*FUNCTION Krigingxt{{{*/
+void* Krigingxt(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        range        = gate->range;
+	Variogram    *variogram    = gate->variogram;
+	Observations *observations = gate->observations;
+	double       *predictions  = gate->predictions;
+	double       *error        = gate->error;
+	double       *percent      = gate->percent;
+
+	/*Intermediaries*/
+	int           i,j,n_obs;
+	double        numerator,denominator,ratio,localpercent;
+	double       *x            = NULL;
+	double       *y            = NULL;
+	double       *obs          = NULL;
+	double       *Gamma        = NULL;
+	double       *GinvG0       = NULL;
+	double       *Ginv1        = NULL;
+	double       *GinvZ        = NULL;
+	double       *gamma0       = NULL;
+	double       *ones         = NULL;
+
+	/*partition loop across threads: */
+	PartitionRange(&i0,&i1,n_interp,num_threads,my_thread);
+	for(int idx=i0;idx<i1;idx++){
+
+		/*Print info*/
+		percent[my_thread]=double(idx-i0)/double(i1-i0)*100.;
+		localpercent=percent[0];
+		for(i=1;i<num_threads;i++) localpercent=min(localpercent,percent[i]);
+		printf("\r      interpolation progress: %5.2lf%%",localpercent);
+
+		/*Get list of observations for current point*/
+		observations->ObservationList(&x,&y,&obs,&n_obs,x_interp[idx],y_interp[idx],range);
+
+		/*Allocate intermediary matrix and vectors*/
+		Gamma  = (double*)xmalloc(n_obs*n_obs*sizeof(double));
+		gamma0 = (double*)xmalloc(n_obs*sizeof(double));
+		ones   = (double*)xmalloc(n_obs*sizeof(double));
+
+		/*First: Create semivariogram matrix for observations*/
+		for(i=0;i<n_obs;i++){
+			for(j=0;j<=i;j++){
+				Gamma[i*n_obs+j] = variogram->SemiVariogram(x[i]-x[j],y[i]-y[j]);
+				Gamma[j*n_obs+i] = Gamma[i*n_obs+j];
+			}
+		}
+		for(i=0;i<n_obs;i++) ones[i]=1;
+
+		/*Get semivariogram vector associated to this location*/
+		for(i=0;i<n_obs;i++) gamma0[i] = variogram->SemiVariogram(x[i]-x_interp[idx],y[i]-y_interp[idx]);
+
+		/*Solve the three linear systems*/
+		GslSolve(&GinvG0,Gamma,gamma0,n_obs); // Gamma^-1 gamma0
+		GslSolve(&Ginv1, Gamma,ones,n_obs);   // Gamma^-1 ones
+		GslSolve(&GinvZ, Gamma,obs,n_obs);    // Gamma^-1 Z
+
+		/*Prepare predictor*/
+		numerator=-1.; denominator=0.;
+		for(i=0;i<n_obs;i++) numerator  +=GinvG0[i];
+		for(i=0;i<n_obs;i++) denominator+=Ginv1[i];
+		ratio=numerator/denominator;
+
+		predictions[idx] = 0.;
+		error[idx]       = - numerator*numerator/denominator;
+		for(i=0;i<n_obs;i++) predictions[idx] += (gamma0[i]-ratio)*GinvZ[i];
+		for(i=0;i<n_obs;i++) error[idx] += gamma0[i]*GinvG0[i];
+
+		/*clean-up*/
+		xfree((void**)&x);
+		xfree((void**)&y);
+		xfree((void**)&obs);
+		xfree((void**)&Gamma);
+		xfree((void**)&gamma0);
+		xfree((void**)&ones);
+		xfree((void**)&GinvG0);
+		xfree((void**)&Ginv1);
+		xfree((void**)&GinvZ);
+	}
+
+	return NULL;
+}/*}}}*/
+
+void ProcessVariogram(Variogram **pvariogram,Options* options){/*{{{*/
+
+	/*Intermediaries*/
+	Variogram* variogram = NULL;
+	char      *model     = NULL;
+
+	if(options->GetOption("model")){
+		options->Get(&model,"model");
+		if     (strcmp(model,"gaussian")==0)    variogram = new GaussianVariogram(options);
+		else if(strcmp(model,"exponential")==0) variogram = new ExponentialVariogram(options);
+		else if(strcmp(model,"spherical")==0)   variogram = new SphericalVariogram(options);
+		else if(strcmp(model,"power")==0)       variogram = new PowerVariogram(options);
+		else _error_("variogram %s not supported yet (list of supported variogram: gaussian, exponential, spherical and power)",model);
+	}
+	else variogram = new GaussianVariogram(options);
 
 	/*Assign output pointer*/
-	*ppredictions=predictions;
-}
+	xfree((void**)&model);
+	*pvariogram = variogram;
+}/*}}}*/
+void GslSolve(double** pX,double* A,double* B,int n){/*{{{*/
+#ifdef _HAVE_GSL_
+
+		/*GSL Matrices and vectors: */
+		int              s;
+		gsl_matrix_view  a;
+		gsl_vector_view  b;
+		gsl_vector      *x = NULL;
+		gsl_permutation *p = NULL;
+
+		/*A will be modified by LU decomposition. Use copy*/
+		double* Acopy = (double*)xmalloc(n*n*sizeof(double));
+		memcpy(Acopy,A,n*n*sizeof(double));
+
+		/*Initialize gsl matrices and vectors: */
+		a = gsl_matrix_view_array (Acopy,n,n);
+		b = gsl_vector_view_array (B,n);
+		x = gsl_vector_alloc (n);
+
+		/*Run LU and solve: */
+		p = gsl_permutation_alloc (n);
+		gsl_linalg_LU_decomp (&a.matrix, p, &s);
+		gsl_linalg_LU_solve (&a.matrix, p, &b.vector, x);
+
+		//printf ("x = \n");
+		//gsl_vector_fprintf (stdout, x, "%g");
+
+		/*Copy result*/
+		double* X = (double*)xmalloc(n*sizeof(double));
+		memcpy(X,gsl_vector_ptr(x,0),n*sizeof(double));
+
+		/*Clean up and assign output pointer*/
+		xfree((void**)&Acopy);
+		gsl_permutation_free(p);
+		gsl_vector_free(x);
+		*pX=X;
+#else
+		_error_("GSL support required");
+#endif
+	}/*}}}*/
Index: /issm/branches/trunk-jpl-damage/src/c/modules/Krigingx/Krigingx.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/Krigingx/Krigingx.h	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/Krigingx/Krigingx.h	(revision 12258)
@@ -9,7 +9,24 @@
 #include "../../toolkits/toolkits.h"
 
+class Observations;
+class Variogram;
 
-int Krigingx(double** ppredictions,double* x, double* y, double* observations, int n_obs,double* x_interp,double* y_interp,int n_interp);
+int  Krigingx(double** ppredictions,double **perror,double* x, double* y, double* observations, int n_obs,double* x_interp,double* y_interp,int n_interp,Options* options);
+void ProcessVariogram(Variogram **pvariogram,Options* options);
+void GslSolve(double** pX,double* A,double* B,int n);
 
+/*threading: */
+typedef struct{
+	int           n_interp;
+	double       *x_interp;
+	double       *y_interp;
+	double        range;
+	Variogram    *variogram;
+	Observations *observations;
+	double       *predictions;
+	double       *error;
+	double       *percent;
+}KrigingxThreadStruct;
+
+void* Krigingxt(void*);
 #endif /* _KRIGINGX_H */
-
Index: /issm/branches/trunk-jpl-damage/src/c/modules/Shp2Kmlx/Shp2Kmlx.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/Shp2Kmlx/Shp2Kmlx.h	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/Shp2Kmlx/Shp2Kmlx.h	(revision 12258)
@@ -22,8 +22,6 @@
 
 /* local prototypes: */
-int Shp2Kmlx(char* filshp,char* filkml,
-			 int sgn);
-int Shp2Kmlx(char* filshp,char* filkml,
-			 int sgn,double cm,double sp);
+int Shp2Kmlx(char* filshp,char* filkml, int sgn);
+int Shp2Kmlx(char* filshp,char* filkml, int sgn,double cm,double sp);
 
 #endif  /* _SHP2KMLX_H */
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Bamg/BamgQuadtree.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Bamg/BamgQuadtree.cpp	(revision 12258)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Bamg/BamgQuadtree.cpp	(revision 12258)
@@ -0,0 +1,598 @@
+#include <limits.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include "../objects.h"
+
+namespace bamg {
+
+	/*MACROS {{{1*/
+	/* 
+	 * 
+	 *    J    j
+	 *    ^    ^
+	 *    |    | +--------+--------+
+	 *    |    | |        |        |
+	 * 1X |    | |   2    |   3    |
+	 *    |    | |        |        |
+	 *    |    | +--------+--------+
+	 *    |    | |        |        |
+	 * 0X |    | |   0    |   1    |
+	 *    |    | |        |        |
+	 *    |    | +--------+--------+
+	 *    |    +-----------------------> i
+	 *    |         
+	 *    |----------------------------> I
+	 *              X0        X1  
+	 *
+	 * box 0 -> I=0 J=0 IJ=00  = 0
+	 * box 1 -> I=1 J=0 IJ=01  = 1
+	 * box 2 -> I=0 J=1 IJ=10  = 2
+	 * box 3 -> I=1 J=1 IJ=11  = 3
+	 */
+#define INTER_SEG(a,b,x,y) (((y) > (a)) && ((x) <(b)))
+#define ABS(i) ((i)<0 ?-(i) :(i))
+#define MAX1(i,j) ((i)>(j) ?(i) :(j))
+#define NORM(i1,j1,i2,j2) MAX1(ABS((i1)-(j1)),ABS((i2)-(j2)))
+
+	//IJ(i,j,l) returns the box number of i and j with respect to l
+	//if !j&l and !i&l -> 0 (box zero: lower left )
+	//if !j&l and  i&l -> 1 (box one:  lower right)
+	//if  j&l and !i&l -> 2 (box two:  upper left )
+	//if  j&l and  i&l -> 3 (box three:upper right)
+#define IJ(i,j,l)  ((j&l) ? ((i&l) ? 3:2 ) :((i&l) ? 1:0 ))
+
+	//I_IJ(k,l) returns l if first  bit of k is 1, else 0
+#define I_IJ(k,l)  ((k&1) ? l:0)
+	//J_IJ(k,l) returns l if second bit of k is 1, else 0
+#define J_IJ(k,l)  ((k&2) ? l:0)
+	/*}}}*/
+	/*DOCUMENTATION What is a BamgQuadtree? {{{1
+	 * A Quadtree is a very simple way to group vertices according
+	 * to their locations. A square that holds all the points of the mesh
+	 * (or the geometry) is divided into 4 boxes. As soon as one box
+	 * hold more than 4 vertices, it is divided into 4 new boxes, etc...
+	 * There cannot be more than MAXDEEP (=30) subdivision.
+	 * This process is like a Dichotomy in dimension 2
+	 *
+	 *  + - -  -    - -    -    - - + -   - + - + - + - -     - - +
+	 *  |                           |       |   | X |             |
+	 *                                      + - + - +
+	 *  |                           |       |   |   |             |
+	 *                              + -   - + - + - +             +
+	 *  |                           |       |       |             |
+	 *                         
+	 *  |                           |       |       |             |
+	 *  + - -  -    - -    -    - - + -   - + -   - + - -     - - +
+	 *  |                           |               |             |
+	 *                         
+	 *  |                           |               |             |
+	 *                         
+	 *  |                           |               |             |
+	 *  |                           |               |             |
+	 *  + - -  -    - -    -    - - + -   -   -   - + - -     - - +
+	 *  |                           |                             |
+	 *                         
+	 *  |                           |                             |
+	 *                         
+	 *  |                           |                             |
+	 *                         
+	 *  |                           |                             |
+	 *  |                           |                             |
+	 *  |                           |                             |
+	 *  |                           |                             |
+	 *  |                           |                             |
+	 *  + - -  -    - -    -    - - + -   -   -   -   - -     - - +
+	 *
+	 * The coordinate system used in a quadtree are integers to avoid
+	 * round-off errors. The vertex in the lower left box has the coordinates
+	 * (0 0) 
+	 * The upper right vertex has the follwing coordinates:
+	 * 2^30 -1           2^30 -1        in decimal
+	 * 0 1 1 1 .... 1    0 1 1 1 .... 1 in binary
+	 *  \--   29  --/     \--   29  --/
+	 * Using binaries is therefore very easy to locate a vertex in a box:
+	 * we just need to look at the bits from the left to the right (See ::Add)
+	 }}}1*/
+
+	/*Constructors/Destructors*/
+	/*FUNCTION BamgQuadtree::BamgQuadtree(){{{1*/
+	BamgQuadtree::BamgQuadtree(){
+
+		/*Number of boxes and vertices*/
+		NbBamgQuadtreeBox=0;
+		NbVertices=0;
+
+		/*Create container*/
+		boxcontainer=new DataSet();
+
+		/*Create Root, pointer toward the main box*/
+		root=NewBamgQuadtreeBox();
+
+		}
+	/*}}}1*/
+	/*FUNCTION BamgQuadtree::BamgQuadtree(Mesh * t,long nbv){{{1*/
+	BamgQuadtree::BamgQuadtree(Mesh * t,long nbv){ 
+
+		/*Number of boxes and vertices*/
+		NbBamgQuadtreeBox=0;
+		NbVertices=0;
+
+		/*Create container*/
+		boxcontainer=new DataSet();
+
+		/*Create Root, pointer toward the main box*/
+		root=NewBamgQuadtreeBox();
+
+		/*Check Sizes*/
+		_assert_(MaxISize>MaxICoor);
+
+		/*Add all vertices of the mesh*/
+		if (nbv==-1) nbv=t->nbv;
+		for (int i=0;i<nbv;i++) Add(t->vertices[i]);
+
+	}
+	/*}}}1*/
+	/*FUNCTION BamgQuadtree::~BamgQuadtree(){{{1*/
+	BamgQuadtree::~BamgQuadtree() {
+		delete boxcontainer;
+		root=NULL;
+	}
+	/*}}}1*/
+
+	/*Methods*/
+	/*FUNCTION BamgQuadtree::Add{{{1*/
+	void  BamgQuadtree::Add(BamgVertex &w){
+		/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, BamgQuadtree.cpp/Add)*/
+		BamgQuadtreeBox** pb=NULL;
+		BamgQuadtreeBox*  b=NULL;
+
+		/*Get integer coodinate of current point w*/
+		register long i=w.i.x, j=w.i.y;
+
+		/*Initialize level*/
+		register long level=MaxISize;
+
+		/*Get inital box (the largest)*/
+		pb = &root;
+
+		/*Find the smallest box where w is located*/
+		while((b=*pb) && (b->nbitems<0)){ 
+
+			//shift b->nbitems by -1
+			b->nbitems--;
+
+			//shifted righ by one bit: level=00000010 -> 00000001
+			level >>= 1;
+
+			//Get next subbox according to the bit value (level)
+			pb = &b->b[IJ(i,j,level)];
+		}
+
+		/*OK, we have found b, a Subbox holding vertices (might be full)
+		  check that the vertex is not already in the box*/
+		if (b){      
+			if (b->nbitems > 3 &&  b->v[3] == &w) return;
+			if (b->nbitems > 2 &&  b->v[2] == &w) return;
+			if (b->nbitems > 1 &&  b->v[1] == &w) return;
+			if (b->nbitems > 0 &&  b->v[0] == &w) return;
+		}
+
+		/*check that l is not 0 (this should not happen as MaxDepth = 30)*/
+		_assert_(level>0);
+
+		/*Now, try to add the vertex, if the subbox is full (nbitems=4), we have to divide it
+		  in 4 new subboxes*/
+		while ((b= *pb) && (b->nbitems == 4)){ // the BamgQuadtreeBox is full
+
+			/*Copy the 4 vertices in the current BamgQuadtreebox*/
+			BamgVertex* v4[4];
+			v4[0]= b->v[0];
+			v4[1]= b->v[1];
+			v4[2]= b->v[2];
+			v4[3]= b->v[3];
+
+			/*set nbitems as negative 
+			 * (box full -> holds 4 pointers toward subboxes and not 4 vertices)*/
+			b->nbitems = -b->nbitems;
+
+			/*Initialize the 4 pointers toward the 4 subboxes*/
+			b->b[0]=b->b[1]=b->b[2]=b->b[3]=NULL;
+
+			/*level = 0010000 -> 0001000*/
+			level >>= 1;
+
+			/*Put the four vertices in the new boxes*/
+			for (int k=0;k<4;k++){
+
+				int          ij;
+				/*bb is the new "sub"box of b where v4[k] is located*/
+				BamgQuadtreeBox *bb = b->b[ij=IJ(v4[k]->i.x,v4[k]->i.y,level)];
+
+				// alloc the BamgQuadtreeBox
+				if (!bb) bb=b->b[ij]=NewBamgQuadtreeBox(); 
+
+				/*Copy the current vertex*/
+				bb->v[bb->nbitems++] = v4[k];
+			}
+
+			/*Get the subbox where w (i,j) is located*/
+			pb = &b->b[IJ(i,j,level)];
+		}
+
+		/*alloc the BamgQuadtreeBox if necessary*/
+		if (!(b=*pb)) b=*pb= NewBamgQuadtreeBox();
+
+		/*Add w*/
+		b->v[b->nbitems++]=&w;
+
+		//Increase NbVertices by one (we have one new vertex)
+		NbVertices++;
+	}
+	/*}}}1*/
+	/*FUNCTION BamgQuadtree::NearestVertex{{{1*/
+	BamgVertex*  BamgQuadtree::NearestVertex(Icoor1 i,Icoor1 j) {
+		/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, BamgQuadtree.cpp/NearestVertex)*/
+
+		/*Intermediaries*/
+		BamgQuadtreeBox *pb[MaxDepth];
+		int          pi[MaxDepth];
+		Icoor1       ii[MaxDepth];
+		Icoor1       jj[MaxDepth];
+		int          level;
+		long         n0;
+		BamgQuadtreeBox *b;
+		long         h0;
+		long         h = MaxISize;
+		long         hb= MaxISize;
+		Icoor1       i0=0,j0=0;
+
+		/*initial output as NULL (no vertex found)*/
+		BamgVertex*  nearest_v=NULL;
+
+		/*Project w coordinates (i,j) onto [0,MaxISize-1] x [0,MaxISize-1] -> (iplus,jplus)*/
+		Icoor1 iplus( i<MaxISize ? (i<0?0:i) : MaxISize-1);
+		Icoor1 jplus( j<MaxISize ? (j<0?0:j) : MaxISize-1);
+
+		/*Get initial Quadtree box (largest)*/
+		b = root;
+
+		/*if the tree is empty, return NULL pointer*/
+		if (!root->nbitems) return nearest_v; 
+
+		/*else, find the smallest non-empty BamgQuadtreeBox containing  the point (i,j)*/
+		while((n0=b->nbitems)<0){
+
+			Icoor1       hb2 = hb >> 1;             //size of the current box
+			int          k   = IJ(iplus,jplus,hb2); //box number (0,1,2 or 3)
+			BamgQuadtreeBox *b0  = b->b[k];             //pointer toward current box
+
+			/* break if NULL box or empty (Keep previous box b)*/
+			if (( b0 == NULL) || (b0->nbitems == 0)) break;
+
+			/*Get next Quadtree box*/
+			b=b0;	
+			i0 += I_IJ(k,hb2); // i orign of BamgQuadtreeBox (macro)
+			j0 += J_IJ(k,hb2); // j orign of BamgQuadtreeBox 
+			hb = hb2;          // size of the box (in Int)
+		}
+
+		/*The box b, is the smallest box containing the point (i,j) and
+		 * has the following properties:
+		 * - n0: number of items (>0 if vertices, else boxes)
+		 * - hb: box size (int)
+		 * - i0: x coordinate of the lower left corner
+		 * - j0: y coordinate of the lower left corner*/
+
+		/* if the current subbox is holding vertices, we are almost done*/
+		if (n0>0){  
+			//loop over the vertices of the box and find the closest vertex
+			for(int k=0;k<n0;k++){
+
+				/*get integer coordinates of current vertex*/
+				I2 i2=b->v[k]->i;
+
+				/*Compute norm with w*/
+				h0=NORM(iplus,i2.x,jplus,i2.y);
+
+				/*is it smaller than previous value*/
+				if (h0<h){
+					h = h0;
+					nearest_v = b->v[k];
+				}
+			}
+			/*return closest vertex*/
+			return nearest_v;
+		}
+
+		/* general case: the current box is empty, we have to go backwards
+			and find the closest not-empty box and find the closest vertex*/
+
+		/*Initialize search variables*/
+		pb[0]=b;                             //pointer toward the box b
+		pi[0]=b->nbitems>0?(int)b->nbitems:4;//number of boxes in b
+		ii[0]=i0;                            //i coordinate of the box lowest left corner
+		jj[0]=j0;                            //j coordinate of the box lowest left corner
+
+		/*initialize h: smallest box size, containing a vertex close to w*/
+		h=hb;
+
+		/*Main loop*/
+		level=0;
+		do {
+
+			/*get current box*/
+			b= pb[level];
+
+			/*Loop over the items in current box (if not empty!)*/
+			while (pi[level]){
+
+				/*We are looping now over the items of b. k is the current index (in [0 3])*/
+				pi[level]--;
+				int k=pi[level];
+
+				/*if the current subbox is holding vertices (b->nbitems<0 is subboxes)*/
+				if (b->nbitems>0){
+					I2 i2=b->v[k]->i;
+					h0 = NORM(iplus,i2.x,jplus,i2.y);
+					if (h0<h){
+						h=h0;
+						nearest_v=b->v[k];
+					}
+				}
+				/*else: current box b is pointing toward 4 boxes
+				 * test sub-box k and go deeper into the tree if it is non empty
+				 * and contains the point w modulo a size h that is either the size of the smallest
+				 * non empty box containing w, or the closest point to w (so far) */
+				else{
+					BamgQuadtreeBox* b0=b;
+
+					/*if the next box exists:*/
+					if (b=b->b[k]){
+
+						/*Get size (hb) and coordinates of the current sub-box lowest left corner*/
+						hb>>=1;
+						Icoor1 iii = ii[level]+I_IJ(k,hb);
+						Icoor1 jjj = jj[level]+J_IJ(k,hb);
+
+						/*if the current point (iplus,jplus) is in b (modulo h), this box is good:
+						 * it is holding vertices that are close to w */
+						if (INTER_SEG(iii,iii+hb,iplus-h,iplus+h) && INTER_SEG(jjj,jjj+hb,jplus-h,jplus+h)){
+							level++;
+							pb[level]= b;
+							pi[level]= b->nbitems>0 ?(int)  b->nbitems : 4  ;
+							ii[level]= iii;
+							jj[level]= jjj;
+						}
+
+						//else go backwards
+						else{
+							//shifted righ by one bit: hb=001000000 -> 01000000
+							b=b0;
+							hb<<=1;
+						}
+					}
+					else{
+						/*Current box is NULL, go to next subbox of b (k=k-1)*/
+						b=b0;
+					}
+				}
+			}
+
+			/*We have found a vertex, now, let's try the other boxes of the previous level
+			 * in case there is a vertex closest to w that has not yet been tested*/
+			hb <<= 1;
+		} while (level--);
+
+		/*return nearest_v, nearest vertex*/
+		return nearest_v;
+
+	}
+	/*}}}1*/
+	/*FUNCTION BamgQuadtree::NearestVertexWithNormal{{{1*/
+	BamgVertex*  BamgQuadtree::NearestVertexWithNormal(Icoor1 i,Icoor1 j) {
+		/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, BamgQuadtree.cpp/NearestVertexWithNormal)*/
+
+		BamgQuadtreeBox * pb[ MaxDepth ];
+		int  pi[ MaxDepth  ];
+		Icoor1 ii[  MaxDepth ], jj [ MaxDepth];
+		int l; // level
+		BamgQuadtreeBox * b;
+		long     h =MaxISize,h0;
+		long     hb=MaxISize;
+		Icoor1  i0=0,j0=0;
+		Icoor1  iplus( i<MaxISize?(i<0?0:i):MaxISize-1);
+		Icoor1  jplus( j<MaxISize?(j<0?0:j):MaxISize-1);
+
+		BamgVertex *vn=0;
+
+		// init for optimisation ---
+		b = root;
+		register long  n0;
+		if (!root->nbitems)
+		 return vn; // empty tree 
+
+		while( (n0 = b->nbitems) < 0) 
+		  {
+			// search the non empty 
+			// BamgQuadtreeBox containing  the point (i,j)
+			register Icoor1 hb2 = hb >> 1 ;
+			register  int k = IJ(iplus,jplus,hb2);// BamgQuadtreeBox number of size hb2 contening i;j
+			register BamgQuadtreeBox * b0= b->b[k];
+			if ( ( b0 == 0) || (b0->nbitems == 0) ) 
+			 break; // null box or empty   => break 	    
+			b=b0;	
+			i0 += I_IJ(k,hb2); // i orign of BamgQuadtreeBox
+			j0 += J_IJ(k,hb2); // j orign of BamgQuadtreeBox 
+			hb = hb2; 
+		  }
+
+
+		if ( n0 > 0) 
+		  {  
+			for(register int k=0;k<n0;k++)
+			  {
+				I2 i2 =  b->v[k]->i;
+				//   try if is in the right direction -- 
+				h0 = NORM(iplus,i2.x,jplus,i2.y);
+				if (h0 <h) {
+					h = h0;
+					vn = b->v[k];}
+			  }
+			if (vn) return vn; 
+		  }
+		// general case -----
+		// INITIALISATION OF THE HEAP 
+		l =0; // level 
+		pb[0]= b;
+		pi[0]=b->nbitems>0 ?(int)  b->nbitems : 4  ;
+		ii[0]=i0;
+		jj[0]=j0;
+		h=hb;
+		do {   // walk on the tree  
+			b= pb[l];
+			while (pi[l]--) // loop on 4 element of the box
+			  { 	      
+				int k = pi[l];
+
+				if (b->nbitems>0) // BamgVertex BamgQuadtreeBox none empty
+				  { 
+					I2 i2 =  b->v[k]->i;
+					// if good direction when try -- 
+
+					h0 = NORM(iplus,i2.x,jplus,i2.y);
+					if (h0 <h) 
+					  {
+						h = h0;
+						vn = b->v[k];
+					  }
+				  }
+				else // Pointer BamgQuadtreeBox 
+				  { 
+					register BamgQuadtreeBox *b0=b;
+					if ((b=b->b[k])) 
+					  {
+						hb >>=1 ; // div by 2
+						register Icoor1 iii = ii[l]+I_IJ(k,hb);
+						register Icoor1 jjj = jj[l]+J_IJ(k,hb);
+
+						if  (INTER_SEG(iii,iii+hb,iplus-h,iplus+h) && INTER_SEG(jjj,jjj+hb,jplus-h,jplus+h)) 
+						  {
+							pb[++l]=  b;
+							pi[l]= b->nbitems>0 ?(int)  b->nbitems : 4  ;
+							ii[l]= iii;
+							jj[l]= jjj;
+
+						  }
+						else
+						 b=b0, hb <<=1 ;
+					  }
+					else
+					 b=b0;
+				  }
+			  }
+			hb <<= 1; // mul by 2 
+		} while (l--);
+
+		return vn;
+	}
+	/*}}}1*/
+	/*FUNCTION BamgQuadtree::NewBamgQuadtreeBox {{{1*/
+	BamgQuadtree::BamgQuadtreeBox* BamgQuadtree::NewBamgQuadtreeBox(void){
+
+		/*Output*/
+		BamgQuadtreeBox* newbox=NULL;
+
+		/*Create and initialize a new box*/
+		newbox=new BamgQuadtreeBox;
+		newbox->nbitems=0;
+		newbox->b[0]=NULL;
+		newbox->b[1]=NULL;
+		newbox->b[2]=NULL;
+		newbox->b[3]=NULL;
+
+		/*Add root to the container*/
+		boxcontainer->AddObject(newbox);
+
+		/*Increase counter*/
+		NbBamgQuadtreeBox++;
+
+		/*currentbox now points toward next quadtree box*/
+		return newbox;
+	}/*}}}*/
+	/*FUNCTION BamgQuadtree::ToClose {{{1*/
+	BamgVertex*   BamgQuadtree::ToClose(BamgVertex & v,double seuil,Icoor1 hx,Icoor1 hy){
+		/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, BamgQuadtree.cpp/ToClose)*/
+
+		const Icoor1 i=v.i.x;
+		const Icoor1 j=v.i.y;
+		const R2 X(v.r);
+		const Metric  Mx(v.m);
+
+		BamgQuadtreeBox * pb[ MaxDepth ];
+		int  pi[ MaxDepth  ];
+		Icoor1 ii[  MaxDepth ], jj [ MaxDepth];
+		register int l=0; // level
+		register BamgQuadtreeBox * b;
+		Icoor1 h=MaxISize;
+		Icoor1 hb =  MaxISize;
+		Icoor1 i0=0,j0=0;
+
+		//  BamgVertex *vn=0;
+
+		if (!root->nbitems)
+		 return 0; // empty tree 
+
+		// general case -----
+		pb[0]=root;
+		pi[0]=root->nbitems>0 ?(int)  root->nbitems : 4  ;
+		ii[0]=i0;
+		jj[0]=j0;
+		h=hb;
+		do {    
+			b= pb[l];
+			while (pi[l]--){ 	      
+				register int k = pi[l];
+
+				if (b->nbitems>0){ // BamgVertex BamgQuadtreeBox none empty
+					I2 i2 =  b->v[k]->i;
+					if ( ABS(i-i2.x) <hx && ABS(j-i2.y) <hy )
+					  {
+						R2 XY(X,b->v[k]->r);
+						double dd;
+						if( (dd= LengthInterpole(Mx(XY), b->v[k]->m(XY)))  < seuil ){
+							return b->v[k]; 
+						}
+					  }
+				}
+				else{ // Pointer BamgQuadtreeBox 
+					register BamgQuadtreeBox *b0=b;
+					if ((b=b->b[k])){
+						hb >>=1 ; // div by 2
+						register long iii = ii[l]+I_IJ(k,hb);
+						register long jjj = jj[l]+J_IJ(k,hb);
+
+						if  (INTER_SEG(iii,iii+hb,i-hx,i+hx) && INTER_SEG(jjj,jjj+hb,j-hy,j+hy)){
+							pb[++l]=  b;
+							pi[l]= b->nbitems>0 ?(int)  b->nbitems : 4  ;
+							ii[l]= iii;
+							jj[l]= jjj;
+
+						}
+						else{
+							b=b0;
+							hb <<=1 ;
+						}
+					}
+					else{
+						b=b0;
+					}
+				}
+			}
+			hb <<= 1; // mul by 2 
+		} while (l--);
+
+		return 0;
+	}
+	/*}}}1*/
+}
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Bamg/BamgQuadtree.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Bamg/BamgQuadtree.h	(revision 12258)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Bamg/BamgQuadtree.h	(revision 12258)
@@ -0,0 +1,60 @@
+/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, BamgQuadtree.h)*/
+#ifndef _BAMGQUADTREE_H
+#define _BAMGQUADTREE_H
+
+#include "./include.h"
+
+namespace bamg {
+
+	const int  MaxDepth = 30;
+	const long MaxISize = ( 1L << MaxDepth);  // = 2^30 : 010000000000..000 (bitwise operation)
+
+	class BamgVertex;
+
+	class BamgQuadtree{
+
+		private:
+
+			/*A quadtree box contains a maximum of 4 vertices. 4 other quadtree boxes are
+			 * created if a fifth vertex is added to the same box. A Quadtree box is therefore
+			 * composed of EITHER:
+			 * - up to 4 vertices
+			 * - 4 "sub" quadtree boxes*/
+			class BamgQuadtreeBox: public Object{ 
+				public:
+					int nbitems; // number of current vertices in the box
+					union{
+						BamgQuadtreeBox* b[4];
+						BamgVertex*  v[4];
+					};
+					/*Object functions*/
+					void    Echo()       {_error_("not implemented yet"); };
+					void    DeepEcho()   {_error_("not implemented yet"); };
+					int     Id()         {_error_("not implemented yet"); };
+					int     MyRank()     {_error_("not implemented yet"); };
+					int     ObjectEnum() {_error_("not implemented yet"); };
+					Object *copy()       {_error_("not implemented yet"); };
+			};
+
+			/*BamgQuadtree private Fields*/
+			DataSet* boxcontainer;
+
+		public:
+
+			/*BamgQuadtree public Fields*/
+			BamgQuadtreeBox* root;
+			long         NbBamgQuadtreeBox;
+			long         NbVertices;
+
+			BamgQuadtree();
+			BamgQuadtree(Mesh *t,long nbv=-1);
+			~BamgQuadtree();
+
+			BamgVertex      *NearestVertex(Icoor1 i,Icoor1 j);
+			BamgVertex      *NearestVertexWithNormal(Icoor1  i,Icoor1 j);
+			BamgQuadtreeBox *NewBamgQuadtreeBox(void);
+			BamgVertex      *ToClose(BamgVertex &,double ,Icoor1,Icoor1);
+			void             Add(BamgVertex &w);
+	};
+}
+#endif
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Bamg/Geometry.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Bamg/Geometry.cpp	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Bamg/Geometry.cpp	(revision 12258)
@@ -505,5 +505,5 @@
 		float             *eangle   = new float[nbe];
 		double             eps      = 1e-20;
-		QuadTree           quadtree; // build quadtree to find duplicates
+		BamgQuadtree           quadtree; // build quadtree to find duplicates
 		BamgVertex        *v0       = vertices;
 		GeomVertex *v0g      = (GeomVertex*) (void*)v0;
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Bamg/Geometry.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Bamg/Geometry.h	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Bamg/Geometry.h	(revision 12258)
@@ -12,5 +12,5 @@
 
 	class Triangle;
-	class QuadTree;
+	class BamgQuadtree;
 	class GeomSubDomain;
 	class Edge;
@@ -20,17 +20,17 @@
 		public:
 
-			long                  NbRef;                         // counter of ref on the this class if 0 we can delete
-			long                  nbv;                           // number of vertices
-			long                  nbe;                           // number of edges
-			long                  nbsubdomains;
-			long                  nbcurves;
+			long           NbRef;                 // counter of ref on the this class if 0 we can delete
+			long           nbv;                   // number of vertices
+			long           nbe;                   // number of edges
+			long           nbsubdomains;
+			long           nbcurves;
 			GeomVertex    *vertices;
 			GeomEdge      *edges;
-			QuadTree             *quadtree;
+			BamgQuadtree  *quadtree;
 			GeomSubDomain *subdomains;
-			Curve                *curves;
-			R2                    pmin,pmax;                     // domain extrema coordinates
-			double                coefIcoor;                     // coef to integer Icoor1;
-			double                MaxCornerAngle;
+			Curve         *curves;
+			R2             pmin,pmax;             // domain extrema coordinates
+			double         coefIcoor;             // coef to integer Icoor1;
+			double         MaxCornerAngle;
 
 			//Constructor/Destructors
@@ -44,5 +44,5 @@
 			GeomVertex       &operator[](long i) { return vertices[i];       };
 			const GeomEdge   &operator()(long i) const { return edges[i];    };
-			GeomEdge         &operator()(long  i) { return edges[i];                };
+			GeomEdge         &operator()(long  i) { return edges[i];         };
 
 			//Methods
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Bamg/Mesh.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Bamg/Mesh.cpp	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Bamg/Mesh.cpp	(revision 12258)
@@ -2885,5 +2885,5 @@
 
 		//build quadtree
-		if (!quadtree)  quadtree = new QuadTree(this,0);
+		if (!quadtree)  quadtree = new BamgQuadtree(this,0);
 		quadtree->Add(*v0);
 		quadtree->Add(*v1);
@@ -3107,10 +3107,10 @@
 	}
 	/*}}}1*/
-	/*FUNCTION Mesh::MakeQuadTree{{{1*/
-	void Mesh::MakeQuadTree() {  
-		/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/MakeQuadTree)*/
+	/*FUNCTION Mesh::MakeBamgQuadtree{{{1*/
+	void Mesh::MakeBamgQuadtree() {  
+		/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/MakeBamgQuadtree)*/
 
 		long int verbose=0;
-		if (  !quadtree )  quadtree = new QuadTree(this);
+		if (  !quadtree )  quadtree = new BamgQuadtree(this);
 
 	}
@@ -3622,5 +3622,5 @@
 
 	if (!quadtree) delete quadtree; //ReInitialise;
-	quadtree = new QuadTree(this,0);
+	quadtree = new BamgQuadtree(this,0);
 	quadtree->Add(*v0);
 	quadtree->Add(*v1);
@@ -3900,5 +3900,5 @@
 		if (quadtree){
 			delete quadtree;
-			quadtree = new QuadTree(this);
+			quadtree = new BamgQuadtree(this);
 		}
 
@@ -4116,5 +4116,5 @@
 
 	delete [] tstart;
-	if (quadtree) quadtree= new QuadTree(this);
+	if (quadtree) quadtree= new BamgQuadtree(this);
 }
 /*}}}1*/
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Bamg/Mesh.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Bamg/Mesh.h	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Bamg/Mesh.h	(revision 12258)
@@ -17,5 +17,5 @@
 	class Geometry;
 	class CrackedEdge;
-	class QuadTree;
+	class BamgQuadtree;
 	class SubDomain;
 
@@ -29,5 +29,5 @@
 			Triangle                     *triangles;
 			Edge                         *edges;
-			QuadTree                     *quadtree;
+			BamgQuadtree                 *quadtree;
 			BamgVertex                  **orderedvertices;
 			SubDomain                    *subdomains;
@@ -94,5 +94,5 @@
 			void MakeQuadrangles(double costheta);
 			int  SplitElement(int choice);
-			void MakeQuadTree();
+			void MakeBamgQuadtree();
 			void NewPoints(Mesh &,BamgOpts* bamgopts,int KeepVertices=1);
 			long InsertNewPoints(long nbvold,long & NbTSwap) ; 
Index: sm/branches/trunk-jpl-damage/src/c/objects/Bamg/QuadTree.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Bamg/QuadTree.cpp	(revision 12257)
+++ 	(revision )
@@ -1,598 +1,0 @@
-#include <limits.h>
-#include <string.h>
-#include <stdlib.h>
-
-#include "../objects.h"
-
-namespace bamg {
-
-	/*MACROS {{{1*/
-	/* 
-	 * 
-	 *    J    j
-	 *    ^    ^
-	 *    |    | +--------+--------+
-	 *    |    | |        |        |
-	 * 1X |    | |   2    |   3    |
-	 *    |    | |        |        |
-	 *    |    | +--------+--------+
-	 *    |    | |        |        |
-	 * 0X |    | |   0    |   1    |
-	 *    |    | |        |        |
-	 *    |    | +--------+--------+
-	 *    |    +-----------------------> i
-	 *    |         
-	 *    |----------------------------> I
-	 *              X0        X1  
-	 *
-	 * box 0 -> I=0 J=0 IJ=00  = 0
-	 * box 1 -> I=1 J=0 IJ=01  = 1
-	 * box 2 -> I=0 J=1 IJ=10  = 2
-	 * box 3 -> I=1 J=1 IJ=11  = 3
-	 */
-#define INTER_SEG(a,b,x,y) (((y) > (a)) && ((x) <(b)))
-#define ABS(i) ((i)<0 ?-(i) :(i))
-#define MAX1(i,j) ((i)>(j) ?(i) :(j))
-#define NORM(i1,j1,i2,j2) MAX1(ABS((i1)-(j1)),ABS((i2)-(j2)))
-
-	//IJ(i,j,l) returns the box number of i and j with respect to l
-	//if !j&l and !i&l -> 0 (box zero: lower left )
-	//if !j&l and  i&l -> 1 (box one:  lower right)
-	//if  j&l and !i&l -> 2 (box two:  upper left )
-	//if  j&l and  i&l -> 3 (box three:upper right)
-#define IJ(i,j,l)  ((j&l) ? ((i&l) ? 3:2 ) :((i&l) ? 1:0 ))
-
-	//I_IJ(k,l) returns l if first  bit of k is 1, else 0
-#define I_IJ(k,l)  ((k&1) ? l:0)
-	//J_IJ(k,l) returns l if second bit of k is 1, else 0
-#define J_IJ(k,l)  ((k&2) ? l:0)
-	/*}}}*/
-	/*DOCUMENTATION What is a QuadTree? {{{1
-	 * A Quadtree is a very simple way to group vertices according
-	 * to their locations. A square that holds all the points of the mesh
-	 * (or the geometry) is divided into 4 boxes. As soon as one box
-	 * hold more than 4 vertices, it is divided into 4 new boxes, etc...
-	 * There cannot be more than MAXDEEP (=30) subdivision.
-	 * This process is like a Dichotomy in dimension 2
-	 *
-	 *  + - -  -    - -    -    - - + -   - + - + - + - -     - - +
-	 *  |                           |       |   | X |             |
-	 *                                      + - + - +
-	 *  |                           |       |   |   |             |
-	 *                              + -   - + - + - +             +
-	 *  |                           |       |       |             |
-	 *                         
-	 *  |                           |       |       |             |
-	 *  + - -  -    - -    -    - - + -   - + -   - + - -     - - +
-	 *  |                           |               |             |
-	 *                         
-	 *  |                           |               |             |
-	 *                         
-	 *  |                           |               |             |
-	 *  |                           |               |             |
-	 *  + - -  -    - -    -    - - + -   -   -   - + - -     - - +
-	 *  |                           |                             |
-	 *                         
-	 *  |                           |                             |
-	 *                         
-	 *  |                           |                             |
-	 *                         
-	 *  |                           |                             |
-	 *  |                           |                             |
-	 *  |                           |                             |
-	 *  |                           |                             |
-	 *  |                           |                             |
-	 *  + - -  -    - -    -    - - + -   -   -   -   - -     - - +
-	 *
-	 * The coordinate system used in a quadtree are integers to avoid
-	 * round-off errors. The vertex in the lower left box has the coordinates
-	 * (0 0) 
-	 * The upper right vertex has the follwing coordinates:
-	 * 2^30 -1           2^30 -1        in decimal
-	 * 0 1 1 1 .... 1    0 1 1 1 .... 1 in binary
-	 *  \--   29  --/     \--   29  --/
-	 * Using binaries is therefore very easy to locate a vertex in a box:
-	 * we just need to look at the bits from the left to the right (See ::Add)
-	 }}}1*/
-
-	/*Constructors/Destructors*/
-	/*FUNCTION QuadTree::QuadTree(){{{1*/
-	QuadTree::QuadTree(){
-
-		/*Number of boxes and vertices*/
-		NbQuadTreeBox=0;
-		NbVertices=0;
-
-		/*Create container*/
-		boxcontainer=new DataSet();
-
-		/*Create Root, pointer toward the main box*/
-		root=NewQuadTreeBox();
-
-		}
-	/*}}}1*/
-	/*FUNCTION QuadTree::QuadTree(Mesh * t,long nbv){{{1*/
-	QuadTree::QuadTree(Mesh * t,long nbv){ 
-
-		/*Number of boxes and vertices*/
-		NbQuadTreeBox=0;
-		NbVertices=0;
-
-		/*Create container*/
-		boxcontainer=new DataSet();
-
-		/*Create Root, pointer toward the main box*/
-		root=NewQuadTreeBox();
-
-		/*Check Sizes*/
-		_assert_(MaxISize>MaxICoor);
-
-		/*Add all vertices of the mesh*/
-		if (nbv==-1) nbv=t->nbv;
-		for (int i=0;i<nbv;i++) Add(t->vertices[i]);
-
-	}
-	/*}}}1*/
-	/*FUNCTION QuadTree::~QuadTree(){{{1*/
-	QuadTree::~QuadTree() {
-		delete boxcontainer;
-		root=NULL;
-	}
-	/*}}}1*/
-
-	/*Methods*/
-	/*FUNCTION QuadTree::Add{{{1*/
-	void  QuadTree::Add(BamgVertex &w){
-		/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, QuadTree.cpp/Add)*/
-		QuadTreeBox** pb=NULL;
-		QuadTreeBox*  b=NULL;
-
-		/*Get integer coodinate of current point w*/
-		register long i=w.i.x, j=w.i.y;
-
-		/*Initialize level*/
-		register long level=MaxISize;
-
-		/*Get inital box (the largest)*/
-		pb = &root;
-
-		/*Find the smallest box where w is located*/
-		while((b=*pb) && (b->nbitems<0)){ 
-
-			//shift b->nbitems by -1
-			b->nbitems--;
-
-			//shifted righ by one bit: level=00000010 -> 00000001
-			level >>= 1;
-
-			//Get next subbox according to the bit value (level)
-			pb = &b->b[IJ(i,j,level)];
-		}
-
-		/*OK, we have found b, a Subbox holding vertices (might be full)
-		  check that the vertex is not already in the box*/
-		if (b){      
-			if (b->nbitems > 3 &&  b->v[3] == &w) return;
-			if (b->nbitems > 2 &&  b->v[2] == &w) return;
-			if (b->nbitems > 1 &&  b->v[1] == &w) return;
-			if (b->nbitems > 0 &&  b->v[0] == &w) return;
-		}
-
-		/*check that l is not 0 (this should not happen as MaxDeep = 30)*/
-		_assert_(level>0);
-
-		/*Now, try to add the vertex, if the subbox is full (nbitems=4), we have to divide it
-		  in 4 new subboxes*/
-		while ((b= *pb) && (b->nbitems == 4)){ // the QuadTreeBox is full
-
-			/*Copy the 4 vertices in the current QuadTreebox*/
-			BamgVertex* v4[4];
-			v4[0]= b->v[0];
-			v4[1]= b->v[1];
-			v4[2]= b->v[2];
-			v4[3]= b->v[3];
-
-			/*set nbitems as negative 
-			 * (box full -> holds 4 pointers toward subboxes and not 4 vertices)*/
-			b->nbitems = -b->nbitems;
-
-			/*Initialize the 4 pointers toward the 4 subboxes*/
-			b->b[0]=b->b[1]=b->b[2]=b->b[3]=NULL;
-
-			/*level = 0010000 -> 0001000*/
-			level >>= 1;
-
-			/*Put the four vertices in the new boxes*/
-			for (int k=0;k<4;k++){
-
-				int          ij;
-				/*bb is the new "sub"box of b where v4[k] is located*/
-				QuadTreeBox *bb = b->b[ij=IJ(v4[k]->i.x,v4[k]->i.y,level)];
-
-				// alloc the QuadTreeBox
-				if (!bb) bb=b->b[ij]=NewQuadTreeBox(); 
-
-				/*Copy the current vertex*/
-				bb->v[bb->nbitems++] = v4[k];
-			}
-
-			/*Get the subbox where w (i,j) is located*/
-			pb = &b->b[IJ(i,j,level)];
-		}
-
-		/*alloc the QuadTreeBox if necessary*/
-		if (!(b=*pb)) b=*pb= NewQuadTreeBox();
-
-		/*Add w*/
-		b->v[b->nbitems++]=&w;
-
-		//Increase NbVertices by one (we have one new vertex)
-		NbVertices++;
-	}
-	/*}}}1*/
-	/*FUNCTION QuadTree::NearestVertex{{{1*/
-	BamgVertex*  QuadTree::NearestVertex(Icoor1 i,Icoor1 j) {
-		/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, QuadTree.cpp/NearestVertex)*/
-
-		/*Intermediaries*/
-		QuadTreeBox *pb[MaxDeep];
-		int          pi[MaxDeep];
-		Icoor1       ii[MaxDeep];
-		Icoor1       jj[MaxDeep];
-		int          level;
-		long         n0;
-		QuadTreeBox *b;
-		long         h0;
-		long         h = MaxISize;
-		long         hb= MaxISize;
-		Icoor1       i0=0,j0=0;
-
-		/*initial output as NULL (no vertex found)*/
-		BamgVertex*  nearest_v=NULL;
-
-		/*Project w coordinates (i,j) onto [0,MaxISize-1] x [0,MaxISize-1] -> (iplus,jplus)*/
-		Icoor1 iplus( i<MaxISize ? (i<0?0:i) : MaxISize-1);
-		Icoor1 jplus( j<MaxISize ? (j<0?0:j) : MaxISize-1);
-
-		/*Get initial Quadtree box (largest)*/
-		b = root;
-
-		/*if the tree is empty, return NULL pointer*/
-		if (!root->nbitems) return nearest_v; 
-
-		/*else, find the smallest non-empty QuadTreeBox containing  the point (i,j)*/
-		while((n0=b->nbitems)<0){
-
-			Icoor1       hb2 = hb >> 1;             //size of the current box
-			int          k   = IJ(iplus,jplus,hb2); //box number (0,1,2 or 3)
-			QuadTreeBox *b0  = b->b[k];             //pointer toward current box
-
-			/* break if NULL box or empty (Keep previous box b)*/
-			if (( b0 == NULL) || (b0->nbitems == 0)) break;
-
-			/*Get next Quadtree box*/
-			b=b0;	
-			i0 += I_IJ(k,hb2); // i orign of QuadTreeBox (macro)
-			j0 += J_IJ(k,hb2); // j orign of QuadTreeBox 
-			hb = hb2;          // size of the box (in Int)
-		}
-
-		/*The box b, is the smallest box containing the point (i,j) and
-		 * has the following properties:
-		 * - n0: number of items (>0 if vertices, else boxes)
-		 * - hb: box size (int)
-		 * - i0: x coordinate of the lower left corner
-		 * - j0: y coordinate of the lower left corner*/
-
-		/* if the current subbox is holding vertices, we are almost done*/
-		if (n0>0){  
-			//loop over the vertices of the box and find the closest vertex
-			for(int k=0;k<n0;k++){
-
-				/*get integer coordinates of current vertex*/
-				I2 i2=b->v[k]->i;
-
-				/*Compute norm with w*/
-				h0=NORM(iplus,i2.x,jplus,i2.y);
-
-				/*is it smaller than previous value*/
-				if (h0<h){
-					h = h0;
-					nearest_v = b->v[k];
-				}
-			}
-			/*return closest vertex*/
-			return nearest_v;
-		}
-
-		/* general case: the current box is empty, we have to go backwards
-			and find the closest not-empty box and find the closest vertex*/
-
-		/*Initialize search variables*/
-		pb[0]=b;                             //pointer toward the box b
-		pi[0]=b->nbitems>0?(int)b->nbitems:4;//number of boxes in b
-		ii[0]=i0;                            //i coordinate of the box lowest left corner
-		jj[0]=j0;                            //j coordinate of the box lowest left corner
-
-		/*initialize h: smallest box size, containing a vertex close to w*/
-		h=hb;
-
-		/*Main loop*/
-		level=0;
-		do {
-
-			/*get current box*/
-			b= pb[level];
-
-			/*Loop over the items in current box (if not empty!)*/
-			while (pi[level]){
-
-				/*We are looping now over the items of b. k is the current index (in [0 3])*/
-				pi[level]--;
-				int k=pi[level];
-
-				/*if the current subbox is holding vertices (b->nbitems<0 is subboxes)*/
-				if (b->nbitems>0){
-					I2 i2=b->v[k]->i;
-					h0 = NORM(iplus,i2.x,jplus,i2.y);
-					if (h0<h){
-						h=h0;
-						nearest_v=b->v[k];
-					}
-				}
-				/*else: current box b is pointing toward 4 boxes
-				 * test sub-box k and go deeper into the tree if it is non empty
-				 * and contains the point w modulo a size h that is either the size of the smallest
-				 * non empty box containing w, or the closest point to w (so far) */
-				else{
-					QuadTreeBox* b0=b;
-
-					/*if the next box exists:*/
-					if (b=b->b[k]){
-
-						/*Get size (hb) and coordinates of the current sub-box lowest left corner*/
-						hb>>=1;
-						Icoor1 iii = ii[level]+I_IJ(k,hb);
-						Icoor1 jjj = jj[level]+J_IJ(k,hb);
-
-						/*if the current point (iplus,jplus) is in b (modulo h), this box is good:
-						 * it is holding vertices that are close to w */
-						if (INTER_SEG(iii,iii+hb,iplus-h,iplus+h) && INTER_SEG(jjj,jjj+hb,jplus-h,jplus+h)){
-							level++;
-							pb[level]= b;
-							pi[level]= b->nbitems>0 ?(int)  b->nbitems : 4  ;
-							ii[level]= iii;
-							jj[level]= jjj;
-						}
-
-						//else go backwards
-						else{
-							//shifted righ by one bit: hb=001000000 -> 01000000
-							b=b0;
-							hb<<=1;
-						}
-					}
-					else{
-						/*Current box is NULL, go to next subbox of b (k=k-1)*/
-						b=b0;
-					}
-				}
-			}
-
-			/*We have found a vertex, now, let's try the other boxes of the previous level
-			 * in case there is a vertex closest to w that has not yet been tested*/
-			hb <<= 1;
-		} while (level--);
-
-		/*return nearest_v, nearest vertex*/
-		return nearest_v;
-
-	}
-	/*}}}1*/
-	/*FUNCTION QuadTree::NearestVertexWithNormal{{{1*/
-	BamgVertex*  QuadTree::NearestVertexWithNormal(Icoor1 i,Icoor1 j) {
-		/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, QuadTree.cpp/NearestVertexWithNormal)*/
-
-		QuadTreeBox * pb[ MaxDeep ];
-		int  pi[ MaxDeep  ];
-		Icoor1 ii[  MaxDeep ], jj [ MaxDeep];
-		int l; // level
-		QuadTreeBox * b;
-		long     h =MaxISize,h0;
-		long     hb=MaxISize;
-		Icoor1  i0=0,j0=0;
-		Icoor1  iplus( i<MaxISize?(i<0?0:i):MaxISize-1);
-		Icoor1  jplus( j<MaxISize?(j<0?0:j):MaxISize-1);
-
-		BamgVertex *vn=0;
-
-		// init for optimisation ---
-		b = root;
-		register long  n0;
-		if (!root->nbitems)
-		 return vn; // empty tree 
-
-		while( (n0 = b->nbitems) < 0) 
-		  {
-			// search the non empty 
-			// QuadTreeBox containing  the point (i,j)
-			register Icoor1 hb2 = hb >> 1 ;
-			register  int k = IJ(iplus,jplus,hb2);// QuadTreeBox number of size hb2 contening i;j
-			register QuadTreeBox * b0= b->b[k];
-			if ( ( b0 == 0) || (b0->nbitems == 0) ) 
-			 break; // null box or empty   => break 	    
-			b=b0;	
-			i0 += I_IJ(k,hb2); // i orign of QuadTreeBox
-			j0 += J_IJ(k,hb2); // j orign of QuadTreeBox 
-			hb = hb2; 
-		  }
-
-
-		if ( n0 > 0) 
-		  {  
-			for(register int k=0;k<n0;k++)
-			  {
-				I2 i2 =  b->v[k]->i;
-				//   try if is in the right direction -- 
-				h0 = NORM(iplus,i2.x,jplus,i2.y);
-				if (h0 <h) {
-					h = h0;
-					vn = b->v[k];}
-			  }
-			if (vn) return vn; 
-		  }
-		// general case -----
-		// INITIALISATION OF THE HEAP 
-		l =0; // level 
-		pb[0]= b;
-		pi[0]=b->nbitems>0 ?(int)  b->nbitems : 4  ;
-		ii[0]=i0;
-		jj[0]=j0;
-		h=hb;
-		do {   // walk on the tree  
-			b= pb[l];
-			while (pi[l]--) // loop on 4 element of the box
-			  { 	      
-				int k = pi[l];
-
-				if (b->nbitems>0) // BamgVertex QuadTreeBox none empty
-				  { 
-					I2 i2 =  b->v[k]->i;
-					// if good direction when try -- 
-
-					h0 = NORM(iplus,i2.x,jplus,i2.y);
-					if (h0 <h) 
-					  {
-						h = h0;
-						vn = b->v[k];
-					  }
-				  }
-				else // Pointer QuadTreeBox 
-				  { 
-					register QuadTreeBox *b0=b;
-					if ((b=b->b[k])) 
-					  {
-						hb >>=1 ; // div by 2
-						register Icoor1 iii = ii[l]+I_IJ(k,hb);
-						register Icoor1 jjj = jj[l]+J_IJ(k,hb);
-
-						if  (INTER_SEG(iii,iii+hb,iplus-h,iplus+h) && INTER_SEG(jjj,jjj+hb,jplus-h,jplus+h)) 
-						  {
-							pb[++l]=  b;
-							pi[l]= b->nbitems>0 ?(int)  b->nbitems : 4  ;
-							ii[l]= iii;
-							jj[l]= jjj;
-
-						  }
-						else
-						 b=b0, hb <<=1 ;
-					  }
-					else
-					 b=b0;
-				  }
-			  }
-			hb <<= 1; // mul by 2 
-		} while (l--);
-
-		return vn;
-	}
-	/*}}}1*/
-	/*FUNCTION QuadTree::NewQuadTreeBox {{{1*/
-	QuadTree::QuadTreeBox* QuadTree::NewQuadTreeBox(void){
-
-		/*Output*/
-		QuadTreeBox* newbox=NULL;
-
-		/*Create and initialize a new box*/
-		newbox=new QuadTreeBox;
-		newbox->nbitems=0;
-		newbox->b[0]=NULL;
-		newbox->b[1]=NULL;
-		newbox->b[2]=NULL;
-		newbox->b[3]=NULL;
-
-		/*Add root to the container*/
-		boxcontainer->AddObject(newbox);
-
-		/*Increase counter*/
-		NbQuadTreeBox++;
-
-		/*currentbox now points toward next quadtree box*/
-		return newbox;
-	}/*}}}*/
-	/*FUNCTION QuadTree::ToClose {{{1*/
-	BamgVertex*   QuadTree::ToClose(BamgVertex & v,double seuil,Icoor1 hx,Icoor1 hy){
-		/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, QuadTree.cpp/ToClose)*/
-
-		const Icoor1 i=v.i.x;
-		const Icoor1 j=v.i.y;
-		const R2 X(v.r);
-		const Metric  Mx(v.m);
-
-		QuadTreeBox * pb[ MaxDeep ];
-		int  pi[ MaxDeep  ];
-		Icoor1 ii[  MaxDeep ], jj [ MaxDeep];
-		register int l=0; // level
-		register QuadTreeBox * b;
-		Icoor1 h=MaxISize;
-		Icoor1 hb =  MaxISize;
-		Icoor1 i0=0,j0=0;
-
-		//  BamgVertex *vn=0;
-
-		if (!root->nbitems)
-		 return 0; // empty tree 
-
-		// general case -----
-		pb[0]=root;
-		pi[0]=root->nbitems>0 ?(int)  root->nbitems : 4  ;
-		ii[0]=i0;
-		jj[0]=j0;
-		h=hb;
-		do {    
-			b= pb[l];
-			while (pi[l]--){ 	      
-				register int k = pi[l];
-
-				if (b->nbitems>0){ // BamgVertex QuadTreeBox none empty
-					I2 i2 =  b->v[k]->i;
-					if ( ABS(i-i2.x) <hx && ABS(j-i2.y) <hy )
-					  {
-						R2 XY(X,b->v[k]->r);
-						double dd;
-						if( (dd= LengthInterpole(Mx(XY), b->v[k]->m(XY)))  < seuil ){
-							return b->v[k]; 
-						}
-					  }
-				}
-				else{ // Pointer QuadTreeBox 
-					register QuadTreeBox *b0=b;
-					if ((b=b->b[k])){
-						hb >>=1 ; // div by 2
-						register long iii = ii[l]+I_IJ(k,hb);
-						register long jjj = jj[l]+J_IJ(k,hb);
-
-						if  (INTER_SEG(iii,iii+hb,i-hx,i+hx) && INTER_SEG(jjj,jjj+hb,j-hy,j+hy)){
-							pb[++l]=  b;
-							pi[l]= b->nbitems>0 ?(int)  b->nbitems : 4  ;
-							ii[l]= iii;
-							jj[l]= jjj;
-
-						}
-						else{
-							b=b0;
-							hb <<=1 ;
-						}
-					}
-					else{
-						b=b0;
-					}
-				}
-			}
-			hb <<= 1; // mul by 2 
-		} while (l--);
-
-		return 0;
-	}
-	/*}}}1*/
-}
Index: sm/branches/trunk-jpl-damage/src/c/objects/Bamg/QuadTree.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Bamg/QuadTree.h	(revision 12257)
+++ 	(revision )
@@ -1,61 +1,0 @@
-/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, QuadTree.h)*/
-#ifndef _QUADTREE_H
-#define _QUADTREE_H
-
-#include "./include.h"
-
-namespace bamg {
-
-	const int  MaxDeep  = 30;
-	const long MaxISize = ( 1L << MaxDeep);  // = 2^30 : 010000000000..000 (bitwise operation)
-
-	class BamgVertex;
-
-	class QuadTree{
-
-		private:
-
-			/*A quadtree box contains a maximum of 4 vertices. 4 other quadtree boxes are
-			 * created if a fifth vertex is added to the same box. A Quadtree box is therefore
-			 * composed of EITHER:
-			 * - up to 4 vertices
-			 * - 4 "sub" quadtree boxes*/
-			class QuadTreeBox: public Object{ 
-				public:
-					int nbitems; // number of current vertices in the box
-					union{
-						QuadTreeBox* b[4];
-						BamgVertex*  v[4];
-					};
-					/*Object functions*/
-					void  Echo(){_error_("not implemented yet");};
-					void  DeepEcho(){_error_("not implemented yet");};
-					int   Id(){_error_("not implemented yet");};
-					int   MyRank(){_error_("not implemented yet");};
-					int   ObjectEnum(){_error_("not implemented yet");};
-					Object* copy(){_error_("not implemented yet");};
-			};
-
-			/*QuadTree private Fields*/
-			DataSet* boxcontainer;
-
-		public:
-
-			/*QuadTree public Fields*/
-			QuadTreeBox* root;
-			long         NbQuadTreeBox;
-			long         NbVertices;
-
-			QuadTree();
-			QuadTree(Mesh *t,long nbv=-1);
-			~QuadTree();
-
-			BamgVertex*  NearestVertex(Icoor1 i,Icoor1 j);
-			BamgVertex*  NearestVertexWithNormal(Icoor1 i,Icoor1 j);
-			QuadTreeBox* NewQuadTreeBox(void);
-			BamgVertex*  ToClose(BamgVertex & ,double ,Icoor1,Icoor1);
-			void         Add( BamgVertex & w);
-
-	};
-}
-#endif
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Constraints/Constraint.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Constraints/Constraint.h	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Constraints/Constraint.h	(revision 12258)
@@ -11,8 +11,6 @@
 /*Headers:*/
 /*{{{1*/
+class Nodes;
 #include "../Object.h"
-
-class Nodes;
-
 #include "../../toolkits/toolkits.h"
 /*}}}*/
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Kriging/ExponentialVariogram.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Kriging/ExponentialVariogram.cpp	(revision 12258)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Kriging/ExponentialVariogram.cpp	(revision 12258)
@@ -0,0 +1,74 @@
+/*!\file ExponentialVariogram.c
+ * \brief: implementation of the ExponentialVariogram object
+ */
+
+#ifdef HAVE_CONFIG_H
+	#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+#include <stdio.h>
+#include <string.h>
+#include "../objects.h"
+#include "../../EnumDefinitions/EnumDefinitions.h"
+#include "../../shared/shared.h"
+#include "../../include/include.h"
+
+/*ExponentialVariogram constructors and destructor*/
+/*FUNCTION ExponentialVariogram::ExponentialVariogram(){{{1*/
+ExponentialVariogram::ExponentialVariogram(){
+	this->nugget = 0.2;
+	this->sill   = 1;
+	this->range  = SQRT3;
+	return;
+}
+/*}}}*/
+/*FUNCTION ExponentialVariogram::ExponentialVariogram(Options* options){{{1*/
+ExponentialVariogram::ExponentialVariogram(Options* options){
+
+	/*Defaults*/
+	this->nugget = 0.2;
+	this->sill   = 1;
+	this->range  = SQRT3;
+
+	/*Overwrite from options*/
+	if(options->GetOption("nugget")) options->Get(&this->nugget,"nugget");
+	if(options->GetOption("sill"))   options->Get(&this->sill,"sill");
+	if(options->GetOption("range"))  options->Get(&this->range,"range");
+
+	/*Checks*/
+	if(nugget==sill) _error_("nugget and sill cannot be equal (constant semivariogram not allowed)");
+}
+/*}}}*/
+/*FUNCTION ExponentialVariogram::~ExponentialVariogram(){{{1*/
+ExponentialVariogram::~ExponentialVariogram(){
+	return;
+}
+/*}}}*/
+
+/*Object virtual functions definitions:*/
+/*FUNCTION ExponentialVariogram::Echo {{{1*/
+void ExponentialVariogram::Echo(void){
+	printf("ExponentialVariogram\n");
+	printf("   nugget: %g\n",this->nugget);
+	printf("   sill  : %g\n",this->sill);
+	printf("   range : %g\n",this->range);
+}
+/*}}}*/
+
+/*Variogram function*/
+/*FUNCTION ExponentialVariogram::SemiVariogram{{{1*/
+double ExponentialVariogram::SemiVariogram(double deltax,double deltay){
+	/*http://en.wikipedia.org/wiki/Variogram*/
+	double h,a,gamma;
+
+	/*Calculate length*/
+	h=sqrt(pow(deltax,2.)+pow(deltay,2.));
+
+	/*return semi-variogram*/
+	a     = 1./3.;
+	gamma = (sill-nugget)*(1-exp(-h/(a*range))) + nugget;
+	return gamma;
+}
+/*}}}*/
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Kriging/ExponentialVariogram.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Kriging/ExponentialVariogram.h	(revision 12258)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Kriging/ExponentialVariogram.h	(revision 12258)
@@ -0,0 +1,34 @@
+/*! \file ExponentialVariogram.h 
+ *  \brief: header file for triavertexinput object
+ */
+
+#ifndef _EXPONENTIALVARIOGRAM_H_
+#define _EXPONENTIALVARIOGRAM_H_
+
+/*Headers:*/
+#include "./Variogram.h"
+
+class ExponentialVariogram: public Variogram{
+
+	public:
+		double nugget; //The height of the jump of the semivariogram at the discontinuity at the origin
+		double sill;   //Limit of the variogram tending to infinity lag distances
+		double range;  //The distance in which the difference of the variogram from the sill becomes negligible
+
+		/*ExponentialVariogram constructors, destructors*/
+		ExponentialVariogram();
+		ExponentialVariogram(Options* options);
+		~ExponentialVariogram();
+
+		/*Object virtual functions definitions*/
+		void  Echo();
+		void  DeepEcho(){_error_("Not implemented yet");};
+		int   Id(){_error_("Not implemented yet");}; 
+		int   MyRank(){_error_("Not implemented yet");};
+		int   ObjectEnum(){_error_("Not implemented yet");};
+		Object* copy(){_error_("Not implemented yet");};
+
+		/*Variogram functions*/
+		double SemiVariogram(double deltax,double deltay);
+};
+#endif  /* _EXPONENTIALVARIOGRAM_H */
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Kriging/GaussianVariogram.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Kriging/GaussianVariogram.cpp	(revision 12258)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Kriging/GaussianVariogram.cpp	(revision 12258)
@@ -0,0 +1,74 @@
+/*!\file GaussianVariogram.c
+ * \brief: implementation of the GaussianVariogram object
+ */
+
+#ifdef HAVE_CONFIG_H
+	#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+#include <stdio.h>
+#include <string.h>
+#include "../objects.h"
+#include "../../EnumDefinitions/EnumDefinitions.h"
+#include "../../shared/shared.h"
+#include "../../include/include.h"
+
+/*GaussianVariogram constructors and destructor*/
+/*FUNCTION GaussianVariogram::GaussianVariogram(){{{1*/
+GaussianVariogram::GaussianVariogram(){
+	this->nugget = 0.2;
+	this->sill   = 1;
+	this->range  = SQRT3;
+	return;
+}
+/*}}}*/
+/*FUNCTION GaussianVariogram::GaussianVariogram(Options* options){{{1*/
+GaussianVariogram::GaussianVariogram(Options* options){
+
+	/*Defaults*/
+	this->nugget = 0.2;
+	this->sill   = 1;
+	this->range  = SQRT3;
+
+	/*Overwrite from options*/
+	if(options->GetOption("nugget")) options->Get(&this->nugget,"nugget");
+	if(options->GetOption("sill"))   options->Get(&this->sill,"sill");
+	if(options->GetOption("range"))  options->Get(&this->range,"range");
+
+	/*Checks*/
+	if(nugget==sill) _error_("nugget and sill cannot be equal (constant semivariogram not allowed)");
+}
+/*}}}*/
+/*FUNCTION GaussianVariogram::~GaussianVariogram(){{{1*/
+GaussianVariogram::~GaussianVariogram(){
+	return;
+}
+/*}}}*/
+
+/*Object virtual functions definitions:*/
+/*FUNCTION GaussianVariogram::Echo {{{1*/
+void GaussianVariogram::Echo(void){
+	printf("GaussianVariogram\n");
+	printf("   nugget: %g\n",this->nugget);
+	printf("   sill  : %g\n",this->sill);
+	printf("   range : %g\n",this->range);
+}
+/*}}}*/
+
+/*Variogram function*/
+/*FUNCTION GaussianVariogram::SemiVariogram{{{1*/
+double GaussianVariogram::SemiVariogram(double deltax,double deltay){
+	/*http://en.wikipedia.org/wiki/Variogram*/
+	double h2,a,gamma;
+
+	/*Calculate length square*/
+	h2=pow(deltax,2.)+pow(deltay,2.);
+
+	/*return semi-variogram*/
+	a     = 1./3.;
+	gamma = (sill-nugget)*(1-exp(-h2/(a*pow(range,2.)))) + nugget;
+	return gamma;
+}
+/*}}}*/
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Kriging/GaussianVariogram.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Kriging/GaussianVariogram.h	(revision 12258)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Kriging/GaussianVariogram.h	(revision 12258)
@@ -0,0 +1,34 @@
+/*! \file GaussianVariogram.h 
+ *  \brief: header file for triavertexinput object
+ */
+
+#ifndef _GAUSSIANVARIOGRAM_H_
+#define _GAUSSIANVARIOGRAM_H_
+
+/*Headers:*/
+#include "./Variogram.h"
+
+class GaussianVariogram: public Variogram{
+
+	public:
+		double nugget; //The height of the jump of the semivariogram at the discontinuity at the origin
+		double sill;   //Limit of the variogram tending to infinity lag distances
+		double range;  //The distance in which the difference of the variogram from the sill becomes negligible
+
+		/*GaussianVariogram constructors, destructors*/
+		GaussianVariogram();
+		GaussianVariogram(Options* options);
+		~GaussianVariogram();
+
+		/*Object virtual functions definitions*/
+		void  Echo();
+		void  DeepEcho(){_error_("Not implemented yet");};
+		int   Id(){_error_("Not implemented yet");}; 
+		int   MyRank(){_error_("Not implemented yet");};
+		int   ObjectEnum(){_error_("Not implemented yet");};
+		Object* copy(){_error_("Not implemented yet");};
+
+		/*Variogram functions*/
+		double SemiVariogram(double deltax,double deltay);
+};
+#endif  /* _GAUSSIANVARIOGRAM_H */
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Kriging/Observation.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Kriging/Observation.cpp	(revision 12258)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Kriging/Observation.cpp	(revision 12258)
@@ -0,0 +1,55 @@
+/*!\file Observation.c
+ * \brief: implementation of the Observation object
+ */
+
+#include <stdlib.h>
+#include "../objects.h"
+
+/*Observation constructors and destructor*/
+/*FUNCTION Observation::Observation(){{{1*/
+Observation::Observation(){
+	return;
+}
+/*}}}*/
+/*FUNCTION Observation::Observation(double x,double y,int xi,int yi,int index,double value){{{1*/
+Observation::Observation(double x_in,double y_in,int xi_in,int yi_in,int index_in,double value_in){
+
+	this->x     = x_in;
+	this->y     = y_in;
+	this->xi    = xi_in;
+	this->yi    = yi_in;
+	this->index = index_in;
+	this->value = value_in;
+
+}
+/*}}}*/
+/*FUNCTION Observation::~Observation(){{{1*/
+Observation::~Observation(){
+	return;
+}
+/*}}}*/
+
+/*Object virtual functions definitions:*/
+/*FUNCTION Observation::Echo {{{1*/
+void Observation::Echo(void){
+
+	int  bit;
+
+	printf("Observation\n");
+	printf("   index : %i\n",this->index);
+	printf("   x     : %g\n",this->x);
+	printf("   y     : %g\n",this->y);
+	printf("   xi    : "); printbinary(this->xi); printf("\n");
+	printf("   yi    : "); printbinary(this->yi); printf("\n");
+	printf("   value : %g\n",this->value);
+}
+/*}}}*/
+
+/*Observations functions*/
+/*FUNCTION Observation::WriteXYObs(double* px,double* py,double* pobs){{{1*/
+void Observation::WriteXYObs(double* px,double* py,double* pobs){
+	*px   = this->x;
+	*py   = this->y;
+	*pobs = this->value;
+}
+/*}}}*/
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Kriging/Observation.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Kriging/Observation.h	(revision 12258)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Kriging/Observation.h	(revision 12258)
@@ -0,0 +1,34 @@
+/*! \file Observation.h 
+ *  \brief: header file for Observation object
+ */
+
+#ifndef _OBSERVATION_H_
+#define _OBSERVATION_H_
+
+#include "../Object.h"
+
+class Observation: public Object{
+
+	public:
+		double x,y;
+		int    xi,yi;
+		int    index;
+		double value;
+
+		/*Observation constructors, destructors*/
+		Observation();
+		Observation(double x_in,double y_in,int xi_in,int yi_in,int index_in,double value_in);
+		~Observation();
+
+		/*Object virtual functions definitions*/
+		void    Echo();
+		void    DeepEcho()  {_error_("Not implemented yet"); };
+		int     Id()        {_error_("Not implemented yet"); };
+		int     MyRank()    {_error_("Not implemented yet"); };
+		int     ObjectEnum(){_error_("Not implemented yet"); };
+		Object *copy()      {_error_("Not implemented yet"); };
+
+		/*Management*/
+		void WriteXYObs(double* px,double* py,double* pobs);
+};
+#endif  /* _OBSERVATION_*/
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Kriging/PowerVariogram.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Kriging/PowerVariogram.cpp	(revision 12258)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Kriging/PowerVariogram.cpp	(revision 12258)
@@ -0,0 +1,75 @@
+/*!\file PowerVariogram.c
+ * \brief: implementation of the PowerVariogram object
+ */
+
+#ifdef HAVE_CONFIG_H
+	#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+#include <stdio.h>
+#include <string.h>
+#include "../objects.h"
+#include "../../EnumDefinitions/EnumDefinitions.h"
+#include "../../shared/shared.h"
+#include "../../include/include.h"
+
+/*PowerVariogram constructors and destructor*/
+/*FUNCTION PowerVariogram::PowerVariogram(){{{1*/
+PowerVariogram::PowerVariogram(){
+	this->nugget = 0.2;
+	this->slope  = 1.;
+	this->power  = 1.;
+	return;
+}
+/*}}}*/
+/*FUNCTION PowerVariogram::PowerVariogram(Options* options){{{1*/
+PowerVariogram::PowerVariogram(Options* options){
+
+	/*Defaults*/
+	this->nugget = 0.2;
+	this->slope  = 1.;
+	this->power  = 1.;
+
+	/*Overwrite from options*/
+	if(options->GetOption("nugget")) options->Get(&this->nugget,"nugget");
+	if(options->GetOption("slope"))  options->Get(&this->slope,"slope");
+	if(options->GetOption("power"))  options->Get(&this->power,"power");
+
+	/*Checks*/
+	if(power<=0 || power>=2) _error_("power must be betwwen 0 and 2 (0 < power < 2)");
+	if(slope<=0) _error_("slope must be positive");
+}
+/*}}}*/
+/*FUNCTION PowerVariogram::~PowerVariogram(){{{1*/
+PowerVariogram::~PowerVariogram(){
+	return;
+}
+/*}}}*/
+
+/*Object virtual functions definitions:*/
+/*FUNCTION PowerVariogram::Echo {{{1*/
+void PowerVariogram::Echo(void){
+	printf("PowerVariogram\n");
+	printf("   nugget: %g\n",this->nugget);
+	printf("   slope : %g\n",this->slope);
+	printf("   power : %g\n",this->power);
+}
+/*}}}*/
+
+/*Variogram function*/
+/*FUNCTION PowerVariogram::SemiVariogram{{{1*/
+double PowerVariogram::SemiVariogram(double deltax,double deltay){
+	/*http://en.wikipedia.org/wiki/Variogram*/
+	double h,gamma;
+
+	/*Calculate length square*/
+	h=sqrt(pow(deltax,2.)+pow(deltay,2.));
+
+	/*return semi-variogram*/
+	gamma = this->nugget + this->slope*pow(h,this->power);
+
+	return gamma;
+}
+/*}}}*/
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Kriging/PowerVariogram.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Kriging/PowerVariogram.h	(revision 12258)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Kriging/PowerVariogram.h	(revision 12258)
@@ -0,0 +1,34 @@
+/*! \file PowerVariogram.h 
+ *  \brief: header file for triavertexinput object
+ */
+
+#ifndef _POWERVARIOGRAM_H_
+#define _POWERVARIOGRAM_H_
+
+/*Headers:*/
+#include "./Variogram.h"
+
+class PowerVariogram: public Variogram{
+
+	public:
+		double nugget; //The height of the jump of the semivariogram at the discontinuity at the origin
+		double slope;  
+		double power; 
+
+		/*PowerVariogram constructors, destructors*/
+		PowerVariogram();
+		PowerVariogram(Options* options);
+		~PowerVariogram();
+
+		/*Object virtual functions definitions*/
+		void  Echo();
+		void  DeepEcho(){_error_("Not implemented yet");};
+		int   Id(){_error_("Not implemented yet");}; 
+		int   MyRank(){_error_("Not implemented yet");};
+		int   ObjectEnum(){_error_("Not implemented yet");};
+		Object* copy(){_error_("Not implemented yet");};
+
+		/*Variogram functions*/
+		double SemiVariogram(double deltax,double deltay);
+};
+#endif  /* _POWERVARIOGRAM_H */
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Kriging/Quadtree.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Kriging/Quadtree.cpp	(revision 12258)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Kriging/Quadtree.cpp	(revision 12258)
@@ -0,0 +1,511 @@
+#include "../objects.h"
+/*DOCUMENTATION What is a Quadtree? {{{1
+ * A Quadtree is a very simple way to group vertices according
+ * to their locations. A square that holds all the points of the mesh
+ * (or the geometry) is divided into 4 boxes. As soon as one box
+ * hold more than 4 vertices, it is divided into 4 new boxes, etc...
+ * There cannot be more than MAXDEEP (=30) subdivision.
+ * This process is like a Dichotomy in dimension 2
+ *
+ *  + - -  -    - -    -    - - + -   - + - + - + - -     - - +
+ *  |                           |       |   | X |             |
+ *                                      + - + - +
+ *  |                           |       |   |   |             |
+ *                              + -   - + - + - +             +
+ *  |                           |       |       |             |
+ *                         
+ *  |                           |       |       |             |
+ *  + - -  -    - -    -    - - + -   - + -   - + - -     - - +
+ *  |                           |               |             |
+ *                         
+ *  |                           |               |             |
+ *                         
+ *  |                           |               |             |
+ *  |                           |               |             |
+ *  + - -  -    - -    -    - - + -   -   -   - + - -     - - +
+ *  |                           |                             |
+ *                         
+ *  |                           |                             |
+ *                         
+ *  |                           |                             |
+ *                         
+ *  |                           |                             |
+ *  |                           |                             |
+ *  |                           |                             |
+ *  |                           |                             |
+ *  |                           |                             |
+ *  + - -  -    - -    -    - - + -   -   -   -   - -     - - +
+ *
+ * The coordinate system used in a quadtree are integers to avoid
+ * round-off errors. The vertex in the lower left box has the coordinates
+ * (0 0) 
+ * The upper right vertex has the follwing coordinates:
+ * 2^30 -1           2^30 -1        in decimal
+ * 0 1 1 1 .... 1    0 1 1 1 .... 1 in binary
+ *  \--   29  --/     \--   29  --/
+ * Using binaries is therefore very easy to locate a vertex in a box:
+ * we just need to look at the bits from the left to the right (See ::Add)
+ }}}1*/
+/*MACROS {{{1*/
+/* 
+ * 
+ *    J    j
+ *    ^    ^
+ *    |    | +--------+--------+
+ *    |    | |        |        |
+ * 1X |    | |   2    |   3    |
+ *    |    | |        |        |
+ *    |    | +--------+--------+
+ *    |    | |        |        |
+ * 0X |    | |   0    |   1    |
+ *    |    | |        |        |
+ *    |    | +--------+--------+
+ *    |    +-----------------------> i
+ *    |         
+ *    |----------------------------> I
+ *              X0        X1  
+ *
+ * box 0 -> I=0 J=0 IJ=00  = 0
+ * box 1 -> I=1 J=0 IJ=01  = 1
+ * box 2 -> I=0 J=1 IJ=10  = 2
+ * box 3 -> I=1 J=1 IJ=11  = 3
+ */
+//IJ(i,j,l) returns the box number of i and j with respect to l
+//if !j&l and !i&l -> 0 (box zero: lower left )
+//if !j&l and  i&l -> 1 (box one:  lower right)
+//if  j&l and !i&l -> 2 (box two:  upper left )
+//if  j&l and  i&l -> 3 (box three:upper right)
+#define IJ(i,j,l)  ((j&l) ? ((i&l) ? 3:2 ) :((i&l) ? 1:0 ))
+/*}}}*/
+
+	/*Constructors/Destructors*/
+/*FUNCTION Quadtree::Quadtree(){{{1*/
+Quadtree::Quadtree(){
+	_error_("Constructor not supported");
+
+}
+/*}}}1*/
+/*FUNCTION Quadtree::Quadtree(double xmin,double xmax,double ymin,double ymax,int maxdepth){{{1*/
+Quadtree::Quadtree(double xmin,double xmax,double ymin,double ymax,int maxdepth){
+
+	/*Intermediaries*/
+	double length;
+
+	/*Initialize fields*/
+	this->MaxDepth=maxdepth;
+	this->NbQuadtreeBox=0;
+	this->NbObs=0;
+
+	/*Create container*/
+	this->boxcontainer=new DataSet();
+
+	/*Create Root, pointer toward the main box*/
+	length=max(xmax-xmin,ymax-ymin);
+	this->root=NewQuadtreeBox(xmin+length/2,ymin+length/2,length);
+}
+/*}}}1*/
+	/*FUNCTION Quadtree::~Quadtree(){{{1*/
+	Quadtree::~Quadtree(){
+
+		delete boxcontainer;
+		root=NULL;
+
+	}
+	/*}}}1*/
+
+	/*Methods*/
+/*FUNCTION Quadtree::Add{{{1*/
+void  Quadtree::Add(Observation* observation){
+
+	/*Intermediaries*/
+	int          xi,yi,ij,level,levelbin;
+	QuadtreeBox **pbox    = NULL; // pointer toward current box b
+	QuadtreeBox **pmaster = NULL; // pointer toward master of b
+	QuadtreeBox  *box     = NULL; // current box b
+	QuadtreeBox  *slave   = NULL; // suslaveox of b (if necessary)
+	Observation  *obs[4];
+
+	/*Get integer coodinates*/
+	xi = observation->xi;
+	yi = observation->yi;
+
+	/*Initialize levels*/
+	level    = 0;
+	levelbin = (1L<<this->MaxDepth);// = 2^30
+
+	/*Get inital box (the largest)*/
+	pmaster = &root;
+	pbox    = &root;
+
+	/*Find the smallest box where the observation is located*/
+	while((box=*pbox) && (box->nbitems<0)){ 
+
+		/*Go down one level (levelbin = 00100 -> 00010)*/
+		levelbin>>=1; level+=1; _assert_(level<this->MaxDepth);
+
+		/*Get next box according to the bit value (levelbin)*/
+		pmaster = pbox;
+		pbox    = &box->box[IJ(xi,yi,levelbin)];
+	}
+	_assert_(levelbin>0);
+
+	/*Now, try to add the vertex, if the box is full (nbitems=4), we have to divide it in 4 new boxes*/
+	while((box=*pbox) && (box->nbitems==4)){
+
+		/*Copy the 4 observation in the current Quadtreebox*/
+		obs[0] = box->obs[0];
+		obs[1] = box->obs[1];
+		obs[2] = box->obs[2];
+		obs[3] = box->obs[3];
+
+		/*set nbitems as -1 (now holding boxes instead of observations)*/
+		box->nbitems = -1;
+		box->box[0]  = NULL;
+		box->box[1]  = NULL;
+		box->box[2]  = NULL;
+		box->box[3]  = NULL;
+
+		/*Go down one level (levelbin = 00010 -> 00001)*/
+		levelbin>>=1; level+=1; _assert_(level<this->MaxDepth);
+
+		/*Put the four observations in the new boxes*/
+		for (int k=0;k<4;k++){
+
+			/*Get box for observation number k*/
+			ij    = IJ(obs[k]->xi,obs[k]->yi,levelbin);
+			slave = box->box[ij];
+			if(!slave){
+				box->box[ij] = NewQuadtreeBox(box,ij);
+				slave        = box->box[ij];
+			}
+			slave->obs[slave->nbitems++] = obs[k];
+		}
+
+		/*Get the suslaveox where the current observation is located*/
+		ij      = IJ(xi,yi,levelbin);
+		pmaster = pbox;
+		pbox    = &box->box[ij];
+	}
+
+	/*alloc the QuadtreeBox if necessary and add current observation*/
+	box = *pbox;
+	if(!box){
+		ij  = IJ(xi,yi,levelbin);
+		box = *pbox = NewQuadtreeBox(*pmaster,ij);
+	}
+	box->obs[box->nbitems++]=observation;
+	NbObs++;
+
+}/*}}}*/
+/*FUNCTION Quadtree::Echo{{{1*/
+void  Quadtree::Echo(void){
+
+	printf("Quadtree:\n");
+	printf("   MaxDepth      = %i\n",this->MaxDepth);
+	printf("   NbQuadtreeBox = %i\n",this->NbQuadtreeBox);
+	printf("   NbObs         = %i\n",this->NbObs);
+	printf("   root          = %p\n",this->root);
+
+}/*}}}*/
+/*FUNCTION Quadtree::DeepEcho{{{1*/
+void  Quadtree::DeepEcho(void){
+
+	printf("Quadtree:\n");
+	printf("   MaxDepth      = %i\n",this->MaxDepth);
+	printf("   NbQuadtreeBox = %i\n",this->NbQuadtreeBox);
+	printf("   NbObs         = %i\n",this->NbObs);
+	printf("   root          = %p\n",this->root);
+	boxcontainer->Echo();
+
+}/*}}}*/
+/*FUNCTION Quadtree::IntergerCoordinates{{{1*/
+void  Quadtree::IntergerCoordinates(int *xi,int *yi,double x,double y){
+
+	/*Intermediaries*/
+	double coefficient;
+	double xmin,ymin;
+
+	/*Checks in debugging mode*/
+	_assert_(xi && yi);
+	_assert_(this->root);
+
+	/*coeffIcoor is the coefficient used for integer coordinates:
+	 *                (x-xmin)
+	 * xi = (2^30 -1) --------- 
+	 *                 length
+	 * coefficient = (2^30 -1)/length
+	 */
+	coefficient = double((1L<<this->MaxDepth)-1)/(this->root->length);
+	xmin        = this->root->xcenter - this->root->length/2;
+	ymin        = this->root->ycenter - this->root->length/2;
+
+	*xi=int(coefficient*(x - xmin));
+	*yi=int(coefficient*(y - ymin));
+}/*}}}*/
+/*FUNCTION Quadtree::NewQuadtreeBox(double xcenter,double ycenter,double length){{{1*/
+Quadtree::QuadtreeBox* Quadtree::NewQuadtreeBox(double xcenter,double ycenter,double length){
+
+	/*Output*/
+	QuadtreeBox* newbox=NULL;
+
+	/*Create and initialize a new box*/
+	newbox=new QuadtreeBox();
+	newbox->nbitems=0;
+	newbox->xcenter=xcenter;
+	newbox->ycenter=ycenter;
+	newbox->length=length;
+	newbox->box[0]=NULL;
+	newbox->box[1]=NULL;
+	newbox->box[2]=NULL;
+	newbox->box[3]=NULL;
+
+	/*Add to container*/
+	this->boxcontainer->AddObject(newbox);
+	NbQuadtreeBox++;
+
+	/*currentbox now points toward next quadtree box*/
+	return newbox;
+}/*}}}*/
+/*FUNCTION Quadtree::NewQuadtreeBox(QuadtreeBox* master,int index) {{{1*/
+Quadtree::QuadtreeBox* Quadtree::NewQuadtreeBox(QuadtreeBox* master,int index){
+
+	/*Output*/
+	QuadtreeBox* newbox=NULL;
+
+	/*Checks in debugging mode*/
+	_assert_(master);
+
+	/*Create and initialize a new box*/
+	newbox=new QuadtreeBox();
+	newbox->nbitems=0;
+	newbox->box[0]=NULL;
+	newbox->box[1]=NULL;
+	newbox->box[2]=NULL;
+	newbox->box[3]=NULL;
+	switch(index){
+		case 0:
+			newbox->xcenter=master->xcenter - master->length/4;
+			newbox->ycenter=master->ycenter - master->length/4;
+			break;
+		case 1:
+			newbox->xcenter=master->xcenter + master->length/4;
+			newbox->ycenter=master->ycenter - master->length/4;
+			break;
+		case 2:
+			newbox->xcenter=master->xcenter - master->length/4;
+			newbox->ycenter=master->ycenter + master->length/4;
+			break;
+		case 3:
+			newbox->xcenter=master->xcenter + master->length/4;
+			newbox->ycenter=master->ycenter + master->length/4;
+			break;
+		default:
+			_error_("Case %i not supported",index);
+	}
+	newbox->length=master->length/2;
+
+	/*Add to container*/
+	this->boxcontainer->AddObject(newbox);
+	NbQuadtreeBox++;
+
+	/*currentbox now points toward next quadtree box*/
+	return newbox;
+}/*}}}*/
+/*FUNCTION Quadtree::QuadtreeDepth{{{1*/
+void Quadtree::QuadtreeDepth(int* A,int xi,int yi){
+
+	QuadtreeBox **pbox = NULL;
+	QuadtreeBox  *box  = NULL;
+	int           level,levelbin;
+
+	/*Initialize levels*/
+	level    = 0;
+	levelbin = (1L<<this->MaxDepth);// = 2^30
+
+	/*Get inital box (the largest)*/
+	pbox=&root;
+
+	/*Find the smallest box where this point is located*/
+	while((box=*pbox) && (box->nbitems<0)){ 
+
+		levelbin>>=1; level+=1; _assert_(level<this->MaxDepth);
+
+		pbox = &box->box[IJ(xi,yi,levelbin)];
+	}
+	if(box && box->nbitems>0){
+		/*This box is not empty, add one level*/
+		level+=1;
+	}
+
+	*A=level;
+}/*}}}*/
+/*FUNCTION Quadtree::QuadtreeDepth2{{{1*/
+void Quadtree::QuadtreeDepth2(int* A,int xi,int yi){
+
+	QuadtreeBox **pbox = NULL;
+	QuadtreeBox  *box  = NULL;
+	int           level,levelbin;
+
+	/*Initialize levels*/
+	level    = 0;
+	levelbin = (1L<<this->MaxDepth);// = 2^30
+
+	/*Get inital box (the largest)*/
+	pbox=&root;
+
+	/*Find the smallest box where this point is located*/
+	while((box=*pbox) && (box->nbitems<0)){ 
+
+		levelbin>>=1; level+=1; 
+
+		pbox = &box->box[IJ(xi,yi,levelbin)];
+	}
+	if(box && box->nbitems>0){
+		/*This box is not empty, add one level*/
+		level+=1;
+	}
+
+	/*If we were to add the vertex, get level*/
+	if(box && box->nbitems==4){
+		int ij;
+		bool flag=true;
+		while(flag){
+
+			levelbin>>=1; level+=1;
+			if(level>this->MaxDepth){
+				level+=1;
+				break;
+			}
+
+			/*loop over the four observations*/
+			ij=IJ(box->obs[0]->xi,box->obs[0]->yi,levelbin);
+			for (int k=1;k<4;k++){
+				if(IJ(box->obs[k]->xi,box->obs[k]->yi,levelbin) != ij){
+					flag = false;
+				}
+			}
+			if(IJ(xi,yi,levelbin)!=ij){
+				flag = false;
+			}
+		}
+	}
+
+	*A=level;
+}/*}}}*/
+/*FUNCTION Quadtree::RangeSearch{{{1*/
+void Quadtree::RangeSearch(int **pindices,int *pnobs,double x,double y,double range){
+
+	/*Intermediaries*/
+	int  nobs;
+	int *indices = NULL;
+
+	/*Allocate indices (maximum by default*/
+	indices = (int*)xmalloc(this->NbObs*sizeof(int));
+	nobs = 0;
+
+	this->root->RangeSearch(indices,&nobs,x,y,range);
+
+	/*Clean-up and return*/
+	*pnobs=nobs;
+	*pindices=indices;
+
+}/*}}}*/
+
+/*QuadtreeBox methos*/
+/*FUNCTION QuadtreeBox::Echo{{{1*/
+void  Quadtree::QuadtreeBox::Echo(void){
+
+	printf("QuadtreeBox:\n");
+	printf("   nbitems = %i\n",this->nbitems);
+	printf("   xcenter = %g\n",this->xcenter);
+	printf("   ycenter = %g\n",this->ycenter);
+	printf("   length  = %g\n",this->length);
+
+}/*}}}*/
+/*FUNCTION QuadtreeBox::IsWithinRange{{{1*/
+int Quadtree::QuadtreeBox::IsWithinRange(double x,double y,double range){
+
+	/*Return 0 if the 2 boxes do not overlap*/
+	if(this->xcenter+this->length/2 < x-range) return 0;
+	if(this->xcenter-this->length/2 > x+range) return 0;
+	if(this->ycenter+this->length/2 < y-range) return 0;
+	if(this->ycenter-this->length/2 > y+range) return 0;
+
+	/*Return 2 if the this box is included in the range*/
+	if(this->xcenter+this->length/2 <= x+range &&
+		this->ycenter+this->length/2 <= y+range &&
+		this->xcenter-this->length/2 >= x-range &&
+		this->ycenter-this->length/2 >= y-range) return 2;
+
+	/*This is a simple overlap*/
+	return 1;
+
+}/*}}}*/
+/*FUNCTION QuadtreeBox::RangeSearch{{{1*/
+void Quadtree::QuadtreeBox::RangeSearch(int* indices,int *pnobs,double x,double y,double range){
+
+	/*Intermediaries*/
+	int i,nobs;
+
+	/*Recover current number of observations*/
+	nobs = *pnobs;
+
+	switch(this->IsWithinRange(x,y,range)){
+		case 0:
+			/*If this box is not within range, return*/
+			break;
+		case 2:
+			/*This box is included in range*/
+			this->WriteObservations(indices,&nobs);
+			break;
+		case 1:
+			/*This box is partly included*/
+			if(this->nbitems>0){
+				/*If this box has only observations, add indices that are within range*/
+				for(i=0;i<this->nbitems;i++){
+					if(fabs(this->obs[i]->x-x) <= range && fabs(this->obs[i]->y-y) <= range){
+						indices[nobs++]=this->obs[i]->index;
+					}
+				}
+			}
+			else{
+				/*This box points toward boxes*/
+				if(this->box[0]) this->box[0]->RangeSearch(indices,&nobs,x,y,range);
+				if(this->box[1]) this->box[1]->RangeSearch(indices,&nobs,x,y,range);
+				if(this->box[2]) this->box[2]->RangeSearch(indices,&nobs,x,y,range);
+				if(this->box[3]) this->box[3]->RangeSearch(indices,&nobs,x,y,range);
+			}
+			break;
+		default:
+			_error_("Case %i not supported",this->IsWithinRange(x,y,range));
+	}
+
+	/*Assign output pointers: */
+	*pnobs=nobs;
+}/*}}}*/
+/*FUNCTION QuadtreeBox::WriteObservations{{{1*/
+void Quadtree::QuadtreeBox::WriteObservations(int* indices,int *pnobs){
+
+	/*Intermediaries*/
+	int i,nobs;
+
+	/*Recover current number of observations*/
+	nobs = *pnobs;
+
+	if(this->nbitems>0){
+		/*If this box has only observations, add all indices*/
+		for(i=0;i<this->nbitems;i++){
+			indices[nobs++]=this->obs[i]->index;
+		}
+	}
+	else{
+		/*This box points toward boxes, */
+		if(this->box[0]) this->box[0]->WriteObservations(indices,&nobs);
+		if(this->box[1]) this->box[1]->WriteObservations(indices,&nobs);
+		if(this->box[2]) this->box[2]->WriteObservations(indices,&nobs);
+		if(this->box[3]) this->box[3]->WriteObservations(indices,&nobs);
+	}
+
+	/*Assign output pointers: */
+	*pnobs=nobs;
+}/*}}}*/
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Kriging/Quadtree.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Kriging/Quadtree.h	(revision 12258)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Kriging/Quadtree.h	(revision 12258)
@@ -0,0 +1,64 @@
+
+#ifndef _QUADTREE_H
+#define _QUADTREE_H
+
+class Observation;
+
+class Quadtree{
+
+	private:
+		/* A quadtree box contains up to 4 points (locations). 4 new quadtree boxes are
+		 * created if a fifth point is added to the same box. A Quadtree box is therefore
+		 * composed of EITHER:
+		 * - up to 4 vertices
+		 * - 4 "sub" quadtree boxes*/
+
+		class QuadtreeBox: public Object{ 
+			public:
+				int    nbitems; // number of current vertices in the box
+				double xcenter; // x position of the center (double)
+				double ycenter; // x position of the center (double)
+				double length;  // width of the box
+				union{
+					QuadtreeBox *box[4];
+					Observation *obs[4];
+				};
+
+				/*Object functions (Needed because the Quadtree uses a Container*/
+				void    Echo();
+				void    DeepEcho()  {_error_("not implemented yet"); };
+				int     Id()        {_error_("not implemented yet"); };
+				int     MyRank()    {_error_("not implemented yet"); };
+				int     ObjectEnum(){_error_("not implemented yet"); };
+				Object *copy()      {_error_("not implemented yet"); };
+
+				/*Methods*/
+				int IsWithinRange(double x,double y,double range);
+				void RangeSearch(int* indices,int *pnobs,double x,double y,double range);
+				void WriteObservations(int* indices,int *pnobs);
+
+		};
+
+		/*Quadtree private Fields*/
+		DataSet* boxcontainer;
+
+	public:
+		int          MaxDepth;          // maximum number of subdivision
+		QuadtreeBox *root;              // main box
+		long         NbQuadtreeBox;     // total number of boxes
+		long         NbObs;             // number of points
+
+		Quadtree();
+		Quadtree(double xmin,double xmax,double ymin,double ymax,int maxdepth_in);
+		~Quadtree();
+		void         Add(Observation *observation);
+		void         DeepEcho(void);
+		void         Echo(void);
+		void         IntergerCoordinates(int *xi,int *yi,double x,double y);
+		QuadtreeBox *NewQuadtreeBox(double xcenter,double ycenter,double length);
+		QuadtreeBox *NewQuadtreeBox(QuadtreeBox* master,int index);
+		void         QuadtreeDepth(int *A,int xi,int yi);
+		void         QuadtreeDepth2(int *A,int xi,int yi);
+		void         RangeSearch(int **pindices,int *pnobs,double x,double y,double range);
+};
+#endif //_QUADTREE_H
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Kriging/SphericalVariogram.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Kriging/SphericalVariogram.cpp	(revision 12258)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Kriging/SphericalVariogram.cpp	(revision 12258)
@@ -0,0 +1,77 @@
+/*!\file SphericalVariogram.c
+ * \brief: implementation of the SphericalVariogram object
+ */
+
+#ifdef HAVE_CONFIG_H
+	#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+#include <stdio.h>
+#include <string.h>
+#include "../objects.h"
+#include "../../EnumDefinitions/EnumDefinitions.h"
+#include "../../shared/shared.h"
+#include "../../include/include.h"
+
+/*SphericalVariogram constructors and destructor*/
+/*FUNCTION SphericalVariogram::SphericalVariogram(){{{1*/
+SphericalVariogram::SphericalVariogram(){
+	this->nugget = 0.2;
+	this->sill   = 1;
+	this->range  = SQRT3;
+	return;
+}
+/*}}}*/
+/*FUNCTION SphericalVariogram::SphericalVariogram(Options* options){{{1*/
+SphericalVariogram::SphericalVariogram(Options* options){
+
+	/*Defaults*/
+	this->nugget = 0.2;
+	this->sill   = 1;
+	this->range  = SQRT3;
+
+	/*Overwrite from options*/
+	if(options->GetOption("nugget")) options->Get(&this->nugget,"nugget");
+	if(options->GetOption("sill"))   options->Get(&this->sill,"sill");
+	if(options->GetOption("range"))  options->Get(&this->range,"range");
+
+	/*Checks*/
+	if(nugget==sill) _error_("nugget and sill cannot be equal (constant semivariogram not allowed)");
+}
+/*}}}*/
+/*FUNCTION SphericalVariogram::~SphericalVariogram(){{{1*/
+SphericalVariogram::~SphericalVariogram(){
+	return;
+}
+/*}}}*/
+
+/*Object virtual functions definitions:*/
+/*FUNCTION SphericalVariogram::Echo {{{1*/
+void SphericalVariogram::Echo(void){
+	printf("SphericalVariogram\n");
+	printf("   nugget: %g\n",this->nugget);
+	printf("   sill  : %g\n",this->sill);
+	printf("   range : %g\n",this->range);
+}
+/*}}}*/
+
+/*Variogram function*/
+/*FUNCTION SphericalVariogram::SemiVariogram{{{1*/
+double SphericalVariogram::SemiVariogram(double deltax,double deltay){
+	/*http://en.wikipedia.org/wiki/Variogram*/
+	double h,gamma;
+
+	/*Calculate length square*/
+	h=sqrt(pow(deltax,2.)+pow(deltay,2.));
+
+	/*return semi-variogram*/
+	if(h<=range)
+	 gamma = (sill-nugget)*( (3*h)/(2*range) - pow(h,3.)/(2*pow(range,3.)) ) + nugget;
+	else
+	 gamma = sill;
+
+	return gamma;
+}
+/*}}}*/
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Kriging/SphericalVariogram.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Kriging/SphericalVariogram.h	(revision 12258)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Kriging/SphericalVariogram.h	(revision 12258)
@@ -0,0 +1,34 @@
+/*! \file SphericalVariogram.h 
+ *  \brief: header file for triavertexinput object
+ */
+
+#ifndef _SPHERICALVARIOGRAM_H_
+#define _SPHERICALVARIOGRAM_H_
+
+/*Headers:*/
+#include "./Variogram.h"
+
+class SphericalVariogram: public Variogram{
+
+	public:
+		double nugget; //The height of the jump of the semivariogram at the discontinuity at the origin
+		double sill;   //Limit of the variogram tending to infinity lag distances
+		double range;  //The distance in which the difference of the variogram from the sill becomes negligible
+
+		/*SphericalVariogram constructors, destructors*/
+		SphericalVariogram();
+		SphericalVariogram(Options* options);
+		~SphericalVariogram();
+
+		/*Object virtual functions definitions*/
+		void  Echo();
+		void  DeepEcho(){_error_("Not implemented yet");};
+		int   Id(){_error_("Not implemented yet");}; 
+		int   MyRank(){_error_("Not implemented yet");};
+		int   ObjectEnum(){_error_("Not implemented yet");};
+		Object* copy(){_error_("Not implemented yet");};
+
+		/*Variogram functions*/
+		double SemiVariogram(double deltax,double deltay);
+};
+#endif  /* _SPHERICALVARIOGRAM_H */
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Kriging/Variogram.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Kriging/Variogram.h	(revision 12258)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Kriging/Variogram.h	(revision 12258)
@@ -0,0 +1,17 @@
+/*!\file:  Variogram.h
+ * \brief abstract class for Variogram object
+ */ 
+
+#ifndef _VARIOGRAM_H_
+#define _VARIOGRAM_H_
+
+#include "../Object.h"
+
+class Variogram: public Object{
+
+	public: 
+		virtual ~Variogram(){};
+		virtual double SemiVariogram(double deltax,double deltay)=0;
+
+};
+#endif
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Numerics/Vector.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Numerics/Vector.cpp	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Numerics/Vector.cpp	(revision 12258)
@@ -85,5 +85,5 @@
 /*}}}*/
 #endif
-#ifdef _HAVE_GSL_
+#if defined(_HAVE_GSL_) && !defined(_HAVE_PETSC_)
 /*FUNCTION Vector::Vector(SeqVec* seq_vec){{{1*/
 Vector::Vector(SeqVec*  seq_vec){
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Numerics/Vector.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Numerics/Vector.h	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Numerics/Vector.h	(revision 12258)
@@ -43,5 +43,5 @@
 		Vector(Vec petsc_vec);
 		#endif
-		#ifdef _HAVE_GSL_
+		#if defined(_HAVE_GSL_) && !defined(_HAVE_PETSC_)
 		Vector(SeqVec*  seq_vec);
 		#endif
Index: /issm/branches/trunk-jpl-damage/src/c/objects/objects.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/objects.h	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/objects.h	(revision 12258)
@@ -170,6 +170,15 @@
 #include "./Bamg/Mesh.h"
 #include "./Bamg/Geometry.h"
-#include "./Bamg/QuadTree.h"
+#include "./Bamg/BamgQuadtree.h"
 #include "./Bamg/SetOfE4.h"
 
+/*Kriging*/
+#include "./Kriging/Variogram.h"
+#include "./Kriging/GaussianVariogram.h"
+#include "./Kriging/ExponentialVariogram.h"
+#include "./Kriging/SphericalVariogram.h"
+#include "./Kriging/PowerVariogram.h"
+#include "./Kriging/Quadtree.h"
+#include "./Kriging/Observation.h"
+
 #endif
Index: /issm/branches/trunk-jpl-damage/src/c/shared/Elements/elements.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/shared/Elements/elements.h	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/src/c/shared/Elements/elements.h	(revision 12258)
@@ -47,4 +47,15 @@
 	printf("\n");
 }
+inline void printbinary(int n) {
+	unsigned int i=1L<<(sizeof(n)*8-1);
+
+	while (i>0) {
+		if (n&i)
+		 printf("1");
+		else
+		 printf("0");
+		i>>=1;
+	}
+}
 
 #endif //ifndef _SHARED_ELEMENTS_H_
Index: /issm/branches/trunk-jpl-damage/src/m/model/collapse.m
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/model/collapse.m	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/src/m/model/collapse.m	(revision 12258)
@@ -102,6 +102,6 @@
 
 %lat long
-if numel(md.mesh.lat)>1,  md.mesh.lat=project2d(md,md.mesh.lat,1); end
-if numel(md.mesh.long)>1, md.mesh.long=project2d(md,md.mesh.long,1); end
+if numel(md.mesh.lat) ==md.mesh.numberofvertices,  md.mesh.lat=project2d(md,md.mesh.lat,1); end
+if numel(md.mesh.long)==md.mesh.numberofvertices, md.mesh.long=project2d(md,md.mesh.long,1); end
 
 %Initialize with the 2d mesh
Index: /issm/branches/trunk-jpl-damage/src/m/model/partition/AreaAverageOntoPartition.m
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/model/partition/AreaAverageOntoPartition.m	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/src/m/model/partition/AreaAverageOntoPartition.m	(revision 12258)
@@ -29,5 +29,5 @@
 	%finally, project vector: 
 	vector=project2d(md3d,vector,layer);
-	md.qmu.partition=project2d(md3d,md3d.part,layer);
+	md.qmu.partition=project2d(md3d,md3d.qmu.partition,layer);
 end
 
Index: /issm/branches/trunk-jpl-damage/src/m/utils/BC/SetIceShelfBC.py
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/utils/BC/SetIceShelfBC.py	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/src/m/utils/BC/SetIceShelfBC.py	(revision 12258)
@@ -1,3 +1,4 @@
-def SetIceShelfBC(md,icefrontfile='')
+from numpy import *
+def SetIceShelfBC(md,icefrontfile=''):
 	#SETICESHELFBC - Create the boundary conditions for diagnostic and thermal models for a  Ice Shelf with Ice Front
 	#
@@ -22,40 +23,41 @@
 			print 'SetIceShelfBC error message: ice front file '+icefrontfile+ ' not found'
 			return []
-		nodeinsideicefront=ContourToMesh(md.mesh.elements,md.mesh.x,md.mesh.y,icefrontfile,'node',2);
-		nodeonicefront=double(md.mesh.vertexonboundary & nodeinsideicefront);
+		nodeinsideicefront=ContourToMesh(md.mesh.elements,md.mesh.x,md.mesh.y,icefrontfile,'node',2)
+		nodeonicefront=double(md.mesh.vertexonboundary.astype(bool) and nodeinsideicefront.astype(bool))
 	
-	pos=find(md.mesh.vertexonboundary & ~nodeonicefront);
-	md.diagnostic.spcvx=NaN*ones(md.mesh.numberofvertices,1);
-	md.diagnostic.spcvy=NaN*ones(md.mesh.numberofvertices,1);
-	md.diagnostic.spcvz=NaN*ones(md.mesh.numberofvertices,1);
-	md.diagnostic.spcvx(pos)=0;
-	md.diagnostic.spcvy(pos)=0;
-	md.diagnostic.spcvz(pos)=0;
-	md.diagnostic.referential=NaN*ones(md.mesh.numberofvertices,6);
+	pos=argwhere(logical_and(md.mesh.vertexonboundary.astype(bool),~nodeonicefront.astype(bool)))
+	md.diagnostic.spcvx=NaN*ones(md.mesh.numberofvertices);
+	md.diagnostic.spcvy=NaN*ones(md.mesh.numberofvertices);
+	md.diagnostic.spcvz=NaN*ones(md.mesh.numberofvertices);
+	md.diagnostic.spcvx[pos]=0;
+	md.diagnostic.spcvy[pos]=0;
+	md.diagnostic.spcvz[pos]=0;
+	md.diagnostic.referential=float('NaN')*ones((md.mesh.numberofvertices,6),float);
 
 	#Dirichlet Values
-	if (length(md.inversion.vx_obs)==md.mesh.numberofvertices & length(md.inversion.vy_obs)==md.mesh.numberofvertices)
-		disp('      boundary conditions for diagnostic model: spc set as observed velocities');
-		md.diagnostic.spcvx(pos)=md.inversion.vx_obs(pos);
-		md.diagnostic.spcvy(pos)=md.inversion.vy_obs(pos);
-	else
-		disp('      boundary conditions for diagnostic model: spc set as zero');
-	end
+	if ~isnan(md.inversion.vx_obs) and ~isnan(md.inversion.vy_obs):
+		if (len(md.inversion.vx_obs)==md.mesh.numberofvertices) and (len(md.inversion.vy_obs)==md.mesh.numberofvertices):
+			print '      boundary conditions for diagnostic model: spc set as observed velocities'
+			md.diagnostic.spcvx[pos]=md.inversion.vx_obs[pos]
+			md.diagnostic.spcvy[pos]=md.inversion.vy_obs[pos]
+	else:
+		print '      boundary conditions for diagnostic model: spc set as zero'
 
 	#segment on Ice Front
 	#segment on Neumann (Ice Front)
-	pos=find(nodeonicefront(md.mesh.segments(:,1)) | nodeonicefront(md.mesh.segments(:,2)));
-	if (md.mesh.dimension==2)
-		pressureload=md.mesh.segments(pos,:);
-	elseif md.mesh.dimension==3
-		pressureload_layer1=[md.mesh.segments(pos,1:2)  md.mesh.segments(pos,2)+md.mesh.numberofvertices2d  md.mesh.segments(pos,1)+md.mesh.numberofvertices2d  md.mesh.segments(pos,3)];
+	segs1=md.mesh.segments[:,0].astype(int)-1
+	segs2=md.mesh.segments[:,1].astype(int)-1
+
+	pos=argwhere(logical_and(nodeonicefront[segs1].astype(bool),nodeonicefront[segs2].astype(bool)))
+	if (md.mesh.dimension==2):
+		pressureload=md.mesh.segments[pos,:];
+	elif md.mesh.dimension==3:
+		pressureload_layer=[md.mesh.segments[pos,0:2],md.mesh.segments[pos,1]+md.mesh.numberofvertices2d,md.mesh.segments[pos,0]+md.mesh.numberofvertices2d, md.mesh.segments[pos,2]];
 		pressureload=[];
-		for i=1:md.mesh.numberoflayers-1,
-			pressureload=[pressureload ;pressureload_layer1(:,1:4)+(i-1)*md.mesh.numberofvertices2d pressureload_layer1(:,5)+(i-1)*md.mesh.numberofelements2d ];
-		end
-	end
+		for i in range(1,md.mesh.numberoflayers-1):
+			pressureload=[pressureload ,pressureload_layer1[:,1:4]+(i-1)*md.mesh.numberofvertices2d, pressureload_layer1[:,5]+(i-1)*md.mesh.numberofelements2d ];
 
 	#Add water or air enum depending on the element
-	pressureload=[pressureload 1*md.mask.elementonfloatingice(pressureload(:,end))];
+	pressureload=[pressureload, 1*md.mask.elementonfloatingice(pressureload[:,end])];
 
 	#plug onto model
@@ -63,31 +65,27 @@
 
 	#Create zeros basalforcings and surfaceforcings
-	if isnan(md.surfaceforcings.precipitation),
-		md.surfaceforcings.precipitation=zeros(md.mesh.numberofvertices,1);
-		disp('      no surfaceforcings.precipitation specified: values set as zero');
-	end
-	if isnan(md.surfaceforcings.mass_balance),
-		md.surfaceforcings.mass_balance=zeros(md.mesh.numberofvertices,1);
-		disp('      no surfaceforcings.mass_balance specified: values set as zero');
-	end
-	if isnan(md.basalforcings.melting_rate),
-		md.basalforcings.melting_rate=zeros(md.mesh.numberofvertices,1);
-		disp('      no basalforcings.melting_rate specified: values set as zero');
-	end
-	if isnan(md.balancethickness.thickening_rate),
-		md.balancethickness.thickening_rate=zeros(md.mesh.numberofvertices,1);
-		disp('      no balancethickness.thickening_rate specified: values set as zero');
-	end
+	if isnan(md.surfaceforcings.precipitation):
+		md.surfaceforcings.precipitation=zeros(md.mesh.numberofvertices);
+		print '      no surfaceforcings.precipitation specified: values set as zero'
+	if isnan(md.surfaceforcings.mass_balance):
+		md.surfaceforcings.mass_balance=zeros(md.mesh.numberofvertices);
+		print '      no surfaceforcings.mass_balance specified: values set as zero'
+	if isnan(md.basalforcings.melting_rate):
+		md.basalforcings.melting_rate=zeros(md.mesh.numberofvertices)
+		print '      no basalforcings.melting_rate specified: values set as zero'
+	if isnan(md.balancethickness.thickening_rate):
+		md.balancethickness.thickening_rate=zeros(md.mesh.numberofvertices);
+		print '      no balancethickness.thickening_rate specified: values set as zero'
 
-	md.prognostic.spcthickness=NaN*ones(md.mesh.numberofvertices,1);
-	md.balancethickness.spcthickness=NaN*ones(md.mesh.numberofvertices,1);
+	md.prognostic.spcthickness=NaN*ones(md.mesh.numberofvertices);
+	md.balancethickness.spcthickness=NaN*ones(md.mesh.numberofvertices);
 
-	if (length(md.initialization.temperature)==md.mesh.numberofvertices),
-		md.thermal.spctemperature=NaN*ones(md.mesh.numberofvertices,1);
-		pos=find(md.mesh.vertexonsurface); md.thermal.spctemperature(pos)=md.initialization.temperature(pos); #impose observed temperature on surface
-		if (length(md.basalforcings.geothermalflux)~=md.mesh.numberofvertices),
-			md.basalforcings.geothermalflux=zeros(md.mesh.numberofvertices,1);
-		end
-	else
-		disp('      no thermal boundary conditions created: no observed temperature found');
-	end
+	if (len(md.initialization.temperature)==md.mesh.numberofvertices):
+		md.thermal.spctemperature=NaN*ones(md.mesh.numberofvertices);
+		pos=argwhere(md.mesh.vertexonsurface); md.thermal.spctemperature[pos]=md.initialization.temperature[pos]; #impose observed temperature on surface
+		if (len(md.basalforcings.geothermalflux) !=md.mesh.numberofvertices):
+			md.basalforcings.geothermalflux=zeros(md.mesh.numberofvertices);
+	else:
+		print '      no thermal boundary conditions created: no observed temperature found'
+
+	return md
Index: /issm/branches/trunk-jpl-damage/src/modules/Kriging/Kriging.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/modules/Kriging/Kriging.cpp	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/src/modules/Kriging/Kriging.cpp	(revision 12258)
@@ -7,11 +7,13 @@
 
 	/*Outputs*/
-	double *x            = NULL;
-	double *y            = NULL;
-	double *observations = NULL;
-	double *x_interp     = NULL;
-	double *y_interp     = NULL;
-	double *predictions  = NULL;
-	int     n_interp,n,n_obs;
+	double  *x            = NULL;
+	double  *y            = NULL;
+	double  *observations = NULL;
+	double  *x_interp     = NULL;
+	double  *y_interp     = NULL;
+	double  *predictions  = NULL;
+	double  *error        = NULL;
+	Options *options      = NULL;
+	int      N_interp,M_interp,M,N,n_obs;
 
 	/*Boot module: */
@@ -19,18 +21,22 @@
 
 	/*checks on arguments on the matlab side: */
-	CheckNumMatlabArguments(nlhs,NLHS,nrhs,NRHS,__FUNCT__,&KrigingUsage);
+	if (nrhs<NRHS || nlhs>NLHS){
+		KrigingUsage(); _error_("Kriging usage error");
+	}
 
 	/*Fetch inputs: */
 	FetchData(&x,&n_obs,X);
-	FetchData(&y,&n,Y);                       if(n_obs!=n) _error_("x and y should have the same size");
-	FetchData(&observations,&n,OBSERVATIONS); if(n_obs!=n) _error_("x and observations should have the same size");
-	FetchData(&x_interp,&n_interp,XINTERP);
-	FetchData(&y_interp,&n,YINTERP);          if(n_interp!=n) _error_("x_interp and y_interp should have the same size");
+	FetchData(&y,&N,Y);                       if(n_obs!=N) _error_("x and y should have the same size");
+	FetchData(&observations,&N,OBSERVATIONS); if(n_obs!=N) _error_("x and observations should have the same size");
+	FetchData(&x_interp,&M_interp,&N_interp,XINTERP);
+	FetchData(&y_interp,&M,&N,YINTERP);       if(N!=N_interp || M!=M_interp) _error_("x_interp and y_interp should have the same size");
+	FetchData(&options,NRHS,nrhs,prhs);
 
 	/*Call x layer*/
-	Krigingx(&predictions,x,y,observations,n_obs,x_interp,y_interp,n_interp);
+	Krigingx(&predictions,&error,x,y,observations,n_obs,x_interp,y_interp,M_interp*N_interp,options);
 
 	/*Generate output Matlab Structures*/
-	WriteData(PREDICTIONS,predictions,n_interp);
+	if(nlhs>=1) WriteData(PREDICTIONS,predictions,M_interp,N_interp);
+	if(nlhs==2) WriteData(ERROR,error,M_interp,N_interp);
 
 	/*Free ressources: */
@@ -41,4 +47,5 @@
 	xfree((void**)&y_interp);
 	xfree((void**)&predictions);
+	xfree((void**)&error);
 
 	/*end module: */
Index: /issm/branches/trunk-jpl-damage/src/modules/Kriging/Kriging.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/modules/Kriging/Kriging.h	(revision 12257)
+++ /issm/branches/trunk-jpl-damage/src/modules/Kriging/Kriging.h	(revision 12258)
@@ -26,8 +26,9 @@
 /* serial output macros: */
 #define PREDICTIONS (mxArray**)&plhs[0]
+#define ERROR       (mxArray**)&plhs[1]
 
 /* serial arg counts: */
 #undef NLHS
-#define NLHS  1
+#define NLHS  2
 #undef NRHS
 #define NRHS  5
