New preprocessor option for not creating a logfile

Closes: #241
issue#70
Sébastien Villemot 2012-04-20 18:15:02 +02:00
parent 60fb8aeaae
commit e1e77909a1
4 changed files with 20 additions and 15 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2003-2010 Dynare Team * Copyright (C) 2003-2012 Dynare Team
* *
* This file is part of Dynare. * 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 Splitting main() in two parts was necessary because ParsingDriver.h and MacroDriver.h can't be
included simultaneously (because of Bison limitations). 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, const string &parallel_config_file, const string &cluster_name, bool parallel_slave_open_mode,
bool parallel_test bool parallel_test
#if defined(_WIN32) || defined(__CYGWIN32__) #if defined(_WIN32) || defined(__CYGWIN32__)
@ -45,7 +45,7 @@ void main2(stringstream &in, string &basename, bool debug, bool clear_all, bool
void void
usage() 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] " << " [console] [parallel[=cluster_name]] [conffile=parallel_config_path_and_filename] [parallel_slave_open_mode] [parallel_test] "
<< " [-D<variable>[=<value>]]" << " [-D<variable>[=<value>]]"
#if defined(_WIN32) || defined(__CYGWIN32__) #if defined(_WIN32) || defined(__CYGWIN32__)
@ -71,6 +71,7 @@ main(int argc, char **argv)
bool no_tmp_terms = false; bool no_tmp_terms = false;
bool only_macro = false; bool only_macro = false;
bool no_line_macro = false; bool no_line_macro = false;
bool no_log = false;
bool warn_uninit = false; bool warn_uninit = false;
bool console = false; bool console = false;
#if defined(_WIN32) || defined(__CYGWIN32__) #if defined(_WIN32) || defined(__CYGWIN32__)
@ -110,6 +111,8 @@ main(int argc, char **argv)
no_line_macro = true; no_line_macro = true;
else if (!strcmp(argv[arg], "notmpterms")) else if (!strcmp(argv[arg], "notmpterms"))
no_tmp_terms = true; no_tmp_terms = true;
else if (!strcmp(argv[arg], "nolog"))
no_log = true;
else if (!strcmp(argv[arg], "warn_uninit")) else if (!strcmp(argv[arg], "warn_uninit"))
warn_uninit = true; warn_uninit = true;
else if (!strcmp(argv[arg], "console")) else if (!strcmp(argv[arg], "console"))
@ -206,7 +209,7 @@ main(int argc, char **argv)
return EXIT_SUCCESS; return EXIT_SUCCESS;
// Do the rest // 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 parallel, parallel_config_file, cluster_name, parallel_slave_open_mode, parallel_test
#if defined(_WIN32) || defined(__CYGWIN32__) #if defined(_WIN32) || defined(__CYGWIN32__)
, cygwin, msvc , cygwin, msvc

View File

@ -26,7 +26,7 @@ using namespace std;
#include "ConfigFile.hh" #include "ConfigFile.hh"
void 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, const string &parallel_config_file, const string &cluster_name, bool parallel_slave_open_mode,
bool parallel_test bool parallel_test
#if defined(_WIN32) || defined(__CYGWIN32__) #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); mod_file->computingPass(no_tmp_terms);
// Write outputs // 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__) #if defined(_WIN32) || defined(__CYGWIN32__)
, cygwin, msvc , cygwin, msvc
#endif #endif

View File

@ -411,7 +411,7 @@ ModFile::computingPass(bool no_tmp_terms)
} }
void 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__) #if defined(_WIN32) || defined(__CYGWIN32__)
, bool cygwin, bool msvc , bool cygwin, bool msvc
#endif #endif
@ -458,12 +458,13 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool console,
<< "% Some global variables initialization" << endl << "% Some global variables initialization" << endl
<< "%" << endl << "%" << endl
<< "global_initialization;" << endl << "global_initialization;" << endl
<< "diary off;" << endl << "diary off;" << endl;
<< "logname_ = '" << basename << ".log';" << endl if (!no_log)
<< "if exist(logname_, 'file')" << endl mOutputFile << "logname_ = '" << basename << ".log';" << endl
<< " delete(logname_)" << endl << "if exist(logname_, 'file')" << endl
<< "end" << endl << " delete(logname_)" << endl
<< "diary(logname_)" << endl; << "end" << endl
<< "diary(logname_)" << endl;
if (console) if (console)
mOutputFile << "options_.console_mode = 1;" << endl; mOutputFile << "options_.console_mode = 1;" << endl;
@ -624,7 +625,8 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool console,
warnings.writeOutput(mOutputFile); warnings.writeOutput(mOutputFile);
mOutputFile << "diary off" << endl; if (!no_log)
mOutputFile << "diary off" << endl;
mOutputFile.close(); mOutputFile.close();

View File

@ -117,7 +117,7 @@ public:
\param cygwin Should the MEX command of use_dll be adapted for Cygwin? \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? \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__) #if defined(_WIN32) || defined(__CYGWIN32__)
, bool cygwin, bool msvc , bool cygwin, bool msvc
#endif #endif