Last active
June 11, 2018 06:52
-
-
Save piroyon/de5b9890cd4a0c26a07de19f2ba03370 to your computer and use it in GitHub Desktop.
Rewrite SGE script to PBS script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
=head1 SCRIPT NAME | |
sge2pbs.pl | |
=head1 DESCRIPTION | |
Rewrite SGE script to PBS script | |
=head1 USAGE | |
perl sge2pbs.pl sge_sh_script_file > pbs_sh_script_file | |
=cut | |
use Switch; | |
$current = $arrayjob = $sgeop = 0; | |
while(<>) { | |
chomp; | |
s/SGE_TASK_ID/PBS_ARRAY_INDEX/g; | |
if (/^$/ && $sgeop == 0) { | |
print "\n"; | |
} | |
elsif (/^#\$[\s\t]+(\-[a-zA-Z]+)/) { | |
$sgeop = 1; | |
$option = $1; | |
if (/^#\$[\s\t]+\-[a-zA-Z]+[\s\t]+(\S.*)/) { | |
$res = $1; | |
} | |
switch ($option) { | |
case "-cwd" { | |
$current = 1; | |
} | |
case "-t" { | |
$arrayjob = 1; | |
$arraynum = $res; | |
print "#PBS -J $res\n" | |
} | |
case "-pe" { | |
@pp = split(/[\s\t]+/, $res); | |
$pe = $pp[0]; | |
$penum = $pp[1]; | |
print "#PBS -l ppn=$penum\n"; | |
} | |
else { | |
print "#PBS $option $res\n" | |
} | |
} | |
} | |
elsif ($sgeop == 1) { | |
print 'cd ${PBS_O_WORKDIR}'; | |
print "\n"; | |
$sgeop = 0; | |
print; | |
print "\n"; | |
} else { | |
print; | |
print "\n"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment