From e1e77909a1a0540aa85ff08547251b0bae467cf4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= Date: Fri, 20 Apr 2012 18:15:02 +0200 Subject: [PATCH] New preprocessor option for not creating a logfile Closes: #241 --- DynareMain.cc | 11 +++++++---- DynareMain2.cc | 4 ++-- ModFile.cc | 18 ++++++++++-------- ModFile.hh | 2 +- 4 files changed, 20 insertions(+), 15 deletions(-) diff --git a/DynareMain.cc b/DynareMain.cc index e40afaad..a43f078d 100644 --- a/DynareMain.cc +++ b/DynareMain.cc @@ -1,5 +1,5 @@ /* - * 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 ¶llel_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[=]]" #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 diff --git a/DynareMain2.cc b/DynareMain2.cc index 0892ec27..8eba44e3 100644 --- a/DynareMain2.cc +++ b/DynareMain2.cc @@ -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 ¶llel_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 diff --git a/ModFile.cc b/ModFile.cc index b6d33b6d..e19ff0af 100644 --- a/ModFile.cc +++ b/ModFile.cc @@ -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(); diff --git a/ModFile.hh b/ModFile.hh index cc2c8d4d..d6e336b9 100644 --- a/ModFile.hh +++ b/ModFile.hh @@ -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