Index: /issm/trunk/configs/astrid/configure.sh
===================================================================
--- /issm/trunk/configs/astrid/configure.sh	(revision 9825)
+++ /issm/trunk/configs/astrid/configure.sh	(revision 9826)
@@ -12,4 +12,5 @@
  --with-petsc-dir=$ISSM_TIER/externalpackages/petsc/install \
  --with-petsc-version=3 \
+ --with-tao-dir=$ISSM_TIER/externalpackages/tao/install \
  --with-mpi-include=$ISSM_TIER/externalpackages/mpich2/install/include  \
  --with-mpi-lib="-L$ISSM_TIER/externalpackages/mpich2/install/lib/ -lmpich " \
Index: /issm/trunk/configs/astrid/configure.sh.petsc3.2
===================================================================
--- /issm/trunk/configs/astrid/configure.sh.petsc3.2	(revision 9826)
+++ /issm/trunk/configs/astrid/configure.sh.petsc3.2	(revision 9826)
@@ -0,0 +1,30 @@
+#!/bin/sh
+
+#External packages versions:
+#petsc 3.1
+#mpich 1.3.1
+
+./configure \
+ --prefix=$ISSM_TIER \
+ --with-matlab-dir=$MATLAB_DIR \
+ --with-triangle-dir=$ISSM_TIER/externalpackages/triangle/install \
+ --with-metis-dir=$ISSM_TIER/externalpackages/metis/install \
+ --with-petsc-dir=$ISSM_TIER/externalpackages/petsc/install \
+ --with-petsc-version=3.2 \
+ --with-mpi-include=$ISSM_TIER/externalpackages/mpich2/install/include  \
+ --with-mpi-lib="-L$ISSM_TIER/externalpackages/mpich2/install/lib/ -lmpich " \
+ --with-petsc-arch=$ISSM_ARCH \
+ --with-dakota-dir=$ISSM_TIER/externalpackages/dakota/install \
+ --with-blas-lapack-dir=$ISSM_TIER/externalpackages/petsc/install \
+ --with-plapack-lib="-L $ISSM_TIER/externalpackages/petsc/install/ -lPLAPACK" \
+ --with-plapack-include="-I $ISSM_TIER/externalpackages/petsc/install/externalpackages/PLAPACKR32-hg/INCLUDE" \
+ --with-blacs-dir=$ISSM_TIER/externalpackages/petsc/install/ \
+ --with-scalapack-dir=$ISSM_TIER/externalpackages/petsc/install/ \
+ --with-mumps-dir=$ISSM_TIER/externalpackages/petsc/install/ \
+ --with-scotch-dir="$ISSM_TIER/externalpackages/scotch/install" \
+ --with-chaco-dir="$ISSM_TIER/externalpackages/chaco/install" \
+ --with-fortran-lib="-L/usr/lib/gcc/x86_64-redhat-linux/4.1.1/ -lgfortran" \
+ --with-graphics-lib=/usr/lib64/libX11.so \
+ --with-cxxoptflags="-march=opteron -O2" \
+ --with-numthreads=32 \
+ --enable-debugging
Index: /issm/trunk/m4/issm_options.m4
===================================================================
--- /issm/trunk/m4/issm_options.m4	(revision 9825)
+++ /issm/trunk/m4/issm_options.m4	(revision 9826)
@@ -342,6 +342,9 @@
 	AC_ARG_WITH([petsc-version],
 			  AS_HELP_STRING([--with-petsc-version = VERSION],
-							 [petsc version -- 2 or 3]),
+							 [petsc version -- 3.1 or 3.2]),
 			  [PETSC_VERSION=$withval],[PETSC_VERSION=""])
+
+	dnl [morlighe@astrid m4]$ echo 3.2 | sed -e 's/3\..*//'
+	dnl [morlighe@astrid m4]$ echo 3.2 | sed -e 's/3\.//'
 
 	if test "$PARALLEL_VALUE" = "yes" ; then
@@ -349,10 +352,19 @@
 			AC_MSG_ERROR([missing --with-petsc-version argument for parallel compilation!])
 		fi
-		if test "$PETSC_VERSION" = "2" ; then
-		AC_DEFINE([_PETSC_VERSION_],[2],[ Petsc version number])
-		fi
-
+		if test "$PETSC_VERSION" = "2.3" ; then
+			AC_DEFINE([_PETSC_MAJOR_],[2],[ Petsc version major])
+			AC_DEFINE([_PETSC_MINOR_],[3],[ Petsc version minor])
+		fi
 		if test "$PETSC_VERSION" = "3" ; then
-		AC_DEFINE([_PETSC_VERSION_],[3],[ Petsc version number])
+			AC_DEFINE([_PETSC_MAJOR_],[3],[ Petsc version major])
+			AC_DEFINE([_PETSC_MINOR_],[1],[ Petsc version minor])
+		fi
+		if test "$PETSC_VERSION" = "3.1" ; then
+			AC_DEFINE([_PETSC_MAJOR_],[3],[ Petsc version major])
+			AC_DEFINE([_PETSC_MINOR_],[1],[ Petsc version minor])
+		fi
+		if test "$PETSC_VERSION" = "3.2" ; then
+			AC_DEFINE([_PETSC_MAJOR_],[3],[ Petsc version major])
+			AC_DEFINE([_PETSC_MINOR_],[2],[ Petsc version minor])
 		fi
 	fi
Index: /issm/trunk/src/c/modules/Solverx/DofTypesToIndexSet.cpp
===================================================================
--- /issm/trunk/src/c/modules/Solverx/DofTypesToIndexSet.cpp	(revision 9825)
+++ /issm/trunk/src/c/modules/Solverx/DofTypesToIndexSet.cpp	(revision 9826)
@@ -64,12 +64,16 @@
 		
 		/*Create indices sets: */
+		#if _PETSC_MAJOR_ < 3 || (_PETSC_MAJOR_ == 3 && _PETSC_MINOR_ < 2)
 		ISCreateGeneral(PETSC_COMM_WORLD,pressure_num,pressure_indices,&isp);
 		ISCreateGeneral(PETSC_COMM_WORLD,velocity_num,velocity_indices,&isv);
+		#else
+		ISCreateGeneral(PETSC_COMM_WORLD,pressure_num,pressure_indices,PETSC_COPY_VALUES,&isp);
+		ISCreateGeneral(PETSC_COMM_WORLD,velocity_num,velocity_indices,PETSC_COPY_VALUES,&isv);
+		#endif
+	}
 
-	}
 	/*Free ressources:*/
 	xfree((void**)&pressure_indices);
 	xfree((void**)&velocity_indices);
-
 
 	/*Assign output pointers:*/
Index: /issm/trunk/src/c/modules/Solverx/Solverx.cpp
===================================================================
--- /issm/trunk/src/c/modules/Solverx/Solverx.cpp	(revision 9825)
+++ /issm/trunk/src/c/modules/Solverx/Solverx.cpp	(revision 9826)
@@ -27,14 +27,18 @@
 	PC         pc               = NULL;
 	int        iteration_number;
-	PetscTruth flag;
 	int        solver_type;
 	bool       fromlocalsize    = true;
+	#if _PETSC_MAJOR_ < 3 || (_PETSC_MAJOR_ == 3 && _PETSC_MINOR_ < 2)
+	PetscTruth flag,flg;
+	#else
+	PetscBool flag,flg;
+	#endif
+
 	/*stokes: */
 	IS         isv=NULL;
 	IS         isp=NULL;
 
-	#if _PETSC_VERSION_ == 3 
+	#if _PETSC_MAJOR_ >= 3 
 	char ksp_type[50];
-	PetscTruth flg;
 	#endif
 
@@ -42,5 +46,11 @@
 	/*Display message*/
 	_printf_(VerboseModule(),"   Solving\n");
+	#if _PETSC_MAJOR_ < 3 || (_PETSC_MAJOR_ == 3 && _PETSC_MINOR_ < 2)
 	if(VerboseSolver())PetscOptionsPrint(stdout);
+	#else
+	PetscViewer *v=NULL;
+	PetscViewerCreate(PETSC_COMM_SELF,v);
+	if(VerboseSolver())PetscOptionsView(*v);
+	#endif
 
 	/*First, check that f-set is not NULL, ie model is fully constrained: {{{*/
@@ -53,5 +63,5 @@
 	/*Initial guess logic here: {{{1*/
 	/*Now, check that we are not getting an initial guess to the solver, if we are running a direct solver: */
-	#if _PETSC_VERSION_ == 3 
+	#if _PETSC_MAJOR_ >= 3 
 	PetscOptionsGetString(PETSC_NULL,"-ksp_type",ksp_type,49,&flg);
 	if (strcmp(ksp_type,"preonly")==0)uf0=NULL;
@@ -73,5 +83,5 @@
 	 We need to convert them if we are going to run the solvers successfully: */
 	#ifdef _SERIAL_
-	#if _PETSC_VERSION_ == 2 
+	#if _PETSC_MAJOR_ == 2 
 	if (solver_type==MUMPSPACKAGE_LU){
 		/*Convert Kff to MATTAIJMUMPS: */
Index: /issm/trunk/src/c/modules/SystemMatricesx/SystemMatricesx.cpp
===================================================================
--- /issm/trunk/src/c/modules/SystemMatricesx/SystemMatricesx.cpp	(revision 9825)
+++ /issm/trunk/src/c/modules/SystemMatricesx/SystemMatricesx.cpp	(revision 9826)
@@ -68,5 +68,5 @@
 		MatAssemblyBegin(Kff,MAT_FINAL_ASSEMBLY);
 		MatAssemblyEnd(Kff,MAT_FINAL_ASSEMBLY);
-		#if _PETSC_VERSION_ == 2 
+		#if _PETSC_MAJOR_ == 2 
 		MatCompress(Kff);
 		#endif
@@ -74,5 +74,5 @@
 		MatAssemblyBegin(Kfs,MAT_FINAL_ASSEMBLY);
 		MatAssemblyEnd(Kfs,MAT_FINAL_ASSEMBLY);
-		#if _PETSC_VERSION_ == 2 
+		#if _PETSC_MAJOR_ == 2 
 		MatCompress(Kfs);
 		#endif
@@ -117,5 +117,5 @@
 		MatAssemblyBegin(Kff,MAT_FINAL_ASSEMBLY);
 		MatAssemblyEnd(Kff,MAT_FINAL_ASSEMBLY);
-		#if _PETSC_VERSION_ == 2 
+		#if _PETSC_MAJOR_ == 2 
 		MatCompress(Kff);
 		#endif
@@ -123,5 +123,5 @@
 		MatAssemblyBegin(Kfs,MAT_FINAL_ASSEMBLY);
 		MatAssemblyEnd(Kfs,MAT_FINAL_ASSEMBLY);
-		#if _PETSC_VERSION_ == 2 
+		#if _PETSC_MAJOR_ == 2 
 		MatCompress(Kfs);
 		#endif
Index: /issm/trunk/src/c/shared/Numerics/PetscOptionsFromAnalysis.cpp
===================================================================
--- /issm/trunk/src/c/shared/Numerics/PetscOptionsFromAnalysis.cpp	(revision 9825)
+++ /issm/trunk/src/c/shared/Numerics/PetscOptionsFromAnalysis.cpp	(revision 9826)
@@ -66,5 +66,5 @@
 	 *capability is not covered by Petsc!: */
 
-	#if _PETSC_VERSION_ == 2 
+	#if _PETSC_MAJOR_ == 2 
 	PetscOptionsDestroy();
 	PetscOptionsCreate();
Index: /issm/trunk/src/c/toolkits/petsc/patches/ISFree.cpp
===================================================================
--- /issm/trunk/src/c/toolkits/petsc/patches/ISFree.cpp	(revision 9825)
+++ /issm/trunk/src/c/toolkits/petsc/patches/ISFree.cpp	(revision 9826)
@@ -17,6 +17,11 @@
 void ISFree(IS* pis){
 
+	#if _PETSC_MAJOR_ < 3 || (_PETSC_MAJOR_ == 3 && _PETSC_MINOR_ < 2)
 	if(*pis)ISDestroy(*pis);
 	*pis=NULL;
+	#else
+	if(*pis)ISDestroy(pis);
+	*pis=NULL;
+	#endif
 
 }
Index: /issm/trunk/src/c/toolkits/petsc/patches/KSPFree.cpp
===================================================================
--- /issm/trunk/src/c/toolkits/petsc/patches/KSPFree.cpp	(revision 9825)
+++ /issm/trunk/src/c/toolkits/petsc/patches/KSPFree.cpp	(revision 9826)
@@ -17,6 +17,11 @@
 void KSPFree(KSP* pksp){
 
+	#if _PETSC_MAJOR_ < 3 || (_PETSC_MAJOR_ == 3 && _PETSC_MINOR_ < 2)
 	if(*pksp)KSPDestroy(*pksp);
 	*pksp=NULL;
+	#else
+	if(*pksp)KSPDestroy(pksp);
+	*pksp=NULL;
+	#endif
 
 }
Index: /issm/trunk/src/c/toolkits/petsc/patches/MatFree.cpp
===================================================================
--- /issm/trunk/src/c/toolkits/petsc/patches/MatFree.cpp	(revision 9825)
+++ /issm/trunk/src/c/toolkits/petsc/patches/MatFree.cpp	(revision 9826)
@@ -17,6 +17,11 @@
 void MatFree(Mat* pmat){
 
+	#if _PETSC_MAJOR_ < 3 || (_PETSC_MAJOR_ == 3 && _PETSC_MINOR_ < 2)
 	if(*pmat)MatDestroy(*pmat);
 	*pmat=NULL;
+	#else
+	if(*pmat)MatDestroy(pmat);
+	*pmat=NULL;
+	#endif
 
 }
Index: /issm/trunk/src/c/toolkits/petsc/patches/MatInvert.cpp
===================================================================
--- /issm/trunk/src/c/toolkits/petsc/patches/MatInvert.cpp	(revision 9825)
+++ /issm/trunk/src/c/toolkits/petsc/patches/MatInvert.cpp	(revision 9826)
@@ -65,5 +65,9 @@
 	MatFree(&identity);
 	VecFree(&diagonal);
+	#if _PETSC_MAJOR_ < 3 || (_PETSC_MAJOR_ == 3 && _PETSC_MINOR_ < 2)
 	KSPDestroy(ksp);
+	#else
+	KSPDestroy(&ksp);
+	#endif
 
 	/*Assign output pointers:*/
Index: /issm/trunk/src/c/toolkits/petsc/patches/MatMultPatch.cpp
===================================================================
--- /issm/trunk/src/c/toolkits/petsc/patches/MatMultPatch.cpp	(revision 9825)
+++ /issm/trunk/src/c/toolkits/petsc/patches/MatMultPatch.cpp	(revision 9826)
@@ -34,5 +34,9 @@
 		VecRelocalize(&X_rel,X,n);
 		MatMult(A,X_rel,AX); ;
-		VecDestroy(X_rel);;
+		#if _PETSC_MAJOR_ < 3 || (_PETSC_MAJOR_ == 3 && _PETSC_MINOR_ < 2)
+		VecDestroy(X_rel);
+		#else
+		VecDestroy(&X_rel);
+		#endif
 	}
 }
Index: /issm/trunk/src/c/toolkits/petsc/patches/MatPartition.cpp
===================================================================
--- /issm/trunk/src/c/toolkits/petsc/patches/MatPartition.cpp	(revision 9825)
+++ /issm/trunk/src/c/toolkits/petsc/patches/MatPartition.cpp	(revision 9826)
@@ -79,5 +79,9 @@
 		
 		/*Now each node has a node_rows vectors holding which rows they should extract from matrixA. Create an Index Set from node_rows.*/
+		#if _PETSC_MAJOR_ < 3 || (_PETSC_MAJOR_ == 3 && _PETSC_MINOR_ < 2)
 		ISCreateGeneral(MPI_COMM_WORLD,count,node_rows,&row_index);
+		#else
+		ISCreateGeneral(MPI_COMM_WORLD,count,node_rows,PETSC_COPY_VALUES,&row_index);
+		#endif
 		
 		/*Same deal for columns*/
@@ -86,10 +90,14 @@
 			*(node_cols+i)=(int)*(col_partition_vector+i)-1;
 		}
+		#if _PETSC_MAJOR_ < 3 || (_PETSC_MAJOR_ == 3 && _PETSC_MINOR_ < 2)
 		ISCreateGeneral(MPI_COMM_WORLD,col_partition_vector_size,node_cols,&col_index);
+		#else
+		ISCreateGeneral(MPI_COMM_WORLD,col_partition_vector_size,node_cols,PETSC_COPY_VALUES,&col_index);
+		#endif
 
 		/*Call MatGetSubMatrix*/
 		csize=PetscDetermineLocalSize(col_partition_vector_size);
 		if(col_partition_vector_size==row_partition_vector_size){
-			#if _PETSC_VERSION_ == 3 
+			#if _PETSC_MAJOR_ >= 3 
 			MatGetSubMatrix(matrixA,row_index,col_index,MAT_INITIAL_MATRIX,&outmatrix);
 			#else
@@ -98,5 +106,5 @@
 		}
 		else{
-			#if _PETSC_VERSION_ == 3 
+			#if _PETSC_MAJOR_ >= 3 
 			MatGetSubMatrix(matrixA,row_index,col_index,MAT_INITIAL_MATRIX,&outmatrix);
 			#else
Index: /issm/trunk/src/c/toolkits/petsc/patches/NewMat.cpp
===================================================================
--- /issm/trunk/src/c/toolkits/petsc/patches/NewMat.cpp	(revision 9825)
+++ /issm/trunk/src/c/toolkits/petsc/patches/NewMat.cpp	(revision 9826)
@@ -78,5 +78,5 @@
 	int    nnz;
 
-	#if _PETSC_VERSION_ == 3 
+	#if _PETSC_MAJOR_ >= 3 
 	const MatType type;
 	#else
@@ -99,5 +99,5 @@
 	MatGetType(outmatrix,&type);
 	
-	#if _PETSC_VERSION_ == 2 
+	#if _PETSC_MAJOR_ == 2 
 	if((strcmp(type,"mpiaij")==0) || (strcmp(type,"aijmumps")==0)){
 		MatMPIAIJSetPreallocation(outmatrix,d_nz,NULL,o_nz,NULL);
Index: /issm/trunk/src/c/toolkits/petsc/patches/PetscOptionsDetermineSolverType.cpp
===================================================================
--- /issm/trunk/src/c/toolkits/petsc/patches/PetscOptionsDetermineSolverType.cpp	(revision 9825)
+++ /issm/trunk/src/c/toolkits/petsc/patches/PetscOptionsDetermineSolverType.cpp	(revision 9826)
@@ -22,5 +22,9 @@
 
 	char option[100];
+   #if _PETSC_MAJOR_ < 3 || (_PETSC_MAJOR_ == 3 && _PETSC_MINOR_ < 2)
 	PetscTruth flag;
+	#else
+	PetscBool flag;
+	#endif
 
 	/*output: */
Index: /issm/trunk/src/c/toolkits/petsc/patches/PetscOptionsInsertMultipleString.cpp
===================================================================
--- /issm/trunk/src/c/toolkits/petsc/patches/PetscOptionsInsertMultipleString.cpp	(revision 9825)
+++ /issm/trunk/src/c/toolkits/petsc/patches/PetscOptionsInsertMultipleString.cpp	(revision 9826)
@@ -23,5 +23,5 @@
 
 	/*The list of options is going to be pairs of the type "-option option_value"*/
-	#if _PETSC_VERSION_ == 2
+	#if _PETSC_MAJOR_ == 2
 		PetscToken *token=NULL ;
 	#else
Index: /issm/trunk/src/c/toolkits/petsc/patches/VecFree.cpp
===================================================================
--- /issm/trunk/src/c/toolkits/petsc/patches/VecFree.cpp	(revision 9825)
+++ /issm/trunk/src/c/toolkits/petsc/patches/VecFree.cpp	(revision 9826)
@@ -17,5 +17,9 @@
 void VecFree(Vec* pvec){
 
+	#if _PETSC_MAJOR_ < 3 || (_PETSC_MAJOR_ == 3 && _PETSC_MINOR_ < 2)
 	if(*pvec)VecDestroy(*pvec);
+	#else
+	if(*pvec)VecDestroy(pvec);
+	#endif
 	*pvec=NULL;
 
Index: /issm/trunk/src/mex/Solver/Solver.cpp
===================================================================
--- /issm/trunk/src/mex/Solver/Solver.cpp	(revision 9825)
+++ /issm/trunk/src/mex/Solver/Solver.cpp	(revision 9826)
@@ -16,5 +16,9 @@
 	int         analysis_type;
 	char        option[100];
+	#if _PETSC_MAJOR_ < 3 || (_PETSC_MAJOR_ == 3 && _PETSC_MINOR_ < 2)
 	PetscTruth  flag;
+	#else
+	PetscBool flag;
+	#endif
 	
 	/*Matlab solver: */
