-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmobius
executable file
·129 lines (107 loc) · 3.7 KB
/
mobius
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#!/usr/bin/perl
use v5.10;
sub organize { # prepares for the next run and sets up restart file
`echo \$(date -R) 'organizing...' >> mob.log`;
`cp -r base $next &>> mob.log`;
`cp -f base/*.f $next &>> mob.log`;
system "mvn $next/{base,$run_name" . '} &>> mob.log';
# `ln -s $(pwd -P)/$last/$restart $(pwd -P)/$next/restart_0.f00001`;
`cp $last/$restart $next/restart_0.f00001`;
}
sub compile { # compile using makenek
`echo \$(date -R) 'compiling...' >> mob.log`;
if (`find $next/nek5000 2> /dev/null` eq '') {
`cd $next; rm compiler.out; ./mn $run_name &>> ../mob.log`;
`echo \$(date -R) 'error: compilation failed...' >> mob.log`;
`cat $next/compiler.out | mail -s 'Error on $machine: $name $next Compilation Failed...' $email`;
`echo \$(date -R) 'ending program...'`;
exit 1;
}
}
sub msend { `cat $mbody | mail -s '$msubject' $email`; }
sub run { # submit the job according to mob.cmd
`echo \$(date -R) 'starting run...' >> mob.log`;
$status=`cd $next; ./mob.cmd $run_name >> ../mob.log; echo $?`;
if ($status != 0) {
`echo "$status" | mail -s 'Error on $machine: $name $next Submission Failed...' $email`;
exit 1;
}
}
sub update_last_next { # update last and next variable
$last_last=$last;
chomp($last = `ls | grep '[0-9][0-9][0-9][0-9][0-9]' | tail -1`);
exit if ($last eq '99999');
$next = sprintf("%05d", $last + 1);
if ($last_last ne $last) {
`echo 'last = $last' >> mob.log`;
`echo 'next = $next' >> mob.log`;
};
}
sub update_name { # update name variable
chomp($name = `cat mob.name 2> /dev/null`);
if ($name eq '') {
chomp($name = `basename \$(pwd)`);
`echo $name > mob.name`;
}
`echo 'name = $name' >> mob.log`;
}
sub update_restart { # update restart variable
$out_format = $name . '_' . $last . '_' . '*0.f*';
if ($timeout) {
chomp($restart = `cd $last; find $out_format | tail -2 | head -1`);
} else {
chomp($restart = `cd $last; find $out_format | tail -1`);
}
if ($restart eq '') { exit 1; }
`echo 'restart = $restart' >> mob.log`;
}
`mv mob.log mob.log2 2> /dev/null`;
`echo \$(date -R) 'starting mobius...' >> mob.log`;
`echo 'removing mob.info...' >> mob.log`;
`rm mob.info 2> /dev/null`;
$config=do("mob.config");
die "Error reading config file: $!" unless defined $config;
$machine=$config->{machine};
$email=$config->{email};
$base=$config->{base};
`echo 'email = $email' >> mob.log`;
`echo 'base = $base' >> mob.log`;
update_name();
`echo \$(date -R) 'starting loop...' >> mob.log`;
for (;;) { # infinite loop
chomp($info = `cat mob.info 2> /dev/null`);
if ($info eq '1') {
`echo 'mob.info == 1, exiting...' >> mob.log`;
last;
}
update_last_next();
$run_name = $name . '_' . $next . '_';
$log = `cat $last/*cobaltlog 2> /dev/null`;
$timeout = $log =~ /maximum execution time exceeded/;
$cleanrun = $log =~ /task completed normally/;
if ($timeout) {
`echo 'Run Timed out...' >> mob.log`;
$msubject = "$name $last Run Exceeded Walltime";
$mbody = 'mbody.txt';
# `echo '' > $mbody`;
# `echo '*****Cobaltlog*****' >> $mbody`;
# `cat *cobaltlog >> $mbody`;
# `echo '' >> $mbody`;
`echo '*****Logfile*****' >> $mbody`;
`cat logfile >> $mbody`;
msend();
`rm mbody.txt`;
last;
}
if ($cleanrun) {
sleep(120);
`echo \$(date -R) 'post-processing...' >> mob.log`;
`cd $last; ../mob.post &>> ../mob.log`;
`echo \$(date -R) 'proceeding to $next...' >> mob.log`;
update_restart();
organize();
compile();
run();
}
sleep(10);
}