Commit 52cc77fe authored by Sébastien Villemot's avatar Sébastien Villemot
Browse files

New preprocessor option for not creating a logfile

Closes: #241
parent bc225f5d
......@@ -685,6 +685,10 @@ step. Useful in conjunction with @code{savemacro} when one wants that to
reuse the intermediary @file{.mod} file, without having it cluttered by
line numbering directives.
@item nolog
Instructs Dynare to no create a logfile of this run in
@file{@var{FILENAME}.log}. The default is to create the logfile.
@item warn_uninit
Display a warning for each variable or parameter which is not
initialized. @xref{Parameter initialization}, or
......
/*
* Copyright (C) 2003-2010 Dynare Team
* Copyright (C) 2003-2012 Dynare Team
*
* This file is part of Dynare.
*
......@@ -34,7 +34,7 @@ using namespace std;
Splitting main() in two parts was necessary because ParsingDriver.h and MacroDriver.h can't be
included simultaneously (because of Bison limitations).
*/
void main2(stringstream &in, string &basename, bool debug, bool clear_all, bool no_tmp_terms, bool warn_uninit, bool console,
void main2(stringstream &in, string &basename, bool debug, bool clear_all, bool no_tmp_terms, bool no_log, bool warn_uninit, bool console,
bool parallel, const string &parallel_config_file, const string &cluster_name, bool parallel_slave_open_mode,
bool parallel_test
#if defined(_WIN32) || defined(__CYGWIN32__)
......@@ -45,7 +45,7 @@ void main2(stringstream &in, string &basename, bool debug, bool clear_all, bool
void
usage()
{
cerr << "Dynare usage: dynare mod_file [debug] [noclearall] [savemacro[=macro_file]] [onlymacro] [nolinemacro] [notmpterms] [warn_uninit]"
cerr << "Dynare usage: dynare mod_file [debug] [noclearall] [savemacro[=macro_file]] [onlymacro] [nolinemacro] [notmpterms] [nolog] [warn_uninit]"
<< " [console] [parallel[=cluster_name]] [conffile=parallel_config_path_and_filename] [parallel_slave_open_mode] [parallel_test] "
<< " [-D<variable>[=<value>]]"
#if defined(_WIN32) || defined(__CYGWIN32__)
......@@ -71,6 +71,7 @@ main(int argc, char **argv)
bool no_tmp_terms = false;
bool only_macro = false;
bool no_line_macro = false;
bool no_log = false;
bool warn_uninit = false;
bool console = false;
#if defined(_WIN32) || defined(__CYGWIN32__)
......@@ -110,6 +111,8 @@ main(int argc, char **argv)
no_line_macro = true;
else if (!strcmp(argv[arg], "notmpterms"))
no_tmp_terms = true;
else if (!strcmp(argv[arg], "nolog"))
no_log = true;
else if (!strcmp(argv[arg], "warn_uninit"))
warn_uninit = true;
else if (!strcmp(argv[arg], "console"))
......@@ -206,7 +209,7 @@ main(int argc, char **argv)
return EXIT_SUCCESS;
// Do the rest
main2(macro_output, basename, debug, clear_all, no_tmp_terms, warn_uninit, console,
main2(macro_output, basename, debug, clear_all, no_tmp_terms, no_log, warn_uninit, console,
parallel, parallel_config_file, cluster_name, parallel_slave_open_mode, parallel_test
#if defined(_WIN32) || defined(__CYGWIN32__)
, cygwin, msvc
......
......@@ -26,7 +26,7 @@ using namespace std;
#include "ConfigFile.hh"
void
main2(stringstream &in, string &basename, bool debug, bool clear_all, bool no_tmp_terms, bool warn_uninit, bool console,
main2(stringstream &in, string &basename, bool debug, bool clear_all, bool no_tmp_terms, bool no_log, bool warn_uninit, bool console,
bool parallel, const string &parallel_config_file, const string &cluster_name, bool parallel_slave_open_mode,
bool parallel_test
#if defined(_WIN32) || defined(__CYGWIN32__)
......@@ -56,7 +56,7 @@ main2(stringstream &in, string &basename, bool debug, bool clear_all, bool no_tm
mod_file->computingPass(no_tmp_terms);
// Write outputs
mod_file->writeOutputFiles(basename, clear_all, console, config_file
mod_file->writeOutputFiles(basename, clear_all, no_log, console, config_file
#if defined(_WIN32) || defined(__CYGWIN32__)
, cygwin, msvc
#endif
......
......@@ -411,7 +411,7 @@ ModFile::computingPass(bool no_tmp_terms)
}
void
ModFile::writeOutputFiles(const string &basename, bool clear_all, bool console, const ConfigFile &config_file
ModFile::writeOutputFiles(const string &basename, bool clear_all, bool no_log, bool console, const ConfigFile &config_file
#if defined(_WIN32) || defined(__CYGWIN32__)
, bool cygwin, bool msvc
#endif
......@@ -458,12 +458,13 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool console,
<< "% Some global variables initialization" << endl
<< "%" << endl
<< "global_initialization;" << endl
<< "diary off;" << endl
<< "logname_ = '" << basename << ".log';" << endl
<< "if exist(logname_, 'file')" << endl
<< " delete(logname_)" << endl
<< "end" << endl
<< "diary(logname_)" << endl;
<< "diary off;" << endl;
if (!no_log)
mOutputFile << "logname_ = '" << basename << ".log';" << endl
<< "if exist(logname_, 'file')" << endl
<< " delete(logname_)" << endl
<< "end" << endl
<< "diary(logname_)" << endl;
if (console)
mOutputFile << "options_.console_mode = 1;" << endl;
......@@ -624,7 +625,8 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool console,
warnings.writeOutput(mOutputFile);
mOutputFile << "diary off" << endl;
if (!no_log)
mOutputFile << "diary off" << endl;
mOutputFile.close();
......
......@@ -117,7 +117,7 @@ public:
\param cygwin Should the MEX command of use_dll be adapted for Cygwin?
\param msvc Should the MEX command of use_dll be adapted for MSVC?
*/
void writeOutputFiles(const string &basename, bool clear_all, bool console, const ConfigFile &config_file
void writeOutputFiles(const string &basename, bool clear_all, bool no_log, bool console, const ConfigFile &config_file
#if defined(_WIN32) || defined(__CYGWIN32__)
, bool cygwin, bool msvc
#endif
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment