From 330b41371a069acadf993ecf9ed91c2f3913d767 Mon Sep 17 00:00:00 2001
From: Marco Ratto <marco.ratto@jrc.ec.europa.eu>
Date: Thu, 15 Mar 2012 15:58:10 +0100
Subject: [PATCH] fixed bugs when GSA asks to evaluate only the  likelihood
 without any filter/smoother;

---
 matlab/prior_posterior_statistics.m      | 14 ++++++++------
 matlab/prior_posterior_statistics_core.m |  6 +++---
 2 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/matlab/prior_posterior_statistics.m b/matlab/prior_posterior_statistics.m
index 6951d6863..b51ea04cc 100644
--- a/matlab/prior_posterior_statistics.m
+++ b/matlab/prior_posterior_statistics.m
@@ -222,12 +222,14 @@ else
     [nCPU, totCPU, nBlockPerCPU] = distributeJobs(options_.parallel, 1, B);
     ifil=zeros(7,totCPU);
     for j=1:totCPU-1,
-        nfiles = ceil(nBlockPerCPU(j)/MAX_nsmoo);
-        ifil(1,j+1) =ifil(1,j)+nfiles;
-        nfiles = ceil(nBlockPerCPU(j)/MAX_ninno);
-        ifil(2,j+1) =ifil(2,j)+nfiles;
-        nfiles = ceil(nBlockPerCPU(j)/MAX_nerro);
-        ifil(3,j+1) =ifil(3,j)+nfiles;
+        if run_smoother
+            nfiles = ceil(nBlockPerCPU(j)/MAX_nsmoo);
+            ifil(1,j+1) =ifil(1,j)+nfiles;
+            nfiles = ceil(nBlockPerCPU(j)/MAX_ninno);
+            ifil(2,j+1) =ifil(2,j)+nfiles;
+            nfiles = ceil(nBlockPerCPU(j)/MAX_nerro);
+            ifil(3,j+1) =ifil(3,j)+nfiles;
+        end
         if naK
             nfiles = ceil(nBlockPerCPU(j)/MAX_naK);
             ifil(4,j+1) =ifil(4,j)+nfiles;
diff --git a/matlab/prior_posterior_statistics_core.m b/matlab/prior_posterior_statistics_core.m
index 802424b00..a0747b62a 100644
--- a/matlab/prior_posterior_statistics_core.m
+++ b/matlab/prior_posterior_statistics_core.m
@@ -163,7 +163,7 @@ for b=fpar:B
     end
     set_all_parameters(deep);
     [dr,info] = resol(oo_.steady_state,0);
-
+    SteadyState = dr.ys;
     if run_smoother
         [alphahat,etahat,epsilonhat,alphatilde,SteadyState,trend_coeff,aK] = ...
             DsgeSmoother(deep,gend,Y,data_index,missing_value);
@@ -225,7 +225,7 @@ for b=fpar:B
     irun = irun +  ones(7,1);
 
 
-    if irun(1) > MAX_nsmoo || b == B
+    if run_smoother && (irun(1) > MAX_nsmoo || b == B)
         stock = stock_smooth(:,:,1:irun(1)-1);
         ifil(1) = ifil(1) + 1;
         save([DirectoryName '/' M_.fname '_smooth' int2str(ifil(1)) '.mat'],'stock');
@@ -239,7 +239,7 @@ for b=fpar:B
         irun(1) = 1;
     end
 
-    if irun(2) > MAX_ninno || b == B
+    if run_smoother && (irun(2) > MAX_ninno || b == B)
         stock = stock_innov(:,:,1:irun(2)-1);
         ifil(2) = ifil(2) + 1;
         save([DirectoryName '/' M_.fname '_inno' int2str(ifil(2)) '.mat'],'stock');
-- 
GitLab