iluke_run

PURPOSE ^

script iluke_run to run and check luke runs

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

 script iluke_run to run and check luke runs

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %
0002 % script iluke_run to run and check luke runs
0003 %
0004 if strcmp(action,'lukestart'),
0005     %
0006     timedep = 1 - lukeobj.timedep.value;
0007     %
0008     if curtime > 0 || timedep,%single time or dependent calculation
0009         mdce_mode = 0;
0010     else% independent multi-time calculation
0011         mdce_mode = lukeobj.dist.select.value - 1;
0012     end
0013     %
0014     remnum = lukeobj.remote.select.value - 1;
0015     %
0016     if remnum > 0,
0017         returnmode = lukeobj.timeout.value;
0018     else
0019         returnmode = 0;
0020     end
0021     %
0022     if curtime > 0
0023         transpmode = transpfastes{curtime};
0024     elseif strcmp(lukeobj.transp.modify.state,'on'),%all transpfastes are identical
0025         transpmode = transpfastes{1};
0026     else
0027         transpmode = true;% ensure enough memory by default
0028     end
0029     %
0030     dkepath = lukeschedulerparam(dkepath,mdce_mode,remnum,returnmode,transpmode,false);
0031     %
0032     opt.backup = 1;% save intermediate results with fluctuations
0033     %
0034     if curtime > 0,
0035         %
0036         opt.save = 0;% (1): save LUKE_RESULTS or return error (0): return results or error
0037         opt.proc = [];% if not empty, structure containing options for proc_luke. In that case, opt.fields = {'data_proc'}.
0038         %
0039         lukestructs = struct;
0040         %
0041         lukestructs.simul.id = lukeobj.lukeid.string;
0042         if remnum == 0 && mdce_mode <= 3,% local calculation
0043             lukestructs.simul.path = workdir;
0044         else
0045             lukestructs.simul.path = './';
0046         end  
0047         %
0048         if isfield(equils{curtime},'fluct') && exist([lukestructs.simul.path,'backup_',lukestructs.simul.id,'.mat'],'file'),
0049             %
0050             lukeobj = iluke_info(lukeobj,'');% disable info display
0051             %
0052             if iselect_jd({'No','Yes'},'Do you want to load backup file and continue simulation ? ',lukeobj.infopanel.handle,style,1) == 2,
0053                 %
0054                 opt.backup = -2;% save intermediate results with fluctuations
0055                 %
0056             end
0057             %
0058             lukeobj = iluke_info(lukeobj,'luke');drawnow;% disable info display
0059             %
0060         end
0061         %
0062         lukestructs.opt = opt;
0063         lukestructs.dkedisplay = dkedisplay;
0064         %
0065         lukestructs.dkeparam = dkeparams{curtime};
0066         lukestructs.equil = equils{curtime};
0067         lukestructs.ohm = ohms{curtime};
0068         lukestructs.transpfaste = transpfastes{curtime};
0069         lukestructs.ripple = ripples{curtime};
0070         lukestructs.waves = wavess{curtime};
0071         %
0072     else
0073         %
0074         opt.save = 1;% (1): save LUKE_RESULTS or return error (0): return results or error
0075         opt.proc = struct;% if not empty, structure containing options for proc_luke. In that case, opt.fields = {'data_proc'}.
0076         %
0077         if any(status.output == 1),% LUKE is already run for some times
0078             %
0079             lukeobj = iluke_info(lukeobj,'');% disable info display
0080             %
0081             job_mask = iselect_jd({},'LUKE already run for some times. Select time indides to calculate : ',lukeobj.infopanel.handle,style.editselectstyle,find(status.output == 0),'edit');
0082             %
0083             lukeobj = iluke_info(lukeobj,'luke');drawnow;% disable info display
0084             %
0085         else
0086             job_mask = find(status.output == 0);
0087         end
0088         %
0089         nt = length(job_mask);
0090         %
0091         lukestructs = cell(1,nt);
0092         %
0093         for it = 1:nt,
0094             lukestructs{it}.simul.id = make_luke_simulid_jd(equils{job_mask(it)},ohms{job_mask(it)},transpfastes{job_mask(it)},ripples{job_mask(it)},wavess{job_mask(it)});
0095             if remnum == 0 && mdce_mode <= 3,% local calculation
0096                 lukestructs{it}.simul.path = workdir;
0097             end        
0098             %
0099             lukestructs{it}.opt = opt;
0100             lukestructs{it}.dkedisplay = dkedisplay;
0101             %
0102             lukestructs{it}.dkeparam = dkeparams{job_mask(it)};
0103             lukestructs{it}.equil = equils{job_mask(it)};
0104             lukestructs{it}.ohm = ohms{job_mask(it)};
0105             lukestructs{it}.transpfaste = transpfastes{job_mask(it)};
0106             lukestructs{it}.ripple = ripples{job_mask(it)};
0107             lukestructs{it}.waves = wavess{job_mask(it)};
0108         end
0109     end
0110     %
0111     if returnmode == 0,
0112         lukeobj.lukechecktext.string = 'LUKE started. Please wait for result.';
0113         iluke_update_state(lukeobj);
0114     end
0115     %
0116     status.data = 2;    
0117     %
0118     clear opt
0119     %
0120 elseif strcmp(action,'runcheck'),
0121     %
0122     if curtime > 0,
0123         %
0124         lukestructs = struct;
0125         lukestructs.job = jobs{curtime};
0126         %
0127 %         remote = jobs{curtime}.remote;
0128         %
0129         jobs{curtime} = [];
0130         status.job(curtime) = 0;
0131         %
0132     else
0133         %
0134         job_mask = find(status.job > 0);
0135         nt = length(job_mask);
0136         %
0137 %         for it = 2:nt,
0138 %             if ~comp_struct_jd(jobs{job_mask(it)}.remote,jobs{job_mask(1)}.remote,0,{},{'host','cmd'}),
0139 %                 error('Not all jobs use the same remote profile. Aborted')
0140 %             end
0141 %         end
0142 %         %
0143 %         remote = jobs{job_mask(1)}.remote;
0144         %
0145         lukestructs = cell(1,nt);
0146         %
0147         for it = 1:nt,
0148             if ~isempty(jobs{job_mask(it)})
0149                 lukestructs{it}.job = jobs{job_mask(it)};
0150                 %
0151                 jobs{job_mask(it)} = [];
0152             end
0153             status.job(job_mask(it)) = 0;
0154         end
0155         %
0156     end
0157     %
0158     returnmode = 1;
0159 %     nrem = length(dkepath.remote);
0160 %     %
0161 %     flag = false(1,nrem);
0162 %     %
0163 %     for irem = 1:nrem,
0164 %         if comp_struct_jd(dkepath.remote(irem),remote,0,{},{'host','cmd'}),
0165 %             flag(irem) = true;
0166 %         end
0167 %     end
0168 %     %
0169 %     if sum(flag) == 0,
0170 %         error('Remote profile from job cannot be found in dkepath. aborted.')
0171 %     elseif sum(flag) > 1,
0172 %         disp('WARNING : more than one remote profile from dkepath found to be compatible with job.remote. First choice selected.')
0173 %     end
0174     %
0175     timedep = [];
0176 %     dkepath.remnum = find(flag,1,'first');
0177 %     %
0178 %     lukeobj.remote.select.value = dkepath.remnum + 1;
0179     %
0180 %     clear flag irem nrem remote
0181 end
0182 %
0183 % run or check luke
0184 %
0185 set(lukeobj.busy.handle,'Visible','on');drawnow;
0186 %
0187 lukestructs = run_lukert(lukestructs,dkepath,timedep);
0188 %
0189 set(lukeobj.busy.handle,'Visible','off');drawnow;
0190 %
0191 % manange output
0192 %
0193 if curtime > 0,
0194     if isfield(lukestructs,'job'),
0195         %
0196         jobs{curtime} = lukestructs.job;
0197         status.job(curtime) = 1;
0198         %
0199         action = 'lukerun';iluke_callbacks;
0200         %
0201     elseif isfield(lukestructs,'err'),
0202         %
0203         lukeobj.infotext.string = {'Error running LUKE : ',lukestructs.err};
0204         %
0205         lukeobj = iluke_info(lukeobj,'text');% enable info display
0206         %
0207     elseif isfield(lukestructs,'output'),
0208         %
0209         outputs{curtime} = iluke_output(lukestructs.output);
0210         %
0211         status.output(curtime) = 1;
0212         status.data = 2;
0213         %
0214         action = 'lukedisp';iluke_callbacks;
0215         %
0216         lukeobj = iluke_info(lukeobj,'text');% enable info display
0217         %
0218     end
0219 else
0220     for it = 1:nt,
0221         if isfield(lukestructs{it},'job'),
0222             %
0223             jobs{job_mask(it)} = lukestructs{it}.job;
0224             status.job(job_mask(it)) = 1;
0225             %
0226         elseif isfield(lukestructs{it},'err'),
0227             %
0228             disp(' ')
0229             disp(['Error running LUKE for shot time ',num2str(shotimes(job_mask(it))),' s : ']);
0230             disperr_jd(lukestructs{it}.err);
0231             %
0232         elseif isfield(lukestructs{it},'output'),
0233             %
0234             outputs{job_mask(it)} = iluke_output(lukestructs{it}.output);
0235             %
0236             status.output(job_mask(it)) = 1;
0237             status.sdiag(:,job_mask(it)) = 1;% enable sdiag for times with distribution
0238             status.data = 2;
0239             %
0240         elseif returnmode == 1 && isfield(lukestructs{1},'job'),% jobs transfered through mdce_remote
0241             status.job(job_mask(it)) = 1;
0242         end
0243     end
0244     %
0245     clear job_mask it nt
0246     %
0247     if any(status.job > 0),
0248         action = 'lukerun';iluke_callbacks;
0249     elseif any(status.output > 0), 
0250         action = 'lukedisp';iluke_callbacks;
0251     else
0252         lukeobj = iluke_info(lukeobj,'text');% enable info display
0253     end
0254     %
0255 end
0256 %
0257 clear lukestructs timedep mdce_mode remnum returnmode transpmode
0258 %
0259     
0260     
0261 
0262 
0263 
0264 
0265 
0266

Community support and wiki are available on Redmine. Last update: 18-Apr-2019.