matlab: allow running MPI openEMS on a HPC

Signed-off-by: Thorsten Liebig <Thorsten.Liebig@gmx.de>
This commit is contained in:
Thorsten Liebig 2013-05-15 16:03:48 +02:00
parent a607bc6969
commit 8698f7a448
2 changed files with 54 additions and 49 deletions

View File

@ -59,7 +59,7 @@ function RunOpenEMS(Sim_Path, Sim_File, opts, Settings)
% WriteOpenEMS('/tmp/path_to_run_in/myfile.xml', FDTD, CSX)
% RunOpenEMS('/tmp/path_to_run_in','myfile.xml','-v')
%
% See also WriteOpenEMS FindFreeSSH InitCSX InitFDTD
% See also WriteOpenEMS FindFreeSSH InitCSX InitFDTD RunOpenEMS_MPI
%
% openEMS matlab interface
% -----------------------

View File

@ -42,6 +42,7 @@ cd(Sim_Path);
scp_options = '-C -o "PasswordAuthentication no" -o "StrictHostKeyChecking no"';
ssh_options = [scp_options ' -x'];
if isfield(Settings.MPI,'Hosts')
Remote_Nodes = Settings.MPI.Hosts;
HostList = '';
for n=1:numel(Remote_Nodes)
@ -70,6 +71,7 @@ for n=1:numel(Remote_Nodes)
error('openEMS:RunOpenEMS',['scp to remote ' remote_name ' failed!']);
end
end
end
%run openEMS (with log file if requested)
@ -79,21 +81,23 @@ else
append_unix = [];
end
disp(['Running remote openEMS_MPI in working dir: ' work_path]);
if ~isfield(Settings.MPI,'GlobalArgs')
Settings.MPI.GlobalArgs = '';
end
if isfield(Settings.MPI,'Hosts')
disp(['Running remote openEMS_MPI in working dir: ' work_path]);
[status] = system(['mpiexec -host ' HostList ' -n ' int2str(NrProc) ' -wdir ' work_path ' ' Settings.MPI.Binary ' ' Sim_File ' ' opts ' ' append_unix]);
else
[status] = system(['mpiexec ' Settings.MPI.GlobalArgs ' -n ' int2str(NrProc) ' -wdir ' work_path ' ' Settings.MPI.Binary ' ' Sim_File ' ' opts ' ' append_unix]);
disp('Running local openEMS_MPI');
[status] = system(['mpiexec ' Settings.MPI.GlobalArgs ' -n ' int2str(NrProc) ' ' Settings.MPI.Binary ' ' Sim_File ' ' opts ' ' append_unix]);
end
if (status~=0)
error('openEMS:RunOpenEMS','mpirun openEMS failed!');
end
if isfield(Settings.MPI,'Hosts')
disp( 'Remote simulation done... copying back results and cleaning up...' );
if (strncmp(work_path,'/tmp/',5)~=1) % savety precaution...
@ -116,5 +120,6 @@ for n=1:numel(Remote_Nodes)
warning('openEMS:RunOpenEMS','remote cleanup failed!');
end
end
end
cd(savePath);