diff --git a/src/DynareMain.cc b/src/DynareMain.cc
index 03c8e7c0fd8e8c04580edf6ffc764af5296d48c2..39290f3481a4bc34dd2a2c972c66b0ac5f103dae 100644
--- a/src/DynareMain.cc
+++ b/src/DynareMain.cc
@@ -47,7 +47,7 @@ void main2(stringstream &in, string &basename, bool debug, bool clear_all, bool
            LanguageOutputType lang, int params_derivs_order, bool transform_unary_ops,
            JsonOutputPointType json, JsonFileOutputType json_output_mode, bool onlyjson, bool jsonderivsimple,
            bool nopreprocessoroutput, const string &mexext, const boost::filesystem::path &matlabroot,
-           const boost::filesystem::path &dynareroot);
+           const boost::filesystem::path &dynareroot, bool onlymodel);
 
 void main1(string &modfile, string &basename, string &modfiletxt, bool debug, bool save_macro, string &save_macro_file,
            bool no_line_macro, bool no_empty_line_macro, map<string, string> &defines, vector<string> &path, stringstream &macro_output);
@@ -60,7 +60,7 @@ usage()
        << " [-D<variable>[=<value>]] [-I/path] [nostrict] [stochastic] [fast] [minimal_workspace] [compute_xrefs] [output=dynamic|first|second|third] [language=julia]"
        << " [params_derivs_order=0|1|2] [transform_unary_ops]"
        << " [json=parse|check|transform|compute] [jsonstdout] [onlyjson] [jsonderivsimple] [nopathchange] [nopreprocessoroutput]"
-       << " [mexext=<extension>] [matlabroot=<path>]"
+       << " [mexext=<extension>] [matlabroot=<path>] [onlymodel]"
        << endl;
   exit(EXIT_FAILURE);
 }
@@ -122,6 +122,7 @@ main(int argc, char **argv)
   boost::filesystem::path dynareroot{argv[0]};
   dynareroot = dynareroot.parent_path();
   dynareroot = dynareroot / ".." / "..";
+  bool onlymodel = false;
 
   // Parse options
   for (int arg = 2; arg < argc; arg++)
@@ -344,6 +345,8 @@ main(int argc, char **argv)
             }
           matlabroot = boost::filesystem::path{s.substr(11)};
         }
+      else if (s == "onlymodel")
+        onlymodel = true;
       else
         {
           cerr << "Unknown option: " << s << endl;
@@ -414,7 +417,7 @@ main(int argc, char **argv)
         parallel, config_file, warnings, nostrict, stochastic, check_model_changes, minimal_workspace,
         compute_xrefs, output_mode, language, params_derivs_order, transform_unary_ops,
         json, json_output_mode, onlyjson, jsonderivsimple, nopreprocessoroutput,
-        mexext, matlabroot, dynareroot);
+        mexext, matlabroot, dynareroot, onlymodel);
 
   return EXIT_SUCCESS;
 }
diff --git a/src/DynareMain2.cc b/src/DynareMain2.cc
index 3d7b6dc610ce8aa7b715a1775b5d0928bec622cc..3f8d117950314952036c072bf6bb824a30ed5b1d 100644
--- a/src/DynareMain2.cc
+++ b/src/DynareMain2.cc
@@ -35,7 +35,7 @@ main2(stringstream &in, string &basename, bool debug, bool clear_all, bool clear
       LanguageOutputType language, int params_derivs_order, bool transform_unary_ops,
       JsonOutputPointType json, JsonFileOutputType json_output_mode, bool onlyjson, bool jsonderivsimple,
       bool nopreprocessoroutput, const string &mexext, const boost::filesystem::path &matlabroot,
-      const boost::filesystem::path &dynareroot)
+      const boost::filesystem::path &dynareroot, bool onlymodel)
 {
   ParsingDriver p(warnings, nostrict);
 
@@ -70,7 +70,7 @@ main2(stringstream &in, string &basename, bool debug, bool clear_all, bool clear
   else
     mod_file->writeOutputFiles(basename, clear_all, clear_global, no_log, no_warn, console, nograph,
                                nointeractive, config_file, check_model_changes, minimal_workspace, compute_xrefs,
-                               nopreprocessoroutput, mexext, matlabroot, dynareroot);
+                               nopreprocessoroutput, mexext, matlabroot, dynareroot, onlymodel);
 
   if (!nopreprocessoroutput)
     cout << "Preprocessing completed." << endl;
diff --git a/src/ModFile.cc b/src/ModFile.cc
index 9881d8633fa9cf2d772138ce0bb129b5939de4f7..ac14a8ee391ecc01ce266f3d5b2e4928de434084 100644
--- a/src/ModFile.cc
+++ b/src/ModFile.cc
@@ -28,6 +28,7 @@
 #include "ModFile.hh"
 #include "ConfigFile.hh"
 #include "ComputingTasks.hh"
+#include "Shocks.hh"
 
 ModFile::ModFile(WarningConsolidation &warnings_arg)
   : var_model_table{symbol_table},
@@ -792,7 +793,7 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool clear_glo
                           bool check_model_changes, bool minimal_workspace, bool compute_xrefs,
                           const bool nopreprocessoroutput, const string &mexext,
                           const boost::filesystem::path &matlabroot,
-                          const boost::filesystem::path &dynareroot) const
+                          const boost::filesystem::path &dynareroot, bool onlymodel) const
 {
   bool hasModelChanged = !dynamic_model.isChecksumMatching(basename, block);
   if (!check_model_changes)
@@ -865,7 +866,8 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool clear_glo
               << "%" << endl
               << "% Some global variables initialization" << endl
               << "%" << endl;
-  config_file.writeHooks(mOutputFile);
+  if (!onlymodel)
+    config_file.writeHooks(mOutputFile);
   mOutputFile << "global_initialization;" << endl
               << "diary off;" << endl;
   if (!no_log)
@@ -946,7 +948,8 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool clear_glo
   mOutputFile << ";" << endl
               << "M_.hessian_eq_zero = isempty(M_.nonzero_hessian_eqs);" << endl;
 
-  config_file.writeCluster(mOutputFile);
+  if (!onlymodel)
+    config_file.writeCluster(mOutputFile);
 
   if (byte_code)
     mOutputFile << "if exist('bytecode') ~= 3" << endl
@@ -967,57 +970,71 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool clear_glo
         static_model.writeOutput(mOutputFile, block);
     }
 
-  for (auto &statement : statements)
-    {
-      statement->writeOutput(mOutputFile, basename, minimal_workspace);
+  if (onlymodel)
+    for (auto &statement : statements)
+      {
+        auto *ips = dynamic_cast<InitParamStatement *>(statement.get());
+        if (ips != nullptr)
+          ips->writeOutput(mOutputFile, basename, minimal_workspace);
 
-      /* Special treatment for initval block: insert initial values for the
-         auxiliary variables and initialize exo det */
-      auto ivs = dynamic_cast<InitValStatement *>(statement.get());
-      if (ivs != nullptr)
+        auto *ss = dynamic_cast<ShocksStatement *>(statement.get());
+        if (ss != nullptr)
+          ss->writeOutput(mOutputFile, basename, minimal_workspace);
+      }
+  else
+    {
+      for (auto &statement : statements)
         {
-          static_model.writeAuxVarInitval(mOutputFile, ExprNodeOutputType::matlabOutsideModel);
-          ivs->writeOutputPostInit(mOutputFile);
-        }
+          statement->writeOutput(mOutputFile, basename, minimal_workspace);
 
-      // Special treatment for endval block: insert initial values for the auxiliary variables
-      auto evs = dynamic_cast<EndValStatement *>(statement.get());
-      if (evs != nullptr)
-        static_model.writeAuxVarInitval(mOutputFile, ExprNodeOutputType::matlabOutsideModel);
+          /* Special treatment for initval block: insert initial values for the
+             auxiliary variables and initialize exo det */
+          auto ivs = dynamic_cast<InitValStatement *>(statement.get());
+          if (ivs != nullptr)
+            {
+              static_model.writeAuxVarInitval(mOutputFile, ExprNodeOutputType::matlabOutsideModel);
+              ivs->writeOutputPostInit(mOutputFile);
+            }
 
-      // Special treatment for load params and steady state statement: insert initial values for the auxiliary variables
-      auto lpass = dynamic_cast<LoadParamsAndSteadyStateStatement *>(statement.get());
-      if (lpass && !no_static)
-        static_model.writeAuxVarInitval(mOutputFile, ExprNodeOutputType::matlabOutsideModel);
-    }
+          // Special treatment for endval block: insert initial values for the auxiliary variables
+          auto evs = dynamic_cast<EndValStatement *>(statement.get());
+          if (evs != nullptr)
+            static_model.writeAuxVarInitval(mOutputFile, ExprNodeOutputType::matlabOutsideModel);
 
-  mOutputFile << "save('" << basename << "_results.mat', 'oo_', 'M_', 'options_');" << endl
-              << "if exist('estim_params_', 'var') == 1" << endl
-              << "  save('" << basename << "_results.mat', 'estim_params_', '-append');" << endl << "end" << endl
-              << "if exist('bayestopt_', 'var') == 1" << endl
-              << "  save('" << basename << "_results.mat', 'bayestopt_', '-append');" << endl << "end" << endl
-              << "if exist('dataset_', 'var') == 1" << endl
-              << "  save('" << basename << "_results.mat', 'dataset_', '-append');" << endl << "end" << endl
-              << "if exist('estimation_info', 'var') == 1" << endl
-              << "  save('" << basename << "_results.mat', 'estimation_info', '-append');" << endl << "end" << endl
-              << "if exist('dataset_info', 'var') == 1" << endl
-              << "  save('" << basename << "_results.mat', 'dataset_info', '-append');" << endl << "end" << endl
-              << "if exist('oo_recursive_', 'var') == 1" << endl
-              << "  save('" << basename << "_results.mat', 'oo_recursive_', '-append');" << endl << "end" << endl;
-
-  config_file.writeEndParallel(mOutputFile);
-
-  mOutputFile << endl << endl
-              << "disp(['Total computing time : ' dynsec2hms(toc(tic0)) ]);" << endl;
-
-  if (!no_warn)
-    {
-      if (warnings.countWarnings() > 0)
-        mOutputFile << "disp('Note: " << warnings.countWarnings() << " warning(s) encountered in the preprocessor')" << endl;
+          // Special treatment for load params and steady state statement: insert initial values for the auxiliary variables
+          auto lpass = dynamic_cast<LoadParamsAndSteadyStateStatement *>(statement.get());
+          if (lpass && !no_static)
+            static_model.writeAuxVarInitval(mOutputFile, ExprNodeOutputType::matlabOutsideModel);
+        }
 
-      mOutputFile << "if ~isempty(lastwarn)" << endl
-                  << "  disp('Note: warning(s) encountered in MATLAB/Octave code')" << endl
-                  << "end" << endl;
+      mOutputFile << "save('" << basename << "_results.mat', 'oo_', 'M_', 'options_');" << endl
+                  << "if exist('estim_params_', 'var') == 1" << endl
+                  << "  save('" << basename << "_results.mat', 'estim_params_', '-append');" << endl << "end" << endl
+                  << "if exist('bayestopt_', 'var') == 1" << endl
+                  << "  save('" << basename << "_results.mat', 'bayestopt_', '-append');" << endl << "end" << endl
+                  << "if exist('dataset_', 'var') == 1" << endl
+                  << "  save('" << basename << "_results.mat', 'dataset_', '-append');" << endl << "end" << endl
+                  << "if exist('estimation_info', 'var') == 1" << endl
+                  << "  save('" << basename << "_results.mat', 'estimation_info', '-append');" << endl << "end" << endl
+                  << "if exist('dataset_info', 'var') == 1" << endl
+                  << "  save('" << basename << "_results.mat', 'dataset_info', '-append');" << endl << "end" << endl
+                  << "if exist('oo_recursive_', 'var') == 1" << endl
+                  << "  save('" << basename << "_results.mat', 'oo_recursive_', '-append');" << endl << "end" << endl;
+
+      config_file.writeEndParallel(mOutputFile);
+
+      mOutputFile << endl << endl
+                  << "disp(['Total computing time : ' dynsec2hms(toc(tic0)) ]);" << endl;
+
+      if (!no_warn)
+        {
+          if (warnings.countWarnings() > 0)
+            mOutputFile << "disp('Note: " << warnings.countWarnings() << " warning(s) encountered in the preprocessor')" << endl;
+
+          mOutputFile << "if ~isempty(lastwarn)" << endl
+                      << "  disp('Note: warning(s) encountered in MATLAB/Octave code')" << endl
+                      << "end" << endl;
+        }
     }
 
   if (!no_log)
diff --git a/src/ModFile.hh b/src/ModFile.hh
index 22a27a4c04eb7aa183168494ce64d786c5cb6826..5f0f68c3c2c303c1fdf0c02098866dcde7c755c7 100644
--- a/src/ModFile.hh
+++ b/src/ModFile.hh
@@ -163,7 +163,8 @@ public:
   void writeOutputFiles(const string &basename, bool clear_all, bool clear_global, bool no_log, bool no_warn,
                         bool console, bool nograph, bool nointeractive, const ConfigFile &config_file,
                         bool check_model_changes, bool minimal_workspace, bool compute_xrefs,
-                        const bool nopreprocessoroutput, const string &mexext, const boost::filesystem::path &matlabroot, const boost::filesystem::path &dynareroot) const;
+                        const bool nopreprocessoroutput, const string &mexext, const boost::filesystem::path &matlabroot,
+                        const boost::filesystem::path &dynareroot, bool onlymodel) const;
   void writeExternalFiles(const string &basename, FileOutputType output, LanguageOutputType language, const bool nopreprocessoroutput) const;
   void writeExternalFilesJulia(const string &basename, FileOutputType output, const bool nopreprocessoroutput) const;