load_batch_jd

PURPOSE ^

SYNOPSIS ^

function completed_jobs = load_batch_jd(filename,completed_jobs,savepath)

DESCRIPTION ^

 Check the job status send by run_lukert with distributed calculations (local or remote)

 INPUTS :

   - filename : file that contain lukestructs
   - completed_jobs : status of the running jobs (vector)
   - savepath : specfici path to save results when job is done (default active folder)
   
 OUTPUTS :

   - completed_jobs : status of the running jobs (vector)

 by J. Decker (joan.decker@cea.fr), E. Nilsson (emelie.nilsson@cea.fr) and Y. Peysson (yves.peysson@cea.fr)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function completed_jobs = load_batch_jd(filename,completed_jobs,savepath)
0002 %
0003 % Check the job status send by run_lukert with distributed calculations (local or remote)
0004 %
0005 % INPUTS :
0006 %
0007 %   - filename : file that contain lukestructs
0008 %   - completed_jobs : status of the running jobs (vector)
0009 %   - savepath : specfici path to save results when job is done (default active folder)
0010 %
0011 % OUTPUTS :
0012 %
0013 %   - completed_jobs : status of the running jobs (vector)
0014 %
0015 % by J. Decker (joan.decker@cea.fr), E. Nilsson (emelie.nilsson@cea.fr) and Y. Peysson (yves.peysson@cea.fr)
0016 %
0017 %
0018 if nargin == 0, 
0019     filename = '';
0020 end
0021 %
0022 if ~isempty(filename)
0023     data = load(filename,'lukestructs','dkepath');
0024 else
0025     try 
0026         filename = ls('LUKE_BATCH*');
0027         data = load(filename(1:end-1),'lukestructs','dkepath');
0028     catch
0029         disp(['WARNING: ',filename,' does not exist in the active folder. Please move to the correct one or give the full file path.'])
0030         completed_jobs = [];
0031         return;
0032     end
0033 end
0034 %
0035 lukestructs_in = data.lukestructs(:);
0036 %
0037 nruns = length(lukestructs_in);
0038 %
0039 if nargin < 2,
0040     completed_jobs = zeros(1,nruns);
0041 end
0042 %
0043 for irun = 1:nruns,% load runs in a loop to avoid memory excess
0044     %
0045     if completed_jobs(irun) == 0,
0046         %
0047         lukestructs = run_lukert(lukestructs_in(irun),data.dkepath);
0048         lukestructs = lukestructs{1};
0049         %
0050         if nargin >= 3,
0051             path_simul = savepath;
0052         elseif isfield(lukestructs,'simul') && isfield(lukestructs.simul,'path') && ~isempty(lukestructs.simul.path),
0053             path_simul = lukestructs.simul.path;
0054         else
0055             path_simul = './';
0056         end
0057         %
0058         if isfield(lukestructs,'job')
0059             disp(['Remote LUKE still running for case : ',num2str(irun),'/',num2str(nruns)])
0060         elseif isfield(lukestructs,'err'),
0061             disp(['Remote LUKE run failed for case : ',num2str(irun),'/',num2str(nruns),' for the following reason :'])
0062             if iscell(lukestructs.err),
0063                 for ierr = 1:length(lukestructs.err),
0064                     disp(lukestructs.err{ierr});
0065                 end
0066             else 
0067                 disp(lukestructs.err);
0068             end
0069             completed_jobs(irun) = -1;
0070         elseif isfield(lukestructs,'output'),
0071             disp(['Remote LUKE completed for case : ',num2str(irun),'/',num2str(nruns)])
0072             %
0073             if isfield(lukestructs.output,'dke_out') && isfield(lukestructs.output.dke_out,'simul') && isfield(lukestructs.output.dke_out.simul,'id'),
0074                 saveid = lukestructs.output.dke_out.simul.id;
0075             elseif isfield(lukestructs.simul,'id')
0076                 saveid = lukestructs.simul.id;
0077             else
0078                 saveid = num2str(irun);
0079             end
0080             %
0081             if ~strcmp(path_simul(end),filesep),
0082                 path_simul = [path_simul,filesep];
0083             end
0084             savename = [path_simul,'LUKE_RESULTS_',saveid,'.mat'];
0085             %
0086             if exist(savename,'file'),
0087                 disp(['Warning : file ',savename,' already exists.'])
0088                 keyboard
0089             end
0090             %
0091             save(savename,'lukestructs','-v7.3');
0092             info_dke_yp(2,['LUKE Results saved in ',savename]);
0093             %
0094             completed_jobs(irun) = 1;
0095         else
0096             disp('Remote LUKE status unknown')
0097             keyboard
0098         end
0099         %
0100     end
0101 end
0102 %
0103 if ~any(completed_jobs == 0),
0104     delete(filename)
0105 end
0106

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