Index: /issm/trunk/src/c/Makefile.am
===================================================================
--- /issm/trunk/src/c/Makefile.am	(revision 4232)
+++ /issm/trunk/src/c/Makefile.am	(revision 4233)
@@ -1043,4 +1043,5 @@
 					./modules/Qmux/DakotaResponses.cpp\
 					./modules/Qmux/DakotaMPI_Bcast.cpp\
+					./modules/Qmux/DakotaFree.cpp\
 					./modules/Qmux/SpawnCore.cpp\
 					./modules/Qmux/SpawnCoreParallel.cpp\
Index: /issm/trunk/src/c/modules/Qmux/DakotaFree.cpp
===================================================================
--- /issm/trunk/src/c/modules/Qmux/DakotaFree.cpp	(revision 4233)
+++ /issm/trunk/src/c/modules/Qmux/DakotaFree.cpp	(revision 4233)
@@ -0,0 +1,50 @@
+/*!\file: DakotaFree.cpp
+ * \brief DakotaFree: free allocations on other cpus, not done by Dakota.
+
+ */ 
+
+#ifdef HAVE_CONFIG_H
+	#include "config.h"
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+void DakotaFree(double** pvariables,char*** pvariables_descriptors,char*** presponses_descriptors,int numvariables,int numresponses){
+
+	int i;
+	
+	double* variables=NULL;
+	char**  variables_descriptors=NULL;
+	char**  responses_descriptors=NULL;
+	char*   string=NULL;
+
+	/*recover pointers: */
+	variables=*pvariables;
+	variables_descriptors=*pvariables_descriptors;
+	responses_descriptors=*presponses_descriptors;
+
+
+	/*Free variables and variables_descriptors only on cpu !=0*/
+	if(my_rank!=0){
+		xfree((void**)&variables);
+		for(i=0;i<numvariables;i++){
+			string=variables_descriptors[i];
+			xfree((void**)&string);
+		}
+		xfree((void**)&variables_descriptors);
+	}
+	
+	//responses descriptors on every cpu
+	for(i=0;i<numresponses;i++){
+		string=responses_descriptors[i];
+		xfree((void**)&string);
+	}
+	//rest of dynamic allocations.
+	xfree((void**)&responses_descriptors);
+
+	/*Assign output pointers:*/
+	*pvariables=variables;
+	*pvariables_descriptors=variables_descriptors;
+	*presponses_descriptors=responses_descriptors;
+}
+
Index: /issm/trunk/src/c/modules/Qmux/Qmux.h
===================================================================
--- /issm/trunk/src/c/modules/Qmux/Qmux.h	(revision 4232)
+++ /issm/trunk/src/c/modules/Qmux/Qmux.h	(revision 4233)
@@ -20,4 +20,5 @@
 void DakotaResponses(double* responses,char** responses_descriptors,int numresponses,FemModel* femmodel);
 void DakotaMPI_Bcast(double** pvariables, char*** pvariables_descriptors,int* pnumvariables, int* pnumresponses);
+void DakotaFree(double** pvariables,char*** pvariables_descriptors,char*** presponses_descriptors,int numvariables,int numresponses);
 #endif
 
Index: /issm/trunk/src/c/modules/Qmux/SpawnCoreParallel.cpp
===================================================================
--- /issm/trunk/src/c/modules/Qmux/SpawnCoreParallel.cpp	(revision 4232)
+++ /issm/trunk/src/c/modules/Qmux/SpawnCoreParallel.cpp	(revision 4233)
@@ -43,6 +43,4 @@
 	char    *string                    = NULL;
 	int      string_length;
-	double  *qmu_part                  = NULL;
-	int      qmu_npart;
 	int      verbose                   = 0;
 	int      dummy;
@@ -57,6 +55,5 @@
 	femmodel->parameters->FindParam(&responses_descriptors,&dummy,ResponseDescriptorsEnum);
 
-	/* only cpu 0, running dakota is providing us with variables, variables_descriptors and responses. 
-	 * broadcast onto other cpus: */
+	/* only cpu 0, running dakota is providing us with variables and variables_descriptors and numresponses: broadcast onto other cpus: */
 	DakotaMPI_Bcast(&variables,&variables_descriptors,&numvariables,&numresponses);
 
@@ -91,23 +88,6 @@
 	DakotaResponses(responses,responses_descriptors,numresponses,femmodel);
 
-	/*Free ressources:{{{1*/
-	//variables only on cpu != 0
-	if(my_rank!=0){
-		xfree((void**)&variables);
-		for(i=0;i<numvariables;i++){
-			string=variables_descriptors[i];
-			xfree((void**)&string);
-		}
-		xfree((void**)&variables_descriptors);
-	}
-	//responses descriptors
-	for(i=0;i<numresponses;i++){
-		string=responses_descriptors[i];
-		xfree((void**)&string);
-	}
-	//rest of dynamic allocations.
-	xfree((void**)&responses_descriptors);
-	xfree((void**)&qmu_part);
-	/*}}}*/
+	/*Free ressources:*/
+	DakotaFree(&variables,&variables_descriptors,&responses_descriptors, numvariables, numresponses);
 }
 
