add onlymodel command line option

issue#70
Houtan Bastani 2018-11-07 15:24:57 +01:00
parent beb99d98cd
commit 5f5fd569dd
No known key found for this signature in database
GPG Key ID: 000094FB955BE169
4 changed files with 73 additions and 52 deletions

View File

@ -47,7 +47,7 @@ void main2(stringstream &in, string &basename, bool debug, bool clear_all, bool
LanguageOutputType lang, int params_derivs_order, bool transform_unary_ops,
JsonOutputPointType json, JsonFileOutputType json_output_mode, bool onlyjson, bool jsonderivsimple,
bool nopreprocessoroutput, const string &mexext, const boost::filesystem::path &matlabroot,
const boost::filesystem::path &dynareroot);
const boost::filesystem::path &dynareroot, bool onlymodel);
void main1(string &modfile, string &basename, string &modfiletxt, bool debug, bool save_macro, string &save_macro_file,
bool no_line_macro, bool no_empty_line_macro, map<string, string> &defines, vector<string> &path, stringstream &macro_output);
@ -60,7 +60,7 @@ usage()
<< " [-D<variable>[=<value>]] [-I/path] [nostrict] [stochastic] [fast] [minimal_workspace] [compute_xrefs] [output=dynamic|first|second|third] [language=julia]"
<< " [params_derivs_order=0|1|2] [transform_unary_ops]"
<< " [json=parse|check|transform|compute] [jsonstdout] [onlyjson] [jsonderivsimple] [nopathchange] [nopreprocessoroutput]"
<< " [mexext=<extension>] [matlabroot=<path>]"
<< " [mexext=<extension>] [matlabroot=<path>] [onlymodel]"
<< endl;
exit(EXIT_FAILURE);
}
@ -122,6 +122,7 @@ main(int argc, char **argv)
boost::filesystem::path dynareroot{argv[0]};
dynareroot = dynareroot.parent_path();
dynareroot = dynareroot / ".." / "..";
bool onlymodel = false;
// Parse options
for (int arg = 2; arg < argc; arg++)
@ -344,6 +345,8 @@ main(int argc, char **argv)
}
matlabroot = boost::filesystem::path{s.substr(11)};
}
else if (s == "onlymodel")
onlymodel = true;
else
{
cerr << "Unknown option: " << s << endl;
@ -414,7 +417,7 @@ main(int argc, char **argv)
parallel, config_file, warnings, nostrict, stochastic, check_model_changes, minimal_workspace,
compute_xrefs, output_mode, language, params_derivs_order, transform_unary_ops,
json, json_output_mode, onlyjson, jsonderivsimple, nopreprocessoroutput,
mexext, matlabroot, dynareroot);
mexext, matlabroot, dynareroot, onlymodel);
return EXIT_SUCCESS;
}

View File

@ -35,7 +35,7 @@ main2(stringstream &in, string &basename, bool debug, bool clear_all, bool clear
LanguageOutputType language, int params_derivs_order, bool transform_unary_ops,
JsonOutputPointType json, JsonFileOutputType json_output_mode, bool onlyjson, bool jsonderivsimple,
bool nopreprocessoroutput, const string &mexext, const boost::filesystem::path &matlabroot,
const boost::filesystem::path &dynareroot)
const boost::filesystem::path &dynareroot, bool onlymodel)
{
ParsingDriver p(warnings, nostrict);
@ -70,7 +70,7 @@ main2(stringstream &in, string &basename, bool debug, bool clear_all, bool clear
else
mod_file->writeOutputFiles(basename, clear_all, clear_global, no_log, no_warn, console, nograph,
nointeractive, config_file, check_model_changes, minimal_workspace, compute_xrefs,
nopreprocessoroutput, mexext, matlabroot, dynareroot);
nopreprocessoroutput, mexext, matlabroot, dynareroot, onlymodel);
if (!nopreprocessoroutput)
cout << "Preprocessing completed." << endl;

View File

@ -28,6 +28,7 @@
#include "ModFile.hh"
#include "ConfigFile.hh"
#include "ComputingTasks.hh"
#include "Shocks.hh"
ModFile::ModFile(WarningConsolidation &warnings_arg)
: var_model_table{symbol_table},
@ -792,7 +793,7 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool clear_glo
bool check_model_changes, bool minimal_workspace, bool compute_xrefs,
const bool nopreprocessoroutput, const string &mexext,
const boost::filesystem::path &matlabroot,
const boost::filesystem::path &dynareroot) const
const boost::filesystem::path &dynareroot, bool onlymodel) const
{
bool hasModelChanged = !dynamic_model.isChecksumMatching(basename, block);
if (!check_model_changes)
@ -865,6 +866,7 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool clear_glo
<< "%" << endl
<< "% Some global variables initialization" << endl
<< "%" << endl;
if (!onlymodel)
config_file.writeHooks(mOutputFile);
mOutputFile << "global_initialization;" << endl
<< "diary off;" << endl;
@ -946,6 +948,7 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool clear_glo
mOutputFile << ";" << endl
<< "M_.hessian_eq_zero = isempty(M_.nonzero_hessian_eqs);" << endl;
if (!onlymodel)
config_file.writeCluster(mOutputFile);
if (byte_code)
@ -967,6 +970,19 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool clear_glo
static_model.writeOutput(mOutputFile, block);
}
if (onlymodel)
for (auto &statement : statements)
{
auto *ips = dynamic_cast<InitParamStatement *>(statement.get());
if (ips != nullptr)
ips->writeOutput(mOutputFile, basename, minimal_workspace);
auto *ss = dynamic_cast<ShocksStatement *>(statement.get());
if (ss != nullptr)
ss->writeOutput(mOutputFile, basename, minimal_workspace);
}
else
{
for (auto &statement : statements)
{
statement->writeOutput(mOutputFile, basename, minimal_workspace);
@ -1019,6 +1035,7 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool clear_glo
<< " disp('Note: warning(s) encountered in MATLAB/Octave code')" << endl
<< "end" << endl;
}
}
if (!no_log)
mOutputFile << "diary off" << endl;

View File

@ -163,7 +163,8 @@ public:
void writeOutputFiles(const string &basename, bool clear_all, bool clear_global, bool no_log, bool no_warn,
bool console, bool nograph, bool nointeractive, const ConfigFile &config_file,
bool check_model_changes, bool minimal_workspace, bool compute_xrefs,
const bool nopreprocessoroutput, const string &mexext, const boost::filesystem::path &matlabroot, const boost::filesystem::path &dynareroot) const;
const bool nopreprocessoroutput, const string &mexext, const boost::filesystem::path &matlabroot,
const boost::filesystem::path &dynareroot, bool onlymodel) const;
void writeExternalFiles(const string &basename, FileOutputType output, LanguageOutputType language, const bool nopreprocessoroutput) const;
void writeExternalFilesJulia(const string &basename, FileOutputType output, const bool nopreprocessoroutput) const;