clean up writing of static model
parent
f3c14ec396
commit
6fc6f2f7d1
|
@ -1195,7 +1195,7 @@ PlannerObjectiveStatement::computingPass()
|
||||||
void
|
void
|
||||||
PlannerObjectiveStatement::writeOutput(ostream &output, const string &basename, bool minimal_workspace) const
|
PlannerObjectiveStatement::writeOutput(ostream &output, const string &basename, bool minimal_workspace) const
|
||||||
{
|
{
|
||||||
model_tree->writeStaticFile(basename + "_objective", false, false, false);
|
model_tree->writeStaticFile(basename + "_objective", false, false, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
BVARDensityStatement::BVARDensityStatement(int maxnlags_arg, const OptionsList &options_list_arg) :
|
BVARDensityStatement::BVARDensityStatement(int maxnlags_arg, const OptionsList &options_list_arg) :
|
||||||
|
|
12
ModFile.cc
12
ModFile.cc
|
@ -810,7 +810,7 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool clear_glo
|
||||||
{
|
{
|
||||||
if (!no_static)
|
if (!no_static)
|
||||||
{
|
{
|
||||||
static_model.writeStaticFile(basename, block, byte_code, use_dll);
|
static_model.writeStaticFile(basename, block, byte_code, use_dll, false);
|
||||||
static_model.writeParamsDerivativesFile(basename);
|
static_model.writeParamsDerivativesFile(basename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -854,7 +854,7 @@ ModFile::writeExternalFilesC(const string &basename, FileOutputType output) cons
|
||||||
dynamic_model.writeDynamicFile(basename, block, byte_code, use_dll, mod_file_struct.order_option);
|
dynamic_model.writeDynamicFile(basename, block, byte_code, use_dll, mod_file_struct.order_option);
|
||||||
|
|
||||||
if (!no_static)
|
if (!no_static)
|
||||||
static_model.writeStaticFile(basename, false, false, true);
|
static_model.writeStaticFile(basename, false, false, true, false);
|
||||||
|
|
||||||
|
|
||||||
// static_model.writeStaticCFile(basename, block, byte_code, use_dll);
|
// static_model.writeStaticCFile(basename, block, byte_code, use_dll);
|
||||||
|
@ -959,7 +959,7 @@ ModFile::writeExternalFilesCC(const string &basename, FileOutputType output) con
|
||||||
dynamic_model.writeDynamicFile(basename, block, byte_code, use_dll, mod_file_struct.order_option);
|
dynamic_model.writeDynamicFile(basename, block, byte_code, use_dll, mod_file_struct.order_option);
|
||||||
|
|
||||||
if (!no_static)
|
if (!no_static)
|
||||||
static_model.writeStaticFile(basename, false, false, true);
|
static_model.writeStaticFile(basename, false, false, true, false);
|
||||||
|
|
||||||
// static_model.writeStaticCFile(basename, block, byte_code, use_dll);
|
// static_model.writeStaticCFile(basename, block, byte_code, use_dll);
|
||||||
// static_model.writeParamsDerivativesFileC(basename, cuda);
|
// static_model.writeParamsDerivativesFileC(basename, cuda);
|
||||||
|
@ -1083,6 +1083,7 @@ ModFile::writeExternalFilesJulia(const string &basename, FileOutputType output)
|
||||||
<< "##" << endl
|
<< "##" << endl
|
||||||
<< "using DynareModel" << endl
|
<< "using DynareModel" << endl
|
||||||
<< "using Utils" << endl
|
<< "using Utils" << endl
|
||||||
|
<< "using " << basename << "Static" << endl
|
||||||
<< "export dynamicmodel!, staticmodel!, steadystate!" << endl
|
<< "export dynamicmodel!, staticmodel!, steadystate!" << endl
|
||||||
<< "export model__" << endl
|
<< "export model__" << endl
|
||||||
<< "model__ = model()" << endl
|
<< "model__ = model()" << endl
|
||||||
|
@ -1115,9 +1116,10 @@ ModFile::writeExternalFilesJulia(const string &basename, FileOutputType output)
|
||||||
|
|
||||||
if (dynamic_model.equation_number() > 0)
|
if (dynamic_model.equation_number() > 0)
|
||||||
if (!no_static)
|
if (!no_static)
|
||||||
static_model.writeStaticFile(basename, false, false, false, &jlOutputFile);
|
static_model.writeStaticFile(basename, false, false, false, true);
|
||||||
|
|
||||||
jlOutputFile << "end" << endl;
|
jlOutputFile << "model__.static = " << basename << "Static.getStaticFunction()" << endl
|
||||||
|
<< "end" << endl;
|
||||||
jlOutputFile.close();
|
jlOutputFile.close();
|
||||||
cout << "done" << endl;
|
cout << "done" << endl;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1560,16 +1560,31 @@ StaticModel::writeStaticCFile(const string &func_name) const
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
StaticModel::writeStaticJuliaFile(ofstream &jlOutputFile) const
|
StaticModel::writeStaticJuliaFile(const string &basename) const
|
||||||
{
|
{
|
||||||
jlOutputFile << "model__.static = function static(y, x, params)" << endl;
|
string filename = basename + "Static.jl";
|
||||||
writeStaticModel(jlOutputFile, false, true);
|
ofstream output;
|
||||||
jlOutputFile << "(residual, g1, g2, g3)" << endl
|
output.open(filename.c_str(), ios::out | ios::binary);
|
||||||
|
if (!output.is_open())
|
||||||
|
{
|
||||||
|
cerr << "ERROR: Can't open file " << filename << " for writing" << endl;
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
output << "module " << basename << "Static" << endl << endl
|
||||||
|
<< "export getStaticFunction" << endl << endl
|
||||||
|
<< "function getStaticFunction()" << endl
|
||||||
|
<< " static" << endl
|
||||||
|
<< "end" << endl << endl
|
||||||
|
<< "function static(y, x, params)" << endl;
|
||||||
|
writeStaticModel(output, false, true);
|
||||||
|
output << "(residual, g1, g2, g3)" << endl
|
||||||
|
<< "end" << endl
|
||||||
<< "end" << endl;
|
<< "end" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
StaticModel::writeStaticFile(const string &basename, bool block, bool bytecode, bool use_dll, ofstream *jlOutputFile) const
|
StaticModel::writeStaticFile(const string &basename, bool block, bool bytecode, bool use_dll, bool julia) const
|
||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
|
@ -1598,8 +1613,8 @@ StaticModel::writeStaticFile(const string &basename, bool block, bool bytecode,
|
||||||
}
|
}
|
||||||
else if(use_dll)
|
else if(use_dll)
|
||||||
writeStaticCFile(basename);
|
writeStaticCFile(basename);
|
||||||
else if (jlOutputFile != NULL)
|
else if (julia)
|
||||||
writeStaticJuliaFile(*jlOutputFile);
|
writeStaticJuliaFile(basename);
|
||||||
else
|
else
|
||||||
writeStaticMFile(basename);
|
writeStaticMFile(basename);
|
||||||
writeAuxVarRecursiveDefinitions(basename);
|
writeAuxVarRecursiveDefinitions(basename);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2003-2012 Dynare Team
|
* Copyright (C) 2003-2015 Dynare Team
|
||||||
*
|
*
|
||||||
* This file is part of Dynare.
|
* This file is part of Dynare.
|
||||||
*
|
*
|
||||||
|
@ -51,7 +51,7 @@ private:
|
||||||
void writeStaticCFile(const string &func_name) const;
|
void writeStaticCFile(const string &func_name) const;
|
||||||
|
|
||||||
//! Writes static model file (Julia version)
|
//! Writes static model file (Julia version)
|
||||||
void writeStaticJuliaFile(ofstream &jlOutputFile) const;
|
void writeStaticJuliaFile(const string &basename) const;
|
||||||
|
|
||||||
//! Writes the static model equations and its derivatives
|
//! Writes the static model equations and its derivatives
|
||||||
void writeStaticModel(ostream &StaticOutput, bool use_dll, bool julia) const;
|
void writeStaticModel(ostream &StaticOutput, bool use_dll, bool julia) const;
|
||||||
|
@ -171,7 +171,7 @@ public:
|
||||||
int &u_count_int, bool &file_open) const;
|
int &u_count_int, bool &file_open) const;
|
||||||
|
|
||||||
//! Writes static model file
|
//! Writes static model file
|
||||||
void writeStaticFile(const string &basename, bool block, bool bytecode, bool use_dll, ofstream *jlOutputFile = NULL) const;
|
void writeStaticFile(const string &basename, bool block, bool bytecode, bool use_dll, bool julia) const;
|
||||||
|
|
||||||
//! Writes file containing static parameters derivatives
|
//! Writes file containing static parameters derivatives
|
||||||
void writeParamsDerivativesFile(const string &basename) const;
|
void writeParamsDerivativesFile(const string &basename) const;
|
||||||
|
|
Loading…
Reference in New Issue