Home > matlab > parallel > dynareParallelGetFiles.m

dynareParallelGetFiles

PURPOSE ^

PARALLEL CONTEXT

SYNOPSIS ^

function dynareParallelGetFiles(NamFileInput,PRCDir,Parallel)

DESCRIPTION ^

 PARALLEL CONTEXT
 In a parallel context, this is a specialized mono-directional (Remote to Local) version of copy()
 function.


 INPUTS
  o NamFileInput   []   ...
  o PRCDir         []   ...
  o Parallel       []   ...

  OUTPUTS
  None



 Copyright (C) 2009-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 dynareParallelGetFiles(NamFileInput,PRCDir,Parallel)
0002 % PARALLEL CONTEXT
0003 % In a parallel context, this is a specialized mono-directional (Remote to Local) version of copy()
0004 % function.
0005 %
0006 %
0007 % INPUTS
0008 %  o NamFileInput   []   ...
0009 %  o PRCDir         []   ...
0010 %  o Parallel       []   ...
0011 %
0012 %  OUTPUTS
0013 %  None
0014 %
0015 %
0016 %
0017 % Copyright (C) 2009-2011 Dynare Team
0018 %
0019 % This file is part of Dynare.
0020 %
0021 % Dynare is free software: you can redistribute it and/or modify
0022 % it under the terms of the GNU General Public License as published by
0023 % the Free Software Foundation, either version 3 of the License, or
0024 % (at your option) any later version.
0025 %
0026 % Dynare is distributed in the hope that it will be useful,
0027 % but WITHOUT ANY WARRANTY; without even the implied warranty of
0028 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0029 % GNU General Public License for more details.
0030 %
0031 % You should have received a copy of the GNU General Public License
0032 % along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
0033 
0034 NamFileInput0=NamFileInput;
0035 
0036 for indPC=1:length(Parallel),
0037     if Parallel(indPC).Local==0,
0038         if ~ispc || strcmpi('unix',Parallel(indPC).OperatingSystem), %isunix || (~matlab_ver_less_than('7.4') && ismac),
0039             if ischar(NamFileInput0),
0040                 for j=1:size(NamFileInput0,1),
0041                     NamFile(j,:)={['./'],deblank(NamFileInput0(j,:))};
0042                 end
0043                 NamFileInput = NamFile;
0044             end
0045             for jfil=1:size(NamFileInput,1),
0046 
0047                 if exist('OCTAVE_VERSION') % Patch for peculiar behaviour of ls under Linux.
0048                     % It is necessary to manage the jolly char '*'!
0049 
0050                     FindAst=strfind(NamFileInput{jfil,2},'comp_status_random_walk_metropolis_hastings_core*');
0051                     
0052                     if isempty (FindAst)
0053 
0054                         [NonServeL NonServeR]= system(['scp ',Parallel(indPC).UserName,'@',Parallel(indPC).ComputerName,':',Parallel(indPC).RemoteDirectory,'/',PRCDir,'/',NamFileInput{jfil,1},NamFileInput{jfil,2},' ',NamFileInput{jfil,1}]);
0055 
0056                     else
0057 
0058                         filenameTemp=NamFileInput{jfil,2};
0059                         
0060                         [NotUsed FlI]=system(['ssh ',Parallel(indPC).UserName,'@',Parallel(indPC).ComputerName,' ls ',Parallel(indPC).RemoteDirectory,'/',PRCDir,'/',filenameTemp, ' 2> OctaveStandardOutputMessage.txt']);
0061                         
0062                         if isempty (FlI)
0063                             return
0064                         end
0065 
0066                         AstPos=strfind(filenameTemp,'.mat')-1;
0067                         FiMat=findstr(FlI, '.mat');
0068                         NumFileToCopy=length(FiMat);
0069 
0070 
0071                         for i=1: NumFileToCopy
0072                             Ni=num2str(i);
0073                             filenameTemp(1,AstPos)=Ni;
0074                             [NonServeL NonServeR]= system(['scp ',Parallel(indPC).UserName,'@',Parallel(indPC).ComputerName,':',Parallel(indPC).RemoteDirectory,'/',PRCDir,'/',NamFileInput{jfil,1},filenameTemp,' ',NamFileInput{jfil,1}]);
0075                         end
0076                     end
0077 
0078                 else
0079 
0080                     [NonServeL NonServeR]= system(['scp ',Parallel(indPC).UserName,'@',Parallel(indPC).ComputerName,':',Parallel(indPC).RemoteDirectory,'/',PRCDir,'/',NamFileInput{jfil,1},NamFileInput{jfil,2},' ',NamFileInput{jfil,1}]);
0081                 end
0082 
0083             end
0084         else
0085             if ischar(NamFileInput0),
0086                 for j=1:size(NamFileInput0,1),
0087                     NamFile(j,:)={['.\'],deblank(NamFileInput0(j,:))};
0088                 end
0089                 NamFileInput = NamFile;
0090             end
0091             for jfil=1:size(NamFileInput,1),
0092                 if ~isempty(dynareParallelDir(NamFileInput{jfil,2},[PRCDir,filesep,NamFileInput{jfil,1}],Parallel(indPC))),
0093                     copyfile(['\\',Parallel(indPC).ComputerName,'\',Parallel(indPC).RemoteDrive,'$\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\',NamFileInput{jfil,1},NamFileInput{jfil,2}],NamFileInput{jfil,1});
0094                 end
0095             end
0096         end
0097     end
0098 end

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