diff --git a/DynareMain.cc b/DynareMain.cc
index 27225bfa61be20c64a7fdde053c63d9eebdf679a..5aec0a9b4dfe3af81268e0c00638543ef2735361 100644
--- a/DynareMain.cc
+++ b/DynareMain.cc
@@ -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,
+void main2(stringstream &in, string &basename, bool debug, bool clear_all, bool no_tmp_terms, 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__)
@@ -46,7 +46,7 @@ void
 usage()
 {
   cerr << "Dynare usage: dynare mod_file [debug] [noclearall] [savemacro[=macro_file]] [onlymacro] [nolinemacro] [notmpterms] [warn_uninit]"
-       << " [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]"
 #if defined(_WIN32) || defined(__CYGWIN32__)
        << " [cygwin] [msvc]"
 #endif
@@ -71,6 +71,7 @@ main(int argc, char **argv)
   bool only_macro = false;
   bool no_line_macro = false;
   bool warn_uninit = false;
+  bool console = false;
 #if defined(_WIN32) || defined(__CYGWIN32__)
   bool cygwin = false;
   bool msvc = false;
@@ -109,6 +110,8 @@ main(int argc, char **argv)
         no_tmp_terms = true;
       else if (!strcmp(argv[arg], "warn_uninit"))
         warn_uninit = true;
+      else if (!strcmp(argv[arg], "console"))
+        console = true;
 #if defined(_WIN32) || defined(__CYGWIN32__)
       else if (!strcmp(argv[arg], "cygwin"))
         cygwin = true;
@@ -180,7 +183,7 @@ main(int argc, char **argv)
     return EXIT_SUCCESS;
 
   // Do the rest
-  main2(macro_output, basename, debug, clear_all, no_tmp_terms, warn_uninit,
+  main2(macro_output, basename, debug, clear_all, no_tmp_terms, 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 5b944a4ace5fa38dc9cd805ec99721b054619246..3813a6e272a4fcad3ce30c10f046efb2b71139c6 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,
+main2(stringstream &in, string &basename, bool debug, bool clear_all, bool no_tmp_terms, 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, config_file
+  mod_file->writeOutputFiles(basename, clear_all, console, config_file
 #if defined(_WIN32) || defined(__CYGWIN32__)
                              , cygwin, msvc
 #endif
diff --git a/ModFile.cc b/ModFile.cc
index bf6b9130fa2990271a5babf0c03552e21f8b168b..ab1eb655209c5f121d6a5e395a73f23d3d280a9e 100644
--- a/ModFile.cc
+++ b/ModFile.cc
@@ -345,7 +345,7 @@ ModFile::computingPass(bool no_tmp_terms)
 }
 
 void
-ModFile::writeOutputFiles(const string &basename, bool clear_all, const ConfigFile &config_file
+ModFile::writeOutputFiles(const string &basename, bool clear_all, bool console, const ConfigFile &config_file
 #if defined(_WIN32) || defined(__CYGWIN32__)
                           , bool cygwin, bool msvc
 #endif
@@ -398,6 +398,9 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, const ConfigFi
               << "end" << endl
               << "diary(logname_)" << endl;
 
+  if (console)
+    mOutputFile << "options_.console_mode = 1;" << endl;
+
   cout << "Processing outputs ...";
 
   symbol_table.writeOutput(mOutputFile);
diff --git a/ModFile.hh b/ModFile.hh
index 71d363167aaee70a5df65797193be64dfa24e69f..00999c88b364606f94123f58f393460a604b252d 100644
--- a/ModFile.hh
+++ b/ModFile.hh
@@ -105,9 +105,11 @@ public:
   /*!
     \param basename The base name used for writing output files. Should be the name of the mod file without its extension
     \param clear_all Should a "clear all" instruction be written to output ?
+    \param console Are we in console mode ?
+    \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, const ConfigFile &config_file
+  void writeOutputFiles(const string &basename, bool clear_all, bool console, const ConfigFile &config_file
 #if defined(_WIN32) || defined(__CYGWIN32__)
                         , bool cygwin, bool msvc
 #endif