From 9aa02c28ffcdbe04315eb27e5d7f73275140fb0b Mon Sep 17 00:00:00 2001
From: michel <michel@ac1d8469-bf42-47a9-8791-bf33cf982152>
Date: Fri, 20 Mar 2009 11:07:41 +0000
Subject: [PATCH] 4.0: merged r2420 changeset from trunk (bug in
 moments_varendo)

git-svn-id: https://www.dynare.org/svn/dynare/branches/4.0@2489 ac1d8469-bf42-47a9-8791-bf33cf982152
---
 matlab/check_posterior_analysis_data.m | 7 +++++--
 matlab/selec_posterior_draws.m         | 2 +-
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/matlab/check_posterior_analysis_data.m b/matlab/check_posterior_analysis_data.m
index d474bdaf77..f543944422 100644
--- a/matlab/check_posterior_analysis_data.m
+++ b/matlab/check_posterior_analysis_data.m
@@ -31,14 +31,17 @@ function [info,description] = check_posterior_analysis_data(type,M_)
     mhdate = get_date_of_a_file(mhname);
     
     %% Get informations about _posterior_draws files.
-    if ~exist([ M_.dname '/metropolis/' M_.fname '_posterior_draws.mat'])
+    drawsinfo = dir([ M_.dname '/metropolis/' M_.fname '_posterior_draws*.mat']);
+    if isempty(drawsinfo)
         info = 1; % select_posterior_draws has to be called first.
         if nargout>1
             description = 'select_posterior_draws has to be called.';
         end
         return
     else
-        pddate = get_date_of_a_file([ M_.dname '/metropolis/' M_.fname '_posterior_draws.mat']);
+        number_of_last_posterior_draws_file = length(drawsinfo);
+        pddate = get_date_of_a_file([ M_.dname '/metropolis/' M_.fname '_posterior_draws'...
+                            int2str(number_of_last_posterior_draws_file) '.mat']);
         if pddate<mhdate
             info = 2; % _posterior_draws files have to be updated.
             if nargout>1
diff --git a/matlab/selec_posterior_draws.m b/matlab/selec_posterior_draws.m
index 8749fdd7cc..0c3c9cadc4 100644
--- a/matlab/selec_posterior_draws.m
+++ b/matlab/selec_posterior_draws.m
@@ -118,7 +118,7 @@ function SampleAddress = selec_posterior_draws(SampleSize,drsize)
                 old_mhblck = mhblck;
             end
             clear('x2')
-            save([fname '_posterior_draws'],'pdraws')
+            save([fname '_posterior_draws1'],'pdraws')
         else% The posterior draws are saved in xx files.
             NumberOfDrawsPerFile = fix(MAX_mega_bytes/drawsize);
             NumberOfFiles = ceil(SampleSize*drawsize/MAX_mega_bytes);      
-- 
GitLab