Skip to content
Snippets Groups Projects
Commit 224e4721 authored by Olivier Sauter's avatar Olivier Sauter
Browse files

avoid mdsconnect if already connected to tunnel (localhost)

parent c5146a94
No related branches found
No related tags found
1 merge request!128D3d addons
Pipeline #143925 passed
......@@ -6,13 +6,13 @@ function [data,ier,varnames_all,varnames_dot_all] = get_mds_tree_d3d(shot, tree
% data= get_mds_tree(shot, 'EFIT01', 'NSTX'); % for NSTX
% data= get_mds_tree(shot, 'NB', 'DIII-D'); % example other tree
%
% PURPOSE: Get entire selected mds tree from mdsplus database.
% PURPOSE: Get entire selected mds tree from mdsplus database.
%
% INPUT: <default>
% shot = shot number
% tree = tree to use <'EFIT01'>
% server = MDS+ database to use: 'DIII-D'(default),'NSTX','EAST',
% 'THOR', 'OPEN'(assumes mdsconnect already called). Other
% 'THOR', 'OPEN'(assumes mdsconnect already called). Other
% inputs invoke mdsconnect(server) to connect to server.
% toupper = 1= all variables made upper case, =-1 all var. made lower case
% [0]= no change, variables made depending on mds case (typical UC)
......@@ -21,9 +21,9 @@ function [data,ier,varnames_all,varnames_dot_all] = get_mds_tree_d3d(shot, tree
% <0> server= 'DIII-D' & all others;
%
% OUTPUT:
% data = structure containing all data in MDS+ tree, with same tree
% data = structure containing all data in MDS+ tree, with same tree
% structure except that 'TOP' replaced by 'tree'
% See: data.allnames for list of all variables in full structure
% See: data.allnames for list of all variables in full structure
% Some Extra items added to structure (all lower case)
% data.id = sting array of important data identifyer enf
% data.shot = shot number
......@@ -31,15 +31,15 @@ function [data,ier,varnames_all,varnames_dot_all] = get_mds_tree_d3d(shot, tree
% data.allnames= list of variables in structure with path relative to "TOP"
% data.mdsnames= list of variables in structure with full mds path
% ier = error code
%
%
% WRITTEN BY: Jim Leuer ON 3/1/05 (original name get_mds_tree)
% taken from get_mds_tree.m uses sub-structure to store
%
% USES: eq_mod
% To see MDS structure on HYDRA run traverser
% tested on DIII-D and NSTX data and should work for JET data but not tested
%
% CHANGE LOG: SMF 20140923 - Changed getnci call to use nid_numbers due to
%
% CHANGE LOG: SMF 20140923 - Changed getnci call to use nid_numbers due to
% fullpath not accepting wildcards.
%
% ==========================================================================
......@@ -70,44 +70,55 @@ function [data,ier,varnames_all,varnames_dot_all] = get_mds_tree_d3d(shot, tree
if isempty(toupper) toupper= 0; end
if isempty(server) server= 'DIII-D'; end
if isempty(tree) tree= 'EFIT01'; end
if isempty(verbose)
if isempty(verbose)
if strcmp(server,'NSTX') | strcmp(server,'EAST')
verbose=1;
else
verbose=0;
end
end
% -----------------------------------------------
% Open and check conneciton to MDSPLUS data base:
tic
ier= 0; status=1;
mdsisopen=0;
% [shoto,status]=mdsopen('atlas.gat.com::EFIT01',shot)
if strcmp(server,'DIII-D') | strcmp(server,'DIIID') | strcmp(server,'D3D')
status = mdsconnect('atlas.gat.com');
elseif strcmp(server,'EAST')
status = mdsconnect('202.127.204.12'); % NOT SURE THIS WORKS
elseif strcmp(server,'NSTX')
status = mdsconnect('skylark.pppl.gov:8501');
elseif strcmp(server,'KSTAR')
if(strcmp(getenv('HOST'),'datagrid') | strcmp(getenv('HOST'),'ksim2')) % On site at NFRI
mds_server = '172.17.100.200:8300';
else % Offsite
% mds_server = '203.230.125.212:8005'; % not able to connect to NFRI server directly
mds_server = 'kd';
end
status = mdsconnect(mds_server);
elseif strcmp(server,'THOR')
status = mdsconnect('thor');
elseif strcmp(server,'VIDAR')
status = mdsconnect('vidar');
elseif strcmp(server,'OPEN')
disp(['get_mds_tree: Assuming MDSCONNECT already called and MDS is ',server])
if exist('mdscurrent') > 0
aa=mdscurrent;
else
aa='will connect';
end
if strmatch('localhost',aa)
% already connected to localhost
status = 1;
else
disp(['get_mds_tree: Attempting to connect to server = ',server])
status = mdsconnect(server);
end
% [shoto,status]=mdsopen('atlas.gat.com::EFIT01',shot)
if strcmp(aa,'will connect') || isempty(aa)
if strcmp(server,'DIII-D') | strcmp(server,'DIIID') | strcmp(server,'D3D')
status = mdsconnect('atlas.gat.com');
elseif strcmp(server,'EAST')
status = mdsconnect('202.127.204.12'); % NOT SURE THIS WORKS
elseif strcmp(server,'NSTX')
status = mdsconnect('skylark.pppl.gov:8501');
elseif strcmp(server,'KSTAR')
if(strcmp(getenv('HOST'),'datagrid') | strcmp(getenv('HOST'),'ksim2')) % On site at NFRI
mds_server = '172.17.100.200:8300';
else % Offsite
% mds_server = '203.230.125.212:8005'; % not able to connect to NFRI server directly
mds_server = 'kd';
end
status = mdsconnect(mds_server);
elseif strcmp(server,'THOR')
status = mdsconnect('thor');
elseif strcmp(server,'VIDAR')
status = mdsconnect('vidar');
elseif strcmp(server,'OPEN')
disp(['get_mds_tree: Assuming MDSCONNECT already called and MDS is ',server])
status = 1;
else
disp(['get_mds_tree: Attempting to connect to server = ',server])
status = mdsconnect(server);
end
end
if ~mod(status,2)
......@@ -131,7 +142,7 @@ function [data,ier,varnames_all,varnames_dot_all] = get_mds_tree_d3d(shot, tree
return;
else
if(verbose)
disp(['% get_mds_tree opened tree, shot: ' tree ' ' int2str(shot)])
disp(['% get_mds_tree opened tree, shot: ' tree ' ' int2str(shot)])
end
end
......@@ -156,7 +167,7 @@ function [data,ier,varnames_all,varnames_dot_all] = get_mds_tree_d3d(shot, tree
mds_all= strvcat(mds_all,mds_ot);
mds_ot= mds_sub_tree(mds_ot);
end
% ===============================================================
% Process each name in mds_all for all variables present
% ===============================================================
......@@ -165,10 +176,10 @@ function [data,ier,varnames_all,varnames_dot_all] = get_mds_tree_d3d(shot, tree
% kk
mds_nam = deblank(mds_all(kk,:));
mdscmd = ['getnci("\' mds_nam ':*","NID_NUMBER")'];
[mds_nids,mstatus] = mdsvalue(mdscmd);
[mds_nids,mstatus] = mdsvalue(mdscmd);
if ~mod(mstatus,2) % handle nstx different format
mdscmd = ['getnci("\\\' mds_nam ':*","NID_NUMBER")'];
[mds_nids,mstatus] = mdsvalue(mdscmd);
[mds_nids,mstatus] = mdsvalue(mdscmd);
end
varnames = [];
if mod(mstatus,2)
......@@ -185,19 +196,19 @@ function [data,ier,varnames_all,varnames_dot_all] = get_mds_tree_d3d(shot, tree
varnamesc = char(varnames);
idgood = strmatch(upper(mds_nam0),upper(varnamesc));
varnamesc = varnamesc(idgood,:);
data_namesc = varnamesc(:,top_num+2:end);
data_namesc = varnamesc(:,top_num+2:end);
numvar = size(varnamesc,1);
% loop over all variables
if numvar>=30
tic
for ii= 1:numvar
% ii=0; ii=ii+1;
fullnam= deblank(varnamesc(ii,:));
fullnam= deblank(varnamesc(ii,:));
data.mdsnames= strvcat(data.mdsnames,fullnam);
dat= mdsvalue(fullnam); % Actual value of data
dat= mdsvalue(fullnam); % Actual value of data
subnam= deblank(data_namesc(ii,:)); %
subnam= deblank(data_namesc(ii,:)); %
id= findstr(subnam,':');
subnam(id)= '.';
if toupper==1
......@@ -221,9 +232,9 @@ function [data,ier,varnames_all,varnames_dot_all] = get_mds_tree_d3d(shot, tree
for ii= 1:numvar
fullnam= deblank(varnamesc(ii,:));
data.mdsnames= strvcat(data.mdsnames,fullnam);
dat= mdsvalue(fullnam); % Actual value of data
dat= mdsvalue(fullnam); % Actual value of data
subnam= deblank(data_namesc(ii,:)); %
subnam= deblank(data_namesc(ii,:)); %
id= findstr(subnam,':');
subnam(id)= '.';
if toupper==1
......@@ -242,18 +253,18 @@ function [data,ier,varnames_all,varnames_dot_all] = get_mds_tree_d3d(shot, tree
eval(str);
end % for ii
end % if numvar
end % for kk
end % for kk
if strcmp(server,'NSTX') | strcmp(server,'EAST')
status=mdsdisconnect; % Exit MDS+ if conneced to remote server
end
return
% ========================================================
% Testing
% ========================================================
% Testing SEE test_get_mds_tree
% (WATCH OUT 114504 has problems use 98549 Ferron High Performance)
......@@ -273,9 +284,9 @@ function [data,ier,varnames_all,varnames_dot_all] = get_mds_tree_d3d(shot, tree
filename='/u/leuer/efit/diiid/s98549/g098549.04000' %
read_gfile
shot=98549; tree='IONS'; server='DIII-D'; toupper=-1;
shot=98549; tree='IONS'; server='DIII-D'; toupper=-1;
ions= get_mds_tree(shot, tree, server, toupper);
shot=98549; tree='NB'; server='DIII-D'; toupper=-1;
shot=98549; tree='NB'; server='DIII-D'; toupper=-1;
nb= get_mds_tree(shot, tree, server, toupper);
% ========================================================
......@@ -288,4 +299,3 @@ function [data,ier,varnames_all,varnames_dot_all] = get_mds_tree_d3d(shot, tree
shot=113363; tree='EFIT01'; server='NSTX';
clear data
data= get_mds_tree(shot, tree, server);
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