-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck-done.pl
More file actions
executable file
·70 lines (61 loc) · 1.35 KB
/
check-done.pl
File metadata and controls
executable file
·70 lines (61 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/perl
use strict;
use ProgramName;
my $name=ProgramName::get();
die "$name <slurm-directory>\n" unless @ARGV==1;
my ($slurmDir)=@ARGV;
my $dir="$slurmDir/outputs";
die "$dir does not exist\n" unless -e $dir;
my @commands=`ls $slurmDir/command*.sh`;
my $N=@commands;
my @done;
for(my $i=1 ; $i<=$N ; ++$i) { $done[$i]=0 }
for(my $i=1 ; $i<=$N ; ++$i) {
my $file="$dir/$i.output";
if(-e $file && done($file)) { $done[$i]=1 }
}
my $first=1;
my $ok=1;
print "#SBATCH --array=";
for(my $i=1 ; $i<=$N ; ++$i) {
next if $done[$i];
$ok=0;
my $j; for($j=$i+1 ; $j<=$N && !$done[$j]; ++$j) {}
if(!$first) { print "," }
my $end=$j-1;
if($i==$end) { print "$i" }
else { print "$i\-$end" }
$i=$j;
$first=0;
}
if($ok) { print "all jobs finished successfully" }
else {
my $totalDone=0;
print "\n\nTHESE ARE DONE:\t";
my $first=1;
my $ok=1;
for(my $i=1 ; $i<=$N ; ++$i) {
next unless $done[$i];
$ok=0;
my $j; for($j=$i+1 ; $j<=$N && $done[$j]; ++$j) {}
if(!$first) { print "," }
$totalDone+=$j-$i;
my $end=$j-1;
if($i==$end) { print "$i" }
else { print "$i\-$end" }
$i=$j;
$first=0;
}
print "\t(total $totalDone)\n"
}
print "\n";
sub done
{
my ($filename)=@_;
open(IN,"tail -n 200 $filename|") || die $filename;
while(<IN>) {
if(/\[done\]/) { close(IN); return 1 }
}
close(IN);
return 0;
}