diff --git a/ComputingTasks.cc b/ComputingTasks.cc index c3390c274afced0e2bcf9f9ec405728159b1acce..1926b67ac600889779b779127e7df34a95f3de84 100644 --- a/ComputingTasks.cc +++ b/ComputingTasks.cc @@ -2382,6 +2382,12 @@ WriteLatexSteadyStateModelStatement::WriteLatexSteadyStateModelStatement(const S { } +void +WriteLatexSteadyStateModelStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) +{ + mod_file_struct.write_latex_steady_state_model_present = true; +} + void WriteLatexSteadyStateModelStatement::writeOutput(ostream &output, const string &basename, bool minimal_workspace) const { diff --git a/ComputingTasks.hh b/ComputingTasks.hh index e371284f31f9c76f3f43e7be58597f8280def44e..18ec20d18045460e162fb4b9e293cb79dd84b29d 100644 --- a/ComputingTasks.hh +++ b/ComputingTasks.hh @@ -632,6 +632,7 @@ private: const SteadyStateModel &steady_state_model; public: WriteLatexSteadyStateModelStatement(const SteadyStateModel &steady_state_model_arg); + virtual void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings); virtual void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const; virtual void writeJsonOutput(ostream &output) const; }; diff --git a/ModFile.cc b/ModFile.cc index 39f9b5b17c46d9eb4d2bc1f8b876b028627c265e..6fea425e5d050a44a6895bb41479969b4d886383 100644 --- a/ModFile.cc +++ b/ModFile.cc @@ -114,7 +114,14 @@ ModFile::checkPass(bool nostrict) (*it)->checkPass(mod_file_struct, warnings); // Check the steady state block - steady_state_model.checkPass(mod_file_struct.ramsey_model_present, warnings); + steady_state_model.checkPass(mod_file_struct, warnings); + + if (mod_file_struct.write_latex_steady_state_model_present && + !mod_file_struct.steady_state_model_present) + { + cerr << "ERROR: You cannot have a write_latex_steady_state_model statement without a steady_state_model block." << endl; + exit(EXIT_FAILURE); + } // If order option has not been set, default to 2 if (!mod_file_struct.order_option) diff --git a/Statement.cc b/Statement.cc index 14bffcc3bcc197f264062525060dc86605a370b3..8a86f75a96b34ee234a195e99831bdda6d35c701 100644 --- a/Statement.cc +++ b/Statement.cc @@ -59,7 +59,9 @@ ModFileStructure::ModFileStructure() : ms_dsge_present(false), occbin_option(false), orig_eq_nbr(0), - ramsey_eq_nbr(0) + ramsey_eq_nbr(0), + steady_state_model_present(false), + write_latex_steady_state_model_present(false) { } diff --git a/Statement.hh b/Statement.hh index 7c80f5d5bb80979381d8dc8eed98e9a4cef3dd28..db7d5606b1bdb6411f96ad14a4a9dc8195cbab3c 100644 --- a/Statement.hh +++ b/Statement.hh @@ -119,7 +119,10 @@ public: int orig_eq_nbr; //! Stores the number of equations added to the Ramsey model int ramsey_eq_nbr; - + //! Whether there was a steady_state_model block + bool steady_state_model_present; + //! Whether there is a write_latex_steady_state_model statement present + bool write_latex_steady_state_model_present; }; class Statement diff --git a/SteadyStateModel.cc b/SteadyStateModel.cc index 22792983807a22b9469785377ceb67293b64abe9..a68b2b1c3ddfe9e8c5f5a2c77f3d8c90cba37240 100644 --- a/SteadyStateModel.cc +++ b/SteadyStateModel.cc @@ -56,11 +56,12 @@ SteadyStateModel::addMultipleDefinitions(const vector<int> &symb_ids, expr_t exp } void -SteadyStateModel::checkPass(bool ramsey_model, WarningConsolidation &warnings) const +SteadyStateModel::checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) const { if (def_table.size() == 0) return; + mod_file_struct.steady_state_model_present = true; vector<int> so_far_defined; for (size_t i = 0; i < def_table.size(); i++) @@ -74,7 +75,7 @@ SteadyStateModel::checkPass(bool ramsey_model, WarningConsolidation &warnings) c warnings << "WARNING: in the 'steady_state_model' block, variable '" << symbol_table.getName(symb_ids[j]) << "' is declared twice" << endl; // Check that expression has no undefined symbol - if (!ramsey_model) + if (!mod_file_struct.ramsey_model_present) { set<int> used_symbols; const expr_t &expr = def_table[i].second; diff --git a/SteadyStateModel.hh b/SteadyStateModel.hh index f0782bc1f464feb07770b087b9ee2bd755de68f2..a4b879dc0bd2463bbf6d2a1a64c87530fbd68d55 100644 --- a/SteadyStateModel.hh +++ b/SteadyStateModel.hh @@ -21,6 +21,7 @@ #define _STEADY_STATE_MODEL_HH #include "DataTree.hh" +#include "Statement.hh" #include "StaticModel.hh" #include "WarningConsolidation.hh" @@ -43,7 +44,7 @@ public: /*! \param[in] ramsey_model Is there a Ramsey model in the MOD file? If yes, then disable the check on the recursivity of the declarations */ - void checkPass(bool ramsey_model, WarningConsolidation &warnings) const; + void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) const; //! Write the steady state file /*! \param[in] ramsey_model Is there a Ramsey model in the MOD file? If yes, then use the "ys" in argument of the steady state file as initial values