fixes global oo_ declaration for steady state operator as discussed on 14 Sep

git-svn-id: https://www.dynare.org/svn/dynare/trunk@3020 ac1d8469-bf42-47a9-8791-bf33cf982152
issue#70
houtanb 2009-10-02 18:36:07 +00:00
parent 7c7a59e1b8
commit 0973dd9fa4
3 changed files with 12 additions and 1 deletions

View File

@ -39,6 +39,8 @@ DataTree::DataTree(SymbolTable &symbol_table_arg, NumericalConstants &num_consta
MinusInfinity = AddUMinus(Infinity); MinusInfinity = AddUMinus(Infinity);
Pi = AddNumConstant("3.141592653589793"); Pi = AddNumConstant("3.141592653589793");
steady_state_found = false;
} }
DataTree::~DataTree() DataTree::~DataTree()
@ -416,6 +418,7 @@ DataTree::AddNormcdf(NodeID iArg1, NodeID iArg2, NodeID iArg3)
NodeID NodeID
DataTree::AddSteadyState(NodeID iArg1) DataTree::AddSteadyState(NodeID iArg1)
{ {
steady_state_found = true;
return AddUnaryOp(oSteadyState, iArg1); return AddUnaryOp(oSteadyState, iArg1);
} }

View File

@ -64,6 +64,9 @@ protected:
//! Stores local variables value (maps symbol ID to corresponding node) //! Stores local variables value (maps symbol ID to corresponding node)
map<int, NodeID> local_variables_table; map<int, NodeID> local_variables_table;
//! true when oSteadyState is encountered in a dynamic model
bool steady_state_found;
//! Internal implementation of AddVariable(), without the check on the lag //! Internal implementation of AddVariable(), without the check on the lag
VariableNode *AddVariableInternal(int symb_id, int lag); VariableNode *AddVariableInternal(int symb_id, int lag);
@ -175,6 +178,8 @@ public:
//! Checks if a given symbol is used somewhere in the data tree //! Checks if a given symbol is used somewhere in the data tree
bool isSymbolUsed(int symb_id) const; bool isSymbolUsed(int symb_id) const;
//! Thrown when trying to access an unknown variable by deriv_id //! Thrown when trying to access an unknown variable by deriv_id
bool containsSteadyStateOperator() const { return steady_state_found; };
//! Thrown when trying to access an unknown variable by deriv_id
class UnknownDerivIDException class UnknownDerivIDException
{ {
}; };

View File

@ -1129,6 +1129,9 @@ DynamicModel::writeDynamicMFile(const string &dynamic_basename) const
<< "% Warning : this file is generated automatically by Dynare" << endl << "% Warning : this file is generated automatically by Dynare" << endl
<< "% from model file (.mod)" << endl << endl; << "% from model file (.mod)" << endl << endl;
if (containsSteadyStateOperator())
mDynamicModelFile << "global oo_;" << endl << endl;
writeDynamicModel(mDynamicModelFile, false); writeDynamicModel(mDynamicModelFile, false);
mDynamicModelFile.close(); mDynamicModelFile.close();