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
Branches
Tags
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 ...@@ -115,10 +115,17 @@ if nargin>=2 % need at least 2 inputs to have 'machine','aug' as arguments (to a
end end
end end
% add paths to each machine which are in subdirectory of gdat and working % Avoid running addpath over and over, this can take some time when there
% add only given machine directory using machine_eff... % are many folders in the path
gdat_path = mfilename('fullpath'); persistent last_machine
eval(['addpath ' gdat_path(1:end-4) upper(machine_eff)]);
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: % copy gdat present call:
gdat_call = []; gdat_call = [];
...@@ -156,21 +163,22 @@ gdat_call = [subcall ' % nargout = ' num2str(nargout)]; ...@@ -156,21 +163,22 @@ gdat_call = [subcall ' % nargout = ' num2str(nargout)];
% copy subcall here so is last subnode % copy subcall here so is last subnode
try try
if nargin==0 if nargin==0
eval(['[gdat_data,gdat_params,error_status,varargout] = gdat_' lower(machine_eff) ';']); args = {};
elseif nargin==1 elseif nargin==1
eval(['[gdat_data,gdat_params,error_status,varargout] = gdat_' lower(machine_eff) '(shot);']); args = {shot};
elseif nargin==2 elseif nargin==2
eval(['[gdat_data,gdat_params,error_status,varargout] = gdat_' lower(machine_eff) '(shot,data_request);']); args = {shot,data_request};
else 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 end
[gdat_data,gdat_params,error_status,varargout] = feval(['gdat_' lower(machine_eff)],args{:});
catch ME_gdat catch ME_gdat
warning(['problems calling gdat_' lower(machine_eff)]); 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 ~isfield(gdat_data,'dim'); gdat_data.dim=[]; end
if ~exist('gdat_params'); gdat_params.plot = []; end if ~exist('gdat_params','var'); gdat_params.plot = []; end
if ~exist('error_status'); error_status = 998; end if ~exist('error_status','var'); error_status = 998; end
if exist('ME_gdat') if exist('ME_gdat','var')
getReport(ME_gdat) getReport(ME_gdat)
end end
return return
...@@ -186,7 +194,7 @@ if gdat_data.gdat_params.doplot ...@@ -186,7 +194,7 @@ if gdat_data.gdat_params.doplot
hhh = []; hhh = [];
end end
if nargout >=3 if nargout >=3
if length(varargout)==0 || isempty(varargout{1}) if isempty(varargout) || isempty(varargout{1})
varargout{1} = hhh; varargout{1} = hhh;
else else
varargout{end+1} = hhh; varargout{end+1} = hhh;
...@@ -194,6 +202,6 @@ if gdat_data.gdat_params.doplot ...@@ -194,6 +202,6 @@ if gdat_data.gdat_params.doplot
end end
end end
if exist('ME_gdat_plot') if exist('ME_gdat_plot','var')
getReport(ME_gdat_plot) getReport(ME_gdat_plot)
end end
...@@ -17,6 +17,16 @@ if isempty(ij) ...@@ -17,6 +17,16 @@ if isempty(ij)
return return
end end
machine_in = lower(machine_in); 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'); fid=fopen([machine_in '_requests_mapping.m'],'r');
nextline=fgetl(fid); nextline=fgetl(fid);
keywds = []; keywds = [];
...@@ -40,3 +50,6 @@ end ...@@ -40,3 +50,6 @@ end
fclose(fid); fclose(fid);
data_request_names.all = []; 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.
Please register or to comment