From d6faa478074b33ce0131ed5e0c373f6f5ae8def7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= Date: Mon, 15 Feb 2010 16:52:36 +0100 Subject: [PATCH] Cosmetic changes: converted files to Unix end-of-line convention + fixed copyright notices and dates --- matlab/AnalyseComputationalEnviroment.m | 2 +- matlab/DiffuseKalmanSmoother1.m | 2 +- matlab/GiveCPUnumber.m | 114 +++++++++++------------ matlab/McMCDiagnostics.m | 2 +- matlab/PosteriorIRF.m | 2 +- matlab/PosteriorIRF_core1.m | 2 +- matlab/PosteriorIRF_core2.m | 17 ++++ matlab/ReshapeMatFiles.m | 2 +- matlab/Tracing.m | 77 ++++++++------- matlab/closeSlave.m | 45 ++++++--- matlab/distributeJobs.m | 73 +++++++-------- matlab/global_initialization.m | 2 +- matlab/independent_metropolis_hastings.m | 2 +- matlab/masterParallel.m | 2 +- matlab/masterParallelMan.m | 2 +- matlab/pm3.m | 2 +- matlab/pm3_core.m | 16 ++++ matlab/prior_posterior_statistics.m | 2 +- matlab/prior_posterior_statistics_core.m | 16 ++++ matlab/random_walk_metropolis_hastings.m | 2 +- 20 files changed, 222 insertions(+), 162 deletions(-) diff --git a/matlab/AnalyseComputationalEnviroment.m b/matlab/AnalyseComputationalEnviroment.m index 3453e1cc0..949b89dfa 100644 --- a/matlab/AnalyseComputationalEnviroment.m +++ b/matlab/AnalyseComputationalEnviroment.m @@ -59,7 +59,7 @@ function [ErrorCode] = AnalyseComputationalEnviroment(DataInput) % Then at the point call of this function it is possible react in a best way, in accord % with the ErrorCode. -% Copyright (C) 2009 Dynare Team +% Copyright (C) 2009-2010 Dynare Team % % This file is part of Dynare. % diff --git a/matlab/DiffuseKalmanSmoother1.m b/matlab/DiffuseKalmanSmoother1.m index f23f9de7a..940befdeb 100644 --- a/matlab/DiffuseKalmanSmoother1.m +++ b/matlab/DiffuseKalmanSmoother1.m @@ -27,7 +27,7 @@ function [alphahat,etahat,atilde, aK] = DiffuseKalmanSmoother1(T,R,Q,Pinf1,Pstar % Models", S.J. Koopman and J. Durbin (2003, in Journal of Time Series % Analysis, vol. 24(1), pp. 85-98). -% Copyright (C) 2004-2008 Dynare Team +% Copyright (C) 2004-2008,2010 Dynare Team % % This file is part of Dynare. % diff --git a/matlab/GiveCPUnumber.m b/matlab/GiveCPUnumber.m index ba11bfab1..2809d1696 100644 --- a/matlab/GiveCPUnumber.m +++ b/matlab/GiveCPUnumber.m @@ -1,58 +1,56 @@ -function [nCPU]= GiveCPUnumber (ComputerInformations) - -% DESCRIPTION -% This function return the CPUs or cores numer avaiable -% on the computer used for run parallel code. - -% INPUTS -% an array contained several fields that describe the hardaware -% software enviroments of a generic computer. -% -% OUTPUTS -% The CPUs or Cores numbers of computer. -% -% SPECIAL REQUIREMENTS -% none - -% Copyright (C) 2005-2009 Dynare Team -% -% This file is part of Dynare. -% -% Dynare is free software: you can redistribute it and/or modify -% it under the terms of the GNU General Public License as published by -% the Free Software Foundation, either version 3 of the License, or -% (at your option) any later version. -% -% Dynare is distributed in the hope that it will be useful, -% but WITHOUT ANY WARRANTY; without even the implied warranty of -% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -% GNU General Public License for more details. -% -% You should have received a copy of the GNU General Public License -% along with Dynare. If not, see . - - -nCPU=-1; - -OffSet=27; - -SringPosition=strfind(ComputerInformations, 'Processors:'); -nCPU=ComputerInformations(SringPosition+OffSet); - -% We check if there are Processors/Cores more than 9. - - - t0=ComputerInformations(SringPosition+OffSet+1); - t1=str2num(t0); - t1=isempty(t1); - - % if t1 is 0 the machine have more than 9 CPU. - - if t1==0 - nCPU=strcat(nCPU,t0); - end - - nCPU=str2num(nCPU); - - return - \ No newline at end of file +function [nCPU]= GiveCPUnumber (ComputerInformations) +% DESCRIPTION +% This function return the CPUs or cores numer avaiable +% on the computer used for run parallel code. +% +% INPUTS +% an array contained several fields that describe the hardaware +% software enviroments of a generic computer. +% +% OUTPUTS +% The CPUs or Cores numbers of computer. +% +% SPECIAL REQUIREMENTS +% none + +% Copyright (C) 2010 Dynare Team +% +% This file is part of Dynare. +% +% Dynare is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% Dynare is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with Dynare. If not, see . + + +nCPU=-1; + +OffSet=27; + +SringPosition=strfind(ComputerInformations, 'Processors:'); +nCPU=ComputerInformations(SringPosition+OffSet); + +% We check if there are Processors/Cores more than 9. + + +t0=ComputerInformations(SringPosition+OffSet+1); +t1=str2num(t0); +t1=isempty(t1); + +% if t1 is 0 the machine have more than 9 CPU. + +if t1==0 + nCPU=strcat(nCPU,t0); +end + +nCPU=str2num(nCPU); + +return diff --git a/matlab/McMCDiagnostics.m b/matlab/McMCDiagnostics.m index c90b67464..5763d8ed1 100644 --- a/matlab/McMCDiagnostics.m +++ b/matlab/McMCDiagnostics.m @@ -13,7 +13,7 @@ function McMCDiagnostics(options_, estim_params_, M_) % SPECIAL REQUIREMENTS % none -% Copyright (C) 2005-2008 Dynare Team +% Copyright (C) 2005-2008,2010 Dynare Team % % This file is part of Dynare. % diff --git a/matlab/PosteriorIRF.m b/matlab/PosteriorIRF.m index 47548110d..4431e79dd 100644 --- a/matlab/PosteriorIRF.m +++ b/matlab/PosteriorIRF.m @@ -11,7 +11,7 @@ function PosteriorIRF(type) % SPECIAL REQUIREMENTS % None -% Copyright (C) 2006-2008 Dynare Team +% Copyright (C) 2006-2008,2010 Dynare Team % % This file is part of Dynare. % diff --git a/matlab/PosteriorIRF_core1.m b/matlab/PosteriorIRF_core1.m index 27637e636..9d376ae8f 100644 --- a/matlab/PosteriorIRF_core1.m +++ b/matlab/PosteriorIRF_core1.m @@ -12,7 +12,7 @@ function myoutput=PosteriorIRF_core1(myinputs,fpar,npar,whoiam, ThisMatlab) % SPECIAL REQUIREMENTS % None -% Copyright (C) 2006-2008 Dynare Team +% Copyright (C) 2006-2008,2010 Dynare Team % % This file is part of Dynare. % diff --git a/matlab/PosteriorIRF_core2.m b/matlab/PosteriorIRF_core2.m index 2a8846b63..0f1e33046 100644 --- a/matlab/PosteriorIRF_core2.m +++ b/matlab/PosteriorIRF_core2.m @@ -1,5 +1,22 @@ function myoutput=PosteriorIRF_core2(myinputs,fpar,npar,whoiam, ThisMatlab) +% Copyright (C) 2006-2008,2010 Dynare Team +% +% This file is part of Dynare. +% +% Dynare is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% Dynare is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with Dynare. If not, see . + global options_ M_ if nargin<4, diff --git a/matlab/ReshapeMatFiles.m b/matlab/ReshapeMatFiles.m index 950958e02..09217c1c5 100644 --- a/matlab/ReshapeMatFiles.m +++ b/matlab/ReshapeMatFiles.m @@ -25,7 +25,7 @@ function ReshapeMatFiles(type, type2) % SPECIAL REQUIREMENTS % none -% Copyright (C) 2003-2007 Dynare Team +% Copyright (C) 2003-2007,2010 Dynare Team % % This file is part of Dynare. % diff --git a/matlab/Tracing.m b/matlab/Tracing.m index e3814552f..7d0e947c9 100644 --- a/matlab/Tracing.m +++ b/matlab/Tracing.m @@ -1,40 +1,37 @@ -function [] = Tracing() - -% DESCRIPTION -% This function is used to test the correct execution of a matlab section -% on remote machine. -% -% If no error happen the function simply create a file. - -% INPUTS -% ... -% -% OUTPUTS -% ... -% -% SPECIAL REQUIREMENTS -% none - -% Copyright (C) 2005-2009 Dynare Team -% -% This file is part of Dynare. -% -% Dynare is free software: you can redistribute it and/or modify -% it under the terms of the GNU General Public License as published by -% the Free Software Foundation, either version 3 of the License, or -% (at your option) any later version. -% -% Dynare is distributed in the hope that it will be useful, -% but WITHOUT ANY WARRANTY; without even the implied warranty of -% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -% GNU General Public License for more details. -% -% You should have received a copy of the GNU General Public License -% along with Dynare. If not, see . - - - fid = fopen('Tracing.txt','w+'); - fclose (fid); - -exit - +function [] = Tracing() +% DESCRIPTION +% This function is used to test the correct execution of a matlab section +% on remote machine. +% +% If no error happen the function simply create a file. +% +% INPUTS +% ... +% +% OUTPUTS +% ... +% +% SPECIAL REQUIREMENTS +% none + +% Copyright (C) 2010 Dynare Team +% +% This file is part of Dynare. +% +% Dynare is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% Dynare is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with Dynare. If not, see . + +fid = fopen('Tracing.txt','w+'); +fclose (fid); + +exit diff --git a/matlab/closeSlave.m b/matlab/closeSlave.m index 8615606b6..150127ada 100644 --- a/matlab/closeSlave.m +++ b/matlab/closeSlave.m @@ -1,14 +1,31 @@ -function closeSlave(Parallel), -% In a parallelc context, this utility closes all remote matlab instances -% called by masteParallelMan (which leaves open remote matlab instances) - -delete( 'slaveParallel_input*.mat'); -for indPC=1:length(Parallel), - if Parallel(indPC).Local==0, - if isunix || (~matlab_ver_less_than('7.4') && ismac), - system(['ssh ',Parallel(indPC).user,'@',Parallel(indPC).PcName,' rm -fr ',Parallel(indPC).RemoteFolder,'/slaveParallel_input*.mat']); - else - mydelete('slaveParallel_input*.mat',['\\',Parallel(indPC).PcName,'\',Parallel(indPC).RemoteDrive,'$\',Parallel(indPC).RemoteFolder,'\']); - end - end -end +function closeSlave(Parallel), +% In a parallelc context, this utility closes all remote matlab instances +% called by masteParallelMan (which leaves open remote matlab instances) + +% Copyright (C) 2010 Dynare Team +% +% This file is part of Dynare. +% +% Dynare is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% Dynare is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with Dynare. If not, see . + +delete( 'slaveParallel_input*.mat'); +for indPC=1:length(Parallel), + if Parallel(indPC).Local==0, + if isunix || (~matlab_ver_less_than('7.4') && ismac), + system(['ssh ',Parallel(indPC).user,'@',Parallel(indPC).PcName,' rm -fr ',Parallel(indPC).RemoteFolder,'/slaveParallel_input*.mat']); + else + mydelete('slaveParallel_input*.mat',['\\',Parallel(indPC).PcName,'\',Parallel(indPC).RemoteDrive,'$\',Parallel(indPC).RemoteFolder,'\']); + end + end +end diff --git a/matlab/distributeJobs.m b/matlab/distributeJobs.m index 492f47cd8..3ef9b0d93 100644 --- a/matlab/distributeJobs.m +++ b/matlab/distributeJobs.m @@ -1,37 +1,36 @@ -function [nCPU, totCPU, nBlockPerCPU] = distributeJobs(Parallel, fBlock, nBlock) - -% Determine the total number of available CPUs, and the number of threads to run on each CPU - -% Copyright (C) 2009 Dynare Team -% -% This file is part of Dynare. -% -% Dynare is free software: you can redistribute it and/or modify -% it under the terms of the GNU General Public License as published by -% the Free Software Foundation, either version 3 of the License, or -% (at your option) any later version. -% -% Dynare is distributed in the hope that it will be useful, -% but WITHOUT ANY WARRANTY; without even the implied warranty of -% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -% GNU General Public License for more details. -% -% You should have received a copy of the GNU General Public License -% along with Dynare. If not, see . - -totCPU=0; -for j=1:length(Parallel), - nCPU(j)=length(Parallel(j).NumCPU); - totCPU=totCPU+nCPU(j); -end - -nCPU=cumsum(nCPU); -offset0 = fBlock-1; -if (nBlock-offset0)>totCPU, - diff = mod((nBlock-offset0),totCPU); - nBlockPerCPU(1:diff) = ceil((nBlock-offset0)/totCPU); - nBlockPerCPU(diff+1:totCPU) = floor((nBlock-offset0)/totCPU); -else - nBlockPerCPU(1:nBlock-offset0)=1; - totCPU = nBlock-offset0; -end +function [nCPU, totCPU, nBlockPerCPU] = distributeJobs(Parallel, fBlock, nBlock) +% Determine the total number of available CPUs, and the number of threads to run on each CPU + +% Copyright (C) 2010 Dynare Team +% +% This file is part of Dynare. +% +% Dynare is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% Dynare is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with Dynare. If not, see . + +totCPU=0; +for j=1:length(Parallel), + nCPU(j)=length(Parallel(j).NumCPU); + totCPU=totCPU+nCPU(j); +end + +nCPU=cumsum(nCPU); +offset0 = fBlock-1; +if (nBlock-offset0)>totCPU, + diff = mod((nBlock-offset0),totCPU); + nBlockPerCPU(1:diff) = ceil((nBlock-offset0)/totCPU); + nBlockPerCPU(diff+1:totCPU) = floor((nBlock-offset0)/totCPU); +else + nBlockPerCPU(1:nBlock-offset0)=1; + totCPU = nBlock-offset0; +end diff --git a/matlab/global_initialization.m b/matlab/global_initialization.m index bff8b85c3..8b8029c7f 100644 --- a/matlab/global_initialization.m +++ b/matlab/global_initialization.m @@ -11,7 +11,7 @@ function global_initialization() % SPECIAL REQUIREMENTS % none -% Copyright (C) 2003-2008 Dynare Team +% Copyright (C) 2003-2010 Dynare Team % % This file is part of Dynare. % diff --git a/matlab/independent_metropolis_hastings.m b/matlab/independent_metropolis_hastings.m index 4aa6916ab..18a0ec576 100644 --- a/matlab/independent_metropolis_hastings.m +++ b/matlab/independent_metropolis_hastings.m @@ -19,7 +19,7 @@ function independent_metropolis_hastings(TargetFun,ProposalFun,xparam1,vv,mh_bou % SPECIAL REQUIREMENTS % None. -% Copyright (C) 2006-2008 Dynare Team +% Copyright (C) 2006-2008,2010 Dynare Team % % This file is part of Dynare. % diff --git a/matlab/masterParallel.m b/matlab/masterParallel.m index 9b4e698ef..6343a696c 100644 --- a/matlab/masterParallel.m +++ b/matlab/masterParallel.m @@ -29,7 +29,7 @@ function [fOutVar,nBlockPerCPU, totCPU] = masterParallel(Parallel,fBlock,nBlock, % the number of CPU declared in "Parallel", if % the number of required threads is lower) -% Copyright (C) 2009 Dynare Team +% Copyright (C) 2009-2010 Dynare Team % % This file is part of Dynare. % diff --git a/matlab/masterParallelMan.m b/matlab/masterParallelMan.m index d4bd67b23..c543a8925 100644 --- a/matlab/masterParallelMan.m +++ b/matlab/masterParallelMan.m @@ -31,7 +31,7 @@ function [fOutVar,nBlockPerCPU, totCPU] = masterParallelMan(Parallel,fBlock,nBlo % the number of CPU declared in "Parallel", if % the number of required threads is lower) -% Copyright (C) 2009 Dynare Team +% Copyright (C) 2009-2010 Dynare Team % % This file is part of Dynare. % diff --git a/matlab/pm3.m b/matlab/pm3.m index 7c682e4db..9c28c7674 100644 --- a/matlab/pm3.m +++ b/matlab/pm3.m @@ -1,6 +1,6 @@ function pm3(n1,n2,ifil,B,tit1,tit2,tit3,tit_tex,names1,names2,name3,DirectoryName,var_type) -% Copyright (C) 2007-2009 Dynare Team +% Copyright (C) 2007-2010 Dynare Team % % This file is part of Dynare. % diff --git a/matlab/pm3_core.m b/matlab/pm3_core.m index 4ab6b40d0..f7487547f 100644 --- a/matlab/pm3_core.m +++ b/matlab/pm3_core.m @@ -1,5 +1,21 @@ function myoutput=pm3_core(myinputs,fpar,nvar,whoiam, ThisMatlab) +% Copyright (C) 2007-2010 Dynare Team +% +% This file is part of Dynare. +% +% Dynare is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% Dynare is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with Dynare. If not, see . if nargin<4, whoiam=0; diff --git a/matlab/prior_posterior_statistics.m b/matlab/prior_posterior_statistics.m index 7c60f7d17..6e8977376 100644 --- a/matlab/prior_posterior_statistics.m +++ b/matlab/prior_posterior_statistics.m @@ -18,7 +18,7 @@ function prior_posterior_statistics(type,Y,gend,data_index,missing_value) % SPECIAL REQUIREMENTS % none -% Copyright (C) 2005-2009 Dynare Team +% Copyright (C) 2005-2010 Dynare Team % % This file is part of Dynare. % diff --git a/matlab/prior_posterior_statistics_core.m b/matlab/prior_posterior_statistics_core.m index 8be66c9df..c7966a097 100644 --- a/matlab/prior_posterior_statistics_core.m +++ b/matlab/prior_posterior_statistics_core.m @@ -1,5 +1,21 @@ function myoutput=prior_posterior_statistics_core(myinputs,fpar,B,whoiam, ThisMatlab) +% Copyright (C) 2005-2010 Dynare Team +% +% This file is part of Dynare. +% +% Dynare is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% Dynare is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with Dynare. If not, see . if nargin<4, whoiam=0; diff --git a/matlab/random_walk_metropolis_hastings.m b/matlab/random_walk_metropolis_hastings.m index 825998d41..236ae898c 100644 --- a/matlab/random_walk_metropolis_hastings.m +++ b/matlab/random_walk_metropolis_hastings.m @@ -19,7 +19,7 @@ function random_walk_metropolis_hastings(TargetFun,ProposalFun,xparam1,vv,mh_bou % SPECIAL REQUIREMENTS % None. -% Copyright (C) 2006-2008 Dynare Team +% Copyright (C) 2006-2008,2010 Dynare Team % % This file is part of Dynare. %