diff --git a/src/ComputingTasks.cc b/src/ComputingTasks.cc
index a6d2c561645240d9322c15fba5c0cf3f065be94a..22b33b213ad9fe9e04f18ebdba841ebef9af3b7f 100644
--- a/src/ComputingTasks.cc
+++ b/src/ComputingTasks.cc
@@ -545,8 +545,7 @@ RamseyConstraintsStatement::RamseyConstraintsStatement(const SymbolTable &symbol
 void
 RamseyConstraintsStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings)
 {
-  if (!mod_file_struct.ramsey_model_present && !mod_file_struct.ramsey_policy_present)
-    cerr << "ramsey_constraints: can only be used with ramsey_model or ramsey_policy" << endl;
+  mod_file_struct.ramsey_constraints_present = true;
 }
 
 void
diff --git a/src/ModFile.cc b/src/ModFile.cc
index ceac9f32867de4c970ca4b85476d3b242f300f6b..c16a5ab22b007798bbdec72e70842b8a06b10d87 100644
--- a/src/ModFile.cc
+++ b/src/ModFile.cc
@@ -170,6 +170,12 @@ ModFile::checkPass(bool nostrict, bool stochastic)
       exit(EXIT_FAILURE);
     }
 
+  if (mod_file_struct.ramsey_constraints_present && !mod_file_struct.ramsey_model_present && !mod_file_struct.ramsey_policy_present)
+    {
+      cerr << "ERROR: A ramsey_constraints block requires the presence of a ramsey_model or ramsey_policy statement" << endl;
+      exit(EXIT_FAILURE);
+    }
+
   if ((mod_file_struct.osr_present && (!mod_file_struct.osr_params_present || !mod_file_struct.optim_weights_present))
       || ((!mod_file_struct.osr_present || !mod_file_struct.osr_params_present) && mod_file_struct.optim_weights_present)
       || ((!mod_file_struct.osr_present || !mod_file_struct.optim_weights_present) && mod_file_struct.osr_params_present))
diff --git a/src/Statement.hh b/src/Statement.hh
index 24d0d46369bbea41435b14988e19c2adcf71f5cf..57d36061f6153798820a5e0095a71195d26230cb 100644
--- a/src/Statement.hh
+++ b/src/Statement.hh
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2006-2021 Dynare Team
+ * Copyright © 2006-2022 Dynare Team
  *
  * This file is part of Dynare.
  *
@@ -149,6 +149,8 @@ public:
   bool shocks_surprise_present{false};
   // Whether an occbin_constraints block appears
   bool occbin_constraints_present{false};
+  // Whether a ramsey_constraints block appears
+  bool ramsey_constraints_present{false};
 };
 
 class Statement