2010-10-29 12:28:44 +02:00
function [ErrorCode] = AnalyseComputationalEnvironment ( DataInput, DataInputAdd)
2010-05-31 11:23:38 +02:00
% PARALLEL CONTEXT
2010-12-17 09:16:30 +01:00
% In a parallel context, this function is used to check the cluster defined by the user.
% If no error happen the function returns 0. The function complies with
% Windows/Linux operating systems and Matlab/Octave software.
%
2010-05-31 11:23:38 +02:00
%
2010-02-10 18:53:16 +01:00
% INPUT/OUTPUT description:
2009-12-16 18:17:34 +01:00
%
2010-10-29 12:28:44 +02:00
%
% DataInput
% is the strcture option_.parallel, with the follow fields:
2009-12-16 18:17:34 +01:00
%
2010-12-17 09:16:30 +01:00
% Local 1 is on local machine, 0 remote
% ComputerName the computer name.
% CPUnbr the CPU's
% UserName the user name for the ComputerName.
% Password the password for the user name in ComputerName.
% RemoteDrive Drive used for Remote computation (data exchange, etc): must be contain 'RemoteFolder'.
% RemoteDirectory Folder in RemoteDrive used for Remote computation.
% MatlabOctavePath Path to MATLAB or Octave executable.
% DynarePath Path to matlab directory within the Dynare installation directory.
2009-12-16 18:17:34 +01:00
%
2010-12-17 09:16:30 +01:00
% This information is typed by the user in the DYNARE configuration file and is parsed by the preprocessor,
% the goal of this function is to check if configuration is correct and if dynare
% can be executed successfully in parallel mode.
2009-12-16 18:17:34 +01:00
%
%
2010-10-29 12:28:44 +02:00
% DataInputAdd
2010-12-17 09:16:30 +01:00
% it is the structure options_.parallel_info. Currently , only the string in the
% field RemoteTmpFolder (the temporary directory created/destroyed on remote
% computer) is used.
2013-03-27 16:33:11 +01:00
if ispc ,
[ tempo , MasterName ] = system ( ' hostname' ) ;
MasterName = deblank ( MasterName ) ;
end
2010-10-29 12:28:44 +02:00
RemoteTmpFolder = DataInputAdd . RemoteTmpFolder ;
2010-12-17 09:16:30 +01:00
dynareParallelMkDir ( RemoteTmpFolder , DataInput ) ;
2010-10-29 12:28:44 +02:00
% The variable ErrorCode is initialized at 0. If there are non problems with
% Local, ComputerName connections,... in general with parallel software execution,
2009-12-16 18:17:34 +01:00
% the ErrorCode is unchanged, in the others cases 1, 2 , ... The values
% table is below.
%
%
% Table for ErrorCode Values.
%
2010-12-17 09:16:30 +01:00
% ErrorCode -> 0 Initial Value -> No Error Detected!!!
% ErrorCode -> 1 ... When an error is detected, the values 1, 2, 3... are
% used to specify the type of error or warning.
2009-12-16 18:17:34 +01:00
%
% Value 1: The variable 'Local' has a bad value!
%
2010-12-17 09:16:30 +01:00
% Value 2: The variable 'CPUnbr' has a bad value. For more information
% see http://www.dynare.org/DynareWiki/ParallelDynare.
% 2.1 [warning] The user asks to use more CPU's than those available.
% 2.2 [warning] There are unused CPU's!
%
2009-12-16 18:17:34 +01:00
%
% Value 3: The remote computer is unreachable!!!
%
2010-02-10 18:53:16 +01:00
% Value 4: The fields user name and/or password are/is empty!
%
2010-12-17 09:16:30 +01:00
% Value 5: Remote Drive and/or Remote Folder do not exist!
2010-02-10 18:53:16 +01:00
%
2010-12-17 09:16:30 +01:00
% Value 6: It is impossible write/read files on the remote computer.
2010-02-10 18:53:16 +01:00
%
2010-12-17 09:16:30 +01:00
% Value 7: The values user and/or passwd are incorrect or the user has
% no permissions to execute a Matlab session. Or simply
% Matlab path (MatlabOctavePath) is incorrect!
2010-10-29 12:28:44 +02:00
%
2010-12-17 09:16:30 +01:00
% Value 8: Dynare path (DynarePath) is incorrect!
2010-10-29 12:28:44 +02:00
%
2010-12-17 09:16:30 +01:00
% Value 9: It is impossible delete remote computational temporary files!
2010-10-29 12:28:44 +02:00
%
2010-02-10 18:53:16 +01:00
%
%
2009-12-16 18:17:34 +01:00
%
2010-12-17 09:16:30 +01:00
% Currently when errors are detected execution simply stops and users can
% fix configuration errors according to the error type.
2009-12-16 18:17:34 +01:00
2013-06-12 16:42:09 +02:00
% Copyright (C) 2009-2013 Dynare Team
2009-12-16 18:17:34 +01:00
%
% 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/>.
2010-10-29 12:28:44 +02:00
2009-12-16 18:17:34 +01:00
ErrorCode = 0 ;
2010-10-29 12:28:44 +02:00
2010-12-17 09:16:30 +01:00
for Node = 1 : length ( DataInput ) % To obtain a recoursive function remove the 'for'
2011-02-07 20:52:09 +01:00
% and use AnalyseComputationalEnvironment with differents input!
2011-06-17 17:17:01 +02:00
% Determine the operating system or software version when necessary
% for different command types.
OScallerUnix = ~ ispc ;
OScallerWindows = ispc ;
OStargetUnix = strcmpi ( ' unix' , DataInput ( Node ) . OperatingSystem ) ;
2011-06-24 10:56:07 +02:00
if isempty ( DataInput ( Node ) . OperatingSystem ) ,
OStargetUnix = OScallerUnix ;
end
2011-06-17 17:17:01 +02:00
OStargetWindows = strcmpi ( ' windows' , DataInput ( Node ) . OperatingSystem ) ;
2011-06-24 10:56:07 +02:00
if isempty ( DataInput ( Node ) . OperatingSystem ) ,
OStargetWindows = OScallerWindows ;
end
2011-06-17 17:17:01 +02:00
Environment = ( OScallerUnix || OStargetUnix ) ;
2013-07-10 17:12:34 +02:00
skipline ( 2 )
2010-12-17 09:16:30 +01:00
disp ( [ ' Testing computer -> ' , DataInput ( Node ) . ComputerName , ' <- ...' ] ) ;
2013-07-10 17:12:34 +02:00
skipline ( 2 )
2011-06-17 17:17:01 +02:00
2010-12-17 09:16:30 +01:00
% The function is composed by two main blocks, determined by the 'Local'
% variable.
2011-06-17 17:17:01 +02:00
2010-12-17 09:16:30 +01:00
% This check can be removed ... according to the dynare parser
2010-10-29 12:28:44 +02:00
% strategy.
2011-06-17 17:17:01 +02:00
2010-12-17 09:16:30 +01:00
if ( ( DataInput ( Node ) . Local == 0 ) | ( DataInput ( Node ) . Local == 1 ) )
% Continue it is Ok!
disp ( ' Check on Local Variable ..... Ok!' ) ;
2013-07-10 17:12:34 +02:00
skipline ( )
2010-10-29 12:28:44 +02:00
else
2010-12-17 09:16:30 +01:00
disp ( ' The variable "Local" has a bad value!' ) ;
2013-07-10 17:12:34 +02:00
skipline ( )
2010-12-17 09:16:30 +01:00
disp ( ' ErrorCode 1.' ) ;
2013-07-10 17:12:34 +02:00
skipline ( )
2010-12-17 09:16:30 +01:00
ErrorCode = 1 ;
2010-10-29 12:28:44 +02:00
return
2009-12-16 18:17:34 +01:00
end
2011-06-17 17:17:01 +02:00
2010-12-17 09:16:30 +01:00
% %%%%%%%%%% Local (No Network) Computing %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Here only the multi-core, or multi-processor avaiable on local
% machine are involved in parallel computing. No network
% comunications are required!
2011-06-17 17:17:01 +02:00
2010-12-17 09:16:30 +01:00
% In this case we need to check only the variable 'CPUnbr'.
2011-06-17 17:17:01 +02:00
2010-12-17 09:16:30 +01:00
% We run the parallel code on local computer, so the others fields are automatically
% fixed by Dynare parser. Then the user can also fill them with wrong values.
2011-06-17 17:17:01 +02:00
2010-12-17 09:16:30 +01:00
% %%%%%%%%%% Cluster Computing %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Here we can have many computer with multi-core, or multi-processor avaiable on the
% network and involved in parallel computing.
% So in this case we need more sophisticated check.
2011-06-17 17:17:01 +02:00
2010-12-17 09:16:30 +01:00
if ( DataInput ( Node ) . Local == 0 )
2011-06-17 17:17:01 +02:00
2010-12-17 09:16:30 +01:00
% Now we verify if it is possibile to be connected with the
% remote computer.
2011-06-17 17:17:01 +02:00
2010-12-17 09:16:30 +01:00
si1 = [ ] ;
de1 = [ ] ;
2011-06-17 17:17:01 +02:00
2010-12-17 09:16:30 +01:00
if Environment
2011-06-17 17:17:01 +02:00
if OScallerWindows
[ si1 de1 ] = system ( [ ' ping ' , DataInput ( Node ) . ComputerName ] ) ;
else
[ si1 de1 ] = system ( [ ' ping ' , DataInput ( Node ) . ComputerName , ' -c 4' ] ) ;
end
2010-12-17 09:16:30 +01:00
else
[ si1 de1 ] = system ( [ ' ping ' , DataInput ( Node ) . ComputerName ] ) ;
end
2011-06-17 17:17:01 +02:00
2010-12-17 09:16:30 +01:00
if ( si1 )
2013-07-10 17:12:34 +02:00
disp ( [ ' It is impossibile to ping to the computer with name "' , DataInput ( Node ) . ComputerName , ' " using the network!' ] )
skipline ( )
disp ( ' ErrorCode 3.' )
2010-12-17 09:16:30 +01:00
ErrorCode = 3 ;
2013-07-10 17:12:34 +02:00
skipline ( 2 )
2010-12-17 09:16:30 +01:00
else
2013-07-10 17:12:34 +02:00
disp ( ' Check on ComputerName Variable ..... Ok!' )
skipline ( 2 )
2010-10-29 12:28:44 +02:00
end
2011-06-17 17:17:01 +02:00
2010-12-17 09:16:30 +01:00
% Now we verify if user name and password are correct and if remote
% drive and remote folder exist on the remote computer and it is
% possible to exchange data with them.
2011-06-17 17:17:01 +02:00
2010-12-17 09:16:30 +01:00
if Environment
% This check can be removed ... according to the dynare parser
% strategy.
2011-06-17 17:17:01 +02:00
2010-12-17 09:16:30 +01:00
if ( isempty ( DataInput ( Node ) . UserName ) )
2013-07-10 17:12:34 +02:00
disp ( ' The fields UserName is empty!' )
skipline ( )
disp ( ' ErrorCode 4.' )
skipline ( 2 )
2010-12-17 09:16:30 +01:00
ErrorCode = 4 ;
return
end
2013-07-10 17:12:34 +02:00
disp ( ' Check on UserName Variable ..... Ok!' )
skipline ( 2 )
2011-06-17 17:17:01 +02:00
2010-12-17 09:16:30 +01:00
% This check can be removed ... according to the dynare parser
2011-06-17 17:17:01 +02:00
% strategy.
if ( ~ isempty ( DataInput ( Node ) . Password ) )
disp ( ' [WARNING] The field Password should be empty under unix or mac!' ) ;
2013-07-10 17:12:34 +02:00
skipline ( )
disp ( [ ' Remove the string ' , DataInput ( Node ) . Password , ' from this field!' ] )
skipline ( )
disp ( ' ErrorCode 4.' )
skipline ( 2 )
2011-06-17 17:17:01 +02:00
ErrorCode = 4 ;
else
2013-07-10 17:12:34 +02:00
disp ( ' Check on Password Variable ..... Ok!' )
skipline ( 2 )
2011-06-17 17:17:01 +02:00
end
2010-12-17 09:16:30 +01:00
else
2011-06-17 17:17:01 +02:00
2010-12-17 09:16:30 +01:00
% This check can be removed ... according to the dynare parser
% strategy.
2011-06-17 17:17:01 +02:00
2010-12-17 09:16:30 +01:00
if ( isempty ( DataInput ( Node ) . UserName ) ) || ( isempty ( DataInput ( Node ) . Password ) )
disp ( ' The fields UserName and/or Password are/is empty!' ) ;
2013-07-10 17:12:34 +02:00
skipline ( )
disp ( ' ErrorCode 4.' )
skipline ( 2 )
2010-12-17 09:16:30 +01:00
ErrorCode = 4 ;
return
end
disp ( ' Check on UserName Variable ..... Ok!' ) ;
2013-07-10 17:12:34 +02:00
skipline ( )
2010-12-17 09:16:30 +01:00
disp ( ' Check on Password Variable ..... Ok!' ) ;
2013-07-10 17:12:34 +02:00
skipline ( )
2010-10-29 12:28:44 +02:00
end
2011-06-17 17:17:01 +02:00
2010-12-17 09:16:30 +01:00
% Now we very if RemoteDrive and/or RemoteDirectory exist on remote
% computer!
2011-06-17 17:17:01 +02:00
2010-12-17 09:16:30 +01:00
if Environment
2011-06-17 17:17:01 +02:00
2010-12-17 09:16:30 +01:00
% This check can be removed ... according to the dynare parser
% strategy.
2011-06-17 17:17:01 +02:00
2010-12-17 09:16:30 +01:00
if isempty ( DataInput ( Node ) . RemoteDirectory )
2013-07-10 17:12:34 +02:00
disp ( ' The field RemoteDirectory is empty!' )
skipline ( )
disp ( ' ErrorCode 5.' )
skipline ( )
2010-12-17 09:16:30 +01:00
ErrorCode = 5 ;
return
end
2011-06-17 17:17:01 +02:00
2010-12-17 09:16:30 +01:00
% This check can be removed ... according to the dynare parser
% strategy.
2011-06-17 17:17:01 +02:00
if ( ~ isempty ( DataInput ( Node ) . RemoteDrive ) )
2013-07-10 17:12:34 +02:00
disp ( ' [WARNING] The fields RemoteDrive should be empty under unix or mac!' )
skipline ( )
disp ( [ ' remove the string ' , DataInput ( Node ) . RemoteDrive , ' from this field!' ] )
skipline ( )
disp ( ' ErrorCode 5.' )
skipline ( 2 )
2011-06-17 17:17:01 +02:00
ErrorCode = 5 ;
end
2010-12-17 09:16:30 +01:00
si2 = [ ] ;
de2 = [ ] ;
2013-03-27 16:33:11 +01:00
if ~ isempty ( DataInput ( Node ) . Port ) ,
ssh_token = [ ' -p ' , DataInput ( Node ) . Port ] ;
else
ssh_token = ' ' ;
end
2011-06-17 17:17:01 +02:00
2013-03-27 16:33:11 +01:00
[ si2 de2 ] = system ( [ ' ssh ' , ssh_token , ' ' , DataInput ( Node ) . UserName , ' @' , DataInput ( Node ) . ComputerName , ' ls ' , DataInput ( Node ) . RemoteDirectory , ' /' , RemoteTmpFolder , ' /' ] ) ;
2011-06-17 17:17:01 +02:00
2010-12-17 09:16:30 +01:00
if ( si2 )
2013-07-10 17:12:34 +02:00
disp ( ' Remote Directory does not exist or is not reachable!' )
skipline ( )
disp ( ' ErrorCode 5.' )
skipline ( 2 )
2010-12-17 09:16:30 +01:00
ErrorCode = 5 ;
return
end
2011-06-17 17:17:01 +02:00
2013-07-10 17:12:34 +02:00
disp ( ' Check on RemoteDirectory Variable ..... Ok!' )
skipline ( 2 )
disp ( ' Check on RemoteDrive Variable ..... Ok!' )
skipline ( 2 )
2011-06-17 17:17:01 +02:00
2010-12-17 09:16:30 +01:00
else
% This check can be removed ... according to the dynare parser
% strategy.
2011-06-17 17:17:01 +02:00
2010-12-17 09:16:30 +01:00
if ( isempty ( DataInput ( Node ) . RemoteDrive ) || isempty ( DataInput ( Node ) . RemoteDirectory ) )
2013-07-10 17:12:34 +02:00
disp ( ' Remote RemoteDrive and/or RemoteDirectory is/are empty!' )
skipline ( )
disp ( ' ErrorCode 5.' )
skipline ( 2 )
2010-12-17 09:16:30 +01:00
ErrorCode = 5 ;
return
end
2011-06-17 17:17:01 +02:00
2010-12-17 09:16:30 +01:00
si2 = [ ] ;
de2 = [ ] ;
2013-03-27 16:33:11 +01:00
[ si2 de2 ] = system ( [ ' dir \\' , DataInput ( Node ) . ComputerName , ' \' , DataInput ( Node ) . RemoteDrive , ' $\' , DataInput ( Node ) . RemoteDirectory , ' \' , RemoteTmpFolder ] ) ;
2011-06-17 17:17:01 +02:00
2010-12-17 09:16:30 +01:00
if ( si2 )
2013-07-10 17:12:34 +02:00
disp ( ' Remote Directory does not exist or it is not reachable!' )
skipline ( )
disp ( ' ErrorCode 5.' )
skipline ( 2 )
2010-12-17 09:16:30 +01:00
ErrorCode = 5 ;
return
end
2011-06-17 17:17:01 +02:00
2013-07-10 17:12:34 +02:00
disp ( ' Check on RemoteDirectory Variable ..... Ok!' )
skipline ( 2 )
disp ( ' Check on RemoteDrive Variable ..... Ok!' )
skipline ( 2 )
2011-06-17 17:17:01 +02:00
2010-10-29 12:28:44 +02:00
end
2011-06-17 17:17:01 +02:00
2010-12-17 09:16:30 +01:00
% Now we verify if it possible to exchange data with the remote
% computer:
2011-06-17 17:17:01 +02:00
2010-12-17 09:16:30 +01:00
% Build a command file to test the matlab execution and dynare path ...
2011-06-17 17:17:01 +02:00
2010-12-17 09:16:30 +01:00
fid = fopen ( ' Tracing.m' , ' w+' ) ;
s1 = ( [ ' fT = fopen(' ' MatlabOctaveIsOk.txt' ' ,' ' w+' ' );\n' ] ) ;
s2 = ' fclose(fT);\n' ;
SBS = strfind ( DataInput ( Node ) . DynarePath , ' \' ) ;
DPStr = DataInput ( Node ) . DynarePath ;
if isempty ( SBS ) ,
DPStrNew = DPStr ;
else
DPStrNew = [ DPStr ( 1 : SBS ( 1 ) ) , ' \' ] ;
for j = 2 : length ( SBS ) ,
DPStrNew = [ DPStrNew , DPStr ( SBS ( j - 1 ) + 1 : SBS ( j ) ) , ' \' ] ;
end
DPStrNew = [ DPStrNew , DPStr ( SBS ( end ) + 1 : end ) ] ;
end
s3 = [ ' addpath(' ' ' , DPStrNew , ' ' ' ),\n' ] ;
s4 = [ ' try,\n dynareroot = dynare_config();\n' ] ;
s41 = ( [ ' fT = fopen(' ' DynareIsOk.txt' ' ,' ' w+' ' );\n' ] ) ;
s42 = ' fclose(fT);\n' ;
s5 = [ ' catch,end,\n' ] ;
s51 = ( [ ' fT = fopen(' ' DynareFailed.txt' ' ,' ' w+' ' );\n' ] ) ;
s52 = ' fclose(fT);\n' ;
send = ' exit' ;
StrCommand = ( [ s1 , s2 , s3 , s4 , s41 , s42 , s5 , s51 , s52 , send ] ) ;
2011-06-17 17:17:01 +02:00
2010-12-17 09:16:30 +01:00
% Mettere controllo su NbW ...
2013-11-04 10:54:45 +01:00
% if isoctave
2011-02-07 20:52:09 +01:00
% NbW = fprintf(fid,StrCommand, '%s');
% else
NbW = fprintf ( fid , StrCommand , ' %s' ) ;
% end
2010-12-17 09:16:30 +01:00
fclose ( fid ) ;
2011-06-17 17:17:01 +02:00
2010-12-17 09:16:30 +01:00
dynareParallelSendFiles ( ' Tracing.m' , RemoteTmpFolder , DataInput ( Node ) ) ;
FindTracing = dynareParallelDir ( ' Tracing.m' , RemoteTmpFolder , DataInput ( Node ) ) ;
2011-06-17 17:17:01 +02:00
2010-12-17 09:16:30 +01:00
delete ( ' Tracing.m' ) ;
2011-06-17 17:17:01 +02:00
2010-12-17 09:16:30 +01:00
if ( isempty ( FindTracing ) )
2013-07-10 17:12:34 +02:00
disp ( ' It is impossible to exchange data with Remote Drive and/or Remote Directory! ErrorCode 6.' )
skipline ( )
disp ( ' ErrorCode 6.' )
skipline ( 2 )
2010-12-17 09:16:30 +01:00
ErrorCode = 6 ;
2010-10-29 12:28:44 +02:00
return
2010-12-17 09:16:30 +01:00
else
2013-07-10 17:12:34 +02:00
disp ( ' Check on Exchange File with Remote Computer ..... Ok!' )
skipline ( 2 )
2010-10-29 12:28:44 +02:00
end
2011-06-17 17:17:01 +02:00
2010-12-17 09:16:30 +01:00
% Now we verify if it is possible execute a matlab/octave section on remote
% machine when the user is .UserName with password .Password and
% the path is MatlabOctavePath.
2011-06-17 17:17:01 +02:00
2013-03-27 16:33:11 +01:00
if Environment ,
if ~ isempty ( DataInput ( Node ) . Port ) ,
ssh_token = [ ' -p ' , DataInput ( Node ) . Port ] ;
else
ssh_token = ' ' ;
end
2011-06-17 17:17:01 +02:00
if strfind ( [ DataInput ( Node ) . MatlabOctavePath ] , ' octave' ) % Hybrid computing Matlab(Master)->Octave(Slaves) and Vice Versa!
2013-03-27 16:33:11 +01:00
system ( [ ' ssh ' , ssh_token , ' ' , DataInput ( Node ) . UserName , ' @' , DataInput ( Node ) . ComputerName , ' "cd ' , DataInput ( Node ) . RemoteDirectory , ' /' , RemoteTmpFolder , ' ; ' , DataInput ( Node ) . MatlabOctavePath , ' Tracing.m;" &' ] ) ;
2011-02-07 20:52:09 +01:00
else
2013-03-27 16:33:11 +01:00
system ( [ ' ssh ' , ssh_token , ' ' , DataInput ( Node ) . UserName , ' @' , DataInput ( Node ) . ComputerName , ' "cd ' , DataInput ( Node ) . RemoteDirectory , ' /' , RemoteTmpFolder , ' ; ' , DataInput ( Node ) . MatlabOctavePath , ' -nosplash -nodesktop -minimize -r Tracing;" &' ] ) ;
2011-02-07 20:52:09 +01:00
end
2010-10-29 12:28:44 +02:00
else
2013-03-27 16:33:11 +01:00
if ~ strcmp ( DataInput ( Node ) . ComputerName , MasterName ) , % run on remote machine
if strfind ( [ DataInput ( Node ) . MatlabOctavePath ] , ' octave' ) % Hybrid computing Matlab(Master)->Octave(Slaves) and Vice Versa!
[ NonServeS NenServeD ] = system ( [ ' start /B psexec \\' , DataInput ( Node ) . ComputerName , ' -e -u ' , DataInput ( Node ) . UserName , ' -p ' , DataInput ( Node ) . Password , ' -W ' , DataInput ( Node ) . RemoteDrive , ' :\' , DataInput ( Node ) . RemoteDirectory , ' \' , RemoteTmpFolder ' -low ' , DataInput ( Node ) . MatlabOctavePath , ' Tracing.m' ] ) ;
else
[ NonServeS NenServeD ] = system ( [ ' start /B psexec \\' , DataInput ( Node ) . ComputerName , ' -e -u ' , DataInput ( Node ) . UserName , ' -p ' , DataInput ( Node ) . Password , ' -W ' , DataInput ( Node ) . RemoteDrive , ' :\' , DataInput ( Node ) . RemoteDirectory , ' \' , RemoteTmpFolder ' -low ' , DataInput ( Node ) . MatlabOctavePath , ' -nosplash -nodesktop -minimize -r Tracing' ] ) ;
end
else % run on local machine via the network: user and passwd cannot be used!
if strfind ( [ DataInput ( Node ) . MatlabOctavePath ] , ' octave' ) % Hybrid computing Matlab(Master)->Octave(Slaves) and Vice Versa!
[ NonServeS NenServeD ] = system ( [ ' start /B psexec \\' , DataInput ( Node ) . ComputerName , ' -e ' , ' -W ' , DataInput ( Node ) . RemoteDrive , ' :\' , DataInput ( Node ) . RemoteDirectory , ' \' , RemoteTmpFolder ' -low ' , DataInput ( Node ) . MatlabOctavePath , ' Tracing.m' ] ) ;
else
[ NonServeS NenServeD ] = system ( [ ' start /B psexec \\' , DataInput ( Node ) . ComputerName , ' -e ' , ' -W ' , DataInput ( Node ) . RemoteDrive , ' :\' , DataInput ( Node ) . RemoteDirectory , ' \' , RemoteTmpFolder ' -low ' , DataInput ( Node ) . MatlabOctavePath , ' -nosplash -nodesktop -minimize -r Tracing' ] ) ;
end
2011-02-07 20:52:09 +01:00
end
2013-03-27 16:33:11 +01:00
2010-10-29 12:28:44 +02:00
end
2011-06-17 17:17:01 +02:00
2010-10-29 12:28:44 +02:00
% Timer da fissare, nei valori di attesa!
2011-06-17 17:17:01 +02:00
2010-10-29 12:28:44 +02:00
t1 = fix ( clock ) ;
2011-06-17 17:17:01 +02:00
2010-10-29 12:28:44 +02:00
if t1 ( 5 ) + 1 > 60 ;
t2 = 2 ;
else t2 = t1 ( 5 ) + 1 ;
end
2011-06-17 17:17:01 +02:00
2010-12-17 09:16:30 +01:00
Flag = 0 ;
2011-06-17 17:17:01 +02:00
2010-10-29 12:28:44 +02:00
while ( 1 ) ;
2010-12-17 09:16:30 +01:00
if Flag == 0
2013-07-10 17:12:34 +02:00
disp ( ' Try to run matlab/octave on remote machine ... ' )
skipline ( )
disp ( ' please wait ... ' )
skipline ( )
2010-12-17 09:16:30 +01:00
Flag = 1 ;
end
2010-10-29 12:28:44 +02:00
nt = fix ( clock ) ;
nt ( 5 ) - t2 ;
2011-06-17 17:17:01 +02:00
2010-12-17 09:16:30 +01:00
if ( ~ isempty ( dynareParallelDir ( ' MatlabOctaveIsOk.txt' , RemoteTmpFolder , DataInput ( Node ) ) ) ) || ( ( nt ( 5 ) - t2 ) > 0 )
2010-10-29 12:28:44 +02:00
if ( ( nt ( 5 ) - t2 ) > 0 )
ErrorCode = 7 ;
end
break
end
2011-06-17 17:17:01 +02:00
2010-10-29 12:28:44 +02:00
end
2011-06-17 17:17:01 +02:00
2010-10-29 12:28:44 +02:00
if ( ErrorCode == 7 )
2011-06-17 17:17:01 +02:00
2013-07-10 17:12:34 +02:00
disp ( ' It is not possible execute a matlab session on remote machine!' )
skipline ( )
disp ( ' ErrorCode 7.' )
skipline ( 2 )
2010-10-29 12:28:44 +02:00
ErrorCode = 7 ;
2010-12-17 09:16:30 +01:00
dynareParallelRmDir ( RemoteTmpFolder , DataInput ( Node ) ) ;
2010-10-29 12:28:44 +02:00
return
else
2013-07-10 17:12:34 +02:00
disp ( ' Check on MatlabOctave Path and MatlabOctave Program Execution on remote machine ..... Ok!' )
skipline ( 2 )
2011-06-17 17:17:01 +02:00
2010-12-17 09:16:30 +01:00
% Now we verify if the DynarePath is correct ...
2013-07-10 17:12:34 +02:00
disp ( ' Check the Dynare path on remote machine ... ' )
skipline ( )
disp ( ' please wait ... ' )
skipline ( 2 )
2011-06-17 17:17:01 +02:00
pause ( 2 )
2010-12-17 09:16:30 +01:00
if isempty ( dynareParallelDir ( ' DynareIsOk.txt' , RemoteTmpFolder , DataInput ( Node ) ) )
ErrorCode = 8 ;
end
2011-06-17 17:17:01 +02:00
2010-12-17 09:16:30 +01:00
if ( ErrorCode == 8 )
2013-07-10 17:12:34 +02:00
disp ( ' The DynarePath is incorrect!' )
skipline ( )
disp ( ' ErrorCode 8.' )
skipline ( 2 )
2010-12-17 09:16:30 +01:00
ErrorCode = 8 ;
dynareParallelRmDir ( RemoteTmpFolder , DataInput ( Node ) ) ;
return
else
2013-07-10 17:12:34 +02:00
disp ( ' Check on Dynare Path remote machine ..... Ok!' )
skipline ( 2 )
2010-12-17 09:16:30 +01:00
end
2010-10-29 12:28:44 +02:00
end
2011-06-17 17:17:01 +02:00
2010-12-17 09:16:30 +01:00
% Now we verify if it is possible delete remote computational traces!
2011-06-17 17:17:01 +02:00
2010-12-17 09:16:30 +01:00
dynareParallelRmDir ( RemoteTmpFolder , DataInput ( Node ) ) ;
2011-06-17 17:17:01 +02:00
2010-12-17 09:16:30 +01:00
si3 = [ ] ;
2011-06-17 17:17:01 +02:00
2011-02-07 20:52:09 +01:00
si3 = dynareParallelDir ( ' Tracing.m' , RemoteTmpFolder , DataInput ( Node ) ) ;
2011-06-17 17:17:01 +02:00
2011-02-07 20:52:09 +01:00
if ( isempty ( si3 ) )
2013-07-10 17:12:34 +02:00
disp ( ' Check on Delete Remote Computational Traces ..... Ok!' )
skipline ( 2 )
2010-12-17 09:16:30 +01:00
else
2013-07-10 17:12:34 +02:00
disp ( ' It is impossible to delete temporary files on remote machine!' )
skipline ( )
disp ( ' ErrorCode 9.' )
skipline ( 2 )
2010-12-17 09:16:30 +01:00
ErrorCode = 9 ;
return
end
2011-06-17 17:17:01 +02:00
2010-10-29 12:28:44 +02:00
end
2010-12-17 09:16:30 +01:00
% Now we check the variable 'CPUnbr'.
2011-06-17 17:17:01 +02:00
2010-12-17 09:16:30 +01:00
% This check can be removed ... according to the dynare parser
2010-10-29 12:28:44 +02:00
% strategy.
2011-06-17 17:17:01 +02:00
2010-12-17 09:16:30 +01:00
yn = isempty ( DataInput ( Node ) . CPUnbr ) ;
2011-06-17 17:17:01 +02:00
2010-10-29 12:28:44 +02:00
if yn == 1
% The field is empty!
2013-07-10 17:12:34 +02:00
disp ( ' The field "CPUnbr" is empty!' )
skipline ( )
disp ( ' ErrorCode 2.' )
skipline ( 2 )
2010-10-29 12:28:44 +02:00
ErrorCode = 2 ;
return
end
2011-06-17 17:17:01 +02:00
2010-12-17 09:16:30 +01:00
% This check can be removed ... according to the dynare parser
2010-10-29 12:28:44 +02:00
% strategy.
2011-06-17 17:17:01 +02:00
2010-10-29 12:28:44 +02:00
% We look for the information on local computer hardware.
2011-06-17 17:17:01 +02:00
2010-10-29 12:28:44 +02:00
si0 = [ ] ;
de0 = [ ] ;
2011-06-17 17:17:01 +02:00
2012-02-10 22:38:41 +01:00
disp ( ' Checking Hardware please wait ...' ) ;
2010-12-17 09:16:30 +01:00
if ( DataInput ( Node ) . Local == 1 )
if Environment ,
[ si0 de0 ] = system ( ' grep processor /proc/cpuinfo' ) ;
else
[ si0 de0 ] = system ( [ ' psinfo \\' ] ) ;
end
2010-10-29 12:28:44 +02:00
else
2010-12-17 09:16:30 +01:00
if Environment ,
2013-03-27 16:33:11 +01:00
if ~ isempty ( DataInput ( Node ) . Port ) ,
ssh_token = [ ' -p ' , DataInput ( Node ) . Port ] ;
else
ssh_token = ' ' ;
end
2011-06-24 10:56:07 +02:00
if OStargetUnix ,
2013-03-27 16:33:11 +01:00
[ si0 de0 ] = system ( [ ' ssh ' , ssh_token , ' ' , DataInput ( Node ) . UserName , ' @' , DataInput ( Node ) . ComputerName , ' grep processor /proc/cpuinfo' ] ) ;
2011-06-24 10:56:07 +02:00
else
2013-03-27 16:33:11 +01:00
[ si0 de0 ] = system ( [ ' ssh ' , ssh_token , ' ' , DataInput ( Node ) . UserName , ' @' , DataInput ( Node ) . ComputerName , ' psinfo' ] ) ;
2011-06-24 10:56:07 +02:00
end
2010-12-17 09:16:30 +01:00
else
[ si0 de0 ] = system ( [ ' psinfo \\' , DataInput ( Node ) . ComputerName , ' -u ' , DataInput ( Node ) . UserName , ' -p ' , DataInput ( Node ) . Password ] ) ;
end
2010-10-29 12:28:44 +02:00
end
2011-06-17 17:17:01 +02:00
2010-12-17 09:16:30 +01:00
RealCPUnbr = ' ' ;
2012-02-10 22:38:41 +01:00
% keyboard;
2013-04-05 17:28:43 +02:00
RealCPUnbr = GiveCPUnumber ( de0 , Environment ) ;
2011-06-17 17:17:01 +02:00
2010-10-29 12:28:44 +02:00
% Questo controllo penso che si possa MIGLIORARE!!!!!
2011-06-17 17:17:01 +02:00
if isempty ( RealCPUnbr ) && Environment == 0 ,
[ si0 de0 ] = system ( [ ' psinfo \\' , DataInput ( Node ) . ComputerName ] ) ;
end
2013-04-05 17:28:43 +02:00
RealCPUnbr = GiveCPUnumber ( de0 , Environment ) ;
2011-02-07 20:52:09 +01:00
2010-10-29 12:28:44 +02:00
if isempty ( RealCPUnbr )
% An error occurred when we try to know the Cpu/Cores
% numbers.
2013-07-10 17:12:34 +02:00
disp ( ' It is impossible determine the number of Cpu/Processor avaiable on this machine!' )
skipline ( )
disp ( ' ErrorCode 2.' )
skipline ( )
2010-12-17 09:16:30 +01:00
if Environment
2013-07-10 17:12:34 +02:00
disp ( ' Check the command "$less /proc/cpuinfo" ... !' )
2010-10-29 12:28:44 +02:00
else
2013-07-10 17:12:34 +02:00
disp ( ' Check if the pstools are installed and are in machine path! And check the command "psinfo \\"' )
2010-10-29 12:28:44 +02:00
end
2013-07-10 17:12:34 +02:00
skipline ( )
2010-10-29 12:28:44 +02:00
ErrorCode = 2 ;
return
end
2011-06-17 17:17:01 +02:00
2009-12-16 18:17:34 +01:00
% Trasforming the input data provided in a form [n1:n2] in a single numerical
% value.
2011-06-17 17:17:01 +02:00
2010-12-17 09:16:30 +01:00
CPUnbrUser = length ( DataInput ( Node ) . CPUnbr ) ;
maxCPUnbrUser = max ( DataInput ( Node ) . CPUnbr ) + 1 ;
2011-06-17 17:17:01 +02:00
2013-07-10 17:12:34 +02:00
disp ( [ ' Hardware has ' , num2str ( RealCPUnbr ) , ' Cpu/Cores!' ] )
disp ( [ ' User requires ' , num2str ( CPUnbrUser ) , ' Cpu/Cores!' ] )
2010-12-17 09:16:30 +01:00
if CPUnbrUser == RealCPUnbr ,
2009-12-16 18:17:34 +01:00
% It is Ok!
2013-07-10 17:12:34 +02:00
disp ( ' Check on CPUnbr Variable ..... Ok!' )
skipline ( 3 )
2009-12-16 18:17:34 +01:00
end
2011-06-17 17:17:01 +02:00
2010-10-29 12:28:44 +02:00
if CPUnbrUser > RealCPUnbr
2013-07-10 17:12:34 +02:00
disp ( ' Warning! The user asks to use more CPU' ' s than those available.' )
skipline ( 2 )
2009-12-16 18:17:34 +01:00
ErrorCode = 2.1 ;
end
2010-10-29 12:28:44 +02:00
if CPUnbrUser < RealCPUnbr
2013-07-10 17:12:34 +02:00
disp ( ' Warning! There are unused CPU' ' s!' )
skipline ( 2 )
2009-12-16 18:17:34 +01:00
ErrorCode = 2.2 ;
end
2011-06-17 17:17:01 +02:00
2013-07-10 17:12:34 +02:00
disp ( [ ' Test for Cluster computation, computer ' , DataInput ( Node ) . ComputerName , ' ..... Passed!' ] )
skipline ( 2 )
end