fix path assumption: search in development path first, then install path

Signed-off-by: Thorsten Liebig <Thorsten.Liebig@gmx.de>
pull/10/head
Thorsten Liebig 2013-09-04 13:25:54 +02:00
parent 700fc01c1b
commit 58a5b6d452
2 changed files with 26 additions and 26 deletions

View File

@ -87,12 +87,14 @@ m_filename = mfilename('fullpath');
dir_name = fileparts( m_filename ); dir_name = fileparts( m_filename );
if isunix if isunix
% <openEMS-path> could be /usr or ~/opt/openEMS etc. % try development path
% assume this file to be in '<openEMS-path>/share/openEMS/matlab/' nf2ff_bin = [dir_name filesep '../nf2ff' filesep 'nf2ff'];
% assume openEMS binary to be in '<openEMS-path>/bin' if (~exist(nf2ff_bin,'file'))
openEMS_Path = [dir_name filesep '../../../bin' filesep]; % fallback to install path
nf2ff_bin = [dir_name filesep '../../../bin' filesep 'nf2ff'];
end
else else
openEMS_Path = [dir_name filesep '..' filesep]; nf2ff_bin = [dir_name filesep '..' filesep nf2ff.exe];
end end
if ((exist(nf2ff.hdf5,'file') && (mode==0)) || (mode==2)) if ((exist(nf2ff.hdf5,'file') && (mode==0)) || (mode==2))
@ -110,13 +112,15 @@ savePath = pwd;
cd(Sim_Path); cd(Sim_Path);
try try
if (~exist(nf2ff_bin,'file'))
error('openEMS:CalcNF2FF',['Binary not found: ' nf2ff_bin]);
end
if isunix if isunix
% remove LD_LIBRARY_PATH set by matlab % remove LD_LIBRARY_PATH set by matlab
system(['export LD_LIBRARY_PATH=; ' openEMS_Path 'nf2ff ' filename '.xml']); system(['export LD_LIBRARY_PATH=; ' nf2ff_bin ' ' filename '.xml']);
else else
system([openEMS_Path 'nf2ff.exe ' filename '.xml']); system([nf2ff_bin ' ' filename '.xml']);
end end
nf2ff.hdf5; nf2ff.hdf5;
cd(savePath); cd(savePath);
catch catch

View File

@ -7,7 +7,7 @@ function invoke_openEMS( opts, logfile, silent )
% %
% openEMS matlab interface % openEMS matlab interface
% ----------------------- % -----------------------
% author: Sebastian Held % author: Sebastian Held, Thorsten Liebig
if nargin < 1 if nargin < 1
error 'specify the xml file to simulate' error 'specify the xml file to simulate'
@ -23,27 +23,26 @@ if (nargin < 2) || isempty(logfile)
end end
end end
% opts = [opts ' --disable-dumps'];
% opts = [opts ' --debug-material'];
% opts = [opts ' --debug-boxes'];
% opts = [opts ' --engine=sse'];
% opts = [opts ' --engine=multithreaded'];
filename = mfilename('fullpath'); filename = mfilename('fullpath');
dir = fileparts( filename ); dir = fileparts( filename );
if isunix if isunix
% <openEMS-path> could be /usr or ~/opt/openEMS etc. % try development path
% assume this file to be in '<openEMS-path>/share/openEMS/matlab/private/' openEMS_bin = [dir filesep '../..' filesep 'openEMS.sh'];
% assume openEMS binary to be in '<openEMS-path>/bin' if (~exist(openEMS_bin,'file'))
openEMS_Path = [dir filesep '../../../../bin' filesep]; % fallback to install path
openEMS_Path = [openEMS_Path 'openEMS.sh']; openEMS_bin = [dir filesep '../../../../bin' filesep 'openEMS.sh'];
end
else else
openEMS_Path = [dir filesep '../..' filesep]; openEMS_bin = [dir filesep '../..' filesep];
openEMS_Path = [openEMS_Path 'openEMS']; openEMS_bin = [openEMS_bin 'openEMS'];
end end
command = [openEMS_Path ' ' opts]; if (~exist(openEMS_bin,'file'))
error('openEMS:invoke_openEMS',['Binary not found: ' openEMS_bin]);
end
command = [openEMS_bin ' ' opts];
if ~silent if ~silent
if (isunix && nargin>1) if (isunix && nargin>1)
@ -53,7 +52,4 @@ else
command = [command ' > ' logfile ' 2>&1']; command = [command ' > ' logfile ' 2>&1'];
end end
% if ~silent
% disp( ['invoking openEMS simulator: ' command] );
% end
system(command); system(command);