From 76644861a3bef6ec1e201454cb045f6ebf64c9fa Mon Sep 17 00:00:00 2001 From: Marco Ratto Date: Tue, 1 Feb 2011 23:21:00 +0100 Subject: [PATCH 1/7] Provisions for octave under linux + small cosmethics. --- matlab/parallel/dynareParallelDir.m | 41 +++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/matlab/parallel/dynareParallelDir.m b/matlab/parallel/dynareParallelDir.m index f656cda31..a2bf7bab5 100644 --- a/matlab/parallel/dynareParallelDir.m +++ b/matlab/parallel/dynareParallelDir.m @@ -4,11 +4,11 @@ function dirlist = dynareParallelDir(filename,PRCDir,Parallel) % % INPUTS % o filename [] ... -% o PRCDir [] ... -% o Parallel [] ... +% o PRCDir [] ... +% o Parallel [] ... % % OUTPUTS -% o dirlist [] ... +% o dirlist [] ... % % Copyright (C) 2009-2010 Dynare Team % @@ -31,21 +31,40 @@ dirlist=[]; for indPC=1:length(Parallel), if ~ispc, %isunix || (~matlab_ver_less_than('7.4') && ismac), if Parallel(indPC).Local==0, - [check, ax]=system(['ssh ',Parallel(indPC).UserName,'@',Parallel(indPC).ComputerName,' ls ',Parallel(indPC).RemoteDirectory,'/',PRCDir,'/',filename]); + if exist('OCTAVE_VERSION') % Patch for peculiar behaviour of ssh-ls under Linux. + % It is necessary to capture the ls warning message. + % To do it under the ssh protocol it is necessary to redirect the ls message in a text file. + % The file is 'OctaveStandardOutputMessage.txt' and it is + % saved in the Model directory. + [check, ax]=system(['ssh ',Parallel(indPC).UserName,'@',Parallel(indPC).ComputerName,' ls ',Parallel(indPC).RemoteDirectory,'/',PRCDir,'/',filename, ' 2> OctaveStandardOutputMessage.txt']); + else + [check, ax]=system(['ssh ',Parallel(indPC).UserName,'@',Parallel(indPC).ComputerName,' ls ',Parallel(indPC).RemoteDirectory,'/',PRCDir,'/',filename]); + end if check ~ 0; ax=[]; end else - try - ax=ls(filename); - catch - ax=[]; + + if exist('OCTAVE_VERSION') % Patch for peculiar behaviour of ls under Linux. + + % It is necessary to capture the ls warning message and properly manage the jolly char '*'! + [check ax]=system(['ls ' ,filename, ' 2> OctaveStandardOutputMessage.txt']); + + if check ~ 0; + ax=[]; + end + else + try + ax=ls(filename); + catch + ax=[]; + end end - + end dirlist = [dirlist, ax]; else - if exist('OCTAVE_VERSION'), % patch for peculiar behaviour of ls under Windows + if exist('OCTAVE_VERSION'), % Patch for peculiar behaviour of ls under Windows. if Parallel(indPC).Local==0, ax0=dir(['\\',Parallel(indPC).ComputerName,'\',Parallel(indPC).RemoteDrive,'$\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\',filename]); else @@ -59,7 +78,7 @@ for indPC=1:length(Parallel), end ax=char(ax{:}); end - + else if Parallel(indPC).Local==0, ax=ls(['\\',Parallel(indPC).ComputerName,'\',Parallel(indPC).RemoteDrive,'$\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\',filename]); From 9fdc7a655e331dbd67dd5e406f7a847bd16a5da7 Mon Sep 17 00:00:00 2001 From: Marco Ratto Date: Tue, 1 Feb 2011 23:21:49 +0100 Subject: [PATCH 2/7] capture system command for mkdir also for linux --- matlab/parallel/dynareParallelMkDir.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/matlab/parallel/dynareParallelMkDir.m b/matlab/parallel/dynareParallelMkDir.m index 5dc6ab242..796354492 100644 --- a/matlab/parallel/dynareParallelMkDir.m +++ b/matlab/parallel/dynareParallelMkDir.m @@ -37,7 +37,7 @@ end for indPC=1:length(Parallel) if Parallel(indPC).Local==0, if ~ispc, %isunix || (~matlab_ver_less_than('7.4') && ismac), - system(['ssh ',Parallel(indPC).UserName,'@',Parallel(indPC).ComputerName,' mkdir -p ',Parallel(indPC).RemoteDirectory,'/',PRCDir]); + [NonServeS NonServeD]=system(['ssh ',Parallel(indPC).UserName,'@',Parallel(indPC).ComputerName,' mkdir -p ',Parallel(indPC).RemoteDirectory,'/',PRCDir]); else [NonServeS NonServeD]=mkdir(['\\',Parallel(indPC).ComputerName,'\',Parallel(indPC).RemoteDrive,'$\',Parallel(indPC).RemoteDirectory,'\',PRCDir]); end From 062734895fcda7e79b5976e3a4888f097ffb1e2d Mon Sep 17 00:00:00 2001 From: Marco Ratto Date: Tue, 1 Feb 2011 23:24:34 +0100 Subject: [PATCH 3/7] dynare provisions for rmdir under windows --- matlab/parallel/dynareParallelRmDir.m | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/matlab/parallel/dynareParallelRmDir.m b/matlab/parallel/dynareParallelRmDir.m index 1e26874d7..08cfba866 100644 --- a/matlab/parallel/dynareParallelRmDir.m +++ b/matlab/parallel/dynareParallelRmDir.m @@ -37,11 +37,21 @@ end for indPC=1:length(Parallel), while (1) - if isunix + if ~isdos stat = system(['ssh ',Parallel(indPC).UserName,'@',Parallel(indPC).ComputerName,' rm -fr ',Parallel(indPC).RemoteDirectory,'/',PRCDir]); break; else + if exist('OCTAVE_VERSION'), % Patch for peculiar behaviour of rmdir under Windows. + % It is necessary because the command rmdir always ask at the user to confirm your decision before + % deleting a directory: this stops the computation! The Octave native function 'confirm_recursive_rmdir' + % disable this mechanism. + val = confirm_recursive_rmdir (false); + [stat, mess, id] = rmdir(['\\',Parallel(indPC).ComputerName,'\',Parallel(indPC).RemoteDrive,'$\',Parallel(indPC).RemoteDirectory,'\',PRCDir],'s'); + + else [stat, mess, id] = rmdir(['\\',Parallel(indPC).ComputerName,'\',Parallel(indPC).RemoteDrive,'$\',Parallel(indPC).RemoteDirectory,'\',PRCDir],'s'); + end + if stat==1, break, else From 3eb1ec0c40e5bf6e6ec441ded168b63c507adeb4 Mon Sep 17 00:00:00 2001 From: Marco Ratto Date: Tue, 1 Feb 2011 23:26:01 +0100 Subject: [PATCH 4/7] fixed bug in previous commit (~ispc) --- matlab/parallel/dynareParallelRmDir.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/matlab/parallel/dynareParallelRmDir.m b/matlab/parallel/dynareParallelRmDir.m index 08cfba866..46d29fe82 100644 --- a/matlab/parallel/dynareParallelRmDir.m +++ b/matlab/parallel/dynareParallelRmDir.m @@ -37,7 +37,7 @@ end for indPC=1:length(Parallel), while (1) - if ~isdos + if ~ispc stat = system(['ssh ',Parallel(indPC).UserName,'@',Parallel(indPC).ComputerName,' rm -fr ',Parallel(indPC).RemoteDirectory,'/',PRCDir]); break; else From 45cf10ed11c4b61c3f484eecd141cfbd80404538 Mon Sep 17 00:00:00 2001 From: Marco Ratto Date: Tue, 1 Feb 2011 23:32:36 +0100 Subject: [PATCH 5/7] missing semicolon --- matlab/parallel/fMessageStatus.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/matlab/parallel/fMessageStatus.m b/matlab/parallel/fMessageStatus.m index 08f5ad515..83117cf6e 100644 --- a/matlab/parallel/fMessageStatus.m +++ b/matlab/parallel/fMessageStatus.m @@ -44,6 +44,6 @@ end fslave = dir( ['slaveParallel_input',int2str(njob),'.mat']); if isempty(fslave), - error('Master asked to break the job') + error('Master asked to break the job'); end From e7646a441216ebc73dc368be2785580fa3197abd Mon Sep 17 00:00:00 2001 From: Marco Ratto Date: Tue, 1 Feb 2011 23:33:22 +0100 Subject: [PATCH 6/7] disable warnings in octave + semicolon --- matlab/parallel/InitializeComputationalEnvironment.m | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/matlab/parallel/InitializeComputationalEnvironment.m b/matlab/parallel/InitializeComputationalEnvironment.m index ebe6b72fc..d92320d12 100644 --- a/matlab/parallel/InitializeComputationalEnvironment.m +++ b/matlab/parallel/InitializeComputationalEnvironment.m @@ -33,6 +33,16 @@ function InitializeComputationalEnvironment() % 'octave'. Then if the field is empty it is necessary to fill it with the % default value. +% Deactivate some 'Parallel/Warning' message in Octave! +% Comment the line 'warning('off');' in order to view the warning message +% in Octave! + +if exist('OCTAVE_VERSION'), + warning('off'); +end + + + global options_ for j=1:length(options_.parallel), @@ -58,7 +68,7 @@ end % parallel computations with Strategy == 1 delete the traces (if exists) of % previous computations. -delete(['P_slave_*End.txt']) +delete(['P_slave_*End.txt']); masterParallel(options_.parallel,[],[],[],[],[],[],options_.parallel_info,1); return \ No newline at end of file From 7583e0d3f1e16a6cb9d9a8c5f2c77a5be853f082 Mon Sep 17 00:00:00 2001 From: Marco Ratto Date: Tue, 1 Feb 2011 23:37:41 +0100 Subject: [PATCH 7/7] semicolons --- matlab/parallel/slaveParallel.m | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/matlab/parallel/slaveParallel.m b/matlab/parallel/slaveParallel.m index ed3544c37..7da7e2932 100644 --- a/matlab/parallel/slaveParallel.m +++ b/matlab/parallel/slaveParallel.m @@ -45,19 +45,19 @@ diary( ['slaveParallel_',int2str(whoiam),'.log']); dynareroot = dynare_config(); % Load input data. -load( ['slaveParallel_input',int2str(whoiam)]) +load( ['slaveParallel_input',int2str(whoiam)]); %Loads fGlobalVar Parallel. if exist('fGlobalVar'), globalVars = fieldnames(fGlobalVar); for j=1:length(globalVars), - eval(['global ',globalVars{j},';']) - evalin('base',['global ',globalVars{j},';']) + eval(['global ',globalVars{j},';']); + evalin('base',['global ',globalVars{j},';']); end struct2local(fGlobalVar); clear fGlobalVar % create global variables in the base workspace as well - evalin('base',['load( [''slaveParallel_input',int2str(whoiam),'''],''fGlobalVar'')']) + evalin('base',['load( [''slaveParallel_input',int2str(whoiam),'''],''fGlobalVar'')']) ; evalin('base','struct2local(fGlobalVar)'); evalin('base','clear fGlobalVar'); end @@ -109,12 +109,12 @@ while (etime(clock,t0)<1200 && ~isempty(fslave)) || ~isempty(dir(['stayalive',in for j=1:length(globalVars), info_whos = whos(globalVars{j}); if isempty(info_whos) || ~info_whos.global, - eval(['global ',globalVars{j},';']) - evalin('base',['global ',globalVars{j},';']) + eval(['global ',globalVars{j},';']); + evalin('base',['global ',globalVars{j},';']); end end struct2local(fGlobalVar); - evalin('base',['load( [''slaveJob',int2str(whoiam),'''],''fGlobalVar'')']) + evalin('base',['load( [''slaveJob',int2str(whoiam),'''],''fGlobalVar'')']); evalin('base','struct2local(fGlobalVar)'); evalin('base','clear fGlobalVar'); end @@ -135,18 +135,18 @@ while (etime(clock,t0)<1200 && ~isempty(fslave)) || ~isempty(dir(['stayalive',in if(whoiam) % Save the output result. - save([ fname,'_output_',int2str(whoiam),'.mat'],'fOutputVar' ) + save([ fname,'_output_',int2str(whoiam),'.mat'],'fOutputVar' ); % Inform the master that the job is finished, and transfer the output data delete(['P_',fname,'_',int2str(whoiam),'End.txt']); end - disp(['Job ',fname,' on CPU ',int2str(whoiam),' completed.']) + disp(['Job ',fname,' on CPU ',int2str(whoiam),' completed.']); t0 =clock; % Re-set waiting time of 20 mins catch ME - disp(['Job ',fname,' on CPU ',int2str(whoiam),' crashed.']) + disp(['Job ',fname,' on CPU ',int2str(whoiam),' crashed.']); fOutputVar.error = ME; - save([ fname,'_output_',int2str(whoiam),'.mat'],'fOutputVar' ) + save([ fname,'_output_',int2str(whoiam),'.mat'],'fOutputVar' ); waitbarString = fOutputVar.error.message; if Parallel(ThisMatlab).Local, waitbarTitle='Local '; @@ -163,7 +163,7 @@ while (etime(clock,t0)<1200 && ~isempty(fslave)) || ~isempty(dir(['stayalive',in end -disp(['slaveParallel on CPU ',int2str(whoiam),' completed.']) +disp(['slaveParallel on CPU ',int2str(whoiam),' completed.']); diary off; delete(['P_slave_',int2str(whoiam),'End.txt']);