Index: /issm/branches/trunk-jpl-damage/configs/config-macosx64-larour-ad.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/configs/config-macosx64-larour-ad.sh	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/configs/config-macosx64-larour-ad.sh	(revision 11708)
@@ -8,15 +8,8 @@
 	--prefix=$ISSM_TIER \
 	--with-metis-dir=$ISSM_TIER/externalpackages/metis/install \
-	--with-petsc-dir=$ISSM_TIER/externalpackages/petsc/install  \
 	--with-mpi-include=$ISSM_TIER/externalpackages/mpich2/install/include  \
 	--with-mpi-lib=" $ISSM_TIER/externalpackages/mpich2/install/lib/libpmpich.a $ISSM_TIER/externalpackages/mpich2/install/lib/libmpich.a $ISSM_TIER/externalpackages/mpich2/install/lib/libmpl.a " \
-	--with-petsc-arch=$ISSM_ARCH \
-	--with-blas-lapack-dir=$ISSM_TIER/externalpackages/petsc/install \
+	--without-blas-lapack-dir \
 	--with-chaco-dir=$ISSM_TIER/externalpackages/chaco/install \
-	--with-plapack-lib="-L$ISSM_TIER/externalpackages/petsc/install/ -lPLAPACK" \
-	--with-plapack-include="-I$ISSM_TIER/externalpackages/petsc/install/include/ " \
-	--with-blacs-dir=$ISSM_TIER/externalpackages/petsc/install/ \
-	--with-scalapack-dir=$ISSM_TIER/externalpackages/petsc/install/ \
-	--with-mumps-dir=$ISSM_TIER/externalpackages/petsc/install/ \
 	--with-fortran-lib="/usr/local/lib/libgfortran.a" \
 	--with-dakota-dir=$ISSM_TIER/externalpackages/dakota/install \
@@ -41,4 +34,10 @@
  
 #--without-prognostic \
-
- 
+#--with-petsc-dir=$ISSM_TIER/externalpackages/petsc/install  \
+#--with-petsc-arch=$ISSM_ARCH \
+#--with-blas-lapack-dir=$ISSM_TIER/externalpackages/petsc/install \
+#--with-plapack-lib="-L$ISSM_TIER/externalpackages/petsc/install/ -lPLAPACK" \
+#--with-plapack-include="-I$ISSM_TIER/externalpackages/petsc/install/include/ " \
+#--with-blacs-dir=$ISSM_TIER/externalpackages/petsc/install/ \
+#--with-scalapack-dir=$ISSM_TIER/externalpackages/petsc/install/ \
+#--with-mumps-dir=$ISSM_TIER/externalpackages/petsc/install/ \
Index: /issm/branches/trunk-jpl-damage/configs/config-macosx64-larour.sh
===================================================================
--- /issm/branches/trunk-jpl-damage/configs/config-macosx64-larour.sh	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/configs/config-macosx64-larour.sh	(revision 11708)
@@ -9,15 +9,7 @@
 	--with-triangle-dir=$ISSM_TIER/externalpackages/triangle/install \
 	--with-metis-dir=$ISSM_TIER/externalpackages/metis/install \
-	--with-petsc-dir=$ISSM_TIER/externalpackages/petsc/install  \
 	--with-mpi-include=$ISSM_TIER/externalpackages/mpich2/install/include  \
 	--with-mpi-lib=" $ISSM_TIER/externalpackages/mpich2/install/lib/libpmpich.a $ISSM_TIER/externalpackages/mpich2/install/lib/libmpich.a $ISSM_TIER/externalpackages/mpich2/install/lib/libmpl.a " \
-	--with-petsc-arch=$ISSM_ARCH \
-	--with-blas-lapack-dir=$ISSM_TIER/externalpackages/petsc/install \
 	--with-chaco-dir=$ISSM_TIER/externalpackages/chaco/install \
-	--with-plapack-lib="-L$ISSM_TIER/externalpackages/petsc/install/ -lPLAPACK" \
-	--with-plapack-include="-I$ISSM_TIER/externalpackages/petsc/install/include/ " \
-	--with-blacs-dir=$ISSM_TIER/externalpackages/petsc/install/ \
-	--with-scalapack-dir=$ISSM_TIER/externalpackages/petsc/install/ \
-	--with-mumps-dir=$ISSM_TIER/externalpackages/petsc/install/ \
 	--with-fortran-lib="/usr/local/lib/libgfortran.a" \
 	--with-dakota-dir=$ISSM_TIER/externalpackages/dakota/install \
@@ -25,3 +17,11 @@
 	--with-graphics-lib="/usr/X11/lib/libX11.dylib" \
 	--with-cxxoptflags=" -fno-common -no-cpp-precomp -fexceptions -arch x86_64 -mmacosx-version-min=10.5  -O3 -DNDEBUG -w "\
-	--with-numthreads=8
+	--with-numthreads=8 \
+	--with-petsc-dir=$ISSM_TIER/externalpackages/petsc/install  \
+	--with-petsc-arch=$ISSM_ARCH \
+	--with-blas-lapack-dir=$ISSM_TIER/externalpackages/petsc/install \
+	--with-plapack-lib="-L$ISSM_TIER/externalpackages/petsc/install/ -lPLAPACK" \
+	--with-plapack-include="-I$ISSM_TIER/externalpackages/petsc/install/include/ " \
+	--with-blacs-dir=$ISSM_TIER/externalpackages/petsc/install/ \
+	--with-scalapack-dir=$ISSM_TIER/externalpackages/petsc/install/ \
+	--with-mumps-dir=$ISSM_TIER/externalpackages/petsc/install/ 
Index: /issm/branches/trunk-jpl-damage/cron/configs/macosx64_larour_validation
===================================================================
--- /issm/branches/trunk-jpl-damage/cron/configs/macosx64_larour_validation	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/cron/configs/macosx64_larour_validation	(revision 11708)
@@ -94,5 +94,5 @@
 #ex: "'id',[101 102 103]"
 
-NROPTIONS="'id',101:151"
+NROPTIONS="'id',[101:136 138:151]"
 
 #------------------------#
Index: /issm/branches/trunk-jpl-damage/m4/issm_options.m4
===================================================================
--- /issm/branches/trunk-jpl-damage/m4/issm_options.m4	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/m4/issm_options.m4	(revision 11708)
@@ -19,4 +19,5 @@
 	AC_MSG_CHECKING(for serial compilation)
 	AM_CONDITIONAL([NOSERIAL], [test $SERIAL_VALUE = no])
+	AM_CONDITIONAL([SERIAL], [test $SERIAL_VALUE = yes])
 	AC_MSG_RESULT($SERIAL_VALUE) 
 	dnl }}}
@@ -28,4 +29,5 @@
 	AC_MSG_CHECKING(for parallel compilation)
 	AM_CONDITIONAL([NOPARALLEL], [test $PARALLEL_VALUE = no])
+	AM_CONDITIONAL([PARALLEL], [test $PARALLEL_VALUE = yes])
 	AC_MSG_RESULT($PARALLEL_VALUE) 
 	ISSMEXT=".exe"
@@ -505,12 +507,13 @@
 							 [petsc root directory, necessary for parallel build]),
 			  [PETSC_ROOT=$withval],[PETSC_ROOT=""])
-
-	if test "$PARALLEL_VALUE" = "yes" ; then
-		if test "$PETSC_ROOT" = "" ; then
-			AC_MSG_ERROR([missing --with-petsc-dir argument for parallel compilation!])
-		fi
-	fi
-
-	dnl if test "$PARALLEL_VALUE" = "yes" ; then 
+		
+	dnl Used to be necessary, not anymore. 
+	dnl if test "$PARALLEL_VALUE" = "yes" ; then
+		dnl if test "$PETSC_ROOT" = "" ; then
+			dnl AC_MSG_ERROR([missing --with-petsc-dir argument for parallel compilation!])
+		dnl fi
+	dnl fi
+
+	if test -d "$PETSC_ROOT"; then
 		AC_MSG_CHECKING(for petsc version)
 		PETSC_MAJOR=`cat $PETSC_ROOT/include/petscversion.h | grep "#define PETSC_VERSION_MAJOR" | sed 's/#define PETSC_VERSION_MAJOR//' | sed 's/ //g'`
@@ -519,7 +522,6 @@
 		AC_DEFINE_UNQUOTED([_PETSC_MINOR_],$PETSC_MINOR,[ Petsc version minor])
 		AC_MSG_RESULT($PETSC_MAJOR.$PETSC_MINOR)
-	dnl fi
-	
-		
+	fi
+	
 	AC_ARG_WITH([petsc-arch],
 			  AS_HELP_STRING([--with-petsc-arch = DIR],
@@ -527,9 +529,10 @@
 			  [PETSC_ARCH=$withval],[PETSC_ARCH=""])
 
-	if test "$PARALLEL_VALUE" = "yes" ; then
-		if test "$PETSC_ARCH" = "" ; then
-			AC_MSG_ERROR([missing --with-petsc-arch argument for parallel compilation!])
-		fi
-	fi
+	dnl Used to be necessary, not anymore. 
+	dnl if test "$PARALLEL_VALUE" = "yes" ; then
+		dnl if test "$PETSC_ARCH" = "" ; then
+			dnl AC_MSG_ERROR([missing --with-petsc-arch argument for parallel compilation!])
+		dnl fi
+	dnl fi
 	
 	AC_MSG_CHECKING(for Petsc headers and libraries in $PETSC_ROOT for architecture $PETSC_ARCH)
@@ -573,9 +576,13 @@
 	fi
 
-	if test $HAVE_PETSC = no; then
-		AC_MSG_ERROR([could not find petsc. user should specify --with-petsc-dir and --with-petsc-arch options. Petsc is needed to run ISSM!])
-	else
-		AC_MSG_RESULT($HAVE_PETSC)
-	fi
+	dnl used to e necessary, not anymore. 
+	dnl if test $HAVE_PETSC = no; then
+		dnl AC_MSG_ERROR([could not find petsc. user should specify --with-petsc-dir and --with-petsc-arch options. Petsc is needed to run ISSM!])
+	dnl else
+	dnl AC_MSG_RESULT($HAVE_PETSC)
+	dnl fi
+	
+	AM_CONDITIONAL([PETSC], [test x$HAVE_PETSC = xyes])
+	AC_MSG_RESULT($HAVE_PETSC)
 	dnl }}}
 	dnl tao{{{1
Index: /issm/branches/trunk-jpl-damage/src/c/Container/Elements.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/Container/Elements.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/Container/Elements.cpp	(revision 11708)
@@ -175,5 +175,5 @@
 	double *resultstimes = NULL;
 	double *vector_serial= NULL;
-	Vec     vector       = NULL;
+	Vector*     vector       = NULL;
 	bool   io_gather;
 	bool   results_as_patches;
@@ -225,5 +225,5 @@
 			else if(resultssizes[i]==P0Enum) vectorsize=numberofelements;
 			else _error_("Unkown result size: %s",EnumToStringx(resultssizes[i]));
-			vector=NewVec(vectorsize);
+			vector=new Vector(vectorsize);
 
 			for(int j=0;j<this->Size();j++){
@@ -231,9 +231,8 @@
 				element->GetVectorFromResults(vector,i,resultssizes[i]);
 			}
-			VecAssemblyBegin(vector);
-			VecAssemblyEnd(vector);
+			vector->Assemble();
 
 			/*Serialize and add to results*/
-			VecToMPISerial(&vector_serial,vector);
+			vector_serial=vector->ToMPISerial();
 			if(my_rank==0){
 				/*No need to add this vector for all cpus*/
@@ -242,5 +241,5 @@
 
 			/*clean up*/
-			VecFree(&vector);
+			xdelete(&vector);
 			xfree((void**)&vector_serial);
 		}
Index: /issm/branches/trunk-jpl-damage/src/c/Container/Parameters.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/Container/Parameters.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/Container/Parameters.cpp	(revision 11708)
@@ -227,6 +227,6 @@
 }
 /*}}}*/
-/*FUNCTION Parameters::FindParam(Vec* pvec,int enum_type){{{1*/
-void Parameters::FindParam(Vec* pvec,int enum_type){ _assert_(this);
+/*FUNCTION Parameters::FindParam(Vector** pvec,int enum_type){{{1*/
+void Parameters::FindParam(Vector** pvec,int enum_type){ _assert_(this);
 	
 	vector<Object*>::iterator object;
@@ -245,6 +245,6 @@
 }
 /*}}}*/
-/*FUNCTION Parameters::FindParam(Mat* pmat,int enum_type){{{1*/
-void Parameters::FindParam(Mat* pmat,int enum_type){ _assert_(this);
+/*FUNCTION Parameters::FindParam(Matrix** pmat,int enum_type){{{1*/
+void Parameters::FindParam(Matrix** pmat,int enum_type){ _assert_(this);
 	
 	vector<Object*>::iterator object;
@@ -389,6 +389,6 @@
 }
 /*}}}*/
-/*FUNCTION Parameters::SetParam(Vec vector,int enum_type);{{{1*/
-void   Parameters::SetParam(Vec vector,int enum_type){
+/*FUNCTION Parameters::SetParam(Vector* vector,int enum_type);{{{1*/
+void   Parameters::SetParam(Vector* vector,int enum_type){
 
 	Param* param=NULL;
@@ -398,9 +398,9 @@
 
 	if(param) param->SetValue(vector); //already exists, just set it.
-	else this->AddObject(new PetscVecParam(enum_type,vector)); //just add the new parameter.
-}
-/*}}}*/
-/*FUNCTION Parameters::SetParam(Mat matrix,int enum_type);{{{1*/
-void   Parameters::SetParam(Mat matrix,int enum_type){
+	else this->AddObject(new VectorParam(enum_type,vector)); //just add the new parameter.
+}
+/*}}}*/
+/*FUNCTION Parameters::SetParam(Matrix* matrix,int enum_type);{{{1*/
+void   Parameters::SetParam(Matrix* matrix,int enum_type){
 
 	Param* param=NULL;
@@ -410,5 +410,5 @@
 
 	if(param) param->SetValue(matrix); //already exists, just set it.
-	else this->AddObject(new PetscMatParam(enum_type,matrix)); //just add the new parameter.
+	else this->AddObject(new MatrixParam(enum_type,matrix)); //just add the new parameter.
 }
 /*}}}*/
Index: /issm/branches/trunk-jpl-damage/src/c/Container/Parameters.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/Container/Parameters.h	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/Container/Parameters.h	(revision 11708)
@@ -7,4 +7,6 @@
 
 /*forward declarations */
+class Matrix;
+class Vector;
 class Materials;
 class Parameters;
@@ -37,6 +39,6 @@
 		void  FindParam(double** pdoublearray,int* pM,int* pN,int enum_type);
 		void  FindParam(double*** parray,int* pM, int** pmdims_array,int** pndims_array,int enum_type);
-		void  FindParam(Vec* pvec,int enum_type);
-		void  FindParam(Mat* pmat,int enum_type);
+		void  FindParam(Vector** pvec,int enum_type);
+		void  FindParam(Matrix** pmat,int enum_type);
 		void  FindParam(FILE** pfid,int enum_type);
 		
@@ -50,6 +52,6 @@
 		void  SetParam(int* intarray,int M,int enum_type);
 		void  SetParam(int* intarray,int M,int N,int enum_type);
-		void  SetParam(Vec vec,int enum_type);
-		void  SetParam(Mat mat,int enum_type);
+		void  SetParam(Vector* vec,int enum_type);
+		void  SetParam(Matrix* mat,int enum_type);
 		void  SetParam(FILE* fid,int enum_type);
 		void  UnitConversion(int direction_enum);
Index: /issm/branches/trunk-jpl-damage/src/c/EnumDefinitions/EnumDefinitions.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/EnumDefinitions/EnumDefinitions.h	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/EnumDefinitions/EnumDefinitions.h	(revision 11708)
@@ -266,6 +266,6 @@
 	PentaEnum,
 	PentaP1InputEnum,
-	PetscMatParamEnum,
-	PetscVecParamEnum,
+	MatrixParamEnum,
+	VectorParamEnum,
 	RiftfrontEnum,
 	SegmentEnum,
Index: /issm/branches/trunk-jpl-damage/src/c/Makefile.am
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/Makefile.am	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/Makefile.am	(revision 11708)
@@ -79,6 +79,4 @@
 					./objects/ExternalResults/StringExternalResult.h\
 					./objects/ExternalResults/StringExternalResult.cpp\
-					./objects/ExternalResults/PetscVecExternalResult.h\
-					./objects/ExternalResults/PetscVecExternalResult.cpp\
 					./objects/Elements/Tria.h\
 					./objects/Elements/Tria.cpp\
@@ -137,6 +135,4 @@
 					./objects/Params/FileParam.cpp\
 					./objects/Params/FileParam.h\
-					./objects/Params/PetscMatParam.cpp\
-					./objects/Params/PetscMatParam.h\
 					./objects/Params/StringArrayParam.cpp\
 					./objects/Params/StringArrayParam.h\
@@ -149,8 +145,10 @@
 					./objects/Params/DoubleVecParam.cpp\
 					./objects/Params/DoubleVecParam.h\
-					./objects/Params/PetscVecParam.cpp\
-					./objects/Params/PetscVecParam.h\
 					./objects/Params/StringParam.cpp\
 					./objects/Params/StringParam.h\
+					./objects/Params/MatrixParam.h\
+					./objects/Params/MatrixParam.cpp\
+					./objects/Params/VectorParam.h\
+					./objects/Params/VectorParam.cpp\
 					./Container/Container.h\
 					./Container/Constraints.h\
@@ -195,5 +193,5 @@
 					./shared/Numerics/XZvectorsToCoordinateSystem.cpp\
 					./shared/Numerics/UnitConversion.cpp\
-					./shared/Numerics/PetscOptionsFromAnalysis.cpp\
+					./shared/Numerics/OptionsFromAnalysis.cpp\
 					./shared/Exceptions/exceptions.h\
 					./shared/Exceptions/Exceptions.cpp\
@@ -209,37 +207,7 @@
 					./shared/Elements/GetNumberOfDofs.cpp\
 					./shared/String/sharedstring.h\
-					./toolkits/petsc\
-					./toolkits/petsc/patches\
-					./toolkits/petsc/patches/SolverEnum.h\
-					./toolkits/petsc/patches/petscpatches.h\
-					./toolkits/petsc/patches/MatlabMatrixToPetscMatrix.cpp\
-					./toolkits/petsc/patches/MatlabVectorToPetscVector.cpp\
-					./toolkits/petsc/patches/PetscMatrixToMatlabMatrix.cpp\
-					./toolkits/petsc/patches/PetscVectorToMatlabVector.cpp\
-					./toolkits/petsc/patches/MatlabMatrixToDoubleMatrix.cpp\
-					./toolkits/petsc/patches/MatlabVectorToDoubleVector.cpp\
-					./toolkits/petsc/patches/PetscDetermineLocalSize.cpp\
-					./toolkits/petsc/patches/VecTranspose.cpp\
-					./toolkits/petsc/patches/VecToMPISerial.cpp\
-					./toolkits/petsc/patches/MatToSerial.cpp\
-					./toolkits/petsc/patches/VecMerge.cpp\
-					./toolkits/petsc/patches/NewVec.cpp\
-					./toolkits/petsc/patches/PetscOptionsDetermineSolverType.cpp\
-					./toolkits/petsc/patches/PetscOptionsInsertMultipleString.cpp\
-					./toolkits/petsc/patches/NewMat.cpp\
-					./toolkits/petsc/patches/SerialToVec.cpp\
-					./toolkits/petsc/patches/VecFree.cpp\
-					./toolkits/petsc/patches/VecDuplicatePatch.cpp\
-					./toolkits/petsc/patches/KSPFree.cpp\
-					./toolkits/petsc/patches/ISFree.cpp\
-					./toolkits/petsc/patches/MatFree.cpp\
-					./toolkits/petsc/patches/GetOwnershipBoundariesFromRange.cpp\
-					./toolkits/petsc/patches/VecPartition.cpp\
-					./toolkits/petsc/patches/MatPartition.cpp\
-					./toolkits/petsc/patches/MatInvert.cpp\
-					./toolkits/petsc/patches/MatMultPatch.cpp\
-					./toolkits/petsc/petscincludes.h\
 					./toolkits/mpi/mpiincludes.h\
 					./toolkits/mpi/patches/mpipatches.h\
+					./toolkits/mpi/patches/DetermineLocalSize.cpp\
 					./toolkits/mpi/patches/MPI_Upperrow.cpp\
 					./toolkits/mpi/patches/MPI_Lowerrow.cpp\
@@ -249,4 +217,5 @@
 					./toolkits/metis/patches/METIS_PartMeshNodalPatch.cpp\
 					./toolkits/triangle/triangleincludes.h\
+					./toolkitsenums.h\
 					./toolkits.h\
 					./io/io.h\
@@ -268,6 +237,4 @@
 					./modules/ModelProcessorx/CreateNumberNodeToElementConnectivity.cpp\
 					./modules/ModelProcessorx/CreateElementsVerticesAndMaterials.cpp\
-					./modules/ParsePetscOptionsx/ParsePetscOptionsx.h\
-					./modules/ParsePetscOptionsx/ParsePetscOptionsx.cpp\
 					./modules/NodesDofx/NodesDofx.h\
 					./modules/NodesDofx/NodesDofx.cpp\
@@ -344,7 +311,5 @@
 					./modules/ResetCoordinateSystemx/ResetCoordinateSystemx.cpp\
 					./modules/Solverx/Solverx.cpp\
-					./modules/Solverx/SolverxPetsc.cpp\
 					./modules/Solverx/Solverx.h\
-					./modules/Solverx/DofTypesToIndexSet.cpp\
 					./modules/VecMergex/VecMergex.cpp\
 					./modules/VecMergex/VecMergex.h\
@@ -731,8 +696,49 @@
 				    ./toolkits/matlab/MatlabMatrixToMatrix.cpp\
 				    ./toolkits/matlab/MatlabVectorToVector.cpp\
+				    ./toolkits/double/MatlabVectorToDoubleVector.cpp\
+				    ./toolkits/double/double.h\
+				    ./toolkits/double/MatlabMatrixToDoubleMatrix.cpp\
 				    ./io/Matlab/matlabio.h\
 				    ./io/Matlab/WriteMatlabData.cpp\
 				    ./io/Matlab/FetchMatlabData.cpp\
 				    ./io/Matlab/OptionParse.cpp
+#}}}
+#Petsc sources  {{{1
+petsc_sources= ./toolkits/petsc\
+					./toolkits/petsc/patches\
+					./toolkits/petsc/patches/SolverEnum.h\
+					./toolkits/petsc/patches/petscpatches.h\
+					./toolkits/petsc/patches/MatlabMatrixToPetscMatrix.cpp\
+					./toolkits/petsc/patches/MatlabVectorToPetscVector.cpp\
+					./toolkits/petsc/patches/PetscMatrixToMatlabMatrix.cpp\
+					./toolkits/petsc/patches/PetscVectorToMatlabVector.cpp\
+					./toolkits/petsc/patches/VecTranspose.cpp\
+					./toolkits/petsc/patches/VecToMPISerial.cpp\
+					./toolkits/petsc/patches/MatToSerial.cpp\
+					./toolkits/petsc/patches/VecMerge.cpp\
+					./toolkits/petsc/patches/NewVec.cpp\
+					./toolkits/petsc/patches/PetscOptionsDetermineSolverType.cpp\
+					./toolkits/petsc/patches/PetscOptionsInsertMultipleString.cpp\
+					./toolkits/petsc/patches/NewMat.cpp\
+					./toolkits/petsc/patches/SerialToVec.cpp\
+					./toolkits/petsc/patches/VecFree.cpp\
+					./toolkits/petsc/patches/VecDuplicatePatch.cpp\
+					./toolkits/petsc/patches/KSPFree.cpp\
+					./toolkits/petsc/patches/ISFree.cpp\
+					./toolkits/petsc/patches/MatFree.cpp\
+					./toolkits/petsc/patches/GetOwnershipBoundariesFromRange.cpp\
+					./toolkits/petsc/patches/VecPartition.cpp\
+					./toolkits/petsc/patches/MatPartition.cpp\
+					./toolkits/petsc/patches/MatInvert.cpp\
+					./toolkits/petsc/patches/MatMultPatch.cpp\
+					./toolkits/petsc/patches/ISSMToPetscInsertMode.cpp\
+					./toolkits/petsc/patches/ISSMToPetscNormMode.cpp\
+					./toolkits/petsc/petscincludes.h\
+					./shared/Numerics/PetscOptionsFromAnalysis.cpp\
+					./modules/ParsePetscOptionsx/ParsePetscOptionsx.h\
+					./modules/ParsePetscOptionsx/ParsePetscOptionsx.cpp\
+					./modules/Solverx/SolverxPetsc.cpp\
+					./modules/Solverx/DofTypesToIndexSet.cpp
+
 #}}}
 #Serialsources  {{{1
@@ -835,4 +841,9 @@
 endif
 
+if PETSC
+issm_sources  +=  $(petsc_sources)
+issm_psources +=  $(petsc_psources)
+endif
+
 if TRANSIENT
 issm_sources  +=  $(transient_sources)
@@ -898,4 +909,5 @@
 
 #ISSM serial library {{{1
+if SERIAL
 libISSM_a_SOURCES  = $(issm_sources)
 libISSM_a_SOURCES += $(serial_sources)
@@ -910,9 +922,12 @@
 libISSM_a_CXXFLAGS += -DMX_COMPAT_32 
 endif
+endif
 #}}}
 #ISSM parallel library {{{1
+if PARALLEL
 libpISSM_a_SOURCES  = $(issm_sources)
 libpISSM_a_SOURCES += $(issm_psources)
 libpISSM_a_CXXFLAGS = -fPIC -D_PARALLEL_   -D_C_ $(CXXFLAGS) $(CXXOPTFLAGS) 
+endif
 #}}}
 #Overload library, to overload any non-standard symbols. {{{1
Index: /issm/branches/trunk-jpl-damage/src/c/io/Matlab/FetchMatlabData.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/io/Matlab/FetchMatlabData.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/io/Matlab/FetchMatlabData.cpp	(revision 11708)
@@ -276,31 +276,4 @@
 }
 /*}}}*/
-/*FUNCTION FetchMatlabData(Mat* pmatrix,const mxArray* dataref){{{1*/
-void FetchMatlabData(Mat* pmatrix,const mxArray* dataref){
-	
-	Mat outmatrix=NULL;
-	int dummy=0;
-
-	if (mxIsClass(dataref,"double") ){
-
-		/*Check dataref is not pointing to NaN: */
-		if ( mxIsNaN(*(mxGetPr(dataref))) && (mxGetM(dataref)==1) && (mxGetN(dataref)==1) ){
-			outmatrix=NULL;
-		}
-		else{
-
-			/*Convert matlab matrix to petsc matrix: */
-			MatlabMatrixToPetscMatrix(&outmatrix,&dummy,&dummy,dataref);
-		}
-	}
-	else{
-		/*This is an error: we don't have the correct input!: */
-		_error_("Input parameter of class %s not supported yet",mxGetClassName(dataref));
-	}
-
-	/*Assign output pointers:*/
-	*pmatrix=outmatrix;
-}
-/*}}}*/
 /*FUNCTION FetchMatlabData(Matrix** pmatrix,const mxArray* dataref){{{1*/
 void FetchMatlabData(Matrix** pmatrix,const mxArray* dataref){
@@ -451,28 +424,4 @@
 	*pvector=outvector;
 	if (pM)*pM=outvector_rows;
-}
-/*}}}*/
-/*FUNCTION FetchMatlabData(Vec* pvector,const mxArray* dataref){{{1*/
-void FetchMatlabData(Vec* pvector,const mxArray* dataref){
-
-	Vec vector=NULL;
-	int dummy;
-
-	if(mxIsEmpty(dataref)){
-		/*Nothing to pick up. Just initialize matrix pointer to NULL: */
-		vector=NULL;
-	}
-	else if (mxIsClass(dataref,"double") ){
-
-		/*Convert matlab vector to petsc vector: */
-		MatlabVectorToPetscVector(&vector,&dummy,dataref);
-	}
-	else{
-		/*This is an error: we don't have the correct input!: */
-		_error_("Input parameter of class %s not supported yet",mxGetClassName(dataref));
-	}
-
-	/*Assign output pointers:*/
-	*pvector=vector;
 }
 /*}}}*/
Index: /issm/branches/trunk-jpl-damage/src/c/io/Matlab/WriteMatlabData.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/io/Matlab/WriteMatlabData.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/io/Matlab/WriteMatlabData.cpp	(revision 11708)
@@ -41,21 +41,4 @@
 }
 /*}}}*/
-/*FUNCTION WriteMatlabData(mxArray** pdataref,Mat matrix){{{1*/
-void WriteMatlabData(mxArray** pdataref,Mat matrix){
-		
-	mxArray* dataref=NULL;
-	
-	if(matrix){
-		
-		/*call toolkit routine: */
-		PetscMatrixToMatlabMatrix(&dataref,matrix);
-	}
-	else{
-		dataref = mxCreateDoubleMatrix(0,0,mxREAL);
-	}
-
-	*pdataref=dataref;
-}
-/*}}}*/
 /*FUNCTION WriteMatlabData(mxArray** pdataref,Matrix* matrix){{{1*/
 void WriteMatlabData(mxArray** pdataref,Matrix* matrix){
@@ -123,21 +106,4 @@
 	}
 	*pdataref=dataref;
-}
-/*}}}*/
-/*FUNCTION WriteMatlabData(mxArray** pdataref,Vec vector){{{1*/
-void WriteMatlabData(mxArray** pdataref,Vec vector){
-	
-	mxArray* dataref=NULL;
-	
-	if(vector){
-		
-		/*call toolkit routine: */
-		PetscVectorToMatlabVector(&dataref,vector);
-	}
-	else{
-		dataref = mxCreateDoubleMatrix(0,0,mxREAL);
-	}
-	*pdataref=dataref;
-
 }
 /*}}}*/
Index: /issm/branches/trunk-jpl-damage/src/c/io/Matlab/matlabio.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/io/Matlab/matlabio.h	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/io/Matlab/matlabio.h	(revision 11708)
@@ -16,9 +16,7 @@
 #include <mex.h>
 void WriteMatlabData(mxArray** pdataref,DataSet* dataset);
-void WriteMatlabData(mxArray** pdataref,Mat matrix);
 void WriteMatlabData(mxArray** pdataref,Matrix* matrix);
 void WriteMatlabData(mxArray** pdataref,double* matrix, int M,int N);
 void WriteMatlabData(mxArray** pdataref,int*    matrix, int M,int N);
-void WriteMatlabData(mxArray** pdataref,Vec vector);
 void WriteMatlabData(mxArray** pdataref,Vector* vector);
 void WriteMatlabData(mxArray** pdataref,double* vector, int M);
@@ -35,5 +33,4 @@
 void FetchMatlabData(bool** pmatrix,int* pM,int *pN,const mxArray* dataref);
 void FetchMatlabData(bool** pmatrix,int* pnumel,int* pndims,int** psize,const mxArray* dataref);
-void FetchMatlabData(Mat* pmatrix,const mxArray* dataref);
 void FetchMatlabData(Matrix** pmatrix,const mxArray* dataref);
 void FetchMatlabData(int** pvector,int* pM,const mxArray* dataref);
@@ -41,5 +38,4 @@
 void FetchMatlabData(double** pvector,int* pM,const mxArray* dataref);
 void FetchMatlabData(bool** pvector,int* pM,const mxArray* dataref);
-void FetchMatlabData(Vec* pvector,const mxArray* dataref);
 void FetchMatlabData(Vector** pvector,const mxArray* dataref);
 void FetchMatlabData(char** pstring,const mxArray* dataref);
Index: /issm/branches/trunk-jpl-damage/src/c/modules/AverageOntoPartitionx/AverageOntoPartitionx.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/AverageOntoPartitionx/AverageOntoPartitionx.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/AverageOntoPartitionx/AverageOntoPartitionx.cpp	(revision 11708)
@@ -29,7 +29,7 @@
 
 	/*output: */
-	Vec partition_contributions=NULL;
-	Vec partition_areas=NULL;
-	Vec vec_average=NULL;
+	Vector* partition_contributions=NULL;
+	Vector* partition_areas=NULL;
+	Vector* vec_average=NULL;
 	double* average=NULL;
 
@@ -44,7 +44,7 @@
 
 	/*allocate: */
-	partition_contributions=NewVec(npart);
-	partition_areas=NewVec(npart);
-	vec_average=NewVec(npart);
+	partition_contributions=new Vector(npart);
+	partition_areas=new Vector(npart);
+	vec_average=new Vector(npart);
 
 	/*loop on each element, and add contribution of the element to the partition (surface weighted average): */
@@ -55,21 +55,18 @@
 
 	/*Assemble: */
-	VecAssemblyBegin(partition_contributions);
-	VecAssemblyEnd(partition_contributions);
-
-	VecAssemblyBegin(partition_areas);
-	VecAssemblyEnd(partition_areas);
+	partition_contributions->Assemble();
+	partition_areas->Assemble();
 
 	/*We have the partition_areas and the partition_contributions for each partition -> compute the surfae weighted average: */
-	VecPointwiseDivide(vec_average,partition_contributions,partition_areas);
+	vec_average->PointwiseDivide(partition_contributions,partition_areas);
 
 	/*serialize:*/
-	VecToMPISerial(&average,vec_average);
+	average=vec_average->ToMPISerial();
 
 	/*Free ressources:*/
 	xfree((void**)&qmu_part);
-	VecFree(&partition_contributions);
-	VecFree(&partition_areas);
-	VecFree(&vec_average);
+	xdelete(&partition_contributions);
+	xdelete(&partition_areas);
+	xdelete(&vec_average);
 
 	/*Assign output pointers:*/
Index: /issm/branches/trunk-jpl-damage/src/c/modules/ComputeBasalStressx/ComputeBasalStressx.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/ComputeBasalStressx/ComputeBasalStressx.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/ComputeBasalStressx/ComputeBasalStressx.cpp	(revision 11708)
@@ -10,5 +10,5 @@
 #include "../../EnumDefinitions/EnumDefinitions.h"
 
-void	ComputeBasalStressx( Vec* psigma,Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,Parameters* parameters){
+void	ComputeBasalStressx( Vector** psigma,Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,Parameters* parameters){
 
 	/*Intermediary*/
@@ -19,5 +19,5 @@
 
 	/*output: */
-	Vec sigma=NULL;
+	Vector* sigma=NULL;
 
 	/*Recover numberofelements: */
@@ -25,5 +25,5 @@
 
 	/*Allocate sigma on numberofelements: */
-	sigma=NewVec((int)numberofelements);
+	sigma=new Vector((int)numberofelements);
 
 	/*Compute basal stress for each element: */
@@ -34,6 +34,5 @@
 
 	/*Assemble vector: */
-	VecAssemblyBegin(sigma);
-	VecAssemblyEnd(sigma);
+	sigma->Assemble();
 
 	/*Assign output pointers: */
Index: /issm/branches/trunk-jpl-damage/src/c/modules/ComputeBasalStressx/ComputeBasalStressx.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/ComputeBasalStressx/ComputeBasalStressx.h	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/ComputeBasalStressx/ComputeBasalStressx.h	(revision 11708)
@@ -10,5 +10,5 @@
 
 /* local prototypes: */
-void	ComputeBasalStressx( Vec* pp_g,Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters);
+void	ComputeBasalStressx( Vector** pp_g,Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters);
 
 #endif  /* _COMPUTEBASALSTRESSX_H */
Index: /issm/branches/trunk-jpl-damage/src/c/modules/ComputeStrainRatex/ComputeStrainRatex.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/ComputeStrainRatex/ComputeStrainRatex.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/ComputeStrainRatex/ComputeStrainRatex.cpp	(revision 11708)
@@ -10,5 +10,5 @@
 #include "../../EnumDefinitions/EnumDefinitions.h"
 
-void	ComputeStrainRatex( Vec* peps,Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,Parameters* parameters){
+void	ComputeStrainRatex( Vector** peps,Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,Parameters* parameters){
 
 	/*Intermediary*/
@@ -19,5 +19,5 @@
 
 	/*output: */
-	Vec eps=NULL;
+	Vector* eps=NULL;
 
 	/*Recover numberofelements: */
@@ -25,5 +25,5 @@
 
 	/*Allocate eps on numberofelements (only 1 dof): */
-	eps=NewVec(numberofelements);
+	eps=new Vector(numberofelements);
 
 	/*Compute basal stress for each element: */
@@ -34,6 +34,5 @@
 
 	/*Assemble vector: */
-	VecAssemblyBegin(eps);
-	VecAssemblyEnd(eps);
+	eps->Assemble();
 
 	/*Assign output pointers: */
Index: /issm/branches/trunk-jpl-damage/src/c/modules/ComputeStrainRatex/ComputeStrainRatex.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/ComputeStrainRatex/ComputeStrainRatex.h	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/ComputeStrainRatex/ComputeStrainRatex.h	(revision 11708)
@@ -10,5 +10,5 @@
 
 /* local prototypes: */
-void	ComputeStrainRatex(Vec* eps_g,Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters);
+void	ComputeStrainRatex(Vector** eps_g,Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters);
 
 #endif  /* _COMPUTESTRAINRATEX_H */
Index: /issm/branches/trunk-jpl-damage/src/c/modules/ContourToMeshx/ContourToMeshx.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/ContourToMeshx/ContourToMeshx.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/ContourToMeshx/ContourToMeshx.cpp	(revision 11708)
@@ -11,5 +11,5 @@
 #include "./ContourToMeshx.h"
 
-int ContourToMeshx( Vec* pin_nod,Vec* pin_elem, double* index, double* x, double* y,Contour** contours,int numcontours,char* interptype,int nel,int nods, int edgevalue) {
+int ContourToMeshx( Vector** pin_nod,Vector** pin_elem, double* index, double* x, double* y,Contour** contours,int numcontours,char* interptype,int nel,int nods, int edgevalue) {
 
 	int noerr=1;
@@ -30,9 +30,9 @@
 
 	/*output: */
-	Vec in_nod=NULL;
-	Vec in_elem=NULL;
+	Vector* in_nod=NULL;
+	Vector* in_elem=NULL;
 
-	in_nod=NewVec(nods);
-	in_elem=NewVec(nel);
+	in_nod=new Vector(nods);
+	in_elem=new Vector(nel);
 
 	/*initialize thread parameters: */
@@ -49,9 +49,8 @@
 
 	/*Assemble in_nod: */
-	VecAssemblyBegin(in_nod);
-	VecAssemblyEnd(in_nod);
+	in_nod->Assemble();
 
 	/*Get in_nod serialised for next operation: */
-	VecToMPISerial(&in_nod_serial,in_nod);
+	in_nod_serial=in_nod->ToMPISerial();
 
 	/*Take care of the case where an element interpolation has been requested: */
@@ -59,5 +58,5 @@
 		for (n=0;n<nel;n++){
 			if ( (in_nod_serial[ (int)*(index+3*n+0) -1] == 1) && (in_nod_serial[ (int)*(index+3*n+1) -1] == 1) && (in_nod_serial[ (int)*(index+3*n+2) -1] == 1) ){
-				value=1; VecSetValues(in_elem,1,&n,&value,INSERT_VALUES);
+				value=1; in_elem->SetValue(n,value,INS_VAL);
 			}
 		}
@@ -65,6 +64,5 @@
 
 	/*Assemble vectors: */
-	VecAssemblyBegin(in_elem);
-	VecAssemblyEnd(in_elem);
+	in_elem->Assemble();
 
 	/*Assign output pointers: */
Index: /issm/branches/trunk-jpl-damage/src/c/modules/ContourToMeshx/ContourToMeshx.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/ContourToMeshx/ContourToMeshx.h	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/ContourToMeshx/ContourToMeshx.h	(revision 11708)
@@ -17,5 +17,5 @@
 	int nods;
 	int edgevalue;
-	Vec in_nod;
+	Vector* in_nod;
 	double* x;
 	double* y;
@@ -25,5 +25,5 @@
 
 /* local prototypes: */
-int ContourToMeshx( Vec* pin_nods,Vec* pin_elem, double* index, double* x, double* y,Contour** contours,int numcontours,char* interptype,int nel,int nods, int edgevalue);
+int ContourToMeshx( Vector** pin_nods,Vector** pin_elem, double* index, double* x, double* y,Contour** contours,int numcontours,char* interptype,int nel,int nods, int edgevalue);
 
 void* ContourToMeshxt(void* vContourToMeshxThreadStruct);
Index: /issm/branches/trunk-jpl-damage/src/c/modules/ContourToMeshx/ContourToMeshxt.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/ContourToMeshx/ContourToMeshxt.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/ContourToMeshx/ContourToMeshxt.cpp	(revision 11708)
@@ -39,5 +39,5 @@
 	double* x=NULL;
 	double* y=NULL;
-	Vec in_nod=NULL;
+	Vector* in_nod=NULL;
 
 
Index: /issm/branches/trunk-jpl-damage/src/c/modules/ContourToNodesx/ContourToNodesx.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/ContourToNodesx/ContourToNodesx.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/ContourToNodesx/ContourToNodesx.cpp	(revision 11708)
@@ -4,5 +4,5 @@
 #include "./ContourToNodesx.h"
 
-int ContourToNodesx( Vec* pflags,double* x, double* y, int nods, Contour** contours,int numcontours,int edgevalue){
+int ContourToNodesx( Vector** pflags,double* x, double* y, int nods, Contour** contours,int numcontours,int edgevalue){
 
 	int i;
@@ -17,7 +17,7 @@
 
 	/*output: */
-	Vec flags=NULL;
+	Vector* flags=NULL;
 
-	flags=NewVec(nods);
+	flags=new Vector(nods);
 
 	/*Loop through all contours: */
@@ -31,6 +31,5 @@
 
 	/*Assemble vector: */
-	VecAssemblyBegin(flags);
-	VecAssemblyEnd(flags);
+	flags->Assemble();
 
 	/*Assign output pointers: */
Index: /issm/branches/trunk-jpl-damage/src/c/modules/ContourToNodesx/ContourToNodesx.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/ContourToNodesx/ContourToNodesx.h	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/ContourToNodesx/ContourToNodesx.h	(revision 11708)
@@ -11,5 +11,5 @@
 
 /* local prototypes: */
-int ContourToNodesx( Vec* pflags,double* x, double* y, int nods, Contour** contours,int numcontours,int edgevalue);
+int ContourToNodesx( Vector** pflags,double* x, double* y, int nods, Contour** contours,int numcontours,int edgevalue);
 
 #endif /* _CONTOURTONODESX_H */
Index: /issm/branches/trunk-jpl-damage/src/c/modules/ControlInputGetGradientx/ControlInputGetGradientx.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/ControlInputGetGradientx/ControlInputGetGradientx.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/ControlInputGetGradientx/ControlInputGetGradientx.cpp	(revision 11708)
@@ -9,10 +9,10 @@
 #include "../../EnumDefinitions/EnumDefinitions.h"
 
-void ControlInputGetGradientx( Vec* pgradient, Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters){
+void ControlInputGetGradientx( Vector** pgradient, Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters){
 
 	/*Intermediaries*/
 	int  num_controls;
 	int *control_type = NULL;
-	Vec  gradient=NULL;
+	Vector*  gradient=NULL;
 
 	/*Retrieve some parameters*/
@@ -21,5 +21,5 @@
 
 	/*Allocate and populate gradient*/
-	gradient=NewVec(num_controls*vertices->NumberOfVertices());
+	gradient=new Vector(num_controls*vertices->NumberOfVertices());
 
 	for(int i=0;i<num_controls;i++){
@@ -30,6 +30,5 @@
 	}
 
-	VecAssemblyBegin(gradient);
-	VecAssemblyEnd(gradient);
+	gradient->Assemble();
 
 	/*Clean up and return*/
Index: /issm/branches/trunk-jpl-damage/src/c/modules/ControlInputGetGradientx/ControlInputGetGradientx.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/ControlInputGetGradientx/ControlInputGetGradientx.h	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/ControlInputGetGradientx/ControlInputGetGradientx.h	(revision 11708)
@@ -8,5 +8,5 @@
 #include "../../Container/Container.h"
 
-void	ControlInputGetGradientx( Vec* pgradient, Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters);
+void	ControlInputGetGradientx( Vector** pgradient, Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters);
 
 #endif
Index: /issm/branches/trunk-jpl-damage/src/c/modules/ControlInputSetGradientx/ControlInputSetGradientx.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/ControlInputSetGradientx/ControlInputSetGradientx.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/ControlInputSetGradientx/ControlInputSetGradientx.cpp	(revision 11708)
@@ -30,9 +30,9 @@
 
 }
-void ControlInputSetGradientx(Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,Vec gradient){
+void ControlInputSetGradientx(Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,Vector* gradient){
 
 	/*Serialize gradient*/
 	double* serial_gradient=NULL;
-	VecToMPISerial(&serial_gradient,gradient);
+	serial_gradient=gradient->ToMPISerial();
 
 	ControlInputSetGradientx(elements,nodes,vertices, loads, materials, parameters,serial_gradient);
Index: /issm/branches/trunk-jpl-damage/src/c/modules/ControlInputSetGradientx/ControlInputSetGradientx.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/ControlInputSetGradientx/ControlInputSetGradientx.h	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/ControlInputSetGradientx/ControlInputSetGradientx.h	(revision 11708)
@@ -9,5 +9,5 @@
 
 void	ControlInputSetGradientx(Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters,double* gradient);
-void	ControlInputSetGradientx(Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters,Vec gradient);
+void	ControlInputSetGradientx(Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters,Vector* gradient);
 
 #endif
Index: /issm/branches/trunk-jpl-damage/src/c/modules/EnumToStringx/EnumToStringx.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/EnumToStringx/EnumToStringx.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/EnumToStringx/EnumToStringx.cpp	(revision 11708)
@@ -262,6 +262,6 @@
 		case PentaEnum : return "Penta";
 		case PentaP1InputEnum : return "PentaP1Input";
-		case PetscMatParamEnum : return "PetscMatParam";
-		case PetscVecParamEnum : return "PetscVecParam";
+		case MatrixParamEnum : return "MatrixParam";
+		case VectorParamEnum : return "VectorParam";
 		case RiftfrontEnum : return "Riftfront";
 		case SegmentEnum : return "Segment";
Index: /issm/branches/trunk-jpl-damage/src/c/modules/GetVectorFromControlInputsx/GetVectorFromControlInputsx.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/GetVectorFromControlInputsx/GetVectorFromControlInputsx.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/GetVectorFromControlInputsx/GetVectorFromControlInputsx.cpp	(revision 11708)
@@ -9,9 +9,9 @@
 #include "../../EnumDefinitions/EnumDefinitions.h"
 
-void GetVectorFromControlInputsx(Vec* pvector, Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,const char* data){
+void GetVectorFromControlInputsx(Vector** pvector, Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,const char* data){
 
 	int  num_controls;
 	int *control_type = NULL;
-	Vec  vector=NULL;
+	Vector*  vector=NULL;
 
 	/*Retrieve some parameters*/
@@ -20,5 +20,5 @@
 
 	/*Allocate and populate gradient*/
-	vector=NewVec(num_controls*vertices->NumberOfVertices());
+	vector=new Vector(num_controls*vertices->NumberOfVertices());
 
 	for(int i=0;i<num_controls;i++){
@@ -29,6 +29,5 @@
 	}
 
-	VecAssemblyBegin(vector);
-	VecAssemblyEnd(vector);
+	vector->Assemble();
 
 	/*Assign output pointers:*/
@@ -43,11 +42,11 @@
 	
 	/*intermediary: */
-	Vec vec_vector=NULL;
+	Vector* vec_vector=NULL;
 
 	GetVectorFromControlInputsx( &vec_vector, elements,nodes, vertices, loads, materials, parameters,data);
-	VecToMPISerial(&vector,vec_vector);
+	vector=vec_vector->ToMPISerial();
 
 	/*Free ressources:*/
-	VecFree(&vec_vector);
+	xdelete(&vec_vector);
 
 	/*Assign output pointers:*/
Index: /issm/branches/trunk-jpl-damage/src/c/modules/GetVectorFromControlInputsx/GetVectorFromControlInputsx.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/GetVectorFromControlInputsx/GetVectorFromControlInputsx.h	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/GetVectorFromControlInputsx/GetVectorFromControlInputsx.h	(revision 11708)
@@ -9,5 +9,5 @@
 
 /* local prototypes: */
-void	GetVectorFromControlInputsx( Vec* pvector, Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters,const char* data="value");
+void	GetVectorFromControlInputsx( Vector** pvector, Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters,const char* data="value");
 void	GetVectorFromControlInputsx( double** pvector, Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters,const char* data="value");
 
Index: /issm/branches/trunk-jpl-damage/src/c/modules/GetVectorFromInputsx/GetVectorFromInputsx.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/GetVectorFromInputsx/GetVectorFromInputsx.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/GetVectorFromInputsx/GetVectorFromInputsx.cpp	(revision 11708)
@@ -9,13 +9,13 @@
 #include "../../EnumDefinitions/EnumDefinitions.h"
 
-void GetVectorFromInputsx( Vec* pvector, Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters, int name, int type){
+void GetVectorFromInputsx( Vector** pvector, Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters, int name, int type){
 
 	int i;
-	Vec vector=NULL;
+	Vector* vector=NULL;
 
 	if(type==VertexEnum){
 
 		/*Allocate vector*/
-		vector=NewVec(vertices->NumberOfVertices());
+		vector=new Vector(vertices->NumberOfVertices());
 
 		/*Look up in elements*/
@@ -35,6 +35,5 @@
 	}
 
-	VecAssemblyBegin(vector);
-	VecAssemblyEnd(vector);
+	vector->Assemble();
 
 	/*Assign output pointers:*/
@@ -48,11 +47,11 @@
 	
 	/*intermediary: */
-	Vec vec_vector=NULL;
+	Vector* vec_vector=NULL;
 
 	GetVectorFromInputsx( &vec_vector, elements,nodes, vertices, loads, materials, parameters, name, type);
-	VecToMPISerial(&vector,vec_vector);
+	vector=vec_vector->ToMPISerial();
 
 	/*Free ressources:*/
-	VecFree(&vec_vector);
+	xdelete(&vec_vector);
 
 	/*Assign output pointers:*/
Index: /issm/branches/trunk-jpl-damage/src/c/modules/GetVectorFromInputsx/GetVectorFromInputsx.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/GetVectorFromInputsx/GetVectorFromInputsx.h	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/GetVectorFromInputsx/GetVectorFromInputsx.h	(revision 11708)
@@ -9,5 +9,5 @@
 
 /* local prototypes: */
-void	GetVectorFromInputsx( Vec* pvector, Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters,int name,int type);
+void	GetVectorFromInputsx( Vector** pvector, Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters,int name,int type);
 void	GetVectorFromInputsx( double** pvector, Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters,int name,int type);
 
Index: /issm/branches/trunk-jpl-damage/src/c/modules/Gradjx/Gradjx.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/Gradjx/Gradjx.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/Gradjx/Gradjx.cpp	(revision 11708)
@@ -10,5 +10,5 @@
 #include "../../EnumDefinitions/EnumDefinitions.h"
 
-void Gradjx(Vec* pgradient,double** pnorm_list, Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters){
+void Gradjx(Vector** pgradient,double** pnorm_list, Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters){
 
 	int     i,j,numberofvertices;
@@ -17,6 +17,6 @@
 	double *norm_list       = NULL;
 	int    *control_type    = NULL;
-	Vec     gradient        = NULL;
-	Vec    *gradient_list   = NULL;
+	Vector*     gradient        = NULL;
+	Vector*    *gradient_list   = NULL;
 	
 	/*retrieve some parameters: */
@@ -26,10 +26,10 @@
 
 	/*Allocate gradient_list */
-	gradient_list = (Vec*)xmalloc(num_controls*sizeof(Vec));
+	gradient_list = (Vector**)xmalloc(num_controls*sizeof(Vector*));
 	norm_list = (double*)xmalloc(num_controls*sizeof(double));
 	for(i=0;i<num_controls;i++){
-		gradient_list[i]=NewVec(num_controls*numberofvertices);
+		gradient_list[i]=new Vector(num_controls*numberofvertices);
 	}
-	gradient=NewVec(num_controls*numberofvertices);
+	gradient=new Vector(num_controls*numberofvertices);
 
 	/*Compute all gradient_list*/
@@ -41,18 +41,17 @@
 		}
 
-		VecAssemblyBegin(gradient_list[i]);
-		VecAssemblyEnd(gradient_list[i]);
+		gradient_list[i]->Assemble();
 
-		VecNorm(gradient_list[i],NORM_INFINITY,&norm_list[i]);
+		norm_list[i]=gradient_list[i]->Norm(NORM_INF);
 	}
 
 	/*Add all gradient_list together*/
 	for(i=0;i<num_controls;i++){
-		VecAXPY(gradient,1.,gradient_list[i]);
-		VecFree(&gradient_list[i]);
+		gradient->AXPY(gradient_list[i],1.0);
+		xdelete(&gradient_list[i]);
 	}
 
 	/*Check that gradient is clean*/
-	VecNorm(gradient,NORM_INFINITY,&norm_inf);
+	norm_inf=gradient->Norm(NORM_INF);
 	if(norm_inf<=0)    _error_("||∂J/∂α||∞ = 0    gradient norm is zero");
 	if(isnan(norm_inf))_error_("||∂J/∂α||∞ = NaN  gradient norm is NaN");
Index: /issm/branches/trunk-jpl-damage/src/c/modules/Gradjx/Gradjx.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/Gradjx/Gradjx.h	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/Gradjx/Gradjx.h	(revision 11708)
@@ -10,5 +10,5 @@
 
 /* local prototypes: */
-void Gradjx(Vec* pgrad_g,double** pgrad_norm,Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials,Parameters* parameters);
+void Gradjx(Vector** pgrad_g,double** pgrad_norm,Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials,Parameters* parameters);
 
 #endif  /* _GRADJX_H */
Index: /issm/branches/trunk-jpl-damage/src/c/modules/GroundinglineMigrationx/GroundinglineMigrationx.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/GroundinglineMigrationx/GroundinglineMigrationx.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/GroundinglineMigrationx/GroundinglineMigrationx.cpp	(revision 11708)
@@ -17,5 +17,5 @@
 	double*  vertices_ungrounding             = NULL;
 	double*  old_floatingice                  = NULL;
-	Vec      vec_old_floatingice              = NULL;
+	Vector*      vec_old_floatingice              = NULL;
 	Element* element                          = NULL;
 	
@@ -39,5 +39,5 @@
 	/*Create vector with vertices initially floating and serialize*/
 	vec_old_floatingice=CreateNodesOnFloatingIce(nodes,analysis_type);
-	VecToMPISerial(&old_floatingice,vec_old_floatingice);
+	old_floatingice=vec_old_floatingice->ToMPISerial();
 
 	/*Migrate grounding line : */
@@ -48,5 +48,5 @@
 
 	/*free ressouces: */
-	VecFree(&vec_old_floatingice);
+	xdelete(&vec_old_floatingice);
 	xfree((void**)&vertices_potentially_ungrounding);
 	xfree((void**)&vertices_ungrounding);
@@ -55,13 +55,13 @@
 
 /*FUNCTION CreateNodesOnFloatingIce {{{1*/
-Vec CreateNodesOnFloatingIce(Nodes* nodes,int configuration_type){ 
+Vector* CreateNodesOnFloatingIce(Nodes* nodes,int configuration_type){ 
 
 	int     i,numnods;
-	Vec   vec_nodes_on_floatingice = NULL;
+	Vector*   vec_nodes_on_floatingice = NULL;
 	Node *node                     = NULL;
 
 	/*First, initialize nodes_on_floatingice, which will track which nodes have changed status: */
 	numnods=nodes->NumberOfNodes(configuration_type);
-	vec_nodes_on_floatingice=NewVec(numnods);
+	vec_nodes_on_floatingice=new Vector(numnods);
 
 	/*Loop through nodes, and fill vec_nodes_on_floatingice: */
@@ -70,5 +70,5 @@
 		if(node->InAnalysis(configuration_type)){
 			if(node->IsFloating()){
-				VecSetValue(vec_nodes_on_floatingice,node->Sid(),1.0,INSERT_VALUES);
+				vec_nodes_on_floatingice->SetValue(node->Sid(),1.0,INS_VAL);
 			}
 		}
@@ -76,6 +76,5 @@
 
 	/*Assemble vector: */
-	VecAssemblyBegin(vec_nodes_on_floatingice);
-	VecAssemblyEnd(vec_nodes_on_floatingice);
+	vec_nodes_on_floatingice->Assemble();
 
 	return vec_nodes_on_floatingice;
@@ -87,10 +86,10 @@
 	int      i,numberofvertices;
 	double*  vertices_potentially_ungrounding      = NULL;
-	Vec      vec_vertices_potentially_ungrounding  = NULL;
+	Vector*      vec_vertices_potentially_ungrounding  = NULL;
 	Element* element                               = NULL;
 
 	/*Initialize vector with number of vertices*/
 	numberofvertices=vertices->NumberOfVertices();
-	vec_vertices_potentially_ungrounding=NewVec(numberofvertices); //grounded vertex that could start floating
+	vec_vertices_potentially_ungrounding=new Vector(numberofvertices); //grounded vertex that could start floating
 
 	/*Fill vector vertices_potentially_floating: */
@@ -101,10 +100,9 @@
 
 	/*Assemble vector and serialize */
-	VecAssemblyBegin(vec_vertices_potentially_ungrounding);
-	VecAssemblyEnd(vec_vertices_potentially_ungrounding);
-	VecToMPISerial(&vertices_potentially_ungrounding,vec_vertices_potentially_ungrounding);
+	vec_vertices_potentially_ungrounding->Assemble();
+	vertices_potentially_ungrounding=vec_vertices_potentially_ungrounding->ToMPISerial();
 
 	/*free ressouces and return: */
-	VecFree(&vec_vertices_potentially_ungrounding);
+	xdelete(&vec_vertices_potentially_ungrounding);
 	return vertices_potentially_ungrounding;
 }
@@ -118,6 +116,6 @@
 	double*  nodes_on_floatingice                  = NULL;
 	double*  elements_neighboring_floatingce      = NULL;
-	Vec      vec_elements_neighboring_floatingice = NULL;
-	Vec      vec_nodes_on_floatingice              = NULL;
+	Vector*      vec_elements_neighboring_floatingice = NULL;
+	Vector*      vec_nodes_on_floatingice              = NULL;
 	Node*    node                                  = NULL;
 	Element* element                               = NULL;
@@ -130,5 +128,5 @@
 	/*recover vec_nodes_on_floatingice*/
 	vec_nodes_on_floatingice=CreateNodesOnFloatingIce(nodes,analysis_type);
-	VecToMPISerial(&nodes_on_floatingice,vec_nodes_on_floatingice);
+	nodes_on_floatingice=vec_nodes_on_floatingice->ToMPISerial();
 
 	nflipped=1; //bootstrap
@@ -136,16 +134,15 @@
 		
 		/*Vector of size number of elements*/
-		vec_elements_neighboring_floatingice=NewVec(elements->NumberOfElements(),true);
+		vec_elements_neighboring_floatingice=new Vector(elements->NumberOfElements(),true);
 
 		/*Figure out if any of the nodes of the element will be floating -> elements neighbouting the floating ice*/
 		for(i=0;i<elements->Size();i++){
 			element=(Element*)elements->GetObjectByOffset(i);
-			VecSetValue(vec_elements_neighboring_floatingice,element->Sid(),element->IsNodeOnShelfFromFlags(nodes_on_floatingice)?1.0:0.0,INSERT_VALUES);
+			vec_elements_neighboring_floatingice->SetValue(element->Sid(),element->IsNodeOnShelfFromFlags(nodes_on_floatingice)?1.0:0.0,INS_VAL);
 		}
 
 		/*Assemble vector and serialize: */
-		VecAssemblyBegin(vec_elements_neighboring_floatingice);
-		VecAssemblyEnd(vec_elements_neighboring_floatingice);
-		VecToMPISerial(&elements_neighboring_floatingce,vec_elements_neighboring_floatingice);
+		vec_elements_neighboring_floatingice->Assemble();
+		elements_neighboring_floatingce=vec_elements_neighboring_floatingice->ToMPISerial();
 
 		/*Go through elements_neighboring_floatingce, and update vector of the nodes that will start floating*/
@@ -157,6 +154,5 @@
 			}
 		}
-		VecAssemblyBegin(vec_nodes_on_floatingice);
-		VecAssemblyEnd(vec_nodes_on_floatingice);
+		vec_nodes_on_floatingice->Assemble();
 		
 		MPI_Allreduce(&local_nflipped,&nflipped,1,MPI_INT,MPI_SUM,MPI_COMM_WORLD);
@@ -168,10 +164,10 @@
 
 		/*Assemble and serialize:*/
-		VecFree(&vec_elements_neighboring_floatingice);
-		VecToMPISerial(&nodes_on_floatingice,vec_nodes_on_floatingice); 
+		xdelete(&vec_elements_neighboring_floatingice);
+		nodes_on_floatingice=vec_nodes_on_floatingice->ToMPISerial();
 	}
 
 	/*Free ressources:*/
-	VecFree(&vec_nodes_on_floatingice);
+	xdelete(&vec_nodes_on_floatingice);
 	xfree((void**)&elements_neighboring_floatingce);
 
Index: /issm/branches/trunk-jpl-damage/src/c/modules/GroundinglineMigrationx/GroundinglineMigrationx.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/GroundinglineMigrationx/GroundinglineMigrationx.h	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/GroundinglineMigrationx/GroundinglineMigrationx.h	(revision 11708)
@@ -14,5 +14,5 @@
 void       GroundinglineMigrationx(Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads,Materials* materials, Parameters* parameters);
 
-Vec        CreateNodesOnFloatingIce(Nodes* nodes,int configuration_type);
+Vector*        CreateNodesOnFloatingIce(Nodes* nodes,int configuration_type);
 double*    PotentialSheetUngrounding(Elements* elements,Vertices* vertices,Parameters* parameters);
 double*    PropagateFloatingiceToGroundedNeighbors(Elements* elements,Nodes* nodes,Vertices* vertices,Parameters* parameters,double* vertices_potentially_ungrounding);
Index: /issm/branches/trunk-jpl-damage/src/c/modules/InputUpdateFromVectorDakotax/InputUpdateFromVectorDakotax.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/InputUpdateFromVectorDakotax/InputUpdateFromVectorDakotax.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/InputUpdateFromVectorDakotax/InputUpdateFromVectorDakotax.cpp	(revision 11708)
@@ -9,9 +9,9 @@
 #include "../../EnumDefinitions/EnumDefinitions.h"
 
-void InputUpdateFromVectorDakotax( Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,Vec vector, int name, int type){
+void InputUpdateFromVectorDakotax( Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,Vector* vector, int name, int type){
 
 	double* serial_vector=NULL;
 
-	VecToMPISerial(&serial_vector,vector);
+	serial_vector=vector->ToMPISerial();
 
 	InputUpdateFromVectorDakotax( elements,nodes, vertices, loads, materials, parameters,serial_vector,name, type);
Index: /issm/branches/trunk-jpl-damage/src/c/modules/InputUpdateFromVectorDakotax/InputUpdateFromVectorDakotax.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/InputUpdateFromVectorDakotax/InputUpdateFromVectorDakotax.h	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/InputUpdateFromVectorDakotax/InputUpdateFromVectorDakotax.h	(revision 11708)
@@ -10,5 +10,5 @@
 
 /* local prototypes: */
-void	InputUpdateFromVectorDakotax( Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters,Vec vector, int name,int type);
+void	InputUpdateFromVectorDakotax( Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters,Vector* vector, int name,int type);
 void	InputUpdateFromVectorDakotax( Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters,double* vector, int name,int type);
 void	InputUpdateFromVectorDakotax( Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters,int* vector, int name,int type);
Index: /issm/branches/trunk-jpl-damage/src/c/modules/InputUpdateFromVectorx/InputUpdateFromVectorx.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/InputUpdateFromVectorx/InputUpdateFromVectorx.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/InputUpdateFromVectorx/InputUpdateFromVectorx.cpp	(revision 11708)
@@ -9,9 +9,9 @@
 #include "../../EnumDefinitions/EnumDefinitions.h"
 
-void InputUpdateFromVectorx( Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,Vec vector, int name, int type){
+void InputUpdateFromVectorx( Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,Vector* vector, int name, int type){
 
 	double* serial_vector=NULL;
 
-	VecToMPISerial(&serial_vector,vector);
+	serial_vector=vector->ToMPISerial();
 
 	InputUpdateFromVectorx( elements,nodes, vertices, loads, materials, parameters,serial_vector,name, type);
Index: /issm/branches/trunk-jpl-damage/src/c/modules/InputUpdateFromVectorx/InputUpdateFromVectorx.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/InputUpdateFromVectorx/InputUpdateFromVectorx.h	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/InputUpdateFromVectorx/InputUpdateFromVectorx.h	(revision 11708)
@@ -10,5 +10,5 @@
 
 /* local prototypes: */
-void	InputUpdateFromVectorx( Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters,Vec vector, int name,int type);
+void	InputUpdateFromVectorx( Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters,Vector* vector, int name,int type);
 void	InputUpdateFromVectorx( Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters,double* vector, int name,int type);
 void	InputUpdateFromVectorx( Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters,int* vector, int name,int type);
Index: /issm/branches/trunk-jpl-damage/src/c/modules/InterpFromGridToMeshx/InterpFromGridToMeshx.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/InterpFromGridToMeshx/InterpFromGridToMeshx.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/InterpFromGridToMeshx/InterpFromGridToMeshx.cpp	(revision 11708)
@@ -16,8 +16,8 @@
 
 /*InterpFromGridToMeshx{{{*/
-int InterpFromGridToMeshx( Vec* pdata_mesh,double* x_in, int x_rows, double* y_in, int y_rows, double* data, int M, int N, double* x_mesh, double* y_mesh, int nods,double default_value, int interpenum){
+int InterpFromGridToMeshx( Vector** pdata_mesh,double* x_in, int x_rows, double* y_in, int y_rows, double* data, int M, int N, double* x_mesh, double* y_mesh, int nods,double default_value, int interpenum){
 
 	/*output: */
-	Vec data_mesh=NULL;
+	Vector* data_mesh=NULL;
 	
 	/*Intermediary*/
@@ -46,5 +46,5 @@
 
 	/*Allocate output vector: */
-	data_mesh=NewVec(nods);
+	data_mesh=new Vector(nods);
 
 	/*Find out what kind of coordinates (x_in,y_in) have been given is input*/
@@ -124,5 +124,5 @@
 	double *y             = gate->y;
 	int     nods          = gate->nods;
-	Vec     data_mesh     = gate->data_mesh;
+	Vector*     data_mesh     = gate->data_mesh;
 	double *data          = gate->data;
 	double  default_value = gate->default_value;
@@ -179,5 +179,5 @@
 		}
 
-		VecSetValue(data_mesh,i,data_value,INSERT_VALUES);
+		data_mesh->SetValue(i,data_value,INS_VAL);
 	}
 }/*}}}*/
Index: /issm/branches/trunk-jpl-damage/src/c/modules/InterpFromGridToMeshx/InterpFromGridToMeshx.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/InterpFromGridToMeshx/InterpFromGridToMeshx.h	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/InterpFromGridToMeshx/InterpFromGridToMeshx.h	(revision 11708)
@@ -23,8 +23,8 @@
 	double* x_mesh;
 	double* y_mesh;
-	Vec     data_mesh;
+	Vector*     data_mesh;
 } InterpFromGridToMeshxThreadStruct;
 
-int    InterpFromGridToMeshx( Vec* pdata_mesh,double* x, int x_rows, double* y, int y_rows, double* data, int M, int N, double* x_mesh, double* y_mesh, int nods, double default_value, int interpenum=BilinearInterpEnum);
+int    InterpFromGridToMeshx( Vector** pdata_mesh,double* x, int x_rows, double* y, int y_rows, double* data, int M, int N, double* x_mesh, double* y_mesh, int nods, double default_value, int interpenum=BilinearInterpEnum);
 void*  InterpFromGridToMeshxt(void* vInterpFromGridToMeshxThreadStruct);
 bool   findindices(int* pn,int* pm,double* x,int x_rows, double* y,int y_rows, double xgrid,double ygrid);
Index: /issm/branches/trunk-jpl-damage/src/c/modules/InterpFromMesh2dx/InterpFromMesh2dx.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/InterpFromMesh2dx/InterpFromMesh2dx.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/InterpFromMesh2dx/InterpFromMesh2dx.cpp	(revision 11708)
@@ -10,10 +10,10 @@
 #include "../modules.h"
 
-int InterpFromMesh2dx( Vec* pdata_prime,double* index_data, double* x_data, double* y_data, int nods_data,int nels_data, double* data, int data_length, double* x_prime, double* y_prime, int nods_prime,
+int InterpFromMesh2dx( Vector** pdata_prime,double* index_data, double* x_data, double* y_data, int nods_data,int nels_data, double* data, int data_length, double* x_prime, double* y_prime, int nods_prime,
 		double* default_values,int num_default_values,Contour** contours,int numcontours){
 
 	
 	/*Output*/
-	Vec data_prime=NULL;
+	Vector* data_prime=NULL;
 
 	/*Intermediary*/
@@ -28,5 +28,5 @@
 
 	/*contours: */
-	Vec    vec_incontour=NULL;
+	Vector*    vec_incontour=NULL;
 	double*    incontour=NULL;
 
@@ -72,8 +72,8 @@
 
 	/*Initialize output*/
-	data_prime=NewVec(nods_prime);
+	data_prime=new Vector(nods_prime);
 	if(num_default_values){
-		if(num_default_values==1)for (i=0;i<nods_prime;i++) VecSetValue(data_prime,i,default_values[0],INSERT_VALUES);
-		else for (i=0;i<nods_prime;i++) VecSetValue(data_prime,i,default_values[i],INSERT_VALUES);
+		if(num_default_values==1)for (i=0;i<nods_prime;i++) data_prime->SetValue(i,default_values[0],INS_VAL);
+		else for (i=0;i<nods_prime;i++) data_prime->SetValue(i,default_values[i],INS_VAL);
 	}
 
@@ -81,5 +81,5 @@
 	if(numcontours){
 		ContourToNodesx( &vec_incontour,x_prime,y_prime,nods_prime,contours,numcontours,1);
-		VecToMPISerial(&incontour,vec_incontour);
+		incontour=vec_incontour->ToMPISerial();
 	}
 	else{
Index: /issm/branches/trunk-jpl-damage/src/c/modules/InterpFromMesh2dx/InterpFromMesh2dx.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/InterpFromMesh2dx/InterpFromMesh2dx.h	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/InterpFromMesh2dx/InterpFromMesh2dx.h	(revision 11708)
@@ -23,5 +23,5 @@
 	double ymin,ymax;
 	int    nods_prime;
-	Vec    data_prime;
+	Vector*    data_prime;
 	double* x_prime;
 	double* y_prime;
@@ -33,5 +33,5 @@
 } InterpFromMesh2dxThreadStruct;
 
-int InterpFromMesh2dx( Vec* pdata_prime,double* index_data, double* x_data, double* y_data, int nods_data,int nels_data, double* data, int data_length, double* x_prime, double* y_prime, int nods_prime,
+int InterpFromMesh2dx( Vector** pdata_prime,double* index_data, double* x_data, double* y_data, int nods_data,int nels_data, double* data, int data_length, double* x_prime, double* y_prime, int nods_prime,
 		double* default_values,int num_default_values,Contour** contours,int numcontours);
 
Index: /issm/branches/trunk-jpl-damage/src/c/modules/InterpFromMesh2dx/InterpFromMesh2dxt.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/InterpFromMesh2dx/InterpFromMesh2dxt.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/InterpFromMesh2dx/InterpFromMesh2dxt.cpp	(revision 11708)
@@ -24,5 +24,5 @@
 	double ymin,ymax;
 	int    nods_prime;
-	Vec    data_prime=NULL;
+	Vector*    data_prime=NULL;
 	double* x_prime=NULL;
 	double* y_prime=NULL;
@@ -120,5 +120,5 @@
 
 					/*insert value and go to the next point*/
-					VecSetValue(data_prime,j,data_value,INSERT_VALUES);
+					data_prime->SetValue(j,data_value,INS_VAL);
 				}
 			}
Index: /issm/branches/trunk-jpl-damage/src/c/modules/InterpFromMeshToMesh2dx/InterpFromMeshToMesh2dx.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/InterpFromMeshToMesh2dx/InterpFromMeshToMesh2dx.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/InterpFromMeshToMesh2dx/InterpFromMeshToMesh2dx.cpp	(revision 11708)
@@ -32,5 +32,5 @@
 
 	/*default values: */
-	Vec    vec_incontour=NULL;
+	Vector*    vec_incontour=NULL;
 	double*    incontour=NULL;
 	bool   skip_bamg=false;
@@ -51,5 +51,5 @@
 	if(num_default_values){
 		ContourToNodesx( &vec_incontour,x_interp,y_interp,nods_interp,contours,numcontours,1);
-		VecToMPISerial(&incontour,vec_incontour);
+		incontour=vec_incontour->ToMPISerial();
 	}
 
Index: /issm/branches/trunk-jpl-damage/src/c/modules/InterpFromMeshToMesh3dx/InterpFromMeshToMesh3dx.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/InterpFromMeshToMesh3dx/InterpFromMeshToMesh3dx.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/InterpFromMeshToMesh3dx/InterpFromMeshToMesh3dx.cpp	(revision 11708)
@@ -7,8 +7,8 @@
 #include "../../include/include.h"
 
-int InterpFromMeshToMesh3dx( Vec* pdata_prime,double* index_data, double* x_data, double* y_data, double* z_data, int nods_data,int nels_data, double* data, int data_length, double* x_prime, double* y_prime, double* z_prime, int nods_prime,double default_value) {
+int InterpFromMeshToMesh3dx( Vector** pdata_prime,double* index_data, double* x_data, double* y_data, double* z_data, int nods_data,int nels_data, double* data, int data_length, double* x_prime, double* y_prime, double* z_prime, int nods_prime,double default_value) {
 
 	/*Output*/
-	Vec data_prime=NULL;
+	Vector* data_prime=NULL;
 
 	/*Intermediary*/
@@ -54,6 +54,6 @@
 
 	/*Initialize output*/
-	data_prime=NewVec(nods_prime);
-	for (i=0;i<nods_prime;i++) VecSetValue(data_prime,i,default_value,INSERT_VALUES);
+	data_prime=new Vector(nods_prime);
+	for (i=0;i<nods_prime;i++) data_prime->SetValue(i,default_value,INS_VAL);
 
 	/*Loop over the elements*/
@@ -127,5 +127,5 @@
 
 					/*insert value and go to the next point*/
-					VecSetValue(data_prime,j,data_value,INSERT_VALUES);
+					data_prime->SetValue(j,data_value,INS_VAL);
 				}
 			}
Index: /issm/branches/trunk-jpl-damage/src/c/modules/InterpFromMeshToMesh3dx/InterpFromMeshToMesh3dx.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/InterpFromMeshToMesh3dx/InterpFromMeshToMesh3dx.h	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/InterpFromMeshToMesh3dx/InterpFromMeshToMesh3dx.h	(revision 11708)
@@ -8,5 +8,5 @@
 #include "../../toolkits/toolkits.h"
 
-int InterpFromMeshToMesh3dx( Vec* pdata_prime,double* index_data, double* x_data, double* y_data, double* z_data, int nods_data,int nels_data, double* data, int data_length, double* x_prime, double* y_prime, double* z_prime, int nods_prime,double default_value);
+int InterpFromMeshToMesh3dx( Vector** pdata_prime,double* index_data, double* x_data, double* y_data, double* z_data, int nods_data,int nels_data, double* data, int data_length, double* x_prime, double* y_prime, double* z_prime, int nods_prime,double default_value);
 
 #endif /* _INTERPFROMMESHTOMESH3DX_H */
Index: /issm/branches/trunk-jpl-damage/src/c/modules/Orthx/Orthx.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/Orthx/Orthx.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/Orthx/Orthx.cpp	(revision 11708)
@@ -5,8 +5,8 @@
 #include "./Orthx.h"
 
-void	Orthx( Vec* pnewgradj, Vec gradj, Vec oldgradj){
+void	Orthx( Vector** pnewgradj, Vector* gradj, Vector* oldgradj){
 	
 	/*output: */
-	Vec newgradj=NULL;
+	Vector* newgradj=NULL;
 
 	/*intermediary:*/
@@ -14,15 +14,15 @@
 
 	/*Initialize output*/
-	VecDuplicate(gradj,&newgradj);
-	VecCopy(gradj,newgradj);
+	newgradj=gradj->Duplicate();
+	gradj->Copy(newgradj);
 
 	/*rough orthagonalization
 	gradient=gradient-(gradient'*oldgradient)*oldgradient /norm(oldgradient)^2; */
 	if(oldgradj){
-		VecNorm(oldgradj,NORM_2,&norm_old);
+		norm_old=oldgradj->Norm(NORM_TWO);
 		_assert_(norm_old!=0); 
-		VecDot(newgradj,oldgradj,&dot_product);
+		dot_product=newgradj->Dot(oldgradj);
 		_assert_(dot_product!=NAN); 
-		VecAXPY(newgradj, -dot_product/pow(norm_old,2), oldgradj);
+		newgradj->AXPY(oldgradj,-dot_product/pow(norm_old,2));
 	}
 
Index: /issm/branches/trunk-jpl-damage/src/c/modules/Orthx/Orthx.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/Orthx/Orthx.h	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/Orthx/Orthx.h	(revision 11708)
@@ -11,5 +11,5 @@
 
 /* local prototypes: */
-void	Orthx( Vec* pnewgradj, Vec gradj, Vec oldgradj);
+void	Orthx( Vector** pnewgradj, Vector* gradj, Vector* oldgradj);
 
 #endif  /* _ORTHX_H */
Index: /issm/branches/trunk-jpl-damage/src/c/modules/PointCloudFindNeighborsx/PointCloudFindNeighborsx.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/PointCloudFindNeighborsx/PointCloudFindNeighborsx.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/PointCloudFindNeighborsx/PointCloudFindNeighborsx.cpp	(revision 11708)
@@ -4,9 +4,9 @@
 #include "./PointCloudFindNeighborsx.h"
 
-int PointCloudFindNeighborsx( Vec* pflags,double* x, double* y, int nods, double mindistance,double multithread){
+int PointCloudFindNeighborsx( Vector** pflags,double* x, double* y, int nods, double mindistance,double multithread){
 
 	/*output: */
-	Vec flags=NULL;
-	flags=NewVec(nods);
+	Vector* flags=NULL;
+	flags=new Vector(nods);
 
 	/*threading: */
@@ -31,6 +31,5 @@
 
 	/*Assemble vector: */
-	VecAssemblyBegin(flags);
-	VecAssemblyEnd(flags);
+	flags->Assemble();
 
 	/*Assign output pointers: */
Index: /issm/branches/trunk-jpl-damage/src/c/modules/PointCloudFindNeighborsx/PointCloudFindNeighborsx.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/PointCloudFindNeighborsx/PointCloudFindNeighborsx.h	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/PointCloudFindNeighborsx/PointCloudFindNeighborsx.h	(revision 11708)
@@ -11,5 +11,5 @@
 
 /* local prototypes: */
-int PointCloudFindNeighborsx( Vec* pflags,double* x, double* y, int nods, double mindistance,double multithread);
+int PointCloudFindNeighborsx( Vector** pflags,double* x, double* y, int nods, double mindistance,double multithread);
 
 /*threading: */
@@ -20,5 +20,5 @@
 	int nods;
 	double mindistance;
-	Vec flags;
+	Vector* flags;
 
 
Index: /issm/branches/trunk-jpl-damage/src/c/modules/PointCloudFindNeighborsx/PointCloudFindNeighborsxt.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/PointCloudFindNeighborsx/PointCloudFindNeighborsxt.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/PointCloudFindNeighborsx/PointCloudFindNeighborsxt.cpp	(revision 11708)
@@ -17,5 +17,5 @@
 	int     nods;
 	double  mindistance;
-	Vec     flags;
+	Vector*     flags;
 
 	/*recover handle and gate: */
@@ -62,6 +62,6 @@
 
 				/*insert value and go to the next point*/
-				if(!already[i]) VecSetValue(flags,i,1,INSERT_VALUES);
-				if(!already[j]) VecSetValue(flags,j,2,INSERT_VALUES);
+				if(!already[i]) flags->SetValue(i,1,INS_VAL);
+				if(!already[j]) flags->SetValue(j,2,INS_VAL);
 				already[i]=true;
 				already[j]=true;
Index: /issm/branches/trunk-jpl-damage/src/c/modules/Reduceloadx/Reduceloadx.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/Reduceloadx/Reduceloadx.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/Reduceloadx/Reduceloadx.cpp	(revision 11708)
@@ -46,11 +46,11 @@
 		}
 
-		pf->AXPY(Kfsy_s,-1);
+		pf->AXPY(Kfsy_s,-1.);
 	}
 
 
 	/*Free ressources and return*/
-	delete y_s0;
-	delete Kfsy_s;
+	xdelete(&y_s0);
+	xdelete(&Kfsy_s);
 
 }
Index: /issm/branches/trunk-jpl-damage/src/c/modules/SetControlInputsFromVectorx/SetControlInputsFromVectorx.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/SetControlInputsFromVectorx/SetControlInputsFromVectorx.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/SetControlInputsFromVectorx/SetControlInputsFromVectorx.cpp	(revision 11708)
@@ -28,9 +28,9 @@
 }
 
-void SetControlInputsFromVectorx(Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,Vec vector){
+void SetControlInputsFromVectorx(Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,Vector* vector){
 	
 	double* serial_vector=NULL;
 
-	VecToMPISerial(&serial_vector,vector);
+	serial_vector=vector->ToMPISerial();
 
 	SetControlInputsFromVectorx(elements,nodes, vertices, loads, materials, parameters,serial_vector);
Index: /issm/branches/trunk-jpl-damage/src/c/modules/SetControlInputsFromVectorx/SetControlInputsFromVectorx.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/SetControlInputsFromVectorx/SetControlInputsFromVectorx.h	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/SetControlInputsFromVectorx/SetControlInputsFromVectorx.h	(revision 11708)
@@ -9,5 +9,5 @@
 
 /* local prototypes: */
-void SetControlInputsFromVectorx(Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters,Vec vector);
+void SetControlInputsFromVectorx(Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters,Vector* vector);
 void SetControlInputsFromVectorx(Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters,double* vector);
 
Index: /issm/branches/trunk-jpl-damage/src/c/modules/Solverx/Solverx.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/Solverx/Solverx.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/Solverx/Solverx.cpp	(revision 11708)
@@ -20,9 +20,20 @@
 	uf=new Vector();
 
+	/*Intermediary: */
+	int analysis_type;
+
 	#ifdef _HAVE_PETSC_
-	Vec uf0_vector=NULL;
-	if (uf0)uf0_vector=uf0->vector;
+	Vec uf0_vector = NULL;
+	Vec df_vector  = NULL;
+	if(uf0) uf0_vector=uf0->vector;
+	if(df)  df_vector = df->vector;
 
-	SolverxPetsc(&uf->vector, Kff->matrix, pf->vector, uf0_vector, df->vector, parameters);
+	/*In serial mode, the Petsc Options database has not been initialized properly: */
+	#ifdef _SERIAL_
+	parameters->FindParam(&analysis_type,AnalysisTypeEnum);
+	PetscOptionsFromAnalysis(parameters,analysis_type);
+	#endif
+
+	SolverxPetsc(&uf->vector,Kff->matrix,pf->vector,uf0_vector,df_vector,parameters);
 	VecGetSize(uf->vector,&uf->M);
 	#else
Index: /issm/branches/trunk-jpl-damage/src/c/modules/Solverx/Solverx.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/Solverx/Solverx.h	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/Solverx/Solverx.h	(revision 11708)
@@ -6,10 +6,20 @@
 #define _SOLVERX_H
 
+#ifdef HAVE_CONFIG_H
+	#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
 #include "../../objects/objects.h"
 
 /* local prototypes: */
 void	Solverx(Vector** puf, Matrix* Kff, Vector* pf, Vector* uf0,Vector* df, Parameters* parameters);
+
+#ifdef _HAVE_PETSC_
 void	SolverxPetsc(Vec* puf, Mat Kff, Vec pf, Vec uf0,Vec df, Parameters* parameters);
 void    DofTypesToIndexSet(IS* pisv, IS* pisp, Vec df,int typeenum);
+#endif
+
 #endif  /* _SOLVERX_H */
 
Index: /issm/branches/trunk-jpl-damage/src/c/modules/StringToEnumx/StringToEnumx.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/StringToEnumx/StringToEnumx.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/StringToEnumx/StringToEnumx.cpp	(revision 11708)
@@ -137,10 +137,10 @@
 	      else if (strcmp(name,"PrognosticHydrostaticAdjustment")==0) return PrognosticHydrostaticAdjustmentEnum;
 	      else if (strcmp(name,"PrognosticMinThickness")==0) return PrognosticMinThicknessEnum;
-	      else if (strcmp(name,"PrognosticPenaltyFactor")==0) return PrognosticPenaltyFactorEnum;
-	      else if (strcmp(name,"PrognosticSpcthickness")==0) return PrognosticSpcthicknessEnum;
          else stage=2;
    }
    if(stage==2){
-	      if (strcmp(name,"PrognosticStabilization")==0) return PrognosticStabilizationEnum;
+	      if (strcmp(name,"PrognosticPenaltyFactor")==0) return PrognosticPenaltyFactorEnum;
+	      else if (strcmp(name,"PrognosticSpcthickness")==0) return PrognosticSpcthicknessEnum;
+	      else if (strcmp(name,"PrognosticStabilization")==0) return PrognosticStabilizationEnum;
 	      else if (strcmp(name,"PrognosticVertexPairing")==0) return PrognosticVertexPairingEnum;
 	      else if (strcmp(name,"QmuIsdakota")==0) return QmuIsdakotaEnum;
@@ -269,6 +269,6 @@
 	      else if (strcmp(name,"Penta")==0) return PentaEnum;
 	      else if (strcmp(name,"PentaP1Input")==0) return PentaP1InputEnum;
-	      else if (strcmp(name,"PetscMatParam")==0) return PetscMatParamEnum;
-	      else if (strcmp(name,"PetscVecParam")==0) return PetscVecParamEnum;
+	      else if (strcmp(name,"MatrixParam")==0) return MatrixParamEnum;
+	      else if (strcmp(name,"VectorParam")==0) return VectorParamEnum;
 	      else if (strcmp(name,"Riftfront")==0) return RiftfrontEnum;
 	      else if (strcmp(name,"Segment")==0) return SegmentEnum;
Index: /issm/branches/trunk-jpl-damage/src/c/modules/SystemMatricesx/SystemMatricesx.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/SystemMatricesx/SystemMatricesx.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/SystemMatricesx/SystemMatricesx.cpp	(revision 11708)
@@ -69,6 +69,4 @@
 		Kfs->Assemble();
 		df->Assemble();
-
-		
 	}
 	
@@ -88,10 +86,9 @@
 			if (load->InAnalysis(configuration_type)) load->CreatePVector(pf);
 		}
-
 		pf->Assemble();
 	}
 
 	/*Now, figure out maximum value of K_gg, so that we can penalize it correctly: */
-	kmax=Kff->Norm(NORM_INFINITY);
+	kmax=Kff->Norm(NORM_INF);
 
 	/*Now, deal with penalties*/
@@ -119,16 +116,15 @@
 
 		pf->Assemble();
-		pf->Assemble();
 	}
 
 	/*Assign output pointers: */
 	if(pKff) *pKff=Kff;
-	else      delete Kff;
+	else      xdelete(&Kff);
 	if(pKfs) *pKfs=Kfs;
-	else      delete Kfs;
+	else      xdelete(&Kfs);
 	if(ppf)  *ppf=pf;
-	else      delete pf;
+	else      xdelete(&pf);
 	if(pdf)  *pdf=df;
-	else      delete df;
+	else      xdelete(&df);
 	if(pkmax) *pkmax=kmax;
 }
Index: /issm/branches/trunk-jpl-damage/src/c/modules/UpdateVertexPositionsx/UpdateVertexPositionsx.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/modules/UpdateVertexPositionsx/UpdateVertexPositionsx.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/modules/UpdateVertexPositionsx/UpdateVertexPositionsx.cpp	(revision 11708)
@@ -13,5 +13,5 @@
 
 	int     i;
-	Vec     vz        = NULL;
+	Vector*     vz        = NULL;
 	Vertex *vertex    = NULL;
 	double *thickness = NULL;
@@ -23,5 +23,5 @@
 
 	/*Allocate vector*/
-	vz=NewVec(vertices->NumberOfVertices());
+	vz=new Vector(vertices->NumberOfVertices());
 
 	/*Update verices new geometry: */
@@ -32,6 +32,5 @@
 
 	/*Assemble mesh velocity*/
-	VecAssemblyBegin(vz);
-	VecAssemblyEnd(vz);
+	vz->Assemble();
 
 	/*Update element inputs*/
@@ -41,5 +40,5 @@
 	xfree((void**)&thickness);
 	xfree((void**)&bed);
-	VecFree(&vz);
+	xdelete(&vz);
 	return 1;
 }
Index: /issm/branches/trunk-jpl-damage/src/c/objects/ElementResults/BoolElementResult.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/ElementResults/BoolElementResult.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/ElementResults/BoolElementResult.cpp	(revision 11708)
@@ -185,11 +185,11 @@
 /*}}}*/
 /*FUNCTION BoolElementResult::GetVectorFromResults{{{1*/
-void BoolElementResult::GetVectorFromResults(Vec vector,int* doflist,int* connectivitylist,int numdofs){
+void BoolElementResult::GetVectorFromResults(Vector* vector,int* doflist,int* connectivitylist,int numdofs){
 
 	_error_("cannot return vector on vertices");
 } /*}}}*/
 /*FUNCTION BoolElementResult::GetElementVectorFromResults{{{1*/
-void BoolElementResult::GetElementVectorFromResults(Vec vector,int dof){
+void BoolElementResult::GetElementVectorFromResults(Vector* vector,int dof){
 
-	VecSetValue(vector,dof,(double)value,INSERT_VALUES);
+	vector->SetValue(dof,value,INS_VAL);
 } /*}}}*/
Index: /issm/branches/trunk-jpl-damage/src/c/objects/ElementResults/BoolElementResult.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/ElementResults/BoolElementResult.h	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/ElementResults/BoolElementResult.h	(revision 11708)
@@ -53,6 +53,6 @@
 		/*BoolElementResult management: {{{1*/
 		int   InstanceEnum();
-		void GetVectorFromResults(Vec vector,int* doflist,int* connectivitylist,int numdofs);
-		void GetElementVectorFromResults(Vec vector,int dof);
+		void GetVectorFromResults(Vector* vector,int* doflist,int* connectivitylist,int numdofs);
+		void GetElementVectorFromResults(Vector* vector,int dof);
 		/*}}}*/
 };
Index: /issm/branches/trunk-jpl-damage/src/c/objects/ElementResults/DoubleElementResult.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/ElementResults/DoubleElementResult.h	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/ElementResults/DoubleElementResult.h	(revision 11708)
@@ -53,6 +53,6 @@
 		/*DoubleElementResult management: {{{1*/
 		int   InstanceEnum();
-		void GetVectorFromResults(Vec vector,int* doflist,int* connectivitylist,int numdofs){_error_("not implemented");};
-		void GetElementVectorFromResults(Vec vector,int dof){_error_("not implemented");};
+		void GetVectorFromResults(Vector* vector,int* doflist,int* connectivitylist,int numdofs){_error_("not implemented");};
+		void GetElementVectorFromResults(Vector* vector,int dof){_error_("not implemented");};
 		/*}}}*/
 };
Index: /issm/branches/trunk-jpl-damage/src/c/objects/ElementResults/ElementResult.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/ElementResults/ElementResult.h	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/ElementResults/ElementResult.h	(revision 11708)
@@ -25,6 +25,6 @@
 		virtual void    PatchFill(int row, Patch* patch)=0;
 		virtual int     InstanceEnum()=0;
-		virtual void    GetVectorFromResults(Vec vector,int* doflist,int* connectivitylist,int numdof)=0;
-		virtual void    GetElementVectorFromResults(Vec vector,int dof)=0;
+		virtual void    GetVectorFromResults(Vector* vector,int* doflist,int* connectivitylist,int numdof)=0;
+		virtual void    GetElementVectorFromResults(Vector* vector,int dof)=0;
 
 };
Index: /issm/branches/trunk-jpl-damage/src/c/objects/ElementResults/PentaP1ElementResult.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/ElementResults/PentaP1ElementResult.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/ElementResults/PentaP1ElementResult.cpp	(revision 11708)
@@ -195,5 +195,5 @@
 /*}}}*/
 /*FUNCTION PentaP1ElementResult::GetVectorFromResults{{{1*/
-void PentaP1ElementResult::GetVectorFromResults(Vec vector,int* doflist,int* connectivitylist,int numdofs){
+void PentaP1ElementResult::GetVectorFromResults(Vector* vector,int* doflist,int* connectivitylist,int numdofs){
 
 	double data[6];
@@ -201,9 +201,9 @@
 	if(numdofs!=6)_error_("Result %s is a PentaP1ElementResult and cannot write vector of %i dofs",numdofs);
 	for(int i=0;i<6;i++) data[i]=this->values[i]/(double)connectivitylist[i];
-	VecSetValues(vector,numdofs,doflist,(const double*)&data,ADD_VALUES);
+	vector->SetValues(numdofs,doflist,&data[0],ADD_VAL);
 
 } /*}}}*/
 /*FUNCTION PentaP1ElementResult::GetElementVectorFromResults{{{1*/
-void PentaP1ElementResult::GetElementVectorFromResults(Vec vector,int dof){
+void PentaP1ElementResult::GetElementVectorFromResults(Vector* vector,int dof){
 
 	_error_("Result %s is a PentaP1ElementResult and should not write vector of size numberofelemenrs",EnumToStringx(enum_type));
Index: /issm/branches/trunk-jpl-damage/src/c/objects/ElementResults/PentaP1ElementResult.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/ElementResults/PentaP1ElementResult.h	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/ElementResults/PentaP1ElementResult.h	(revision 11708)
@@ -52,6 +52,6 @@
 		/*PentaP1ElementResult management: {{{1*/
 		int   InstanceEnum();
-		void GetVectorFromResults(Vec vector,int* doflist,int* connectivitylist,int numdofs);
-		void GetElementVectorFromResults(Vec vector,int dof);
+		void GetVectorFromResults(Vector* vector,int* doflist,int* connectivitylist,int numdofs);
+		void GetElementVectorFromResults(Vector* vector,int dof);
 		/*}}}*/
 
Index: /issm/branches/trunk-jpl-damage/src/c/objects/ElementResults/TriaP1ElementResult.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/ElementResults/TriaP1ElementResult.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/ElementResults/TriaP1ElementResult.cpp	(revision 11708)
@@ -184,5 +184,5 @@
 /*}}}*/
 /*FUNCTION TriaP1ElementResult::GetVectorFromResults{{{1*/
-void TriaP1ElementResult::GetVectorFromResults(Vec vector,int* doflist,int* connectivitylist,int numdofs){
+void TriaP1ElementResult::GetVectorFromResults(Vector* vector,int* doflist,int* connectivitylist,int numdofs){
 
 	double data[3];
@@ -190,10 +190,9 @@
 	if(numdofs!=3)_error_("Result %s is a TriaP1ElementResult and cannot write vector of %i dofs",numdofs);
 	for(int i=0;i<3;i++) data[i]=this->values[i]/(double)connectivitylist[i];
-	VecSetValues(vector,numdofs,doflist,(const double*)&data,ADD_VALUES);
+	vector->SetValues(numdofs,doflist,&data[0],ADD_VAL);
 
 } /*}}}*/
 /*FUNCTION TriaP1ElementResult::GetElementVectorFromResults{{{1*/
-void TriaP1ElementResult::GetElementVectorFromResults(Vec vector,int dof){
-
+void TriaP1ElementResult::GetElementVectorFromResults(Vector* vector,int dof){
 	_error_("Result %s is a TriaP1ElementResult and should not write vector of size numberofelemenrs",EnumToStringx(enum_type));
 } /*}}}*/
Index: /issm/branches/trunk-jpl-damage/src/c/objects/ElementResults/TriaP1ElementResult.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/ElementResults/TriaP1ElementResult.h	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/ElementResults/TriaP1ElementResult.h	(revision 11708)
@@ -51,6 +51,6 @@
 		/*TriaP1ElementResult management: {{{1*/
 		int   InstanceEnum();
-		void GetVectorFromResults(Vec vector,int* doflist,int* connectivitylist,int numdofs);
-		void GetElementVectorFromResults(Vec vector,int dof);
+		void GetVectorFromResults(Vector* vector,int* doflist,int* connectivitylist,int numdofs);
+		void GetElementVectorFromResults(Vector* vector,int dof);
 		/*}}}*/
 
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Elements/Element.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Elements/Element.h	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Elements/Element.h	(revision 11708)
@@ -46,6 +46,6 @@
 		virtual double SurfaceArea(void)=0;
 		virtual void   InputDepthAverageAtBase(int enum_type,int average_enum_type,int object_enum)=0;
-		virtual void   ComputeBasalStress(Vec sigma_b)=0;
-		virtual void   ComputeStrainRate(Vec eps)=0;
+		virtual void   ComputeBasalStress(Vector* sigma_b)=0;
+		virtual void   ComputeStrainRate(Vector* eps)=0;
 		virtual void   PatchSize(int* pnumrows, int* pnumvertices,int* pnumnodes)=0;
 		virtual void   PatchFill(int* pcount, Patch* patch)=0;
@@ -62,17 +62,17 @@
 		virtual int    NodalValue(double* pvalue, int index, int natureofdataenum,bool process_units)=0;
 		virtual void   InputScale(int enum_type,double scale_factor)=0;
-		virtual void   GetVectorFromInputs(Vec vector, int name_enum)=0;
-		virtual void   GetVectorFromResults(Vec vector,int id,int interp)=0;
+		virtual void   GetVectorFromInputs(Vector* vector, int name_enum)=0;
+		virtual void   GetVectorFromResults(Vector* vector,int id,int interp)=0;
 		virtual void   InputArtificialNoise(int enum_type,double min,double max)=0;
 		virtual bool   InputConvergence(double* eps, int* enums,int num_enums,int* criterionenums,double* criterionvalues,int num_criterionenums)=0;
-		virtual void   AverageOntoPartition(Vec partition_contributions,Vec partition_areas,double* vertex_response,double* qmu_part)=0;
+		virtual void   AverageOntoPartition(Vector* partition_contributions,Vector* partition_areas,double* vertex_response,double* qmu_part)=0;
 		virtual int*   GetHorizontalNeighboorSids(void)=0;
 		virtual double TimeAdapt()=0;
 		virtual void   MigrateGroundingLine(double* old_floating_ice,double* sheet_ungrounding)=0;
-		virtual void   PotentialSheetUngrounding(Vec potential_sheet_ungrounding)=0;
+		virtual void   PotentialSheetUngrounding(Vector* potential_sheet_ungrounding)=0;
 		virtual void   PositiveDegreeDay(void)=0;
-		virtual int    UpdatePotentialSheetUngrounding(double* potential_sheet_ungrounding,Vec vec_nodes_on_iceshelf,double* nodes_on_iceshelf)=0;
+		virtual int    UpdatePotentialSheetUngrounding(double* potential_sheet_ungrounding,Vector* vec_nodes_on_iceshelf,double* nodes_on_iceshelf)=0;
 		virtual void   ResetCoordinateSystem()=0;
-		virtual void   SmearFunction(Vec smearedvector,double (*WeightFunction)(double distance,double radius),double radius)=0;
+		virtual void   SmearFunction(Vector* smearedvector,double (*WeightFunction)(double distance,double radius),double radius)=0;
 
 		#ifdef _HAVE_RESPONSES_
@@ -94,5 +94,5 @@
 
 		#ifdef _HAVE_CONTROL_
-		virtual void   Gradj(Vec gradient,int control_type,int control_index)=0;
+		virtual void   Gradj(Vector* gradient,int control_type,int control_index)=0;
 		virtual double ThicknessAbsMisfit(bool process_units  ,int weight_index)=0;
 		virtual double SurfaceAbsVelMisfit(bool process_units ,int weight_index)=0;
@@ -104,8 +104,8 @@
 		virtual double RheologyBbarAbsGradient(bool process_units,int weight_index)=0;
 		virtual double DragCoefficientAbsGradient(bool process_units,int weight_index)=0;
-		virtual void   ControlInputGetGradient(Vec gradient,int enum_type,int control_index)=0;
+		virtual void   ControlInputGetGradient(Vector* gradient,int enum_type,int control_index)=0;
 		virtual void   ControlInputSetGradient(double* gradient,int enum_type,int control_index)=0;
 		virtual void   ControlInputScaleGradient(int enum_type, double scale)=0;
-		virtual void   GetVectorFromControlInputs(Vec gradient,int control_enum,int control_index,const char* data)=0;
+		virtual void   GetVectorFromControlInputs(Vector* gradient,int control_enum,int control_index,const char* data)=0;
 		virtual void   SetControlInputsFromVector(double* vector,int control_enum,int control_index)=0;
 		virtual void   InputControlUpdate(double scalar,bool save_parameter)=0;
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Elements/Penta.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Elements/Penta.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Elements/Penta.cpp	(revision 11708)
@@ -302,5 +302,5 @@
 /*Other*/
 /*FUNCTION Penta::AverageOntoPartition {{{1*/
-void  Penta::AverageOntoPartition(Vec partition_contributions,Vec partition_areas,double* vertex_response,double* qmu_part){
+void  Penta::AverageOntoPartition(Vector* partition_contributions,Vector* partition_areas,double* vertex_response,double* qmu_part){
 	_error_("Not supported yet!");
 }
@@ -383,5 +383,5 @@
 /*}}}*/
 /*FUNCTION Penta::ComputeBasalStress {{{1*/
-void  Penta::ComputeBasalStress(Vec sigma_b){
+void  Penta::ComputeBasalStress(Vector* sigma_b){
 
 	int         i,j,ig;
@@ -417,5 +417,5 @@
 	if(!IsOnBed()){
 		//put zero
-		VecSetValue(sigma_b,id-1,0.0,INSERT_VALUES);
+		sigma_b->SetValue(id-1,0.0,INS_VAL);
 		return;
 	}
@@ -469,9 +469,9 @@
 
 	/*Add value to output*/
-	VecSetValue(sigma_b,id-1,value,INSERT_VALUES);
+	sigma_b->SetValue(id-1,value,INS_VAL);
 }
 /*}}}*/
 /*FUNCTION Penta::ComputeStrainRate {{{1*/
-void  Penta::ComputeStrainRate(Vec eps){
+void  Penta::ComputeStrainRate(Vector* eps){
 
 	_error_("Not implemented yet");
@@ -1218,5 +1218,5 @@
 /*}}}*/
 /*FUNCTION Penta::GetVectorFromInputs{{{1*/
-void  Penta::GetVectorFromInputs(Vec vector,int input_enum){
+void  Penta::GetVectorFromInputs(Vector* vector,int input_enum){
 
 	int doflist1[NUMVERTICES];
@@ -1237,5 +1237,5 @@
 /*}}}*/
 /*FUNCTION Penta::GetVectorFromResults{{{1*/
-void  Penta::GetVectorFromResults(Vec vector,int offset,int interp){
+void  Penta::GetVectorFromResults(Vector* vector,int offset,int interp){
 
 	/*Get result*/
@@ -2422,5 +2422,5 @@
 /*}}}*/
 /*FUNCTION Penta::PotentialSheetUngrounding{{{1*/
-void  Penta::PotentialSheetUngrounding(Vec potential_sheet_ungrounding){
+void  Penta::PotentialSheetUngrounding(Vector* potential_sheet_ungrounding){
 
 	int     i;
@@ -2444,5 +2444,5 @@
 			if (bed_hydro>ba[i]){
 				/*Vertex that could potentially unground, flag it*/
-				VecSetValue(potential_sheet_ungrounding,nodes[i]->Sid(),1,INSERT_VALUES);
+				potential_sheet_ungrounding->SetValue(nodes[i]->Sid(),1,INS_VAL);
 			}
 		}
@@ -2942,5 +2942,5 @@
 /*}}}*/
 /*FUNCTION Penta::UpdatePotentialSheetUngrounding{{{1*/
-int Penta::UpdatePotentialSheetUngrounding(double* vertices_potentially_ungrounding,Vec vec_nodes_on_iceshelf,double* nodes_on_iceshelf){
+int Penta::UpdatePotentialSheetUngrounding(double* vertices_potentially_ungrounding,Vector* vec_nodes_on_iceshelf,double* nodes_on_iceshelf){
 
 	int i;
@@ -2950,5 +2950,5 @@
 	for(i=0;i<NUMVERTICES;i++){
 		if (vertices_potentially_ungrounding[nodes[i]->Sid()]){
-			VecSetValue(vec_nodes_on_iceshelf,nodes[i]->Sid(),1,INSERT_VALUES);
+			vec_nodes_on_iceshelf->SetValue(nodes[i]->Sid(),1,INS_VAL);
 		
 			/*If node was not on ice shelf, we flipped*/
@@ -3010,5 +3010,5 @@
 /*}}}*/
 /*FUNCTION Penta::SmearFunction {{{1*/
-void  Penta::SmearFunction(Vec smearedvector,double (*WeightFunction)(double distance,double radius),double radius){
+void  Penta::SmearFunction(Vector* smearedvector,double (*WeightFunction)(double distance,double radius),double radius){
 	_error_("not implemented yet");
 }
@@ -4213,5 +4213,5 @@
 
 	/*Add value to global vector*/
-	solution->SetValues(numdof,doflist,values,INSERT_VALUES);
+	solution->SetValues(numdof,doflist,values,INS_VAL);
 
 	/*Free ressources:*/
@@ -4244,5 +4244,5 @@
 
 	/*Add value to global vector*/
-	solution->SetValues(numdof,doflist,values,INSERT_VALUES);
+	solution->SetValues(numdof,doflist,values,INS_VAL);
 
 	/*Free ressources:*/
@@ -4404,5 +4404,5 @@
 #ifdef _HAVE_CONTROL_
 /*FUNCTION Penta::ControlInputGetGradient{{{1*/
-void Penta::ControlInputGetGradient(Vec gradient,int enum_type,int control_index){
+void Penta::ControlInputGetGradient(Vector* gradient,int enum_type,int control_index){
 
 	int doflist1[NUMVERTICES];
@@ -4729,5 +4729,5 @@
 /*}}}*/
 /*FUNCTION Penta::Gradj {{{1*/
-void  Penta::Gradj(Vec gradient,int control_type,int control_index){
+void  Penta::Gradj(Vector* gradient,int control_type,int control_index){
 	/*dJ/dalpha = ∂L/∂alpha = ∂J/∂alpha + ∂/∂alpha(KU-F)*/
 
@@ -4820,5 +4820,5 @@
 /*}}}*/
 /*FUNCTION Penta::GradjDragMacAyeal {{{1*/
-void  Penta::GradjDragMacAyeal(Vec gradient,int control_index){
+void  Penta::GradjDragMacAyeal(Vector* gradient,int control_index){
 
 	/*Gradient is 0 if on shelf or not on bed*/
@@ -4832,5 +4832,5 @@
 } /*}}}*/
 /*FUNCTION Penta::GradjDragPattyn {{{1*/
-void  Penta::GradjDragPattyn(Vec gradient,int control_index){
+void  Penta::GradjDragPattyn(Vector* gradient,int control_index){
 
 	int        i,j,ig;
@@ -4895,5 +4895,5 @@
 		}
 	}
-	VecSetValues(gradient,NUMVERTICES,doflist1,(const double*)grade_g,ADD_VALUES);
+	gradient->SetValues(NUMVERTICES,doflist1,grade_g,ADD_VAL);
 
 	/*Clean up and return*/
@@ -4903,5 +4903,5 @@
 /*}}}*/
 /*FUNCTION Penta::GradjDragStokes {{{1*/
-void  Penta::GradjDragStokes(Vec gradient,int control_index){
+void  Penta::GradjDragStokes(Vector* gradient,int control_index){
 
 	int        i,j,ig;
@@ -4988,5 +4988,5 @@
 	}
 
-	VecSetValues(gradient,NUMVERTICES,doflist1,(const double*)grade_g,ADD_VALUES);
+	gradient->SetValues(NUMVERTICES,doflist1,grade_g,ADD_VAL);
 
 	delete friction;
@@ -4995,5 +4995,5 @@
 /*}}}*/
 /*FUNCTION Penta::GradjBbarMacAyeal {{{1*/
-void  Penta::GradjBbarMacAyeal(Vec gradient,int control_index){
+void  Penta::GradjBbarMacAyeal(Vector* gradient,int control_index){
 
 	/*This element should be collapsed into a tria element at its base*/
@@ -5013,5 +5013,5 @@
 } /*}}}*/
 /*FUNCTION Penta::GradjBbarPattyn {{{1*/
-void  Penta::GradjBbarPattyn(Vec gradient,int control_index){
+void  Penta::GradjBbarPattyn(Vector* gradient,int control_index){
 
 	/*Gradient is computed on bed only (Bbar)*/
@@ -5030,5 +5030,5 @@
 } /*}}}*/
 /*FUNCTION Penta::GradjBbarStokes {{{1*/
-void  Penta::GradjBbarStokes(Vec gradient,int control_index){
+void  Penta::GradjBbarStokes(Vector* gradient,int control_index){
 
 	/*Gradient is computed on bed only (Bbar)*/
@@ -5406,5 +5406,5 @@
 /*}}}*/
 /*FUNCTION Penta::GetVectorFromControlInputs{{{1*/
-void  Penta::GetVectorFromControlInputs(Vec vector,int control_enum,int control_index,const char* data){
+void  Penta::GetVectorFromControlInputs(Vector* vector,int control_enum,int control_index,const char* data){
 
 	int doflist1[NUMVERTICES];
@@ -7896,5 +7896,5 @@
 
 	/*Add value to global vector*/
-	solution->SetValues(numdof,doflist,values,INSERT_VALUES);
+	solution->SetValues(numdof,doflist,values,INS_VAL);
 
 	/*Free ressources:*/
@@ -7932,5 +7932,5 @@
 
 	/*Add value to global vector*/
-	solution->SetValues(numdof,doflist,values,INSERT_VALUES);
+	solution->SetValues(numdof,doflist,values,INS_VAL);
 
 	/*Free ressources:*/
@@ -7965,5 +7965,5 @@
 
 	/*Add value to global vector*/
-	solution->SetValues(numdof,doflist,values,INSERT_VALUES);
+	solution->SetValues(numdof,doflist,values,INS_VAL);
 
 	/*Free ressources:*/
@@ -8010,5 +8010,5 @@
 
 	/*Add value to global vector*/
-	solution->SetValues(numdof,doflist,values,INSERT_VALUES);
+	solution->SetValues(numdof,doflist,values,INS_VAL);
 
 	/*Free ressources:*/
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Elements/Penta.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Elements/Penta.h	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Elements/Penta.h	(revision 11708)
@@ -79,8 +79,8 @@
 		/*}}}*/
 		/*Element virtual functions definitions: {{{1*/
-		void   AverageOntoPartition(Vec partition_contributions,Vec partition_areas,double* vertex_response,double* qmu_part);
+		void   AverageOntoPartition(Vector* partition_contributions,Vector* partition_areas,double* vertex_response,double* qmu_part);
 		void   BasalFrictionCreateInput(void);
-		void   ComputeBasalStress(Vec sigma_b);
-		void   ComputeStrainRate(Vec eps);
+		void   ComputeBasalStress(Vector* sigma_b);
+		void   ComputeStrainRate(Vector* eps);
 		void   ComputeStressTensor();
 		void   Configure(Elements* elements,Loads* loads,DataSet* nodes,Materials* materials,Parameters* parameters);
@@ -93,6 +93,6 @@
 		void   GetSolutionFromInputs(Vector* solution);
 		double GetZcoord(GaussPenta* gauss);
-		void   GetVectorFromInputs(Vec vector,int name_enum);
-		void   GetVectorFromResults(Vec vector,int offset,int interp);
+		void   GetVectorFromInputs(Vector* vector,int name_enum);
+		void   GetVectorFromResults(Vector* vector,int offset,int interp);
 		
 		int    Sid();
@@ -107,5 +107,5 @@
 		void   InputToResult(int enum_type,int step,double time);
 		void   MigrateGroundingLine(double* old_floating_ice,double* sheet_ungrounding);
-		void   PotentialSheetUngrounding(Vec potential_sheet_ungrounding);
+		void   PotentialSheetUngrounding(Vector* potential_sheet_ungrounding);
 		void   RequestedOutput(int output_enum,int step,double time);
 		void   ListResultsInfo(int** results_enums,int** results_size,double** results_times,int** results_steps,int* num_results);
@@ -117,10 +117,10 @@
 		double SurfaceArea(void);
 		void   Update(int index, IoModel* iomodel,int analysis_counter,int analysis_type);
-		int    UpdatePotentialSheetUngrounding(double* potential_sheet_ungrounding,Vec vec_nodes_on_iceshelf,double* nodes_on_iceshelf);
+		int    UpdatePotentialSheetUngrounding(double* potential_sheet_ungrounding,Vector* vec_nodes_on_iceshelf,double* nodes_on_iceshelf);
 		int    NodalValue(double* pvalue, int index, int natureofdataenum,bool process_units);
 		double TimeAdapt();
 		int*   GetHorizontalNeighboorSids(void);
 		void   ViscousHeatingCreateInput(void);
-		void   SmearFunction(Vec smearedvector,double (*WeightFunction)(double distance,double radius),double radius);
+		void   SmearFunction(Vector* smearedvector,double (*WeightFunction)(double distance,double radius),double radius);
 
 		 #ifdef _HAVE_RESPONSES_
@@ -144,14 +144,14 @@
 		double DragCoefficientAbsGradient(bool process_units,int weight_index);
 		void   GradientIndexing(int* indexing,int control_index);
-		void   Gradj(Vec gradient,int control_type,int control_index);
-		void   GradjDragMacAyeal(Vec gradient,int control_index);
-		void   GradjDragPattyn(Vec gradient,int control_index);
-		void   GradjDragStokes(Vec gradient,int control_index);
-		void   GradjBbarMacAyeal(Vec gradient,int control_index);
-		void   GradjBbarPattyn(Vec gradient,int control_index);
-		void   GradjBbarStokes(Vec gradient,int control_index);
-		void   GetVectorFromControlInputs(Vec gradient,int control_enum,int control_index,const char* data);
+		void   Gradj(Vector* gradient,int control_type,int control_index);
+		void   GradjDragMacAyeal(Vector* gradient,int control_index);
+		void   GradjDragPattyn(Vector* gradient,int control_index);
+		void   GradjDragStokes(Vector* gradient,int control_index);
+		void   GradjBbarMacAyeal(Vector* gradient,int control_index);
+		void   GradjBbarPattyn(Vector* gradient,int control_index);
+		void   GradjBbarStokes(Vector* gradient,int control_index);
+		void   GetVectorFromControlInputs(Vector* gradient,int control_enum,int control_index,const char* data);
 		void   SetControlInputsFromVector(double* vector,int control_enum,int control_index);
-		void   ControlInputGetGradient(Vec gradient,int enum_type,int control_index);
+		void   ControlInputGetGradient(Vector* gradient,int enum_type,int control_index);
 		void   ControlInputScaleGradient(int enum_type,double scale);
 		void   ControlInputSetGradient(double* gradient,int enum_type,int control_index);
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Elements/Tria.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Elements/Tria.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Elements/Tria.cpp	(revision 11708)
@@ -279,5 +279,5 @@
 /*Other*/
 /*FUNCTION Tria::AverageOntoPartition {{{1*/
-void  Tria::AverageOntoPartition(Vec partition_contributions,Vec partition_areas,double* vertex_response,double* qmu_part){
+void  Tria::AverageOntoPartition(Vector* partition_contributions,Vector* partition_areas,double* vertex_response,double* qmu_part){
 
 	bool      already=false;
@@ -312,6 +312,6 @@
 		}
 		if(!already){
-			VecSetValue(partition_contributions,partition[i],mean*area,ADD_VALUES);
-			VecSetValue(partition_areas,partition[i],area,ADD_VALUES);
+			partition_contributions->SetValue(partition[i],mean*area,ADD_VAL);
+			partition_areas->SetValue(partition[i],area,ADD_VAL);
 		};
 	}
@@ -925,10 +925,10 @@
 /*}}}*/
 /*FUNCTION Tria::ComputeBasalStress {{{1*/
-void  Tria::ComputeBasalStress(Vec eps){
+void  Tria::ComputeBasalStress(Vector* eps){
 	_error_("Not Implemented yet");
 }
 /*}}}*/
 /*FUNCTION Tria::ComputeStrainRate {{{1*/
-void  Tria::ComputeStrainRate(Vec eps){
+void  Tria::ComputeStrainRate(Vector* eps){
 	_error_("Not Implemented yet");
 }
@@ -1324,5 +1324,5 @@
 /*}}}*/
 /*FUNCTION Tria::GetVectorFromInputs{{{1*/
-void  Tria::GetVectorFromInputs(Vec vector,int input_enum){
+void  Tria::GetVectorFromInputs(Vector* vector,int input_enum){
 
 	int doflist1[NUMVERTICES];
@@ -1343,5 +1343,5 @@
 /*}}}*/
 /*FUNCTION Tria::GetVectorFromResults{{{1*/
-void  Tria::GetVectorFromResults(Vec vector,int offset,int interp){
+void  Tria::GetVectorFromResults(Vector* vector,int offset,int interp){
 
 	/*Get result*/
@@ -2207,5 +2207,5 @@
 /*}}}*/
 /*FUNCTION Tria::PotentialSheetUngrounding{{{1*/
-void  Tria::PotentialSheetUngrounding(Vec potential_sheet_ungrounding){
+void  Tria::PotentialSheetUngrounding(Vector* potential_sheet_ungrounding){
 
 	int     i;
@@ -2229,5 +2229,5 @@
 			if (bed_hydro>ba[i]){
 				/*Vertex that could potentially unground, flag it*/
-				VecSetValue(potential_sheet_ungrounding,nodes[i]->Sid(),1,INSERT_VALUES);
+				potential_sheet_ungrounding->SetValue(nodes[i]->Sid(),1,INS_VAL);
 			}
 		}
@@ -2287,5 +2287,5 @@
 /*}}}1*/
 /*FUNCTION Tria::SmearFunction {{{1*/
-void  Tria::SmearFunction(Vec smearedvector,double (*WeightFunction)(double distance,double radius),double radius){
+void  Tria::SmearFunction(Vector*  smearedvector,double (*WeightFunction)(double distance,double radius),double radius){
 	_error_("not implemented yet");
 
@@ -2508,5 +2508,5 @@
 /*}}}*/
 /*FUNCTION Tria::UpdatePotentialSheetUngrounding{{{1*/
-int Tria::UpdatePotentialSheetUngrounding(double* vertices_potentially_ungrounding,Vec vec_nodes_on_iceshelf,double* nodes_on_iceshelf){
+int Tria::UpdatePotentialSheetUngrounding(double* vertices_potentially_ungrounding,Vector* vec_nodes_on_iceshelf,double* nodes_on_iceshelf){
 
 	int i;
@@ -2516,5 +2516,5 @@
 	for(i=0;i<3;i++){
 		if (vertices_potentially_ungrounding[nodes[i]->Sid()]){
-			VecSetValue(vec_nodes_on_iceshelf,nodes[i]->Sid(),1,INSERT_VALUES);
+			vec_nodes_on_iceshelf->SetValue(nodes[i]->Sid(),1,INS_VAL);
 		
 			/*If node was not on ice shelf, we flipped*/
@@ -3174,5 +3174,5 @@
 	}
 
-	solution->SetValues(numdof,doflist,values,INSERT_VALUES);
+	solution->SetValues(numdof,doflist,values,INS_VAL);
 
 	/*Free ressources:*/
@@ -3213,5 +3213,5 @@
 	}
 
-	solution->SetValues(numdof,doflist,values,INSERT_VALUES);
+	solution->SetValues(numdof,doflist,values,INS_VAL);
 
 	/*Free ressources:*/
@@ -3381,5 +3381,5 @@
 /*}}}*/
 /*FUNCTION Tria::ControlInputGetGradient{{{1*/
-void Tria::ControlInputGetGradient(Vec gradient,int enum_type,int control_index){
+void Tria::ControlInputGetGradient(Vector* gradient,int enum_type,int control_index){
 
 	int doflist1[NUMVERTICES];
@@ -3440,5 +3440,5 @@
 }/*}}}*/
 /*FUNCTION Tria::Gradj {{{1*/
-void  Tria::Gradj(Vec gradient,int control_type,int control_index){
+void  Tria::Gradj(Vector* gradient,int control_type,int control_index){
 	/*dJ/dalpha = ∂L/∂alpha = ∂J/∂alpha + ∂/∂alpha(KU-F)*/
 
@@ -3502,5 +3502,5 @@
 /*}}}*/
 /*FUNCTION Tria::GradjBGradient{{{1*/
-void  Tria::GradjBGradient(Vec gradient,int weight_index,int control_index){
+void  Tria::GradjBGradient(Vector* gradient,int weight_index,int control_index){
 
 	int        i,ig;
@@ -3535,5 +3535,5 @@
 		for (i=0;i<NUMVERTICES;i++) grade_g[i]+=-weight*Jdet*gauss->weight*(dbasis[0][i]*dk[0]+dbasis[1][i]*dk[1]);
 	}
-	VecSetValues(gradient,NUMVERTICES,doflist1,(const double*)grade_g,ADD_VALUES);
+	gradient->SetValues(NUMVERTICES,doflist1,grade_g,ADD_VAL);
 
 	/*Clean up and return*/
@@ -3542,5 +3542,5 @@
 /*}}}*/
 /*FUNCTION Tria::GradjZGradient{{{1*/
-void  Tria::GradjZGradient(Vec gradient,int weight_index,int control_index){
+void  Tria::GradjZGradient(Vector* gradient,int weight_index,int control_index){
 
 	int        i,ig;
@@ -3575,5 +3575,5 @@
 		for (i=0;i<NUMVERTICES;i++) grade_g[i]+=-weight*Jdet*gauss->weight*(dbasis[0][i]*dk[0]+dbasis[1][i]*dk[1]);
 	}
-	VecSetValues(gradient,NUMVERTICES,doflist1,(const double*)grade_g,ADD_VALUES);
+	gradient->SetValues(NUMVERTICES,doflist1,grade_g,ADD_VAL);
 
 	/*Clean up and return*/
@@ -3582,5 +3582,5 @@
 /*}}}*/
 /*FUNCTION Tria::GradjBMacAyeal{{{1*/
-void  Tria::GradjBMacAyeal(Vec gradient,int control_index){
+void  Tria::GradjBMacAyeal(Vector* gradient,int control_index){
 
 	/*Intermediaries*/
@@ -3632,5 +3632,5 @@
 	}
 
-	VecSetValues(gradient,NUMVERTICES,doflist,(const double*)grad,ADD_VALUES);
+	gradient->SetValues(NUMVERTICES,doflist,grad,ADD_VAL);
 
 	/*clean-up*/
@@ -3639,5 +3639,5 @@
 /*}}}*/
 /*FUNCTION Tria::GradjZMacAyeal{{{1*/
-void  Tria::GradjZMacAyeal(Vec gradient,int control_index){
+void  Tria::GradjZMacAyeal(Vector* gradient,int control_index){
 
 	/*Intermediaries*/
@@ -3689,5 +3689,5 @@
 	}
 
-	VecSetValues(gradient,NUMVERTICES,doflist,(const double*)grad,ADD_VALUES);
+	gradient->SetValues(NUMVERTICES,doflist,grad,ADD_VAL);
 
 	/*clean-up*/
@@ -3696,5 +3696,5 @@
 /*}}}*/
 /*FUNCTION Tria::GradjDragMacAyeal {{{1*/
-void  Tria::GradjDragMacAyeal(Vec gradient,int control_index){
+void  Tria::GradjDragMacAyeal(Vector* gradient,int control_index){
 
 	int        i,ig;
@@ -3776,5 +3776,5 @@
 	/*End Analytical gradient*/
 
-	VecSetValues(gradient,NUMVERTICES,doflist1,(const double*)grade_g,ADD_VALUES);
+	gradient->SetValues(NUMVERTICES,doflist1,grade_g,ADD_VAL);
 
 	/*Clean up and return*/
@@ -3784,5 +3784,5 @@
 /*}}}*/
 /*FUNCTION Tria::GradjDragGradient{{{1*/
-void  Tria::GradjDragGradient(Vec gradient, int weight_index,int control_index){
+void  Tria::GradjDragGradient(Vector* gradient, int weight_index,int control_index){
 
 	int        i,ig;
@@ -3821,5 +3821,5 @@
 		}
 	}
-	VecSetValues(gradient,NUMVERTICES,doflist1,(const double*)grade_g,ADD_VALUES);
+	gradient->SetValues(NUMVERTICES,doflist1,grade_g,ADD_VAL);
 
 	/*Clean up and return*/
@@ -3828,5 +3828,5 @@
 /*}}}*/
 /*FUNCTION Tria::GradjDhDtBalancedthickness{{{1*/
-void  Tria::GradjDhDtBalancedthickness(Vec gradient,int control_index){
+void  Tria::GradjDhDtBalancedthickness(Vector* gradient,int control_index){
 
 	/*Intermediaries*/
@@ -3840,9 +3840,9 @@
 	for(int i=0;i<NUMVERTICES;i++) gradient_g[i]=-lambda[i];
 
-	VecSetValues(gradient,NUMVERTICES,doflist1,(const double*)gradient_g,INSERT_VALUES);
+	gradient->SetValues(NUMVERTICES,doflist1,gradient_g,INS_VAL);
 }
 /*}}}*/
 /*FUNCTION Tria::GradjVxBalancedthickness{{{1*/
-void  Tria::GradjVxBalancedthickness(Vec gradient,int control_index){
+void  Tria::GradjVxBalancedthickness(Vector* gradient,int control_index){
 
 	/*Intermediaries*/
@@ -3880,5 +3880,5 @@
 	}
 
-	VecSetValues(gradient,NUMVERTICES,doflist1,(const double*)grade_g,ADD_VALUES);
+	gradient->SetValues(NUMVERTICES,doflist1,grade_g,ADD_VAL);
 
 	/*Clean up and return*/
@@ -3887,5 +3887,5 @@
 /*}}}*/
 /*FUNCTION Tria::GradjVyBalancedthickness{{{1*/
-void  Tria::GradjVyBalancedthickness(Vec gradient,int control_index){
+void  Tria::GradjVyBalancedthickness(Vector* gradient,int control_index){
 
 	/*Intermediaries*/
@@ -3922,5 +3922,5 @@
 		for(i=0;i<NUMVERTICES;i++) grade_g[i]+=thickness*Dlambda[1]*Jdet*gauss->weight*basis[i];
 	}
-	VecSetValues(gradient,NUMVERTICES,doflist1,(const double*)grade_g,ADD_VALUES);
+	gradient->SetValues(NUMVERTICES,doflist1,grade_g,ADD_VAL);
 
 	/*Clean up and return*/
@@ -5016,5 +5016,5 @@
 /*}}}*/
 /*FUNCTION Tria::GetVectorFromControlInputs{{{1*/
-void  Tria::GetVectorFromControlInputs(Vec vector,int control_enum,int control_index,const char* data){
+void  Tria::GetVectorFromControlInputs(Vector* vector,int control_enum,int control_index,const char* data){
 
 	int doflist1[NUMVERTICES];
@@ -5318,5 +5318,5 @@
 	}
 
-	solution->SetValues(numdof,doflist,values,INSERT_VALUES);
+	solution->SetValues(numdof,doflist,values,INS_VAL);
 
 	/*Free ressources:*/
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Elements/Tria.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Elements/Tria.h	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Elements/Tria.h	(revision 11708)
@@ -76,7 +76,7 @@
 		/*}}}*/
 		/*Element virtual functions definitions: {{{1*/
-		void   AverageOntoPartition(Vec partition_contributions,Vec partition_areas,double* vertex_response,double* qmu_part);
-		void   ComputeBasalStress(Vec sigma_b);
-		void   ComputeStrainRate(Vec eps);
+		void   AverageOntoPartition(Vector* partition_contributions,Vector* partition_areas,double* vertex_response,double* qmu_part);
+		void   ComputeBasalStress(Vector* sigma_b);
+		void   ComputeStrainRate(Vector* eps);
 		void   ComputeStressTensor();
 		void   Configure(Elements* elements,Loads* loads,DataSet* nodes,Materials* materials,Parameters* parameters);
@@ -93,6 +93,6 @@
 		bool   IsOnWater(); 
 		void   GetSolutionFromInputs(Vector* solution);
-		void   GetVectorFromInputs(Vec vector, int name_enum);
-		void   GetVectorFromResults(Vec vector,int offset,int interp);
+		void   GetVectorFromInputs(Vector* vector, int name_enum);
+		void   GetVectorFromResults(Vector* vector,int offset,int interp);
 		void   InputArtificialNoise(int enum_type,double min, double max);
 		bool   InputConvergence(double* eps, int* enums,int num_enums,int* criterionenums,double* criterionvalues,int num_criterionenums);
@@ -107,5 +107,5 @@
 		void   MigrateGroundingLine(double* oldfloating,double* sheet_ungrounding);
 		int    NodalValue(double* pvalue, int index, int natureofdataenum,bool process_units);
-		void   PotentialSheetUngrounding(Vec potential_sheet_ungrounding);
+		void   PotentialSheetUngrounding(Vector* potential_sheet_ungrounding);
 		void   PositiveDegreeDay(void);
 		void   RequestedOutput(int output_enum,int step,double time);
@@ -117,8 +117,8 @@
 		double SurfaceArea(void);
 		void   Update(int index, IoModel* iomodel,int analysis_counter,int analysis_type);
-		int    UpdatePotentialSheetUngrounding(double* vertices_potentially_ungrounding,Vec vec_nodes_on_iceshelf,double* nodes_on_iceshelf);
+		int    UpdatePotentialSheetUngrounding(double* vertices_potentially_ungrounding,Vector* vec_nodes_on_iceshelf,double* nodes_on_iceshelf);
 		double TimeAdapt();
 		int*   GetHorizontalNeighboorSids(void);
-		void   SmearFunction(Vec smearedvector,double (*WeightFunction)(double distance,double radius),double radius);
+		void   SmearFunction(Vector* smearedvector,double (*WeightFunction)(double distance,double radius),double radius);
 
 		#ifdef _HAVE_RESPONSES_
@@ -143,18 +143,18 @@
 		double DragCoefficientAbsGradient(bool process_units,int weight_index);
 		void   GradientIndexing(int* indexing,int control_index);
-		void   Gradj(Vec gradient,int control_type,int control_index);
-		void   GradjBGradient(Vec gradient,int weight_index,int control_index);
-		void   GradjZGradient(Vec gradient,int weight_index,int control_index);
-		void   GradjBMacAyeal(Vec gradient,int control_index);
-		void   GradjZMacAyeal(Vec gradient,int control_index);
-		void   GradjDragMacAyeal(Vec gradient,int control_index);
-		void   GradjDragStokes(Vec gradient,int control_index);
-		void   GradjDragGradient(Vec gradient,int weight_index,int control_index);
-		void   GradjDhDtBalancedthickness(Vec gradient,int control_index);
-		void   GradjVxBalancedthickness(Vec gradient,int control_index);
-		void   GradjVyBalancedthickness(Vec gradient,int control_index);
-		void   GetVectorFromControlInputs(Vec gradient,int control_enum,int control_index,const char* data);
+		void   Gradj(Vector* gradient,int control_type,int control_index);
+		void   GradjBGradient(Vector* gradient,int weight_index,int control_index);
+		void   GradjZGradient(Vector* gradient,int weight_index,int control_index);
+		void   GradjBMacAyeal(Vector* gradient,int control_index);
+		void   GradjZMacAyeal(Vector* gradient,int control_index);
+		void   GradjDragMacAyeal(Vector* gradient,int control_index);
+		void   GradjDragStokes(Vector* gradient,int control_index);
+		void   GradjDragGradient(Vector* gradient,int weight_index,int control_index);
+		void   GradjDhDtBalancedthickness(Vector* gradient,int control_index);
+		void   GradjVxBalancedthickness(Vector* gradient,int control_index);
+		void   GradjVyBalancedthickness(Vector* gradient,int control_index);
+		void   GetVectorFromControlInputs(Vector* gradient,int control_enum,int control_index,const char* data);
 		void   SetControlInputsFromVector(double* vector,int control_enum,int control_index);
-		void   ControlInputGetGradient(Vec gradient,int enum_type,int control_index);
+		void   ControlInputGetGradient(Vector* gradient,int enum_type,int control_index);
 		void   ControlInputScaleGradient(int enum_type,double scale);
 		void   ControlInputSetGradient(double* gradient,int enum_type,int control_index);
Index: /issm/branches/trunk-jpl-damage/src/c/objects/ExternalResults/PetscVecExternalResult.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/ExternalResults/PetscVecExternalResult.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/ExternalResults/PetscVecExternalResult.cpp	(revision 11708)
@@ -27,5 +27,5 @@
 /*}}}*/
 /*FUNCTION PetscVecExternalResult::PetscVecExternalResult(int enum_type,IssmPetscVec value){{{1*/
-PetscVecExternalResult::PetscVecExternalResult(int in_id, int in_enum_type,Vec in_value,int in_step, double in_time){
+PetscVecExternalResult::PetscVecExternalResult(int in_id, int in_enum_type,Vector* in_value,int in_step, double in_time){
 
 	id=in_id;
@@ -35,6 +35,6 @@
 
 	if(in_value){
-		VecDuplicate(in_value,&value);
-		VecCopy(in_value,value);
+		value=in_value->Duplicate();
+		in_value->Copy(value);
 	}
 	else value=NULL;
Index: /issm/branches/trunk-jpl-damage/src/c/objects/ExternalResults/PetscVecExternalResult.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/ExternalResults/PetscVecExternalResult.h	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/ExternalResults/PetscVecExternalResult.h	(revision 11708)
@@ -33,5 +33,5 @@
 		int id;
 		int enum_type;
-		Vec value;
+		Vector* value;
 		int step;
 		double time;
@@ -40,5 +40,5 @@
 		/*PetscVecExternalResult constructors, destructors: {{{1*/
 		PetscVecExternalResult();
-		PetscVecExternalResult(int id,int enum_type,Vec value, int step, double time);
+		PetscVecExternalResult(int id,int enum_type,Vector* value, int step, double time);
 		~PetscVecExternalResult();
 		/*}}}*/
Index: /issm/branches/trunk-jpl-damage/src/c/objects/FemModel.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/FemModel.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/FemModel.cpp	(revision 11708)
@@ -144,4 +144,5 @@
 	this->loads->SetCurrentConfiguration(elements, loads, nodes,vertices, materials,parameters);
 
+	#ifdef _HAVE_PETSC_
 	/*take care of petsc options, that depend on this analysis type (present only after model processor)*/
 	if(this->parameters->Exist(PetscOptionsStringsEnum)){
@@ -149,4 +150,5 @@
 		_printf_(VerboseSolver(),"      petsc Options set for analysis type: %s\n",EnumToStringx(analysis_type));
 	}
+	#endif
 
 }
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/BoolInput.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/BoolInput.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/BoolInput.cpp	(revision 11708)
@@ -233,5 +233,5 @@
 /*}}}*/
 /*FUNCTION BoolInput::GetVectorFromInputs{{{1*/
-void BoolInput::GetVectorFromInputs(Vec vector,int* doflist){
+void BoolInput::GetVectorFromInputs(Vector* vector,int* doflist){
 
 	_error_(" not supporte yet!");
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/BoolInput.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/BoolInput.h	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/BoolInput.h	(revision 11708)
@@ -81,5 +81,5 @@
 		void Extrude(void);
 		void VerticallyIntegrate(Input* thickness_input){_error_("not supported yet");};
-		void GetVectorFromInputs(Vec vector,int* doflist);
+		void GetVectorFromInputs(Vector* vector,int* doflist);
 		void GetValuesPtr(double** pvalues,int* pnum_values);
 		/*}}}*/
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/ControlInput.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/ControlInput.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/ControlInput.cpp	(revision 11708)
@@ -355,5 +355,5 @@
 }/*}}}*/
 /*FUNCTION ControlInput::GetGradient{{{1*/
-void ControlInput::GetGradient(Vec gradient_vec,int* doflist){
+void ControlInput::GetGradient(Vector* gradient_vec,int* doflist){
 	if(gradient) gradient->GetVectorFromInputs(gradient_vec,doflist);
 }/*}}}*/
@@ -406,10 +406,10 @@
 	return gradient->SpawnResult(step,time);
 }/*}}}*/
-/*FUNCTION ControlInput::GetVectorFromInputs(Vec vector,int* doflist){{{1*/
-void ControlInput::GetVectorFromInputs(Vec vector,int* doflist){
+/*FUNCTION ControlInput::GetVectorFromInputs(Vector* vector,int* doflist){{{1*/
+void ControlInput::GetVectorFromInputs(Vector* vector,int* doflist){
 	values->GetVectorFromInputs(vector,doflist);
 }/*}}}*/
-/*FUNCTION ControlInput::GetVectorFromInputs(Vec vector,int* doflist,const char* data){{{1*/
-void ControlInput::GetVectorFromInputs(Vec vector,int* doflist,const char* data){
+/*FUNCTION ControlInput::GetVectorFromInputs(Vector* vector,int* doflist,const char* data){{{1*/
+void ControlInput::GetVectorFromInputs(Vector* vector,int* doflist,const char* data){
 	 if(strcmp(data,"value")==0){
 		 _assert_(values);
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/ControlInput.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/ControlInput.h	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/ControlInput.h	(revision 11708)
@@ -87,9 +87,9 @@
 		void Extrude(void);
 		void VerticallyIntegrate(Input* thickness_input);
-		void GetVectorFromInputs(Vec vector,int* doflist,const char* data);
-		void GetVectorFromInputs(Vec vector,int* doflist);
+		void GetVectorFromInputs(Vector* vector,int* doflist,const char* data);
+		void GetVectorFromInputs(Vector* vector,int* doflist);
 		void GetValuesPtr(double** pvalues,int* pnum_values){_error_("not implemented yet");};
 		ElementResult* SpawnGradient(int step, double time);
-		void GetGradient(Vec gradient_vec,int* doflist);
+		void GetGradient(Vector* gradient_vec,int* doflist);
 		void ScaleGradient(double scale);
 		void SetGradient(Input* gradient_in);
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/DatasetInput.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/DatasetInput.h	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/DatasetInput.h	(revision 11708)
@@ -82,8 +82,8 @@
 		void Extrude(void){_error_("not implemented yet");};
 		void VerticallyIntegrate(Input* thickness_input){_error_("not implemented yet");};
-		void GetVectorFromInputs(Vec vector,int* doflist){_error_("not implemented yet");};
+		void GetVectorFromInputs(Vector* vector,int* doflist){_error_("not implemented yet");};
 		void GetValuesPtr(double** pvalues,int* pnum_values){_error_("not implemented yet");};
 		ElementResult* SpawnGradient(int step, double time){_error_("not implemented yet");};
-		void GetGradient(Vec gradient_vec,int* doflist){_error_("not implemented yet");};
+		void GetGradient(Vector* gradient_vec,int* doflist){_error_("not implemented yet");};
 		void ScaleGradient(double scale){_error_("not implemented yet");};
 		void SetGradient(Input* gradient_in){_error_("not implemented yet");};
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/DoubleInput.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/DoubleInput.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/DoubleInput.cpp	(revision 11708)
@@ -310,5 +310,5 @@
 /*}}}*/
 /*FUNCTION DoubleInput::GetVectorFromInputs{{{1*/
-void DoubleInput::GetVectorFromInputs(Vec vector,int* doflist){
+void DoubleInput::GetVectorFromInputs(Vector* vector,int* doflist){
 
 	_error_(" not supporte yet!");
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/DoubleInput.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/DoubleInput.h	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/DoubleInput.h	(revision 11708)
@@ -80,5 +80,5 @@
 		void Extrude(void){_error_("not supported yet");};
 		void VerticallyIntegrate(Input* thickness_input);
-		void GetVectorFromInputs(Vec vector,int* doflist);
+		void GetVectorFromInputs(Vector* vector,int* doflist);
 		void GetValuesPtr(double** pvalues,int* pnum_values);
 		/*}}}*/
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/Input.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/Input.h	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/Input.h	(revision 11708)
@@ -56,5 +56,5 @@
 		virtual void   VerticallyIntegrate(Input* thickness_input)=0;
 		virtual void   Extrude()=0;
-		virtual void   GetVectorFromInputs(Vec vector,int* doflist)=0;
+		virtual void   GetVectorFromInputs(Vector* vector,int* doflist)=0;
 		virtual void   GetValuesPtr(double** pvalues,int* pnum_values)=0;
 		
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/IntInput.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/IntInput.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/IntInput.cpp	(revision 11708)
@@ -231,5 +231,5 @@
 /*}}}*/
 /*FUNCTION IntInput::GetVectorFromInputs{{{1*/
-void IntInput::GetVectorFromInputs(Vec vector,int* doflist){
+void IntInput::GetVectorFromInputs(Vector* vector,int* doflist){
 
 	_error_(" not supporte yet!");
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/IntInput.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/IntInput.h	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/IntInput.h	(revision 11708)
@@ -81,5 +81,5 @@
 		void Extrude(void){_error_("not supported yet");};
 		void VerticallyIntegrate(Input* thickness_input){_error_("not supported yet");};
-		void GetVectorFromInputs(Vec vector,int* doflist);
+		void GetVectorFromInputs(Vector* vector,int* doflist);
 		void GetValuesPtr(double** pvalues,int* pnum_values);
 		/*}}}*/
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/PentaP1Input.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/PentaP1Input.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/PentaP1Input.cpp	(revision 11708)
@@ -660,8 +660,8 @@
 /*}}}*/
 /*FUNCTION PentaP1Input::GetVectorFromInputs{{{1*/
-void PentaP1Input::GetVectorFromInputs(Vec vector,int* doflist){
+void PentaP1Input::GetVectorFromInputs(Vector* vector,int* doflist){
 
 	const int numvertices=6;
-	VecSetValues(vector,numvertices,doflist,(const double*)this->values,INSERT_VALUES);
+	vector->SetValues(numvertices,doflist,this->values,INS_VAL);
 
 } /*}}}*/
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/PentaP1Input.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/PentaP1Input.h	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/PentaP1Input.h	(revision 11708)
@@ -82,5 +82,5 @@
 		void Extrude(void);
 		void VerticallyIntegrate(Input* thickness_input);
-		void GetVectorFromInputs(Vec vector,int* doflist);
+		void GetVectorFromInputs(Vector* vector,int* doflist);
 		void GetValuesPtr(double** pvalues,int* pnum_values);
 		/*}}}*/
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/TransientInput.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/TransientInput.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/TransientInput.cpp	(revision 11708)
@@ -440,5 +440,5 @@
 /*}}}*/
 /*FUNCTION TransientInput::GetVectorFromInputs{{{1*/
-void TransientInput::GetVectorFromInputs(Vec vector,int* doflist){
+void TransientInput::GetVectorFromInputs(Vector* vector,int* doflist){
 
 	double time;
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/TransientInput.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/TransientInput.h	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/TransientInput.h	(revision 11708)
@@ -84,5 +84,5 @@
 		void Extrude(void){_error_("not supported yet");}
 		void VerticallyIntegrate(Input* thickness_forcing){_error_("not supported yet");};
-		void GetVectorFromInputs(Vec vector,int* doflist);
+		void GetVectorFromInputs(Vector* vector,int* doflist);
 		void GetValuesPtr(double** pvalues,int* pnum_values){_error_("not supported yet");};
       void GetTimeValues(double* values,double time){_error_("not implemented yet");};
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/TriaP1Input.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/TriaP1Input.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/TriaP1Input.cpp	(revision 11708)
@@ -391,8 +391,8 @@
 /*}}}*/
 /*FUNCTION TriaP1Input::GetVectorFromInputs{{{1*/
-void TriaP1Input::GetVectorFromInputs(Vec vector,int* doflist){
+void TriaP1Input::GetVectorFromInputs(Vector* vector,int* doflist){
 
 	const int numvertices=3;
-	VecSetValues(vector,numvertices,doflist,(const double*)this->values,INSERT_VALUES);
+	vector->SetValues(numvertices,doflist,this->values,INS_VAL);
 
 } /*}}}*/
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/TriaP1Input.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/TriaP1Input.h	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Inputs/TriaP1Input.h	(revision 11708)
@@ -82,5 +82,5 @@
 		void Extrude(void){_error_("not supported yet");};
 		void VerticallyIntegrate(Input* thickness_input){_error_("not supported yet");};
-		void GetVectorFromInputs(Vec vector,int* doflist);
+		void GetVectorFromInputs(Vector* vector,int* doflist);
 		void GetValuesPtr(double** pvalues,int* pnum_values);
 		/*}}}*/
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Materials/Material.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Materials/Material.h	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Materials/Material.h	(revision 11708)
@@ -22,5 +22,5 @@
 		virtual void   InputDuplicate(int original_enum,int new_enum)=0;
 		virtual void   Configure(Elements* elements)=0;
-		virtual void   GetVectorFromInputs(Vec vector,int input_enum)=0;
+		virtual void   GetVectorFromInputs(Vector* vector,int input_enum)=0;
 
 };
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Materials/Matice.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Materials/Matice.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Materials/Matice.cpp	(revision 11708)
@@ -249,5 +249,5 @@
 /*}}}*/
 /*FUNCTION Matice::GetVectorFromInputs{{{1*/
-void  Matice::GetVectorFromInputs(Vec vector,int input_enum){
+void  Matice::GetVectorFromInputs(Vector* vector,int input_enum){
 
 	/*Intermediaries*/
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Materials/Matice.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Materials/Matice.h	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Materials/Matice.h	(revision 11708)
@@ -60,5 +60,5 @@
 		void   InputDuplicate(int original_enum,int new_enum);
 		void   Configure(Elements* elements);
-		void   GetVectorFromInputs(Vec vector,int input_enum);
+		void   GetVectorFromInputs(Vector* vector,int input_enum);
 		/*}}}*/
 		/*Matice Numerics: {{{1*/
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Materials/Matpar.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Materials/Matpar.h	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Materials/Matpar.h	(revision 11708)
@@ -71,5 +71,5 @@
 		void   InputDuplicate(int original_enum,int new_enum){_error_("not implemented yet");};
 		void   Configure(Elements* elements);
-		void   GetVectorFromInputs(Vec vector,int input_enum){return;}
+		void   GetVectorFromInputs(Vector* vector,int input_enum){return;}
 		/*}}}*/
 		/*Numerics: {{{1*/
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Node.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Node.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Node.cpp	(revision 11708)
@@ -568,5 +568,5 @@
 /*}}}*/
 /*FUNCTION Node::CreateVecSets {{{1*/
-void  Node::CreateVecSets(Vec pv_g,Vec pv_f,Vec pv_s){
+void  Node::CreateVecSets(Vector* pv_g,Vector* pv_f,Vector* pv_s){
 
 	double gvalue=1.0; //all nodes are in the g set;
@@ -578,13 +578,13 @@
 
 		/*g set: */
-		VecSetValues(pv_g,1,&indexing.gdoflist[i],&gvalue,INSERT_VALUES);
+		pv_g->SetValue(indexing.gdoflist[i],gvalue,INS_VAL);
 		
 		/*f set: */
 		value=(double)this->indexing.f_set[i];
-		VecSetValues(pv_f,1,&indexing.gdoflist[i],&value,INSERT_VALUES);
+		pv_f->SetValue(indexing.gdoflist[i],value,INS_VAL);
 
 		/*s set: */
 		value=(double)this->indexing.s_set[i];
-		VecSetValues(pv_s,1,&indexing.gdoflist[i],&value,INSERT_VALUES);
+		pv_s->SetValue(indexing.gdoflist[i],value,INS_VAL);
 
 	}
@@ -613,5 +613,5 @@
 		
 		/*Add values into constraint vector: */
-		ys->SetValues(this->indexing.ssize,this->indexing.sdoflist,values,INSERT_VALUES);
+		ys->SetValues(this->indexing.ssize,this->indexing.sdoflist,values,INS_VAL);
 	}
 
@@ -897,5 +897,5 @@
 
 			/*Add values into ug: */
-			ug->SetValues(this->indexing.fsize,indices,values,INSERT_VALUES);
+			ug->SetValues(this->indexing.fsize,indices,values,INS_VAL);
 		}
 	}
@@ -915,5 +915,5 @@
 
 			/*Add values into ug: */
-			ug->SetValues(this->indexing.ssize,indices,values,INSERT_VALUES);
+			ug->SetValues(this->indexing.ssize,indices,values,INS_VAL);
 		}
 	}
@@ -945,5 +945,5 @@
 
 			/*Add values into ug: */
-			vector->SetValues(this->indexing.fsize,this->indexing.fdoflist,values,INSERT_VALUES);
+			vector->SetValues(this->indexing.fsize,this->indexing.fdoflist,values,INS_VAL);
 		}
 	}
@@ -961,5 +961,5 @@
 
 			/*Add values into ug: */
-			vector->SetValues(this->indexing.ssize,this->indexing.sdoflist,values,INSERT_VALUES);
+			vector->SetValues(this->indexing.ssize,this->indexing.sdoflist,values,INS_VAL);
 		}
 	}
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Node.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Node.h	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Node.h	(revision 11708)
@@ -87,5 +87,5 @@
 		void   DofInFSet(int dof);
 		int    GetDof(int dofindex,int setenum);
-		void   CreateVecSets(Vec pv_g,Vec pv_f,Vec pv_s);
+		void   CreateVecSets(Vector* pv_g,Vector* pv_f,Vector* pv_s);
 		int    GetConnectivity();
 		void   GetDofList(int* poutdoflist,int approximation_enum,int setenum);
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Numerics/Matrix.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Numerics/Matrix.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Numerics/Matrix.cpp	(revision 11708)
@@ -17,5 +17,7 @@
 #include "../../Container/Container.h"
 #include "../../include/include.h"
+#include "../../toolkits/toolkits.h"
 #include "./Matrix.h"
+	
 /*}}}*/
 
@@ -61,4 +63,37 @@
 	#ifdef _HAVE_PETSC_
 	this->matrix=NewMat(pM,pN,sparsity);
+	#else
+	this->matrix=(double*)xcalloc(pM*pN,sizeof(double));
+	#endif
+	#ifdef _HAVE_ADOLC_
+	this->amatrix=(adouble*)xmalloc(pM*pN*sizeof(adouble));
+	#endif
+}
+/*}}}*/
+/*FUNCTION Matrix::Matrix(double* serial_mat, int M,int N,double sparsity){{{1*/
+Matrix::Matrix(double* serial_mat, int pM,int pN,double sparsity){
+
+	this->M=pM;
+	this->N=pN;
+
+	#ifdef _HAVE_PETSC_
+	int     i;
+	int*    idxm=NULL;
+	int*    idxn=NULL;
+
+	this->matrix=NewMat(pM,pN,sparsity);
+
+	idxm=(int*)xmalloc(M*sizeof(int));
+	idxn=(int*)xmalloc(N*sizeof(int));
+	for(i=0;i<M;i++)idxm[i]=i;
+	for(i=0;i<N;i++)idxn[i]=i;
+
+	MatSetValues(this->matrix,M,idxm,N,idxn,serial_mat,INSERT_VALUES);
+
+	MatAssemblyBegin(this->matrix,MAT_FINAL_ASSEMBLY);
+	MatAssemblyEnd(this->matrix,MAT_FINAL_ASSEMBLY);
+
+	xfree((void**)&idxm);
+	xfree((void**)&idxn);
 	#else
 	this->matrix=(double*)xcalloc(pM*pN,sizeof(double));
@@ -160,9 +195,9 @@
 /*}}}*/
 /*FUNCTION Matrix::Norm{{{1*/
-double Matrix::Norm(int norm_type){
+double Matrix::Norm(NormMode norm_type){
 	
 	double norm=0;
 	#ifdef _HAVE_PETSC_
-	    MatNorm(this->matrix,(NormType)norm_type,&norm);
+	    MatNorm(this->matrix,ISSMToPetscNormMode(norm_type),&norm);
 	#else
 		_error_("not implemented yet!");
@@ -201,2 +236,29 @@
 }
 /*}}}*/
+/*FUNCTION Matrix::Duplicate{{{1*/
+Matrix* Matrix::Duplicate(void){
+
+	Matrix* output=NULL;
+
+	output=new Matrix();
+
+	#ifdef _HAVE_PETSC
+		MatDuplicate(this->matrix,MAT_COPY_VALUES,&output->matrix);
+	#else
+		_error_("not implemented yet!");
+	#endif
+}
+/*}}}*/
+/*FUNCTION Matrix::ToSerial{{{1*/
+double* Matrix::ToSerial(void){
+
+	double* output=NULL;
+
+	#ifdef _HAVE_PETSC
+		MatToSerial(&output,this->matrix);
+	#else
+		_error_("not implemented yet!");
+	#endif
+	return output;
+}
+/*}}}*/
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Numerics/Matrix.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Numerics/Matrix.h	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Numerics/Matrix.h	(revision 11708)
@@ -14,5 +14,4 @@
 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
 #endif
-#include "../Object.h"
 #include "../../toolkits/toolkits.h"
 #include "../../EnumDefinitions/EnumDefinitions.h"
@@ -48,4 +47,5 @@
 		Matrix(int M,int N);
 		Matrix(int M,int N,double sparsity);
+		Matrix(double* serial_mat,int M,int N,double sparsity);
 		Matrix(int M,int N,int connectivity,int numberofdofspernode);
 		~Matrix();
@@ -57,8 +57,10 @@
 		#endif
 		void Assemble(void);
-		double Norm(int norm_type);
+		double Norm(NormMode norm_type);
 		void GetSize(int* pM,int* pN);
 		void GetLocalSize(int* pM,int* pN);
 		void MatMult(Vector* X,Vector* AX);
+		Matrix* Duplicate(void);
+		double* ToSerial(void);
 		/*}}}*/
 
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Numerics/Vector.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Numerics/Vector.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Numerics/Vector.cpp	(revision 11708)
@@ -17,4 +17,5 @@
 #include "../../Container/Container.h"
 #include "../../include/include.h"
+#include "../../toolkits/toolkits.h"
 #include "./Vector.h"
 /*}}}*/
@@ -49,5 +50,47 @@
 }
 /*}}}*/
-/*FUNCTION Vector::~Vector(){{{1*/
+/*FUNCTION Vector::Vector(double* serial_vec,int M){{{1*/
+Vector::Vector(double* serial_vec,int pM){
+
+	int i,j;
+
+	#ifdef _HAVE_PETSC_
+		int* idxm=NULL;
+
+		this->vector=NewVec(pM);
+		
+		idxm=(int*)xmalloc(M*sizeof(int));
+		for(i=0;i<M;i++)idxm[i]=i;
+		VecSetValues(this->vector,M,idxm,serial_vec,INSERT_VALUES);
+
+		VecAssemblyBegin(this->vector);
+		VecAssemblyEnd(this->vector);
+
+		xfree((void**)&idxm);
+
+	#else
+		this->M=pM;
+		this->vector=(double*)xcalloc(pM,sizeof(double));
+	#endif
+	#ifdef _HAVE_ADOLC_
+		this->avector=(adouble*)xmalloc(pM*sizeof(adouble));
+	#endif
+}
+/*}}}*/
+#ifdef _HAVE_PETSC_
+/*FUNCTION Vector::Vector(Vec petsc_vec){{{1*/
+Vector::Vector(Vec petsc_vec){
+
+	/*Get Vector size*/
+	VecGetSize(petsc_vec,&this->M);
+
+	/*copy vector*/
+	VecDuplicate(petsc_vec,&this->vector);
+	VecCopy(petsc_vec,this->vector);
+
+}
+/*}}}*/
+#endif
+		/*FUNCTION Vector::~Vector(){{{1*/
 Vector::~Vector(){
 
@@ -116,15 +159,40 @@
 /*}}}*/
 /*FUNCTION Vector::SetValues{{{1*/
-void Vector::SetValues(int ssize, int* list, double* values, int mode){
-		
-		
-	#ifdef _HAVE_PETSC_
-	VecSetValues(this->vector,ssize,list,values,(InsertMode)mode);
-	#else
-		_error_("not implemented yet!");
-	#endif
-
-}
-/*}}}*/
+void Vector::SetValues(int ssize, int* list, double* values, InsMode mode){
+		
+		
+	#ifdef _HAVE_PETSC_
+		VecSetValues(this->vector,ssize,list,values,ISSMToPetscInsertMode(mode));
+	#else
+		_error_("not implemented yet!");
+	#endif
+
+}
+/*}}}*/
+/*FUNCTION Vector::SetValue{{{1*/
+void Vector::SetValue(int dof, double value, InsMode mode){
+		
+		
+	#ifdef _HAVE_PETSC_
+		VecSetValues(this->vector,1,&dof,&value,ISSMToPetscInsertMode(mode));
+	#else
+		_error_("not implemented yet!");
+	#endif
+
+}
+/*}}}*/
+/*FUNCTION Vector::GetValue{{{1*/
+void Vector::GetValue(double* pvalue,int dof){
+		
+		
+	#ifdef _HAVE_PETSC_
+	VecGetValues(this->vector,1,&dof,pvalue);
+	#else
+		_error_("not implemented yet!");
+	#endif
+
+}
+/*}}}*/
+		
 /*FUNCTION Vector::GetSize{{{1*/
 void Vector::GetSize(int* pM){
@@ -170,5 +238,5 @@
 	
 	#ifdef _HAVE_PETSC_
-		this->Set(value);
+		VecSet(this->vector,value);
 	#else
 		_error_("not implemented yet!");
@@ -185,5 +253,4 @@
 		_error_("not implemented yet!");
 	#endif
-
 }
 /*}}}*/
@@ -226,9 +293,9 @@
 /*}}}*/
 /*FUNCTION Vector::Norm{{{1*/
-double Vector::Norm(int norm_type){
+double Vector::Norm(NormMode norm_type){
 	
 	double norm=0;
 	#ifdef _HAVE_PETSC_
-	    VecNorm(this->vector,(NormType)norm_type,&norm);
+	    VecNorm(this->vector,ISSMToPetscNormMode(norm_type),&norm);
 	#else
 		_error_("not implemented yet!");
@@ -247,2 +314,24 @@
 }
 /*}}}*/
+/*FUNCTION Vector::Scale{{{1*/
+double Vector::Dot(Vector* vector){
+
+	double dot;
+	#ifdef _HAVE_PETSC_
+	    VecDot(this->vector,vector->vector,&dot);
+	#else
+		_error_("not implemented yet!");
+	#endif
+	return dot;
+}
+/*}}}*/
+/*FUNCTION Vector::PointwiseDivide{{{1*/
+void Vector::PointwiseDivide(Vector* x,Vector* y){
+
+	#ifdef _HAVE_PETSC_
+		VecPointwiseDivide(this->vector,x->vector,y->vector);
+	#else
+		_error_("not implemented yet!");
+	#endif
+}
+/*}}}*/
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Numerics/Vector.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Numerics/Vector.h	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Numerics/Vector.h	(revision 11708)
@@ -14,5 +14,4 @@
 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
 #endif
-#include "../Object.h"
 #include "../../toolkits/toolkits.h"
 #include "../../EnumDefinitions/EnumDefinitions.h"
@@ -22,5 +21,4 @@
 #endif
 		
-
 #ifdef _SERIAL_
 #include "mex.h"
@@ -47,4 +45,8 @@
 		Vector();
 		Vector(int M,bool fromlocalsize=false);
+		Vector(double* serial_vec,int pM);
+		#ifdef _HAVE_PETSC_
+		Vector(Vec petsc_vec);
+		#endif
 		~Vector();
 		/*}}}*/
@@ -55,5 +57,7 @@
 		#endif
 		void Assemble(void);
-		void SetValues(int ssize, int* list, double* values, int mode);
+		void SetValues(int ssize, int* list, double* values, InsMode mode);
+		void SetValue(int dof, double value, InsMode  mode);
+		void GetValue(double* pvalue, int dof);
 		void GetSize(int* pM);
 		void GetLocalSize(int* pM);
@@ -64,6 +68,8 @@
 		double* ToMPISerial(void);
 		void Copy(Vector* to);
-		double Norm(int norm_type);
+		double Norm(NormMode norm_type);
 		void Scale(double scale_factor);
+		void PointwiseDivide(Vector* x,Vector* y);
+		double Dot(Vector* vector);
 		/*}}}*/
 };
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Params/BoolParam.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Params/BoolParam.h	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Params/BoolParam.h	(revision 11708)
@@ -61,6 +61,6 @@
 		void  GetParameterValue(double** pdoublearray,int* pM, int* pN){_error_("Bool param of enum %i (%s) cannot return a double array",enum_type,EnumToStringx(enum_type));}
 		void  GetParameterValue(double*** parray, int* pM,int** pmdims, int** pndims){_error_("Bool param of enum %i (%s) cannot return a matrix array",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(Vec* pvec){_error_("Bool param of enum %i (%s) cannot return a Vec",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(Mat* pmat){_error_("Bool param of enum %i (%s) cannot return a Mat",enum_type,EnumToStringx(enum_type));}
+		void  GetParameterValue(Vector** pvec){_error_("Bool param of enum %i (%s) cannot return a Vec",enum_type,EnumToStringx(enum_type));}
+		void  GetParameterValue(Matrix** pmat){_error_("Bool param of enum %i (%s) cannot return a Mat",enum_type,EnumToStringx(enum_type));}
 		void  GetParameterValue(FILE** pfid){_error_("Bool param of enum %i (%s) cannot return a FILE",enum_type,EnumToStringx(enum_type));}
 
@@ -74,6 +74,6 @@
 		void  SetValue(int* intarray,int M){_error_("Bool param of enum %i (%s) cannot hold a int array",enum_type,EnumToStringx(enum_type));}
 		void  SetValue(int* pintarray,int M,int N){_error_("Bool param of enum %i (%s) cannot hold a int array",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(Vec vec){_error_("Bool param of enum %i (%s) cannot hold a Vec",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(Mat mat){_error_("Bool param of enum %i (%s) cannot hold a Mat",enum_type,EnumToStringx(enum_type));}
+		void  SetValue(Vector* vec){_error_("Bool param of enum %i (%s) cannot hold a Vec",enum_type,EnumToStringx(enum_type));}
+		void  SetValue(Matrix* mat){_error_("Bool param of enum %i (%s) cannot hold a Mat",enum_type,EnumToStringx(enum_type));}
 		void  SetValue(FILE* fid){_error_("Bool param of enum %i (%s) cannot hold a FILE",enum_type,EnumToStringx(enum_type));}
 		void  SetValue(double** array, int M, int* mdim_array, int* ndim_array){_error_("Bool param of enum %i (%s) cannot hold an array of matrices",enum_type,EnumToStringx(enum_type));}
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Params/DoubleMatArrayParam.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Params/DoubleMatArrayParam.h	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Params/DoubleMatArrayParam.h	(revision 11708)
@@ -64,6 +64,6 @@
 		void  GetParameterValue(double** pdoublearray,int* pM, int* pN){_error_("DoubleMatArray param of enum %i (%s) cannot return a double array",enum_type,EnumToStringx(enum_type));}
 		void  GetParameterValue(double*** parray, int* pM,int** pmdims, int** pndims);
-		void  GetParameterValue(Vec* pvec){_error_("DoubleMatArray param of enum %i (%s) cannot return a Vec",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(Mat* pmat){_error_("DoubleMatArray param of enum %i (%s) cannot return a Mat",enum_type,EnumToStringx(enum_type));}
+		void  GetParameterValue(Vector** pvec){_error_("DoubleMatArray param of enum %i (%s) cannot return a Vec",enum_type,EnumToStringx(enum_type));}
+		void  GetParameterValue(Matrix** pmat){_error_("DoubleMatArray param of enum %i (%s) cannot return a Mat",enum_type,EnumToStringx(enum_type));}
 		void  GetParameterValue(FILE** pfid){_error_("DoubleMatArray param of enum %i (%s) cannot return a FILE",enum_type,EnumToStringx(enum_type));}
 
@@ -77,6 +77,6 @@
 		void  SetValue(int* intarray,int M){_error_("DoubleMatArray param of enum %i (%s) cannot hold a int vec array",enum_type,EnumToStringx(enum_type));}
 		void  SetValue(int* intarray,int M,int N){_error_("DoubleMatArray param of enum %i (%s) cannot hold a int mat array",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(Vec vec){_error_("DoubleMatArray param of enum %i (%s) cannot hold a Vec",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(Mat mat){_error_("DoubleMatArray param of enum %i (%s) cannot hold a Mat",enum_type,EnumToStringx(enum_type));}
+		void  SetValue(Vector* vec){_error_("DoubleMatArray param of enum %i (%s) cannot hold a Vec",enum_type,EnumToStringx(enum_type));}
+		void  SetValue(Matrix* mat){_error_("DoubleMatArray param of enum %i (%s) cannot hold a Mat",enum_type,EnumToStringx(enum_type));}
 		void  SetValue(FILE* fid){_error_("Bool param of enum %i (%s) cannot hold a FILE",enum_type,EnumToStringx(enum_type));}
 		void  SetValue(double** array, int M, int* mdim_array, int* ndim_array);
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Params/DoubleMatParam.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Params/DoubleMatParam.h	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Params/DoubleMatParam.h	(revision 11708)
@@ -63,6 +63,6 @@
 		void  GetParameterValue(double** pdoublearray,int* pM,int* pN);
 		void  GetParameterValue(double*** parray, int* pM,int** pmdims, int** pndims){_error_("DoubleMat param of enum %i (%s) cannot return a matrix array",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(Vec* pvec){_error_("DoubleMat param of enum %i (%s) cannot return a Vec",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(Mat* pmat){_error_("DoubleMat param of enum %i (%s) cannot return a Mat",enum_type,EnumToStringx(enum_type));}
+		void  GetParameterValue(Vector** pvec){_error_("DoubleMat param of enum %i (%s) cannot return a Vec",enum_type,EnumToStringx(enum_type));}
+		void  GetParameterValue(Matrix** pmat){_error_("DoubleMat param of enum %i (%s) cannot return a Mat",enum_type,EnumToStringx(enum_type));}
 		void  GetParameterValue(FILE** pfid){_error_("DoubleMat param of enum %i (%s) cannot return a FILE",enum_type,EnumToStringx(enum_type));}
 
@@ -76,6 +76,6 @@
 		void  SetValue(int* intarray,int M){_error_("DoubleMat param of enum %i (%s) cannot hold a int vec array",enum_type,EnumToStringx(enum_type));}
 		void  SetValue(int* intarray,int M,int N){_error_("DoubleMat param of enum %i (%s) cannot hold a int mat array",enum_type,EnumToStringx(enum_type));};
-		void  SetValue(Vec vec){_error_("DoubleMat param of enum %i (%s) cannot hold a Vec",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(Mat mat){_error_("DoubleMat param of enum %i (%s) cannot hold a Mat",enum_type,EnumToStringx(enum_type));}
+		void  SetValue(Vector* vec){_error_("DoubleMat param of enum %i (%s) cannot hold a Vec",enum_type,EnumToStringx(enum_type));}
+		void  SetValue(Matrix* mat){_error_("DoubleMat param of enum %i (%s) cannot hold a Mat",enum_type,EnumToStringx(enum_type));}
 		void  SetValue(FILE* fid){_error_("DoubleMat param of enum %i (%s) cannot hold a FILE",enum_type,EnumToStringx(enum_type));}
 		void  SetValue(double** array, int M, int* mdim_array, int* ndim_array){_error_("DoubleMat param of enum %i (%s) cannot hold an array of matrices",enum_type,EnumToStringx(enum_type));}
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Params/DoubleParam.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Params/DoubleParam.h	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Params/DoubleParam.h	(revision 11708)
@@ -62,6 +62,6 @@
 		void  GetParameterValue(double** pdoublearray,int* pM, int* pN);
 		void  GetParameterValue(double*** parray, int* pM,int** pmdims, int** pndims){_error_("Double param of enum %i (%s) cannot return a matrix array",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(Vec* pvec){_error_("Double param of enum %i (%s) cannot return a Vec",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(Mat* pmat){_error_("Double param of enum %i (%s) cannot return a Mat",enum_type,EnumToStringx(enum_type));}
+		void  GetParameterValue(Vector** pvec){_error_("Double param of enum %i (%s) cannot return a Vec",enum_type,EnumToStringx(enum_type));}
+		void  GetParameterValue(Matrix** pmat){_error_("Double param of enum %i (%s) cannot return a Mat",enum_type,EnumToStringx(enum_type));}
 		void  GetParameterValue(FILE** pfid){_error_("Double param of enum %i (%s) cannot return a FILE",enum_type,EnumToStringx(enum_type));}
 
@@ -75,6 +75,6 @@
 		void  SetValue(int* intarray,int M){_error_("Double param of enum %i (%s) cannot hold a int array",enum_type,EnumToStringx(enum_type));}
 		void  SetValue(int* pintarray,int M,int N){_error_("Double param of enum %i (%s) cannot hold a int array",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(Vec vec){_error_("Double param of enum %i (%s) cannot hold a Vec",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(Mat mat){_error_("Double param of enum %i (%s) cannot hold a Mat",enum_type,EnumToStringx(enum_type));}
+		void  SetValue(Vector* vec){_error_("Double param of enum %i (%s) cannot hold a Vec",enum_type,EnumToStringx(enum_type));}
+		void  SetValue(Matrix* mat){_error_("Double param of enum %i (%s) cannot hold a Mat",enum_type,EnumToStringx(enum_type));}
 		void  SetValue(FILE* fid){_error_("Double param of enum %i (%s) cannot hold a FILE",enum_type,EnumToStringx(enum_type));}
 		void  SetValue(double** array, int M, int* mdim_array, int* ndim_array){_error_("Double param of enum %i (%s) cannot hold an array of matrices",enum_type,EnumToStringx(enum_type));}
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Params/DoubleVecParam.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Params/DoubleVecParam.h	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Params/DoubleVecParam.h	(revision 11708)
@@ -62,6 +62,6 @@
 		void  GetParameterValue(double** pdoublearray,int* pM, int* pN);
 		void  GetParameterValue(double*** parray, int* pM,int** pmdims, int** pndims){_error_("DoubleVec param of enum %i (%s) cannot return a matrix array",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(Vec* pvec){_error_("DoubleVec param of enum %i (%s) cannot return a Vec",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(Mat* pmat){_error_("DoubleVec param of enum %i (%s) cannot return a Mat",enum_type,EnumToStringx(enum_type));}
+		void  GetParameterValue(Vector** pvec){_error_("DoubleVec param of enum %i (%s) cannot return a Vec",enum_type,EnumToStringx(enum_type));}
+		void  GetParameterValue(Matrix** pmat){_error_("DoubleVec param of enum %i (%s) cannot return a Mat",enum_type,EnumToStringx(enum_type));}
 		void  GetParameterValue(FILE** pfid){_error_("DoubleVec param of enum %i (%s) cannot return a FILE",enum_type,EnumToStringx(enum_type));}
 
@@ -75,6 +75,6 @@
 		void  SetValue(int* intarray,int M){_error_("DoubleVec param of enum %i (%s) cannot hold a int mat array",enum_type,EnumToStringx(enum_type));};
 		void  SetValue(int* pintarray,int M,int N){_error_("DoubleVec param of enum %i (%s) cannot hold a int mat array",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(Vec vec){_error_("DoubleVec param of enum %i (%s) cannot hold a Vec",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(Mat mat){_error_("DoubleVec param of enum %i (%s) cannot hold a Mat",enum_type,EnumToStringx(enum_type));}
+		void  SetValue(Vector* vec){_error_("DoubleVec param of enum %i (%s) cannot hold a Vec",enum_type,EnumToStringx(enum_type));}
+		void  SetValue(Matrix* mat){_error_("DoubleVec param of enum %i (%s) cannot hold a Mat",enum_type,EnumToStringx(enum_type));}
 		void  SetValue(FILE* fid){_error_("DoubleVec param of enum %i (%s) cannot hold a FILE",enum_type,EnumToStringx(enum_type));}
 		void  SetValue(double** array, int M, int* mdim_array, int* ndim_array){_error_("DoubleVec param of enum %i (%s) cannot hold an array of matrices",enum_type,EnumToStringx(enum_type));}
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Params/FileParam.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Params/FileParam.h	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Params/FileParam.h	(revision 11708)
@@ -61,6 +61,6 @@
 		void  GetParameterValue(double** pdoublearray,int* pM, int* pN){_error_("FileParam of enum %i (%s) cannot return a double array",enum_type,EnumToStringx(enum_type));}
 		void  GetParameterValue(double*** parray, int* pM,int** pmdims, int** pndims){_error_("File param of enum %i (%s) cannot return a matrix array",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(Vec* pvec){_error_("FileParam of enum %i (%s) cannot return a Vec",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(Mat* pmat){_error_("FileParam of enum %i (%s) cannot return a Mat",enum_type,EnumToStringx(enum_type));}
+		void  GetParameterValue(Vector** pvec){_error_("FileParam of enum %i (%s) cannot return a Vec",enum_type,EnumToStringx(enum_type));}
+		void  GetParameterValue(Matrix** pmat){_error_("FileParam of enum %i (%s) cannot return a Mat",enum_type,EnumToStringx(enum_type));}
 		void  GetParameterValue(FILE** pfid){*pfid=value;};
 
@@ -74,6 +74,6 @@
 		void  SetValue(int* intarray,int M){_error_("FileParam of enum %i (%s) cannot hold a int array",enum_type,EnumToStringx(enum_type));}
 		void  SetValue(int* pintarray,int M,int N){_error_("FileParam of enum %i (%s) cannot hold a int array",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(Vec vec){_error_("FileParam of enum %i (%s) cannot hold a Vec",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(Mat mat){_error_("FileParam of enum %i (%s) cannot hold a Mat",enum_type,EnumToStringx(enum_type));}
+		void  SetValue(Vector* vec){_error_("FileParam of enum %i (%s) cannot hold a Vec",enum_type,EnumToStringx(enum_type));}
+		void  SetValue(Matrix* mat){_error_("FileParam of enum %i (%s) cannot hold a Mat",enum_type,EnumToStringx(enum_type));}
 		void  SetValue(FILE* fid){_error_("File param of enum %i (%s) cannot hold a FILE",enum_type,EnumToStringx(enum_type));}
 		void  SetValue(double** array, int M, int* mdim_array, int* ndim_array){_error_("File param of enum %i (%s) cannot hold an array of matrices",enum_type,EnumToStringx(enum_type));}
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Params/IntMatParam.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Params/IntMatParam.h	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Params/IntMatParam.h	(revision 11708)
@@ -63,6 +63,6 @@
 		void  GetParameterValue(double** pdoublearray,int* pM,int* pN){_error_("IntMat param of enum %i (%s) cannot return a matrix array",enum_type,EnumToStringx(enum_type));};
 		void  GetParameterValue(double*** parray, int* pM,int** pmdims, int** pndims){_error_("IntMat param of enum %i (%s) cannot return a matrix array",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(Vec* pvec){_error_("IntMat param of enum %i (%s) cannot return a Vec",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(Mat* pmat){_error_("IntMat param of enum %i (%s) cannot return a Mat",enum_type,EnumToStringx(enum_type));}
+		void  GetParameterValue(Vector** pvec){_error_("IntMat param of enum %i (%s) cannot return a Vec",enum_type,EnumToStringx(enum_type));}
+		void  GetParameterValue(Matrix** pmat){_error_("IntMat param of enum %i (%s) cannot return a Mat",enum_type,EnumToStringx(enum_type));}
 		void  GetParameterValue(FILE** pfid){_error_("IntMat param of enum %i (%s) cannot return a FILE",enum_type,EnumToStringx(enum_type));}
 
@@ -76,6 +76,6 @@
 		void  SetValue(int* intarray,int M){_error_("IntMat param of enum %i (%s) cannot hold a int vec array",enum_type,EnumToStringx(enum_type));};
 		void  SetValue(int* intarray,int M,int N);
-		void  SetValue(Vec vec){_error_("IntMat param of enum %i (%s) cannot hold a Vec",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(Mat mat){_error_("IntMat param of enum %i (%s) cannot hold a Mat",enum_type,EnumToStringx(enum_type));}
+		void  SetValue(Vector* vec){_error_("IntMat param of enum %i (%s) cannot hold a Vec",enum_type,EnumToStringx(enum_type));}
+		void  SetValue(Matrix* mat){_error_("IntMat param of enum %i (%s) cannot hold a Mat",enum_type,EnumToStringx(enum_type));}
 		void  SetValue(FILE* fid){_error_("IntMat param of enum %i (%s) cannot hold a FILE",enum_type,EnumToStringx(enum_type));}
 		void  SetValue(double** array, int M, int* mdim_array, int* ndim_array){_error_("IntMat param of enum %i (%s) cannot hold an array of matrices",enum_type,EnumToStringx(enum_type));}
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Params/IntParam.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Params/IntParam.h	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Params/IntParam.h	(revision 11708)
@@ -62,6 +62,6 @@
 		void  GetParameterValue(double** pdoublearray,int* pM, int* pN){_error_("Int param of enum %i (%s) cannot return a double array",enum_type,EnumToStringx(enum_type));}
 		void  GetParameterValue(double*** parray, int* pM,int** pmdims, int** pndims){_error_("Int param of enum %i (%s) cannot return a matrix array",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(Vec* pvec){_error_("Int param of enum %i (%s) cannot return a Vec",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(Mat* pmat){_error_("Int param of enum %i (%s) cannot return a Mat",enum_type,EnumToStringx(enum_type));}
+		void  GetParameterValue(Vector** pvec){_error_("Int param of enum %i (%s) cannot return a Vec",enum_type,EnumToStringx(enum_type));}
+		void  GetParameterValue(Matrix** pmat){_error_("Int param of enum %i (%s) cannot return a Mat",enum_type,EnumToStringx(enum_type));}
 		void  GetParameterValue(FILE** pfid){_error_("Int param of enum %i (%s) cannot return a FILE",enum_type,EnumToStringx(enum_type));}
 
@@ -75,6 +75,6 @@
 		void  SetValue(double* doublearray,int M){_error_("Int param of enum %i (%s) cannot hold a double array",enum_type,EnumToStringx(enum_type));}
 		void  SetValue(double* pdoublearray,int M,int N){_error_("Int param of enum %i (%s) cannot hold a double array",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(Vec vec){_error_("Int param of enum %i (%s) cannot hold a Vec",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(Mat mat){_error_("Int param of enum %i (%s) cannot hold a Mat",enum_type,EnumToStringx(enum_type));}
+		void  SetValue(Vector* vec){_error_("Int param of enum %i (%s) cannot hold a Vec",enum_type,EnumToStringx(enum_type));}
+		void  SetValue(Matrix* mat){_error_("Int param of enum %i (%s) cannot hold a Mat",enum_type,EnumToStringx(enum_type));}
 		void  SetValue(FILE* fid){_error_("Int param of enum %i (%s) cannot hold a FILE",enum_type,EnumToStringx(enum_type));}
 		void  SetValue(double** array, int M, int* mdim_array, int* ndim_array){_error_("Int param of enum %i (%s) cannot hold an array of matrices",enum_type,EnumToStringx(enum_type));}
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Params/IntVecParam.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Params/IntVecParam.h	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Params/IntVecParam.h	(revision 11708)
@@ -63,6 +63,6 @@
 		void  GetParameterValue(double** pdoublearray,int* pM, int* pN){_error_("IntVec param of enum %i (%s) cannot return a double array",enum_type,EnumToStringx(enum_type));}
 		void  GetParameterValue(double*** parray, int* pM,int** pmdims, int** pndims){_error_("IntVec param of enum %i (%s) cannot return a matrix array",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(Vec* pvec){_error_("IntVec param of enum %i (%s) cannot return a Vec",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(Mat* pmat){_error_("IntVec param of enum %i (%s) cannot return a Mat",enum_type,EnumToStringx(enum_type));}
+		void  GetParameterValue(Vector** pvec){_error_("IntVec param of enum %i (%s) cannot return a Vec",enum_type,EnumToStringx(enum_type));}
+		void  GetParameterValue(Matrix** pmat){_error_("IntVec param of enum %i (%s) cannot return a Mat",enum_type,EnumToStringx(enum_type));}
 		void  GetParameterValue(FILE** pfid){_error_("IntVec param of enum %i (%s) cannot return a FILE",enum_type,EnumToStringx(enum_type));}
 
@@ -76,6 +76,6 @@
 		void  SetValue(int* intarray,int M);
 		void  SetValue(int* pintarray,int M,int N){_error_("IntVec param of enum %i (%s) cannot hold a int mat array",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(Vec vec){_error_("IntVec param of enum %i (%s) cannot hold a Vec",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(Mat mat){_error_("IntVec param of enum %i (%s) cannot hold a Mat",enum_type,EnumToStringx(enum_type));}
+		void  SetValue(Vector* vec){_error_("IntVec param of enum %i (%s) cannot hold a Vec",enum_type,EnumToStringx(enum_type));}
+		void  SetValue(Matrix* mat){_error_("IntVec param of enum %i (%s) cannot hold a Mat",enum_type,EnumToStringx(enum_type));}
 		void  SetValue(FILE* fid){_error_("IntVec param of enum %i (%s) cannot hold a FILE",enum_type,EnumToStringx(enum_type));}
 		void  SetValue(double** array, int M, int* mdim_array, int* ndim_array){_error_("IntVec param of enum %i (%s) cannot hold an array of matrices",enum_type,EnumToStringx(enum_type));}
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Params/MatrixParam.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Params/MatrixParam.cpp	(revision 11708)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Params/MatrixParam.cpp	(revision 11708)
@@ -0,0 +1,227 @@
+/*!\file MatrixParam.c
+ * \brief: implementation of the MatrixParam object
+ */
+
+/*header files: */
+/*{{{1*/
+#ifdef HAVE_CONFIG_H
+	#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+#include <stdio.h>
+#include <string.h>
+#include "../objects.h"
+#include "../../EnumDefinitions/EnumDefinitions.h"
+#include "../../shared/shared.h"
+#include "../../Container/Container.h"
+#include "../../include/include.h"
+/*}}}*/
+
+/*MatrixParam constructors and destructor*/
+/*FUNCTION MatrixParam::MatrixParam(){{{1*/
+MatrixParam::MatrixParam(){
+	return;
+}
+/*}}}*/
+/*FUNCTION MatrixParam::MatrixParam(int enum_type,Matrix* value){{{1*/
+MatrixParam::MatrixParam(int in_enum_type,Matrix* in_value){
+
+	enum_type=in_enum_type;
+	value=NULL;
+
+	if(in_value){
+		value=in_value->Duplicate();
+	}
+}
+/*}}}*/
+/*FUNCTION MatrixParam::~MatrixParam(){{{1*/
+MatrixParam::~MatrixParam(){
+	xdelete(&value);
+}
+/*}}}*/
+
+/*Object virtual functions definitions:*/
+/*FUNCTION MatrixParam::Echo {{{1*/
+void MatrixParam::Echo(void){
+
+	printf("MatrixParam:\n");
+	printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
+
+}
+/*}}}*/
+/*FUNCTION MatrixParam::DeepEcho{{{1*/
+void MatrixParam::DeepEcho(void){
+
+	int i;
+	printf("MatrixParam:\n");
+	printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
+	this->value->Echo();
+}
+/*}}}*/
+/*FUNCTION MatrixParam::Id{{{1*/
+int    MatrixParam::Id(void){ return -1; }
+/*}}}*/
+/*FUNCTION MatrixParam::MyRank{{{1*/
+int    MatrixParam::MyRank(void){ 
+	extern int my_rank;
+	return my_rank; 
+}
+/*}}}*/
+#ifdef _SERIAL_
+/*FUNCTION MatrixParam::Marshall{{{1*/
+void  MatrixParam::Marshall(char** pmarshalled_dataset){
+
+	char* marshalled_dataset=NULL;
+	int   enum_value=0;
+	int   M,N;
+	double* serial_mat=NULL;
+
+	/*recover marshalled_dataset: */
+	marshalled_dataset=*pmarshalled_dataset;
+
+	/*get enum value of MatrixParam: */
+	enum_value=MatrixParamEnum;
+	
+	/*marshall enum: */
+	memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);
+	
+	/*marshall MatrixParam data: */
+	memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
+	if(value){
+		value->GetSize(&M,&N);
+		serial_mat=value->ToSerial();
+		memcpy(marshalled_dataset,&M,sizeof(M));marshalled_dataset+=sizeof(M);
+		memcpy(marshalled_dataset,&N,sizeof(N));marshalled_dataset+=sizeof(N);
+		memcpy(marshalled_dataset,serial_mat,M*N*sizeof(double));marshalled_dataset+=(M*N*sizeof(double));
+	}
+	else{
+		M=0;
+		N=0;
+		memcpy(marshalled_dataset,&M,sizeof(M));marshalled_dataset+=sizeof(M);
+		memcpy(marshalled_dataset,&N,sizeof(N));marshalled_dataset+=sizeof(N);
+	}
+	
+	/*Free ressources:*/
+	xfree((void**)&serial_mat);
+
+	/*return:*/
+	*pmarshalled_dataset=marshalled_dataset;
+}
+/*}}}*/
+/*FUNCTION MatrixParam::MarshallSize{{{1*/
+int   MatrixParam::MarshallSize(){
+
+	int M=0;
+	int N=0;
+	if(value)value->GetSize(&M,&N);
+			
+	return sizeof(M)+
+		sizeof(N)+
+		M*N*sizeof(double)+
+		+sizeof(enum_type)+
+		+sizeof(int); //sizeof(int) for enum value
+}
+/*}}}*/
+/*FUNCTION MatrixParam::Demarshall{{{1*/
+void  MatrixParam::Demarshall(char** pmarshalled_dataset){
+
+	char* marshalled_dataset=NULL;
+	int   M,N;
+	double* serial_mat=NULL;
+
+	/*recover marshalled_dataset: */
+	marshalled_dataset=*pmarshalled_dataset;
+
+	/*this time, no need to get enum type, the pointer directly points to the beginning of the 
+	 *object data (thanks to DataSet::Demarshall):*/
+	memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
+	
+	/*data: */
+	memcpy(&M,marshalled_dataset,sizeof(M));marshalled_dataset+=sizeof(M);
+	memcpy(&N,marshalled_dataset,sizeof(N));marshalled_dataset+=sizeof(N);
+	if(M!=0 && N!=0){
+		serial_mat=(double*)xmalloc(M*N*sizeof(double));
+		memcpy(serial_mat,marshalled_dataset,M*N*sizeof(double));marshalled_dataset+=(M*N*sizeof(double));
+		value=new Matrix(serial_mat,M,N,.001);
+	}
+	else{
+		value=NULL;
+	}
+
+	/*Free ressources:*/
+	xfree((void**)&serial_mat);
+
+	/*return: */
+	*pmarshalled_dataset=marshalled_dataset;
+}
+/*}}}*/
+#endif
+/*FUNCTION MatrixParam::ObjectEnum{{{1*/
+int MatrixParam::ObjectEnum(void){
+
+	return MatrixParamEnum;
+
+}
+/*}}}*/
+/*FUNCTION MatrixParam::copy{{{1*/
+Object* MatrixParam::copy() {
+	
+	return new MatrixParam(this->enum_type,this->value);
+
+}
+/*}}}*/
+
+/*MatrixParam virtual functions definitions: */
+/*FUNCTION MatrixParam::GetParameterValue{{{1*/
+void  MatrixParam::GetParameterValue(Matrix** poutput){
+	Matrix* output=NULL;
+
+	if(value){
+		output=value->Duplicate();
+	}
+	*poutput=output;
+}
+/*}}}*/
+/*FUNCTION MatrixParam::GetParameterName{{{1*/
+void MatrixParam::GetParameterName(char**pname){
+	EnumToStringx(pname,this->enum_type);
+}
+/*}}}*/
+/*FUNCTION MatrixParam::SetMatlabField{{{1*/
+#ifdef _SERIAL_
+void  MatrixParam::SetMatlabField(mxArray* dataref){
+	
+	char* name=NULL;
+	int   M,N;
+	double* doublemat=NULL;
+	mxArray* pfield=NULL;
+
+	doublemat=value->ToSerial();
+	value->GetSize(&M,&N);
+	this->GetParameterName(&name);
+				
+	pfield=mxCreateDoubleMatrix(0,0,mxREAL);
+	mxSetM(pfield,M);
+	mxSetN(pfield,N);
+	mxSetPr(pfield,doublemat);
+	mxSetField( dataref, 0, name, pfield);
+}
+#endif
+/*}}}*/
+/*FUNCTION MatrixParam::SetValue{{{1*/
+void  MatrixParam::SetValue(Matrix* matrix){
+	
+	/*avoid leak: */
+	xdelete(&value);
+	
+	/*copy: */
+	value=matrix->Duplicate();
+}
+/*}}}*/
+/*FUNCTION MatrixParam::UnitConversion{{{1*/
+void  MatrixParam::UnitConversion(int direction_enum){
+	/*do nothing, no unit conversion*/
+}
+/*}}}*/
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Params/MatrixParam.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Params/MatrixParam.h	(revision 11708)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Params/MatrixParam.h	(revision 11708)
@@ -0,0 +1,90 @@
+/*! \file MatrixParam.h 
+ *  \brief: header file for MatrixParam object
+ */
+
+
+#ifndef _MATRIXPARAM_H_
+#define _MATRIXPARAM_H_
+
+/*Headers:*/
+/*{{{1*/
+#ifdef HAVE_CONFIG_H
+	#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+#ifdef _SERIAL_
+#include <mex.h>
+#endif
+
+#include "./Param.h"
+#include "../../include/include.h"
+#include "../../shared/shared.h"
+/*}}}*/
+
+class MatrixParam: public Param{
+
+	private: 
+		/*just hold 3 values for 3 vertices: */
+		int enum_type;
+		Matrix* value;
+
+	public:
+		/*MatrixParam constructors, destructors: {{{1*/
+		MatrixParam();
+		MatrixParam(int enum_type,Matrix* value);
+		~MatrixParam();
+		/*}}}*/
+		/*Object virtual functions definitions:{{{1 */
+		void  Echo();
+		void  DeepEcho();
+		int   Id(); 
+		int   MyRank();
+		#ifdef _SERIAL_
+		void  Marshall(char** pmarshalled_dataset);
+		int   MarshallSize();
+		void  Demarshall(char** pmarshalled_dataset);
+		#endif
+		int   ObjectEnum();
+		Object* copy();
+		/*}}}*/
+		/*Param vritual function definitions: {{{1*/
+		int   InstanceEnum(){return enum_type;}
+		void  GetParameterValue(bool* pbool){_error_("Matrix param of enum %i (%s) cannot return a bool",enum_type,EnumToStringx(enum_type));}
+		void  GetParameterValue(int* pinteger){_error_("Matrix param of enum %i (%s) cannot return an integer",enum_type,EnumToStringx(enum_type));}
+		void  GetParameterValue(int** pintarray,int* pM){_error_("Matrix param of enum %i (%s) cannot return an array of integers",enum_type,EnumToStringx(enum_type));}
+		void  GetParameterValue(int** pintarray,int* pM,int* pN){_error_("Matrix param of enum %i (%s) cannot return an array of integers",enum_type,EnumToStringx(enum_type));}
+		void  GetParameterValue(double* pdouble){_error_("Matrix param of enum %i (%s) cannot return a double",enum_type,EnumToStringx(enum_type));}
+		void  GetParameterValue(char** pstring){_error_("Matrix param of enum %i (%s) cannot return a string",enum_type,EnumToStringx(enum_type));}
+		void  GetParameterValue(char*** pstringarray,int* pM){_error_("Matrix param of enum %i (%s) cannot return a string array",enum_type,EnumToStringx(enum_type));}
+		void  GetParameterValue(double** pdoublearray,int* pM){_error_("Matrix param of enum %i (%s) cannot return a double array",enum_type,EnumToStringx(enum_type));}
+		void  GetParameterValue(double** pdoublearray,int* pM, int* pN){_error_("Matrix param of enum %i (%s) cannot return a double array",enum_type,EnumToStringx(enum_type));}
+		void  GetParameterValue(double*** parray, int* pM,int** pmdims, int** pndims){_error_("Matrix param of enum %i (%s) cannot return a matrix array",enum_type,EnumToStringx(enum_type));}
+		void  GetParameterValue(Vector** pvec){_error_("Matrix param of enum %i (%s) cannot return a vec",enum_type,EnumToStringx(enum_type));}
+		void  GetParameterValue(Matrix** poutput);
+		void  GetParameterValue(FILE** pfid){_error_("Matrix param of enum %i (%s) cannot return a FILE",enum_type,EnumToStringx(enum_type));}
+
+		void  SetValue(bool boolean){_error_("Matrix param of enum %i (%s) cannot hold a boolean",enum_type,EnumToStringx(enum_type));}
+		void  SetValue(int integer){_error_("Matrix param of enum %i (%s) cannot hold an integer",enum_type,EnumToStringx(enum_type));}
+		void  SetValue(double scalar){_error_("Matrix param of enum %i (%s) cannot hold a scalar",enum_type,EnumToStringx(enum_type));}
+		void  SetValue(char* string){_error_("Matrix param of enum %i (%s) cannot hold a string",enum_type,EnumToStringx(enum_type));}
+		void  SetValue(char** stringarray,int M){_error_("Matrix param of enum %i (%s) cannot hold a string array",enum_type,EnumToStringx(enum_type));}
+		void  SetValue(double* doublearray,int M){_error_("Matrix param of enum %i (%s) cannot hold a double array",enum_type,EnumToStringx(enum_type));}
+		void  SetValue(double* pdoublearray,int M,int N){_error_("Matrix param of enum %i (%s) cannot hold a double array",enum_type,EnumToStringx(enum_type));}
+		void  SetValue(int* intarray,int M){_error_("Matrix param of enum %i (%s) cannot hold a int array",enum_type,EnumToStringx(enum_type));}
+		void  SetValue(int* pintarray,int M,int N){_error_("Matrix param of enum %i (%s) cannot hold a int array",enum_type,EnumToStringx(enum_type));}
+		void  SetValue(Vector* vec){_error_("Matrix param of enum %i (%s) cannot hold a Vec",enum_type,EnumToStringx(enum_type));}
+		void  SetValue(Matrix* mat);
+		void  SetValue(FILE* fid){_error_("Matrix param of enum %i (%s) cannot hold a FILE",enum_type,EnumToStringx(enum_type));}
+		void  SetValue(double** array, int M, int* mdim_array, int* ndim_array){_error_("Matrix param of enum %i (%s) cannot hold an array of matrices",enum_type,EnumToStringx(enum_type));}
+		void  UnitConversion(int direction_enum);
+
+		void GetParameterName(char**pname);
+		#ifdef _SERIAL_
+		void  SetMatlabField(mxArray* dataref);
+		#endif
+
+		/*}}}*/
+};
+#endif  /* _MATRIXPARAM_H */
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Params/Param.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Params/Param.h	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Params/Param.h	(revision 11708)
@@ -41,6 +41,6 @@
 		virtual void  GetParameterValue(double** pdoublearray,int* pM,int* pN)=0;
 		virtual void  GetParameterValue(double*** parray, int* pM,int** pmdims, int** pndims)=0;
-		virtual void  GetParameterValue(Vec* pvec)=0;
-		virtual void  GetParameterValue(Mat* pmat)=0;
+		virtual void  GetParameterValue(Vector** pvec)=0;
+		virtual void  GetParameterValue(Matrix** pmat)=0;
 		virtual void  GetParameterValue(FILE** pfid)=0;
 		
@@ -54,6 +54,6 @@
 		virtual void  SetValue(int* intarray,int M)=0;
 		virtual void  SetValue(int* pintarray,int M,int N)=0;
-		virtual void  SetValue(Vec vec)=0;
-		virtual void  SetValue(Mat mat)=0;
+		virtual void  SetValue(Vector* vec)=0;
+		virtual void  SetValue(Matrix* mat)=0;
 		virtual void  SetValue(FILE* fid)=0;
 		virtual void  SetValue(double** array, int M, int* mdim_array, int* ndim_array)=0;
Index: sm/branches/trunk-jpl-damage/src/c/objects/Params/PetscMatParam.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Params/PetscMatParam.cpp	(revision 11707)
+++ 	(revision )
@@ -1,242 +1,0 @@
-/*!\file PetscMatParam.c
- * \brief: implementation of the PetscMatParam object
- */
-
-/*header files: */
-/*{{{1*/
-#ifdef HAVE_CONFIG_H
-	#include <config.h>
-#else
-#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
-#endif
-
-#include <stdio.h>
-#include <string.h>
-#include "../objects.h"
-#include "../../EnumDefinitions/EnumDefinitions.h"
-#include "../../shared/shared.h"
-#include "../../Container/Container.h"
-#include "../../include/include.h"
-/*}}}*/
-
-/*PetscMatParam constructors and destructor*/
-/*FUNCTION PetscMatParam::PetscMatParam(){{{1*/
-PetscMatParam::PetscMatParam(){
-	return;
-}
-/*}}}*/
-/*FUNCTION PetscMatParam::PetscMatParam(int enum_type,IssmPetscMat value){{{1*/
-PetscMatParam::PetscMatParam(int in_enum_type,Mat in_value){
-
-	enum_type=in_enum_type;
-
-	value=NULL;
-
-	if(in_value){
-		MatDuplicate(in_value,MAT_COPY_VALUES,&value);
-	}
-}
-/*}}}*/
-/*FUNCTION PetscMatParam::~PetscMatParam(){{{1*/
-PetscMatParam::~PetscMatParam(){
-	MatFree(&value);
-}
-/*}}}*/
-
-/*Object virtual functions definitions:*/
-/*FUNCTION PetscMatParam::Echo {{{1*/
-void PetscMatParam::Echo(void){
-
-	printf("PetscMatParam:\n");
-	printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
-
-}
-/*}}}*/
-/*FUNCTION PetscMatParam::DeepEcho{{{1*/
-void PetscMatParam::DeepEcho(void){
-
-	int i;
-	printf("PetscMatParam:\n");
-	printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
-	MatView(value,PETSC_VIEWER_STDOUT_WORLD);
-}
-/*}}}*/
-/*FUNCTION PetscMatParam::Id{{{1*/
-int    PetscMatParam::Id(void){ return -1; }
-/*}}}*/
-/*FUNCTION PetscMatParam::MyRank{{{1*/
-int    PetscMatParam::MyRank(void){ 
-	extern int my_rank;
-	return my_rank; 
-}
-/*}}}*/
-#ifdef _SERIAL_
-/*FUNCTION PetscMatParam::Marshall{{{1*/
-void  PetscMatParam::Marshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   enum_value=0;
-	int   M,N;
-	double* serial_mat=NULL;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*get enum value of PetscMatParam: */
-	enum_value=PetscMatParamEnum;
-	
-	/*marshall enum: */
-	memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);
-	
-	/*marshall PetscMatParam data: */
-	memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-	if(value){
-		MatGetSize(value,&M,&N);
-		MatToSerial(&serial_mat,value);
-		memcpy(marshalled_dataset,&M,sizeof(M));marshalled_dataset+=sizeof(M);
-		memcpy(marshalled_dataset,&N,sizeof(N));marshalled_dataset+=sizeof(N);
-		memcpy(marshalled_dataset,serial_mat,M*N*sizeof(double));marshalled_dataset+=(M*N*sizeof(double));
-	}
-	else{
-		M=0;
-		N=0;
-		memcpy(marshalled_dataset,&M,sizeof(M));marshalled_dataset+=sizeof(M);
-		memcpy(marshalled_dataset,&N,sizeof(N));marshalled_dataset+=sizeof(N);
-	}
-	
-	/*Free ressources:*/
-	xfree((void**)&serial_mat);
-
-	/*return:*/
-	*pmarshalled_dataset=marshalled_dataset;
-}
-/*}}}*/
-/*FUNCTION PetscMatParam::MarshallSize{{{1*/
-int   PetscMatParam::MarshallSize(){
-
-	int M=0;
-	int N=0;
-	if(value)MatGetSize(value,&M,&N);
-			
-	return sizeof(M)+
-		sizeof(N)+
-		M*N*sizeof(double)+
-		+sizeof(enum_type)+
-		+sizeof(int); //sizeof(int) for enum value
-}
-/*}}}*/
-/*FUNCTION PetscMatParam::Demarshall{{{1*/
-void  PetscMatParam::Demarshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   i,j;
-	int   M,N;
-	double* serial_mat=NULL;
-	int*    idxm=NULL;
-	int*    idxn=NULL;
-	double sparsity=.001;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*this time, no need to get enum type, the pointer directly points to the beginning of the 
-	 *object data (thanks to DataSet::Demarshall):*/
-	memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-	
-	/*data: */
-	memcpy(&M,marshalled_dataset,sizeof(M));marshalled_dataset+=sizeof(M);
-	memcpy(&N,marshalled_dataset,sizeof(N));marshalled_dataset+=sizeof(N);
-	if(M!=0 && N!=0){
-		serial_mat=(double*)xmalloc(M*N*sizeof(double));
-		memcpy(serial_mat,marshalled_dataset,M*N*sizeof(double));marshalled_dataset+=(M*N*sizeof(double));
-		value=NewMat(M,N,sparsity);
-		idxm=(int*)xmalloc(M*sizeof(int));
-		idxn=(int*)xmalloc(N*sizeof(int));
-		for(i=0;i<M;i++)idxm[i]=i;
-		for(i=0;i<N;i++)idxn[i]=i;
-		MatSetValues(value,M,idxm,N,idxn,serial_mat,INSERT_VALUES); 
-		MatAssemblyBegin(value,MAT_FINAL_ASSEMBLY); 
-		MatAssemblyEnd(value,MAT_FINAL_ASSEMBLY);
-
-			}
-	else{
-		value=NULL;
-	}
-
-	/*Free ressources:*/
-	xfree((void**)&serial_mat);
-	xfree((void**)&idxm);
-	xfree((void**)&idxn);
-
-	/*return: */
-	*pmarshalled_dataset=marshalled_dataset;
-}
-/*}}}*/
-#endif
-/*FUNCTION PetscMatParam::ObjectEnum{{{1*/
-int PetscMatParam::ObjectEnum(void){
-
-	return PetscMatParamEnum;
-
-}
-/*}}}*/
-/*FUNCTION PetscMatParam::copy{{{1*/
-Object* PetscMatParam::copy() {
-	
-	return new PetscMatParam(this->enum_type,this->value);
-
-}
-/*}}}*/
-
-/*PetscMatParam virtual functions definitions: */
-/*FUNCTION PetscMatParam::GetParameterValue{{{1*/
-void  PetscMatParam::GetParameterValue(Mat* poutput){
-	Mat output=NULL;
-
-	if(value){
-		MatDuplicate(value,MAT_COPY_VALUES,&output);
-	}
-	*poutput=output;
-}
-/*}}}*/
-/*FUNCTION PetscMatParam::GetParameterName{{{1*/
-void PetscMatParam::GetParameterName(char**pname){
-	EnumToStringx(pname,this->enum_type);
-}
-/*}}}*/
-/*FUNCTION PetscMatParam::SetMatlabField{{{1*/
-#ifdef _SERIAL_
-void  PetscMatParam::SetMatlabField(mxArray* dataref){
-	
-	char* name=NULL;
-	int   M,N;
-	double* doublemat=NULL;
-	mxArray* pfield=NULL;
-
-	MatToSerial(&doublemat,value);
-	MatGetSize(value,&M,&N);
-	this->GetParameterName(&name);
-				
-	pfield=mxCreateDoubleMatrix(0,0,mxREAL);
-	mxSetM(pfield,M);
-	mxSetN(pfield,N);
-	mxSetPr(pfield,doublemat);
-	mxSetField( dataref, 0, name, pfield);
-}
-#endif
-/*}}}*/
-/*FUNCTION PetscMatParam::SetValue{{{1*/
-void  PetscMatParam::SetValue(Mat matrix){
-	
-	/*avoid leak: */
-	MatFree(&value);
-	
-	/*copy: */
-	MatDuplicate(matrix,MAT_COPY_VALUES,&value);
-}
-/*}}}*/
-/*FUNCTION PetscMatParam::UnitConversion{{{1*/
-void  PetscMatParam::UnitConversion(int direction_enum){
-	/*do nothing, no unit conversion*/
-}
-/*}}}*/
Index: sm/branches/trunk-jpl-damage/src/c/objects/Params/PetscMatParam.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Params/PetscMatParam.h	(revision 11707)
+++ 	(revision )
@@ -1,90 +1,0 @@
-/*! \file PetscMatParam.h 
- *  \brief: header file for triavertexinput object
- */
-
-
-#ifndef _PETSCMATPARAM_H_
-#define _PETSCMATPARAM_H_
-
-/*Headers:*/
-/*{{{1*/
-#ifdef HAVE_CONFIG_H
-	#include <config.h>
-#else
-#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
-#endif
-
-#ifdef _SERIAL_
-#include <mex.h>
-#endif
-
-#include "./Param.h"
-#include "../../include/include.h"
-#include "../../shared/shared.h"
-/*}}}*/
-
-class PetscMatParam: public Param{
-
-	private: 
-		/*just hold 3 values for 3 vertices: */
-		int enum_type;
-		Mat value;
-
-	public:
-		/*PetscMatParam constructors, destructors: {{{1*/
-		PetscMatParam();
-		PetscMatParam(int enum_type,Mat value);
-		~PetscMatParam();
-		/*}}}*/
-		/*Object virtual functions definitions:{{{1 */
-		void  Echo();
-		void  DeepEcho();
-		int   Id(); 
-		int   MyRank();
-		#ifdef _SERIAL_
-		void  Marshall(char** pmarshalled_dataset);
-		int   MarshallSize();
-		void  Demarshall(char** pmarshalled_dataset);
-		#endif
-		int   ObjectEnum();
-		Object* copy();
-		/*}}}*/
-		/*Param vritual function definitions: {{{1*/
-		int   InstanceEnum(){return enum_type;}
-		void  GetParameterValue(bool* pbool){_error_("PetscMat param of enum %i (%s) cannot return a bool",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(int* pinteger){_error_("PetscMat param of enum %i (%s) cannot return an integer",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(int** pintarray,int* pM){_error_("PetscMat param of enum %i (%s) cannot return an array of integers",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(int** pintarray,int* pM,int* pN){_error_("PetscMat param of enum %i (%s) cannot return an array of integers",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(double* pdouble){_error_("PetscMat param of enum %i (%s) cannot return a double",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(char** pstring){_error_("PetscMat param of enum %i (%s) cannot return a string",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(char*** pstringarray,int* pM){_error_("PetscMat param of enum %i (%s) cannot return a string array",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(double** pdoublearray,int* pM){_error_("PetscMat param of enum %i (%s) cannot return a double array",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(double** pdoublearray,int* pM, int* pN){_error_("PetscMat param of enum %i (%s) cannot return a double array",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(double*** parray, int* pM,int** pmdims, int** pndims){_error_("PetscMat param of enum %i (%s) cannot return a matrix array",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(Vec* pvec){_error_("PetscMat param of enum %i (%s) cannot return a vec",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(Mat* poutput);
-		void  GetParameterValue(FILE** pfid){_error_("PetscMat param of enum %i (%s) cannot return a FILE",enum_type,EnumToStringx(enum_type));}
-
-		void  SetValue(bool boolean){_error_("PetscMat param of enum %i (%s) cannot hold a boolean",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(int integer){_error_("PetscMat param of enum %i (%s) cannot hold an integer",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(double scalar){_error_("PetscMat param of enum %i (%s) cannot hold a scalar",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(char* string){_error_("PetscMat param of enum %i (%s) cannot hold a string",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(char** stringarray,int M){_error_("PetscMat param of enum %i (%s) cannot hold a string array",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(double* doublearray,int M){_error_("PetscMat param of enum %i (%s) cannot hold a double array",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(double* pdoublearray,int M,int N){_error_("PetscMat param of enum %i (%s) cannot hold a double array",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(int* intarray,int M){_error_("PetscMat param of enum %i (%s) cannot hold a int array",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(int* pintarray,int M,int N){_error_("PetscMat param of enum %i (%s) cannot hold a int array",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(Vec vec){_error_("PetscMat param of enum %i (%s) cannot hold a Vec",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(Mat mat);
-		void  SetValue(FILE* fid){_error_("PetscMat param of enum %i (%s) cannot hold a FILE",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(double** array, int M, int* mdim_array, int* ndim_array){_error_("PetscMat param of enum %i (%s) cannot hold an array of matrices",enum_type,EnumToStringx(enum_type));}
-		void  UnitConversion(int direction_enum);
-
-		void GetParameterName(char**pname);
-		#ifdef _SERIAL_
-		void  SetMatlabField(mxArray* dataref);
-		#endif
-
-		/*}}}*/
-};
-#endif  /* _PETSCMATPARAM_H */
Index: sm/branches/trunk-jpl-damage/src/c/objects/Params/PetscVecParam.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Params/PetscVecParam.cpp	(revision 11707)
+++ 	(revision )
@@ -1,237 +1,0 @@
-/*!\file PetscVecParam.c
- * \brief: implementation of the PetscVecParam object
- */
-
-/*header files: */
-/*{{{1*/
-#ifdef HAVE_CONFIG_H
-	#include <config.h>
-#else
-#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
-#endif
-
-#include <stdio.h>
-#include <string.h>
-#include "../objects.h"
-#include "../../EnumDefinitions/EnumDefinitions.h"
-#include "../../shared/shared.h"
-#include "../../Container/Container.h"
-#include "../../include/include.h"
-/*}}}*/
-
-/*PetscVecParam constructors and destructor*/
-/*FUNCTION PetscVecParam::PetscVecParam(){{{1*/
-PetscVecParam::PetscVecParam(){
-	return;
-}
-/*}}}*/
-/*FUNCTION PetscVecParam::PetscVecParam(int enum_type,IssmPetscVec value){{{1*/
-PetscVecParam::PetscVecParam(int in_enum_type,Vec in_value){
-
-	enum_type=in_enum_type;
-
-	value=NULL;
-
-	if(in_value){
-		VecDuplicate(in_value,&value);
-		VecCopy(in_value,value);
-	}
-}
-/*}}}*/
-/*FUNCTION PetscVecParam::~PetscVecParam(){{{1*/
-PetscVecParam::~PetscVecParam(){
-	VecFree(&value);
-}
-/*}}}*/
-
-/*Object virtual functions definitions:*/
-/*FUNCTION PetscVecParam::Echo {{{1*/
-void PetscVecParam::Echo(void){
-
-	printf("PetscVecParam:\n");
-	printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
-
-}
-/*}}}*/
-/*FUNCTION PetscVecParam::DeepEcho{{{1*/
-void PetscVecParam::DeepEcho(void){
-
-	int i;
-	printf("PetscVecParam:\n");
-	printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
-	VecView(value,PETSC_VIEWER_STDOUT_WORLD);
-}
-/*}}}*/
-/*FUNCTION PetscVecParam::Id{{{1*/
-int    PetscVecParam::Id(void){ return -1; }
-/*}}}*/
-/*FUNCTION PetscVecParam::MyRank{{{1*/
-int    PetscVecParam::MyRank(void){ 
-	extern int my_rank;
-	return my_rank; 
-}
-/*}}}*/
-#ifdef _SERIAL_
-/*FUNCTION PetscVecParam::Marshall{{{1*/
-void  PetscVecParam::Marshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   enum_value=0;
-	int   M;
-	double* serial_value=NULL;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*get enum value of PetscVecParam: */
-	enum_value=PetscVecParamEnum;
-	
-	/*marshall enum: */
-	memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);
-	
-	/*marshall PetscVecParam data: */
-	memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-	if(value){
-		VecGetSize(value,&M);
-		VecToMPISerial(&serial_value,value);
-		memcpy(marshalled_dataset,&M,sizeof(M));marshalled_dataset+=sizeof(M);
-		memcpy(marshalled_dataset,serial_value,M*sizeof(double));marshalled_dataset+=(M*sizeof(double));
-	}
-	else{
-		M=0;
-		memcpy(marshalled_dataset,&M,sizeof(M));marshalled_dataset+=sizeof(M);
-	}
-	/*Free ressources:*/
-	xfree((void**)&serial_value);
-
-	/*return:*/
-	*pmarshalled_dataset=marshalled_dataset;
-}
-/*}}}*/
-/*FUNCTION PetscVecParam::MarshallSize{{{1*/
-int   PetscVecParam::MarshallSize(){
-
-	int M=0;
-	if(value)VecGetSize(value,&M);
-
-	return sizeof(M)+M*sizeof(double)
-		+sizeof(enum_type)+
-		+sizeof(int); //sizeof(int) for enum value
-}
-/*}}}*/
-/*FUNCTION PetscVecParam::Demarshall{{{1*/
-void  PetscVecParam::Demarshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   i;
-	int   M;
-	double* serial_vec=NULL;
-	int*    idxm=NULL;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*this time, no need to get enum type, the pointer directly points to the beginning of the 
-	 *object data (thanks to DataSet::Demarshall):*/
-	memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-	
-	/*data: */
-	
-	memcpy(&M,marshalled_dataset,sizeof(M));marshalled_dataset+=sizeof(M);
-	if(M){
-		serial_vec=(double*)xmalloc(M*sizeof(double));
-		memcpy(serial_vec,marshalled_dataset,M*sizeof(double));marshalled_dataset+=(M*sizeof(double));
-
-		value=NewVec(M);
-		idxm=(int*)xmalloc(M*sizeof(int));
-		for(i=0;i<M;i++)idxm[i]=i;
-		VecSetValues(value,M,idxm,serial_vec,INSERT_VALUES);
-
-		VecAssemblyBegin(value);
-		VecAssemblyEnd(value);
-
-		
-	}
-	else{
-		value=NULL;
-	}
-
-	/*Free ressources:*/
-	xfree((void**)&serial_vec);
-	xfree((void**)&idxm);
-
-	/*return: */
-	*pmarshalled_dataset=marshalled_dataset;
-}
-/*}}}*/
-#endif
-/*FUNCTION PetscVecParam::ObjectEnum{{{1*/
-int PetscVecParam::ObjectEnum(void){
-
-	return PetscVecParamEnum;
-
-}
-/*}}}*/
-/*FUNCTION PetscVecParam::copy{{{1*/
-Object* PetscVecParam::copy() {
-	
-	return new PetscVecParam(this->enum_type,this->value);
-
-}
-/*}}}*/
-
-/*PetscVecParam virtual functions definitions: */
-/*FUNCTION PetscVecParam::GetParameterValue{{{1*/
-void  PetscVecParam::GetParameterValue(Vec* poutput){
-	Vec output=NULL;
-
-	if(value){
-		VecDuplicate(value,&output);
-		VecCopy(value,output);
-	}
-	*poutput=output;
-}
-/*}}}*/
-/*FUNCTION PetscVecParam::GetParameterName{{{1*/
-void PetscVecParam::GetParameterName(char**pname){
-	EnumToStringx(pname,this->enum_type);
-}
-/*}}}*/
-/*FUNCTION PetscVecParam::SetMatlabField{{{1*/
-#ifdef _SERIAL_
-void  PetscVecParam::SetMatlabField(mxArray* dataref){
-
-	mxArray* pfield=NULL;
-	char* name=NULL;
-	double* doublevec=NULL;
-	int M;
-	
-	VecToMPISerial(&doublevec,value);
-	VecGetSize(value,&M);
-	this->GetParameterName(&name);
-	
-	pfield=mxCreateDoubleMatrix(0,0,mxREAL);
-	mxSetM(pfield,M);
-	mxSetN(pfield,1);
-	mxSetPr(pfield,doublevec);
-	
-	mxSetField( dataref, 0, name, pfield);
-}
-#endif
-/*}}}*/
-/*FUNCTION PetscVecParam::SetValue{{{1*/
-void  PetscVecParam::SetValue(Vec vector){
-
-	/*avoid leak: */
-	VecFree(&value);
-	
-	/*copy: */
-	VecDuplicate(vector,&value);
-	VecCopy(vector,value);
-}
-/*}}}*/
-/*FUNCTION PetscVecParam::UnitConversion{{{1*/
-void  PetscVecParam::UnitConversion(int direction_enum){
-	/*do nothing, no unit conversion*/
-}
-/*}}}*/
Index: sm/branches/trunk-jpl-damage/src/c/objects/Params/PetscVecParam.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Params/PetscVecParam.h	(revision 11707)
+++ 	(revision )
@@ -1,90 +1,0 @@
-/*! \file PetscVecParam.h 
- *  \brief: header file for triavertexinput object
- */
-
-
-#ifndef _PETSCVECPARAM_H_
-#define _PETSCVECPARAM_H_
-
-/*Headers:*/
-/*{{{1*/
-#ifdef HAVE_CONFIG_H
-	#include <config.h>
-#else
-#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
-#endif
-
-#ifdef _SERIAL_
-#include <mex.h>
-#endif
-
-#include "./Param.h"
-#include "../../include/include.h"
-#include "../../shared/shared.h"
-/*}}}*/
-
-class PetscVecParam: public Param{
-
-	private: 
-		/*just hold 3 values for 3 vertices: */
-		int enum_type;
-		Vec value;
-
-	public:
-		/*PetscVecParam constructors, destructors: {{{1*/
-		PetscVecParam();
-		PetscVecParam(int enum_type,Vec value);
-		~PetscVecParam();
-		/*}}}*/
-		/*Object virtual functions definitions:{{{1 */
-		void  Echo();
-		void  DeepEcho();
-		int   Id(); 
-		int   MyRank();
-		#ifdef _SERIAL_
-		void  Marshall(char** pmarshalled_dataset);
-		int   MarshallSize();
-		void  Demarshall(char** pmarshalled_dataset);
-		#endif
-		int   ObjectEnum();
-		Object* copy();
-		/*}}}*/
-		/*Param vritual function definitions: {{{1*/
-		int   InstanceEnum(){return enum_type;}
-		void  GetParameterValue(bool* pbool){_error_("PetscVec param of enum %i (%s) cannot return a bool",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(int* pinteger){_error_("PetscVec param of enum %i (%s) cannot return an integer",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(int** pintarray,int* pM){_error_("PetscVec param of enum %i (%s) cannot return an array of integers",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(int** pintarray,int* pM,int* pN){_error_("PetscVec param of enum %i (%s) cannot return an array of integers",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(double* pdouble){_error_("PetscVec param of enum %i (%s) cannot return a double",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(char** pstring){_error_("PetscVec param of enum %i (%s) cannot return a string",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(char*** pstringarray,int* pM){_error_("PetscVec param of enum %i (%s) cannot return a string array",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(double** pdoublearray,int* pM){_error_("PetscVec param of enum %i (%s) cannot return a double array",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(double** pdoublearray,int* pM, int* pN){_error_("PetscVec param of enum %i (%s) cannot return a double array",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(double*** parray, int* pM,int** pmdims, int** pndims){_error_("PetscVec param of enum %i (%s) cannot return a matrix array",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(Mat* pmat){_error_("PetscVec param of enum %i (%s) cannot return a Mat",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(Vec* poutput);
-		void  GetParameterValue(FILE** pfid){_error_("PetscVec of enum %i (%s) cannot return a FILE",enum_type,EnumToStringx(enum_type));}
-
-		void  SetValue(bool boolean){_error_("PetscVec of enum %i (%s) cannot hold a boolean",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(int integer){_error_("PetscVec of enum %i (%s) cannot hold an integer",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(double scalar){_error_("PetscVec of enum %i (%s) cannot hold a scalar",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(char* string){_error_("PetscVec of enum %i (%s) cannot hold a string",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(char** stringarray,int M){_error_("PetscVec of enum %i (%s) cannot hold a string array",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(double* doublearray,int M){_error_("PetscVec of enum %i (%s) cannot hold a double array",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(double* pdoublearray,int M,int N){_error_("PetscVec of enum %i (%s) cannot hold a double array",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(int* intarray,int M){_error_("PetscVec of enum %i (%s) cannot hold a int array",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(int* pintarray,int M,int N){_error_("PetscVec of enum %i (%s) cannot hold a int array",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(Vec vec);
-		void  SetValue(Mat mat){_error_("PetscVec of enum %i (%s) cannot hold a Mat",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(FILE* fid){_error_("PetscVec of enum %i (%s) cannot hold a FILE",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(double** array, int M, int* mdim_array, int* ndim_array){_error_("PetscVec param of enum %i (%s) cannot hold an array of matrices",enum_type,EnumToStringx(enum_type));}
-		void  UnitConversion(int direction_enum);
-
-		void GetParameterName(char**pname);
-		#ifdef _SERIAL_
-		void  SetMatlabField(mxArray* dataref);
-		#endif
-
-		/*}}}*/
-};
-#endif  /* _PETSCVECPARAM_H */
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Params/StringArrayParam.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Params/StringArrayParam.h	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Params/StringArrayParam.h	(revision 11708)
@@ -64,6 +64,6 @@
 		void  GetParameterValue(double** pdoublearray,int* pM, int* pN){_error_("StringArray param of enum %i (%s) cannot return a double array",enum_type,EnumToStringx(enum_type));}
 		void  GetParameterValue(double*** parray, int* pM,int** pmdims, int** pndims){_error_("Vec param of enum %i (%s) cannot return a matrix array",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(Vec* pvec){_error_("StringArray param of enum %i (%s) cannot return a Vec",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(Mat* pmat){_error_("StringArray param of enum %i (%s) cannot return a Mat",enum_type,EnumToStringx(enum_type));}
+		void  GetParameterValue(Vector** pvec){_error_("StringArray param of enum %i (%s) cannot return a Vec",enum_type,EnumToStringx(enum_type));}
+		void  GetParameterValue(Matrix** pmat){_error_("StringArray param of enum %i (%s) cannot return a Mat",enum_type,EnumToStringx(enum_type));}
 		void  GetParameterValue(FILE** pfid){_error_("StringArray param of enum %i (%s) cannot return a FILE",enum_type,EnumToStringx(enum_type));}
 
@@ -77,6 +77,6 @@
 		void  SetValue(int* intarray,int M){_error_("StringArray param of enum %i (%s) cannot hold a int array",enum_type,EnumToStringx(enum_type));}
 		void  SetValue(int* pintarray,int M,int N){_error_("StringArray param of enum %i (%s) cannot hold a int array",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(Vec vec){_error_("StringArray param of enum %i (%s) cannot hold a Vec",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(Mat mat){_error_("StringArray param of enum %i (%s) cannot hold a Mat",enum_type,EnumToStringx(enum_type));}
+		void  SetValue(Vector* vec){_error_("StringArray param of enum %i (%s) cannot hold a Vec",enum_type,EnumToStringx(enum_type));}
+		void  SetValue(Matrix* mat){_error_("StringArray param of enum %i (%s) cannot hold a Mat",enum_type,EnumToStringx(enum_type));}
 		void  SetValue(FILE* fid){_error_("StringArray param of enum %i (%s) cannot hold a FILE",enum_type,EnumToStringx(enum_type));}
 		void  SetValue(double** array, int M, int* mdim_array, int* ndim_array){_error_("StringArray param of enum %i (%s) cannot hold an array of matrices",enum_type,EnumToStringx(enum_type));}
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Params/StringParam.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Params/StringParam.h	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Params/StringParam.h	(revision 11708)
@@ -62,6 +62,6 @@
 		void  GetParameterValue(double** pdoublearray,int* pM, int* pN){_error_("String param of enum %i (%s) cannot return a double array",enum_type,EnumToStringx(enum_type));}
 		void  GetParameterValue(double*** parray, int* pM,int** pmdims, int** pndims){_error_("String param of enum %i (%s) cannot return a matrix array",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(Vec* pvec){_error_("String param of enum %i (%s) cannot return a Vec",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(Mat* pmat){_error_("String param of enum %i (%s) cannot return a Mat",enum_type,EnumToStringx(enum_type));}
+		void  GetParameterValue(Vector** pvec){_error_("String param of enum %i (%s) cannot return a Vec",enum_type,EnumToStringx(enum_type));}
+		void  GetParameterValue(Matrix** pmat){_error_("String param of enum %i (%s) cannot return a Mat",enum_type,EnumToStringx(enum_type));}
 		void  GetParameterValue(FILE** pfid){_error_("Bool param of enum %i (%s) cannot return a FILE",enum_type,EnumToStringx(enum_type));}
 
@@ -75,6 +75,6 @@
 		void  SetValue(int* intarray,int M){_error_("String param of enum %i (%s) cannot hold a int array",enum_type,EnumToStringx(enum_type));}
 		void  SetValue(int* pintarray,int M,int N){_error_("String param of enum %i (%s) cannot hold a int array",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(Vec vec){_error_("String param of enum %i (%s) cannot hold a Vec",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(Mat mat){_error_("String param of enum %i (%s) cannot hold a Mat",enum_type,EnumToStringx(enum_type));}
+		void  SetValue(Vector* vec){_error_("String param of enum %i (%s) cannot hold a Vec",enum_type,EnumToStringx(enum_type));}
+		void  SetValue(Matrix* mat){_error_("String param of enum %i (%s) cannot hold a Mat",enum_type,EnumToStringx(enum_type));}
 		void  SetValue(FILE* fid){_error_("String param of enum %i (%s) cannot hold a FILE",enum_type,EnumToStringx(enum_type));}
 		void  SetValue(double** array, int M, int* mdim_array, int* ndim_array){_error_("String param of enum %i (%s) cannot hold an array of matrices",enum_type,EnumToStringx(enum_type));}
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Params/VectorParam.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Params/VectorParam.cpp	(revision 11708)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Params/VectorParam.cpp	(revision 11708)
@@ -0,0 +1,227 @@
+/*!\file VectorParam.c
+ * \brief: implementation of the VectorParam object
+ */
+
+/*header files: */
+/*{{{1*/
+#ifdef HAVE_CONFIG_H
+	#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+#include <stdio.h>
+#include <string.h>
+#include "../objects.h"
+#include "../../EnumDefinitions/EnumDefinitions.h"
+#include "../../shared/shared.h"
+#include "../../Container/Container.h"
+#include "../../include/include.h"
+/*}}}*/
+
+/*VectorParam constructors and destructor*/
+/*FUNCTION VectorParam::VectorParam(){{{1*/
+VectorParam::VectorParam(){
+	return;
+}
+/*}}}*/
+/*FUNCTION VectorParam::VectorParam(int enum_type,IssmVector value){{{1*/
+VectorParam::VectorParam(int in_enum_type,Vector* in_value){
+
+	enum_type=in_enum_type;
+
+	value=NULL;
+
+	if(in_value){
+		value=in_value->Duplicate();
+		in_value->Copy(value);
+	}
+}
+/*}}}*/
+/*FUNCTION VectorParam::~VectorParam(){{{1*/
+VectorParam::~VectorParam(){
+	xdelete(&value);
+}
+/*}}}*/
+
+/*Object virtual functions definitions:*/
+/*FUNCTION VectorParam::Echo {{{1*/
+void VectorParam::Echo(void){
+
+	printf("VectorParam:\n");
+	printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
+
+}
+/*}}}*/
+/*FUNCTION VectorParam::DeepEcho{{{1*/
+void VectorParam::DeepEcho(void){
+
+	int i;
+	printf("VectorParam:\n");
+	printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
+	value->Echo();
+}
+/*}}}*/
+/*FUNCTION VectorParam::Id{{{1*/
+int    VectorParam::Id(void){ return -1; }
+/*}}}*/
+/*FUNCTION VectorParam::MyRank{{{1*/
+int    VectorParam::MyRank(void){ 
+	extern int my_rank;
+	return my_rank; 
+}
+/*}}}*/
+#ifdef _SERIAL_
+/*FUNCTION VectorParam::Marshall{{{1*/
+void  VectorParam::Marshall(char** pmarshalled_dataset){
+
+	char* marshalled_dataset=NULL;
+	int   enum_value=0;
+	int   M;
+	double* serial_value=NULL;
+
+	/*recover marshalled_dataset: */
+	marshalled_dataset=*pmarshalled_dataset;
+
+	/*get enum value of VectorParam: */
+	enum_value=VectorParamEnum;
+	
+	/*marshall enum: */
+	memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);
+	
+	/*marshall VectorParam data: */
+	memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
+	if(value){
+		value->GetSize(&M);
+		serial_value=value->ToMPISerial();
+		memcpy(marshalled_dataset,&M,sizeof(M));marshalled_dataset+=sizeof(M);
+		memcpy(marshalled_dataset,serial_value,M*sizeof(double));marshalled_dataset+=(M*sizeof(double));
+	}
+	else{
+		M=0;
+		memcpy(marshalled_dataset,&M,sizeof(M));marshalled_dataset+=sizeof(M);
+	}
+	/*Free ressources:*/
+	xfree((void**)&serial_value);
+
+	/*return:*/
+	*pmarshalled_dataset=marshalled_dataset;
+}
+/*}}}*/
+/*FUNCTION VectorParam::MarshallSize{{{1*/
+int   VectorParam::MarshallSize(){
+
+	int M=0;
+	if(value)value->GetSize(&M);
+
+	return sizeof(M)+M*sizeof(double)
+		+sizeof(enum_type)+
+		+sizeof(int); //sizeof(int) for enum value
+}
+/*}}}*/
+/*FUNCTION VectorParam::Demarshall{{{1*/
+void  VectorParam::Demarshall(char** pmarshalled_dataset){
+
+	char* marshalled_dataset=NULL;
+	int   i;
+	double* serial_vec=NULL;
+	int   M;
+
+	/*recover marshalled_dataset: */
+	marshalled_dataset=*pmarshalled_dataset;
+
+	/*this time, no need to get enum type, the pointer directly points to the beginning of the 
+	 *object data (thanks to DataSet::Demarshall):*/
+	memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
+	
+	/*data: */
+	
+	memcpy(&M,marshalled_dataset,sizeof(M));marshalled_dataset+=sizeof(M);
+	if(M){
+		serial_vec=(double*)xmalloc(M*sizeof(double));
+		memcpy(serial_vec,marshalled_dataset,M*sizeof(double));marshalled_dataset+=(M*sizeof(double));
+
+		value=new Vector(serial_vec,M);
+	}
+	else{
+		value=NULL;
+	}
+
+	/*Free ressources:*/
+	xfree((void**)&serial_vec);
+
+	/*return: */
+	*pmarshalled_dataset=marshalled_dataset;
+}
+/*}}}*/
+#endif
+/*FUNCTION VectorParam::ObjectEnum{{{1*/
+int VectorParam::ObjectEnum(void){
+
+	return VectorParamEnum;
+
+}
+/*}}}*/
+/*FUNCTION VectorParam::copy{{{1*/
+Object* VectorParam::copy() {
+	
+	return new VectorParam(this->enum_type,this->value);
+
+}
+/*}}}*/
+
+/*VectorParam virtual functions definitions: */
+/*FUNCTION VectorParam::GetParameterValue{{{1*/
+void  VectorParam::GetParameterValue(Vector** poutput){
+	Vector*  output=NULL;
+
+	if(value){
+		output=value->Duplicate();
+		value->Copy(output);
+	}
+	*poutput=output;
+}
+/*}}}*/
+/*FUNCTION VectorParam::GetParameterName{{{1*/
+void VectorParam::GetParameterName(char**pname){
+	EnumToStringx(pname,this->enum_type);
+}
+/*}}}*/
+/*FUNCTION VectorParam::SetMatlabField{{{1*/
+#ifdef _SERIAL_
+void  VectorParam::SetMatlabField(mxArray* dataref){
+
+	mxArray* pfield=NULL;
+	char* name=NULL;
+	double* doublevec=NULL;
+	int M;
+	
+	doublevec=value->ToMPISerial();
+	value->GetSize(&M);
+	this->GetParameterName(&name);
+	
+	pfield=mxCreateDoubleMatrix(0,0,mxREAL);
+	mxSetM(pfield,M);
+	mxSetN(pfield,1);
+	mxSetPr(pfield,doublevec);
+	
+	mxSetField( dataref, 0, name, pfield);
+}
+#endif
+/*}}}*/
+/*FUNCTION VectorParam::SetValue{{{1*/
+void  VectorParam::SetValue(Vector* vector){
+
+	/*avoid leak: */
+	xdelete(&value);
+	
+	/*copy: */
+	value=vector->Duplicate();
+	vector->Copy(value);
+}
+/*}}}*/
+/*FUNCTION VectorParam::UnitConversion{{{1*/
+void  VectorParam::UnitConversion(int direction_enum){
+	/*do nothing, no unit conversion*/
+}
+/*}}}*/
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Params/VectorParam.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Params/VectorParam.h	(revision 11708)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Params/VectorParam.h	(revision 11708)
@@ -0,0 +1,90 @@
+/*! \file VectorParam.h 
+ *  \brief: header file for triavertexinput object
+ */
+
+
+#ifndef _VECTORPARAM_H_
+#define _VECTORPARAM_H_
+
+/*Headers:*/
+/*{{{1*/
+#ifdef HAVE_CONFIG_H
+	#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+#ifdef _SERIAL_
+#include <mex.h>
+#endif
+
+#include "./Param.h"
+#include "../../include/include.h"
+#include "../../shared/shared.h"
+/*}}}*/
+
+class VectorParam: public Param{
+
+	private: 
+		/*just hold 3 values for 3 vertices: */
+		int enum_type;
+		Vector* value;
+
+	public:
+		/*VectorParam constructors, destructors: {{{1*/
+		VectorParam();
+		VectorParam(int enum_type,Vector* value);
+		~VectorParam();
+		/*}}}*/
+		/*Object virtual functions definitions:{{{1 */
+		void  Echo();
+		void  DeepEcho();
+		int   Id(); 
+		int   MyRank();
+		#ifdef _SERIAL_
+		void  Marshall(char** pmarshalled_dataset);
+		int   MarshallSize();
+		void  Demarshall(char** pmarshalled_dataset);
+		#endif
+		int   ObjectEnum();
+		Object* copy();
+		/*}}}*/
+		/*Param vritual function definitions: {{{1*/
+		int   InstanceEnum(){return enum_type;}
+		void  GetParameterValue(bool* pbool){_error_("Vector param of enum %i (%s) cannot return a bool",enum_type,EnumToStringx(enum_type));}
+		void  GetParameterValue(int* pinteger){_error_("Vector param of enum %i (%s) cannot return an integer",enum_type,EnumToStringx(enum_type));}
+		void  GetParameterValue(int** pintarray,int* pM){_error_("Vector param of enum %i (%s) cannot return an array of integers",enum_type,EnumToStringx(enum_type));}
+		void  GetParameterValue(int** pintarray,int* pM,int* pN){_error_("Vector param of enum %i (%s) cannot return an array of integers",enum_type,EnumToStringx(enum_type));}
+		void  GetParameterValue(double* pdouble){_error_("Vector param of enum %i (%s) cannot return a double",enum_type,EnumToStringx(enum_type));}
+		void  GetParameterValue(char** pstring){_error_("Vector param of enum %i (%s) cannot return a string",enum_type,EnumToStringx(enum_type));}
+		void  GetParameterValue(char*** pstringarray,int* pM){_error_("Vector param of enum %i (%s) cannot return a string array",enum_type,EnumToStringx(enum_type));}
+		void  GetParameterValue(double** pdoublearray,int* pM){_error_("Vector param of enum %i (%s) cannot return a double array",enum_type,EnumToStringx(enum_type));}
+		void  GetParameterValue(double** pdoublearray,int* pM, int* pN){_error_("Vector param of enum %i (%s) cannot return a double array",enum_type,EnumToStringx(enum_type));}
+		void  GetParameterValue(double*** parray, int* pM,int** pmdims, int** pndims){_error_("Vector param of enum %i (%s) cannot return a matrix array",enum_type,EnumToStringx(enum_type));}
+		void  GetParameterValue(Matrix** pmat){_error_("Vector param of enum %i (%s) cannot return a Mat",enum_type,EnumToStringx(enum_type));}
+		void  GetParameterValue(Vector** poutput);
+		void  GetParameterValue(FILE** pfid){_error_("Vector of enum %i (%s) cannot return a FILE",enum_type,EnumToStringx(enum_type));}
+
+		void  SetValue(bool boolean){_error_("Vector of enum %i (%s) cannot hold a boolean",enum_type,EnumToStringx(enum_type));}
+		void  SetValue(int integer){_error_("Vector of enum %i (%s) cannot hold an integer",enum_type,EnumToStringx(enum_type));}
+		void  SetValue(double scalar){_error_("Vector of enum %i (%s) cannot hold a scalar",enum_type,EnumToStringx(enum_type));}
+		void  SetValue(char* string){_error_("Vector of enum %i (%s) cannot hold a string",enum_type,EnumToStringx(enum_type));}
+		void  SetValue(char** stringarray,int M){_error_("Vector of enum %i (%s) cannot hold a string array",enum_type,EnumToStringx(enum_type));}
+		void  SetValue(double* doublearray,int M){_error_("Vector of enum %i (%s) cannot hold a double array",enum_type,EnumToStringx(enum_type));}
+		void  SetValue(double* pdoublearray,int M,int N){_error_("Vector of enum %i (%s) cannot hold a double array",enum_type,EnumToStringx(enum_type));}
+		void  SetValue(int* intarray,int M){_error_("Vector of enum %i (%s) cannot hold a int array",enum_type,EnumToStringx(enum_type));}
+		void  SetValue(int* pintarray,int M,int N){_error_("Vector of enum %i (%s) cannot hold a int array",enum_type,EnumToStringx(enum_type));}
+		void  SetValue(Vector* vec);
+		void  SetValue(Matrix* mat){_error_("Vector of enum %i (%s) cannot hold a Mat",enum_type,EnumToStringx(enum_type));}
+		void  SetValue(FILE* fid){_error_("Vector of enum %i (%s) cannot hold a FILE",enum_type,EnumToStringx(enum_type));}
+		void  SetValue(double** array, int M, int* mdim_array, int* ndim_array){_error_("Vector param of enum %i (%s) cannot hold an array of matrices",enum_type,EnumToStringx(enum_type));}
+		void  UnitConversion(int direction_enum);
+
+		void GetParameterName(char**pname);
+		#ifdef _SERIAL_
+		void  SetMatlabField(mxArray* dataref);
+		#endif
+
+		/*}}}*/
+};
+#endif  /* _VECTORPARAM_H */
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Vertex.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Vertex.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Vertex.cpp	(revision 11708)
@@ -273,5 +273,5 @@
 /*}}}*/
 /*FUNCTION Vertex::UpdateVertexPosition {{{1*/
-void  Vertex::UpdatePosition(Vec vz,Parameters* parameters,double* thickness,double* bed){
+void  Vertex::UpdatePosition(Vector* vz,Parameters* parameters,double* thickness,double* bed){
 
 	double oldz,newz;
@@ -288,5 +288,5 @@
 
 	/*put vz in vector*/
-	VecSetValue(vz,this->dof,velz,INSERT_VALUES);
-}
-/*}}}*/
+	vz->SetValue(this->dof,velz,INS_VAL);
+}
+/*}}}*/
Index: /issm/branches/trunk-jpl-damage/src/c/objects/Vertex.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/Vertex.h	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/Vertex.h	(revision 11708)
@@ -10,4 +10,6 @@
 #include "./Object.h"
 class IoModel;
+class Vector;
+class Parameters;
 #include "../shared/Exceptions/exceptions.h"
 #include "../toolkits/toolkits.h"
@@ -63,5 +65,5 @@
 		int   Sid(void); 
 		int   Connectivity(void); 
-		void  UpdatePosition(Vec vz,Parameters* parameters,double* thickness,double* bed);
+		void  UpdatePosition(Vector* vz,Parameters* parameters,double* thickness,double* bed);
 		/*}}}*/
 };
Index: /issm/branches/trunk-jpl-damage/src/c/objects/objects.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/objects/objects.h	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/objects/objects.h	(revision 11708)
@@ -135,6 +135,6 @@
 #include "./Params/FileParam.h"
 #include "./Params/Param.h"
-#include "./Params/PetscMatParam.h"
-#include "./Params/PetscVecParam.h"
+#include "./Params/MatrixParam.h"
+#include "./Params/VectorParam.h"
 #include "./Params/StringArrayParam.h"
 #include "./Params/StringParam.h"
Index: /issm/branches/trunk-jpl-damage/src/c/shared/Alloc/alloc.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/shared/Alloc/alloc.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/shared/Alloc/alloc.cpp	(revision 11708)
@@ -67,12 +67,11 @@
 }
 
-void xfree( void* *pv){
+void xfree(void* *pv){
 
-	if (pv && *pv) {
-
+	if (pv && *pv){
 		#ifdef _SERIAL_
-		mxFree(*pv);
+			mxFree(*pv);
 		#else
-		free(*pv);
+			free(*pv);
 		#endif
 
@@ -81,18 +80,34 @@
 }
 
-void xdelete( Matrix** pv){
-
-	if (pv && *pv) {
-
+void xdelete(Matrix** pv){
+	
+	if (pv && *pv){
+		#ifdef _PARALLEL_ 
+		/*There is no mxDelete in the Matlab API -> using delete trips up Matlab. So we 
+		 * don't actually free memory in Matlab, we let the memory manager do that. We only
+		 * free in parallel: */
 		delete *pv;
+		#else
+		/*Actually, still get rid of internal Petsc matrix. Quick fix until Matlab handles C++ 
+		 * correctly: */
+		MatFree(&(*pv)->matrix);
+		#endif
 		*pv=NULL;
 	}
 }
 
-void xdelete( Vector** pv){
+void xdelete(Vector** pv){
 
-	if (pv && *pv) {
-
+	if (pv && *pv){
+		#ifdef _PARALLEL_ 
+		/*There is no mxDelete in the Matlab API -> using delete trips up Matlab. So we 
+		 * don't actually free memory in Matlab, we let the memory manager do that. We only
+		 * free in parallel: */
 		delete *pv;
+		#else
+		/*Actually, still get rid of internal Petsc vector. Quick fix until Matlab handles C++ 
+		 * correctly: */
+		VecFree(&(*pv)->vector);
+		#endif
 		*pv=NULL;
 	}
@@ -100,5 +115,5 @@
 
 
-void* xrealloc ( void* pv, int size){
+void* xrealloc( void* pv, int size){
 	
 	register void* value=NULL;
Index: /issm/branches/trunk-jpl-damage/src/c/shared/Exp/IsInPoly.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/shared/Exp/IsInPoly.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/shared/Exp/IsInPoly.cpp	(revision 11708)
@@ -15,5 +15,5 @@
 
 /*IsInPoly {{{1*/
-int IsInPoly(Vec in,double* xc,double* yc,int numvertices,double* x,double* y,int i0,int i1, int edgevalue){
+int IsInPoly(Vector* in,double* xc,double* yc,int numvertices,double* x,double* y,int i0,int i1, int edgevalue){
 
 	int i;
@@ -37,5 +37,5 @@
 
 		//Get current value of value[i] -> do not change it if != 0
-		VecGetValues(in,1,&i,&value);
+		in->GetValue(&value,i);
 		if (value){
 			/*this vertex already is inside one of the contours, continue*/
@@ -51,10 +51,10 @@
 			value=pnpoly(numvertices,xc,yc,x0,y0,edgevalue);
 		}
-		VecSetValues(in,1,&i,&value,INSERT_VALUES);
+		in->SetValue(i,value,INS_VAL);
 	}
 	 return 1;
 }/*}}}*/
 /*IsOutsidePoly {{{1*/
-int IsOutsidePoly(Vec in,double* xc,double* yc,int numvertices,double* x,double* y,int i0,int i1, int edgevalue){
+int IsOutsidePoly(Vector* in,double* xc,double* yc,int numvertices,double* x,double* y,int i0,int i1, int edgevalue){
 
 	int i,j;
@@ -78,5 +78,5 @@
 
 		//Get current value of value[i] -> do not change it if != 0
-		VecGetValues(in,1,&i,&value);
+		in->GetValue(&value,i);
 		if (value){
 			/*this vertex already is inside one of the contours, continue*/
@@ -92,5 +92,5 @@
 			value=1-pnpoly(numvertices,xc,yc,x0,y0,edgevalue);
 		}
-		VecSetValues(in,1,&i,&value,INSERT_VALUES);
+		in->SetValue(i,value,INS_VAL);
 	}
 	return 1;
Index: /issm/branches/trunk-jpl-damage/src/c/shared/Exp/exp.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/shared/Exp/exp.h	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/shared/Exp/exp.h	(revision 11708)
@@ -9,6 +9,6 @@
 #include "../../toolkits/toolkits.h"
 
-int IsInPoly(Vec in,double* xc,double* yc,int numvertices,double* x,double* y,int i0,int i1, int edgevalue);
-int IsOutsidePoly(Vec in,double* xc,double* yc,int numvertices,double* x,double* y,int i0,int i1, int edgevalue);
+int IsInPoly(Vector* in,double* xc,double* yc,int numvertices,double* x,double* y,int i0,int i1, int edgevalue);
+int IsOutsidePoly(Vector* in,double* xc,double* yc,int numvertices,double* x,double* y,int i0,int i1, int edgevalue);
 int IsInPolySerial(double* in,double* xc,double* yc,int numvertices,double* x,double* y,int nods, int edgevalue);
 int DomainOutlineRead(int* pnprof,int** pprofnvertices,double*** ppprofx,double*** ppprofy,bool** pclosed,char* domainname,bool whole);
Index: /issm/branches/trunk-jpl-damage/src/c/shared/Matlab/ModuleBoot.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/shared/Matlab/ModuleBoot.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/shared/Matlab/ModuleBoot.cpp	(revision 11708)
@@ -5,4 +5,11 @@
 
 #include "../../toolkits/toolkits.h"
+
+#ifdef HAVE_CONFIG_H
+	#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
 
 int my_rank;
@@ -16,32 +23,34 @@
 
 	/*Some test for MPI_Init crash with mpich2 1.4 on larsen, just ignore*/
-	#if _PETSC_MAJOR_ == 3 && _PETSC_MINOR_ < 1
-	if(0){
-		int              mp_init = 0;
-		PetscErrorCode   ierr;
-		extern PetscBool PetscBeganMPI;
-		MPI_Initialized(&mp_init); 
-		if(mp_init!=1){
-			MPI_Init(NULL,NULL); 
-			PetscBeganMPI = PETSC_TRUE;
+	#ifdef _HAVE_PETSC_
+		#if _PETSC_MAJOR_ == 3 && _PETSC_MINOR_ < 1
+		if(0){
+			int              mp_init = 0;
+			PetscErrorCode   ierr;
+			extern PetscBool PetscBeganMPI;
+			MPI_Initialized(&mp_init); 
+			if(mp_init!=1){
+				MPI_Init(NULL,NULL); 
+				PetscBeganMPI = PETSC_TRUE;
+				ierr=PetscInitializeNoArguments();CHKERRQ(ierr);
+			} 
+		}
+		else if (0){
+			PetscErrorCode   ierr;
+			PetscBool flg;
+			ierr=PetscInitialized(&flg);CHKERRQ(ierr);
+			if(flg){
+				extern PetscBool PetscBeganMPI;
+				PetscBeganMPI = PETSC_FALSE;
+				ierr=PetscFinalize();CHKERRQ(ierr);
+			}
 			ierr=PetscInitializeNoArguments();CHKERRQ(ierr);
-		} 
-	}
-	else if (0){
-		PetscErrorCode   ierr;
-		PetscBool flg;
-		ierr=PetscInitialized(&flg);CHKERRQ(ierr);
-		if(flg){
-			extern PetscBool PetscBeganMPI;
-			PetscBeganMPI = PETSC_FALSE;
-			ierr=PetscFinalize();CHKERRQ(ierr);
+			ierr=PetscPopSignalHandler();CHKERRQ(ierr);
 		}
-		ierr=PetscInitializeNoArguments();CHKERRQ(ierr);
-		ierr=PetscPopSignalHandler();CHKERRQ(ierr);
-	}
+		#endif
+
+		/*Initialize Petsc: */
+		PetscInitializeNoArguments();
 	#endif
-
-	/*Initialize Petsc: */
-	PetscInitializeNoArguments();
 
 	return 1;
Index: /issm/branches/trunk-jpl-damage/src/c/shared/Numerics/OptionsFromAnalysis.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/shared/Numerics/OptionsFromAnalysis.cpp	(revision 11708)
+++ /issm/branches/trunk-jpl-damage/src/c/shared/Numerics/OptionsFromAnalysis.cpp	(revision 11708)
@@ -0,0 +1,80 @@
+/*!\file:  OptionsFromAnalysis.cpp
+ * \brief: figure out ISSM options for current analysis, return a string.
+ */ 
+
+#ifdef HAVE_CONFIG_H
+	#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+#include "../../objects/objects.h"
+#include "../../Container/Parameters.h"
+#include "../../EnumDefinitions/EnumDefinitions.h"
+
+char* OptionsFromAnalysis(Parameters* parameters,int analysis_type){
+	
+	/*output: */
+	char*   outstring=NULL;
+
+	/*intermediary: */
+	int     dummy;
+	double* analyses=NULL;
+	char**  strings=NULL;
+	char*   string=NULL;
+	int     numanalyses;
+	int     found=-1;
+	int     i;
+
+	numanalyses=0;
+	parameters->FindParam(&strings,&numanalyses,PetscOptionsStringsEnum);
+
+	#ifdef _SERIAL_ //do not take this away, because ISSM loads analyses as a Double Param instead of a DoubleVec Param  when running with only 1 analysis
+	if(numanalyses==1){ analyses=(double*)xmalloc(1*sizeof(double)); parameters->FindParam(analyses,PetscOptionsAnalysesEnum);
+	}
+	else parameters->FindParam(&analyses,&dummy,PetscOptionsAnalysesEnum);
+	#else
+	parameters->FindParam(&analyses,&dummy,PetscOptionsAnalysesEnum);
+	#endif
+
+	if(numanalyses==0)return NULL; //we did not find petsc options, don't bother.
+
+	/*ok, go through analyses and figure out if it corresponds to our analysis_type: */
+	found=-1;
+	for(i=0;i<numanalyses;i++){
+		if (analyses[i]==analysis_type){
+			/*found the analysis, get out of here: */
+			found=i;
+			break;
+		}
+	}
+	if(found==-1){
+		/*still haven't found a list of petsc options, go find the default one, for analysis type NoneAnalysisEnum: */
+		for(i=0;i<numanalyses;i++){
+			if (analyses[i]==NoneAnalysisEnum){
+				/*found the default analysis, get out of here: */
+				found=i;
+				break;
+			}
+		}
+	}
+	if (found==-1){
+		/*ok, we did not find anything, this is not good! error out: */
+		_error_("%s%s","could find neither a default analysis  nor analysis ",EnumToStringx(analysis_type));
+	}
+
+	/*ok, grab the option string: */
+	outstring=(char*)xmalloc((strlen(strings[found])+1)*sizeof(char));
+	strcpy(outstring,strings[found]);
+
+	/*Free ressources*/
+	xfree((void**)&analyses);
+	for(i=0;i<numanalyses;i++){
+		string=strings[i];
+		xfree((void**)&string);
+	}
+	xfree((void**)&strings);
+
+
+	return outstring;
+}
Index: /issm/branches/trunk-jpl-damage/src/c/shared/Numerics/PetscOptionsFromAnalysis.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/shared/Numerics/PetscOptionsFromAnalysis.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/shared/Numerics/PetscOptionsFromAnalysis.cpp	(revision 11708)
@@ -15,51 +15,9 @@
 void PetscOptionsFromAnalysis(Parameters* parameters,int analysis_type){
 
-	int     dummy;
-	double* analyses=NULL;
-	char**  strings=NULL;
-	int     numanalyses;
-	char*   string=NULL;
-	int     found=-1;
-	int     i;
+	/*intermediary: */
+	char* options=NULL;
 
-	numanalyses=0;
-	parameters->FindParam(&strings,&numanalyses,PetscOptionsStringsEnum);
-
-	#ifdef _SERIAL_ //do not take this away, because ISSM loads analyses as a Double Param instead of a DoubleVec Param  when running with only 1 analysis
-	if(numanalyses==1){ analyses=(double*)xmalloc(1*sizeof(double)); parameters->FindParam(analyses,PetscOptionsAnalysesEnum);
-	}
-	else parameters->FindParam(&analyses,&dummy,PetscOptionsAnalysesEnum);
-	#else
-	parameters->FindParam(&analyses,&dummy,PetscOptionsAnalysesEnum);
-	#endif
-
-	if(numanalyses==0)return; //we did not find petsc options, don't bother.
-
-	/*ok, go through analyses and figure out if it corresponds to our analysis_type: */
-	found=-1;
-	for(i=0;i<numanalyses;i++){
-		if (analyses[i]==analysis_type){
-			/*found the analysis, get out of here: */
-			found=i;
-			break;
-		}
-	}
-	if(found==-1){
-		/*still haven't found a list of petsc options, go find the default one, for analysis type NoneAnalysisEnum: */
-		for(i=0;i<numanalyses;i++){
-			if (analyses[i]==NoneAnalysisEnum){
-				/*found the default analysis, get out of here: */
-				found=i;
-				break;
-			}
-		}
-	}
-	if (found==-1){
-		/*ok, we did not find anything, this is not good! error out: */
-		_error_("%s%s","could find neither a default analysis  nor analysis ",EnumToStringx(analysis_type));
-	}
-
-	/*ok, grab the petsc option string: */
-	string=strings[found];
+	/*Recover first the options string for this analysis: */
+	options=OptionsFromAnalysis(parameters,analysis_type);
 
 	/*now, reset the options database with this string. Taken from petsc/install/src/sys/objects/pinit.c. This 
@@ -72,20 +30,13 @@
 	//PetscOptionsCheckInitial_Components();
 	PetscOptionsSetFromOptions();
-	PetscOptionsInsertMultipleString(string); //our patch
+	PetscOptionsInsertMultipleString(options); //our patch
 	#else
 	PetscOptionsSetFromOptions();
 	PetscOptionsClear();
 	//PetscOptionsSetFromOptions();
-	PetscOptionsInsertMultipleString(string); //our patch
+	PetscOptionsInsertMultipleString(options); //our patch
 	#endif
 
-
-	/*Free ressources*/
-	xfree((void**)&analyses);
-	for(i=0;i<numanalyses;i++){
-		string=strings[i];
-		xfree((void**)&string);
-	}
-	xfree((void**)&strings);
-
+	/*Free ressources:*/
+	xfree((void**)&options);
 }
Index: /issm/branches/trunk-jpl-damage/src/c/shared/Numerics/numerics.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/shared/Numerics/numerics.h	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/shared/Numerics/numerics.h	(revision 11708)
@@ -27,6 +27,9 @@
 void   UnitConversion(double* values, int numvalues,int direction_enum, int type_enum);
 double UnitConversion(double value, int direction_enum, int type_enum);
+char*  OptionsFromAnalysis(Parameters* parameters,int analysis_type);
+void   XZvectorsToCoordinateSystem(double* T,double* xzvectors);
+#ifdef _HAVE_PETSC_
 void   PetscOptionsFromAnalysis(Parameters* parameters,int analysis_type);
-void   XZvectorsToCoordinateSystem(double* T,double* xzvectors);
+#endif
 
 #endif //ifndef _NUMERICS_H_
Index: /issm/branches/trunk-jpl-damage/src/c/solutions/controltao_core.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/solutions/controltao_core.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/solutions/controltao_core.cpp	(revision 11708)
@@ -13,5 +13,5 @@
 #include "../solvers/solvers.h"
 
-#if defined (_HAVE_TAO_) && (_PETSC_MAJOR_ == 3 && _PETSC_MINOR_ == 2)
+#if defined (_HAVE_TAO_) && defined (_HAVE_PETSC_) && (_PETSC_MAJOR_ == 3 && _PETSC_MINOR_ == 2)
 #include <tao.h>
 
@@ -33,7 +33,7 @@
 	double    *dummy          = NULL;
 	int       *control_list   = NULL;
-	Vec        X              = NULL;
-	Vec        XL             = NULL;
-	Vec        XU             = NULL;
+	Vector    *X              = NULL;
+	Vector    *XL             = NULL;
+	Vector    *XU             = NULL;
 
 	/*Initialize TAO*/
@@ -68,8 +68,8 @@
 	GetVectorFromControlInputsx(&XL,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,"lowerbound");
 	GetVectorFromControlInputsx(&XU,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,"upperbound");
-	TaoSetInitialVector(tao,X);
-	TaoSetVariableBounds(tao,XL,XU);
-	VecFree(&XL);
-	VecFree(&XU);
+	TaoSetInitialVector(tao,X->vector);
+	TaoSetVariableBounds(tao,XL->vector,XU->vector);
+	xdelete(&XL);
+	xdelete(&XU);
 
 	user.femmodel=femmodel;
@@ -80,5 +80,5 @@
 	TaoSolve(tao);
 	TaoView(tao,PETSC_VIEWER_STDOUT_WORLD);
-	TaoGetSolutionVector(tao,&X);
+	TaoGetSolutionVector(tao,&X->vector);
 	SetControlInputsFromVectorx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,X);
 	for(int i=0;i<num_controls;i++){
@@ -95,9 +95,9 @@
 	/*Clean up and return*/
 	xfree((void**)&control_list);
-	VecFree(&X);
+	xdelete(&X);
 	TaoDestroy(&tao);
 	TaoFinalize();
 }
-int FormFunctionGradient(TaoSolver tao, Vec X, double *fcn,Vec G,void *userCtx){
+int FormFunctionGradient(TaoSolver tao, Vec Xpetsc, double *fcn,Vec G,void *userCtx){
 
 	/*Retreive arguments*/
@@ -107,9 +107,14 @@
 	int      *cost_functions = NULL;
 	double   *cost_functionsd= NULL;
-	Vec       gradient       = NULL;
+	Vector   *gradient       = NULL;
+	Vector   *X              = NULL;
+
+	/*Convert input to Vec*/
+	X=new Vector(Xpetsc);
 
 	/*Set new variable*/
 	//VecView(X,PETSC_VIEWER_STDOUT_WORLD);
 	SetControlInputsFromVectorx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,X);
+	xdelete(&X);
 
 	/*Recover some parameters*/
@@ -136,5 +141,5 @@
 	/*Compute gradient*/
 	Gradjx(&gradient,NULL,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters);
-	VecCopy(gradient,G); VecFree(&gradient);
+	VecCopy(gradient->vector,G); xdelete(&gradient);
 	VecScale(G,-1.);
 
Index: /issm/branches/trunk-jpl-damage/src/c/solutions/convergence.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/solutions/convergence.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/solutions/convergence.cpp	(revision 11708)
@@ -52,6 +52,6 @@
 
 		//compute norm(KUF), norm(F) and residue
-		nKUF=KUF->Norm(NORM_2);
-		nF=pf->Norm(NORM_2);
+		nKUF=KUF->Norm(NORM_TWO);
+		nF=pf->Norm(NORM_TWO);
 		solver_residue=nKUF/nF;
 		_printf_(true,"\n%s%g\n","   solver residue: norm(KU-F)/norm(F)=",solver_residue);
@@ -67,6 +67,6 @@
 	KUold=uf->Duplicate(); Kff->MatMult(old_uf,KUold);
 	KUoldF=KUold->Duplicate();KUold->Copy(KUoldF); KUoldF->AYPX(pf,-1.0);
-	nKUoldF=KUoldF->Norm(NORM_2);
-	nF=pf->Norm(NORM_2);
+	nKUoldF=KUoldF->Norm(NORM_TWO);
+	nF=pf->Norm(NORM_TWO);
 	res=nKUoldF/nF;
 	if (isnan(res)){
@@ -94,5 +94,5 @@
 		//compute norm(du)/norm(u)
 		duf=old_uf->Duplicate(); old_uf->Copy(duf); duf->AYPX(uf,-1.0);
-		ndu=duf->Norm(NORM_2); nu=old_uf->Norm(NORM_2);
+		ndu=duf->Norm(NORM_TWO); nu=old_uf->Norm(NORM_TWO);
 
 		if (isnan(ndu) || isnan(nu)) _error_("convergence criterion is NaN!");
@@ -120,5 +120,5 @@
 		//compute max(du)
 		duf=old_uf->Duplicate(); old_uf->Copy(duf); duf->AYPX(uf,-1.0);
-		ndu=duf->Norm(NORM_2); nduinf=duf->Norm(NORM_INFINITY);
+		ndu=duf->Norm(NORM_TWO); nduinf=duf->Norm(NORM_INF);
 		if (isnan(ndu) || isnan(nu)) _error_("convergence criterion is NaN!");
 
Index: /issm/branches/trunk-jpl-damage/src/c/solutions/gradient_core.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/solutions/gradient_core.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/solutions/gradient_core.cpp	(revision 11708)
@@ -18,7 +18,7 @@
 	double  norm_inf;
 	double *norm_list    = NULL;
-	Vec     new_gradient = NULL;
-	Vec     gradient     = NULL;
-	Vec     old_gradient = NULL;
+	Vector*     new_gradient = NULL;
+	Vector*     gradient     = NULL;
+	Vector*     old_gradient = NULL;
 
 	/*Compute gradient*/
@@ -29,5 +29,5 @@
 		_printf_(VerboseControl(),"   orthogonalization\n");
 		ControlInputGetGradientx(&old_gradient,femmodel->elements,femmodel->nodes, femmodel->vertices,femmodel->loads, femmodel->materials,femmodel->parameters);
-		Orthx(&new_gradient,gradient,old_gradient); VecFree(&old_gradient); VecFree(&gradient);
+		Orthx(&new_gradient,gradient,old_gradient); xdelete(&old_gradient); xdelete(&gradient);
 	}
 	else{ 
@@ -36,5 +36,5 @@
 
 	/*Check that gradient is clean*/
-	VecNorm(new_gradient,NORM_INFINITY,&norm_inf);
+	norm_inf=new_gradient->Norm(NORM_INF);
 	if(norm_inf<=0)    _error_("||∂J/∂α||∞ = 0    gradient norm is zero");
 	if(isnan(norm_inf))_error_("||∂J/∂α||∞ = NaN  gradient norm is NaN");
@@ -42,5 +42,5 @@
 	/*plug back into inputs: */
 	ControlInputSetGradientx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,new_gradient);
-	VecFree(&new_gradient);
+	xdelete(&new_gradient);
 
 	/*Scale Gradients*/
Index: /issm/branches/trunk-jpl-damage/src/c/solutions/issm.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/solutions/issm.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/solutions/issm.cpp	(revision 11708)
@@ -37,4 +37,5 @@
 	double   start_core, finish_core;
 	double   start_init, finish_init;
+	int      ierr;
 
 	MODULEBOOT();
@@ -44,7 +45,12 @@
 	#endif
 
-	/*Initialize Petsc and get start time*/
-	int ierr=PetscInitialize(&argc,&argv,(char*)0,"");  
+	/*Initialize environments: Petsc, MPI, etc...: */
+	#ifdef _HAVE_PETSC_
+	ierr=PetscInitialize(&argc,&argv,(char*)0,"");  
 	if(ierr) _error_("Could not initialize Petsc");
+	#else
+	MPI_Init(&argc,&argv);
+	#endif
+
 	MPI_Barrier(MPI_COMM_WORLD); start=MPI_Wtime();
 
@@ -130,6 +136,12 @@
 	_printf_(true,"   %-34s %f seconds  \n","Core solution elapsed time:",finish_core-start_core);
 	_printf_(true,"\n   %s %i hrs %i min %i sec\n\n","Total elapsed time:",int((finish-start)/3600),int(int(finish-start)%3600/60),int(finish-start)%60);
+	
+	
 	_printf_(true,"closing MPI and Petsc\n");
+	#ifdef _HAVE_PETSC_
 	PetscFinalize(); 
+	#else
+	MPI_Finalize();
+	#endif
 	
 	/*end module: */
Index: /issm/branches/trunk-jpl-damage/src/c/toolkits/double/MatlabMatrixToDoubleMatrix.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/toolkits/double/MatlabMatrixToDoubleMatrix.cpp	(revision 11708)
+++ /issm/branches/trunk-jpl-damage/src/c/toolkits/double/MatlabMatrixToDoubleMatrix.cpp	(revision 11708)
@@ -0,0 +1,97 @@
+/* \file MatlabMatrixToDoubleMatrix.cpp
+ * \brief: convert a sparse or dense matlab matrix to a double* pointer
+ */
+
+
+#ifdef HAVE_CONFIG_H
+	#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+
+#ifdef _SERIAL_
+
+/*Matlab includes: */
+#include "mex.h"
+
+#include "../../shared/shared.h"
+
+int MatlabMatrixToDoubleMatrix(double** pmatrix,int* pmatrix_rows,int* pmatrix_cols,const mxArray* mxmatrix){
+
+	int     i,j,count,rows,cols;
+	double *pmxdoublematrix = NULL;
+	float  *pmxsinglematrix = NULL;
+
+	/*output: */
+	double* matrix=NULL;
+
+	/*matlab indices: */
+	mwIndex*    ir=NULL;
+	mwIndex*    jc=NULL;
+
+	/*Ok, first check if we are dealing with a sparse or full matrix: */
+	if (mxIsSparse(mxmatrix)){
+
+		/*Dealing with sparse matrix: recover size first: */
+		pmxdoublematrix=(double*)mxGetPr(mxmatrix);
+		rows=mxGetM(mxmatrix);
+		cols=mxGetN(mxmatrix);
+		matrix=(double*)xcalloc(rows*cols,sizeof(double));
+
+		/*Now, get ir,jc and pr: */
+		ir=mxGetIr(mxmatrix);
+		jc=mxGetJc(mxmatrix);
+
+		/*Now, start inserting data into double* matrix: */
+		count=0;
+		for(i=0;i<cols;i++){
+			for(j=0;j<(jc[i+1]-jc[i]);j++){
+				matrix[rows*ir[count]+i]=pmxdoublematrix[count];
+				count++;
+			}
+		}
+
+	}
+	else if(mxIsClass(mxmatrix,"double")){
+		/*Dealing with dense matrix: recover pointer and size: */
+		pmxdoublematrix=(double*)mxGetPr(mxmatrix);
+		rows=mxGetM(mxmatrix);
+		cols=mxGetN(mxmatrix);
+		
+		/*Create serial matrix: */
+		matrix=(double*)xcalloc(rows*cols,sizeof(double));
+
+		for(i=0;i<rows;i++){
+			for(j=0;j<cols;j++){
+				matrix[cols*i+j]=(double)pmxdoublematrix[rows*j+i];
+			}
+		}
+	}
+	else if(mxIsClass(mxmatrix,"single")){
+		/*Dealing with dense matrix: recover pointer and size: */
+		pmxsinglematrix=(float*)mxGetPr(mxmatrix);
+		rows=mxGetM(mxmatrix);
+		cols=mxGetN(mxmatrix);
+
+		/*Create serial matrix: */
+		matrix=(double*)xcalloc(rows*cols,sizeof(double));
+
+		for(i=0;i<rows;i++){
+			for(j=0;j<cols;j++){
+				matrix[cols*i+j]=(double)pmxsinglematrix[rows*j+i];
+			}
+		}
+	}
+	else{
+		_error_("Matlab matrix type Not implemented yet");
+	}
+
+	/*Assign output pointer: */
+	*pmatrix=matrix;
+	*pmatrix_rows=rows;
+	*pmatrix_cols=cols;
+
+	return 1;
+}
+#endif
Index: /issm/branches/trunk-jpl-damage/src/c/toolkits/double/MatlabVectorToDoubleVector.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/toolkits/double/MatlabVectorToDoubleVector.cpp	(revision 11708)
+++ /issm/branches/trunk-jpl-damage/src/c/toolkits/double/MatlabVectorToDoubleVector.cpp	(revision 11708)
@@ -0,0 +1,92 @@
+/* \file MatlabVectorToDoubleVector.cpp
+ * \brief: convert a sparse or dense matlab vector to a serial vector:
+ */
+
+
+#ifdef HAVE_CONFIG_H
+	#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+
+#ifdef _SERIAL_
+
+#include <string.h>
+
+/*Matlab includes: */
+#include "mex.h"
+
+#include "../../shared/shared.h"
+
+int MatlabVectorToDoubleVector(double** pvector,int* pvector_rows,const mxArray* mxvector){
+
+	int rows,cols;
+	double* mxvector_ptr=NULL;
+	int ierr;
+	int i,j;
+
+	/*output: */
+	double* vector=NULL;
+
+	/*matlab indices: */
+	mwIndex*    ir=NULL;
+	mwIndex*    jc=NULL;
+	double* pr=NULL;
+	int     count;
+	int     nnz;
+	int     nz;
+
+	/*Ok, first check if we are dealing with a sparse or full vector: */
+	if (mxIsSparse(mxvector)){
+
+		/*Dealing with sparse vector: recover size first: */
+		mxvector_ptr=(double*)mxGetPr(mxvector);
+		rows=mxGetM(mxvector);
+		cols=mxGetN(mxvector);
+		nnz=mxGetNzmax(mxvector);
+		
+		/*Check that input is actualy a vector*/
+		if (cols!=1) _error_("input vector of size %ix%i should have only one column",rows,cols);
+
+		nz=(int)((double)nnz/(double)rows);
+
+		vector=(double*)xcalloc(rows,sizeof(double));
+
+		/*Now, get ir,jc and pr: */
+		pr=mxGetPr(mxvector);
+		ir=mxGetIr(mxvector);
+		jc=mxGetJc(mxvector);
+
+		/*Now, start inserting data into sparse vector: */
+		count=0;
+		for(i=0;i<cols;i++){
+			for(j=0;j<(jc[i+1]-jc[i]);j++){
+				vector[ir[count]]=pr[count];
+				count++;
+			}
+		}
+
+	}
+	else{
+
+		/*Dealing with dense vector: recover pointer and size: */
+		mxvector_ptr=(double*)mxGetPr(mxvector);
+		rows=mxGetM(mxvector);
+		cols=mxGetN(mxvector);
+
+		/*Check that input is actualy a vector*/
+		if (cols!=1) _error_("input vector of size %ix%i should have only one column",rows,cols);
+
+		/*allocate and memcpy*/
+		vector=(double*)xmalloc(rows*sizeof(double));
+		memcpy(vector,mxvector_ptr,rows*sizeof(double));
+	}
+
+	/*Assign output pointer: */
+	*pvector=vector;
+	*pvector_rows=rows;
+
+	return 1;
+}
+#endif
Index: /issm/branches/trunk-jpl-damage/src/c/toolkits/double/double.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/toolkits/double/double.h	(revision 11708)
+++ /issm/branches/trunk-jpl-damage/src/c/toolkits/double/double.h	(revision 11708)
@@ -0,0 +1,14 @@
+/*\file double.h
+ * \brief: our own double matrix
+ */
+
+#ifndef _DOUBLE_H_
+#define _DOUBLE_H_
+
+#ifdef _SERIAL_
+#include "mex.h"
+int MatlabMatrixToDoubleMatrix(double** pmatrix,int* pmatrix_rows,int* pmatrix_cols,const mxArray* mxmatrix);
+int MatlabVectorToDoubleVector(double** pvector,int* pvector_rows,const mxArray* mxvector);
+#endif
+
+#endif
Index: /issm/branches/trunk-jpl-damage/src/c/toolkits/mpi/patches/DetermineLocalSize.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/toolkits/mpi/patches/DetermineLocalSize.cpp	(revision 11708)
+++ /issm/branches/trunk-jpl-damage/src/c/toolkits/mpi/patches/DetermineLocalSize.cpp	(revision 11708)
@@ -0,0 +1,50 @@
+/* \file DetermineLocalSize.cpp
+ * \brief: routine to determine local size of a global petsc matrix or vector. 
+ */
+
+#include <stdio.h>
+#include <math.h>
+
+
+#include "../../../shared/shared.h"
+
+int DetermineLocalSize(int global_size){
+
+	/*output: */
+	int  local_size;
+
+	/*intermediary: */
+	int  i;
+	int  row_rest;
+	int* num_local_rows=NULL;
+
+	/*from MPI: */
+	extern int num_procs;
+	extern int my_rank;
+	
+	/*We are  not bound by any library, just use what seems most logical*/
+	num_local_rows=(int*)xmalloc(num_procs*sizeof(int));    
+
+	for (i=0;i<num_procs;i++){
+
+		/*Here, we use floor. We under distribute rows. The rows 
+		  left  are then redistributed, therefore resulting in a 
+		  more even distribution.*/
+		num_local_rows[i]=(int)floor((double)global_size/(double)num_procs); 
+	}
+	
+	/*There may be some rows left. Distribute evenly.*/ 
+	row_rest=global_size - num_procs*(int)floor((double)global_size/(double)num_procs);
+	for (i=0;i<row_rest;i++){
+		num_local_rows[i]++;
+	}
+
+	local_size=num_local_rows[my_rank];
+	
+	/*free ressources: */
+	xfree((void**)&num_local_rows);
+
+	/*return size: */
+	return local_size;
+
+}
Index: /issm/branches/trunk-jpl-damage/src/c/toolkits/mpi/patches/MPI_Boundariesfromrange.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/toolkits/mpi/patches/MPI_Boundariesfromrange.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/toolkits/mpi/patches/MPI_Boundariesfromrange.cpp	(revision 11708)
@@ -4,5 +4,4 @@
  */
 
-#include "../../petsc/patches/petscpatches.h"
 #include "./mpipatches.h"
 #include "../../../shared/shared.h"
Index: /issm/branches/trunk-jpl-damage/src/c/toolkits/mpi/patches/MPI_Lowerrow.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/toolkits/mpi/patches/MPI_Lowerrow.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/toolkits/mpi/patches/MPI_Lowerrow.cpp	(revision 11708)
@@ -7,5 +7,4 @@
  */
 
-#include "../../petsc/patches/petscpatches.h"
 #include "./mpipatches.h"
 
@@ -19,5 +18,5 @@
 
 	/*First, figure out our range : */
-	range=PetscDetermineLocalSize(n);
+	range=DetermineLocalSize(n);
 
 	/*Now determien upper and lower boundaries: */
Index: /issm/branches/trunk-jpl-damage/src/c/toolkits/mpi/patches/MPI_Upperrow.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/toolkits/mpi/patches/MPI_Upperrow.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/toolkits/mpi/patches/MPI_Upperrow.cpp	(revision 11708)
@@ -7,5 +7,4 @@
  */
 
-#include "../../petsc/patches/petscpatches.h"
 #include "./mpipatches.h"
 
@@ -17,5 +16,5 @@
 
 	/*First, figure out our range : */
-	range=PetscDetermineLocalSize(n);
+	range=DetermineLocalSize(n);
 
 	/*Now determien upper and lower boundaries: */
Index: /issm/branches/trunk-jpl-damage/src/c/toolkits/mpi/patches/mpipatches.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/toolkits/mpi/patches/mpipatches.h	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/toolkits/mpi/patches/mpipatches.h	(revision 11708)
@@ -11,4 +11,5 @@
 int MPI_Lowerrow(int n);
 int MPI_Upperrow(int n);
+int DetermineLocalSize(int global_size);
 
 
Index: /issm/branches/trunk-jpl-damage/src/c/toolkits/petsc/patches/ISSMToPetscInsertMode.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/toolkits/petsc/patches/ISSMToPetscInsertMode.cpp	(revision 11708)
+++ /issm/branches/trunk-jpl-damage/src/c/toolkits/petsc/patches/ISSMToPetscInsertMode.cpp	(revision 11708)
@@ -0,0 +1,35 @@
+/* \file ISSMToPetscInsertMode.cpp
+ * \brief: convert InsertMode from ISSM to Petsc
+ */
+
+
+#ifdef HAVE_CONFIG_H
+	#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+/*Petsc includes: */
+#include "petscmat.h"
+#include "petscvec.h"
+#include "petscksp.h"
+
+/*ISSM includes: */
+#include "../../toolkitsenums.h"
+#include "../../../shared/shared.h"
+
+
+InsertMode ISSMToPetscInsertMode(InsMode mode){
+
+	switch(mode){
+		case ADD_VAL:  
+			return ADD_VALUES;
+			break;
+		case INS_VAL:
+			return INSERT_VALUES;
+			break;
+		default: 
+			_error_("unknown insert mode!");
+			break;
+	}
+}
Index: /issm/branches/trunk-jpl-damage/src/c/toolkits/petsc/patches/ISSMToPetscNormMode.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/toolkits/petsc/patches/ISSMToPetscNormMode.cpp	(revision 11708)
+++ /issm/branches/trunk-jpl-damage/src/c/toolkits/petsc/patches/ISSMToPetscNormMode.cpp	(revision 11708)
@@ -0,0 +1,35 @@
+/* \file ISSMToPetscNormMode.cpp
+ * \brief: convert NormMode from ISSM to Petsc
+ */
+
+
+#ifdef HAVE_CONFIG_H
+	#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+/*Petsc includes: */
+#include "petscmat.h"
+#include "petscvec.h"
+#include "petscksp.h"
+
+/*ISSM includes: */
+#include "../../toolkitsenums.h"
+#include "../../../shared/shared.h"
+
+
+NormType ISSMToPetscNormMode(NormMode mode){
+
+	switch(mode){
+		case NORM_INF:  
+			return NORM_INFINITY;
+			break;
+		case NORM_TWO:  
+			return NORM_2;
+			break;
+		default: 
+			_error_("unknown norm !");
+			break;
+	}
+}
Index: /issm/branches/trunk-jpl-damage/src/c/toolkits/petsc/patches/MatPartition.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/toolkits/petsc/patches/MatPartition.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/toolkits/petsc/patches/MatPartition.cpp	(revision 11708)
@@ -15,4 +15,5 @@
 
 #include "../../../shared/shared.h"
+#include "../../mpi/patches/mpipatches.h"
 
 int MatPartition(Mat* poutmatrix,Mat matrixA,double* row_partition_vector,int row_partition_vector_size ,
@@ -97,5 +98,5 @@
 
 		/*Call MatGetSubMatrix*/
-		csize=PetscDetermineLocalSize(col_partition_vector_size);
+		csize=DetermineLocalSize(col_partition_vector_size);
 		if(col_partition_vector_size==row_partition_vector_size){
 			#if _PETSC_MAJOR_ >= 3 
Index: /issm/branches/trunk-jpl-damage/src/c/toolkits/petsc/patches/MatToSerial.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/toolkits/petsc/patches/MatToSerial.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/toolkits/petsc/patches/MatToSerial.cpp	(revision 11708)
@@ -2,4 +2,11 @@
  * \brief gather a Petsc Mat matrix onto cpu 0
  */
+
+#ifdef HAVE_CONFIG_H
+	#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
 
 #include "../petscincludes.h"
Index: sm/branches/trunk-jpl-damage/src/c/toolkits/petsc/patches/MatlabMatrixToDoubleMatrix.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/toolkits/petsc/patches/MatlabMatrixToDoubleMatrix.cpp	(revision 11707)
+++ 	(revision )
@@ -1,102 +1,0 @@
-/* \file MatlabMatrixToDoubleMatrix.cpp
- * \brief: convert a sparse or dense matlab matrix to a double* pointer
- */
-
-
-#ifdef HAVE_CONFIG_H
-	#include <config.h>
-#else
-#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
-#endif
-
-
-#ifdef _SERIAL_
-
-/*Petsc includes: */
-#include "petscmat.h"
-#include "petscvec.h"
-#include "petscksp.h"
-
-/*Matlab includes: */
-#include "mex.h"
-
-#include "../../../shared/shared.h"
-
-int MatlabMatrixToDoubleMatrix(double** pmatrix,int* pmatrix_rows,int* pmatrix_cols,const mxArray* mxmatrix){
-
-	int     i,j,count,rows,cols;
-	double *pmxdoublematrix = NULL;
-	float  *pmxsinglematrix = NULL;
-
-	/*output: */
-	double* matrix=NULL;
-
-	/*matlab indices: */
-	mwIndex*    ir=NULL;
-	mwIndex*    jc=NULL;
-
-	/*Ok, first check if we are dealing with a sparse or full matrix: */
-	if (mxIsSparse(mxmatrix)){
-
-		/*Dealing with sparse matrix: recover size first: */
-		pmxdoublematrix=(double*)mxGetPr(mxmatrix);
-		rows=mxGetM(mxmatrix);
-		cols=mxGetN(mxmatrix);
-		matrix=(double*)xcalloc(rows*cols,sizeof(double));
-
-		/*Now, get ir,jc and pr: */
-		ir=mxGetIr(mxmatrix);
-		jc=mxGetJc(mxmatrix);
-
-		/*Now, start inserting data into double* matrix: */
-		count=0;
-		for(i=0;i<cols;i++){
-			for(j=0;j<(jc[i+1]-jc[i]);j++){
-				matrix[rows*ir[count]+i]=pmxdoublematrix[count];
-				count++;
-			}
-		}
-
-	}
-	else if(mxIsClass(mxmatrix,"double")){
-		/*Dealing with dense matrix: recover pointer and size: */
-		pmxdoublematrix=(double*)mxGetPr(mxmatrix);
-		rows=mxGetM(mxmatrix);
-		cols=mxGetN(mxmatrix);
-		
-		/*Create serial matrix: */
-		matrix=(double*)xcalloc(rows*cols,sizeof(double));
-
-		for(i=0;i<rows;i++){
-			for(j=0;j<cols;j++){
-				matrix[cols*i+j]=(double)pmxdoublematrix[rows*j+i];
-			}
-		}
-	}
-	else if(mxIsClass(mxmatrix,"single")){
-		/*Dealing with dense matrix: recover pointer and size: */
-		pmxsinglematrix=(float*)mxGetPr(mxmatrix);
-		rows=mxGetM(mxmatrix);
-		cols=mxGetN(mxmatrix);
-
-		/*Create serial matrix: */
-		matrix=(double*)xcalloc(rows*cols,sizeof(double));
-
-		for(i=0;i<rows;i++){
-			for(j=0;j<cols;j++){
-				matrix[cols*i+j]=(double)pmxsinglematrix[rows*j+i];
-			}
-		}
-	}
-	else{
-		_error_("Matlab matrix type Not implemented yet");
-	}
-
-	/*Assign output pointer: */
-	*pmatrix=matrix;
-	*pmatrix_rows=rows;
-	*pmatrix_cols=cols;
-
-	return 1;
-}
-#endif
Index: sm/branches/trunk-jpl-damage/src/c/toolkits/petsc/patches/MatlabVectorToDoubleVector.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/toolkits/petsc/patches/MatlabVectorToDoubleVector.cpp	(revision 11707)
+++ 	(revision )
@@ -1,98 +1,0 @@
-/* \file MatlabVectorToDoubleVector.cpp
- * \brief: convert a sparse or dense matlab vector to a serial vector:
- */
-
-
-#ifdef HAVE_CONFIG_H
-	#include <config.h>
-#else
-#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
-#endif
-
-
-#ifdef _SERIAL_
-
-#include <string.h>
-
-/*Petsc includes: */
-#include "petscmat.h"
-#include "petscvec.h"
-#include "petscksp.h"
-
-
-/*Matlab includes: */
-#include "mex.h"
-
-#include "../../../shared/shared.h"
-
-int MatlabVectorToDoubleVector(double** pvector,int* pvector_rows,const mxArray* mxvector){
-
-	int rows,cols;
-	double* mxvector_ptr=NULL;
-	int ierr;
-	int i,j;
-
-	/*output: */
-	double* vector=NULL;
-
-	/*matlab indices: */
-	mwIndex*    ir=NULL;
-	mwIndex*    jc=NULL;
-	double* pr=NULL;
-	int     count;
-	int     nnz;
-	int     nz;
-
-	/*Ok, first check if we are dealing with a sparse or full vector: */
-	if (mxIsSparse(mxvector)){
-
-		/*Dealing with sparse vector: recover size first: */
-		mxvector_ptr=(double*)mxGetPr(mxvector);
-		rows=mxGetM(mxvector);
-		cols=mxGetN(mxvector);
-		nnz=mxGetNzmax(mxvector);
-		
-		/*Check that input is actualy a vector*/
-		if (cols!=1) _error_("input vector of size %ix%i should have only one column",rows,cols);
-
-		nz=(int)((double)nnz/(double)rows);
-
-		vector=(double*)xcalloc(rows,sizeof(double));
-
-		/*Now, get ir,jc and pr: */
-		pr=mxGetPr(mxvector);
-		ir=mxGetIr(mxvector);
-		jc=mxGetJc(mxvector);
-
-		/*Now, start inserting data into sparse vector: */
-		count=0;
-		for(i=0;i<cols;i++){
-			for(j=0;j<(jc[i+1]-jc[i]);j++){
-				vector[ir[count]]=pr[count];
-				count++;
-			}
-		}
-
-	}
-	else{
-
-		/*Dealing with dense vector: recover pointer and size: */
-		mxvector_ptr=(double*)mxGetPr(mxvector);
-		rows=mxGetM(mxvector);
-		cols=mxGetN(mxvector);
-
-		/*Check that input is actualy a vector*/
-		if (cols!=1) _error_("input vector of size %ix%i should have only one column",rows,cols);
-
-		/*allocate and memcpy*/
-		vector=(double*)xmalloc(rows*sizeof(double));
-		memcpy(vector,mxvector_ptr,rows*sizeof(double));
-	}
-
-	/*Assign output pointer: */
-	*pvector=vector;
-	*pvector_rows=rows;
-
-	return 1;
-}
-#endif
Index: /issm/branches/trunk-jpl-damage/src/c/toolkits/petsc/patches/NewMat.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/toolkits/petsc/patches/NewMat.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/toolkits/petsc/patches/NewMat.cpp	(revision 11708)
@@ -18,4 +18,5 @@
 #include "../../../shared/shared.h"
 #include "../../../include/include.h"
+#include "../../mpi/patches/mpipatches.h"
 
 /*NewMat(int M,int N){{{1*/
@@ -31,6 +32,6 @@
 
 	/*Determine local sizes: */
-	m=PetscDetermineLocalSize(M);
-	n=PetscDetermineLocalSize(N);
+	m=DetermineLocalSize(M);
+	n=DetermineLocalSize(N);
 	
 	nnz=(int)((double)M*(double)N*sparsity); //number of non zeros.
@@ -55,6 +56,6 @@
 
 	/*Determine local sizes: */
-	m=PetscDetermineLocalSize(M);
-	n=PetscDetermineLocalSize(N);
+	m=DetermineLocalSize(M);
+	n=DetermineLocalSize(N);
 	
 	nnz=(int)((double)M*(double)N*sparsity); //number of non zeros.
@@ -85,6 +86,6 @@
 
 	/*Determine local sizes: */
-	m=PetscDetermineLocalSize(M);
-	n=PetscDetermineLocalSize(N);
+	m=DetermineLocalSize(M);
+	n=DetermineLocalSize(N);
 
 	/*Figure out number of non zeros per row: */
Index: /issm/branches/trunk-jpl-damage/src/c/toolkits/petsc/patches/NewVec.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/toolkits/petsc/patches/NewVec.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/toolkits/petsc/patches/NewVec.cpp	(revision 11708)
@@ -15,4 +15,5 @@
 
 #include "./petscpatches.h"
+#include "../../mpi/patches/mpipatches.h"
 
 Vec NewVec(int size,bool fromlocalsize){
@@ -29,5 +30,5 @@
 	}
 	else{
-		local_size=PetscDetermineLocalSize(size);
+		local_size=DetermineLocalSize(size);
 	}
 	
Index: sm/branches/trunk-jpl-damage/src/c/toolkits/petsc/patches/PetscDetermineLocalSize.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/toolkits/petsc/patches/PetscDetermineLocalSize.cpp	(revision 11707)
+++ 	(revision )
@@ -1,50 +1,0 @@
-/* \file PetscDetermineLocalSize.cpp
- * \brief: routine to determine local size of a global petsc matrix or vector. 
- */
-
-#include <stdio.h>
-#include <math.h>
-
-
-#include "../../../shared/shared.h"
-
-int PetscDetermineLocalSize(int global_size){
-
-	/*output: */
-	int  local_size;
-
-	/*intermediary: */
-	int  i;
-	int  row_rest;
-	int* num_local_rows=NULL;
-
-	/*from MPI: */
-	extern int num_procs;
-	extern int my_rank;
-	
-	/*We are  not bound by any library, just use what seems most logical*/
-	num_local_rows=(int*)xmalloc(num_procs*sizeof(int));    
-
-	for (i=0;i<num_procs;i++){
-
-		/*Here, we use floor. We under distribute rows. The rows 
-		  left  are then redistributed, therefore resulting in a 
-		  more even distribution.*/
-		num_local_rows[i]=(int)floor((double)global_size/(double)num_procs); 
-	}
-	
-	/*There may be some rows left. Distribute evenly.*/ 
-	row_rest=global_size - num_procs*(int)floor((double)global_size/(double)num_procs);
-	for (i=0;i<row_rest;i++){
-		num_local_rows[i]++;
-	}
-
-	local_size=num_local_rows[my_rank];
-	
-	/*free ressources: */
-	xfree((void**)&num_local_rows);
-
-	/*return size: */
-	return local_size;
-
-}
Index: /issm/branches/trunk-jpl-damage/src/c/toolkits/petsc/patches/VecToMPISerial.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/toolkits/petsc/patches/VecToMPISerial.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/toolkits/petsc/patches/VecToMPISerial.cpp	(revision 11708)
@@ -2,4 +2,11 @@
  * \brief gather a Petsc Vector spread across the cluster, onto node 0, and then broadcast to all nodes. 
  */
+
+#ifdef HAVE_CONFIG_H
+	#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
 
 #include "../petscincludes.h"
Index: /issm/branches/trunk-jpl-damage/src/c/toolkits/petsc/patches/petscpatches.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/toolkits/petsc/patches/petscpatches.h	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/toolkits/petsc/patches/petscpatches.h	(revision 11708)
@@ -12,4 +12,5 @@
 
 #include "./SolverEnum.h"
+#include "../../toolkitsenums.h"
 
 class Parameters;
@@ -21,9 +22,6 @@
 int PetscMatrixToMatlabMatrix(mxArray** pdataref,Mat matrix);
 int PetscVectorToMatlabVector(mxArray** pdataref,Vec vector);
-int MatlabMatrixToDoubleMatrix(double** pmatrix,int* pmatrix_rows,int* pmatrix_cols,const mxArray* mxmatrix);
-int MatlabVectorToDoubleVector(double** pvector,int* pvector_rows,const mxArray* mxvector);
 #endif
 
-int PetscDetermineLocalSize(int global_size);
 Vec NewVec(int size,bool fromlocalsize=false);
 Mat NewMat(int M,int N);
@@ -49,4 +47,6 @@
 void VecDuplicatePatch(Vec* output, Vec input);
 Vec  SerialToVec(double* vector,int vector_size);
+InsertMode ISSMToPetscInsertMode(InsMode mode);
+NormType ISSMToPetscNormMode(NormMode mode);
 
 #endif
Index: /issm/branches/trunk-jpl-damage/src/c/toolkits/petsc/petscincludes.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/toolkits/petsc/petscincludes.h	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/toolkits/petsc/petscincludes.h	(revision 11708)
@@ -5,4 +5,6 @@
 #ifndef _PETSC_INCLUDES_H_
 #define _PETSC_INCLUDES_H_
+
+#ifdef _HAVE_PETSC_
 
 /*Petsc includes: */
@@ -16,2 +18,3 @@
 
 #endif
+#endif
Index: /issm/branches/trunk-jpl-damage/src/c/toolkits/plapack/plapackincludes.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/toolkits/plapack/plapackincludes.h	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/toolkits/plapack/plapackincludes.h	(revision 11708)
@@ -6,4 +6,11 @@
 #define _PLA_INCLUDES_H_
 
+#ifdef HAVE_CONFIG_H
+	#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+
 #include "PLA.h"
 
@@ -12,5 +19,7 @@
 
 /*our own patches: */
+#ifdef _HAVE_PETSC_
 #include "patches/petscpatches.h"
+#endif
 
 
Index: /issm/branches/trunk-jpl-damage/src/c/toolkits/toolkits.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/toolkits/toolkits.h	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/c/toolkits/toolkits.h	(revision 11708)
@@ -6,9 +6,20 @@
 #define _TOOLKITS_H_
 
+#ifdef HAVE_CONFIG_H
+	#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+#ifdef _HAVE_PETSC_
 #include "./petsc/petscincludes.h"
+#endif
+
 #include "./mpi/mpiincludes.h"
 #include "./metis/metisincludes.h"
 #include "./triangle/triangleincludes.h"
 #include "./matlab/matlabincludes.h"
+#include "./double/double.h"
+#include "./toolkitsenums.h"
 
 #endif
Index: /issm/branches/trunk-jpl-damage/src/c/toolkits/toolkitsenums.h
===================================================================
--- /issm/branches/trunk-jpl-damage/src/c/toolkits/toolkitsenums.h	(revision 11708)
+++ /issm/branches/trunk-jpl-damage/src/c/toolkits/toolkitsenums.h	(revision 11708)
@@ -0,0 +1,17 @@
+/* \file toolkitsenums.h
+ * \brief: enums that encompasse all of the toolkit APIs. This mainly maps into PETSC enums.
+ */
+
+#ifndef _TOOLKITSENUMS_H_
+#define _TOOLKITSENUMS_H_
+
+#ifdef HAVE_CONFIG_H
+	#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+typedef enum {INS_VAL, ADD_VAL} InsMode;
+typedef enum {NORM_INF,NORM_TWO} NormMode;
+
+#endif
Index: /issm/branches/trunk-jpl-damage/src/m/classes/inversion.m
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/classes/inversion.m	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/m/classes/inversion.m	(revision 11708)
@@ -91,8 +91,7 @@
 
 			checkfield(md,'inversion.iscontrol','values',[0 1]);
-			checkfield(md,'inversion.control_parameters','cell',1,'values',{'BalancethicknessThickeningRate' 'FrictionCoefficient' 'MaterialsRheologyBbar' 'MaterialsRheologyZbar' 'Vx' 'Vy'});
 			checkfield(md,'inversion.tao','values',[0 1]);
 			checkfield(md,'inversion.incomplete_adjoint','values',[0 1]);
-			checkfield(md,'inversion.control_parameters','cell',1,'values',{'BalancethicknessThickeningRate' 'FrictionCoefficient' 'MaterialsRheologyBbar' 'Vx' 'Vy'});
+			checkfield(md,'inversion.control_parameters','cell',1,'values',{'BalancethicknessThickeningRate' 'FrictionCoefficient' 'MaterialsRheologyBbar' 'MaterialsRheologyZbar' 'Vx' 'Vy'});
 			checkfield(md,'inversion.nsteps','numel',1,'>=',1);
 			checkfield(md,'inversion.maxiter_per_step','size',[md.inversion.nsteps 1],'>=',0);
Index: /issm/branches/trunk-jpl-damage/src/m/enum/MatrixParamEnum.m
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/enum/MatrixParamEnum.m	(revision 11708)
+++ /issm/branches/trunk-jpl-damage/src/m/enum/MatrixParamEnum.m	(revision 11708)
@@ -0,0 +1,11 @@
+function macro=MatrixParamEnum()
+%MATRIXPARAMENUM - Enum of MatrixParam
+%
+%   WARNING: DO NOT MODIFY THIS FILE
+%            this file has been automatically generated by src/c/EnumDefinitions/Synchronize.sh
+%            Please read src/c/EnumDefinitions/README for more information
+%
+%   Usage:
+%      macro=MatrixParamEnum()
+
+macro=StringToEnum('MatrixParam');
Index: sm/branches/trunk-jpl-damage/src/m/enum/PetscMatParamEnum.m
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/enum/PetscMatParamEnum.m	(revision 11707)
+++ 	(revision )
@@ -1,11 +1,0 @@
-function macro=PetscMatParamEnum()
-%PETSCMATPARAMENUM - Enum of PetscMatParam
-%
-%   WARNING: DO NOT MODIFY THIS FILE
-%            this file has been automatically generated by src/c/EnumDefinitions/Synchronize.sh
-%            Please read src/c/EnumDefinitions/README for more information
-%
-%   Usage:
-%      macro=PetscMatParamEnum()
-
-macro=StringToEnum('PetscMatParam');
Index: sm/branches/trunk-jpl-damage/src/m/enum/PetscVecParamEnum.m
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/enum/PetscVecParamEnum.m	(revision 11707)
+++ 	(revision )
@@ -1,11 +1,0 @@
-function macro=PetscVecParamEnum()
-%PETSCVECPARAMENUM - Enum of PetscVecParam
-%
-%   WARNING: DO NOT MODIFY THIS FILE
-%            this file has been automatically generated by src/c/EnumDefinitions/Synchronize.sh
-%            Please read src/c/EnumDefinitions/README for more information
-%
-%   Usage:
-%      macro=PetscVecParamEnum()
-
-macro=StringToEnum('PetscVecParam');
Index: /issm/branches/trunk-jpl-damage/src/m/enum/VectorParamEnum.m
===================================================================
--- /issm/branches/trunk-jpl-damage/src/m/enum/VectorParamEnum.m	(revision 11708)
+++ /issm/branches/trunk-jpl-damage/src/m/enum/VectorParamEnum.m	(revision 11708)
@@ -0,0 +1,11 @@
+function macro=VectorParamEnum()
+%VECTORPARAMENUM - Enum of VectorParam
+%
+%   WARNING: DO NOT MODIFY THIS FILE
+%            this file has been automatically generated by src/c/EnumDefinitions/Synchronize.sh
+%            Please read src/c/EnumDefinitions/README for more information
+%
+%   Usage:
+%      macro=VectorParamEnum()
+
+macro=StringToEnum('VectorParam');
Index: /issm/branches/trunk-jpl-damage/src/mex/ComputeBasalStress/ComputeBasalStress.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/mex/ComputeBasalStress/ComputeBasalStress.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/mex/ComputeBasalStress/ComputeBasalStress.cpp	(revision 11708)
@@ -17,5 +17,5 @@
 
 	/* output datasets: */
-	Vec sigma_g=NULL;
+	Vector* sigma_g=NULL;
 
 	/*Boot module: */
@@ -51,5 +51,5 @@
 	delete loads;
 	delete parameters;
-	VecFree(&sigma_g);
+	xdelete(&sigma_g);
 
 	/*end module: */
Index: /issm/branches/trunk-jpl-damage/src/mex/ContourToMesh/ContourToMesh.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/mex/ContourToMesh/ContourToMesh.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/mex/ContourToMesh/ContourToMesh.cpp	(revision 11708)
@@ -33,7 +33,7 @@
 
 	/* output: */
-	Vec  in_nod=NULL;
+	Vector*  in_nod=NULL;
 	int  nods;
-	Vec  in_elem=NULL;
+	Vector*  in_elem=NULL;
 	int  nel;
 
Index: /issm/branches/trunk-jpl-damage/src/mex/ContourToNodes/ContourToNodes.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/mex/ContourToNodes/ContourToNodes.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/mex/ContourToNodes/ContourToNodes.cpp	(revision 11708)
@@ -35,5 +35,5 @@
 
 	/* output: */
-	Vec  flags=NULL;
+	Vector*  flags=NULL;
 	int  nods;
 
Index: /issm/branches/trunk-jpl-damage/src/mex/ControlInputGetGradient/ControlInputGetGradient.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/mex/ControlInputGetGradient/ControlInputGetGradient.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/mex/ControlInputGetGradient/ControlInputGetGradient.cpp	(revision 11708)
@@ -14,5 +14,5 @@
 	Materials  *materials  = NULL;
 	Parameters *parameters = NULL;
-	Vec         gradient   = NULL;
+	Vector*         gradient   = NULL;
 
 	/* output datasets: elements and loads*/
Index: /issm/branches/trunk-jpl-damage/src/mex/CreateNodalConstraints/CreateNodalConstraints.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/mex/CreateNodalConstraints/CreateNodalConstraints.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/mex/CreateNodalConstraints/CreateNodalConstraints.cpp	(revision 11708)
@@ -32,5 +32,5 @@
 	/*Free ressources: */
 	delete nodes;
-	delete ys;
+	xdelete(&ys);
 
 	/*end module: */
Index: /issm/branches/trunk-jpl-damage/src/mex/GetVectorFromInputs/GetVectorFromInputs.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/mex/GetVectorFromInputs/GetVectorFromInputs.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/mex/GetVectorFromInputs/GetVectorFromInputs.cpp	(revision 11708)
@@ -16,5 +16,5 @@
 	int name_enum;
 	int type_enum;
-	Vec      ug=NULL;
+	Vector*      ug=NULL;
 
 	/* output datasets: elements and loads*/
Index: /issm/branches/trunk-jpl-damage/src/mex/Gradj/Gradj.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/mex/Gradj/Gradj.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/mex/Gradj/Gradj.cpp	(revision 11708)
@@ -18,5 +18,5 @@
 
 	/* output datasets: */
-	Vec         gradient       = NULL;
+	Vector*         gradient       = NULL;
 
 	/*Boot module: */
@@ -54,5 +54,5 @@
 	delete materials;
 	delete parameters;
-	VecFree(&gradient);
+	xdelete(&gradient);
 
 	/*end module: */
Index: /issm/branches/trunk-jpl-damage/src/mex/InputUpdateFromSolution/InputUpdateFromSolution.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/mex/InputUpdateFromSolution/InputUpdateFromSolution.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/mex/InputUpdateFromSolution/InputUpdateFromSolution.cpp	(revision 11708)
@@ -8,11 +8,11 @@
 
 	/*input datasets: */
-	Elements* elements=NULL;
-	Nodes* nodes=NULL;
-	Vertices* vertices=NULL;
-	Loads* loads=NULL;
-	Materials* materials=NULL;
-	Parameters* parameters=NULL;
-	Vector*      solution=NULL;
+	Elements   *elements   = NULL;
+	Nodes      *nodes      = NULL;
+	Vertices   *vertices   = NULL;
+	Loads      *loads      = NULL;
+	Materials  *materials  = NULL;
+	Parameters *parameters = NULL;
+	Vector     *solution   = NULL;
 
 	/*Boot module: */
@@ -50,5 +50,5 @@
 	delete materials;
 	delete parameters;
-	delete solution;
+	xdelete(&solution);
 
 	/*end module: */
Index: /issm/branches/trunk-jpl-damage/src/mex/InterpFromGridToMesh/InterpFromGridToMesh.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/mex/InterpFromGridToMesh/InterpFromGridToMesh.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/mex/InterpFromGridToMesh/InterpFromGridToMesh.cpp	(revision 11708)
@@ -37,5 +37,5 @@
 
 	/* output: */
-	Vec  data_mesh=NULL;
+	Vector*  data_mesh=NULL;
 
 	/*Boot module: */
Index: /issm/branches/trunk-jpl-damage/src/mex/InterpFromMesh2d/InterpFromMesh2d.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/mex/InterpFromMesh2d/InterpFromMesh2d.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/mex/InterpFromMesh2d/InterpFromMesh2d.cpp	(revision 11708)
@@ -61,5 +61,5 @@
 
 	/* output: */
-	Vec  data_prime=NULL;
+	Vector*  data_prime=NULL;
 
 	/*Boot module: */
Index: /issm/branches/trunk-jpl-damage/src/mex/InterpFromMeshToMesh3d/InterpFromMeshToMesh3d.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/mex/InterpFromMeshToMesh3d/InterpFromMeshToMesh3d.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/mex/InterpFromMeshToMesh3d/InterpFromMeshToMesh3d.cpp	(revision 11708)
@@ -55,5 +55,5 @@
 
 	/* output: */
-	Vec  data_prime=NULL;
+	Vector*  data_prime=NULL;
 
 	/*Boot module: */
Index: /issm/branches/trunk-jpl-damage/src/mex/Makefile.am
===================================================================
--- /issm/branches/trunk-jpl-damage/src/mex/Makefile.am	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/mex/Makefile.am	(revision 11708)
@@ -76,5 +76,4 @@
 				SurfaceArea\
 				SystemMatrices\
-				Test\
 				TimeAdapt\
 				TriaSearch\
@@ -206,7 +205,4 @@
 			  GroundinglineMigration/GroundinglineMigration.h
 
-Test_SOURCES = Test/Test.cpp\
-			  Test/Test.h
-
 HoleFiller_SOURCES = HoleFiller/HoleFiller.cpp\
 			  HoleFiller/HoleFiller.h
Index: /issm/branches/trunk-jpl-damage/src/mex/Mergesolutionfromftog/Mergesolutionfromftog.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/mex/Mergesolutionfromftog/Mergesolutionfromftog.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/mex/Mergesolutionfromftog/Mergesolutionfromftog.cpp	(revision 11708)
@@ -45,7 +45,7 @@
 
 	/*Free ressources: */
-	delete uf;
-	delete ug;
-	delete ys;
+	xdelete(&uf);
+	xdelete(&ug);
+	xdelete(&ys);
 	delete nodes;
 	delete parameters;
Index: /issm/branches/trunk-jpl-damage/src/mex/Orth/Orth.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/mex/Orth/Orth.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/mex/Orth/Orth.cpp	(revision 11708)
@@ -8,9 +8,9 @@
 
 	/*input datasets: */
-	Vec gradj=NULL;
-	Vec oldgradj=NULL;
+	Vector* gradj=NULL;
+	Vector* oldgradj=NULL;
 
 	/* output datasets: */
-	Vec newgradj=NULL;
+	Vector* newgradj=NULL;
 
 	/*Boot module: */
@@ -31,7 +31,7 @@
 
 	/*Free ressources: */
-	VecFree(&gradj);
-	VecFree(&oldgradj);
-	VecFree(&newgradj);
+	xdelete(&gradj);
+	xdelete(&oldgradj);
+	xdelete(&newgradj);
 
 	/*end module: */
Index: /issm/branches/trunk-jpl-damage/src/mex/PointCloudFindNeighbors/PointCloudFindNeighbors.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/mex/PointCloudFindNeighbors/PointCloudFindNeighbors.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/mex/PointCloudFindNeighbors/PointCloudFindNeighbors.cpp	(revision 11708)
@@ -17,5 +17,5 @@
 
 	/* output: */
-	Vec  flags=NULL;
+	Vector*  flags=NULL;
 
 	/*Boot module: */
Index: /issm/branches/trunk-jpl-damage/src/mex/Reduceload/Reduceload.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/mex/Reduceload/Reduceload.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/mex/Reduceload/Reduceload.cpp	(revision 11708)
@@ -40,7 +40,7 @@
 
 	/*Free ressources: */
-	delete pf;
-	delete Kfs;
-	delete ys;
+	xdelete(&pf);
+	xdelete(&Kfs);
+	xdelete(&ys);
 
 	MODULEEND();
Index: /issm/branches/trunk-jpl-damage/src/mex/Reducevectorgtof/Reducevectorgtof.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/mex/Reducevectorgtof/Reducevectorgtof.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/mex/Reducevectorgtof/Reducevectorgtof.cpp	(revision 11708)
@@ -8,10 +8,10 @@
 
 	/*input datasets: */
-	Vector* ug=NULL;
-	Nodes* nodes=NULL;
-	Parameters* parameters=NULL;
+	Vector     *ug         = NULL;
+	Nodes      *nodes      = NULL;
+	Parameters *parameters = NULL;
 
 	/* output datasets: */
-	Vector* uf=NULL;
+	Vector *uf = NULL;
 
 	/*Boot module: */
@@ -35,6 +35,6 @@
 	delete nodes;
 	delete parameters;
-	delete ug;
-	delete uf;
+	xdelete(&ug);
+	xdelete(&uf);
 
 	/*end module: */
Index: /issm/branches/trunk-jpl-damage/src/mex/Reducevectorgtos/Reducevectorgtos.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/mex/Reducevectorgtos/Reducevectorgtos.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/mex/Reducevectorgtos/Reducevectorgtos.cpp	(revision 11708)
@@ -35,6 +35,6 @@
 	delete nodes;
 	delete parameters;
-	delete yg;
-	delete ys;
+	xdelete(&yg);
+	xdelete(&ys);
 
 	/*end module: */
Index: /issm/branches/trunk-jpl-damage/src/mex/ResetCoordinateSystem/ResetCoordinateSystem.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/mex/ResetCoordinateSystem/ResetCoordinateSystem.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/mex/ResetCoordinateSystem/ResetCoordinateSystem.cpp	(revision 11708)
@@ -17,5 +17,5 @@
 
 	/* output datasets: */
-	Vec sigma_g=NULL;
+	Vector* sigma_g=NULL;
 
 	/*Boot module: */
Index: /issm/branches/trunk-jpl-damage/src/mex/Solver/Solver.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/mex/Solver/Solver.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/mex/Solver/Solver.cpp	(revision 11708)
@@ -15,14 +15,12 @@
 	Parameters *parameters    = NULL;
 	int         analysis_type;
-	char        option[100];
-	#if _PETSC_MAJOR_ < 3 || (_PETSC_MAJOR_ == 3 && _PETSC_MINOR_ < 2)
-	PetscTruth  flag;
-	#else
-	PetscBool flag;
-	#endif
-	
-	/*Matlab solver: */
+	char*       options=NULL;
+	char*       token=NULL;
+	char*       option=NULL;
+
+	/*For use of matlab solver: */
 	mxArray* array[2];
 
+	/*Start module: */
 	MODULEBOOT();
 
@@ -34,14 +32,10 @@
 
 	/*In serial mode, we have not set any petsc options, do it now: */
-	#ifdef _SERIAL_
-	parameters->FindParam(&analysis_type,AnalysisTypeEnum);
-	PetscOptionsFromAnalysis(parameters,analysis_type);
-	#endif
 	
-	/*Retrieve solver type: */
-	PetscOptionsGetString(PETSC_NULL,"-ksp_type",&option[0],100,&flag);
+	options=OptionsFromAnalysis(parameters,analysis_type);
+	token=strstr(options,"--ksp_type");
 
 	/*Fetch rest of data only if not running the matlab solver: */
-	if (strcmp(option,"matlab")!=0){
+	if ((token==NULL) || (strncmp(token+10,"matlab",6)!=0)){
 	
 		/*Input datasets: */
@@ -58,5 +52,5 @@
 	}
 	else{
-		/*Matlab solver: */
+		/*Call Matlab solver: */
 		if (VerboseModule()) printf("   Solving\n");
 		array[0]=KFF;
@@ -66,9 +60,9 @@
 
 	/*Free ressources: */
-	delete Kff;
-	delete pf;
-	delete uf0;
-	delete uf;
-	delete df;
+	xdelete(&Kff);
+	xdelete(&pf);
+	xdelete(&uf0);
+	xdelete(&uf);
+	xdelete(&df);
 	delete parameters;
 
Index: /issm/branches/trunk-jpl-damage/src/mex/SystemMatrices/SystemMatrices.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/mex/SystemMatrices/SystemMatrices.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/mex/SystemMatrices/SystemMatrices.cpp	(revision 11708)
@@ -72,8 +72,8 @@
 	delete materials;
 	delete parameters;
-	delete Kff;
-	delete Kfs;
-	delete pf;
-	delete df;
+	xdelete(&Kff);
+	xdelete(&Kfs);
+	xdelete(&pf);
+	xdelete(&df);
 
 	/*end module: */
Index: /issm/branches/trunk-jpl-damage/src/mex/UpdateDynamicConstraints/UpdateDynamicConstraints.cpp
===================================================================
--- /issm/branches/trunk-jpl-damage/src/mex/UpdateDynamicConstraints/UpdateDynamicConstraints.cpp	(revision 11707)
+++ /issm/branches/trunk-jpl-damage/src/mex/UpdateDynamicConstraints/UpdateDynamicConstraints.cpp	(revision 11708)
@@ -32,5 +32,5 @@
 
 	/*Free ressources: */
-	delete yg;
+	xdelete(&yg);
 	delete constraints;
 	delete nodes;
