Index: /issm/trunk/src/c/objects/Elements/Penta.cpp
===================================================================
--- /issm/trunk/src/c/objects/Elements/Penta.cpp	(revision 5875)
+++ /issm/trunk/src/c/objects/Elements/Penta.cpp	(revision 5876)
@@ -699,5 +699,7 @@
 	switch(analysis_type){
 		case DiagnosticHorizAnalysisEnum: case AdjointHorizAnalysisEnum:
-			CreateKMatrixDiagnosticHoriz(Kgg);
+			Ke=CreateKMatrixDiagnosticHoriz();
+			if(Ke) Ke->AddToGlobal(Kgg,NULL,NULL);
+			delete Ke;
 			break;
 		case DiagnosticHutterAnalysisEnum:
@@ -2166,41 +2168,24 @@
 /*}}}*/
 /*FUNCTION Penta::CreateKMatrixDiagnosticHoriz {{{1*/
-void  Penta::CreateKMatrixDiagnosticHoriz(Mat Kgg){
+ElementMatrix* Penta::CreateKMatrixDiagnosticHoriz(void){
 
 	int approximation;
-	ElementMatrix* Ke=NULL;
-
 	inputs->GetParameterValue(&approximation,ApproximationEnum);
 
 	switch(approximation){
 		case MacAyealApproximationEnum:
-			Ke=CreateKMatrixDiagnosticMacAyeal2d();
-			if(Ke) Ke->AddToGlobal(Kgg,NULL,NULL);
-			delete Ke;
-			break;
+			return CreateKMatrixDiagnosticMacAyeal2d();
 		case PattynApproximationEnum:
-			Ke=CreateKMatrixDiagnosticPattyn();
-			if(Ke) Ke->AddToGlobal(Kgg,NULL,NULL);
-			delete Ke;
-			break;
+			return CreateKMatrixDiagnosticPattyn();
 		case StokesApproximationEnum:
-			Ke=CreateKMatrixDiagnosticStokes();
-			if(Ke) Ke->AddToGlobal(Kgg,NULL,NULL);
-			delete Ke;
-			break;
+			return CreateKMatrixDiagnosticStokes();
 		case HutterApproximationEnum:
-			break;
+			return NULL;
 		case NoneApproximationEnum:
-			break;
+			return NULL;
 		case MacAyealPattynApproximationEnum:
-			Ke=CreateKMatrixDiagnosticMacAyealPattyn();
-			if(Ke) Ke->AddToGlobal(Kgg,NULL,NULL);
-			delete Ke;
-			break;
+			return CreateKMatrixDiagnosticMacAyealPattyn();
 		case PattynStokesApproximationEnum:
-			Ke=CreateKMatrixDiagnosticPattynStokes();
-			if(Ke) Ke->AddToGlobal(Kgg,NULL,NULL);
-			delete Ke;
-			break;
+			return CreateKMatrixDiagnosticPattynStokes();
 		default:
 			ISSMERROR("Approximation %s not supported yet",EnumToString(approximation));
Index: /issm/trunk/src/c/objects/Elements/Penta.h
===================================================================
--- /issm/trunk/src/c/objects/Elements/Penta.h	(revision 5875)
+++ /issm/trunk/src/c/objects/Elements/Penta.h	(revision 5876)
@@ -127,5 +127,5 @@
 		ElementMatrix* CreateKMatrixCouplingMacAyealPattynFriction(void);
 		ElementMatrix* CreateKMatrixCouplingPattynStokes(void);
-		void	  CreateKMatrixDiagnosticHoriz( Mat Kgg);
+		ElementMatrix* CreateKMatrixDiagnosticHoriz(void);
 		ElementMatrix* CreateKMatrixDiagnosticHutter(void);
 		ElementMatrix* CreateKMatrixDiagnosticMacAyeal2d(void);
