diff --git a/src/ComputingTasks.cc b/src/ComputingTasks.cc index 4b1e4226aff6e77eb767d30cb73f72889fb7911f..6238649cfbdef8bf73a7a856eb8b649ae2d42cdf 100644 --- a/src/ComputingTasks.cc +++ b/src/ComputingTasks.cc @@ -645,6 +645,8 @@ StochSimulStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsoli << endl; exit(EXIT_FAILURE); } + + symbol_list.removeDuplicates("stoch_simul", warnings); } void diff --git a/src/ComputingTasks.hh b/src/ComputingTasks.hh index 1568272d3b82f6ff59eec1636545f621127f2e05..4961ccc8bb37c1fe50c28abdafbedb1df49fe6e8 100644 --- a/src/ComputingTasks.hh +++ b/src/ComputingTasks.hh @@ -124,7 +124,7 @@ public: class StochSimulStatement : public Statement { private: - const SymbolList symbol_list; + SymbolList symbol_list; const OptionsList options_list; public: StochSimulStatement(SymbolList symbol_list_arg, diff --git a/src/SymbolList.cc b/src/SymbolList.cc index 1d290984c948a4b29021d52e21686253e94ad8ea..f8dab968c9b8e1d2423aa3531681d3ed5c50f15c 100644 --- a/src/SymbolList.cc +++ b/src/SymbolList.cc @@ -1,5 +1,5 @@ /* - * Copyright © 2003-2018 Dynare Team + * Copyright © 2003-2019 Dynare Team * * This file is part of Dynare. * @@ -70,3 +70,16 @@ SymbolList::getSymbols() const { return symbols; } + +void +SymbolList::removeDuplicates(const string &dynare_command, WarningConsolidation &warnings) +{ + vector<string> unique_symbols; + for (auto & it : symbols) + if (find(unique_symbols.begin(), unique_symbols.end(), it) == unique_symbols.end()) + unique_symbols.push_back(it); + else + warnings << "WARNING: In " << dynare_command << ": " << it + << " found more than once in symbol list. Removing all but first occurence." << endl; + symbols = unique_symbols; +} diff --git a/src/SymbolList.hh b/src/SymbolList.hh index 622f9914abf6bbe6bb5fd6da33b2881c153797ef..afdf6080016639b896bdf4a8219ac81d4a6ce792 100644 --- a/src/SymbolList.hh +++ b/src/SymbolList.hh @@ -1,5 +1,5 @@ /* - * Copyright © 2003-2017 Dynare Team + * Copyright © 2003-2019 Dynare Team * * This file is part of Dynare. * @@ -24,6 +24,8 @@ #include <vector> #include <ostream> +#include "WarningConsolidation.hh" + using namespace std; //! Used to store a list of symbols @@ -36,6 +38,8 @@ private: public: //! Adds a symbol to the list void addSymbol(const string &symbol); + //! Removed duplicate symbols + void removeDuplicates(const string &dynare_command, WarningConsolidation &warnings); //! Output content in Matlab format /*! Creates a string array for Matlab, stored in variable "varname" */ void writeOutput(const string &varname, ostream &output) const;