openEMS/matlab/private/invoke_openEMS.m

56 lines
1.2 KiB
Matlab
Raw Normal View History

function invoke_openEMS( opts, logfile, silent )
% function invoke_openEMS( opts, logfile, silent )
%
% internal method to invoke openEMS, use RunOpenEMS instead
%
% See also RunOpenEMS
%
% openEMS matlab interface
% -----------------------
% author: Sebastian Held, Thorsten Liebig
2010-05-03 20:09:40 +00:00
if nargin < 1
error 'specify the xml file to simulate'
end
if nargin < 3
silent = 0;
end
if (nargin < 2) || isempty(logfile)
if isunix
logfile = '/dev/null';
else
logfile = 'nul:';
end
end
2010-05-03 20:09:40 +00:00
filename = mfilename('fullpath');
dir = fileparts( filename );
2012-11-16 20:44:46 +00:00
2010-05-03 20:09:40 +00:00
if isunix
% 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
2010-05-03 20:09:40 +00:00
else
openEMS_bin = [dir filesep '../..' filesep];
openEMS_bin = [openEMS_bin 'openEMS'];
end
if (~exist(openEMS_bin,'file'))
error('openEMS:invoke_openEMS',['Binary not found: ' openEMS_bin]);
2010-05-03 20:09:40 +00:00
end
command = [openEMS_bin ' ' opts];
if ~silent
if (isunix && nargin>1)
command = [command ' 2>&1 | tee ' logfile];
end
else
command = [command ' > ' logfile ' 2>&1'];
end
2010-05-03 20:09:40 +00:00
system(command);