job_destroy.m

function y=job_destroy(a)

sched = findResource('scheduler', 'type', 'generic');

curdir = pwd;    % 23.07.10
set(sched, 'DataLocation', curdir)

if nargin < 1

  finished_jobs=findJob(sched, 'State', 'finished');
  if ~isempty(finished_jobs)
    destroy(finished_jobs)
    system('rm Job*.mpiexec.out 2>/dev/null');    % all (not only finished)

    y=' "finished" Jobs destroyed';
  end

else
  jobs=findJob(sched);
  if ~isempty(jobs)
    destroy(jobs)
     
    y=' all Jobs destroyed';
  end
  system('rm Job*.mpiexec.out 2>/dev/null');
  clear all
end
return
end