Index: /issm/trunk/src/c/modules/Solverx/Solverx.cpp
===================================================================
--- /issm/trunk/src/c/modules/Solverx/Solverx.cpp	(revision 6851)
+++ /issm/trunk/src/c/modules/Solverx/Solverx.cpp	(revision 6852)
@@ -31,4 +31,8 @@
 	bool       fromlocalsize    = true;
 
+	#if _PETSC_VERSION_ == 3 
+	const MatType type;
+	#endif
+
 
 	/*Display message*/
@@ -40,4 +44,10 @@
 		*puf=NULL; return;
 	}
+
+	/*Now, check that we are not getting an initial guess to the solver, if we are running a direct solver: */
+	#if _PETSC_VERSION_ == 3 
+	MatGetType(Kff,&type);
+	if (strcmp(type,"mpidense")==0)uf0=NULL;
+	#endif
 	
 
Index: /issm/trunk/src/c/modules/SystemMatricesx/SystemMatricesx.cpp
===================================================================
--- /issm/trunk/src/c/modules/SystemMatricesx/SystemMatricesx.cpp	(revision 6851)
+++ /issm/trunk/src/c/modules/SystemMatricesx/SystemMatricesx.cpp	(revision 6852)
@@ -30,4 +30,6 @@
 	/*Display message*/
 	_printf_(VerboseModule(),"   Generating matrices\n");
+
+
 
 	/*retrive parameters: */
@@ -74,17 +76,23 @@
 			MatAssemblyBegin(Kgg,MAT_FINAL_ASSEMBLY);
 			MatAssemblyEnd(Kgg,MAT_FINAL_ASSEMBLY);
+			#if _PETSC_VERSION_ == 2 
 			MatCompress(Kgg);
+			#endif
 		}
 		else{
 			MatAssemblyBegin(Kff,MAT_FINAL_ASSEMBLY);
 			MatAssemblyEnd(Kff,MAT_FINAL_ASSEMBLY);
+			#if _PETSC_VERSION_ == 2 
 			MatCompress(Kff);
+			#endif
 
 			MatAssemblyBegin(Kfs,MAT_FINAL_ASSEMBLY);
 			MatAssemblyEnd(Kfs,MAT_FINAL_ASSEMBLY);
+			#if _PETSC_VERSION_ == 2 
 			MatCompress(Kfs);
+			#endif
 		}
 	}
-	if(pflag){
+if(pflag){
 
 		if(!buildkff)pg=NewVec(gsize);
@@ -130,17 +138,23 @@
 			MatAssemblyBegin(Kgg,MAT_FINAL_ASSEMBLY);
 			MatAssemblyEnd(Kgg,MAT_FINAL_ASSEMBLY);
+			#if _PETSC_VERSION_ == 2 
 			MatCompress(Kgg);
+			#endif
 		}
 		else{
 			MatAssemblyBegin(Kff,MAT_FINAL_ASSEMBLY);
 			MatAssemblyEnd(Kff,MAT_FINAL_ASSEMBLY);
+			#if _PETSC_VERSION_ == 2 
 			MatCompress(Kff);
+			#endif
 
 			MatAssemblyBegin(Kfs,MAT_FINAL_ASSEMBLY);
 			MatAssemblyEnd(Kfs,MAT_FINAL_ASSEMBLY);
+			#if _PETSC_VERSION_ == 2 
 			MatCompress(Kfs);
+			#endif
 		}
 	}
-	if(penalty_pflag){
+if(penalty_pflag){
 
 		/*Fill right hand side vector, from loads: */
Index: /issm/trunk/src/c/shared/Numerics/PetscOptionsFromAnalysis.cpp
===================================================================
--- /issm/trunk/src/c/shared/Numerics/PetscOptionsFromAnalysis.cpp	(revision 6851)
+++ /issm/trunk/src/c/shared/Numerics/PetscOptionsFromAnalysis.cpp	(revision 6852)
@@ -65,4 +65,6 @@
 	/*now, reset the options database with this string. Taken from petsc/install/src/sys/objects/pinit.c. This 
 	 *capability is not covered by Petsc!: */
+
+	#if _PETSC_VERSION_ == 2 
 	PetscOptionsDestroy();
 	PetscOptionsCreate();
@@ -71,4 +73,11 @@
 	PetscOptionsSetFromOptions();
 	PetscOptionsInsertMultipleString(string); //our patch
+	#else
+	PetscOptionsSetFromOptions();
+	PetscOptionsClear();
+	//PetscOptionsSetFromOptions();
+	PetscOptionsInsertMultipleString(string); //our patch
+	#endif
+
 
 	/*Free ressources:{{{1*/
Index: /issm/trunk/src/c/toolkits/petsc/patches/MatPartition.cpp
===================================================================
--- /issm/trunk/src/c/toolkits/petsc/patches/MatPartition.cpp	(revision 6851)
+++ /issm/trunk/src/c/toolkits/petsc/patches/MatPartition.cpp	(revision 6852)
@@ -91,8 +91,16 @@
 		csize=PetscDetermineLocalSize(col_partition_vector_size);
 		if(col_partition_vector_size==row_partition_vector_size){
+			#if _PETSC_VERSION_ == 3 
+			MatGetSubMatrix(matrixA,row_index,col_index,MAT_INITIAL_MATRIX,&outmatrix);
+			#else
 			MatGetSubMatrix(matrixA,row_index,col_index,count,MAT_INITIAL_MATRIX,&outmatrix);
+			#endif
 		}
 		else{
+			#if _PETSC_VERSION_ == 3 
+			MatGetSubMatrix(matrixA,row_index,col_index,MAT_INITIAL_MATRIX,&outmatrix);
+			#else
 			MatGetSubMatrix(matrixA,row_index,col_index,csize,MAT_INITIAL_MATRIX,&outmatrix);
+			#endif
 		}
 
Index: /issm/trunk/src/c/toolkits/petsc/patches/NewMat.cpp
===================================================================
--- /issm/trunk/src/c/toolkits/petsc/patches/NewMat.cpp	(revision 6851)
+++ /issm/trunk/src/c/toolkits/petsc/patches/NewMat.cpp	(revision 6852)
@@ -77,5 +77,11 @@
 	int    d_nz,o_nz;
 	int    nnz;
+
+	#if _PETSC_VERSION_ == 3 
+	const MatType type;
+	#else
 	MatType type;
+	#endif
+
 
 
@@ -83,5 +89,5 @@
 	m=PetscDetermineLocalSize(M);
 	n=PetscDetermineLocalSize(N);
-	
+
 	/*Figure out number of non zeros per row: */
 	d_nz=(int)connectivity*numberofdofspernode/2;
@@ -92,9 +98,18 @@
 	MatSetFromOptions(outmatrix);
 
+	
+
 	/*preallocation  according to type: */
 	MatGetType(outmatrix,&type);
+	
+	#if _PETSC_VERSION_ == 2 
 	if((strcmp(type,"mpiaij")==0) || (strcmp(type,"aijmumps")==0)){
 		MatMPIAIJSetPreallocation(outmatrix,d_nz,NULL,o_nz,NULL);
 	}
+	#else
+	if((strcmp(type,"mpiaij")==0) || (strcmp(type,"mpidense")==0)){
+		MatMPIAIJSetPreallocation(outmatrix,d_nz,NULL,o_nz,NULL);
+	}
+	#endif
 
 	return outmatrix;
