diff --git a/src/ComputingTasks.cc b/src/ComputingTasks.cc
index 162d28fe4005e07996fb16519348cc0aa0c0588e..a804b83166f6e51e9d76062203a0ccbb48a3a2c4 100644
--- a/src/ComputingTasks.cc
+++ b/src/ComputingTasks.cc
@@ -668,8 +668,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 511f29c018f3368b512bbfca10d27e7c36c70a57..9237d34a9a3436325d766a533a1ce35f1ba9ec6a 100644
--- a/src/ModFile.cc
+++ b/src/ModFile.cc
@@ -166,6 +166,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