Cleanup the “output” option
— output Julia files as soon as “language=julia” is passed, independently of the value of the “output” option — drop the “dynamic” and “first” values of the “output” option, since they actually do nothing — obey the “output” option even in the deterministic case Ref. dynare#1600issue#70
parent
f5760c33ea
commit
8e03f17350
|
@ -54,7 +54,7 @@ usage()
|
||||||
{
|
{
|
||||||
cerr << "Dynare usage: dynare mod_file [debug] [noclearall] [onlyclearglobals] [savemacro[=macro_file]] [onlymacro] [linemacro] [notmpterms] [nolog] [warn_uninit]"
|
cerr << "Dynare usage: dynare mod_file [debug] [noclearall] [onlyclearglobals] [savemacro[=macro_file]] [onlymacro] [linemacro] [notmpterms] [nolog] [warn_uninit]"
|
||||||
<< " [console] [nograph] [nointeractive] [parallel[=cluster_name]] [conffile=parallel_config_path_and_filename] [parallel_slave_open_mode] [parallel_test]"
|
<< " [console] [nograph] [nointeractive] [parallel[=cluster_name]] [conffile=parallel_config_path_and_filename] [parallel_slave_open_mode] [parallel_test]"
|
||||||
<< " [-D<variable>[=<value>]] [-I/path] [nostrict] [stochastic] [fast] [minimal_workspace] [compute_xrefs] [output=dynamic|first|second|third] [language=matlab|julia]"
|
<< " [-D<variable>[=<value>]] [-I/path] [nostrict] [stochastic] [fast] [minimal_workspace] [compute_xrefs] [output=second|third] [language=matlab|julia]"
|
||||||
<< " [params_derivs_order=0|1|2] [transform_unary_ops] [exclude_eqs=<equation_tag_list_or_file>] [include_eqs=<equation_tag_list_or_file>]"
|
<< " [params_derivs_order=0|1|2] [transform_unary_ops] [exclude_eqs=<equation_tag_list_or_file>] [include_eqs=<equation_tag_list_or_file>]"
|
||||||
<< " [json=parse|check|transform|compute] [jsonstdout] [onlyjson] [jsonderivsimple] [nopathchange] [nopreprocessoroutput]"
|
<< " [json=parse|check|transform|compute] [jsonstdout] [onlyjson] [jsonderivsimple] [nopathchange] [nopreprocessoroutput]"
|
||||||
<< " [mexext=<extension>] [matlabroot=<path>] [onlymodel] [notime] [use_dll]"
|
<< " [mexext=<extension>] [matlabroot=<path>] [onlymodel] [notime] [use_dll]"
|
||||||
|
@ -153,7 +153,7 @@ main(int argc, char **argv)
|
||||||
string exclude_eqs, include_eqs;
|
string exclude_eqs, include_eqs;
|
||||||
vector<pair<string, string>> defines;
|
vector<pair<string, string>> defines;
|
||||||
vector<filesystem::path> paths;
|
vector<filesystem::path> paths;
|
||||||
FileOutputType output_mode{FileOutputType::none};
|
OutputType output_mode{OutputType::standard};
|
||||||
JsonOutputPointType json{JsonOutputPointType::nojson};
|
JsonOutputPointType json{JsonOutputPointType::nojson};
|
||||||
JsonFileOutputType json_output_mode{JsonFileOutputType::file};
|
JsonFileOutputType json_output_mode{JsonFileOutputType::file};
|
||||||
bool onlyjson = false;
|
bool onlyjson = false;
|
||||||
|
@ -297,14 +297,10 @@ main(int argc, char **argv)
|
||||||
|
|
||||||
s.erase(0, 7);
|
s.erase(0, 7);
|
||||||
|
|
||||||
if (s == "dynamic")
|
if (s == "second")
|
||||||
output_mode = FileOutputType::dynamic;
|
output_mode = OutputType::second;
|
||||||
else if (s == "first")
|
|
||||||
output_mode = FileOutputType::first;
|
|
||||||
else if (s == "second")
|
|
||||||
output_mode = FileOutputType::second;
|
|
||||||
else if (s == "third")
|
else if (s == "third")
|
||||||
output_mode = FileOutputType::third;
|
output_mode = OutputType::third;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cerr << "Incorrect syntax for output option" << endl;
|
cerr << "Incorrect syntax for output option" << endl;
|
||||||
|
@ -495,11 +491,11 @@ main(int argc, char **argv)
|
||||||
if (json == JsonOutputPointType::computingpass)
|
if (json == JsonOutputPointType::computingpass)
|
||||||
mod_file->writeJsonOutput(basename, json, json_output_mode, onlyjson, jsonderivsimple);
|
mod_file->writeJsonOutput(basename, json, json_output_mode, onlyjson, jsonderivsimple);
|
||||||
|
|
||||||
// Write outputs
|
// Write output files
|
||||||
if (output_mode != FileOutputType::none)
|
if (language == LanguageOutputType::julia)
|
||||||
mod_file->writeExternalFiles(basename, language);
|
mod_file->writeJuliaOutput(basename);
|
||||||
else
|
else
|
||||||
mod_file->writeOutputFiles(basename, clear_all, clear_global, no_warn, console, nograph,
|
mod_file->writeMOutput(basename, clear_all, clear_global, no_warn, console, nograph,
|
||||||
nointeractive, config_file, check_model_changes, minimal_workspace, compute_xrefs,
|
nointeractive, config_file, check_model_changes, minimal_workspace, compute_xrefs,
|
||||||
mexext, matlabroot, dynareroot, onlymodel, gui, notime);
|
mexext, matlabroot, dynareroot, onlymodel, gui, notime);
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright © 2014-2019 Dynare Team
|
* Copyright © 2014-2021 Dynare Team
|
||||||
*
|
*
|
||||||
* This file is part of Dynare.
|
* This file is part of Dynare.
|
||||||
*
|
*
|
||||||
|
@ -20,18 +20,18 @@
|
||||||
#ifndef _EXTENDED_PREPROCESSOR_TYPES_HH
|
#ifndef _EXTENDED_PREPROCESSOR_TYPES_HH
|
||||||
#define _EXTENDED_PREPROCESSOR_TYPES_HH
|
#define _EXTENDED_PREPROCESSOR_TYPES_HH
|
||||||
|
|
||||||
enum class FileOutputType
|
// Values for the “output” option
|
||||||
|
enum class OutputType
|
||||||
{
|
{
|
||||||
none, // outputs files for Matlab/Octave processing
|
standard, // Default value, infer the derivation order from .mod file only
|
||||||
dynamic, // outputs <fname>_dynamic.* and related files
|
second, // Output at least 2nd dynamic derivatives
|
||||||
first, // outputs <fname>_first_derivatives.* and related files
|
third, // Output at least 3rd dynamic derivatives
|
||||||
second, // outputs <fname>_first_derivatives.*, <fname>_second_derivatives.* and related files
|
|
||||||
third, // outputs <fname>_first_derivatives.*, <fname>_second_derivatives.*, <fname>_third_derivatives.* and related files
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Values for the “language” option
|
||||||
enum class LanguageOutputType
|
enum class LanguageOutputType
|
||||||
{
|
{
|
||||||
matlab, // outputs files for Matlab/Octave processing
|
matlab, // outputs files for MATLAB/Octave processing
|
||||||
julia, // outputs files for Julia
|
julia, // outputs files for Julia
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -41,6 +41,7 @@ enum class JsonFileOutputType
|
||||||
standardout, // output JSON files to stdout
|
standardout, // output JSON files to stdout
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Values for the “json” option
|
||||||
enum class JsonOutputPointType
|
enum class JsonOutputPointType
|
||||||
{
|
{
|
||||||
nojson, // don't output JSON
|
nojson, // don't output JSON
|
||||||
|
@ -49,4 +50,5 @@ enum class JsonOutputPointType
|
||||||
transformpass, // output JSON after the transform pass
|
transformpass, // output JSON after the transform pass
|
||||||
computingpass // output JSON after the computing pass
|
computingpass // output JSON after the computing pass
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -721,7 +721,7 @@ ModFile::transformPass(bool nostrict, bool stochastic, bool compute_xrefs, bool
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ModFile::computingPass(bool no_tmp_terms, FileOutputType output, int params_derivs_order)
|
ModFile::computingPass(bool no_tmp_terms, OutputType output, int params_derivs_order)
|
||||||
{
|
{
|
||||||
// Mod file may have no equation (for example in a standalone BVAR estimation)
|
// Mod file may have no equation (for example in a standalone BVAR estimation)
|
||||||
if (dynamic_model.equation_number() > 0)
|
if (dynamic_model.equation_number() > 0)
|
||||||
|
@ -765,7 +765,14 @@ ModFile::computingPass(bool no_tmp_terms, FileOutputType output, int params_deri
|
||||||
|| mod_file_struct.calib_smoother_present || mod_file_struct.mom_estimation_present)
|
|| mod_file_struct.calib_smoother_present || mod_file_struct.mom_estimation_present)
|
||||||
{
|
{
|
||||||
if (mod_file_struct.perfect_foresight_solver_present)
|
if (mod_file_struct.perfect_foresight_solver_present)
|
||||||
dynamic_model.computingPass(true, 1, 0, global_eval_context, no_tmp_terms, block, use_dll, bytecode, linear_decomposition);
|
{
|
||||||
|
int derivsOrder = 1;
|
||||||
|
if (output == OutputType::second)
|
||||||
|
derivsOrder = 2;
|
||||||
|
else if (output == OutputType::third)
|
||||||
|
derivsOrder = 3;
|
||||||
|
dynamic_model.computingPass(true, derivsOrder, 0, global_eval_context, no_tmp_terms, block, use_dll, bytecode, linear_decomposition);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (mod_file_struct.stoch_simul_present
|
if (mod_file_struct.stoch_simul_present
|
||||||
|
@ -783,9 +790,9 @@ ModFile::computingPass(bool no_tmp_terms, FileOutputType output, int params_deri
|
||||||
derivsOrder = max(mod_file_struct.order_option,
|
derivsOrder = max(mod_file_struct.order_option,
|
||||||
max(mod_file_struct.identification_order,mod_file_struct.mom_order) + 1); // See preprocessor#40
|
max(mod_file_struct.identification_order,mod_file_struct.mom_order) + 1); // See preprocessor#40
|
||||||
|
|
||||||
if (mod_file_struct.sensitivity_present || linear || output == FileOutputType::second)
|
if (mod_file_struct.sensitivity_present || linear || output == OutputType::second)
|
||||||
derivsOrder = max(derivsOrder, 2);
|
derivsOrder = max(derivsOrder, 2);
|
||||||
if (mod_file_struct.estimation_analytic_derivation || output == FileOutputType::third)
|
if (mod_file_struct.estimation_analytic_derivation || output == OutputType::third)
|
||||||
derivsOrder = max(derivsOrder, 3);
|
derivsOrder = max(derivsOrder, 3);
|
||||||
int paramsDerivsOrder = 0;
|
int paramsDerivsOrder = 0;
|
||||||
if (mod_file_struct.identification_present
|
if (mod_file_struct.identification_present
|
||||||
|
@ -839,7 +846,7 @@ ModFile::computingPass(bool no_tmp_terms, FileOutputType output, int params_deri
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ModFile::writeOutputFiles(const string &basename, bool clear_all, bool clear_global, bool no_warn,
|
ModFile::writeMOutput(const string &basename, bool clear_all, bool clear_global, bool no_warn,
|
||||||
bool console, bool nograph, bool nointeractive, const ConfigFile &config_file,
|
bool console, bool nograph, bool nointeractive, const ConfigFile &config_file,
|
||||||
bool check_model_changes, bool minimal_workspace, bool compute_xrefs,
|
bool check_model_changes, bool minimal_workspace, bool compute_xrefs,
|
||||||
const string &mexext,
|
const string &mexext,
|
||||||
|
@ -1154,21 +1161,7 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool clear_glo
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ModFile::writeExternalFiles(const string &basename, LanguageOutputType language) const
|
ModFile::writeJuliaOutput(const string &basename) const
|
||||||
{
|
|
||||||
switch (language)
|
|
||||||
{
|
|
||||||
case LanguageOutputType::julia:
|
|
||||||
writeExternalFilesJulia(basename);
|
|
||||||
break;
|
|
||||||
case LanguageOutputType::matlab:
|
|
||||||
cerr << "The 'output' option cannot be used when language=matlab" << endl;
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
ModFile::writeExternalFilesJulia(const string &basename) const
|
|
||||||
{
|
{
|
||||||
ofstream jlOutputFile;
|
ofstream jlOutputFile;
|
||||||
if (basename.size())
|
if (basename.size())
|
||||||
|
|
|
@ -152,7 +152,7 @@ public:
|
||||||
//! Execute computations
|
//! Execute computations
|
||||||
/*! \param no_tmp_terms if true, no temporary terms will be computed in the static and dynamic files */
|
/*! \param no_tmp_terms if true, no temporary terms will be computed in the static and dynamic files */
|
||||||
/*! \param params_derivs_order compute this order of derivs wrt parameters */
|
/*! \param params_derivs_order compute this order of derivs wrt parameters */
|
||||||
void computingPass(bool no_tmp_terms, FileOutputType output, int params_derivs_order);
|
void computingPass(bool no_tmp_terms, OutputType output, int params_derivs_order);
|
||||||
//! Writes Matlab/Octave output files
|
//! Writes Matlab/Octave output files
|
||||||
/*!
|
/*!
|
||||||
\param basename The base name used for writing output files. Should be the name of the mod file without its extension
|
\param basename The base name used for writing output files. Should be the name of the mod file without its extension
|
||||||
|
@ -165,13 +165,13 @@ public:
|
||||||
\param mingw Should the MEX command of use_dll be adapted for MinGW?
|
\param mingw Should the MEX command of use_dll be adapted for MinGW?
|
||||||
\param compute_xrefs if true, equation cross references will be computed
|
\param compute_xrefs if true, equation cross references will be computed
|
||||||
*/
|
*/
|
||||||
void writeOutputFiles(const string &basename, bool clear_all, bool clear_global, bool no_warn,
|
void writeMOutput(const string &basename, bool clear_all, bool clear_global, bool no_warn,
|
||||||
bool console, bool nograph, bool nointeractive, const ConfigFile &config_file,
|
bool console, bool nograph, bool nointeractive, const ConfigFile &config_file,
|
||||||
bool check_model_changes, bool minimal_workspace, bool compute_xrefs,
|
bool check_model_changes, bool minimal_workspace, bool compute_xrefs,
|
||||||
const string &mexext, const filesystem::path &matlabroot,
|
const string &mexext, const filesystem::path &matlabroot,
|
||||||
const filesystem::path &dynareroot, bool onlymodel, bool gui, bool notime) const;
|
const filesystem::path &dynareroot, bool onlymodel, bool gui, bool notime) const;
|
||||||
void writeExternalFiles(const string &basename, LanguageOutputType language) const;
|
|
||||||
void writeExternalFilesJulia(const string &basename) const;
|
void writeJuliaOutput(const string &basename) const;
|
||||||
|
|
||||||
void computeChecksum();
|
void computeChecksum();
|
||||||
//! Write JSON representation of ModFile object
|
//! Write JSON representation of ModFile object
|
||||||
|
|
Loading…
Reference in New Issue