Changeset 19634


Ignore:
Timestamp:
10/14/15 12:20:38 (9 years ago)
Author:
Eric.Larour
Message:

CHG: fixing issue with dakota <6.

Location:
issm/trunk-jpl
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/m4/issm_options.m4

    r19633 r19634  
    452452                                if      test x$DAKOTA_VERSION = x4.2 || test x$DAKOTA_VERSION = x4.2+; then
    453453                                        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"
     454                                        AM_CONDITIONAL([ISSM_DAKOTA],0)
    454455                                else if test x$DAKOTA_VERSION = x5.1 || test x$DAKOTA_VERSION = x5.2; then
    455456                                        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"
     457                                        AM_CONDITIONAL([ISSM_DAKOTA],0)
    456458                                else if test x$DAKOTA_VERSION = x6.1 || test x$DAKOTA_VERSION = x6.2; then
    457459                                   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"
     
    459461                                        AC_DEFINE([DISABLE_DAKOTA_CONFIG_H],[1],[disabling DAKOTA_CONFIG_H])
    460462                                        AC_DEFINE([DAKOTA_HAVE_MPI],[1],[enabling parallel MPI])
     463                                        AM_CONDITIONAL([ISSM_DAKOTA],1)
    461464                                else
    462465                                        AC_MSG_ERROR([Dakota version not found or version ($DAKOTA_VERSION) not supported!]);
     
    468471                                if      test x$DAKOTA_VERSION = x4.2 || test x$DAKOTA_VERSION = x4.2+; then
    469472                                        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"
     473                                        AM_CONDITIONAL([ISSM_DAKOTA],0)
    470474                                else if test x$DAKOTA_VERSION = x5.1 || test x$DAKOTA_VERSION = x5.2; then
    471475                                        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"
     476                                        AM_CONDITIONAL([ISSM_DAKOTA],0)
    472477                                else if test x$DAKOTA_VERSION = x5.3 || test x$DAKOTA_VERSION = x5.3.1; then
    473478                                        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"
    474479                                        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"
     480                                        AC_DEFINE([DISABLE_DAKOTA_CONFIG_H],[1],[disabling DAKOTA_CONFIG_H])
     481                                        AM_CONDITIONAL([ISSM_DAKOTA],0)
    475482                                else if test x$DAKOTA_VERSION = x6.1 || test x$DAKOTA_VERSION = x6.2; then
    476483                                   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"
     
    478485                                        AC_DEFINE([DISABLE_DAKOTA_CONFIG_H],[1],[disabling DAKOTA_CONFIG_H])
    479486                                        AC_DEFINE([DAKOTA_HAVE_MPI],[1],[enabling parallel MPI])
     487                                        AM_CONDITIONAL([ISSM_DAKOTA],1)
    480488                                else
    481489                                        AC_MSG_ERROR([Dakota version not found or version ($DAKOTA_VERSION) not supported!]);
     
    488496                                if      test x$DAKOTA_VERSION = x4.2 || test x$DAKOTA_VERSION = x4.2+; then
    489497                                        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"
     498                                        AM_CONDITIONAL([ISSM_DAKOTA],0)
    490499                                        dnl DAKOTALIB+= "-lgslcblas -L/usr/lib -lblas -llapack"
    491500                                else if test x$DAKOTA_VERSION = x5.1 || test x$DAKOTA_VERSION = x5.2; then
    492501                                        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"
     502                                        AM_CONDITIONAL([ISSM_DAKOTA],0)
    493503                                        dnl DAKOTALIB+= "-lgslcblas -L/usr/lib -lblas -llapack"
    494504                                else if test x$DAKOTA_VERSION = x5.3 || test x$DAKOTA_VERSION = x5.3.1; then
    495505                                        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"
    496506                                        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"
     507                                        AM_CONDITIONAL([ISSM_DAKOTA],0)
     508                                        AC_DEFINE([DISABLE_DAKOTA_CONFIG_H],[1],[disabling DAKOTA_CONFIG_H])
     509                                        AM_CONDITIONAL([ISSM_DAKOTA],0)
    497510                                else if test x$DAKOTA_VERSION = x6.1 || test x$DAKOTA_VERSION = x6.2; then
    498511                                   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"
     
    500513                                        AC_DEFINE([DISABLE_DAKOTA_CONFIG_H],[1],[disabling DAKOTA_CONFIG_H])
    501514                                        AC_DEFINE([DAKOTA_HAVE_MPI],[1],[enabling parallel MPI])
     515                                        AM_CONDITIONAL([ISSM_DAKOTA],1)
    502516                                else
    503517                                        AC_MSG_ERROR([Dakota version not found or version ($DAKOTA_VERSION) not supported!]);
  • issm/trunk-jpl/src/c/Makefile.am

    r19632 r19634  
    661661endif
    662662
    663 if DAKOTA
     663if ISSM_DAKOTA
    664664bin_PROGRAMS += issm_dakota
    665665issm_dakota_SOURCES = main/issm_dakota.cpp
  • issm/trunk-jpl/src/c/classes/Dakota/IssmDirectApplicInterface.h

    r19632 r19634  
    3838/*}}}*/
    3939
    40 #if defined(_HAVE_DAKOTA_) && (_DAKOTA_MAJOR_ < 5 || (_DAKOTA_MAJOR_ == 5 && _DAKOTA_MINOR_ < 3))
     40#if !defined(_WRAPPERS_) && defined(_HAVE_DAKOTA_) && (_DAKOTA_MAJOR_ <= 5) //this only works for Dakota <=5, which had no effective parallel capabilities yet.
    4141
    4242/*Dakota include files:{{{*/
    43 #include <DakotaInterface.H>
    44 #include <DakotaStrategy.H>
    45 #include <DakotaModel.H>
     43#if (_DAKOTA_MAJOR_ < 5 || (_DAKOTA_MAJOR_ == 5 && _DAKOTA_MINOR_ < 3))
    4644#include <DirectApplicInterface.H>
    4745#include <DakotaResponse.H>
     
    5048#include <ProblemDescDB.H>
    5149#include <ParallelLibrary.H>
     50#else
     51#include <DirectApplicInterface.hpp>
     52#include <DakotaResponse.hpp>
     53#include <ParamResponsePair.hpp>
     54#include <ProblemDescDB.hpp>
     55#include <ParallelLibrary.hpp>
     56#endif
    5257/*}}}*/
     58
     59int  DakotaSpawnCore(double* d_responses, int d_numresponses, double* d_variables, char** d_variables_descriptors,int d_numvariables, void* void_femmodel,int counter);
    5360
    5461/*IssmDirectApplicInterface class */
  • issm/trunk-jpl/src/c/cores/dakota_core.cpp

    r19632 r19634  
    5959#include "../shared/shared.h"
    6060#include "../classes/classes.h"
    61 
    62 #if defined(_HAVE_DAKOTA_) && (_DAKOTA_MAJOR_ < 5 || (_DAKOTA_MAJOR_ == 5 && _DAKOTA_MINOR_ < 3))
    63 
    64 /*include dakota files: */
     61#include "../modules/modules.h"
     62
     63#if defined(_HAVE_DAKOTA_) && (_DAKOTA_MAJOR_ <= 5) //this only works for Dakota <=5, which had no effective parallel capabilities yet.
     64/*Dakota include files:{{{*/
     65#if (_DAKOTA_MAJOR_ < 5 || (_DAKOTA_MAJOR_ == 5 && _DAKOTA_MINOR_ < 3))
    6566#include <ParallelLibrary.H>
    6667#include <ProblemDescDB.H>
     
    6869#include <DakotaModel.H>
    6970#include <DakotaInterface.H>
    70 int  DakotaSpawnCore(double* d_responses, int d_numresponses, double* d_variables, char** d_variables_descriptors,int d_numvariables, void* void_femmodel,int counter){ /*{{{*/
    71 
    72         /*Notice the d_, which prefixes anything that is being provided to us by the Dakota pluggin. Careful. some things are ours, some are dakotas!: */
    73 
    74         char     **responses_descriptors    = NULL;      //these are our! there are only numresponsedescriptors of them, not d_numresponses!!!
    75         int        numresponsedescriptors;
    76         int        solution_type;
    77         bool       control_analysis         = false;
    78         void     (*solutioncore)(FemModel*) = NULL;
    79         FemModel  *femmodel                 = NULL;
    80         bool       nodakotacore             = true;
    81 
    82         /*If counter==-1 on cpu0, it means that the dakota runs are done. In which case, bail out and return 0: */
    83         ISSM_MPI_Bcast(&counter,1,ISSM_MPI_INT,0,IssmComm::GetComm());
    84         if(counter==-1)return 0;
    85 
    86         /*cast void_femmodel to FemModel, and at the same time, make a copy, so we start this new core run for this specific sample
    87          *with a brand new copy of the model, which has not been tempered with by previous dakota runs: */
    88         femmodel=(reinterpret_cast<FemModel*>(void_femmodel))->copy();
    89 
    90         /*retrieve parameters: */
    91         femmodel->parameters->FindParam(&responses_descriptors,&numresponsedescriptors,QmuResponsedescriptorsEnum);
    92         femmodel->parameters->FindParam(&solution_type,SolutionTypeEnum);
    93         femmodel->parameters->FindParam(&control_analysis,InversionIscontrolEnum);
    94 
    95         if(VerboseQmu()) _printf0_("qmu iteration: " << counter << "\n");
    96 
    97         /* only cpu 0, running dakota is providing us with variables and variables_descriptors and numresponses: broadcast onto other cpus: */
    98         DakotaMPI_Bcast(&d_variables,&d_variables_descriptors,&d_numvariables,&d_numresponses);
    99 
    100         /*Modify core inputs in objects contained in femmodel, to reflect the dakota variables inputs: */
    101         InputUpdateFromDakotax(femmodel,d_variables,d_variables_descriptors,d_numvariables);
    102 
    103         /*Determine solution sequence: */
    104         if(VerboseQmu()) _printf0_("Starting " << EnumToStringx(solution_type) << " core:\n");
    105         WrapperCorePointerFromSolutionEnum(&solutioncore,femmodel->parameters,solution_type,nodakotacore);
    106 
    107         /*Run the core solution sequence: */
    108         solutioncore(femmodel);
    109 
    110         /*compute responses: */
    111         if(VerboseQmu()) _printf0_("compute dakota responses:\n");
    112         femmodel->DakotaResponsesx(d_responses,responses_descriptors,numresponsedescriptors,d_numresponses);
    113 
    114         /*Free ressources:*/
    115         DakotaFree(&d_variables,&d_variables_descriptors,&responses_descriptors, d_numvariables, numresponsedescriptors);
    116 
    117         /*Avoid leaks here: */
    118         delete femmodel;
    119 
    120         return 1; //this is critical! do not return 0, otherwise, dakota_core will stop running!
    121 }
     71#else
     72#include <ParallelLibrary.hpp>
     73#include <ProblemDescDB.hpp>
     74#include <DakotaStrategy.hpp>
     75#include <DakotaModel.hpp>
     76#include <DakotaInterface.hpp>
     77#endif
    12278/*}}}*/
     79
     80void DakotaFree(double** pvariables,char*** pvariables_descriptors,char*** presponses_descriptors,int numvariables,int numresponses){ /*{{{*/
     81
     82        /*\brief DakotaFree: free allocations on other cpus, not done by Dakota.*/
     83
     84        int i;
     85        int my_rank;
     86
     87        double  *variables             = NULL;
     88        char   **variables_descriptors = NULL;
     89        char   **responses_descriptors = NULL;
     90        char    *string                = NULL;
     91
     92        /*recover pointers: */
     93        variables=*pvariables;
     94        variables_descriptors=*pvariables_descriptors;
     95        responses_descriptors=*presponses_descriptors;
     96
     97        /*recover my_rank:*/
     98        my_rank=IssmComm::GetRank();
     99
     100        /*Free variables and variables_descriptors only on cpu !=0*/
     101        if(my_rank!=0){
     102                xDelete<double>(variables);
     103                for(i=0;i<numvariables;i++){
     104                        string=variables_descriptors[i];
     105                        xDelete<char>(string);
     106                }
     107                xDelete<char*>(variables_descriptors);
     108        }
     109
     110        //responses descriptors on every cpu
     111        for(i=0;i<numresponses;i++){
     112                string=responses_descriptors[i];
     113                xDelete<char>(string);
     114        }
     115        //rest of dynamic allocations.
     116        xDelete<char*>(responses_descriptors);
     117
     118        /*Assign output pointers:*/
     119        *pvariables=variables;
     120        *pvariables_descriptors=variables_descriptors;
     121        *presponses_descriptors=responses_descriptors;
     122} /*}}}*/
    123123void DakotaMPI_Bcast(double** pvariables, char*** pvariables_descriptors,int* pnumvariables, int* pnumresponses){ /*{{{*/
    124124
     
    180180        *pnumresponses=numresponses;
    181181} /*}}}*/
    182 void DakotaFree(double** pvariables,char*** pvariables_descriptors,char*** presponses_descriptors,int numvariables,int numresponses){ /*{{{*/
    183 
    184         /*\brief DakotaFree: free allocations on other cpus, not done by Dakota.*/
    185 
    186         int i;
    187         int my_rank;
    188 
    189         double  *variables             = NULL;
    190         char   **variables_descriptors = NULL;
    191         char   **responses_descriptors = NULL;
    192         char    *string                = NULL;
    193 
    194         /*recover pointers: */
    195         variables=*pvariables;
    196         variables_descriptors=*pvariables_descriptors;
    197         responses_descriptors=*presponses_descriptors;
    198 
    199         /*recover my_rank:*/
    200         my_rank=IssmComm::GetRank();
    201 
    202         /*Free variables and variables_descriptors only on cpu !=0*/
    203         if(my_rank!=0){
    204                 xDelete<double>(variables);
    205                 for(i=0;i<numvariables;i++){
    206                         string=variables_descriptors[i];
    207                         xDelete<char>(string);
    208                 }
    209                 xDelete<char*>(variables_descriptors);
    210         }
    211 
    212         //responses descriptors on every cpu
    213         for(i=0;i<numresponses;i++){
    214                 string=responses_descriptors[i];
    215                 xDelete<char>(string);
    216         }
    217         //rest of dynamic allocations.
    218         xDelete<char*>(responses_descriptors);
    219 
    220         /*Assign output pointers:*/
    221         *pvariables=variables;
    222         *pvariables_descriptors=variables_descriptors;
    223         *presponses_descriptors=responses_descriptors;
    224 } /*}}}*/
     182int  DakotaSpawnCore(double* d_responses, int d_numresponses, double* d_variables, char** d_variables_descriptors,int d_numvariables, void* void_femmodel,int counter){ /*{{{*/
     183
     184        /*Notice the d_, which prefixes anything that is being provided to us by the Dakota pluggin. Careful. some things are ours, some are dakotas!: */
     185
     186        char     **responses_descriptors    = NULL;      //these are our! there are only numresponsedescriptors of them, not d_numresponses!!!
     187        int        numresponsedescriptors;
     188        int        solution_type;
     189        bool       control_analysis         = false;
     190        void     (*solutioncore)(FemModel*) = NULL;
     191        FemModel  *femmodel                 = NULL;
     192        bool       nodakotacore             = true;
     193
     194        /*If counter==-1 on cpu0, it means that the dakota runs are done. In which case, bail out and return 0: */
     195        ISSM_MPI_Bcast(&counter,1,ISSM_MPI_INT,0,IssmComm::GetComm());
     196        if(counter==-1)return 0;
     197
     198        /*cast void_femmodel to FemModel, and at the same time, make a copy, so we start this new core run for this specific sample
     199         *with a brand new copy of the model, which has not been tempered with by previous dakota runs: */
     200        femmodel=(reinterpret_cast<FemModel*>(void_femmodel))->copy();
     201
     202        /*retrieve parameters: */
     203        femmodel->parameters->FindParam(&responses_descriptors,&numresponsedescriptors,QmuResponsedescriptorsEnum);
     204        femmodel->parameters->FindParam(&solution_type,SolutionTypeEnum);
     205        femmodel->parameters->FindParam(&control_analysis,InversionIscontrolEnum);
     206
     207        if(VerboseQmu()) _printf0_("qmu iteration: " << counter << "\n");
     208
     209        /* only cpu 0, running dakota is providing us with variables and variables_descriptors and numresponses: broadcast onto other cpus: */
     210        DakotaMPI_Bcast(&d_variables,&d_variables_descriptors,&d_numvariables,&d_numresponses);
     211
     212        /*Modify core inputs in objects contained in femmodel, to reflect the dakota variables inputs: */
     213        InputUpdateFromDakotax(femmodel,d_variables,d_variables_descriptors,d_numvariables);
     214
     215        /*Determine solution sequence: */
     216        if(VerboseQmu()) _printf0_("Starting " << EnumToStringx(solution_type) << " core:\n");
     217        WrapperCorePointerFromSolutionEnum(&solutioncore,femmodel->parameters,solution_type,nodakotacore);
     218
     219        /*Run the core solution sequence: */
     220        solutioncore(femmodel);
     221
     222        /*compute responses: */
     223        if(VerboseQmu()) _printf0_("compute dakota responses:\n");
     224        femmodel->DakotaResponsesx(d_responses,responses_descriptors,numresponsedescriptors,d_numresponses);
     225
     226        /*Free ressources:*/
     227        DakotaFree(&d_variables,&d_variables_descriptors,&responses_descriptors, d_numvariables, numresponsedescriptors);
     228
     229        /*Avoid leaks here: */
     230        delete femmodel;
     231
     232        return 1; //this is critical! do not return 0, otherwise, dakota_core will stop running!
     233}
     234/*}}}*/
    225235void dakota_core(FemModel* femmodel){  /*{{{*/
    226236
     
    273283
    274284                        // Serial case: plug in derived Interface object without an analysisComm
    275                         interface.assign_rep(new SIM::DakotaPlugin(problem_db,(void*)femmodel), false);
     285                        interface.assign_rep(new SIM::IssmDirectApplicInterface(problem_db,(void*)femmodel), false);
    276286                }
    277287
     
    299309#else
    300310void dakota_core(FemModel* femmodel){
    301         /*do nothing*/
     311        _error_("dakota_core for versions of Dakota >=6 should not be used anymore! Use instead the issm_dakota  executable!");
    302312}
    303313#endif
  • issm/trunk-jpl/src/c/main/issm_dakota.cpp

    r19632 r19634  
    66
    77/*Dakota includes: */
     8#if defined(_HAVE_DAKOTA_) && _DAKOTA_MAJOR_ >= 6
    89#include "ParallelLibrary.hpp"
    910#include "ProblemDescDB.hpp"
     
    1112#include "DakotaModel.hpp"
    1213#include "DakotaInterface.hpp"
     14#endif
    1315
    1416int main(int argc,char **argv){
     17
     18
     19        #if defined(_HAVE_DAKOTA_) && _DAKOTA_MAJOR_ >= 6
    1520
    1621        bool parallel=true;
     
    8085        /*Return unix success: */
    8186        return 0;
     87        #else
     88        Cout <<  "ISSM Dakota  executable was compiled without support of Dakota! Will just return now!" << "\n";
     89        return 1;
     90        #endif
    8291}
Note: See TracChangeset for help on using the changeset viewer.