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

Drop persistent variable and check if gdat_MACHINE is not already in the path.

git-svn-id: https://spcsvn.epfl.ch/repos/TCV/gdat/trunk@9687 d63d8f72-b253-0410-a779-e742ad2e26cf
parent 066f940a
No related merge requests found
...@@ -118,15 +118,12 @@ end ...@@ -118,15 +118,12 @@ end
% Avoid running addpath over and over, this can take some time when there % Avoid running addpath over and over, this can take some time when there
% are many folders in the path % are many folders in the path
persistent last_machine subfunction = sprintf('gdat_%s',deblank(lower(machine_eff)));
if isempty(which(subfunction)),
if isempty(last_machine) || ~strcmpi(last_machine,machine_eff) gdat_path = fileparts(mfilename('fullpath'));
% add paths to each machine which are in subdirectory of gdat and working addpath(fullfile(gdat_path,upper(machine_eff)));
% 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 end
% NOTE: we could also check if it matches the path to the main function.
% copy gdat present call: % copy gdat present call:
gdat_call = []; gdat_call = [];
......
function gdatpaths
% %
% add paths for gdat directory % add paths for gdat directory
% %
% assumes gdat already available % assumes gdat already available
% %
a=which('gdat'); a=which('gdat');
ii=findstr('/',a); if isempty(a), error('gdat is not in the MATLAB path'); end
a=a(1:ii(end)); a = fileparts(a);
machines=[{'JET'} {'TCV'} {'AUG'} {'D3D'}]; machines=[{'JET'} {'TCV'} {'AUG'} {'D3D'}];
machines=[{'JET'} {'TCV'} {'AUG'} {'KSTAR'}]; machines=[{'JET'} {'TCV'} {'AUG'} {'KSTAR'}];
...@@ -13,7 +14,6 @@ machines=[{'JET'} {'TCV'} {'AUG'} {'D3D'} {'KSTAR'}]; ...@@ -13,7 +14,6 @@ machines=[{'JET'} {'TCV'} {'AUG'} {'D3D'} {'KSTAR'}];
add_paths = cell(1,length(machines)); add_paths = cell(1,length(machines));
for i=1:length(machines) for i=1:length(machines)
add_paths{i}=[a machines{i}]; add_paths{i}=fullfile(a,machines{i});
end end
addpath(add_paths{:}); addpath(add_paths{:});
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