From 5d96e8c2f0b53da9e86203200862e79aefba67f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= Date: Wed, 28 Jun 2017 14:19:35 +0200 Subject: [PATCH 01/18] Also remove git files of matlab/modules/ from tarball. --- Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 5fa0d96ca..c5e4ef4d7 100644 --- a/Makefile.am +++ b/Makefile.am @@ -39,7 +39,7 @@ dist-hook: rm -rf `find $(distdir)/matlab $(distdir)/examples -name *~` rm -rf $(distdir)/matlab/preprocessor* $(distdir)/matlab/dynare_version.m $(MKDIR_P) $(distdir)/mex/matlab $(distdir)/mex/octave - rm -rf `find $(distdir)/contrib -name '.git*'` + rm -rf `find $(distdir) -name '.git*'` install-exec-local: $(MKDIR_P) $(DESTDIR)$(pkglibdir)/contrib/ms-sbvar/TZcode From 801154dbee1e54f5d17514bfdd094fe44d3effd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= Date: Wed, 28 Jun 2017 15:06:02 +0200 Subject: [PATCH 02/18] Do not install LICENSE.md files of submodules under /usr/lib/dynare/matlab. --- Makefile.am | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile.am b/Makefile.am index c5e4ef4d7..b23681f95 100644 --- a/Makefile.am +++ b/Makefile.am @@ -48,6 +48,7 @@ install-exec-local: cp -r contrib/jsonlab $(DESTDIR)$(pkglibdir)/contrib/jsonlab cp -r examples $(DESTDIR)$(pkglibdir) cp -r matlab $(DESTDIR)$(pkglibdir) + find $(DESTDIR)$(pkglibdir) -name LICENSE.md -delete rm -rf $(DESTDIR)$(pkglibdir)/matlab/preprocessor* { \ if [ -z "`file preprocessor/dynare_m | grep x86.64`" ]; then \ From 1ff5c3f5718b787b60948153b1e93d465e6b8d68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= Date: Wed, 28 Jun 2017 15:06:54 +0200 Subject: [PATCH 03/18] Fix various typos (thanks lintian). --- dynare++/kord/korder.cweb | 4 ++-- dynare++/kord/korder_stoch.hweb | 2 +- mex/sources/bytecode/SparseMatrix.cc | 4 ++-- mex/sources/bytecode/bytecode.cc | 2 +- preprocessor/DynamicModel.cc | 2 +- preprocessor/DynareMain.cc | 4 ++-- preprocessor/ModFile.cc | 2 +- preprocessor/StaticModel.cc | 2 +- 8 files changed, 11 insertions(+), 11 deletions(-) diff --git a/dynare++/kord/korder.cweb b/dynare++/kord/korder.cweb index ce5684143..a73360e38 100644 --- a/dynare++/kord/korder.cweb +++ b/dynare++/kord/korder.cweb @@ -159,9 +159,9 @@ KOrder::KOrder(int num_stat, int num_pred, int num_both, int num_forw, KORD_RAISE_IF(gy.nrows() != ypart.ny(), "Wrong number of rows in gy in KOrder constructor"); KORD_RAISE_IF(gu.nrows() != ypart.ny(), - "Wrong number of rows in gu in KOrder constuctor"); + "Wrong number of rows in gu in KOrder constructor"); KORD_RAISE_IF(gu.ncols() != nu, - "Wrong number of columns in gu in KOrder constuctor"); + "Wrong number of columns in gu in KOrder constructor"); // set nvs: nvs[0] = ypart.nys(); nvs[1] = nu; nvs[2] = nu; nvs[3] = 1; diff --git a/dynare++/kord/korder_stoch.hweb b/dynare++/kord/korder_stoch.hweb index 83d7cd6f4..0587c9a3a 100644 --- a/dynare++/kord/korder_stoch.hweb +++ b/dynare++/kord/korder_stoch.hweb @@ -64,7 +64,7 @@ public:@; @<|IntegDerivs| constructor code@>; }; -@ This constuctor integrates a rule (namely its $g^{**}$ part) with +@ This constructor integrates a rule (namely its $g^{**}$ part) with respect to $u=\tilde\sigma\eta$, and stores to the object the derivatives of this integral $h$ at $(y^*,u,\sigma)=(\tilde y^*,0,\tilde\sigma)$. The original container of $g^{**}$, the moments of diff --git a/mex/sources/bytecode/SparseMatrix.cc b/mex/sources/bytecode/SparseMatrix.cc index 7db7341cb..1ef1239a6 100644 --- a/mex/sources/bytecode/SparseMatrix.cc +++ b/mex/sources/bytecode/SparseMatrix.cc @@ -6708,7 +6708,7 @@ dynSparseMatrix::Simulate_Newton_Two_Boundaries(int blck, int y_size, int y_kmin { if (restart > 2) { - mexPrintf("Divergence or slowdown occured during simulation.\nIn the next iteration, pivoting method will be applied to all periods.\n"); + mexPrintf("Divergence or slowdown occurred during simulation.\nIn the next iteration, pivoting method will be applied to all periods.\n"); symbolic = false; alt_symbolic = true; markowitz_c_s = markowitz_c; @@ -6716,7 +6716,7 @@ dynSparseMatrix::Simulate_Newton_Two_Boundaries(int blck, int y_size, int y_kmin } else { - mexPrintf("Divergence or slowdown occured during simulation.\nIn the next iteration, pivoting method will be applied for a longer period.\n"); + mexPrintf("Divergence or slowdown occurred during simulation.\nIn the next iteration, pivoting method will be applied for a longer period.\n"); start_compare = min(tbreak_g, periods); restart++; } diff --git a/mex/sources/bytecode/bytecode.cc b/mex/sources/bytecode/bytecode.cc index 80ba1b450..2bac3e3f2 100644 --- a/mex/sources/bytecode/bytecode.cc +++ b/mex/sources/bytecode/bytecode.cc @@ -773,7 +773,7 @@ main(int nrhs, const char *prhs[]) for (vector::iterator it = splan.begin(); it != splan.end(); it++) { mexPrintf("----------------------------------------------------------------------------------------------------\n"); - mexPrintf("suprise #%d\n", i+1); + mexPrintf("surprise #%d\n", i+1); if (it->exo.length()) mexPrintf(" plan fliping var=%s (%d) exo=%s (%d) for the following periods and with the following values:\n", it->var.c_str(), it->var_num, it->exo.c_str(), it->exo_num); else diff --git a/preprocessor/DynamicModel.cc b/preprocessor/DynamicModel.cc index 8d3ca37da..e935e1cc5 100644 --- a/preprocessor/DynamicModel.cc +++ b/preprocessor/DynamicModel.cc @@ -510,7 +510,7 @@ DynamicModel::writeModelEquationsOrdered_M(const string &dynamic_basename) const } else { - cerr << "Type missmatch for equation " << equation_ID+1 << "\n"; + cerr << "Type mismatch for equation " << equation_ID+1 << "\n"; exit(EXIT_FAILURE); } output << ";\n"; diff --git a/preprocessor/DynareMain.cc b/preprocessor/DynareMain.cc index 14d594c49..0230d7320 100644 --- a/preprocessor/DynareMain.cc +++ b/preprocessor/DynareMain.cc @@ -251,7 +251,7 @@ main(int argc, char **argv) { if (strlen(argv[arg]) <= 7 || argv[arg][6] != '=') { - cerr << "Incorrect syntax for ouput option" << endl; + cerr << "Incorrect syntax for output option" << endl; usage(); } if (strlen(argv[arg]) == 14 && !strncmp(argv[arg] + 7, "dynamic", 7)) @@ -264,7 +264,7 @@ main(int argc, char **argv) output_mode = third; else { - cerr << "Incorrect syntax for ouput option" << endl; + cerr << "Incorrect syntax for output option" << endl; usage(); } } diff --git a/preprocessor/ModFile.cc b/preprocessor/ModFile.cc index 397fee1bb..0ad63d2b3 100644 --- a/preprocessor/ModFile.cc +++ b/preprocessor/ModFile.cc @@ -232,7 +232,7 @@ ModFile::checkPass(bool nostrict) if (mod_file_struct.dsge_prior_weight_initialized && mod_file_struct.dsge_prior_weight_in_estimated_params) { - cerr << "ERROR: dsge_prior_weight cannot be both initalized and estimated." << endl; + cerr << "ERROR: dsge_prior_weight cannot be both initialized and estimated." << endl; exit(EXIT_FAILURE); } } diff --git a/preprocessor/StaticModel.cc b/preprocessor/StaticModel.cc index ecc50640d..5c18d1247 100644 --- a/preprocessor/StaticModel.cc +++ b/preprocessor/StaticModel.cc @@ -341,7 +341,7 @@ StaticModel::writeModelEquationsOrdered_M(const string &static_basename) const } else { - cerr << "Type missmatch for equation " << equation_ID+1 << "\n"; + cerr << "Type mismatch for equation " << equation_ID+1 << "\n"; exit(EXIT_FAILURE); } output << ";\n"; From ff68aa7229d52031be0d4e5d9ae68074b5e99a89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= Date: Wed, 28 Jun 2017 15:23:46 +0200 Subject: [PATCH 04/18] reporting: submodule update. --- matlab/modules/reporting | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/matlab/modules/reporting b/matlab/modules/reporting index eb996550e..dfa40f0b7 160000 --- a/matlab/modules/reporting +++ b/matlab/modules/reporting @@ -1 +1 @@ -Subproject commit eb996550e0aafe5c43a0eb96a017680d77d1b5ee +Subproject commit dfa40f0b7506cfdee02c69c33eeb26180a22e76f From 684861ce8760b1004bfe04c6eaa958758ca385f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Charybdis=29?= Date: Wed, 28 Jun 2017 15:34:59 +0200 Subject: [PATCH 05/18] Fixed typos. --- doc/dynare.texi | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/doc/dynare.texi b/doc/dynare.texi index 4ac0d84df..e8f02554e 100644 --- a/doc/dynare.texi +++ b/doc/dynare.texi @@ -846,16 +846,16 @@ Suppresses all warnings. @item json=parse|transform|compute Causes the preprocessor to output a version of the @file{.mod} file in JSON format. If @code{parse} is passed, the output will be written after the parsing -of the @file{.mod} file to a file called @file{@var{FILENAME}.mod}. If +of the @file{.mod} file to a file called @file{@var{FILENAME}.json}. If @code{transform} is passed, the JSON output of the transformed model (maximum lead of 1, minimum lag of -1, expectation operators substituted, etc.) will be -written to a file called @file{@var{FILENAME}.mod} and the original, -untransformed model will be written in @file{@var{FILENAME}_original.mod}. And +written to a file called @file{@var{FILENAME}.json} and the original, +untransformed model will be written in @file{@var{FILENAME}_original.json}. And if @code{compute} is passed, the output is written after the computing pass. In -this case, the transformed model is written to @file{@var{FILENAME}.mod}, the -original model is written to @file{@var{FILENAME}_original.mod}, and the -dynamic and static files are written to @file{@var{FILENAME}_dynamic.mod} and -@file{@var{FILENAME}_static.mod}. +this case, the transformed model is written to @file{@var{FILENAME}.json}, the +original model is written to @file{@var{FILENAME}_original.json}, and the +dynamic and static files are written to @file{@var{FILENAME}_dynamic.json} and +@file{@var{FILENAME}_static.json}. @item jsonstdout Instead of writing output requested by @ref{json} to files, write to standard @@ -866,9 +866,9 @@ Quit processing once the output requested by @ref{json} has been written. @item jsonprintderivdetail In addition to the output provided when @code{compute} is passed to @ref{json}, -create two files, @file{@var{FILENAME}_dynamic_details.mod} and -@file{@var{FILENAME}_static_details.mod}. The difference between these files -and their @file{_dynamic.mod} and @file{_static.mod} counterparts is that these +create two files, @file{@var{FILENAME}_dynamic_details.json} and +@file{@var{FILENAME}_static_details.json}. The difference between these files +and their @file{_dynamic.json} and @file{_static.json} counterparts is that these files provide information about which variable(s) and equation the derivative corresponds to. From 74ed99c6cac1df5456f197cea88ca054353c59f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= Date: Wed, 28 Jun 2017 15:48:28 +0200 Subject: [PATCH 06/18] ms-sbvar/switch_dw: update submodule. --- contrib/ms-sbvar/switch_dw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/ms-sbvar/switch_dw b/contrib/ms-sbvar/switch_dw index 8b3d14040..824a85ee9 160000 --- a/contrib/ms-sbvar/switch_dw +++ b/contrib/ms-sbvar/switch_dw @@ -1 +1 @@ -Subproject commit 8b3d14040133ea5b622cde9ea79b3b0b41891bce +Subproject commit 824a85ee962810157f815dcea04f516219814649 From 2007ceea454f3f5cc6d9c47cd4e4f350c743a025 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Charybdis=29?= Date: Wed, 28 Jun 2017 15:44:09 +0200 Subject: [PATCH 07/18] Cosmetic change. A "lag"" key with a negative value should be interpreted as a lead (and not a lag). Possible solutions are (1) Change the sign of the value, (2) Add a new key "lead" and consider only positive values, and (3) Change the key name for "shift" with negative values for lags and positive values for leads. The commit implements the third choice. --- preprocessor/DynamicModel.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/preprocessor/DynamicModel.cc b/preprocessor/DynamicModel.cc index e935e1cc5..a4f81a0c4 100644 --- a/preprocessor/DynamicModel.cc +++ b/preprocessor/DynamicModel.cc @@ -5590,7 +5590,7 @@ DynamicModel::writeJsonComputingPassOutput(ostream &output, bool writeDetails) c if (writeDetails) jacobian_output << "{\"eq\": " << eq + 1 << ", \"var\": \"" << symbol_table.getName(getSymbIDByDerivID(var)) << "\"" - << ", \"lag\": " << getLagByDerivID(var); + << ", \"shift\": " << getLagByDerivID(var); else jacobian_output << "{\"row\": " << eq + 1; jacobian_output << ", \"col\": " << col + 1 @@ -5627,9 +5627,9 @@ DynamicModel::writeJsonComputingPassOutput(ostream &output, bool writeDetails) c if (writeDetails) hessian_output << "{\"eq\": " << eq + 1 << ", \"var1\": \"" << symbol_table.getName(getSymbIDByDerivID(var1)) << "\"" - << ", \"lag1\": " << getLagByDerivID(var1) + << ", \"shift1\": " << getLagByDerivID(var1) << ", \"var2\": \"" << symbol_table.getName(getSymbIDByDerivID(var2)) << "\"" - << ", \"lag2\": " << getLagByDerivID(var2); + << ", \"shift2\": " << getLagByDerivID(var2); else hessian_output << "{\"row\": " << eq + 1; @@ -5667,11 +5667,11 @@ DynamicModel::writeJsonComputingPassOutput(ostream &output, bool writeDetails) c if (writeDetails) third_derivatives_output << "{\"eq\": " << eq + 1 << ", \"var1\": \"" << symbol_table.getName(getSymbIDByDerivID(var1)) << "\"" - << ", \"lag1\": " << getLagByDerivID(var1) + << ", \"shift1\": " << getLagByDerivID(var1) << ", \"var2\": \"" << symbol_table.getName(getSymbIDByDerivID(var2)) << "\"" - << ", \"lag2\": " << getLagByDerivID(var2) + << ", \"shift2\": " << getLagByDerivID(var2) << ", \"var3\": \"" << symbol_table.getName(getSymbIDByDerivID(var3)) << "\"" - << ", \"lag3\": " << getLagByDerivID(var3); + << ", \"shift3\": " << getLagByDerivID(var3); else third_derivatives_output << "{\"row\": " << eq + 1; From 45ea2e477a156b9729da842b437dc9c6a33442d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= Date: Wed, 28 Jun 2017 15:58:58 +0200 Subject: [PATCH 08/18] Add julia preprocessor to the clean rule. --- preprocessor/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/preprocessor/Makefile.am b/preprocessor/Makefile.am index 892b2b178..5a8ac507e 100644 --- a/preprocessor/Makefile.am +++ b/preprocessor/Makefile.am @@ -86,7 +86,7 @@ html-local: endif clean-local: - rm -rf ../matlab/preprocessor* + rm -rf ../matlab/preprocessor* ../julia/preprocessor* rm -rf doc/html/ EXTRA_DIST = $(BUILT_SOURCES) Doxyfile From b81e0cd91e02a0320d45897e4d0110b7340fe801 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Charybdis=29?= Date: Wed, 28 Jun 2017 16:03:46 +0200 Subject: [PATCH 09/18] Added json file in the clean rule. --- tests/Makefile.am | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/Makefile.am b/tests/Makefile.am index a4e8ab876..9474d3949 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -998,3 +998,4 @@ clean-local: find . -name "*.aux" -type f -delete find . -name "*.log" -type f -delete find . -name "*.eps" -type f -delete + find . -name "*.json" -type f -delete From a48fbee19ecd8982e4b27dd478867516f851d75c Mon Sep 17 00:00:00 2001 From: Houtan Bastani Date: Wed, 28 Jun 2017 17:11:24 +0200 Subject: [PATCH 10/18] preprocessor: write certain variables from M_ to JSON output --- preprocessor/DynamicModel.cc | 70 ++++++++++++++++++++++++++++++++++++ preprocessor/DynamicModel.hh | 3 ++ preprocessor/ModFile.cc | 12 +++++-- preprocessor/ModFile.hh | 2 +- 4 files changed, 83 insertions(+), 4 deletions(-) diff --git a/preprocessor/DynamicModel.cc b/preprocessor/DynamicModel.cc index a4f81a0c4..f072fd959 100644 --- a/preprocessor/DynamicModel.cc +++ b/preprocessor/DynamicModel.cc @@ -5544,6 +5544,76 @@ DynamicModel::writeJsonOriginalModelOutput(ostream &output) const writeJsonModelEquations(output, false); } +void +DynamicModel::writeJsonDynamicModelInfo(ostream &output) const +{ + output << "\"model_info\": {" + << "\"lead_lag_incidence\": ["; + // Loop on endogenous variables + int nstatic = 0, + nfwrd = 0, + npred = 0, + nboth = 0; + for (int endoID = 0; endoID < symbol_table.endo_nbr(); endoID++) + { + if (endoID != 0) + output << ","; + output << "["; + int sstatic = 1, + sfwrd = 0, + spred = 0, + sboth = 0; + // Loop on periods + for (int lag = -max_endo_lag; lag <= max_endo_lead; lag++) + { + // Print variableID if exists with current period, otherwise print 0 + try + { + if (lag != -max_endo_lag) + output << ","; + int varID = getDerivID(symbol_table.getID(eEndogenous, endoID), lag); + output << " " << getDynJacobianCol(varID) + 1; + if (lag == -1) + { + sstatic = 0; + spred = 1; + } + else if (lag == 1) + { + if (spred == 1) + { + sboth = 1; + spred = 0; + } + else + { + sstatic = 0; + sfwrd = 1; + } + } + } + catch (UnknownDerivIDException &e) + { + output << " 0"; + } + } + nstatic += sstatic; + nfwrd += sfwrd; + npred += spred; + nboth += sboth; + output << "]"; + } + output << "], " + << "\"nstatic\": " << nstatic << ", " + << "\"nfwrd\": " << nfwrd << ", " + << "\"npred\": " << npred << ", " + << "\"nboth\": " << nboth << ", " + << "\"nsfwrd\": " << nfwrd+nboth << ", " + << "\"nspred\": " << npred+nboth << ", " + << "\"ndynamic\": " << npred+nboth+nfwrd << endl; + output << "}"; +} + void DynamicModel::writeJsonComputingPassOutput(ostream &output, bool writeDetails) const { diff --git a/preprocessor/DynamicModel.hh b/preprocessor/DynamicModel.hh index b0ebd7fa5..1fb14bc20 100644 --- a/preprocessor/DynamicModel.hh +++ b/preprocessor/DynamicModel.hh @@ -242,6 +242,9 @@ public: //! Write JSON Output representation of original dynamic model void writeJsonOriginalModelOutput(ostream &output) const; + //! Write JSON Output representation of model info (useful stuff from M_) + void writeJsonDynamicModelInfo(ostream &output) const; + //! Write JSON Output representation of dynamic model after computing pass void writeJsonComputingPassOutput(ostream &output, bool writeDetails) const; diff --git a/preprocessor/ModFile.cc b/preprocessor/ModFile.cc index 0ad63d2b3..ba7a38c74 100644 --- a/preprocessor/ModFile.cc +++ b/preprocessor/ModFile.cc @@ -1270,7 +1270,7 @@ ModFile::writeJsonOutput(const string &basename, JsonOutputPointType json, JsonF if (json == parsing || json == checkpass) symbol_table.freeze(); - writeJsonOutputParsingCheck(basename, json_output_mode, json == transformpass); + writeJsonOutputParsingCheck(basename, json_output_mode, json == transformpass, json == computingpass); if (json == parsing || json == checkpass) symbol_table.unfreeze(); @@ -1302,7 +1302,7 @@ ModFile::writeJsonOutput(const string &basename, JsonOutputPointType json, JsonF } void -ModFile::writeJsonOutputParsingCheck(const string &basename, JsonFileOutputType json_output_mode, bool transformpass) const +ModFile::writeJsonOutputParsingCheck(const string &basename, JsonFileOutputType json_output_mode, bool transformpass, bool computingpass) const { ostringstream output; output << "{" << endl; @@ -1323,6 +1323,12 @@ ModFile::writeJsonOutputParsingCheck(const string &basename, JsonFileOutputType } output << "]" << endl; } + + if (computingpass) + { + output << ","; + dynamic_model.writeJsonDynamicModelInfo(output); + } output << "}" << endl; ostringstream original_model_output; @@ -1338,7 +1344,7 @@ ModFile::writeJsonOutputParsingCheck(const string &basename, JsonFileOutputType { cout << output.str(); if (!original_model_output.str().empty()) - cout << original_model_output.str(); + cout << "," << original_model_output.str(); } else { diff --git a/preprocessor/ModFile.hh b/preprocessor/ModFile.hh index 1b763f636..985a15a79 100644 --- a/preprocessor/ModFile.hh +++ b/preprocessor/ModFile.hh @@ -118,7 +118,7 @@ private: //! Warnings Encountered WarningConsolidation &warnings; //! Functions used in writing of JSON outut. See writeJsonOutput - void writeJsonOutputParsingCheck(const string &basename, JsonFileOutputType json_output_mode, bool transformpass) const; + void writeJsonOutputParsingCheck(const string &basename, JsonFileOutputType json_output_mode, bool transformpass, bool computingpass) const; void writeJsonComputingPassOutput(const string &basename, JsonFileOutputType json_output_mode, bool jsonprintderivdetail) const; void writeJsonFileHelper(string &fname, ostringstream &output) const; public: From 1270f1243961487693882af81e7a394e47fee9ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= Date: Wed, 28 Jun 2017 16:55:56 +0200 Subject: [PATCH 11/18] Drop texi2html requirement (obsolete software), use texi2any instead. --- README.md | 6 +++--- configure.ac | 7 ++----- doc/Makefile.am | 5 +---- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 0a19dc997..9d8ce9ff0 100644 --- a/README.md +++ b/README.md @@ -81,7 +81,7 @@ A number of tools and libraries are needed in order to recompile everything. You - [Beamer](http://latex-beamer.sourceforge.net/) (for some PDF presentations) - For building the reference manual: - [GNU Texinfo](http://www.gnu.org/software/texinfo/) - - [Texi2HTML](http://www.nongnu.org/texi2html) and [Latex2HTML](http://www.latex2html.org), if you want nice mathematical formulas in HTML output + - [Latex2HTML](http://www.latex2html.org), if you want nice mathematical formulas in HTML output - [Doxygen](http://www.stack.nl/%7Edimitri/doxygen/) (if you want to build Dynare preprocessor source documentation) - For Octave, the development libraries corresponding to the UMFPACK packaged with Octave @@ -237,7 +237,7 @@ Alternatively, if you want to build everything, manually install the following p - `texlive-fonts-extra` (for ccicons) - `latex-beamer` - `texinfo` -- `texi2html`, `latex2html` +- `latex2html` - `doxygen` ## Fedora @@ -253,7 +253,7 @@ Alternatively, if you want to build everything, manually install the following p - `automake` - `texlive` - `texinfo` -- `texi2html`, `latex2html` +- `latex2html` - `doxygen` ## Windows diff --git a/configure.ac b/configure.ac index 4ddf92682..afed6de63 100755 --- a/configure.ac +++ b/configure.ac @@ -117,9 +117,6 @@ AM_CONDITIONAL([HAVE_PDFLATEX], [test "x$PDFLATEX" != "x"]) AC_CHECK_PROG([BIBTEX], [bibtex], [bibtex]) AM_CONDITIONAL([HAVE_BIBTEX], [test "x$BIBTEX" != "x"]) -AC_CHECK_PROG([TEXI2HTML], [texi2html], [texi2html]) -AM_CONDITIONAL([HAVE_TEXI2HTML], [test "x$TEXI2HTML" != "x"]) - AC_CHECK_PROG([LATEX2HTML], [latex2html], [latex2html]) AM_CONDITIONAL([HAVE_LATEX2HTML], [test "x$LATEX2HTML" != "x"]) @@ -282,10 +279,10 @@ fi if test "x$MAKEINFO" != "x"; then BUILD_DYNARE_INFO="yes" - if test "x$TEXI2HTML" != "x" -a "x$LATEX2HTML" != "x"; then + if test "x$LATEX2HTML" != "x"; then BUILD_DYNARE_HTML_MANUAL="yes" else - BUILD_DYNARE_HTML_MANUAL="yes (but with ugly math formulas, missing texi2html or latex2html)" + BUILD_DYNARE_HTML_MANUAL="yes (but with ugly math formulas, missing latex2html)" fi BUILD_DYNARE_PDF_MANUAL="yes" else diff --git a/doc/Makefile.am b/doc/Makefile.am index 6eb8fdcc2..ce992bca2 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -2,15 +2,12 @@ SUBDIRS = preprocessor macroprocessor userguide parallel internals gsa dseries-a info_TEXINFOS = dynare.texi -if HAVE_TEXI2HTML if HAVE_LATEX2HTML html-local: dynare.html dynare.html: dynare.texi rm -rf dynare.html - mkdir -p dynare.html - cd dynare.html && $(TEXI2HTML) --l2h --split section --prefix index ../dynare.texi -endif + texi2any --html --split=section -c L2H=1 -c PREFIX=dynare.html dynare.texi endif PDF_TARGETS = From a779a6440220f46631ad4be904475fec6ceb0513 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= Date: Wed, 28 Jun 2017 17:22:39 +0200 Subject: [PATCH 12/18] Update list of build-dependencies on Debian. --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 9d8ce9ff0..67a9ae727 100644 --- a/README.md +++ b/README.md @@ -219,9 +219,9 @@ Alternatively, if you want to build everything, manually install the following p - `build-essential` (for gcc, g++ and make) - `gfortran` -- `liboctave-dev` or `octave3.2-headers` (will install ATLAS) +- `liboctave-dev` (or `octave3.2-headers` on older systems) - `libboost-graph-dev` -- `libgsl0-dev` +- `libgsl-dev` (or `libgsl0-dev` on older systems) - `libmatio-dev` - `libslicot-dev` and `libslicot-pic` - `libsuitesparse-dev` @@ -235,7 +235,8 @@ Alternatively, if you want to build everything, manually install the following p - `texlive-formats-extra` (for Eplain) - `texlive-latex-extra` (for fullpage.sty) - `texlive-fonts-extra` (for ccicons) -- `latex-beamer` +- `texlive-latex-recommended` (or `latex-beamer` on older systems) +- `texlive-science` (or `texlive-math-extra` on older systems) (for amstex) - `texinfo` - `latex2html` - `doxygen` From 5feea2fc72b7cdd1738b004a8b7fa90088e9aa2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= Date: Wed, 28 Jun 2017 18:19:10 +0200 Subject: [PATCH 13/18] Update macro-processor slides (new @#include variant). --- doc/macroprocessor/macroprocessor.tex | 66 +++++++++++++++------------ 1 file changed, 38 insertions(+), 28 deletions(-) diff --git a/doc/macroprocessor/macroprocessor.tex b/doc/macroprocessor/macroprocessor.tex index ef419c0b3..552779af2 100644 --- a/doc/macroprocessor/macroprocessor.tex +++ b/doc/macroprocessor/macroprocessor.tex @@ -8,12 +8,11 @@ \usetheme{Boadilla} \title{The Dynare Macro-processor} -\subtitle{Dynare Summer School 2015} +\subtitle{Dynare Summer School 2017} \author{Sébastien Villemot} %\pgfdeclareimage[height=0.6cm]{logo}{logo-ofce} -%\institute[OFCE]{\pgfuseimage{logo}} \institute{OFCE} -\date{June 9, 2015} +\date{June 13, 2017} \AtBeginSection[] { @@ -91,30 +90,6 @@ \end{itemize} \end{frame} -\begin{frame}[fragile=singleslide] - \frametitle{Inclusion directive} - \begin{itemize} - \item This directive simply includes the content of another file at the place where it is inserted. - \begin{block}{Syntax} - \verb+@#include "+\textit{filename}\verb+"+ - \end{block} - \begin{block}{Example} -\begin{verbatim} -@#include "modelcomponent.mod" -\end{verbatim} - \end{block} - \item Exactly equivalent to a copy/paste of the content of the included file - \item Note that it is possible to nest includes (\textit{i.e.} to include a file from an included file) - \item Since Dynare 4.5, the filename can be given by a macro-variable (see below). - Useful in loops. - \begin{block}{Example with variable} -\begin{verbatim} -@#define fname = "modelcomponent.mod" -@#include fname -\end{verbatim} - \end{block} - \end{itemize} -\end{frame} \begin{frame} \frametitle{Variables} @@ -219,6 +194,41 @@ end; \end{block} \end{frame} +\begin{frame}[fragile=singleslide] + \frametitle{Inclusion directive (1/2)} + \begin{itemize} + \item This directive simply includes the content of another file at the place where it is inserted. + \begin{block}{Syntax} + \verb+@#include "+\textit{filename}\verb+"+ + \end{block} + \begin{block}{Example} +\begin{verbatim} +@#include "modelcomponent.mod" +\end{verbatim} + \end{block} + \item Exactly equivalent to a copy/paste of the content of the included file + \item Note that it is possible to nest includes (\textit{i.e.} to include a + file from an included file) + \end{itemize} +\end{frame} + +\begin{frame}[fragile=singleslide] + \frametitle{Inclusion directive (2/2)} + \begin{itemize} +\item The filename can be given by a macro-variable (useful in loops): + \begin{block}{Example with variable} +\begin{verbatim} +@#define fname = "modelcomponent.mod" +@#include fname +\end{verbatim} + \end{block} + \item Files to include are searched for in current directory. Other directories can + be added with + \texttt{@includepath} directive, \texttt{-I} command line option or + \texttt{[paths]} section in config file. + \end{itemize} +\end{frame} + \begin{frame}[fragile=singleslide] \frametitle{Loop directive} \begin{block}{Syntax} @@ -604,7 +614,7 @@ rhos = [ 0.8, 0.9, 1]; \ccbysa \column{0.71\textwidth} \tiny - Copyright © 2008--2015 Dynare Team \\ + Copyright © 2008--2017 Dynare Team \\ Licence: \href{http://creativecommons.org/licenses/by-sa/4.0/}{Creative Commons Attribution-ShareAlike 4.0} \end{columns} From 28505f84f154b1c048bb2b6be27ceafeef095e23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= Date: Thu, 29 Jun 2017 12:01:24 +0200 Subject: [PATCH 14/18] Add lmodern to Debian build-dependencies. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 67a9ae727..2780c0315 100644 --- a/README.md +++ b/README.md @@ -238,6 +238,7 @@ Alternatively, if you want to build everything, manually install the following p - `texlive-latex-recommended` (or `latex-beamer` on older systems) - `texlive-science` (or `texlive-math-extra` on older systems) (for amstex) - `texinfo` +- `lmodern` (for macroprocessor PDF) - `latex2html` - `doxygen` From f1ed349d6b748a77241fa5004b16634328c43151 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= Date: Thu, 29 Jun 2017 12:32:21 +0200 Subject: [PATCH 15/18] Enfore standard tmp directory when calling latex2html. --- doc/Makefile.am | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/Makefile.am b/doc/Makefile.am index ce992bca2..99bd82d70 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -5,9 +5,11 @@ info_TEXINFOS = dynare.texi if HAVE_LATEX2HTML html-local: dynare.html +# The temporary directory for latex2html (L2H_TMP) must not contain a dot, so +# enforce standard tmp directory instead of defaulting to current directory dynare.html: dynare.texi rm -rf dynare.html - texi2any --html --split=section -c L2H=1 -c PREFIX=dynare.html dynare.texi + texi2any --html --split=section -c L2H=1 -c L2H_TMP=$${TMPDIR:-/tmp} -c PREFIX=dynare.html dynare.texi endif PDF_TARGETS = From 9a13adb1119b7133947893418848d1641eab2d5d Mon Sep 17 00:00:00 2001 From: Houtan Bastani Date: Thu, 29 Jun 2017 12:42:28 +0200 Subject: [PATCH 16/18] preprocessor: print JSON deriv detail by default; use option to print less-detailed versions of dynamic/static models --- doc/dynare.texi | 11 +-- preprocessor/DynamicModel.cc | 141 +++++++++++++++++++++-------------- preprocessor/DynareMain.cc | 12 +-- preprocessor/DynareMain2.cc | 4 +- preprocessor/ModFile.cc | 82 ++++++++++---------- preprocessor/ModFile.hh | 4 +- preprocessor/StaticModel.cc | 110 +++++++++++++++++---------- 7 files changed, 209 insertions(+), 155 deletions(-) diff --git a/doc/dynare.texi b/doc/dynare.texi index e8f02554e..0237713ce 100644 --- a/doc/dynare.texi +++ b/doc/dynare.texi @@ -864,13 +864,10 @@ out. @item onlyjson Quit processing once the output requested by @ref{json} has been written. -@item jsonprintderivdetail -In addition to the output provided when @code{compute} is passed to @ref{json}, -create two files, @file{@var{FILENAME}_dynamic_details.json} and -@file{@var{FILENAME}_static_details.json}. The difference between these files -and their @file{_dynamic.json} and @file{_static.json} counterparts is that these -files provide information about which variable(s) and equation the derivative -corresponds to. +@item jsonderivsimple +Print a simplified version of the static and dynamic files in +@file{@var{FILENAME}_static_simple.json} and +@file{@var{FILENAME}_dynamic_simple.json}. @item warn_uninit Display a warning for each variable or parameter which is not diff --git a/preprocessor/DynamicModel.cc b/preprocessor/DynamicModel.cc index f072fd959..e827d58ce 100644 --- a/preprocessor/DynamicModel.cc +++ b/preprocessor/DynamicModel.cc @@ -5658,13 +5658,17 @@ DynamicModel::writeJsonComputingPassOutput(ostream &output, bool writeDetails) c expr_t d1 = it->second; if (writeDetails) - jacobian_output << "{\"eq\": " << eq + 1 - << ", \"var\": \"" << symbol_table.getName(getSymbIDByDerivID(var)) << "\"" - << ", \"shift\": " << getLagByDerivID(var); + jacobian_output << "{\"eq\": " << eq + 1; else jacobian_output << "{\"row\": " << eq + 1; - jacobian_output << ", \"col\": " << col + 1 - << ", \"val\": \""; + + jacobian_output << ", \"col\": " << col + 1; + + if (writeDetails) + jacobian_output << ", \"var\": \"" << symbol_table.getName(getSymbIDByDerivID(var)) << "\"" + << ", \"shift\": " << getLagByDerivID(var); + + jacobian_output << ", \"val\": \""; d1->writeJsonOutput(jacobian_output, temp_term_union, tef_terms); jacobian_output << "\"}" << endl; } @@ -5695,19 +5699,22 @@ DynamicModel::writeJsonComputingPassOutput(ostream &output, bool writeDetails) c int col_nb_sym = id2 * dynJacobianColsNbr + id1; if (writeDetails) - hessian_output << "{\"eq\": " << eq + 1 - << ", \"var1\": \"" << symbol_table.getName(getSymbIDByDerivID(var1)) << "\"" - << ", \"shift1\": " << getLagByDerivID(var1) - << ", \"var2\": \"" << symbol_table.getName(getSymbIDByDerivID(var2)) << "\"" - << ", \"shift2\": " << getLagByDerivID(var2); + hessian_output << "{\"eq\": " << eq + 1; else hessian_output << "{\"row\": " << eq + 1; hessian_output << ", \"col\": [" << col_nb + 1; if (id1 != id2) hessian_output << ", " << col_nb_sym + 1; - hessian_output << "]" - << ", \"val\": \""; + hessian_output << "]"; + + if (writeDetails) + hessian_output << ", \"var1\": \"" << symbol_table.getName(getSymbIDByDerivID(var1)) << "\"" + << ", \"shift1\": " << getLagByDerivID(var1) + << ", \"var2\": \"" << symbol_table.getName(getSymbIDByDerivID(var2)) << "\"" + << ", \"shift2\": " << getLagByDerivID(var2); + + hessian_output << ", \"val\": \""; d2->writeJsonOutput(hessian_output, temp_term_union, tef_terms); hessian_output << "\"}" << endl; } @@ -5735,13 +5742,7 @@ DynamicModel::writeJsonComputingPassOutput(ostream &output, bool writeDetails) c expr_t d3 = it->second; if (writeDetails) - third_derivatives_output << "{\"eq\": " << eq + 1 - << ", \"var1\": \"" << symbol_table.getName(getSymbIDByDerivID(var1)) << "\"" - << ", \"shift1\": " << getLagByDerivID(var1) - << ", \"var2\": \"" << symbol_table.getName(getSymbIDByDerivID(var2)) << "\"" - << ", \"shift2\": " << getLagByDerivID(var2) - << ", \"var3\": \"" << symbol_table.getName(getSymbIDByDerivID(var3)) << "\"" - << ", \"shift3\": " << getLagByDerivID(var3); + third_derivatives_output << "{\"eq\": " << eq + 1; else third_derivatives_output << "{\"row\": " << eq + 1; @@ -5763,17 +5764,26 @@ DynamicModel::writeJsonComputingPassOutput(ostream &output, bool writeDetails) c third_derivatives_output << ", "; third_derivatives_output << *it2 + 1; } - third_derivatives_output << "]" - << ", \"val\": \""; + third_derivatives_output << "]"; + + if (writeDetails) + third_derivatives_output << ", \"var1\": \"" << symbol_table.getName(getSymbIDByDerivID(var1)) << "\"" + << ", \"shift1\": " << getLagByDerivID(var1) + << ", \"var2\": \"" << symbol_table.getName(getSymbIDByDerivID(var2)) << "\"" + << ", \"shift2\": " << getLagByDerivID(var2) + << ", \"var3\": \"" << symbol_table.getName(getSymbIDByDerivID(var3)) << "\"" + << ", \"shift3\": " << getLagByDerivID(var3); + + third_derivatives_output << ", \"val\": \""; d3->writeJsonOutput(third_derivatives_output, temp_term_union, tef_terms); third_derivatives_output << "\"}" << endl; } third_derivatives_output << "]}"; if (writeDetails) - output << "\"dynamic_model_derivative_details\": {"; + output << "\"dynamic_model\": {"; else - output << "\"dynamic_model_derivatives\": {"; + output << "\"dynamic_model_simple\": {"; output << model_local_vars_output.str() << ", " << model_output.str() << ", " << jacobian_output.str() @@ -5823,12 +5833,16 @@ DynamicModel::writeJsonParamsDerivativesFile(ostream &output, bool writeDetails) int param_col = symbol_table.getTypeSpecificID(getSymbIDByDerivID(param)) + 1; if (writeDetails) - jacobian_output << "{\"eq\": " << eq + 1 - << ", \"param\": \"" << symbol_table.getName(getSymbIDByDerivID(param)) << "\""; + jacobian_output << "{\"eq\": " << eq + 1; else jacobian_output << "{\"row\": " << eq + 1; - jacobian_output << ", \"param_col\": " << param_col + 1 - << ", \"val\": \""; + + jacobian_output << ", \"param_col\": " << param_col + 1; + + if (writeDetails) + jacobian_output << ", \"param\": \"" << symbol_table.getName(getSymbIDByDerivID(param)) << "\""; + + jacobian_output << ", \"val\": \""; d1->writeJsonOutput(jacobian_output, params_derivs_temporary_terms, tef_terms); jacobian_output << "\"}" << endl; } @@ -5853,15 +5867,19 @@ DynamicModel::writeJsonParamsDerivativesFile(ostream &output, bool writeDetails) int param_col = symbol_table.getTypeSpecificID(getSymbIDByDerivID(param)) + 1; if (writeDetails) - hessian_output << "{\"eq\": " << eq + 1 - << ", \"var\": \"" << symbol_table.getName(getSymbIDByDerivID(var)) << "\"" - << ", \"lag\": " << getLagByDerivID(var) - << ", \"param\": \"" << symbol_table.getName(getSymbIDByDerivID(param)) << "\""; + hessian_output << "{\"eq\": " << eq + 1; else hessian_output << "{\"row\": " << eq + 1; + hessian_output << ", \"var_col\": " << var_col + 1 - << ", \"param_col\": " << param_col + 1 - << ", \"val\": \""; + << ", \"param_col\": " << param_col + 1; + + if (writeDetails) + hessian_output << ", \"var\": \"" << symbol_table.getName(getSymbIDByDerivID(var)) << "\"" + << ", \"lag\": " << getLagByDerivID(var) + << ", \"param\": \"" << symbol_table.getName(getSymbIDByDerivID(param)) << "\""; + + hessian_output << ", \"val\": \""; d2->writeJsonOutput(hessian_output, params_derivs_temporary_terms, tef_terms); hessian_output << "\"}" << endl; } @@ -5887,14 +5905,17 @@ DynamicModel::writeJsonParamsDerivativesFile(ostream &output, bool writeDetails) int param2_col = symbol_table.getTypeSpecificID(getSymbIDByDerivID(param2)) + 1; if (writeDetails) - hessian1_output << "{\"eq\": " << eq + 1 - << ", \"param1\": \"" << symbol_table.getName(getSymbIDByDerivID(param1)) << "\"" - << ", \"param2\": \"" << symbol_table.getName(getSymbIDByDerivID(param2)) << "\""; + hessian1_output << "{\"eq\": " << eq + 1; else hessian1_output << "{\"row\": " << eq + 1; hessian1_output << ", \"param1_col\": " << param1_col + 1 - << ", \"param2_col\": " << param2_col + 1 - << ", \"val\": \""; + << ", \"param2_col\": " << param2_col + 1; + + if (writeDetails) + hessian1_output << ", \"param1\": \"" << symbol_table.getName(getSymbIDByDerivID(param1)) << "\"" + << ", \"param2\": \"" << symbol_table.getName(getSymbIDByDerivID(param2)) << "\""; + + hessian1_output << ", \"val\": \""; d2->writeJsonOutput(hessian1_output, params_derivs_temporary_terms, tef_terms); hessian1_output << "\"}" << endl; } @@ -5922,17 +5943,21 @@ DynamicModel::writeJsonParamsDerivativesFile(ostream &output, bool writeDetails) int param2_col = symbol_table.getTypeSpecificID(getSymbIDByDerivID(param2)) + 1; if (writeDetails) - third_derivs_output << "{\"eq\": " << eq + 1 - << ", \"var\": \"" << symbol_table.getName(var) << "\"" + third_derivs_output << "{\"eq\": " << eq + 1; + else + third_derivs_output << "{\"row\": " << eq + 1; + + third_derivs_output << ", \"var_col\": " << var_col + 1 + << ", \"param1_col\": " << param1_col + 1 + << ", \"param2_col\": " << param2_col + 1; + + if (writeDetails) + third_derivs_output << ", \"var\": \"" << symbol_table.getName(var) << "\"" << ", \"lag\": " << getLagByDerivID(var) << ", \"param1\": \"" << symbol_table.getName(getSymbIDByDerivID(param1)) << "\"" << ", \"param2\": \"" << symbol_table.getName(getSymbIDByDerivID(param2)) << "\""; - else - third_derivs_output << "{\"row\": " << eq + 1; - third_derivs_output << ", \"var_col\": " << var_col + 1 - << ", \"param1_col\": " << param1_col + 1 - << ", \"param2_col\": " << param2_col + 1 - << ", \"val\": \""; + + third_derivs_output << ", \"val\": \""; d2->writeJsonOutput(third_derivs_output, params_derivs_temporary_terms, tef_terms); third_derivs_output << "\"}" << endl; } @@ -5961,27 +5986,31 @@ DynamicModel::writeJsonParamsDerivativesFile(ostream &output, bool writeDetails) int param_col = symbol_table.getTypeSpecificID(getSymbIDByDerivID(param)) + 1; if (writeDetails) - third_derivs1_output << "{\"eq\": " << eq + 1 - << ", \"var1\": \"" << symbol_table.getName(getSymbIDByDerivID(var1)) << "\"" + third_derivs1_output << "{\"eq\": " << eq + 1; + else + third_derivs1_output << "{\"row\": " << eq + 1; + + third_derivs1_output << ", \"var1_col\": " << var1_col + 1 + << ", \"var2_col\": " << var2_col + 1 + << ", \"param_col\": " << param_col + 1; + + if (writeDetails) + third_derivs1_output << ", \"var1\": \"" << symbol_table.getName(getSymbIDByDerivID(var1)) << "\"" << ", \"lag1\": " << getLagByDerivID(var1) << ", \"var2\": \"" << symbol_table.getName(getSymbIDByDerivID(var2)) << "\"" << ", \"lag2\": " << getLagByDerivID(var2) << ", \"param\": \"" << symbol_table.getName(getSymbIDByDerivID(param)) << "\""; - else - third_derivs1_output << "{\"row\": " << eq + 1; - third_derivs1_output << ", \"var1_col\": " << var1_col + 1 - << ", \"var2_col\": " << var2_col + 1 - << ", \"param_col\": " << param_col + 1 - << ", \"val\": \""; + + third_derivs1_output << ", \"val\": \""; d2->writeJsonOutput(third_derivs1_output, params_derivs_temporary_terms, tef_terms); third_derivs1_output << "\"}" << endl; } third_derivs1_output << "]}" << endl; if (writeDetails) - output << "\"dynamic_model_params_derivative_details\": {"; + output << "\"dynamic_model_params_derivative\": {"; else - output << "\"dynamic_model_params_derivatives\": {"; + output << "\"dynamic_model_params_derivatives_simple\": {"; output << model_local_vars_output.str() << ", " << model_output.str() << ", " << jacobian_output.str() diff --git a/preprocessor/DynareMain.cc b/preprocessor/DynareMain.cc index 0230d7320..49c260252 100644 --- a/preprocessor/DynareMain.cc +++ b/preprocessor/DynareMain.cc @@ -45,7 +45,7 @@ void main2(stringstream &in, string &basename, bool debug, bool clear_all, bool #if defined(_WIN32) || defined(__CYGWIN32__) || defined(__MINGW32__) , bool cygwin, bool msvc, bool mingw #endif - , JsonOutputPointType json, JsonFileOutputType json_output_mode, bool onlyjson, bool jsonprintderivdetail + , JsonOutputPointType json, JsonFileOutputType json_output_mode, bool onlyjson, bool jsonderivsimple ); void main1(char *modfile, string &basename, bool debug, bool save_macro, string &save_macro_file, @@ -62,7 +62,7 @@ usage() #if defined(_WIN32) || defined(__CYGWIN32__) || defined(__MINGW32__) << " [cygwin] [msvc] [mingw]" #endif - << "[json=parse|check|transform|compute] [jsonstdout] [onlyjson] [jsonprintderivdetail]" + << "[json=parse|check|transform|compute] [jsonstdout] [onlyjson] [jsonderivsimple]" << endl; exit(EXIT_FAILURE); } @@ -118,7 +118,7 @@ main(int argc, char **argv) JsonOutputPointType json = nojson; JsonFileOutputType json_output_mode = file; bool onlyjson = false; - bool jsonprintderivdetail = false; + bool jsonderivsimple = false; LanguageOutputType language = matlab; // Parse options @@ -301,8 +301,8 @@ main(int argc, char **argv) json_output_mode = standardout; else if (!strcmp(argv[arg], "onlyjson")) onlyjson = true; - else if (!strcmp(argv[arg], "jsonprintderivdetail")) - jsonprintderivdetail = true; + else if (!strcmp(argv[arg], "jsonderivsimple")) + jsonderivsimple = true; else if (strlen(argv[arg]) >= 4 && !strncmp(argv[arg], "json", 4)) { if (strlen(argv[arg]) <= 5 || argv[arg][4] != '=') @@ -370,7 +370,7 @@ main(int argc, char **argv) #if defined(_WIN32) || defined(__CYGWIN32__) || defined(__MINGW32__) , cygwin, msvc, mingw #endif - , json, json_output_mode, onlyjson, jsonprintderivdetail + , json, json_output_mode, onlyjson, jsonderivsimple ); return EXIT_SUCCESS; diff --git a/preprocessor/DynareMain2.cc b/preprocessor/DynareMain2.cc index 758b278fa..e0a9e5392 100644 --- a/preprocessor/DynareMain2.cc +++ b/preprocessor/DynareMain2.cc @@ -34,7 +34,7 @@ main2(stringstream &in, string &basename, bool debug, bool clear_all, bool clear #if defined(_WIN32) || defined(__CYGWIN32__) || defined(__MINGW32__) , bool cygwin, bool msvc, bool mingw #endif - , JsonOutputPointType json, JsonFileOutputType json_output_mode, bool onlyjson, bool jsonprintderivdetail + , JsonOutputPointType json, JsonFileOutputType json_output_mode, bool onlyjson, bool jsonderivsimple ) { ParsingDriver p(warnings, nostrict); @@ -60,7 +60,7 @@ main2(stringstream &in, string &basename, bool debug, bool clear_all, bool clear // Do computations mod_file->computingPass(no_tmp_terms, output_mode, params_derivs_order); if (json == computingpass) - mod_file->writeJsonOutput(basename, json, json_output_mode, onlyjson, jsonprintderivdetail); + mod_file->writeJsonOutput(basename, json, json_output_mode, onlyjson, jsonderivsimple); // Write outputs if (output_mode != none) diff --git a/preprocessor/ModFile.cc b/preprocessor/ModFile.cc index ba7a38c74..4098c8a26 100644 --- a/preprocessor/ModFile.cc +++ b/preprocessor/ModFile.cc @@ -1262,7 +1262,7 @@ ModFile::writeExternalFilesJulia(const string &basename, FileOutputType output) } void -ModFile::writeJsonOutput(const string &basename, JsonOutputPointType json, JsonFileOutputType json_output_mode, bool onlyjson, bool jsonprintderivdetail) +ModFile::writeJsonOutput(const string &basename, JsonOutputPointType json, JsonFileOutputType json_output_mode, bool onlyjson, bool jsonderivsimple) { if (json == nojson) return; @@ -1276,7 +1276,7 @@ ModFile::writeJsonOutput(const string &basename, JsonOutputPointType json, JsonF symbol_table.unfreeze(); if (json == computingpass) - writeJsonComputingPassOutput(basename, json_output_mode, jsonprintderivdetail); + writeJsonComputingPassOutput(basename, json_output_mode, jsonderivsimple); switch (json) { @@ -1396,16 +1396,16 @@ ModFile::writeJsonOutputParsingCheck(const string &basename, JsonFileOutputType } void -ModFile::writeJsonComputingPassOutput(const string &basename, JsonFileOutputType json_output_mode, bool jsonprintderivdetail) const +ModFile::writeJsonComputingPassOutput(const string &basename, JsonFileOutputType json_output_mode, bool jsonderivsimple) const { - ostringstream static_output, static_detail_output; + ostringstream static_output, static_simple_output; static_output << "{"; - static_model.writeJsonComputingPassOutput(static_output, false); + static_model.writeJsonComputingPassOutput(static_output, true); static_output << "}" << endl; - ostringstream dynamic_output, dynamic_detail_output; + ostringstream dynamic_output, dynamic_simple_output; dynamic_output << "{"; - dynamic_model.writeJsonComputingPassOutput(dynamic_output, false); + dynamic_model.writeJsonComputingPassOutput(dynamic_output, true); dynamic_output << "}" << endl; ostringstream original_model_output; @@ -1413,42 +1413,42 @@ ModFile::writeJsonComputingPassOutput(const string &basename, JsonFileOutputType original_model.writeJsonOriginalModelOutput(original_model_output); original_model_output << "}" << endl; - ostringstream tmp_out, static_paramsd_output, static_paramsd_detail_output; + ostringstream tmp_out, static_paramsd_output, static_paramsd_simple_output; tmp_out << ""; static_paramsd_output << ""; - static_paramsd_detail_output << ""; - static_model.writeJsonParamsDerivativesFile(tmp_out, false); + static_paramsd_simple_output << ""; + static_model.writeJsonParamsDerivativesFile(tmp_out, true); if (!tmp_out.str().empty()) static_paramsd_output << "{" << tmp_out.str() << "}" << endl; - ostringstream tmp1_out, dynamic_paramsd_output, dynamic_paramsd_detail_output; + ostringstream tmp1_out, dynamic_paramsd_output, dynamic_paramsd_simple_output; tmp1_out << ""; dynamic_paramsd_output << ""; - dynamic_paramsd_detail_output << ""; - dynamic_model.writeJsonParamsDerivativesFile(tmp1_out, false); + dynamic_paramsd_simple_output << ""; + dynamic_model.writeJsonParamsDerivativesFile(tmp1_out, true); if (!tmp1_out.str().empty()) dynamic_paramsd_output << "{" << tmp1_out.str() << "}" << endl; - if (jsonprintderivdetail) + if (jsonderivsimple) { - static_detail_output << "{"; - static_model.writeJsonComputingPassOutput(static_detail_output, true); - static_detail_output << "}"; + static_simple_output << "{"; + static_model.writeJsonComputingPassOutput(static_simple_output, false); + static_simple_output << "}"; - dynamic_detail_output << "{"; - dynamic_model.writeJsonComputingPassOutput(dynamic_detail_output, true); - dynamic_detail_output << "}"; + dynamic_simple_output << "{"; + dynamic_model.writeJsonComputingPassOutput(dynamic_simple_output, false); + dynamic_simple_output << "}"; ostringstream tmpd_out, tmpd1_out; tmpd_out << ""; tmpd1_out << ""; static_model.writeJsonParamsDerivativesFile(tmpd_out, true); if (!tmpd_out.str().empty()) - static_paramsd_detail_output << "{" << tmpd_out.str() << "}" << endl; + static_paramsd_simple_output << "{" << tmpd_out.str() << "}" << endl; dynamic_model.writeJsonParamsDerivativesFile(tmpd1_out, true); if (!tmpd1_out.str().empty()) - dynamic_paramsd_detail_output << "{" << tmpd1_out.str() << "}" << endl; + dynamic_paramsd_simple_output << "{" << tmpd1_out.str() << "}" << endl; } if (json_output_mode == standardout) @@ -1463,16 +1463,16 @@ ModFile::writeJsonComputingPassOutput(const string &basename, JsonFileOutputType if (!dynamic_paramsd_output.str().empty()) cout << dynamic_paramsd_output.str() << endl; - if (jsonprintderivdetail) + if (jsonderivsimple) { - cout << static_detail_output.str() << endl - << dynamic_detail_output.str() << endl; + cout << static_simple_output.str() << endl + << dynamic_simple_output.str() << endl; - if (!static_paramsd_detail_output.str().empty()) - cout << static_paramsd_detail_output.str() << endl; + if (!static_paramsd_simple_output.str().empty()) + cout << static_paramsd_simple_output.str() << endl; - if (!dynamic_paramsd_detail_output.str().empty()) - cout << dynamic_paramsd_detail_output.str() << endl; + if (!dynamic_paramsd_simple_output.str().empty()) + cout << dynamic_paramsd_simple_output.str() << endl; } } else @@ -1492,32 +1492,32 @@ ModFile::writeJsonComputingPassOutput(const string &basename, JsonFileOutputType writeJsonFileHelper(fname_static, static_output); writeJsonFileHelper(fname_dynamic, dynamic_output); - if (jsonprintderivdetail) + if (jsonderivsimple) { - string fname_static_details, fname_dynamic_details; - fname_static_details = basename + "_static_details.json"; - fname_dynamic_details = basename + "_dynamic_details.json"; + string fname_static_simple, fname_dynamic_simple; + fname_static_simple = basename + "_static_simple.json"; + fname_dynamic_simple = basename + "_dynamic_simple.json"; - writeJsonFileHelper(fname_static_details, static_detail_output); - writeJsonFileHelper(fname_dynamic_details, dynamic_detail_output); + writeJsonFileHelper(fname_static_simple, static_simple_output); + writeJsonFileHelper(fname_dynamic_simple, dynamic_simple_output); } if (!static_paramsd_output.str().empty()) { - string fname_static_params, fname_static_params_details; + string fname_static_params, fname_static_params_simple; fname_static_params = basename + "_static_params_derivs.json"; - fname_static_params_details = basename + "_static_params_derivs_details.json"; + fname_static_params_simple = basename + "_static_params_derivs_simple.json"; writeJsonFileHelper(fname_static_params, static_paramsd_output); - writeJsonFileHelper(fname_static_params_details, static_paramsd_detail_output); + writeJsonFileHelper(fname_static_params_simple, static_paramsd_simple_output); } if (!dynamic_paramsd_output.str().empty()) { - string fname_dynamic_params, fname_dynamic_params_details; + string fname_dynamic_params, fname_dynamic_params_simple; fname_dynamic_params = basename + "_params_derivs.json"; - fname_dynamic_params_details = basename + "_params_derivs_details.json"; + fname_dynamic_params_simple = basename + "_params_derivs_simple.json"; writeJsonFileHelper(fname_dynamic_params, dynamic_paramsd_output); - writeJsonFileHelper(fname_dynamic_params_details, dynamic_paramsd_detail_output); + writeJsonFileHelper(fname_dynamic_params_simple, dynamic_paramsd_simple_output); } } } diff --git a/preprocessor/ModFile.hh b/preprocessor/ModFile.hh index 985a15a79..7744d9281 100644 --- a/preprocessor/ModFile.hh +++ b/preprocessor/ModFile.hh @@ -119,7 +119,7 @@ private: WarningConsolidation &warnings; //! Functions used in writing of JSON outut. See writeJsonOutput void writeJsonOutputParsingCheck(const string &basename, JsonFileOutputType json_output_mode, bool transformpass, bool computingpass) const; - void writeJsonComputingPassOutput(const string &basename, JsonFileOutputType json_output_mode, bool jsonprintderivdetail) const; + void writeJsonComputingPassOutput(const string &basename, JsonFileOutputType json_output_mode, bool jsonderivsimple) const; void writeJsonFileHelper(string &fname, ostringstream &output) const; public: //! Add a statement @@ -174,7 +174,7 @@ public: //! Initially created to enable Julia to work with .mod files //! Potentially outputs ModFile after the various parts of processing (parsing, checkPass, transformPass, computingPass) //! Allows user of other host language platforms (python, fortran, etc) to provide support for dynare .mod files - void writeJsonOutput(const string &basename, JsonOutputPointType json, JsonFileOutputType json_output_mode, bool onlyjson, bool jsonprintderivdetail = false); + void writeJsonOutput(const string &basename, JsonOutputPointType json, JsonFileOutputType json_output_mode, bool onlyjson, bool jsonderivsimple = false); }; #endif // ! MOD_FILE_HH diff --git a/preprocessor/StaticModel.cc b/preprocessor/StaticModel.cc index 5c18d1247..a398d1c4f 100644 --- a/preprocessor/StaticModel.cc +++ b/preprocessor/StaticModel.cc @@ -2467,12 +2467,16 @@ StaticModel::writeJsonComputingPassOutput(ostream &output, bool writeDetails) co expr_t d1 = it->second; if (writeDetails) - jacobian_output << "{\"eq\": " << eq + 1 - << ", \"var\": \"" << symbol_table.getName(symb_id) << "\""; + jacobian_output << "{\"eq\": " << eq + 1; else jacobian_output << "{\"row\": " << eq + 1; - jacobian_output << ", \"col\": " << col + 1 - << ", \"val\": \""; + + jacobian_output << ", \"col\": " << col + 1; + + if (writeDetails) + jacobian_output << ", \"var\": \"" << symbol_table.getName(symb_id) << "\""; + + jacobian_output << ", \"val\": \""; d1->writeJsonOutput(jacobian_output, temp_term_union, tef_terms); jacobian_output << "\"}" << endl; } @@ -2506,13 +2510,16 @@ StaticModel::writeJsonComputingPassOutput(ostream &output, bool writeDetails) co int col_sym = tsid2*symbol_table.endo_nbr()+tsid1; if (writeDetails) - hessian_output << "{\"eq\": " << eq + 1 - << ", \"var1\": \"" << symbol_table.getName(symb_id1) << "\"" - << ", \"var2\": \"" << symbol_table.getName(symb_id2) << "\""; + hessian_output << "{\"eq\": " << eq + 1; else hessian_output << "{\"row\": " << eq + 1; hessian_output << ", \"col\": [" << col + 1; + + if (writeDetails) + hessian_output << ", \"var1\": \"" << symbol_table.getName(symb_id1) << "\"" + << ", \"var2\": \"" << symbol_table.getName(symb_id2) << "\""; + if (symb_id1 != symb_id2) hessian_output << ", " << col_sym + 1; hessian_output << "]" @@ -2544,10 +2551,7 @@ StaticModel::writeJsonComputingPassOutput(ostream &output, bool writeDetails) co expr_t d3 = it->second; if (writeDetails) - third_derivatives_output << "{\"eq\": " << eq + 1 - << ", \"var1\": \"" << symbol_table.getName(getSymbIDByDerivID(var1)) << "\"" - << ", \"var2\": \"" << symbol_table.getName(getSymbIDByDerivID(var2)) << "\"" - << ", \"var3\": \"" << symbol_table.getName(getSymbIDByDerivID(var3)) << "\""; + third_derivatives_output << "{\"eq\": " << eq + 1; else third_derivatives_output << "{\"row\": " << eq + 1; @@ -2569,17 +2573,23 @@ StaticModel::writeJsonComputingPassOutput(ostream &output, bool writeDetails) co third_derivatives_output << ", "; third_derivatives_output << *it2 + 1; } - third_derivatives_output << "]" - << ", \"val\": \""; + third_derivatives_output << "]"; + + if (writeDetails) + third_derivatives_output << ", \"var1\": \"" << symbol_table.getName(getSymbIDByDerivID(var1)) << "\"" + << ", \"var2\": \"" << symbol_table.getName(getSymbIDByDerivID(var2)) << "\"" + << ", \"var3\": \"" << symbol_table.getName(getSymbIDByDerivID(var3)) << "\""; + + third_derivatives_output << ", \"val\": \""; d3->writeJsonOutput(third_derivatives_output, temp_term_union, tef_terms); third_derivatives_output << "\"}" << endl; } third_derivatives_output << "]}"; if (writeDetails) - output << "\"static_model_derivative_details\": {"; + output << "\"static_model\": {"; else - output << "\"static_model_derivatives\": {"; + output << "\"static_model_simple\": {"; output << model_local_vars_output.str() << ", " << model_output.str() << ", " << jacobian_output.str() @@ -2629,12 +2639,16 @@ StaticModel::writeJsonParamsDerivativesFile(ostream &output, bool writeDetails) int param_col = symbol_table.getTypeSpecificID(getSymbIDByDerivID(param)) + 1; if (writeDetails) - jacobian_output << "{\"eq\": " << eq + 1 - << ", \"param\": \"" << symbol_table.getName(getSymbIDByDerivID(param)) << "\""; + jacobian_output << "{\"eq\": " << eq + 1; else jacobian_output << "{\"row\": " << eq + 1; - jacobian_output << ", \"param_col\": " << param_col - << ", \"val\": \""; + + if (writeDetails) + jacobian_output << ", \"param_col\": " << param_col; + + jacobian_output << ", \"param\": \"" << symbol_table.getName(getSymbIDByDerivID(param)) << "\""; + + jacobian_output << ", \"val\": \""; d1->writeJsonOutput(jacobian_output, params_derivs_temporary_terms, tef_terms); jacobian_output << "\"}" << endl; } @@ -2659,11 +2673,14 @@ StaticModel::writeJsonParamsDerivativesFile(ostream &output, bool writeDetails) int param_col = symbol_table.getTypeSpecificID(getSymbIDByDerivID(param)) + 1; if (writeDetails) - hessian_output << "{\"eq\": " << eq + 1 - << ", \"var\": \"" << symbol_table.getName(getSymbIDByDerivID(var)) << "\"" - << ", \"param\": \"" << symbol_table.getName(getSymbIDByDerivID(param)) << "\""; + hessian_output << "{\"eq\": " << eq + 1; else hessian_output << "{\"row\": " << eq + 1; + + if (writeDetails) + hessian_output << ", \"var\": \"" << symbol_table.getName(getSymbIDByDerivID(var)) << "\"" + << ", \"param\": \"" << symbol_table.getName(getSymbIDByDerivID(param)) << "\""; + hessian_output << ", \"var_col\": " << var_col << ", \"param_col\": " << param_col << ", \"val\": \""; @@ -2692,14 +2709,18 @@ StaticModel::writeJsonParamsDerivativesFile(ostream &output, bool writeDetails) int param2_col = symbol_table.getTypeSpecificID(getSymbIDByDerivID(param2)) + 1; if (writeDetails) - hessian1_output << "{\"eq\": " << eq + 1 - << ", \"param1\": \"" << symbol_table.getName(getSymbIDByDerivID(param1)) << "\"" - << ", \"param2\": \"" << symbol_table.getName(getSymbIDByDerivID(param2)) << "\""; + hessian1_output << "{\"eq\": " << eq + 1; else hessian1_output << "{\"row\": " << eq + 1; + hessian1_output << ", \"param1_col\": " << param1_col - << ", \"param2_col\": " << param2_col - << ", \"val\": \""; + << ", \"param2_col\": " << param2_col; + + if (writeDetails) + hessian1_output << ", \"param1\": \"" << symbol_table.getName(getSymbIDByDerivID(param1)) << "\"" + << ", \"param2\": \"" << symbol_table.getName(getSymbIDByDerivID(param2)) << "\""; + + hessian1_output << ", \"val\": \""; d2->writeJsonOutput(hessian1_output, params_derivs_temporary_terms, tef_terms); hessian1_output << "\"}" << endl; } @@ -2727,16 +2748,19 @@ StaticModel::writeJsonParamsDerivativesFile(ostream &output, bool writeDetails) int param2_col = symbol_table.getTypeSpecificID(getSymbIDByDerivID(param2)) + 1; if (writeDetails) - third_derivs_output << "{\"eq\": " << eq + 1 - << ", \"var\": \"" << symbol_table.getName(var) << "\"" - << ", \"param1\": \"" << symbol_table.getName(getSymbIDByDerivID(param1)) << "\"" - << ", \"param2\": \"" << symbol_table.getName(getSymbIDByDerivID(param2)) << "\""; + third_derivs_output << "{\"eq\": " << eq + 1; else third_derivs_output << "{\"row\": " << eq + 1; third_derivs_output << ", \"var_col\": " << var_col << ", \"param1_col\": " << param1_col - << ", \"param2_col\": " << param2_col - << ", \"val\": \""; + << ", \"param2_col\": " << param2_col; + + if (writeDetails) + third_derivs_output << ", \"var\": \"" << symbol_table.getName(var) << "\"" + << ", \"param1\": \"" << symbol_table.getName(getSymbIDByDerivID(param1)) << "\"" + << ", \"param2\": \"" << symbol_table.getName(getSymbIDByDerivID(param2)) << "\""; + + third_derivs_output << ", \"val\": \""; d2->writeJsonOutput(third_derivs_output, params_derivs_temporary_terms, tef_terms); third_derivs_output << "\"}" << endl; } @@ -2765,25 +2789,29 @@ StaticModel::writeJsonParamsDerivativesFile(ostream &output, bool writeDetails) int param_col = symbol_table.getTypeSpecificID(getSymbIDByDerivID(param)) + 1; if (writeDetails) - third_derivs1_output << "{\"eq\": " << eq + 1 - << ", \"var1\": \"" << symbol_table.getName(getSymbIDByDerivID(var1)) << "\"" - << ", \"var2\": \"" << symbol_table.getName(getSymbIDByDerivID(var2)) << "\"" - << ", \"param1\": \"" << symbol_table.getName(getSymbIDByDerivID(param)) << "\""; + third_derivs1_output << "{\"eq\": " << eq + 1; else third_derivs1_output << "{\"row\": " << eq + 1; + third_derivs1_output << ", \"var1_col\": " << var1_col << ", \"var2_col\": " << var2_col - << ", \"param_col\": " << param_col - << ", \"val\": \""; + << ", \"param_col\": " << param_col; + + if (writeDetails) + third_derivs1_output << ", \"var1\": \"" << symbol_table.getName(getSymbIDByDerivID(var1)) << "\"" + << ", \"var2\": \"" << symbol_table.getName(getSymbIDByDerivID(var2)) << "\"" + << ", \"param1\": \"" << symbol_table.getName(getSymbIDByDerivID(param)) << "\""; + + third_derivs1_output << ", \"val\": \""; d2->writeJsonOutput(third_derivs1_output, params_derivs_temporary_terms, tef_terms); third_derivs1_output << "\"}" << endl; } third_derivs1_output << "]}" << endl; if (writeDetails) - output << "\"static_model_params_derivative_details\": {"; + output << "\"static_model_params_derivative\": {"; else - output << "\"static_model_params_derivatives\": {"; + output << "\"static_model_params_derivatives_simple\": {"; output << model_local_vars_output.str() << ", " << model_output.str() << ", " << jacobian_output.str() From 153bcb8fe428c8c81071e5bc3c94b4ac8ca7645e Mon Sep 17 00:00:00 2001 From: Houtan Bastani Date: Thu, 29 Jun 2017 13:15:32 +0200 Subject: [PATCH 17/18] preprocessor: cleanup writing JSON to standardout --- preprocessor/ModFile.cc | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/preprocessor/ModFile.cc b/preprocessor/ModFile.cc index 4098c8a26..77805bc16 100644 --- a/preprocessor/ModFile.cc +++ b/preprocessor/ModFile.cc @@ -1270,6 +1270,9 @@ ModFile::writeJsonOutput(const string &basename, JsonOutputPointType json, JsonF if (json == parsing || json == checkpass) symbol_table.freeze(); + if (json_output_mode == standardout) + cout << "{" << endl; + writeJsonOutputParsingCheck(basename, json_output_mode, json == transformpass, json == computingpass); if (json == parsing || json == checkpass) @@ -1278,6 +1281,9 @@ ModFile::writeJsonOutput(const string &basename, JsonOutputPointType json, JsonF if (json == computingpass) writeJsonComputingPassOutput(basename, json_output_mode, jsonderivsimple); + if (json_output_mode == standardout) + cout << "}" << endl; + switch (json) { case parsing: @@ -1333,7 +1339,7 @@ ModFile::writeJsonOutputParsingCheck(const string &basename, JsonFileOutputType ostringstream original_model_output; original_model_output << ""; - if (transformpass) + if (transformpass || computingpass) { original_model_output << "{"; original_model.writeJsonOriginalModelOutput(original_model_output); @@ -1342,9 +1348,13 @@ ModFile::writeJsonOutputParsingCheck(const string &basename, JsonFileOutputType if (json_output_mode == standardout) { + if (transformpass || computingpass) + cout << "\"transformed_model\": "; + else + cout << "\"model\": "; cout << output.str(); if (!original_model_output.str().empty()) - cout << "," << original_model_output.str(); + cout << ", \"original_model\": " << original_model_output.str(); } else { @@ -1408,11 +1418,6 @@ ModFile::writeJsonComputingPassOutput(const string &basename, JsonFileOutputType dynamic_model.writeJsonComputingPassOutput(dynamic_output, true); dynamic_output << "}" << endl; - ostringstream original_model_output; - original_model_output << "{"; - original_model.writeJsonOriginalModelOutput(original_model_output); - original_model_output << "}" << endl; - ostringstream tmp_out, static_paramsd_output, static_paramsd_simple_output; tmp_out << ""; static_paramsd_output << ""; @@ -1453,26 +1458,25 @@ ModFile::writeJsonComputingPassOutput(const string &basename, JsonFileOutputType if (json_output_mode == standardout) { - cout << original_model_output.str() << endl - << static_output.str() << endl - << dynamic_output.str() << endl; + cout << ", \"static_model\": " << static_output.str() << endl + << ", \"dynamic_model\": " << dynamic_output.str() << endl; if (!static_paramsd_output.str().empty()) - cout << static_paramsd_output.str() << endl; + cout << ", \"static_params_deriv\": " << static_paramsd_output.str() << endl; if (!dynamic_paramsd_output.str().empty()) - cout << dynamic_paramsd_output.str() << endl; + cout << ", \"dynamic_params_deriv\":" << dynamic_paramsd_output.str() << endl; if (jsonderivsimple) { - cout << static_simple_output.str() << endl - << dynamic_simple_output.str() << endl; + cout << ", \"static_model_simple\": " << static_simple_output.str() << endl + << ", \"dynamic_model_simple\": " << dynamic_simple_output.str() << endl; if (!static_paramsd_simple_output.str().empty()) - cout << static_paramsd_simple_output.str() << endl; + cout << "," << static_paramsd_simple_output.str() << endl; if (!dynamic_paramsd_simple_output.str().empty()) - cout << dynamic_paramsd_simple_output.str() << endl; + cout << "," << dynamic_paramsd_simple_output.str() << endl; } } else @@ -1484,11 +1488,9 @@ ModFile::writeJsonComputingPassOutput(const string &basename, JsonFileOutputType } string fname_original, fname_static, fname_dynamic; - fname_original = basename + "_original.json"; fname_static = basename + "_static.json"; fname_dynamic = basename + "_dynamic.json"; - writeJsonFileHelper(fname_original, original_model_output); writeJsonFileHelper(fname_static, static_output); writeJsonFileHelper(fname_dynamic, dynamic_output); From 49a866255a8c09a595d976560e6eaaafb121e0b5 Mon Sep 17 00:00:00 2001 From: Houtan Bastani Date: Thu, 29 Jun 2017 13:18:59 +0200 Subject: [PATCH 18/18] preprocessor: couch JSON stdout output in constant text so users can easily find it --- preprocessor/ModFile.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/preprocessor/ModFile.cc b/preprocessor/ModFile.cc index 77805bc16..130e6da3d 100644 --- a/preprocessor/ModFile.cc +++ b/preprocessor/ModFile.cc @@ -1271,7 +1271,8 @@ ModFile::writeJsonOutput(const string &basename, JsonOutputPointType json, JsonF symbol_table.freeze(); if (json_output_mode == standardout) - cout << "{" << endl; + cout << "//-- BEGIN JSON --// " << endl + << "{" << endl; writeJsonOutputParsingCheck(basename, json_output_mode, json == transformpass, json == computingpass); @@ -1282,7 +1283,8 @@ ModFile::writeJsonOutput(const string &basename, JsonOutputPointType json, JsonF writeJsonComputingPassOutput(basename, json_output_mode, jsonderivsimple); if (json_output_mode == standardout) - cout << "}" << endl; + cout << "}" << endl + << "//-- END JSON --// " << endl; switch (json) {