Commit 689d897f authored by Andrew Senior's avatar Andrew Senior

Added support for using nec2c as the NEC2 model engine instead of the Fortran

nec2 code. The model engine used can be chosen in the configuration file and
the choice is offered by the setup function.
parent 7c068c19
......@@ -26,7 +26,6 @@ conf=getconfig;
log_dir=conf.log_dir;
model_dir=conf.model_dir;
nec2_bin=conf.nec2_bin;
results_dir=conf.results_dir;
plots_dir=conf.plots_dir;
......@@ -186,11 +185,20 @@ for gnum=1:length(txg)
mkexcitation(modname,'nec_in.txt',txg(gnum));
% run NEC2
fprintf(' *** running NEC2 ***\n');
fflush(1);
[status,output]=system([nec2_bin ' nec_in.txt nec_out.txt']);
switch conf.model_engine
case 'nec2'
nec_cmd=[conf.nec2_bin ' nec_in.txt nec_out.txt'];
case 'nec2c'
nec_cmd=[conf.nec2c_bin ' -i nec_in.txt -o nec_out.txt'];
otherwise
error('Unknown model engine: %s',conf.model_engine);
end
[status,output]=system(nec_cmd);
if status ~= 0
error('Error %d running NEC2: %s',status,output);
end
......
......@@ -33,6 +33,13 @@ if isempty(C)
%C.nec2_bin='/home/andrew/devel/nec/nec-2/nec/nec2';
C.nec2_bin='/the/real/path/to/nec2';
% path to NEC2C binary
C.nec2c_bin='nec2c';
% which model engine to use
% 'nec2' for Fortran-based version, 'nec2c' for C-based version
C.model_engine='nec2';
data_root=fullfile(getenv('HOME'),'heatererp');
% directory containing transmitter logs
......@@ -69,7 +76,8 @@ if isempty(C)
% Store final parameters into configuration structure
conf_params={'model_dir','nec2_bin','log_dir','results_dir', ...
'plots_dir','ant_segments','ant_wire_radius'};
'plots_dir','ant_segments','ant_wire_radius', ...
'model_engine','nec2c_bin'};
for k=1:length(conf_params)
if exist(conf_params{k},'var')
......
......@@ -36,7 +36,7 @@ while 1
break;
end
if ~isempty(strfind(l,'- - - CURRENTS AND LOCATION - - -'))
if ~isempty(strfind(l,'- CURRENTS AND LOCATION -'))
fprintf('found currents\n');
rp_found=1;
break;
......
......@@ -37,7 +37,7 @@ while 1
break;
end
if ~isempty(strfind(l,'- - - RADIATION PATTERNS - - -'))
if ~isempty(strfind(l,'- RADIATION PATTERNS -'))
fprintf('found radiation pattern\n');
rp_found=1;
break;
......
......@@ -36,7 +36,7 @@ while 1
break;
end
if ~isempty(strfind(l,'- - - ANTENNA INPUT PARAMETERS - - -'))
if ~isempty(strfind(l,'- ANTENNA INPUT PARAMETERS -'))
fprintf('found source data\n');
src_found=1;
break;
......
......@@ -26,13 +26,23 @@ if ~isempty(s)
C.model_dir=s;
end
fprintf('\nThe path to the NEC2 binary (executable)\n');
fprintf('is currently: %s\n',C.nec2_bin);
fprintf('Enter a new path, or blank to leave it unchanged.\n');
fprintf('\nDo you want to use nec2c as the model engine?\n');
fprintf('Enter Y if you do, anything else or blank if not.\n');
fflush(stdout);
s=input('> ','s');
if ~isempty(s)
C.nec2_bin=s;
if strcmp(s,'Y')
C.model_engine='nec2c';
fprintf('Using nec2c as the model engine.\n');
else
C.model_engine='nec2';
fprintf('\nThe path to the NEC2 binary (executable)\n');
fprintf('is currently: %s\n',C.nec2_bin);
fprintf('Enter a new path, or blank to leave it unchanged.\n');
fflush(stdout);
s=input('> ','s');
if ~isempty(s)
C.nec2_bin=s;
end
end
fprintf('\nThe directory where the transmitter log files are stored\n');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment