diff --git a/src/NumericalInitialization.cc b/src/NumericalInitialization.cc
index bd498c473cbbe29428300f1297ce69e71b845d27..84f48893c987802243ee969e0c1dbfba36ad65ac 100644
--- a/src/NumericalInitialization.cc
+++ b/src/NumericalInitialization.cc
@@ -187,6 +187,12 @@ void
 InitValStatement::checkPass([[maybe_unused]] ModFileStructure &mod_file_struct,
                             [[maybe_unused]] WarningConsolidation &warnings)
 {
+  if (mod_file_struct.endval_present)
+    {
+      cerr << "ERROR: an 'initval' block cannot appear after an 'endval' block" << endl; // See #104
+      exit(EXIT_FAILURE);
+    }
+
   set<int> exogs = getUninitializedVariables(SymbolType::exogenous);
   set<int> endogs = getUninitializedVariables(SymbolType::endogenous);
 
@@ -253,6 +259,8 @@ void
 EndValStatement::checkPass([[maybe_unused]] ModFileStructure &mod_file_struct,
                            [[maybe_unused]] WarningConsolidation &warnings)
 {
+  mod_file_struct.endval_present = true;
+
   set<int> exogs = getUninitializedVariables(SymbolType::exogenous);
   set<int> endogs = getUninitializedVariables(SymbolType::endogenous);
 
diff --git a/src/Statement.hh b/src/Statement.hh
index 6a8bdc7f44665cfcb3ca926ff6bc9fc43c75769f..3fba939506c80867c5bd7dfefaf2f5d80dce06fd 100644
--- a/src/Statement.hh
+++ b/src/Statement.hh
@@ -157,6 +157,8 @@ struct ModFileStructure
   /* Lists symbol IDs of parameters that appear in a “planner_discount” option.
      See dynare#1173 for more details. */
   set<int> parameters_in_planner_discount;
+  // Whether an endval block (without the learnt_it=… option) appears
+  bool endval_present{false};
   // Whether a shocks(surprise) block appears
   bool shocks_surprise_present{false};
   // Whether a shocks(learnt_in=…) block appears