- Bugs and memory leak correction
- implementation of model_info command git-svn-id: https://www.dynare.org/svn/dynare/dynare_v4@2007 ac1d8469-bf42-47a9-8791-bf33cf982152time-shift
parent
08688fd7f3
commit
3f047dab9c
|
@ -825,13 +825,21 @@ BlockTriangular::Normalize_and_BlockDecompose(bool* IM, Model_Block* ModelBlock,
|
|||
normalization.Gr_to_IM_basic(n, *prologue, *epilogue, IM, Equation_gr, false);
|
||||
}
|
||||
cout << "Finding the optimal block decomposition of the model ...\n";
|
||||
if(bt_verbose)
|
||||
blocks.Print_Equation_gr(Equation_gr);
|
||||
res = blocks.sc(Equation_gr);
|
||||
normalization.Free_Equation(n-*prologue-*epilogue,Equation_gr);
|
||||
if(*prologue+*epilogue<n)
|
||||
{
|
||||
if(bt_verbose)
|
||||
blocks.Print_Equation_gr(Equation_gr);
|
||||
res = blocks.sc(Equation_gr);
|
||||
normalization.Free_Equation(n-*prologue-*epilogue,Equation_gr);
|
||||
if(bt_verbose)
|
||||
blocks.block_result_print(res);
|
||||
}
|
||||
else
|
||||
{
|
||||
res = (block_result_t*)malloc(sizeof(*res));
|
||||
res->n_sets=0;
|
||||
}
|
||||
free(Equation_gr);
|
||||
if(bt_verbose)
|
||||
blocks.block_result_print(res);
|
||||
if ((*prologue) || (*epilogue))
|
||||
j = 1;
|
||||
else
|
||||
|
@ -868,7 +876,10 @@ BlockTriangular::Normalize_and_BlockDecompose(bool* IM, Model_Block* ModelBlock,
|
|||
}
|
||||
if (*epilogue)
|
||||
Allocate_Block(*epilogue, &count_Equ, &count_Block, EPILOGUE, ModelBlock);
|
||||
blocks.block_result_free(res);
|
||||
if(res->n_sets)
|
||||
blocks.block_result_free(res);
|
||||
else
|
||||
free(res);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -68,21 +68,23 @@ CheckStatement::checkPass(ModFileStructure &mod_file_struct)
|
|||
mod_file_struct.check_present = true;
|
||||
}
|
||||
|
||||
ModelInfoStatement::ModelInfoStatement(const OptionsList &options_list_arg) :
|
||||
Model_InfoStatement::Model_InfoStatement(const OptionsList &options_list_arg) :
|
||||
options_list(options_list_arg)
|
||||
{
|
||||
}
|
||||
|
||||
void ModelInfoStatement::checkPass(ModFileStructure &mod_file_struct)
|
||||
void Model_InfoStatement::checkPass(ModFileStructure &mod_file_struct)
|
||||
{
|
||||
//mod_file_struct.model_info_present = true;
|
||||
}
|
||||
|
||||
void ModelInfoStatement::writeOutput(ostream &output, const string &basename) const
|
||||
void Model_InfoStatement::writeOutput(ostream &output, const string &basename) const
|
||||
{
|
||||
options_list.writeOutput(output);
|
||||
output << "model_info();\n";
|
||||
}
|
||||
|
||||
|
||||
SimulStatement::SimulStatement(const OptionsList &options_list_arg) :
|
||||
options_list(options_list_arg)
|
||||
{
|
||||
|
|
|
@ -967,7 +967,7 @@ ModelTree::writeModelStaticEquationsOrdered_M(ostream &output, Model_Block *Mode
|
|||
||ModelBlock->Block_List[j].Simulation_Type==EVALUATE_BACKWARD_R
|
||||
||ModelBlock->Block_List[j].Simulation_Type==EVALUATE_FOREWARD_R )
|
||||
output << "function [y] = " << static_basename << "_" << j+1 << "(y, x)\n";
|
||||
else
|
||||
else
|
||||
output << "function [residual, g1, g2, g3, b] = " << static_basename << "_" << j+1 << "(y, x)\n";
|
||||
output << " % ////////////////////////////////////////////////////////////////////////" << endl
|
||||
<< " % //" << string(" Block ").substr(int(log10(j + 1))) << j + 1 << " "
|
||||
|
@ -1451,6 +1451,13 @@ ModelTree::writeModelEquationsCodeOrdered(const string file_name, const Model_Bl
|
|||
code_file.write(reinterpret_cast<char *>(&v1), sizeof(v1));
|
||||
code_file.write(&FCUML, sizeof(FCUML));
|
||||
}
|
||||
Uf[v].Ufl=Uf[v].Ufl_First;
|
||||
while(Uf[v].Ufl)
|
||||
{
|
||||
Uf[v].Ufl_First=Uf[v].Ufl->pNext;
|
||||
free(Uf[v].Ufl);
|
||||
Uf[v].Ufl=Uf[v].Ufl_First;
|
||||
}
|
||||
code_file.write(&FBINARY, sizeof(FBINARY));
|
||||
v=oMinus;
|
||||
code_file.write(reinterpret_cast<char *>(&v), sizeof(v));
|
||||
|
@ -1515,6 +1522,13 @@ ModelTree::writeModelEquationsCodeOrdered(const string file_name, const Model_Bl
|
|||
code_file.write(reinterpret_cast<char *>(&v1), sizeof(v1));
|
||||
code_file.write(&FCUML, sizeof(FCUML));
|
||||
}
|
||||
Uf[v].Ufl=Uf[v].Ufl_First;
|
||||
while(Uf[v].Ufl)
|
||||
{
|
||||
Uf[v].Ufl_First=Uf[v].Ufl->pNext;
|
||||
free(Uf[v].Ufl);
|
||||
Uf[v].Ufl=Uf[v].Ufl_First;
|
||||
}
|
||||
code_file.write(&FBINARY, sizeof(FBINARY));
|
||||
v=oMinus;
|
||||
code_file.write(reinterpret_cast<char *>(&v), sizeof(v));
|
||||
|
@ -1552,6 +1566,44 @@ ModelTree::writeModelEquationsCodeOrdered(const string file_name, const Model_Bl
|
|||
code_file.write(&FENDBLOCK, sizeof(FENDBLOCK));
|
||||
code_file.write(&FEND, sizeof(FEND));
|
||||
code_file.close();
|
||||
/*int mx_blck=j;
|
||||
for(j=0;j<mx_blck;j++)
|
||||
{
|
||||
if(ModelBlock->Block_List[j].Simulation_Type==SOLVE_BACKWARD_COMPLETE || ModelBlock->Block_List[j].Simulation_Type==SOLVE_FOREWARD_COMPLETE)
|
||||
{
|
||||
m=ModelBlock->Block_List[j].Max_Lag;
|
||||
for(i=0;i<ModelBlock->Block_List[j].IM_lead_lag[m].size;i++)
|
||||
{
|
||||
int eqr=ModelBlock->Block_List[j].IM_lead_lag[m].Equ[i];
|
||||
int v=ModelBlock->Block_List[j].Equation[eqr];
|
||||
Uf[v].Ufl=Uf[v].Ufl_First;
|
||||
while(Uf[v].Ufl)
|
||||
{
|
||||
Uf[v].Ufl_First=Uf[v].Ufl->pNext;
|
||||
free(Uf[v].Ufl);
|
||||
Uf[v].Ufl=Uf[v].Ufl_First;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(ModelBlock->Block_List[j].Simulation_Type==SOLVE_TWO_BOUNDARIES_COMPLETE || ModelBlock->Block_List[j].Simulation_Type==SOLVE_TWO_BOUNDARIES_SIMPLE)
|
||||
{
|
||||
for(m=0;m<=ModelBlock->Block_List[j].Max_Lead+ModelBlock->Block_List[j].Max_Lag;m++)
|
||||
{
|
||||
for(i=0;i<ModelBlock->Block_List[j].IM_lead_lag[m].size;i++)
|
||||
{
|
||||
int eqr=ModelBlock->Block_List[j].IM_lead_lag[m].Equ[i];
|
||||
int v=ModelBlock->Block_List[j].Equation[eqr];
|
||||
Uf[v].Ufl=Uf[v].Ufl_First;
|
||||
while(Uf[v].Ufl)
|
||||
{
|
||||
Uf[v].Ufl_First=Uf[v].Ufl->pNext;
|
||||
free(Uf[v].Ufl);
|
||||
Uf[v].Ufl=Uf[v].Ufl_First;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -729,13 +729,15 @@ ParsingDriver::simul()
|
|||
options_list.clear();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ParsingDriver::model_info()
|
||||
{
|
||||
mod_file->addStatement(new ModelInfoStatement(options_list));
|
||||
mod_file->addStatement(new Model_InfoStatement(options_list));
|
||||
options_list.clear();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ParsingDriver::check()
|
||||
{
|
||||
|
|
|
@ -76,12 +76,12 @@ public:
|
|||
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||
};
|
||||
|
||||
class ModelInfoStatement : public Statement
|
||||
class Model_InfoStatement : public Statement
|
||||
{
|
||||
private:
|
||||
const OptionsList options_list;
|
||||
public:
|
||||
ModelInfoStatement(const OptionsList &options_list_arg);
|
||||
Model_InfoStatement(const OptionsList &options_list_arg);
|
||||
virtual void checkPass(ModFileStructure &mod_file_struct);
|
||||
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue