0001 function external = iload_externaldata_jd(dkepath,basestr,workdir,opt_gui,style)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023 if nargin < 5,
0024 style = struct;
0025 end
0026 if nargin < 4,
0027 opt_gui = true;
0028 end
0029 if ~isfield(style,'distselectstyle'),
0030 style.distselectstyle = style;
0031 end
0032
0033 external = [];
0034
0035
0036
0037 LUKE_REMNUM = getenv('LUKE_REMNUM');
0038 if isempty(LUKE_REMNUM),
0039 remnum = iselect_jd(dkepath.remprofiles,'Select local or remote location for database quest',opt_gui,style.distselectstyle,1,'popupmenu') - 1;
0040 else
0041 remnum = str2double(LUKE_REMNUM);
0042 end
0043
0044 if remnum == 0,
0045 remote = [];
0046 else
0047 remote = dkepath.remote(remnum);
0048 end
0049
0050
0051
0052 if nargin > 1 && ~isempty(basestr),
0053
0054 fname = ['load_externaldata_',basestr];
0055
0056 if ~exist(fname,'file'),
0057
0058 disp(['-----> Database access is not implemented for ',basestr]);
0059 return;
0060
0061 end
0062
0063 else
0064
0065 basestrs = find_externalbases_jd(dkepath.luke_root);
0066
0067 if isempty(basestrs),
0068 external.err = 'No function found to import from database';
0069 return
0070 end
0071
0072 LUKE_EXTERNAL = getenv('LUKE_EXTERNAL');
0073 ibasestr = find(strcmp(basestrs,LUKE_EXTERNAL));
0074
0075 if isempty(ibasestr),
0076 ibasestr = find(strcmp(basestrs,'TS'));
0077 end
0078
0079 style.butwidth = 150;
0080 baseselect = iselect_jd(basestrs,'Select tokamak (and eventually database function)',opt_gui,style,ibasestr,'popupmenu');
0081 basestr = basestrs{baseselect};
0082
0083 fname = ['load_externaldata_',basestr];
0084
0085 end
0086
0087 iMultiTimes = strfind(basestr,'MultiTimes');
0088
0089
0090
0091 if ~any(iMultiTimes),
0092
0093
0094
0095 external_in = feval(fname);
0096
0097
0098
0099 external_in = imod_struct_jd(external_in,'external',0,boolean(opt_gui),external_in,style);
0100
0101 [err,~,external_out] = matremote_jd(fname,{external_in,opt_gui},remote);
0102
0103 if isempty(err),
0104 external = external_out;
0105 end
0106
0107 else
0108
0109 external = feval(fname,pwd,opt_gui,style,remote);
0110
0111 end
0112 end
0113
0114 function basestrs = find_externalbases_jd(luke_root)
0115
0116 datadir = [luke_root,'Project_DKE/Database/EXTERNAL_files/'];
0117
0118 datafiles = dir(datadir);
0119
0120 strtofind = 'load_externaldata_';
0121
0122 basestrs = {};
0123
0124 for iname = 1:length(datafiles),
0125 if length(datafiles(iname).name) > length(strtofind) && strcmp(datafiles(iname).name(1:length(strtofind)),strtofind) && strcmp(datafiles(iname).name(end-1:end),'.m'),
0126 basestrs = [basestrs,datafiles(iname).name(length(strtofind)+1:end-2)];
0127 end
0128 end
0129
0130 end
0131