diff --git a/preprocessor/ComputingTasks.cc b/preprocessor/ComputingTasks.cc index 18d54db99..7fc5d59ef 100644 --- a/preprocessor/ComputingTasks.cc +++ b/preprocessor/ComputingTasks.cc @@ -223,6 +223,29 @@ ForecastStatement::ForecastStatement(const SymbolList &symbol_list_arg, { } +Statement * +ForecastStatement::cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table) +{ + SymbolList new_symbol_list; + try + { + SymbolTable *new_symbol_table = dynamic_datatree.getSymbolTable(); + vector symbols = symbol_list.get_symbols(); + for (vector::const_iterator it = symbols.begin(); it != symbols.end(); it++) + { + new_symbol_table->getID(*it); + new_symbol_list.addSymbol(*it); + } + } + catch (SymbolTable::UnknownSymbolNameException &e) + { + cerr << "ERROR: A variable in the forecast statement was not found in the symbol table" << endl + << " This likely means that you have declared a varexo that is not used in the model" << endl; + exit(EXIT_FAILURE); + } + return new ForecastStatement(new_symbol_list, options_list); +} + void ForecastStatement::writeOutput(ostream &output, const string &basename) const { diff --git a/preprocessor/ComputingTasks.hh b/preprocessor/ComputingTasks.hh index d84ef1afa..bc7dbcb19 100644 --- a/preprocessor/ComputingTasks.hh +++ b/preprocessor/ComputingTasks.hh @@ -109,6 +109,7 @@ public: ForecastStatement(const SymbolList &symbol_list_arg, const OptionsList &options_list_arg); virtual void writeOutput(ostream &output, const string &basename) const; + virtual Statement *cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table); }; class RamseyModelStatement : public Statement