diff --git a/matlab/CalcNF2FF.m b/matlab/CalcNF2FF.m index e5868ae..c0e233b 100644 --- a/matlab/CalcNF2FF.m +++ b/matlab/CalcNF2FF.m @@ -87,12 +87,14 @@ m_filename = mfilename('fullpath'); dir_name = fileparts( m_filename ); if isunix - % could be /usr or ~/opt/openEMS etc. - % assume this file to be in '/share/openEMS/matlab/' - % assume openEMS binary to be in '/bin' - openEMS_Path = [dir_name filesep '../../../bin' filesep]; + % try development path + nf2ff_bin = [dir_name filesep '../nf2ff' filesep 'nf2ff']; + if (~exist(nf2ff_bin,'file')) + % fallback to install path + nf2ff_bin = [dir_name filesep '../../../bin' filesep 'nf2ff']; + end else - openEMS_Path = [dir_name filesep '..' filesep]; + nf2ff_bin = [dir_name filesep '..' filesep nf2ff.exe]; end if ((exist(nf2ff.hdf5,'file') && (mode==0)) || (mode==2)) @@ -110,13 +112,15 @@ savePath = pwd; cd(Sim_Path); try + if (~exist(nf2ff_bin,'file')) + error('openEMS:CalcNF2FF',['Binary not found: ' nf2ff_bin]); + end if isunix % 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 - system([openEMS_Path 'nf2ff.exe ' filename '.xml']); + system([nf2ff_bin ' ' filename '.xml']); end - nf2ff.hdf5; cd(savePath); catch diff --git a/matlab/private/invoke_openEMS.m b/matlab/private/invoke_openEMS.m index 24bba3f..30c3a0c 100644 --- a/matlab/private/invoke_openEMS.m +++ b/matlab/private/invoke_openEMS.m @@ -7,7 +7,7 @@ function invoke_openEMS( opts, logfile, silent ) % % openEMS matlab interface % ----------------------- -% author: Sebastian Held +% author: Sebastian Held, Thorsten Liebig if nargin < 1 error 'specify the xml file to simulate' @@ -23,27 +23,26 @@ if (nargin < 2) || isempty(logfile) 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'); dir = fileparts( filename ); if isunix - % could be /usr or ~/opt/openEMS etc. - % assume this file to be in '/share/openEMS/matlab/private/' - % assume openEMS binary to be in '/bin' - openEMS_Path = [dir filesep '../../../../bin' filesep]; - openEMS_Path = [openEMS_Path 'openEMS.sh']; + % try development path + openEMS_bin = [dir filesep '../..' filesep 'openEMS.sh']; + if (~exist(openEMS_bin,'file')) + % fallback to install path + openEMS_bin = [dir filesep '../../../../bin' filesep 'openEMS.sh']; + end else - openEMS_Path = [dir filesep '../..' filesep]; - openEMS_Path = [openEMS_Path 'openEMS']; + openEMS_bin = [dir filesep '../..' filesep]; + openEMS_bin = [openEMS_bin 'openEMS']; 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 (isunix && nargin>1) @@ -53,7 +52,4 @@ else command = [command ' > ' logfile ' 2>&1']; end -% if ~silent -% disp( ['invoking openEMS simulator: ' command] ); -% end system(command);