Home > matlab > parallel > dynareParallelSendFiles.m

dynareParallelSendFiles

PURPOSE ^

PARALLEL CONTEXT

SYNOPSIS ^

function dynareParallelSendFiles(NamFileInput,PRCDir,Parallel)

DESCRIPTION ^

 PARALLEL CONTEXT
 In a parallel context, this is a specialized mono-directional (Local to Remote) 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 dynareParallelSendFiles(NamFileInput,PRCDir,Parallel)
0002 % PARALLEL CONTEXT
0003 % In a parallel context, this is a specialized mono-directional (Local to Remote) 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 
0035 if ischar(NamFileInput),
0036     for j=1:size(NamFileInput,1),
0037         NamFile(j,:)={'',deblank(NamFileInput(j,:))};
0038     end
0039     NamFileInput = NamFile;
0040 end
0041 
0042 for indPC=1:length(Parallel),
0043     if Parallel(indPC).Local==0,
0044         if ~ispc || strcmpi('unix',Parallel(indPC).OperatingSystem), %isunix || (~matlab_ver_less_than('7.4') && ismac),
0045             for jfil=1:size(NamFileInput,1),
0046                 if ~isempty(NamFileInput{jfil,1})
0047                     [NonServeL NonServeR]=system(['ssh ',Parallel(indPC).UserName,'@',Parallel(indPC).ComputerName,' mkdir -p ',Parallel(indPC).RemoteDirectory,'/',PRCDir,'/',NamFileInput{jfil,1}]);
0048                 end
0049                 [NonServeL NonServeR]=system(['scp ',NamFileInput{jfil,1},NamFileInput{jfil,2},' ',Parallel(indPC).UserName,'@',Parallel(indPC).ComputerName,':',Parallel(indPC).RemoteDirectory,'/',PRCDir,'/',NamFileInput{jfil,1}]);
0050             end
0051         else
0052             for jfil=1:size(NamFileInput,1)
0053                 if ~isempty(NamFileInput{jfil,1})
0054                     if isempty(dynareParallelDir(NamFileInput{jfil,1},PRCDir,Parallel(indPC)))
0055                         
0056                         if exist('OCTAVE_VERSION') % Patch for peculiar behaviour of mkdir under Windows.
0057                             
0058                             % It is Necessary because Octave is not able to
0059                             % create two nested directory at the same time.
0060                             
0061                            % Remove (if present) the '/' chars. Can be easily transformed
0062                            % in a function.
0063                            
0064                             NamFileInputTemp=NamFileInput{jfil,1};
0065                             while(1)
0066                                 Bs=strfind(NamFileInputTemp,'/');
0067                                 if isempty(Bs),
0068                                     break;
0069                                 else
0070                                     NamFileInputTemp(1,Bs)='\';
0071                                 end
0072                             end
0073                             
0074                             [NonServeL NonServeR]=system(['mkdir \\',Parallel(indPC).ComputerName,'\',Parallel(indPC).RemoteDrive,'$\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\',NamFileInputTemp]);
0075 
0076                         else
0077                             mkdir(['\\',Parallel(indPC).ComputerName,'\',Parallel(indPC).RemoteDrive,'$\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\',NamFileInput{jfil,1}]);
0078                         end
0079                     end
0080                 end
0081                 
0082                 if exist('OCTAVE_VERSION') % Patch for peculiar behaviour copyfile ls under Windows.
0083                     
0084                     % It is Necessary because Octave is not able to
0085                     % use the jolly char '*' with copyfile.
0086                     
0087                       % Remove (if present) the '/' chars. Can be easily transformed
0088                       % in a function.
0089                     
0090                     NamFileInputTemp=NamFileInput{jfil,1};
0091                     while(1)
0092                         Bs=strfind(NamFileInputTemp,'/');
0093                         if isempty(Bs),
0094                             break;
0095                         else
0096                             NamFileInputTemp(1,Bs)='\';
0097                         end
0098                     end
0099                     
0100                     [NonServeS NonServeD]=system(['copy ',NamFileInputTemp, NamFileInput{jfil,2},' \\',Parallel(indPC).ComputerName,'\',Parallel(indPC).RemoteDrive,'$\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\',NamFileInputTemp]);
0101                     
0102                 else
0103                     copyfile([NamFileInput{jfil,1},NamFileInput{jfil,2}],['\\',Parallel(indPC).ComputerName,'\',Parallel(indPC).RemoteDrive,'$\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\',NamFileInput{jfil,1}]);
0104                 end
0105             end
0106         end
0107     end
0108 end

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