forked from carlacummins/carla-git
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathibsub
More file actions
executable file
·43 lines (33 loc) · 940 Bytes
/
ibsub
File metadata and controls
executable file
·43 lines (33 loc) · 940 Bytes
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
#!/usr/bin/env perl
=head1 Description
Requesting resource requirements is annoyingly repetitive. Let this script help!
Interprets human-readable memory requirements and submits the correct interactive
bsub command.
# run a specific command with 4Gb memory:
ibsub 4gb perl this_is_not_a_script.pl
# request basic, empty interactive shell with 100mb memory
ibsub 100mb
=cut
use strict;
use warnings;
my $mem_h = shift @ARGV;
$mem_h ||= '1gb';
$mem_h = lc($mem_h);
my $command = '$SHELL';
$command = join(' ', @ARGV) if $ARGV[0];
my ($mult, $unit);
if ( $mem_h =~ /([0-9\.]+)gb/ ) {
$unit = $1;
$mult = 1000;
}
elsif ( $mem_h =~ /([0-9]+)mb/ ) {
$unit = $1;
$mult = 1;
}
else {
die ( "Can't figure out memory statement. Please use e.g. 2gb, 4.5gb, 500mb" );
}
my $mb_req = $unit * $mult;
my $bsub = "bsub -Is -q production-rh74 -M$mb_req -R\"select[mem>$mb_req] rusage[mem=$mb_req]\" $command";
print "$bsub\n";
system($bsub);