Skip to content
Snippets Groups Projects
Commit 7a543e09 authored by Antoine Merle's avatar Antoine Merle
Browse files

* Add persistent variable to avoid to constantly add the same folders to the...

* Add persistent variable to avoid to constantly add the same folders to the path or to get the list of data requests

git-svn-id: https://spcsvn.epfl.ch/repos/TCV/gdat/trunk@6182 d63d8f72-b253-0410-a779-e742ad2e26cf
parent 1dcee0f8
No related branches found
No related tags found
No related merge requests found
......@@ -115,10 +115,17 @@ if nargin>=2 % need at least 2 inputs to have 'machine','aug' as arguments (to a
end
end
% add paths to each machine which are in subdirectory of gdat and working
% add only given machine directory using machine_eff...
gdat_path = mfilename('fullpath');
eval(['addpath ' gdat_path(1:end-4) upper(machine_eff)]);
% Avoid running addpath over and over, this can take some time when there
% are many folders in the path
persistent last_machine
if isempty(last_machine) || ~strcmpi(last_machine,machine_eff)
% add paths to each machine which are in subdirectory of gdat and working
% add only given machine directory using machine_eff...
gdat_path = mfilename('fullpath');
addpath([gdat_path(1:end-4) upper(machine_eff)]);
last_machine = machine_eff;
end
% copy gdat present call:
gdat_call = [];
......@@ -156,21 +163,22 @@ gdat_call = [subcall ' % nargout = ' num2str(nargout)];
% copy subcall here so is last subnode
try
if nargin==0
eval(['[gdat_data,gdat_params,error_status,varargout] = gdat_' lower(machine_eff) ';']);
args = {};
elseif nargin==1
eval(['[gdat_data,gdat_params,error_status,varargout] = gdat_' lower(machine_eff) '(shot);']);
args = {shot};
elseif nargin==2
eval(['[gdat_data,gdat_params,error_status,varargout] = gdat_' lower(machine_eff) '(shot,data_request);']);
args = {shot,data_request};
else
eval(['[gdat_data,gdat_params,error_status,varargout] = gdat_' lower(machine_eff) '(shot,data_request,varargin_eff{:});']);
args = [{shot,data_request},varargin_eff];
end
[gdat_data,gdat_params,error_status,varargout] = feval(['gdat_' lower(machine_eff)],args{:});
catch ME_gdat
warning(['problems calling gdat_' lower(machine_eff)]);
if ~exist('gdat_data'); gdat_data.data = []; end
if ~exist('gdat_data','var'); gdat_data.data = []; end
if ~isfield(gdat_data,'dim'); gdat_data.dim=[]; end
if ~exist('gdat_params'); gdat_params.plot = []; end
if ~exist('error_status'); error_status = 998; end
if exist('ME_gdat')
if ~exist('gdat_params','var'); gdat_params.plot = []; end
if ~exist('error_status','var'); error_status = 998; end
if exist('ME_gdat','var')
getReport(ME_gdat)
end
return
......@@ -186,7 +194,7 @@ if gdat_data.gdat_params.doplot
hhh = [];
end
if nargout >=3
if length(varargout)==0 || isempty(varargout{1})
if isempty(varargout) || isempty(varargout{1})
varargout{1} = hhh;
else
varargout{end+1} = hhh;
......@@ -194,6 +202,6 @@ if gdat_data.gdat_params.doplot
end
end
if exist('ME_gdat_plot')
if exist('ME_gdat_plot','var')
getReport(ME_gdat_plot)
end
......@@ -17,6 +17,16 @@ if isempty(ij)
return
end
machine_in = lower(machine_in);
% Avoid running this function over and over
% This is another bottleneck in the gdat execution.
persistent last_machine last_answer
if ~isempty(last_machine) && strcmpi(last_machine,machine_in)
data_request_names = last_answer;
return;
end
fid=fopen([machine_in '_requests_mapping.m'],'r');
nextline=fgetl(fid);
keywds = [];
......@@ -40,3 +50,6 @@ end
fclose(fid);
data_request_names.all = [];
last_machine = machine_in;
last_answer = data_request_names;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment