0001 function rundke_metis(path_sources,locid_simul,basestr,shotnum,shotimes,opt,dkepath,wavestructs,equil,dkeparam,dkedisplay,ohm,transpfaste,ripple,metisevol,scheduler_run_lukert)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030 maxnargin = 16;
0031
0032 if nargin < maxnargin,
0033 scheduler_run_lukert = struct;
0034 end
0035 if nargin < maxnargin-1,
0036 metisevol = 0;
0037 end
0038 if nargin < maxnargin-2 || (~isstruct(ripple) && any(isnan(ripple))),
0039 ripple = struct;
0040 end
0041 if nargin < maxnargin-3 || (~isstruct(transpfaste) && any(isnan(transpfaste))),
0042 transpfaste = struct;
0043 end
0044 if nargin < maxnargin-4 || (~isstruct(ohm) && any(isnan(ohm))),
0045 ohm = struct;
0046
0047 end
0048 if nargin < maxnargin-5 || (~isstruct(dkedisplay) && any(isnan(dkedisplay))),
0049 dkedisplay = struct;
0050 end
0051 if nargin < maxnargin-6 || (~isstruct(dkeparam) && any(isnan(dkeparam))),
0052 dkeparam = struct;
0053 end
0054 if nargin < maxnargin-7 || (~isstruct(equil) && any(isnan(equil))),
0055 equil = struct;
0056 end
0057 if nargin < maxnargin-8 || (~iscell(wavestructs) && ~isstruct(wavestructs) && any(isnan(wavestructs))),
0058 wavestructs = struct;
0059 end
0060 if nargin < maxnargin-9 || (~isstruct(dkepath) && any(isnan(dkepath))),
0061 dkepath = load_structures_yp('dkepath','','');
0062 end
0063 if nargin < maxnargin-10 || (~isstruct(opt) && any(isnan(opt))),
0064 opt = struct;
0065 end
0066 if nargin < maxnargin-11,
0067 shotimes = {};
0068 end
0069 if nargin < maxnargin-12,
0070 error('shot number must be specified');
0071 end
0072
0073 dkepath.clustermode.run_lukert.scheduler = scheduler_run_lukert;
0074
0075 if metisevol == 0,
0076 dkepath.clustermode.run_lukert.scheduler.remtimout = 0;
0077 else
0078 dkepath.clustermode.run_lukert.scheduler.remtimout = Inf;
0079 opt.save = 1;
0080 opt.fields = NaN;
0081 dkeparam.tn_mode = 1;
0082 end
0083
0084
0085
0086 if isempty(path_sources),
0087 path_sources = './';
0088 end
0089
0090 [shotimes,isel] = select_shotimes_jd(['before_luke@',basestr,'_',shotnum,'_'],'.mat',path_sources,shotimes);
0091
0092
0093
0094 if ~isnan(isel),
0095
0096
0097
0098 if length(dkeparam) > 1,
0099 dkeparam = dkeparam(isel);
0100 end
0101 if length(dkedisplay) > 1,
0102 dkedisplay = dkedisplay(isel);
0103 end
0104 if length(equil) > 1,
0105 equil = equil(isel);
0106 end
0107 for iw = 1:length(wavestructs),
0108 if iscell(wavestructs) && length(wavestructs{iw}) > 1,
0109 wavestructs{iw} = wavestructs{iw}(isel);
0110 elseif ~iscell(wavestructs) && length(wavestructs) > 1,
0111 wavestructs = wavestructs(isel);
0112 end
0113 end
0114 if length(ohm) > 1,
0115 ohm = ohm(isel);
0116 end
0117 if length(transpfaste) > 1,
0118 transpfaste = transpfaste(isel);
0119 end
0120 if length(ripple) > 1,
0121 ripple = ripple(isel);
0122 end
0123 end
0124
0125 nshots = length(shotimes);
0126
0127
0128
0129 lukestructs = cell(1,nshots);
0130
0131 for ishot = 1:nshots
0132
0133 metis_data = load([path_sources,filesep,'before_luke@',basestr,'_',shotnum,'_',shotimes{ishot},'.mat']);
0134
0135 lukestruct = struct;
0136
0137
0138
0139 if length(dkeparam) > 1,
0140 lukestruct.dkeparam = conc_struct_jd(metis_data.dkeparam,dkeparam(ishot));
0141 else
0142 lukestruct.dkeparam = conc_struct_jd(metis_data.dkeparam,dkeparam);
0143 end
0144
0145 if length(dkedisplay) > 1,
0146 lukestruct.dkedisplay = conc_struct_jd(metis_data.dkedisplay,dkedisplay(ishot));
0147 else
0148 lukestruct.dkedisplay = conc_struct_jd(metis_data.dkedisplay,dkedisplay);
0149 end
0150
0151 if length(equil) > 1,
0152 lukestruct.equil = conc_struct_jd(metis_data.equil,equil(ishot));
0153 else
0154 lukestruct.equil = conc_struct_jd(metis_data.equil,equil);
0155 end
0156
0157 if length(metis_data.wavestructs) == 1 && iscell(wavestructs) && length(wavestructs) > 1,
0158 metis_data.wavestructs = repmat(metis_data.wavestructs,[1,length(wavestructs)]);
0159 end
0160 if isempty(metis_data.wavestructs) && iscell(wavestructs) && length(wavestructs) >= 1,
0161 metis_data.wavestructs = repmat({struct},[1,length(wavestructs)]);
0162 end
0163
0164 lukestruct.wavestructs = {};
0165 for iw = 1:length(metis_data.wavestructs),
0166 if iscell(wavestructs),
0167 if length(wavestructs{iw}) > 1,
0168 lukestruct.wavestructs{iw} = conc_struct_jd(metis_data.wavestructs{iw},wavestructs{iw}(ishot));
0169 else
0170 lukestruct.wavestructs{iw} = conc_struct_jd(metis_data.wavestructs{iw},wavestructs{iw});
0171 end
0172 else
0173 if length(wavestructs) > 1,
0174 lukestruct.wavestructs{iw} = conc_struct_jd(metis_data.wavestructs{iw},wavestructs(ishot));
0175 else
0176 lukestruct.wavestructs{iw} = conc_struct_jd(metis_data.wavestructs{iw},wavestructs);
0177 end
0178 end
0179 end
0180
0181 if length(ohm) > 1,
0182 lukestruct.ohm = conc_struct_jd(metis_data.ohm,ohm(ishot));
0183 else
0184 lukestruct.ohm = conc_struct_jd(metis_data.ohm,ohm);
0185 end
0186 if length(transpfaste) > 1,
0187 lukestruct.transpfaste = conc_struct_jd(metis_data.transpfaste,transpfaste(ishot));
0188 else
0189 lukestruct.transpfaste = conc_struct_jd(metis_data.transpfaste,transpfaste);
0190 end
0191 if length(ripple) > 1,
0192 lukestruct.ripple = conc_struct_jd(metis_data.ripple,ripple(ishot));
0193 else
0194 lukestruct.ripple = conc_struct_jd(metis_data.ripple,ripple);
0195 end
0196
0197 lukestruct.opt = opt;
0198
0199
0200
0201 lukestruct.simul.id = ['METIS_',make_luke_simulid_jd(lukestruct.equil,lukestruct.ohm,lukestruct.transpfaste,lukestruct.ripple,...
0202 '',lukestruct.wavestructs,locid_simul)];
0203
0204 if (~isfield(dkepath,'remnum') || dkepath.remnum == 0 || isempty(dkepath.remote(dkepath.remnum).host)) && ...
0205 (~isfield(scheduler_run_lukert,'mode') || scheduler_run_lukert.mode >= 0),
0206 lukestruct.simul.path = path_sources;
0207 end
0208
0209 lukestructs{ishot} = lukestruct;
0210
0211 if isfield(opt,'saveinputs') && opt.saveinputs == 1,
0212
0213 saveinputs_jd(lukestruct);
0214
0215 end
0216
0217 end
0218
0219
0220
0221 if metisevol == 0,
0222
0223 lukestructs = run_lukert(lukestructs,dkepath);
0224
0225 else
0226
0227 if metisevol == 1,
0228 lukestructs{1}.dkeparam.tn = NaN;
0229 else
0230 lukestructs{1}.dkeparam.tn = str2double(shotimes{1});
0231 end
0232
0233 lukestruct = run_lukert(lukestructs{1},dkepath);
0234
0235 if ~isfield(lukestruct.dkeparam,'Te_ref') || ~isfield(lukestruct.dkeparam,'ne_ref'),
0236 lukestruct.dkeparam.Te_ref = lukestruct.output.mksa.Te_ref;
0237 lukestruct.dkeparam.ne_ref = lukestruct.output.mksa.ne_ref;
0238 end
0239
0240 for ishot = 2:nshots,
0241 lukestructs{ishot}.XXf0 = lukestruct.output.dke_out.Zf0_interp(end);
0242 lukestructs{ishot}.dkeparam.rho_S = lukestruct.output.radialDKE.xrho_S_dke;
0243 lukestructs{ishot}.dkeparam.tn = str2double(shotimes{ishot}) - str2double(shotimes{ishot-1});
0244
0245 lukestruct = run_lukert(lukestructs{ishot},dkepath);
0246 end
0247 end
0248
0249
0250
0251 if ~isfield(opt,'save') || opt.save == 0,
0252
0253 savestr = [basestr,'_',shotnum];
0254
0255 if ~isempty(locid_simul),
0256 savestr = [savestr,'_',locid_simul];
0257 end
0258
0259 save_batch_jd(lukestructs,dkepath,savestr)
0260
0261 end
0262