Index: /issm/trunk-jpl/m4/issm_options.m4
===================================================================
--- /issm/trunk-jpl/m4/issm_options.m4	(revision 19633)
+++ /issm/trunk-jpl/m4/issm_options.m4	(revision 19634)
@@ -452,6 +452,8 @@
 				if      test x$DAKOTA_VERSION = x4.2 || test x$DAKOTA_VERSION = x4.2+; then
 					DAKOTALIB="-L$DAKOTA_ROOT/lib -ldakota -lteuchos -lpecos -lfftw3 -llhs -levidence -lsurfpack -lconmin -lddace -lfsudace -ljega -lcport -lopt -lpsuade -lnewmat -lncsuopt -lgsl -lquadrature -lcoliny -lcolin -lpebbl -lutilib -l3po -lnappspack -lappspack -lconveyor -lshared -lcdd -lamplsolver"
+					AM_CONDITIONAL([ISSM_DAKOTA],0)
 				else if test x$DAKOTA_VERSION = x5.1 || test x$DAKOTA_VERSION = x5.2; then
 					DAKOTALIB="-L$DAKOTA_ROOT/lib -L$BOOST_ROOT/lib -ldakota -lteuchos -lpecos -llhs -lsparsegrid -lsurfpack -lconmin -lddace -lfsudace -ljega -lcport -loptpp -lpsuade -lncsuopt -lcolin -linterfaces -lmomh -lscolib -lpebbl -ltinyxml -lutilib -l3po -lhopspack -lnidr -lamplsolver -lboost_signals -lboost_regex -lboost_filesystem"
+					AM_CONDITIONAL([ISSM_DAKOTA],0)
 				else if test x$DAKOTA_VERSION = x6.1 || test x$DAKOTA_VERSION = x6.2; then
 				   DAKOTAFLAGS="-DDISABLE_DAKOTA_CONFIG_H -DBOOST_MULTI_INDEX_DISABLE_SERIALIZATION -DDAKOTA_PLUGIN -DBOOST_DISABLE_ASSERTS -DDAKOTA_HAVE_BOOST_FS -DHAVE_UNISTD_H -DHAVE_SYSTEM -DHAVE_WORKING_FORK -DHAVE_WORKING_VFORK -DHAVE_SYS_WAIT_H -DHAVE_USLEEP -DDAKOTA_F90 -DDAKOTA_HAVE_MPI -DHAVE_PECOS -DHAVE_SURFPACK -DDAKOTA_COLINY -DDAKOTA_UTILIB -DHAVE_ADAPTIVE_SAMPLING -DHAVE_CONMIN -DDAKOTA_DDACE -DHAVE_FSUDACE -DDAKOTA_HOPS -DHAVE_JEGA -DHAVE_NCSU -DHAVE_NL2SOL -DHAVE_OPTPP -DDAKOTA_OPTPP -DHAVE_PSUADE -DHAVE_AMPL"
@@ -459,4 +461,5 @@
 					AC_DEFINE([DISABLE_DAKOTA_CONFIG_H],[1],[disabling DAKOTA_CONFIG_H])
 					AC_DEFINE([DAKOTA_HAVE_MPI],[1],[enabling parallel MPI])
+					AM_CONDITIONAL([ISSM_DAKOTA],1)
 				else
 					AC_MSG_ERROR([Dakota version not found or version ($DAKOTA_VERSION) not supported!]);
@@ -468,9 +471,13 @@
 				if      test x$DAKOTA_VERSION = x4.2 || test x$DAKOTA_VERSION = x4.2+; then
 					DAKOTALIB="-L$DAKOTA_ROOT/lib -ldakota -lteuchos -lpecos -lfftw3 -llhs -levidence -lsurfpack -lconmin -lddace -lfsudace -ljega -lcport -lopt -lpsuade -lnewmat -lncsuopt -lgsl -lquadrature -lcoliny -lcolin -lpebbl -lutilib -l3po -lnappspack -lappspack -lconveyor -lshared -lcdd -lamplsolver"
+					AM_CONDITIONAL([ISSM_DAKOTA],0)
 				else if test x$DAKOTA_VERSION = x5.1 || test x$DAKOTA_VERSION = x5.2; then
 					DAKOTALIB="-L$DAKOTA_ROOT/lib -ldakota -lteuchos -lpecos -llhs -lsparsegrid -lsurfpack -lconmin -lddace -lfsudace -ljega -lcport -loptpp -lpsuade -lncsuopt -lcolin -linterfaces -lmomh -lscolib -lpebbl -ltinyxml -lutilib -l3po -lhopspack -lnidr -lamplsolver -lboost_signals -lboost_regex -lboost_filesystem -lboost_system -ldl"
+					AM_CONDITIONAL([ISSM_DAKOTA],0)
 				else if test x$DAKOTA_VERSION = x5.3 || test x$DAKOTA_VERSION = x5.3.1; then
 					DAKOTAFLAGS="-DDISABLE_DAKOTA_CONFIG_H -DBOOST_MULTI_INDEX_DISABLE_SERIALIZATION -DDAKOTA_PLUGIN -DBOOST_DISABLE_ASSERTS -DDAKOTA_HAVE_BOOST_FS -DHAVE_UNISTD_H -DHAVE_SYSTEM -DHAVE_WORKING_FORK -DHAVE_WORKING_VFORK -DHAVE_SYS_WAIT_H -DHAVE_USLEEP -DDAKOTA_F90 -DDAKOTA_HAVE_MPI -DHAVE_PECOS -DHAVE_SURFPACK -DDAKOTA_COLINY -DDAKOTA_UTILIB -DHAVE_ADAPTIVE_SAMPLING -DHAVE_CONMIN -DDAKOTA_DDACE -DHAVE_FSUDACE -DDAKOTA_HOPS -DHAVE_JEGA -DHAVE_NCSU -DHAVE_NL2SOL -DHAVE_OPTPP -DDAKOTA_OPTPP -DHAVE_PSUADE -DHAVE_AMPL"
 					DAKOTALIB="-L$DAKOTA_ROOT/lib -L$BOOST_ROOT/lib -ldakota_src -lpecos_src -lscolib -ljega_fe -llhs -lpebbl -lcolin -linterfaces -lmods -lmoga -loptpp -lsampling -lsoga -lsurfpack -lutilib -lconmin -ldakota_src_fortran -lmod -lncsuopt -lsurfpack_fortran -lteuchos -l3po -lamplsolver -lanalyzer -lbose -lcport -ldace -ldfftpack -leutils -lfsudace -lhopspack -ljega -lnidr -lpecos -lpsuade -lrandom -ltinyxml -lutilities -lsparsegrid -lboost_signals -lboost_regex -lboost_filesystem -lboost_system"
+					AC_DEFINE([DISABLE_DAKOTA_CONFIG_H],[1],[disabling DAKOTA_CONFIG_H])
+					AM_CONDITIONAL([ISSM_DAKOTA],0)
 				else if test x$DAKOTA_VERSION = x6.1 || test x$DAKOTA_VERSION = x6.2; then
 				   DAKOTAFLAGS="-DDISABLE_DAKOTA_CONFIG_H -DBOOST_MULTI_INDEX_DISABLE_SERIALIZATION -DDAKOTA_PLUGIN -DBOOST_DISABLE_ASSERTS -DDAKOTA_HAVE_BOOST_FS -DHAVE_UNISTD_H -DHAVE_SYSTEM -DHAVE_WORKING_FORK -DHAVE_WORKING_VFORK -DHAVE_SYS_WAIT_H -DHAVE_USLEEP -DDAKOTA_F90 -DDAKOTA_HAVE_MPI -DHAVE_PECOS -DHAVE_SURFPACK -DDAKOTA_COLINY -DDAKOTA_UTILIB -DHAVE_ADAPTIVE_SAMPLING -DHAVE_CONMIN -DDAKOTA_DDACE -DHAVE_FSUDACE -DDAKOTA_HOPS -DHAVE_JEGA -DHAVE_NCSU -DHAVE_NL2SOL -DHAVE_OPTPP -DDAKOTA_OPTPP -DHAVE_PSUADE -DHAVE_AMPL"
@@ -478,4 +485,5 @@
 					AC_DEFINE([DISABLE_DAKOTA_CONFIG_H],[1],[disabling DAKOTA_CONFIG_H])
 					AC_DEFINE([DAKOTA_HAVE_MPI],[1],[enabling parallel MPI])
+					AM_CONDITIONAL([ISSM_DAKOTA],1)
 				else
 					AC_MSG_ERROR([Dakota version not found or version ($DAKOTA_VERSION) not supported!]);
@@ -488,11 +496,16 @@
 				if      test x$DAKOTA_VERSION = x4.2 || test x$DAKOTA_VERSION = x4.2+; then
 					DAKOTALIB="-L$DAKOTA_ROOT/lib -ldakota -lteuchos -lpecos -lfftw3 -llhs -levidence -lsurfpack -lconmin -lddace -lfsudace -ljega -lcport -lopt -lpsuade -lnewmat -lncsuopt -lgsl -lquadrature -lcoliny -lcolin -lpebbl -lutilib -l3po -lnappspack -lappspack -lconveyor -lshared -lcdd -lamplsolver" 
+					AM_CONDITIONAL([ISSM_DAKOTA],0)
 					dnl DAKOTALIB+= "-lgslcblas -L/usr/lib -lblas -llapack"
 				else if test x$DAKOTA_VERSION = x5.1 || test x$DAKOTA_VERSION = x5.2; then
 					DAKOTALIB="-L$DAKOTA_ROOT/lib -ldakota -lteuchos -lpecos -llhs -lsparsegrid -lsurfpack -lconmin -lddace -lfsudace -ljega -lcport -loptpp -lpsuade -lncsuopt -lcolin -linterfaces -lmomh -lscolib -lpebbl -ltinyxml -lutilib -l3po -lhopspack -lnidr -lamplsolver -lboost_signals -lboost_regex -lboost_filesystem -lboost_system"
+					AM_CONDITIONAL([ISSM_DAKOTA],0)
 					dnl DAKOTALIB+= "-lgslcblas -L/usr/lib -lblas -llapack"
 				else if test x$DAKOTA_VERSION = x5.3 || test x$DAKOTA_VERSION = x5.3.1; then
 					DAKOTAFLAGS="-DDISABLE_DAKOTA_CONFIG_H -DBOOST_MULTI_INDEX_DISABLE_SERIALIZATION -DDAKOTA_PLUGIN -DBOOST_DISABLE_ASSERTS -DDAKOTA_HAVE_BOOST_FS -DHAVE_UNISTD_H -DHAVE_SYSTEM -DHAVE_WORKING_FORK -DHAVE_WORKING_VFORK -DHAVE_SYS_WAIT_H -DHAVE_USLEEP -DDAKOTA_F90 -DDAKOTA_HAVE_MPI -DHAVE_PECOS -DHAVE_SURFPACK -DDAKOTA_COLINY -DDAKOTA_UTILIB -DHAVE_ADAPTIVE_SAMPLING -DHAVE_CONMIN -DDAKOTA_DDACE -DHAVE_FSUDACE -DDAKOTA_HOPS -DHAVE_JEGA -DHAVE_NCSU -DHAVE_NL2SOL -DHAVE_OPTPP -DDAKOTA_OPTPP -DHAVE_PSUADE -DHAVE_AMPL"
 					DAKOTALIB="-L$DAKOTA_ROOT/lib -L$BOOST_ROOT/lib -ldakota_src -lpecos_src -lscolib -ljega_fe -llhs -lpebbl -lcolin -linterfaces -lmods -lmoga -loptpp -lsampling -lsoga -lsurfpack -lutilib -lconmin -ldakota_src_fortran -lmod -lncsuopt -lsurfpack_fortran -lteuchos -l3po -lamplsolver -lanalyzer -lbose -lcport -ldace -ldfftpack -leutils -lfsudace -lhopspack -ljega -lnidr -lpecos -lpsuade -lrandom -ltinyxml -lutilities -lsparsegrid -lboost_signals -lboost_regex -lboost_filesystem -lboost_system"
+					AM_CONDITIONAL([ISSM_DAKOTA],0)
+					AC_DEFINE([DISABLE_DAKOTA_CONFIG_H],[1],[disabling DAKOTA_CONFIG_H])
+					AM_CONDITIONAL([ISSM_DAKOTA],0)
 				else if test x$DAKOTA_VERSION = x6.1 || test x$DAKOTA_VERSION = x6.2; then
 				   DAKOTAFLAGS="-DDISABLE_DAKOTA_CONFIG_H -DBOOST_MULTI_INDEX_DISABLE_SERIALIZATION -DDAKOTA_PLUGIN -DBOOST_DISABLE_ASSERTS -DDAKOTA_HAVE_BOOST_FS -DHAVE_UNISTD_H -DHAVE_SYSTEM -DHAVE_WORKING_FORK -DHAVE_WORKING_VFORK -DHAVE_SYS_WAIT_H -DHAVE_USLEEP -DDAKOTA_F90 -DDAKOTA_HAVE_MPI -DHAVE_PECOS -DHAVE_SURFPACK -DDAKOTA_COLINY -DDAKOTA_UTILIB -DHAVE_ADAPTIVE_SAMPLING -DHAVE_CONMIN -DDAKOTA_DDACE -DHAVE_FSUDACE -DDAKOTA_HOPS -DHAVE_JEGA -DHAVE_NCSU -DHAVE_NL2SOL -DHAVE_OPTPP -DDAKOTA_OPTPP -DHAVE_PSUADE -DHAVE_AMPL -Wno-deprecated-register -Wno-return-type"
@@ -500,4 +513,5 @@
 					AC_DEFINE([DISABLE_DAKOTA_CONFIG_H],[1],[disabling DAKOTA_CONFIG_H])
 					AC_DEFINE([DAKOTA_HAVE_MPI],[1],[enabling parallel MPI])
+					AM_CONDITIONAL([ISSM_DAKOTA],1)
 				else
 					AC_MSG_ERROR([Dakota version not found or version ($DAKOTA_VERSION) not supported!]);
Index: /issm/trunk-jpl/src/c/Makefile.am
===================================================================
--- /issm/trunk-jpl/src/c/Makefile.am	(revision 19633)
+++ /issm/trunk-jpl/src/c/Makefile.am	(revision 19634)
@@ -661,5 +661,5 @@
 endif
 
-if DAKOTA
+if ISSM_DAKOTA
 bin_PROGRAMS += issm_dakota
 issm_dakota_SOURCES = main/issm_dakota.cpp
Index: /issm/trunk-jpl/src/c/classes/Dakota/IssmDirectApplicInterface.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/Dakota/IssmDirectApplicInterface.h	(revision 19633)
+++ /issm/trunk-jpl/src/c/classes/Dakota/IssmDirectApplicInterface.h	(revision 19634)
@@ -38,10 +38,8 @@
 /*}}}*/
 
-#if defined(_HAVE_DAKOTA_) && (_DAKOTA_MAJOR_ < 5 || (_DAKOTA_MAJOR_ == 5 && _DAKOTA_MINOR_ < 3))
+#if !defined(_WRAPPERS_) && defined(_HAVE_DAKOTA_) && (_DAKOTA_MAJOR_ <= 5) //this only works for Dakota <=5, which had no effective parallel capabilities yet.
 
 /*Dakota include files:{{{*/
-#include <DakotaInterface.H>
-#include <DakotaStrategy.H>
-#include <DakotaModel.H>
+#if (_DAKOTA_MAJOR_ < 5 || (_DAKOTA_MAJOR_ == 5 && _DAKOTA_MINOR_ < 3))
 #include <DirectApplicInterface.H>
 #include <DakotaResponse.H>
@@ -50,5 +48,14 @@
 #include <ProblemDescDB.H>
 #include <ParallelLibrary.H>
+#else
+#include <DirectApplicInterface.hpp>
+#include <DakotaResponse.hpp>
+#include <ParamResponsePair.hpp>
+#include <ProblemDescDB.hpp>
+#include <ParallelLibrary.hpp>
+#endif
 /*}}}*/
+
+int  DakotaSpawnCore(double* d_responses, int d_numresponses, double* d_variables, char** d_variables_descriptors,int d_numvariables, void* void_femmodel,int counter);
 
 /*IssmDirectApplicInterface class */
Index: /issm/trunk-jpl/src/c/cores/dakota_core.cpp
===================================================================
--- /issm/trunk-jpl/src/c/cores/dakota_core.cpp	(revision 19633)
+++ /issm/trunk-jpl/src/c/cores/dakota_core.cpp	(revision 19634)
@@ -59,8 +59,9 @@
 #include "../shared/shared.h"
 #include "../classes/classes.h"
-
-#if defined(_HAVE_DAKOTA_) && (_DAKOTA_MAJOR_ < 5 || (_DAKOTA_MAJOR_ == 5 && _DAKOTA_MINOR_ < 3))
-
-/*include dakota files: */
+#include "../modules/modules.h"
+
+#if defined(_HAVE_DAKOTA_) && (_DAKOTA_MAJOR_ <= 5) //this only works for Dakota <=5, which had no effective parallel capabilities yet.
+/*Dakota include files:{{{*/
+#if (_DAKOTA_MAJOR_ < 5 || (_DAKOTA_MAJOR_ == 5 && _DAKOTA_MINOR_ < 3))
 #include <ParallelLibrary.H>
 #include <ProblemDescDB.H>
@@ -68,57 +69,56 @@
 #include <DakotaModel.H>
 #include <DakotaInterface.H>
-int  DakotaSpawnCore(double* d_responses, int d_numresponses, double* d_variables, char** d_variables_descriptors,int d_numvariables, void* void_femmodel,int counter){ /*{{{*/
-
-	/*Notice the d_, which prefixes anything that is being provided to us by the Dakota pluggin. Careful. some things are ours, some are dakotas!: */
-
-	char     **responses_descriptors    = NULL;      //these are our! there are only numresponsedescriptors of them, not d_numresponses!!!
-	int        numresponsedescriptors;
-	int        solution_type;
-	bool       control_analysis         = false;
-	void     (*solutioncore)(FemModel*) = NULL;
-	FemModel  *femmodel                 = NULL;
-	bool       nodakotacore             = true;
-
-	/*If counter==-1 on cpu0, it means that the dakota runs are done. In which case, bail out and return 0: */
-	ISSM_MPI_Bcast(&counter,1,ISSM_MPI_INT,0,IssmComm::GetComm()); 
-	if(counter==-1)return 0;
-
-	/*cast void_femmodel to FemModel, and at the same time, make a copy, so we start this new core run for this specific sample 
-	 *with a brand new copy of the model, which has not been tempered with by previous dakota runs: */
-	femmodel=(reinterpret_cast<FemModel*>(void_femmodel))->copy();
-
-	/*retrieve parameters: */
-	femmodel->parameters->FindParam(&responses_descriptors,&numresponsedescriptors,QmuResponsedescriptorsEnum);
-	femmodel->parameters->FindParam(&solution_type,SolutionTypeEnum);
-	femmodel->parameters->FindParam(&control_analysis,InversionIscontrolEnum);
-
-	if(VerboseQmu()) _printf0_("qmu iteration: " << counter << "\n");
-
-	/* only cpu 0, running dakota is providing us with variables and variables_descriptors and numresponses: broadcast onto other cpus: */
-	DakotaMPI_Bcast(&d_variables,&d_variables_descriptors,&d_numvariables,&d_numresponses);
-
-	/*Modify core inputs in objects contained in femmodel, to reflect the dakota variables inputs: */
-	InputUpdateFromDakotax(femmodel,d_variables,d_variables_descriptors,d_numvariables);
-
-	/*Determine solution sequence: */
-	if(VerboseQmu()) _printf0_("Starting " << EnumToStringx(solution_type) << " core:\n");
-	WrapperCorePointerFromSolutionEnum(&solutioncore,femmodel->parameters,solution_type,nodakotacore);
-
-	/*Run the core solution sequence: */
-	solutioncore(femmodel);
-
-	/*compute responses: */
-	if(VerboseQmu()) _printf0_("compute dakota responses:\n");
-	femmodel->DakotaResponsesx(d_responses,responses_descriptors,numresponsedescriptors,d_numresponses);
-
-	/*Free ressources:*/
-	DakotaFree(&d_variables,&d_variables_descriptors,&responses_descriptors, d_numvariables, numresponsedescriptors);
-
-	/*Avoid leaks here: */
-	delete femmodel;
-
-	return 1; //this is critical! do not return 0, otherwise, dakota_core will stop running!
-} 
+#else
+#include <ParallelLibrary.hpp>
+#include <ProblemDescDB.hpp>
+#include <DakotaStrategy.hpp>
+#include <DakotaModel.hpp>
+#include <DakotaInterface.hpp>
+#endif
 /*}}}*/
+
+void DakotaFree(double** pvariables,char*** pvariables_descriptors,char*** presponses_descriptors,int numvariables,int numresponses){ /*{{{*/
+
+	/*\brief DakotaFree: free allocations on other cpus, not done by Dakota.*/
+
+	int i;
+	int my_rank;
+
+	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;
+
+	/*recover my_rank:*/
+	my_rank=IssmComm::GetRank();
+
+	/*Free variables and variables_descriptors only on cpu !=0*/
+	if(my_rank!=0){
+		xDelete<double>(variables);
+		for(i=0;i<numvariables;i++){
+			string=variables_descriptors[i];
+			xDelete<char>(string);
+		}
+		xDelete<char*>(variables_descriptors);
+	}
+
+	//responses descriptors on every cpu
+	for(i=0;i<numresponses;i++){
+		string=responses_descriptors[i];
+		xDelete<char>(string);
+	}
+	//rest of dynamic allocations.
+	xDelete<char*>(responses_descriptors);
+
+	/*Assign output pointers:*/
+	*pvariables=variables;
+	*pvariables_descriptors=variables_descriptors;
+	*presponses_descriptors=responses_descriptors;
+} /*}}}*/
 void DakotaMPI_Bcast(double** pvariables, char*** pvariables_descriptors,int* pnumvariables, int* pnumresponses){ /*{{{*/
 
@@ -180,47 +180,57 @@
 	*pnumresponses=numresponses;
 } /*}}}*/
-void DakotaFree(double** pvariables,char*** pvariables_descriptors,char*** presponses_descriptors,int numvariables,int numresponses){ /*{{{*/
-
-	/*\brief DakotaFree: free allocations on other cpus, not done by Dakota.*/
-
-	int i;
-	int my_rank;
-
-	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;
-
-	/*recover my_rank:*/
-	my_rank=IssmComm::GetRank();
-
-	/*Free variables and variables_descriptors only on cpu !=0*/
-	if(my_rank!=0){
-		xDelete<double>(variables);
-		for(i=0;i<numvariables;i++){
-			string=variables_descriptors[i];
-			xDelete<char>(string);
-		}
-		xDelete<char*>(variables_descriptors);
-	}
-
-	//responses descriptors on every cpu
-	for(i=0;i<numresponses;i++){
-		string=responses_descriptors[i];
-		xDelete<char>(string);
-	}
-	//rest of dynamic allocations.
-	xDelete<char*>(responses_descriptors);
-
-	/*Assign output pointers:*/
-	*pvariables=variables;
-	*pvariables_descriptors=variables_descriptors;
-	*presponses_descriptors=responses_descriptors;
-} /*}}}*/
+int  DakotaSpawnCore(double* d_responses, int d_numresponses, double* d_variables, char** d_variables_descriptors,int d_numvariables, void* void_femmodel,int counter){ /*{{{*/
+
+	/*Notice the d_, which prefixes anything that is being provided to us by the Dakota pluggin. Careful. some things are ours, some are dakotas!: */
+
+	char     **responses_descriptors    = NULL;      //these are our! there are only numresponsedescriptors of them, not d_numresponses!!!
+	int        numresponsedescriptors;
+	int        solution_type;
+	bool       control_analysis         = false;
+	void     (*solutioncore)(FemModel*) = NULL;
+	FemModel  *femmodel                 = NULL;
+	bool       nodakotacore             = true;
+
+	/*If counter==-1 on cpu0, it means that the dakota runs are done. In which case, bail out and return 0: */
+	ISSM_MPI_Bcast(&counter,1,ISSM_MPI_INT,0,IssmComm::GetComm()); 
+	if(counter==-1)return 0;
+
+	/*cast void_femmodel to FemModel, and at the same time, make a copy, so we start this new core run for this specific sample 
+	 *with a brand new copy of the model, which has not been tempered with by previous dakota runs: */
+	femmodel=(reinterpret_cast<FemModel*>(void_femmodel))->copy();
+
+	/*retrieve parameters: */
+	femmodel->parameters->FindParam(&responses_descriptors,&numresponsedescriptors,QmuResponsedescriptorsEnum);
+	femmodel->parameters->FindParam(&solution_type,SolutionTypeEnum);
+	femmodel->parameters->FindParam(&control_analysis,InversionIscontrolEnum);
+
+	if(VerboseQmu()) _printf0_("qmu iteration: " << counter << "\n");
+
+	/* only cpu 0, running dakota is providing us with variables and variables_descriptors and numresponses: broadcast onto other cpus: */
+	DakotaMPI_Bcast(&d_variables,&d_variables_descriptors,&d_numvariables,&d_numresponses);
+
+	/*Modify core inputs in objects contained in femmodel, to reflect the dakota variables inputs: */
+	InputUpdateFromDakotax(femmodel,d_variables,d_variables_descriptors,d_numvariables);
+
+	/*Determine solution sequence: */
+	if(VerboseQmu()) _printf0_("Starting " << EnumToStringx(solution_type) << " core:\n");
+	WrapperCorePointerFromSolutionEnum(&solutioncore,femmodel->parameters,solution_type,nodakotacore);
+
+	/*Run the core solution sequence: */
+	solutioncore(femmodel);
+
+	/*compute responses: */
+	if(VerboseQmu()) _printf0_("compute dakota responses:\n");
+	femmodel->DakotaResponsesx(d_responses,responses_descriptors,numresponsedescriptors,d_numresponses);
+
+	/*Free ressources:*/
+	DakotaFree(&d_variables,&d_variables_descriptors,&responses_descriptors, d_numvariables, numresponsedescriptors);
+
+	/*Avoid leaks here: */
+	delete femmodel;
+
+	return 1; //this is critical! do not return 0, otherwise, dakota_core will stop running!
+} 
+/*}}}*/
 void dakota_core(FemModel* femmodel){  /*{{{*/
 
@@ -273,5 +283,5 @@
 
 			// Serial case: plug in derived Interface object without an analysisComm
-			interface.assign_rep(new SIM::DakotaPlugin(problem_db,(void*)femmodel), false);
+			interface.assign_rep(new SIM::IssmDirectApplicInterface(problem_db,(void*)femmodel), false);
 		}
 
@@ -299,5 +309,5 @@
 #else
 void dakota_core(FemModel* femmodel){ 
-	/*do nothing*/
+	_error_("dakota_core for versions of Dakota >=6 should not be used anymore! Use instead the issm_dakota  executable!");
 }
 #endif
Index: /issm/trunk-jpl/src/c/main/issm_dakota.cpp
===================================================================
--- /issm/trunk-jpl/src/c/main/issm_dakota.cpp	(revision 19633)
+++ /issm/trunk-jpl/src/c/main/issm_dakota.cpp	(revision 19634)
@@ -6,4 +6,5 @@
 
 /*Dakota includes: */
+#if defined(_HAVE_DAKOTA_) && _DAKOTA_MAJOR_ >= 6
 #include "ParallelLibrary.hpp"
 #include "ProblemDescDB.hpp"
@@ -11,6 +12,10 @@
 #include "DakotaModel.hpp"
 #include "DakotaInterface.hpp"
+#endif
 
 int main(int argc,char **argv){
+
+
+	#if defined(_HAVE_DAKOTA_) && _DAKOTA_MAJOR_ >= 6
 
 	bool parallel=true;
@@ -80,3 +85,7 @@
 	/*Return unix success: */
 	return 0; 
+	#else 
+	Cout <<  "ISSM Dakota  executable was compiled without support of Dakota! Will just return now!" << "\n";
+	return 1;
+	#endif
 }
