Home > matlab > pm3_core.m

pm3_core

PURPOSE ^

PARALLEL CONTEXT

SYNOPSIS ^

function myoutput=pm3_core(myinputs,fpar,nvar,whoiam, ThisMatlab)

DESCRIPTION ^

 PARALLEL CONTEXT
 Core functionality for pm3.m function, which can be parallelized.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function myoutput=pm3_core(myinputs,fpar,nvar,whoiam, ThisMatlab)
0002 
0003 % PARALLEL CONTEXT
0004 % Core functionality for pm3.m function, which can be parallelized.
0005 
0006 % INPUTS
0007 % See the comment in random_walk_metropolis_hastings_core.m funtion.
0008 
0009 % OUTPUTS
0010 % o myoutput  [struc]
0011 %
0012 %
0013 % ALGORITHM
0014 %   Portion of McMCDiagnostics.m function.
0015 %
0016 % SPECIAL REQUIREMENTS.
0017 %   None.
0018 
0019 % Copyright (C) 2007-2011 Dynare Team
0020 %
0021 % This file is part of Dynare.
0022 %
0023 % Dynare is free software: you can redistribute it and/or modify
0024 % it under the terms of the GNU General Public License as published by
0025 % the Free Software Foundation, either version 3 of the License, or
0026 % (at your option) any later version.
0027 %
0028 % Dynare is distributed in the hope that it will be useful,
0029 % but WITHOUT ANY WARRANTY; without even the implied warranty of
0030 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0031 % GNU General Public License for more details.
0032 %
0033 % You should have received a copy of the GNU General Public License
0034 % along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
0035 
0036 if nargin<4,
0037     whoiam=0;
0038 end
0039 
0040 % Reshape 'myinputs' for local computation.
0041 % In order to avoid confusion in the name space, the instruction struct2local(myinputs) is replaced by:
0042 
0043 tit1=myinputs.tit1;
0044 nn=myinputs.nn;
0045 n2=myinputs.n2;
0046 Distrib=myinputs.Distrib;
0047 varlist=myinputs.varlist;
0048 MaxNumberOfPlotsPerFigure=myinputs.MaxNumberOfPlotsPerFigure;
0049 name3=myinputs.name3;
0050 tit3=myinputs.tit3;
0051 Mean=myinputs.Mean;
0052 
0053 if whoiam
0054     Parallel=myinputs.Parallel;
0055 end
0056 
0057 
0058 global options_ M_ oo_
0059 
0060 
0061 if whoiam
0062     prct0={0,whoiam,Parallel(ThisMatlab)};
0063     h = dyn_waitbar(prct0,'Parallel plots pm3 ...');
0064 end
0065 
0066 
0067 
0068 figunumber = 0;
0069 subplotnum = 0;
0070 hh = dyn_figure(options_,'Name',[tit1 ' ' int2str(figunumber+1)]);
0071 RemoteFlag = 0;
0072 if whoiam,
0073     if Parallel(ThisMatlab).Local ==0
0074         RemoteFlag=1;
0075     end
0076 end
0077 
0078 OutputFileName = {};
0079 
0080 for i=fpar:nvar
0081     if max(abs(Mean(:,i))) > 10^(-6)
0082         subplotnum = subplotnum+1;
0083         set(0,'CurrentFigure',hh);
0084         subplot(nn,nn,subplotnum);
0085         plot([1 n2],[0 0],'-r','linewidth',0.5);
0086         hold on
0087         for k = 1:9
0088             plot(1:n2,squeeze(Distrib(k,:,i)),'-g','linewidth',0.5);
0089         end
0090         plot(1:n2,Mean(:,i),'-k','linewidth',1);
0091         xlim([1 n2]);
0092         hold off;
0093         name = deblank(varlist(i,:));
0094         title(name,'Interpreter','none')
0095     end
0096     
0097     if whoiam,
0098         if Parallel(ThisMatlab).Local==0
0099             DirectoryName = CheckPath('Output',M_.dname);
0100         end
0101     end
0102     
0103     if subplotnum == MaxNumberOfPlotsPerFigure || i == nvar
0104         dyn_saveas(hh,[M_.dname '/Output/'  M_.fname '_' name3 '_' deblank(tit3(i,:))],options_);
0105         if RemoteFlag==1,
0106             OutputFileName = [OutputFileName; {[M_.dname, filesep, 'Output',filesep], [M_.fname '_' name3 '_' deblank(tit3(i,:)) '.*']}];
0107         end
0108         subplotnum = 0;
0109         figunumber = figunumber+1;
0110         if (i ~= nvar)
0111             hh = dyn_figure(options_,'Name',[name3 ' ' int2str(figunumber+1)]);
0112         end
0113     end
0114     
0115     if whoiam,
0116 %         waitbarString = [ 'Variable ' int2str(i) '/' int2str(nvar) ' done.'];
0117 %         fMessageStatus((i-fpar+1)/(nvar-fpar+1),whoiam,waitbarString, waitbarTitle, Parallel(ThisMatlab));
0118         dyn_waitbar((i-fpar+1)/(nvar-fpar+1),h);
0119     end
0120     
0121     
0122 end
0123 
0124 if whoiam,
0125     dyn_waitbar_close(h);
0126 end
0127 myoutput.OutputFileName=OutputFileName;

Generated on Tue 22-May-2012 02:40:23 by m2html © 2005