diff --git a/doc/manual/source/the-model-file.rst b/doc/manual/source/the-model-file.rst
index 4f7e6cf85cfa68b0bba0d6f649c8891a77338e2a..738448c7afb56ccc01844e86fe4812cc690ea797 100644
--- a/doc/manual/source/the-model-file.rst
+++ b/doc/manual/source/the-model-file.rst
@@ -1928,6 +1928,12 @@ in this case ``initval`` is used to specify the terminal conditions.
     in the last ``initval`` or ``endval`` block (or the steady state
     file if you provided one, see :ref:`st-st`).
 
+    *Options*
+
+    .. option:: non_zero
+
+        Only display non-zero residuals.
+
 .. command:: initval_file (OPTIONS...);
 
     |br| In a deterministic setup, this command is used to specify a
diff --git a/matlab/resid.m b/matlab/resid.m
index 19d316b56472a3208f4a2b505f16df5c70f2c466..9bcb336a854c794266b0a80a5e057addb831ca38 100644
--- a/matlab/resid.m
+++ b/matlab/resid.m
@@ -1,10 +1,10 @@
-function z = resid(junk)
-% function z = resid(junk)
+function z = resid(options_resid_)
+% function z = resid(options_resid_)
 %
 % Computes static residuals associated with the guess values.
 %
 % INPUTS
-%    junk:   dummy value for backward compatibility
+%    options_resid_:   options to resid
 %
 % OUTPUTS
 %    z:      residuals
@@ -12,7 +12,7 @@ function z = resid(junk)
 % SPECIAL REQUIREMENTS
 %    none
 
-% Copyright (C) 2001-2020 Dynare Team
+% Copyright (C) 2001-2022 Dynare Team
 %
 % This file is part of Dynare.
 %
@@ -31,10 +31,7 @@ function z = resid(junk)
 
 global M_ options_ oo_
 
-tagname = 'name';
-if nargin && ischar(junk)
-    tagname = junk;
-end
+non_zero = isfield(options_resid_, 'non_zero') && options_resid_.non_zero;
 
 tags  = M_.equations_tags;
 istag = 0;
@@ -80,24 +77,31 @@ if nargout == 0
     ind = [];
     disp('Residuals of the static equations:')
     skipline()
+    any_non_zero_residual = false;
     for i=1:M_.orig_eq_nbr
         if abs(z(i+M_.ramsey_eq_nbr)) < options_.solve_tolf/100
             tmp = 0;
         else
             tmp = z(i+M_.ramsey_eq_nbr);
+            any_non_zero_residual = true;
         end
         if istag
             tg = tags(cell2mat(tags(:,1)) == i,2:3); % all tags for equation i
-            ind = strmatch( tagname, cellstr( tg(:,1) ) );
+            ind = strmatch('name', cellstr( tg(:,1) ) );
         end
-        if ~istag || length(ind) == 0
-            disp(['Equation number ' int2str(i) ' : ' num2str(tmp)])
-        else
-            t1 = tg( ind , 2 );
-            s = cell2mat(t1);
-            disp( ['Equation number ', int2str(i) ,' : ', num2str(tmp) ,' : ' s])
+        if ~(non_zero && tmp == 0)
+            if ~istag || length(ind) == 0
+                disp(['Equation number ' int2str(i) ' : ' num2str(tmp)])
+            else
+                t1 = tg( ind , 2 );
+                s = cell2mat(t1);
+                disp( ['Equation number ', int2str(i) ,' : ', num2str(tmp) ,' : ' s])
+            end
         end
     end
+    if non_zero && ~any_non_zero_residual
+        disp('All residuals are zero')
+    end
     skipline(2)
 end
 
diff --git a/preprocessor b/preprocessor
index 17c5e1935d825bb815059a0bfcf67ee71a98daee..9db21a231c5ab8f8aa26680ffecf3abfcf45bfab 160000
--- a/preprocessor
+++ b/preprocessor
@@ -1 +1 @@
-Subproject commit 17c5e1935d825bb815059a0bfcf67ee71a98daee
+Subproject commit 9db21a231c5ab8f8aa26680ffecf3abfcf45bfab
diff --git a/tests/decision_rules/third_order/FV2011.mod b/tests/decision_rules/third_order/FV2011.mod
index 4fe714a1a580bebeb61af95ec5071a58eed67879..5b102eaf74f610e1feaaf5703a8f4e201d6388db 100644
--- a/tests/decision_rules/third_order/FV2011.mod
+++ b/tests/decision_rules/third_order/FV2011.mod
@@ -110,7 +110,7 @@ var u_sigma_tb; stderr 1;
 var u_sigma_r; stderr 1;
 end;
 
-resid(1);
+resid;
 
 options_.solve_tolf=1E-12;
 steady(solve_algo=3);
@@ -118,4 +118,4 @@ steady(solve_algo=3);
 check;
 stoch_simul(order=3,pruning,irf=0,nofunctions,contemporaneous_correlation,TeX) C I Y H r D K lambda phi; 
 
-comparison_policy_functions_dynare_mathematica;
\ No newline at end of file
+comparison_policy_functions_dynare_mathematica;
diff --git a/tests/ep/burnside.mod b/tests/ep/burnside.mod
index 595b4d9323a47fa30370c03e33c2827d527b35b2..958cb8f62f1c17ddc9087ba84dc3d22dd5ac92cb 100644
--- a/tests/ep/burnside.mod
+++ b/tests/ep/burnside.mod
@@ -22,7 +22,7 @@ x = xbar;
 y = beta*exp(theta*xbar)/(1-beta*exp(theta*xbar));
 end;
 
-resid(1);
+resid;
 
 steady;
 
diff --git a/tests/example1_with_tags.mod b/tests/example1_with_tags.mod
index af027aac191595f5d75abc1c267af776e82175b5..749382d4e14583d309a76046bd858238e00dda0e 100644
--- a/tests/example1_with_tags.mod
+++ b/tests/example1_with_tags.mod
@@ -48,4 +48,4 @@ e = 0;
 u = 0;
 end;
 
-resid('title');
\ No newline at end of file
+resid(non_zero);
diff --git a/tests/loglinear/example4_exp.mod b/tests/loglinear/example4_exp.mod
index 40b6613886a2421e272871ac1a568bc4f93450ba..9ebad8f8ba30e1bb5365f3c0620838d44196fc7c 100644
--- a/tests/loglinear/example4_exp.mod
+++ b/tests/loglinear/example4_exp.mod
@@ -4,7 +4,7 @@
  */
 
 /*
- * Copyright (C) 2001-2016 Dynare Team
+ * Copyright (C) 2001-2022 Dynare Team
  *
  * This file is part of Dynare.
  *
@@ -56,7 +56,7 @@ k = log(11.08360443260358);
 a = 0;
 b = 0;
 end;
-resid(1);
+resid;
 shocks;
 var e; stderr 0.009;
 var u; stderr 0.009;
@@ -78,4 +78,4 @@ conditional_forecast(parameter_set=calibration, controlled_varexo=(u,e));
 
 oo_exp=oo_;
 conditional_forecasts_exp=oo_.conditional_forecast;
-save results_exp.mat oo_exp conditional_forecasts_exp
\ No newline at end of file
+save results_exp.mat oo_exp conditional_forecasts_exp
diff --git a/tests/loglinear/example4_exp_histval.mod b/tests/loglinear/example4_exp_histval.mod
index d0b7a90bc7139e298c719ff94842ab997edf2c85..ed01394dbb9c2466373b570049f386d8895d4ab1 100644
--- a/tests/loglinear/example4_exp_histval.mod
+++ b/tests/loglinear/example4_exp_histval.mod
@@ -4,7 +4,7 @@
  */
 
 /*
- * Copyright (C) 2001-2016 Dynare Team
+ * Copyright (C) 2001-2022 Dynare Team
  *
  * This file is part of Dynare.
  *
@@ -56,7 +56,7 @@ k = log(11.08360443260358);
 a = 0;
 b = 0;
 end;
-resid(1);
+resid;
 shocks;
 var e; stderr 0.009;
 var u; stderr 0.009;
diff --git a/tests/loglinear/example4_loglinear.mod b/tests/loglinear/example4_loglinear.mod
index e0f7a6f1d69eed18cfc2c52f86c33e7c9f7622b9..1f7df590e2d48fec2a974ed9d3091f6310d28378 100644
--- a/tests/loglinear/example4_loglinear.mod
+++ b/tests/loglinear/example4_loglinear.mod
@@ -4,7 +4,7 @@
  */
 
 /*
- * Copyright (C) 2001-2010 Dynare Team
+ * Copyright (C) 2001-2022 Dynare Team
  *
  * This file is part of Dynare.
  *
@@ -56,7 +56,7 @@ k = 11.08360443260358;
 a = 1;
 b = 1;
 end;
-resid(1);
+resid;
 steady;
 
 shocks;
@@ -132,4 +132,4 @@ end
 stoch_simul(loglinear,order=1,periods=100000);
 if abs(mean(y)-0.0776)>0.02
     error('Simulations are wrong')
-end
\ No newline at end of file
+end
diff --git a/tests/loglinear/example4_loglinear_histval.mod b/tests/loglinear/example4_loglinear_histval.mod
index c5617e12bf09afd865ba0885af5e42cfb08b2386..a21705f7305670432c787fb31e2648eb0650c2ec 100644
--- a/tests/loglinear/example4_loglinear_histval.mod
+++ b/tests/loglinear/example4_loglinear_histval.mod
@@ -4,7 +4,7 @@
  */
 
 /*
- * Copyright (C) 2001-2010 Dynare Team
+ * Copyright (C) 2001-2022 Dynare Team
  *
  * This file is part of Dynare.
  *
@@ -57,7 +57,7 @@ a = 1;
 b = 1;
 end;
 
-resid(1);
+resid;
 shocks;
 var e; stderr 0.009;
 var u; stderr 0.009;
diff --git a/tests/risky_ss/jermann98.mod b/tests/risky_ss/jermann98.mod
index 5633d5bbc865a92c004b1ddb2c860fec97afa3b6..80e50c156326bafc7f957a110caf931e08c0a02e 100644
--- a/tests/risky_ss/jermann98.mod
+++ b/tests/risky_ss/jermann98.mod
@@ -78,7 +78,7 @@ mu     = ((c-(chihab*c/g))^(-tau))-chihab*bet*((c*g-chihab*c)^(-tau));
 ez     = 0;
 end;
 
-resid(1);
+resid;
 
 steady;                      
 
diff --git a/tests/risky_ss/jermann98_2.mod b/tests/risky_ss/jermann98_2.mod
index 4b28bd1d30034c684648a1749038ef5d94232958..0309f66ee8128b03b66a8403760a3809689404c8 100644
--- a/tests/risky_ss/jermann98_2.mod
+++ b/tests/risky_ss/jermann98_2.mod
@@ -78,7 +78,7 @@ mu     = (((c-(chihab*c/g))^(-tau))-chihab*bet*((c*g-chihab*c)^(-tau)))/1e4;
 ez     = 0;
 end;
 
-resid(1);
+resid;
 
 steady;                      
 
diff --git a/tests/risky_ss/jermann98_3.mod b/tests/risky_ss/jermann98_3.mod
index e008cd07e75d3bdbac3aaf39707a869251b2b578..6135956fc274928600edc50b6dda5741c931d2fb 100644
--- a/tests/risky_ss/jermann98_3.mod
+++ b/tests/risky_ss/jermann98_3.mod
@@ -78,7 +78,7 @@ mu     = (((c-(chihab*c/g))^(-tau))-chihab*bet*((c*g-chihab*c)^(-tau)))/1e4;
 ez     = 0;
 end;
 
-resid(1);
+resid;
 
 steady;                      
 
diff --git a/tests/second_order/burnside_1.mod b/tests/second_order/burnside_1.mod
index 5c9906f7c098f4ddfdcc1cb149cff799bda0f5e4..3ce22a0bb7883f15d56bcb3676799ca151d4dbcc 100644
--- a/tests/second_order/burnside_1.mod
+++ b/tests/second_order/burnside_1.mod
@@ -22,7 +22,7 @@ x = xbar;
 y = beta*exp(theta*xbar)/(1-beta*exp(theta*xbar));
 end;
 
-resid(1);
+resid;
 
 steady;
 
diff --git a/tests/second_order/ds1.mod b/tests/second_order/ds1.mod
index ef4e6365979ce2fb4db73598b16e509d87db98f6..0b0958e171e0e473bae0558141003b9c3e850fcb 100644
--- a/tests/second_order/ds1.mod
+++ b/tests/second_order/ds1.mod
@@ -62,7 +62,7 @@ initval;
   ze_1 = log(betabar)+yk_1;
 end;
 
-resid(1);
+resid;
 steady;
 model_diagnostics;
 check;
diff --git a/tests/second_order/ds2.mod b/tests/second_order/ds2.mod
index 45a92208e637111f5d07c00a89687f07752c7840..90b7f5706beb410f9e67241432b1fb364aacf82b 100644
--- a/tests/second_order/ds2.mod
+++ b/tests/second_order/ds2.mod
@@ -62,7 +62,7 @@ initval;
   ze_1 = log(betabar)+yk_1;
 end;
 
-resid(1);
+resid;
 steady;
 model_diagnostics;
 check;
@@ -74,4 +74,4 @@ oo2 = oo_.dr;
 if any(abs(oo1.ghxx-oo2.ghxx) > 1e-14);error('ds1 with missing variable doesn''t reproduce ds2');end;
 if any(abs(oo1.ghuu-oo2.ghuu) > 1e-14);error('ds1 with missing variable doesn''t reproduce ds2');end;
 if any(abs(oo1.ghxu-oo2.ghxu) > 1e-14);error('ds1 with missing variable doesn''t reproduce ds2');end;
-if any(abs(oo1.ghs2-oo2.ghs2) > 1e-14);error('ds1 with missing variable doesn''t reproduce ds2');end;
\ No newline at end of file
+if any(abs(oo1.ghs2-oo2.ghs2) > 1e-14);error('ds1 with missing variable doesn''t reproduce ds2');end;
diff --git a/tests/simul/Solow_no_varexo.mod b/tests/simul/Solow_no_varexo.mod
index 42de8ec69cad656588b8e23254828c6f592f0b66..effb75d7dda8d92d8b6038e06085848d6ec5fa6f 100644
--- a/tests/simul/Solow_no_varexo.mod
+++ b/tests/simul/Solow_no_varexo.mod
@@ -58,7 +58,7 @@ y=k^alpha;
 c=(1-s)*y;
 invest=y-c;
 end;
-resid(1);
+resid;
 steady;
 
 simul(periods=200, solve_algo=4);