Line 50: |
Line 50: |
| =head1 SYNOPSIS | | =head1 SYNOPSIS |
| | | |
− | generate_simple_stuff_makefile [options] | + | generate_simple_stuff_makefile [options] |
| | | |
| -o output directory : location of all output files | | -o output directory : location of all output files |
| -m output make file | | -m output make file |
− |
| + | |
| example: ./generate_simple_stuff_makefile.pl | | example: ./generate_simple_stuff_makefile.pl |
| | | |
| =head1 DESCRIPTION | | =head1 DESCRIPTION |
− |
| + | |
| =cut | | =cut |
| | | |
Line 67: |
Line 67: |
| my $outputDir = getcwd(); | | my $outputDir = getcwd(); |
| my $makeFile = "simple_stuff.mk"; | | my $makeFile = "simple_stuff.mk"; |
| + | my $launchMethod = "local"; |
| | | |
| #initialize options | | #initialize options |
Line 73: |
Line 74: |
| if(!GetOptions ('h'=>\$help, 'v'=>\$verbose, 'd'=>\$debug, | | if(!GetOptions ('h'=>\$help, 'v'=>\$verbose, 'd'=>\$debug, |
| 'o:s'=>\$outputDir, | | 'o:s'=>\$outputDir, |
− | 'm:s'=>\$makeFile) | + | 'l:s'=>\$launchMethod, |
− | || !defined($outputDir) | + | 'm:s'=>\$makeFile) |
| + | || !defined($outputDir) |
| || scalar(@ARGV)!=0) | | || scalar(@ARGV)!=0) |
| { | | { |
Line 85: |
Line 87: |
| pod2usage(1); | | pod2usage(1); |
| } | | } |
| + | } |
| + | |
| + | if ($launchMethod ne "local" && $launchMethod ne "slurm") |
| + | { |
| + | print STDERR "Launch method has to be local or slurm\n"; |
| + | exit(1); |
| } | | } |
| | | |
Line 93: |
Line 101: |
| printf("\n"); | | printf("\n"); |
| printf("output directory : %s\n", $outputDir); | | printf("output directory : %s\n", $outputDir); |
| + | printf("launch method : %s\n", $launchMethod); |
| printf("\n"); | | printf("\n"); |
| | | |
Line 129: |
Line 138: |
| $dep = ""; | | $dep = ""; |
| @cmd = ("echo $i > $outputDir/$i.log"); | | @cmd = ("echo $i > $outputDir/$i.log"); |
− | makeLocalStep($tgt, $dep, @cmd); | + | makeJob($launchMethod, $tgt, $dep, @cmd); |
− | #makeSlurm($tgt, $dep, @cmd);
| |
| } | | } |
| | | |
Line 140: |
Line 148: |
| $dep = $inputFilesOK; | | $dep = $inputFilesOK; |
| @cmd = ("cat $inputFiles > $outputFile"); | | @cmd = ("cat $inputFiles > $outputFile"); |
− | makeLocalStep($tgt, $dep, @cmd);
| + | makeJob($launchMethod, $tgt, $dep, @cmd); |
− | #makeSlurm($tgt, $dep, @cmd);
| + | |
− |
| |
| ########################### | | ########################### |
| #3. Cleanup temporary files | | #3. Cleanup temporary files |
Line 149: |
Line 156: |
| $dep = "$outputDir/all.log.OK"; | | $dep = "$outputDir/all.log.OK"; |
| @cmd = ("rm $inputFiles"); | | @cmd = ("rm $inputFiles"); |
− | makeLocalStep($tgt, $dep, @cmd);
| + | makeJob($launchMethod, $tgt, $dep, @cmd); |
− | #makeSlurm($tgt, $dep, @cmd);
| + | |
− |
| |
| #******************* | | #******************* |
| #Write out make file | | #Write out make file |
Line 174: |
Line 180: |
| #functions | | #functions |
| ########## | | ########## |
| + | |
| + | #run a job either locally or by slurm |
| + | sub makeJob |
| + | { |
| + | my ($method, $tgt, $dep, @cmd) = @_; |
| + | |
| + | if ($method eq "local") |
| + | { |
| + | makeLocalStep($tgt, $dep, @cmd); |
| + | } |
| + | elsif ($method eq "slurm") |
| + | { |
| + | makeSlurm($tgt, $dep, @cmd); |
| + | } |
| + | } |
| | | |
| #run slurm jobs | | #run slurm jobs |
− | sub makeSlurm | + | sub makeSlurm |
| { | | { |
| my ($tgt, $dep, @cmd) = @_; | | my ($tgt, $dep, @cmd) = @_; |