Home > matlab > parallel > closeSlave.m

closeSlave

PURPOSE ^

PARALLEL CONTEXT

SYNOPSIS ^

function closeSlave(Parallel,TmpFolder,partial),

DESCRIPTION ^

 PARALLEL CONTEXT
 In parallel context, this utility closes all remote matlab instances
 called by masterParallel when strategy (1) is active i.e. always open (which leaves
 open remote matlab instances).

 INPUTS
  o Parallel [struct vector]   copy of options_.parallel.
  o TmpFolder        string    if islocal==0, is the name of didectory devoted to remote computation.
                               This directory is named using current date
                               and is used only one time and then deleted.
                               If islocal==1, TmpFolder=''.
 

 OUTPUTS
   None

 Copyright (C) 2010-2011 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 <http://www.gnu.org/licenses/>.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function closeSlave(Parallel,TmpFolder,partial),
0002 % PARALLEL CONTEXT
0003 % In parallel context, this utility closes all remote matlab instances
0004 % called by masterParallel when strategy (1) is active i.e. always open (which leaves
0005 % open remote matlab instances).
0006 %
0007 % INPUTS
0008 %  o Parallel [struct vector]   copy of options_.parallel.
0009 %  o TmpFolder        string    if islocal==0, is the name of didectory devoted to remote computation.
0010 %                               This directory is named using current date
0011 %                               and is used only one time and then deleted.
0012 %                               If islocal==1, TmpFolder=''.
0013 %
0014 %
0015 % OUTPUTS
0016 %   None
0017 %
0018 % Copyright (C) 2010-2011 Dynare Team
0019 %
0020 % This file is part of Dynare.
0021 %
0022 % Dynare is free software: you can redistribute it and/or modify
0023 % it under the terms of the GNU General Public License as published by
0024 % the Free Software Foundation, either version 3 of the License, or
0025 % (at your option) any later version.
0026 %
0027 % Dynare is distributed in the hope that it will be useful,
0028 % but WITHOUT ANY WARRANTY; without even the implied warranty of
0029 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0030 % GNU General Public License for more details.
0031 %
0032 % You should have received a copy of the GNU General Public License
0033 % along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
0034 
0035 if nargin<3,
0036     partial=0;
0037 end
0038 
0039 s=warning('off');
0040 
0041 if partial==1
0042     save('slaveParallel_break','partial')
0043     for indPC=1:length(Parallel),
0044         if (Parallel(indPC).Local==0),
0045             dynareParallelSendFiles('slaveParallel_break.mat',TmpFolder,Parallel(indPC));
0046         end
0047     end
0048 %     delete('slaveParallel_break')
0049     return
0050 end
0051 if partial==-1
0052     delete('slaveParallel_break.mat')
0053     for indPC=1:length(Parallel),
0054         if (Parallel(indPC).Local==0),
0055             dynareParallelDelete( 'slaveParallel_break.mat',TmpFolder,Parallel(indPC));
0056         end
0057     end
0058 %     delete('slaveParallel_break')
0059     return
0060 end
0061 
0062 for indPC=1:length(Parallel),
0063     if (Parallel(indPC).Local==0),
0064         dynareParallelDelete( 'slaveParallel_input*.mat',TmpFolder,Parallel(indPC));
0065     end
0066     %else
0067     delete( 'slaveParallel_input*.mat');
0068     pause(1)
0069     delete(['slaveParallel_*.log']);
0070     %end
0071     delete ConcurrentCommand1.bat;
0072 end
0073 
0074 while(1)
0075     if isempty(dynareParallelDir(['P_slave_',int2str(j),'End.txt'],TmpFolder,Parallel));
0076         for indPC=1:length(Parallel),
0077             if (Parallel(indPC).Local==0),
0078                 dynareParallelRmDir(TmpFolder,Parallel(indPC)),
0079                 
0080             end
0081         end
0082         break
0083         
0084     end
0085 end
0086 
0087 s=warning('on');
0088

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