| 1 | package PBS::Client; | ||||||||||||||||||||||||||||
| 2 | 8 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 8 | ▶ | use vars qw($VERSION); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 8 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 8 | ▶ | use File::Temp qw(tempfile); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 8 | $VERSION = '0.11'; | |||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | #------------------------------------------------ | ||||||||||||||||||||||||||||
| 9 | # Submit jobs to PBS | ||||||||||||||||||||||||||||
| 10 | # | ||||||||||||||||||||||||||||
| 11 | # Included methods: | ||||||||||||||||||||||||||||
| 12 | # - Construct PBS client object | ||||||||||||||||||||||||||||
| 13 | # $client = PBS::Client->new(); | ||||||||||||||||||||||||||||
| 14 | # | ||||||||||||||||||||||||||||
| 15 | # - Submit jobs | ||||||||||||||||||||||||||||
| 16 | # $client->qsub($job); | ||||||||||||||||||||||||||||
| 17 | # -- $client -- client object | ||||||||||||||||||||||||||||
| 18 | # -- $job ----- job object | ||||||||||||||||||||||||||||
| 19 | # | ||||||||||||||||||||||||||||
| 20 | # - Generate job script without job submission | ||||||||||||||||||||||||||||
| 21 | # $client->genScript($job); | ||||||||||||||||||||||||||||
| 22 | # -- $client -- client object | ||||||||||||||||||||||||||||
| 23 | # -- $job ----- job object | ||||||||||||||||||||||||||||
| 24 | #------------------------------------------------ | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | #------------------------ | ||||||||||||||||||||||||||||
| 28 | # Constructor method | ||||||||||||||||||||||||||||
| 29 | # | ||||||||||||||||||||||||||||
| 30 | # <IN> | ||||||||||||||||||||||||||||
| 31 | # $class -- client object | ||||||||||||||||||||||||||||
| 32 | # %hash --- argument hash | ||||||||||||||||||||||||||||
| 33 | # | ||||||||||||||||||||||||||||
| 34 | # <OUT> | ||||||||||||||||||||||||||||
| 35 | # $self -- client object | ||||||||||||||||||||||||||||
| 36 | sub new | ||||||||||||||||||||||||||||
| 37 | 13 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 38 | 13 | my ($class, %hash) = @_; | |||||||||||||||||||||||||||
| 39 | 13 | my $self = \%hash; | |||||||||||||||||||||||||||
| 40 | 13 | return bless($self, $class); | |||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | #------------------------ | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | #-------------------------- | ||||||||||||||||||||||||||||
| 46 | # Generic attribute methods | ||||||||||||||||||||||||||||
| 47 | sub AUTOLOAD | ||||||||||||||||||||||||||||
| 48 | 13 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
AUTOLOAD: called CC=3 SCAR=14.2
| |||||||||||||||||||||||||||||
| 49 | 13 | my ($self, $key) = @_; | |||||||||||||||||||||||||||
| 50 | 13 | my $attr = our $AUTOLOAD; | |||||||||||||||||||||||||||
| 51 | 13 | $attr =~ s/.*:://; | |||||||||||||||||||||||||||
| 52 | 13 | ▶ | return if ($attr eq 'DESTROY'); # ignore destructor | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 53 | 0 | ▶ | $self->{$attr} = $key if (defined $key); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 54 | 0 | return($self->{$attr}); | |||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||
| 56 | #-------------------------- | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | #------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 60 | # Submit PBS jobs by qsub command | ||||||||||||||||||||||||||||
| 61 | # - called subroutines: getScript(), _numPrevJob() and _qsubDepend() | ||||||||||||||||||||||||||||
| 62 | # | ||||||||||||||||||||||||||||
| 63 | # <IN> | ||||||||||||||||||||||||||||
| 64 | # $self -- client object | ||||||||||||||||||||||||||||
| 65 | # $job --- job object | ||||||||||||||||||||||||||||
| 66 | # | ||||||||||||||||||||||||||||
| 67 | # <OUT> | ||||||||||||||||||||||||||||
| 68 | # \@pbsid -- array reference of PBS job ID | ||||||||||||||||||||||||||||
| 69 | sub qsub | ||||||||||||||||||||||||||||
| 70 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
qsub: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||
| 71 | 0 | my ($self, $job) = @_; | |||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | #---------------------------------------------------------- | ||||||||||||||||||||||||||||
| 74 | # Codes for backward compatatible with old private software | ||||||||||||||||||||||||||||
| 75 | #---------------------------------------------------------- | ||||||||||||||||||||||||||||
| 76 | 0 | ▶ | if (!ref($job) || ref($job) eq 'ARRAY') | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not ref $job or ref $job eq "ARRAY"
MC/DC0%0/2
not ref $job or ref $job eq "ARRAY"
not ref $job
ref $job eq "ARRAY"
Truth table0%0/3
not(A) or B
A= not ref $jobB= ref $job eq "ARRAY"
| |||||||||||||||||||||||||||||
| 77 | { | ||||||||||||||||||||||||||||
| 78 | 0 | $self->cmd($job); | |||||||||||||||||||||||||||
| 79 | 0 | &qsub($self, $self); | |||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | #----------------------------------------------- | ||||||||||||||||||||||||||||
| 83 | # Dependency: count number of previous jobs | ||||||||||||||||||||||||||||
| 84 | #----------------------------------------------- | ||||||||||||||||||||||||||||
| 85 | 0 | my $on = &_numPrevJob($job); | |||||||||||||||||||||||||||
| 86 | 0 | ▶ | $job->{depend}{on} = [$on] if ($on); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 87 | 0 | my $file = $job->{script}; | |||||||||||||||||||||||||||
| 88 | 0 | my @pbsid = (); | |||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | #----------------------------------------------- | ||||||||||||||||||||||||||||
| 91 | # Single job | ||||||||||||||||||||||||||||
| 92 | # Thanks to Demian Ricchardi for a bug fix | ||||||||||||||||||||||||||||
| 93 | #----------------------------------------------- | ||||||||||||||||||||||||||||
| 94 | 0 | ▶ | if (!ref($job->{cmd})) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 95 | { | ||||||||||||||||||||||||||||
| 96 | 0 | my $tempFile = &genScript($self, $job); # generate script | |||||||||||||||||||||||||||
| 97 | 0 | my $out = &call_qsub('qsub', $tempFile); # submit script | |||||||||||||||||||||||||||
| 98 | 0 | my $pbsid = ($out =~ /^(\d+)/)[0]; # get pid | |||||||||||||||||||||||||||
| 99 | 0 | rename($tempFile, "$file.$pbsid"); # rename script | |||||||||||||||||||||||||||
| 100 | 0 | push(@pbsid, $pbsid); | |||||||||||||||||||||||||||
| 101 | 0 | $job->pbsid($pbsid); | |||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||
| 103 | #----------------------------------------------- | ||||||||||||||||||||||||||||
| 104 | # Multiple (matrix of) jobs | ||||||||||||||||||||||||||||
| 105 | # Thanks to Demian Ricchardi for a bug fix | ||||||||||||||||||||||||||||
| 106 | #----------------------------------------------- | ||||||||||||||||||||||||||||
| 107 | else | ||||||||||||||||||||||||||||
| 108 | { | ||||||||||||||||||||||||||||
| 109 | 0 | my $subjob = $job->copy; | |||||||||||||||||||||||||||
| 110 | 0 | ▶ | for (my $i = 0; $i < @{$job->{cmd}}; $i++) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 111 | { | ||||||||||||||||||||||||||||
| 112 | # Get command | ||||||||||||||||||||||||||||
| 113 | 0 | my $list = ${$job->{cmd}}[$i]; | |||||||||||||||||||||||||||
| 114 | 0 | ▶ | my $cmd = (ref $list)? (join("\n", @$list)): $list; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 115 | 0 | $subjob->{cmd} = $cmd; | |||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||
| 117 | # Generate and submit job script | ||||||||||||||||||||||||||||
| 118 | 0 | my $tempFile = &genScript($self, $subjob); # generate script | |||||||||||||||||||||||||||
| 119 | 0 | my $out = &call_qsub('qsub', $tempFile); # submit script | |||||||||||||||||||||||||||
| 120 | 0 | my $pbsid = ($out =~ /^(\d+)/)[0]; # get pid | |||||||||||||||||||||||||||
| 121 | 0 | rename($tempFile, "$file.$pbsid"); # rename script | |||||||||||||||||||||||||||
| 122 | 0 | push(@pbsid, $pbsid); | |||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||
| 124 | 0 | $job->pbsid(\@pbsid); | |||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||
| 127 | #----------------------------------------------- | ||||||||||||||||||||||||||||
| 128 | # Dependency: submit previous and following jobs | ||||||||||||||||||||||||||||
| 129 | #----------------------------------------------- | ||||||||||||||||||||||||||||
| 130 | 0 | &_qsubDepend($self, $job, \@pbsid); | |||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||
| 132 | 0 | return(\@pbsid); | |||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||
| 134 | #------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||
| 137 | #------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 138 | # Thanks to Sander Hulst | ||||||||||||||||||||||||||||
| 139 | sub call_qsub | ||||||||||||||||||||||||||||
| 140 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
call_qsub: not called CC=2 SCAR=11.3
Pod
undocumented
| |||||||||||||||||||||||||||||
| 141 | 0 | my @args = @_; | |||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||
| 143 | # If the qsub command fails, for instance, pbs_server is not running, | ||||||||||||||||||||||||||||
| 144 | # PBS::Client's qsub should not silently ignore. Disable any reaper | ||||||||||||||||||||||||||||
| 145 | # functions so the exit code can be captured | ||||||||||||||||||||||||||||
| 146 | 8 | ▶ | use Symbol qw(gensym); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 147 | 8 | ▶ | use IPC::Open3; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 148 | 0 | my $stdout = gensym(); | |||||||||||||||||||||||||||
| 149 | 0 | my $stderr = gensym(); | |||||||||||||||||||||||||||
| 150 | { | ||||||||||||||||||||||||||||
| 151 | 0 | ▶ | local $SIG{CHLD} = sub{}; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 152 | 0 | my $pid = open3(gensym, $stdout, $stderr, @args); | |||||||||||||||||||||||||||
| 153 | 0 | waitpid($pid,0); | |||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||
| 155 | 0 | ▶ | confess <$stderr> if ($?); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 156 | 0 | return <$stdout>; | |||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||
| 158 | #------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||
| 161 | #------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 162 | # Dispatch PBS jobs by dispatch and qsub command | ||||||||||||||||||||||||||||
| 163 | # - Codes for backward compatible with old private software | ||||||||||||||||||||||||||||
| 164 | # - called subroutines: getScript() | ||||||||||||||||||||||||||||
| 165 | # | ||||||||||||||||||||||||||||
| 166 | # <IN> | ||||||||||||||||||||||||||||
| 167 | # $self -- server object | ||||||||||||||||||||||||||||
| 168 | # $job --- job object | ||||||||||||||||||||||||||||
| 169 | # | ||||||||||||||||||||||||||||
| 170 | # <OUT> | ||||||||||||||||||||||||||||
| 171 | # \@pbsid -- array reference of PBS job ID | ||||||||||||||||||||||||||||
| 172 | sub dispatch | ||||||||||||||||||||||||||||
| 173 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
dispatch: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 174 | 0 | my ($self, $job) = @_; | |||||||||||||||||||||||||||
| 175 | 0 | my $file = $job->{script}; | |||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||
| 177 | #----------------------------------------------- | ||||||||||||||||||||||||||||
| 178 | # Dependency: count number of previous jobs | ||||||||||||||||||||||||||||
| 179 | #----------------------------------------------- | ||||||||||||||||||||||||||||
| 180 | 0 | my $on = &_numPrevJob($job); | |||||||||||||||||||||||||||
| 181 | 0 | ▶ | $job->{depend}{on} = [$on] if ($on); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 182 | 0 | my @pbsid = (); | |||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||
| 184 | #--------- | ||||||||||||||||||||||||||||
| 185 | # Dispatch | ||||||||||||||||||||||||||||
| 186 | #--------- | ||||||||||||||||||||||||||||
| 187 | 0 | my $subjob = $job->copy; | |||||||||||||||||||||||||||
| 188 | 0 | ▶ | for (my $i = 0; $i < @{$job->{cmd}}; $i++) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 189 | { | ||||||||||||||||||||||||||||
| 190 | #-------------- | ||||||||||||||||||||||||||||
| 191 | # Dispatch jobs | ||||||||||||||||||||||||||||
| 192 | #-------------- | ||||||||||||||||||||||||||||
| 193 | 0 | my $list = ${$job->{cmd}}[$i]; | |||||||||||||||||||||||||||
| 194 | 0 | ▶ | my $djob = (ref $list)? (join("\n", @$list)): $list; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 195 | 0 | $djob =~ s/\\/\\\\/g; | |||||||||||||||||||||||||||
| 196 | 0 | $djob =~ s/"/\\\"/g; | |||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||
| 198 | #----------------- | ||||||||||||||||||||||||||||
| 199 | # Dispatch command | ||||||||||||||||||||||||||||
| 200 | #----------------- | ||||||||||||||||||||||||||||
| 201 | 0 | my $cmd = 'echo "'."\n$djob\n".'" | dispatch'; | |||||||||||||||||||||||||||
| 202 | 0 | $subjob->{cmd} = $cmd; | |||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||
| 204 | #------------------------------- | ||||||||||||||||||||||||||||
| 205 | # Generate and submit job script | ||||||||||||||||||||||||||||
| 206 | #------------------------------- | ||||||||||||||||||||||||||||
| 207 | 0 | ▶ | my $numJob = (ref $list)? (scalar(@$list)): 1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 208 | 0 | ▶ | $subjob->nodes($numJob) if (!defined $subjob->{nodes}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 209 | 0 | my $tempFile = &genScript($self, $subjob); # generate script | |||||||||||||||||||||||||||
| 210 | 0 | my $out = `qsub $tempFile`; # submit script | |||||||||||||||||||||||||||
| 211 | 0 | my $pbsid = ($out =~ /^(\d+)/)[0]; # grab pid | |||||||||||||||||||||||||||
| 212 | 0 | rename($tempFile, "$file.$pbsid"); # rename script | |||||||||||||||||||||||||||
| 213 | 0 | push(@pbsid, $pbsid); | |||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||
| 215 | 0 | $job->pbsid(\@pbsid); | |||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||
| 217 | #------------------------------------------------- | ||||||||||||||||||||||||||||
| 218 | # Dependency: dispatch previous and following jobs | ||||||||||||||||||||||||||||
| 219 | #------------------------------------------------- | ||||||||||||||||||||||||||||
| 220 | 0 | &_dphDepend($self, $job, \@pbsid); | |||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||
| 222 | 0 | return(\@pbsid); | |||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||
| 224 | #------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||
| 227 | #----------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 228 | # Generate shell script from command string array | ||||||||||||||||||||||||||||
| 229 | # - called subroutines: _trace(), _nodes(), _stage() and _depend() | ||||||||||||||||||||||||||||
| 230 | # - called by qsub() | ||||||||||||||||||||||||||||
| 231 | # | ||||||||||||||||||||||||||||
| 232 | # <IN> | ||||||||||||||||||||||||||||
| 233 | # $self -- client object | ||||||||||||||||||||||||||||
| 234 | # $job --- job object | ||||||||||||||||||||||||||||
| 235 | # | ||||||||||||||||||||||||||||
| 236 | # <OUT> | ||||||||||||||||||||||||||||
| 237 | # $file -- filename of job script | ||||||||||||||||||||||||||||
| 238 | sub genScript | ||||||||||||||||||||||||||||
| 239 | 11 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
genScript: called CC=34 SCAR=36.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 240 | 11 | my ($self, $job) = @_; | |||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||
| 242 | #------------------------- | ||||||||||||||||||||||||||||
| 243 | # Process the queue string | ||||||||||||||||||||||||||||
| 244 | #------------------------- | ||||||||||||||||||||||||||||
| 245 | 11 | my $queue = ''; | |||||||||||||||||||||||||||
| 246 | 11 | ▶ | $queue .= $job->{queue} if (defined $job->{queue}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 247 | 11 | ▶ | $queue .= '@'.$self->{server} if (defined $self->{server}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||
| 249 | #------------------------------- | ||||||||||||||||||||||||||||
| 250 | # Process the mail option string | ||||||||||||||||||||||||||||
| 251 | #------------------------------- | ||||||||||||||||||||||||||||
| 252 | 11 | my $mailOpt; | |||||||||||||||||||||||||||
| 253 | 11 | ▶ | if (defined $job->{mailopt}) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 254 | { | ||||||||||||||||||||||||||||
| 255 | 1 | $mailOpt = $job->{mailopt}; | |||||||||||||||||||||||||||
| 256 | 1 | $mailOpt =~ s/\s*,\s*//; | |||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||
| 259 | #--------------------- | ||||||||||||||||||||||||||||
| 260 | # Generate node string | ||||||||||||||||||||||||||||
| 261 | #--------------------- | ||||||||||||||||||||||||||||
| 262 | 11 | my $nodes = &_nodes($job); | |||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||
| 264 | #------------------------------------ | ||||||||||||||||||||||||||||
| 265 | # Set internal variable: | ||||||||||||||||||||||||||||
| 266 | # - temporary file for the job script | ||||||||||||||||||||||||||||
| 267 | #------------------------------------ | ||||||||||||||||||||||||||||
| 268 | 11 | my (undef, $file) = tempfile(DIR => $job->{wd}); | |||||||||||||||||||||||||||
| 269 | 11 | $job->_tempScript($file); | |||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||
| 271 | #------------------------ | ||||||||||||||||||||||||||||
| 272 | # PBS request option list | ||||||||||||||||||||||||||||
| 273 | #------------------------ | ||||||||||||||||||||||||||||
| 274 | 11 | ▶ | open(SH, ">$file") || confess "Can't write $file"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 275 | 11 | print SH "#!$job->{shell}\n\n"; | |||||||||||||||||||||||||||
| 276 | 11 | print SH "#PBS -N $job->{name}\n"; | |||||||||||||||||||||||||||
| 277 | 11 | print SH "#PBS -d $job->{wd}\n"; | |||||||||||||||||||||||||||
| 278 | 11 | ▶ | print SH "#PBS -e $job->{efile}\n" if (defined $job->{efile}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 279 | 11 | ▶ | print SH "#PBS -o $job->{ofile}\n" if (defined $job->{ofile}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 280 | 11 | ▶ | print SH "#PBS -q $queue\n" if ($queue); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 281 | print SH "#PBS -W x=PARTITION:$job->{partition}\n" if | ||||||||||||||||||||||||||||
| 282 | 11 | ▶ | (defined $job->{partition}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 283 | print SH "#PBS -W stagein=".&_stage('in', $job->{stagein})."\n" if | ||||||||||||||||||||||||||||
| 284 | 11 | ▶ | (defined $job->{stagein}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 285 | print SH "#PBS -W stageout=".&_stage('out', $job->{stageout})."\n" if | ||||||||||||||||||||||||||||
| 286 | 11 | ▶ | (defined $job->{stageout}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 287 | print SH "#PBS -M ".&_mailList($job->{maillist})."\n" if | ||||||||||||||||||||||||||||
| 288 | 11 | ▶ | (defined $job->{maillist}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 289 | 11 | ▶ | print SH "#PBS -m ".$mailOpt."\n" if (defined $mailOpt); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 290 | 11 | ▶ | print SH "#PBS -v ".&_varList($job->{vars})."\n" if (defined $job->{vars}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 291 | 11 | ▶ | print SH "#PBS -A $job->{account}\n" if (defined $job->{account}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 292 | 11 | ▶ | print SH "#PBS -p $job->{pri}\n" if (defined $job->{pri}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 293 | 11 | print SH "#PBS -l nodes=$nodes\n"; | |||||||||||||||||||||||||||
| 294 | 11 | ▶ | print SH "#PBS -l host=$job->{host}\n" if (defined $job->{host}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 295 | 11 | ▶ | print SH "#PBS -l mem=$job->{mem}\n" if (defined $job->{mem}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 296 | 11 | ▶ | print SH "#PBS -l pmem=$job->{pmem}\n" if (defined $job->{pmem}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 297 | 11 | ▶ | print SH "#PBS -l vmem=$job->{vmem}\n" if (defined $job->{vmem}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 298 | 11 | ▶ | print SH "#PBS -l pvmem=$job->{pvmem}\n" if (defined $job->{pvmem}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 299 | 11 | ▶ | print SH "#PBS -l cput=$job->{cput}\n" if (defined $job->{cput}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 300 | 11 | ▶ | print SH "#PBS -l pcput=$job->{pcput}\n" if (defined $job->{pcput}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 301 | 11 | ▶ | print SH "#PBS -l walltime=$job->{wallt}\n" if (defined $job->{wallt}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 302 | 11 | ▶ | print SH "#PBS -l nice=$job->{nice}\n" if (defined $job->{nice}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 303 | print SH "#PBS -l prologue=$job->{prologue}\n" if | ||||||||||||||||||||||||||||
| 304 | 11 | ▶ | (defined $job->{prologue}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 305 | print SH "#PBS -l epilogue=$job->{epilogue}\n" if | ||||||||||||||||||||||||||||
| 306 | 11 | ▶ | (defined $job->{epilogue}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||
| 308 | #--------------- | ||||||||||||||||||||||||||||
| 309 | # Beginning time | ||||||||||||||||||||||||||||
| 310 | #--------------- | ||||||||||||||||||||||||||||
| 311 | 11 | ▶ | if (defined $job->{begint}) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 312 | { | ||||||||||||||||||||||||||||
| 313 | 2 | my $begint = $job->{begint}; | |||||||||||||||||||||||||||
| 314 | 2 | $begint =~ s/[\-\s]//g; | |||||||||||||||||||||||||||
| 315 | 2 | my @a = ($begint =~ /([\d\.]+)/g); | |||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||
| 317 | 2 | ▶ | if (scalar(@a) == 3) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 318 | { | ||||||||||||||||||||||||||||
| 319 | 1 | print SH "#PBS -a $a[0]$a[1].$a[2]\n"; | |||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||
| 321 | else | ||||||||||||||||||||||||||||
| 322 | { | ||||||||||||||||||||||||||||
| 323 | 1 | $begint = join('', @a); | |||||||||||||||||||||||||||
| 324 | 1 | print SH "#PBS -a $begint\n"; | |||||||||||||||||||||||||||
| 325 | } | ||||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||
| 328 | #---------------------- | ||||||||||||||||||||||||||||
| 329 | # Job dependency option | ||||||||||||||||||||||||||||
| 330 | #---------------------- | ||||||||||||||||||||||||||||
| 331 | 11 | ▶ | if (defined $job->{depend}) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 332 | { | ||||||||||||||||||||||||||||
| 333 | 0 | my $depend = &_depend($job->{depend}); | |||||||||||||||||||||||||||
| 334 | 0 | print SH "#PBS -W depend=$depend\n"; | |||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||
| 336 | 11 | print SH "\n"; | |||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||
| 338 | #-------------- | ||||||||||||||||||||||||||||
| 339 | # Trace the job | ||||||||||||||||||||||||||||
| 340 | #-------------- | ||||||||||||||||||||||||||||
| 341 | 11 | my $cmd = $job->{cmd}; | |||||||||||||||||||||||||||
| 342 | 11 | my $tracer = $job->{tracer}; | |||||||||||||||||||||||||||
| 343 | 11 | ▶ | if ($tracer && $tracer ne 'off') | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$tracer and $tracer ne "off"
MC/DC0%0/2
$tracer and $tracer ne "off"
$tracer
$tracer ne "off"
Truth table33%1/3
A and B
A= $tracerB= $tracer ne "off"
| |||||||||||||||||||||||||||||
| 344 | { | ||||||||||||||||||||||||||||
| 345 | 0 | my $server; | |||||||||||||||||||||||||||
| 346 | 0 | ▶ | if (defined $self->{server}) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 347 | { | ||||||||||||||||||||||||||||
| 348 | 0 | $server = $self->{server}; | |||||||||||||||||||||||||||
| 349 | } | ||||||||||||||||||||||||||||
| 350 | else | ||||||||||||||||||||||||||||
| 351 | { | ||||||||||||||||||||||||||||
| 352 | 0 | $server = `qstat -Bf|head -1`; | |||||||||||||||||||||||||||
| 353 | 0 | $server = substr($server, 8); | |||||||||||||||||||||||||||
| 354 | } | ||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||
| 356 | my ($tfile) = (defined $job->{tfile})? ($job->{tfile}): | ||||||||||||||||||||||||||||
| 357 | 0 | ▶ | ($job->{script}.'.t$PBS_JOBID'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 358 | 0 | &_trace($server, $tfile, $cmd); | |||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||
| 360 | else | ||||||||||||||||||||||||||||
| 361 | { | ||||||||||||||||||||||||||||
| 362 | #---------------- | ||||||||||||||||||||||||||||
| 363 | # Execute command | ||||||||||||||||||||||||||||
| 364 | #---------------- | ||||||||||||||||||||||||||||
| 365 | 11 | print SH "$cmd\n"; | |||||||||||||||||||||||||||
| 366 | } | ||||||||||||||||||||||||||||
| 367 | 11 | close(SH); | |||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||
| 369 | 11 | return($file); | |||||||||||||||||||||||||||
| 370 | } | ||||||||||||||||||||||||||||
| 371 | #----------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||
| 374 | #------------------------------ | ||||||||||||||||||||||||||||
| 375 | # Count number of previous jobs | ||||||||||||||||||||||||||||
| 376 | sub _numPrevJob | ||||||||||||||||||||||||||||
| 377 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
_numPrevJob: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||
| 378 | 0 | my ($job) = @_; | |||||||||||||||||||||||||||
| 379 | 0 | my $on = 0; | |||||||||||||||||||||||||||
| 380 | 0 | ▶ | if (defined $job->{prev}) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 381 | { | ||||||||||||||||||||||||||||
| 382 | 0 | foreach my $type (keys %{$job->{prev}}) | |||||||||||||||||||||||||||
| 383 | { | ||||||||||||||||||||||||||||
| 384 | 0 | ▶ | if (ref($job->{prev}{$type}) eq 'ARRAY') | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 385 | { | ||||||||||||||||||||||||||||
| 386 | 0 | foreach my $jobTmp (@{$job->{prev}{$type}}) | |||||||||||||||||||||||||||
| 387 | { | ||||||||||||||||||||||||||||
| 388 | 0 | my $prevcmd = $jobTmp->{cmd}; | |||||||||||||||||||||||||||
| 389 | 0 | ▶ | if (ref($prevcmd)) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 390 | { | ||||||||||||||||||||||||||||
| 391 | 0 | my $numCmd = scalar(@$prevcmd); | |||||||||||||||||||||||||||
| 392 | 0 | $on += $numCmd; | |||||||||||||||||||||||||||
| 393 | } | ||||||||||||||||||||||||||||
| 394 | else | ||||||||||||||||||||||||||||
| 395 | { | ||||||||||||||||||||||||||||
| 396 | 0 | $on++; | |||||||||||||||||||||||||||
| 397 | } | ||||||||||||||||||||||||||||
| 398 | } | ||||||||||||||||||||||||||||
| 399 | } | ||||||||||||||||||||||||||||
| 400 | else | ||||||||||||||||||||||||||||
| 401 | { | ||||||||||||||||||||||||||||
| 402 | 0 | my $prevcmd = $job->{prev}{$type}{cmd}; | |||||||||||||||||||||||||||
| 403 | 0 | ▶ | if (ref($prevcmd)) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 404 | { | ||||||||||||||||||||||||||||
| 405 | 0 | my $numCmd = scalar(@$prevcmd); | |||||||||||||||||||||||||||
| 406 | 0 | $on += $numCmd; | |||||||||||||||||||||||||||
| 407 | } | ||||||||||||||||||||||||||||
| 408 | else | ||||||||||||||||||||||||||||
| 409 | { | ||||||||||||||||||||||||||||
| 410 | 0 | $on++; | |||||||||||||||||||||||||||
| 411 | } | ||||||||||||||||||||||||||||
| 412 | } | ||||||||||||||||||||||||||||
| 413 | } | ||||||||||||||||||||||||||||
| 414 | } | ||||||||||||||||||||||||||||
| 415 | 0 | return($on); | |||||||||||||||||||||||||||
| 416 | } | ||||||||||||||||||||||||||||
| 417 | #------------------------------ | ||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||
| 420 | #---------------------- | ||||||||||||||||||||||||||||
| 421 | # Submit dependent jobs | ||||||||||||||||||||||||||||
| 422 | # - called by qsub() | ||||||||||||||||||||||||||||
| 423 | sub _qsubDepend | ||||||||||||||||||||||||||||
| 424 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
_qsubDepend: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||
| 425 | 0 | my ($self, $job, $pbsid) = @_; | |||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||
| 427 | 0 | my %type = ( | |||||||||||||||||||||||||||
| 428 | 'prevstart' => 'before', | ||||||||||||||||||||||||||||
| 429 | 'prevend' => 'beforeany', | ||||||||||||||||||||||||||||
| 430 | 'prevok' => 'beforeok', | ||||||||||||||||||||||||||||
| 431 | 'prevfail' => 'beforenotok', | ||||||||||||||||||||||||||||
| 432 | 'nextstart' => 'after', | ||||||||||||||||||||||||||||
| 433 | 'nextend' => 'afterany', | ||||||||||||||||||||||||||||
| 434 | 'nextok' => 'afterok', | ||||||||||||||||||||||||||||
| 435 | 'nextfail' => 'afternotok', | ||||||||||||||||||||||||||||
| 436 | ); | ||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||
| 438 | 0 | foreach my $order (qw(prev next)) | |||||||||||||||||||||||||||
| 439 | { | ||||||||||||||||||||||||||||
| 440 | 0 | foreach my $cond (qw(start end ok fail)) | |||||||||||||||||||||||||||
| 441 | { | ||||||||||||||||||||||||||||
| 442 | 0 | ▶ | if (defined $job->{$order}{$cond}) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 443 | { | ||||||||||||||||||||||||||||
| 444 | 0 | my $type = $type{$order.$cond}; | |||||||||||||||||||||||||||
| 445 | 0 | ▶ | if (ref($job->{$order}{$cond}) eq 'ARRAY') # array of job obj | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 446 | { | ||||||||||||||||||||||||||||
| 447 | 0 | foreach my $jobTmp (@{$job->{$order}{$cond}}) | |||||||||||||||||||||||||||
| 448 | { | ||||||||||||||||||||||||||||
| 449 | 0 | $$jobTmp{depend}{$type} = $pbsid; | |||||||||||||||||||||||||||
| 450 | 0 | &qsub($self, $jobTmp); | |||||||||||||||||||||||||||
| 451 | } | ||||||||||||||||||||||||||||
| 452 | } | ||||||||||||||||||||||||||||
| 453 | else | ||||||||||||||||||||||||||||
| 454 | { | ||||||||||||||||||||||||||||
| 455 | 0 | my $jobTmp = $job->{$order}{$cond}; | |||||||||||||||||||||||||||
| 456 | 0 | $$jobTmp{depend}{$type} = $pbsid; | |||||||||||||||||||||||||||
| 457 | 0 | &qsub($self, $jobTmp); | |||||||||||||||||||||||||||
| 458 | } | ||||||||||||||||||||||||||||
| 459 | } | ||||||||||||||||||||||||||||
| 460 | } | ||||||||||||||||||||||||||||
| 461 | } | ||||||||||||||||||||||||||||
| 462 | } | ||||||||||||||||||||||||||||
| 463 | #---------------------- | ||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||
| 466 | #------------------------ | ||||||||||||||||||||||||||||
| 467 | # Dispatch dependent jobs | ||||||||||||||||||||||||||||
| 468 | # - called by dispatch() | ||||||||||||||||||||||||||||
| 469 | sub _dphDepend | ||||||||||||||||||||||||||||
| 470 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
_dphDepend: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||
| 471 | 0 | my ($self, $job, $pbsid) = @_; | |||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||
| 473 | 0 | my %type = ( | |||||||||||||||||||||||||||
| 474 | 'prevstart' => 'before', | ||||||||||||||||||||||||||||
| 475 | 'prevend' => 'beforeany', | ||||||||||||||||||||||||||||
| 476 | 'prevok' => 'beforeok', | ||||||||||||||||||||||||||||
| 477 | 'prevfail' => 'beforenotok', | ||||||||||||||||||||||||||||
| 478 | 'nextstart' => 'after', | ||||||||||||||||||||||||||||
| 479 | 'nextend' => 'afterany', | ||||||||||||||||||||||||||||
| 480 | 'nextok' => 'afterok', | ||||||||||||||||||||||||||||
| 481 | 'nextfail' => 'afternotok', | ||||||||||||||||||||||||||||
| 482 | ); | ||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||
| 484 | 0 | foreach my $order (qw(prev next)) | |||||||||||||||||||||||||||
| 485 | { | ||||||||||||||||||||||||||||
| 486 | 0 | foreach my $cond (qw(start end ok fail)) | |||||||||||||||||||||||||||
| 487 | { | ||||||||||||||||||||||||||||
| 488 | 0 | ▶ | if (defined $job->{$order}{$cond}) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 489 | { | ||||||||||||||||||||||||||||
| 490 | 0 | my $type = $type{$order.$cond}; | |||||||||||||||||||||||||||
| 491 | 0 | ▶ | if (ref($job->{$order}{$cond}) eq 'ARRAY') # array of job obj | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 492 | { | ||||||||||||||||||||||||||||
| 493 | 0 | foreach my $jobTmp (@{$job->{$order}{$cond}}) | |||||||||||||||||||||||||||
| 494 | { | ||||||||||||||||||||||||||||
| 495 | 0 | $$jobTmp{depend}{$type} = $pbsid; | |||||||||||||||||||||||||||
| 496 | 0 | &dispatch($self, $jobTmp); | |||||||||||||||||||||||||||
| 497 | } | ||||||||||||||||||||||||||||
| 498 | } | ||||||||||||||||||||||||||||
| 499 | else | ||||||||||||||||||||||||||||
| 500 | { | ||||||||||||||||||||||||||||
| 501 | 0 | my $jobTmp = $job->{$order}{$cond}; | |||||||||||||||||||||||||||
| 502 | 0 | $$jobTmp{depend}{$type} = $pbsid; | |||||||||||||||||||||||||||
| 503 | 0 | &dispatch($self, $jobTmp); | |||||||||||||||||||||||||||
| 504 | } | ||||||||||||||||||||||||||||
| 505 | } | ||||||||||||||||||||||||||||
| 506 | } | ||||||||||||||||||||||||||||
| 507 | } | ||||||||||||||||||||||||||||
| 508 | } | ||||||||||||||||||||||||||||
| 509 | #------------------------ | ||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||
| 511 | |||||||||||||||||||||||||||||
| 512 | #----------------------------------------------------- | ||||||||||||||||||||||||||||
| 513 | # Trace the job by recording the location of execution | ||||||||||||||||||||||||||||
| 514 | # - called by genScript() | ||||||||||||||||||||||||||||
| 515 | # | ||||||||||||||||||||||||||||
| 516 | # <IN> | ||||||||||||||||||||||||||||
| 517 | # $cmd -- command string | ||||||||||||||||||||||||||||
| 518 | sub _trace | ||||||||||||||||||||||||||||
| 519 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
_trace: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 520 | 0 | my ($server, $tfile, $cmd) = @_; | |||||||||||||||||||||||||||
| 521 | |||||||||||||||||||||||||||||
| 522 | 0 | print SH "server=$server\n"; | |||||||||||||||||||||||||||
| 523 | 0 | print SH "tfile=$tfile\n"; | |||||||||||||||||||||||||||
| 524 | 0 | print SH 'tfile=${tfile/%.$server/}'."\n"; | |||||||||||||||||||||||||||
| 525 | |||||||||||||||||||||||||||||
| 526 | # Get machine, start and finish time | ||||||||||||||||||||||||||||
| 527 | 0 | print SH 'echo MACHINES : > $tfile'."\n"; | |||||||||||||||||||||||||||
| 528 | 0 | print SH 'cat $PBS_NODEFILE >> $tfile'."\n"; | |||||||||||||||||||||||||||
| 529 | 0 | print SH 'echo "" >> $tfile'."\n"; | |||||||||||||||||||||||||||
| 530 | 0 | print SH 'start=`date +\'%F %T\'`'."\n"; | |||||||||||||||||||||||||||
| 531 | 0 | print SH 'echo "START : $start" >> $tfile'."\n"; | |||||||||||||||||||||||||||
| 532 | 0 | print SH "\n$cmd\n\n"; | |||||||||||||||||||||||||||
| 533 | 0 | print SH 'finish=`date +\'%F %T\'`'."\n"; | |||||||||||||||||||||||||||
| 534 | 0 | print SH 'echo "FINISH : $finish" >> $tfile'."\n"; | |||||||||||||||||||||||||||
| 535 | |||||||||||||||||||||||||||||
| 536 | # Calculate the duration of the command | ||||||||||||||||||||||||||||
| 537 | 0 | print SH 'begin=`date +%s -d "$start"`'."\n"; | |||||||||||||||||||||||||||
| 538 | 0 | print SH 'end=`date +%s -d "$finish"`'."\n"; | |||||||||||||||||||||||||||
| 539 | 0 | print SH 'sec=`expr $end - $begin`'."\n"; | |||||||||||||||||||||||||||
| 540 | 0 | print SH 'if [ $sec -ge 60 ]'."\n"; | |||||||||||||||||||||||||||
| 541 | 0 | print SH 'then'."\n"; | |||||||||||||||||||||||||||
| 542 | 0 | print SH ' min=`expr $sec / 60`'."\n"; | |||||||||||||||||||||||||||
| 543 | 0 | print SH ' sec=`expr $sec % 60`'."\n\n"; | |||||||||||||||||||||||||||
| 544 | 0 | print SH ' if [ $min -ge 60 ]'."\n"; | |||||||||||||||||||||||||||
| 545 | 0 | print SH ' then'."\n"; | |||||||||||||||||||||||||||
| 546 | 0 | print SH ' hr=`expr $min / 60`'."\n"; | |||||||||||||||||||||||||||
| 547 | 0 | print SH ' min=`expr $min % 60`'."\n"; | |||||||||||||||||||||||||||
| 548 | 0 | print SH ' echo "RUNTIME : $hr hr $min min $sec sec" >> $tfile'."\n"; | |||||||||||||||||||||||||||
| 549 | 0 | print SH ' else'."\n"; | |||||||||||||||||||||||||||
| 550 | 0 | print SH ' echo "RUNTIME : $min min $sec sec" >> $tfile'."\n"; | |||||||||||||||||||||||||||
| 551 | 0 | print SH ' fi'."\n"; | |||||||||||||||||||||||||||
| 552 | 0 | print SH 'else'."\n"; | |||||||||||||||||||||||||||
| 553 | 0 | print SH ' echo "RUNTIME : $sec sec" >> $tfile'."\n"; | |||||||||||||||||||||||||||
| 554 | 0 | print SH 'fi'."\n"; | |||||||||||||||||||||||||||
| 555 | } | ||||||||||||||||||||||||||||
| 556 | #----------------------------------------------------- | ||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||
| 558 | |||||||||||||||||||||||||||||
| 559 | #---------------------------------------------------------- | ||||||||||||||||||||||||||||
| 560 | # Construct node request string | ||||||||||||||||||||||||||||
| 561 | # - called by genScript() | ||||||||||||||||||||||||||||
| 562 | # | ||||||||||||||||||||||||||||
| 563 | # <IN> | ||||||||||||||||||||||||||||
| 564 | # $job -- job object | ||||||||||||||||||||||||||||
| 565 | # | ||||||||||||||||||||||||||||
| 566 | # <OUT> | ||||||||||||||||||||||||||||
| 567 | # $str -- node request string | ||||||||||||||||||||||||||||
| 568 | sub _nodes | ||||||||||||||||||||||||||||
| 569 | 11 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
_nodes: called CC=10 SCAR=23.3
| |||||||||||||||||||||||||||||
| 570 | 11 | my ($job) = @_; | |||||||||||||||||||||||||||
| 571 | 11 | ▶ | $job->nodes('1') if (!defined $job->{nodes}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 572 | 11 | my $type = ref($job->{nodes}); | |||||||||||||||||||||||||||
| 573 | |||||||||||||||||||||||||||||
| 574 | #------------------------------------------- | ||||||||||||||||||||||||||||
| 575 | # String | ||||||||||||||||||||||||||||
| 576 | # Example: | ||||||||||||||||||||||||||||
| 577 | # (1) nodes => 2, ppn => 2 | ||||||||||||||||||||||||||||
| 578 | # (2) nodes => "delta01+delta02", ppn => 2 | ||||||||||||||||||||||||||||
| 579 | # (3) nodes => "delta01:ppn=2+delta02:ppn=1" | ||||||||||||||||||||||||||||
| 580 | #------------------------------------------- | ||||||||||||||||||||||||||||
| 581 | 11 | ▶ | if ($type eq '') | ||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||
| 582 | { | ||||||||||||||||||||||||||||
| 583 | 9 | ▶ | if ($job->{nodes} =~ /^\d+$/) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 584 | { | ||||||||||||||||||||||||||||
| 585 | 8 | my $str = "$job->{nodes}"; | |||||||||||||||||||||||||||
| 586 | 8 | ▶ | $str .= ":ppn=$job->{ppn}" if (defined $job->{ppn}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 587 | 8 | return($str); | |||||||||||||||||||||||||||
| 588 | } | ||||||||||||||||||||||||||||
| 589 | else | ||||||||||||||||||||||||||||
| 590 | { | ||||||||||||||||||||||||||||
| 591 | 1 | ▶ | if (defined $job->{ppn}) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 592 | { | ||||||||||||||||||||||||||||
| 593 | 1 | my @node = split(/\s*\+\s*/, $job->{nodes}); | |||||||||||||||||||||||||||
| 594 | 1 | my $str = join(":ppn=$job->{ppn}+", @node); | |||||||||||||||||||||||||||
| 595 | 1 | $str .= ":ppn=$job->{ppn}"; | |||||||||||||||||||||||||||
| 596 | 1 | return($str); | |||||||||||||||||||||||||||
| 597 | } | ||||||||||||||||||||||||||||
| 598 | 0 | return($job->{nodes}); | |||||||||||||||||||||||||||
| 599 | } | ||||||||||||||||||||||||||||
| 600 | } | ||||||||||||||||||||||||||||
| 601 | #----------------------------------------------- | ||||||||||||||||||||||||||||
| 602 | # Array | ||||||||||||||||||||||||||||
| 603 | # Example: | ||||||||||||||||||||||||||||
| 604 | # (1) nodes => [qw(delta01 delta02)], ppn => 2 | ||||||||||||||||||||||||||||
| 605 | # (2) nodes => [qw(delta01:ppn=2 delta02:ppn=1)] | ||||||||||||||||||||||||||||
| 606 | #----------------------------------------------- | ||||||||||||||||||||||||||||
| 607 | elsif ($type eq 'ARRAY') | ||||||||||||||||||||||||||||
| 608 | { | ||||||||||||||||||||||||||||
| 609 | 1 | ▶ | if (defined $job->{ppn}) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 610 | { | ||||||||||||||||||||||||||||
| 611 | 1 | my $str = join( ":ppn=$job->{ppn}+", @{$job->{nodes}} ); | |||||||||||||||||||||||||||
| 612 | 1 | $str .= ":ppn=$job->{ppn}"; | |||||||||||||||||||||||||||
| 613 | 1 | return($str); | |||||||||||||||||||||||||||
| 614 | } | ||||||||||||||||||||||||||||
| 615 | 0 | return( join('+', @{$job->{nodes}}) ); | |||||||||||||||||||||||||||
| 616 | } | ||||||||||||||||||||||||||||
| 617 | #------------------------------------------ | ||||||||||||||||||||||||||||
| 618 | # Hash | ||||||||||||||||||||||||||||
| 619 | # Example: | ||||||||||||||||||||||||||||
| 620 | # (1) nodes => {delta01 => 2, delta02 => 1} | ||||||||||||||||||||||||||||
| 621 | #------------------------------------------ | ||||||||||||||||||||||||||||
| 622 | elsif ($type eq 'HASH') | ||||||||||||||||||||||||||||
| 623 | { | ||||||||||||||||||||||||||||
| 624 | 1 | my $str = ''; | |||||||||||||||||||||||||||
| 625 | 1 | foreach my $node (keys %{$job->{nodes}}) | |||||||||||||||||||||||||||
| 626 | { | ||||||||||||||||||||||||||||
| 627 | 1 | $str .= "$node:ppn=${$job->{nodes}}{$node}+"; | |||||||||||||||||||||||||||
| 628 | } | ||||||||||||||||||||||||||||
| 629 | 1 | chop($str); | |||||||||||||||||||||||||||
| 630 | 1 | return($str); | |||||||||||||||||||||||||||
| 631 | } | ||||||||||||||||||||||||||||
| 632 | } | ||||||||||||||||||||||||||||
| 633 | #---------------------------------------------------------- | ||||||||||||||||||||||||||||
| 634 | |||||||||||||||||||||||||||||
| 635 | |||||||||||||||||||||||||||||
| 636 | #---------------------------------------------------------- | ||||||||||||||||||||||||||||
| 637 | # Construct string for file staging (in and out) | ||||||||||||||||||||||||||||
| 638 | # - called by genScript() | ||||||||||||||||||||||||||||
| 639 | sub _stage | ||||||||||||||||||||||||||||
| 640 | 2 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
_stage: called CC=8 SCAR=38.1
| |||||||||||||||||||||||||||||
| 641 | 2 | my ($act, $file) = @_; | |||||||||||||||||||||||||||
| 642 | 2 | my $type = ref($file); | |||||||||||||||||||||||||||
| 643 | |||||||||||||||||||||||||||||
| 644 | #------------------------------------------- | ||||||||||||||||||||||||||||
| 645 | # String | ||||||||||||||||||||||||||||
| 646 | # Example: | ||||||||||||||||||||||||||||
| 647 | # stagein => "to01.file@fromMachine:from01.file,". | ||||||||||||||||||||||||||||
| 648 | # "to02.file@fromMachine:from02.file" | ||||||||||||||||||||||||||||
| 649 | # stageout => "from01.file@toMachine:to01.file,". | ||||||||||||||||||||||||||||
| 650 | # "from02.file@toMachine:to02.file" | ||||||||||||||||||||||||||||
| 651 | #------------------------------------------- | ||||||||||||||||||||||||||||
| 652 | 2 | ▶ | return($file) if ($type eq ''); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 653 | |||||||||||||||||||||||||||||
| 654 | #------------------------------------------- | ||||||||||||||||||||||||||||
| 655 | # Array | ||||||||||||||||||||||||||||
| 656 | # Example: | ||||||||||||||||||||||||||||
| 657 | # stagein => ['to01.file@fromMachine:from01.file', | ||||||||||||||||||||||||||||
| 658 | # 'to02.file@fromMachine:from02.file'] | ||||||||||||||||||||||||||||
| 659 | # stageout => ['from01.file@toMachine:to01.file', | ||||||||||||||||||||||||||||
| 660 | # 'from02.file@toMachine:to02.file'] | ||||||||||||||||||||||||||||
| 661 | #------------------------------------------- | ||||||||||||||||||||||||||||
| 662 | 0 | ▶ | return(join(',', @$file)) if ($type eq 'ARRAY'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 663 | |||||||||||||||||||||||||||||
| 664 | #------------------------------------------- | ||||||||||||||||||||||||||||
| 665 | # Hash | ||||||||||||||||||||||||||||
| 666 | # Example: | ||||||||||||||||||||||||||||
| 667 | # stagein => {'fromMachine:from01.file' => 'to01.file', | ||||||||||||||||||||||||||||
| 668 | # 'fromMachine:from02.file' => 'to02.file'} | ||||||||||||||||||||||||||||
| 669 | # stageout => {'from01.file' => 'toMachine:to01.file', | ||||||||||||||||||||||||||||
| 670 | # 'from02.file' => 'toMachine:to02.file'} | ||||||||||||||||||||||||||||
| 671 | #------------------------------------------- | ||||||||||||||||||||||||||||
| 672 | 0 | ▶ | if ($type eq 'HASH') | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 673 | { | ||||||||||||||||||||||||||||
| 674 | 0 | ▶ | if ($act eq 'in') | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 675 | { | ||||||||||||||||||||||||||||
| 676 | 0 | my @stages; | |||||||||||||||||||||||||||
| 677 | 0 | foreach my $f (keys %$file) | |||||||||||||||||||||||||||
| 678 | { | ||||||||||||||||||||||||||||
| 679 | 0 | push(@stages, "$$file{$f}".'@'."$f"); | |||||||||||||||||||||||||||
| 680 | } | ||||||||||||||||||||||||||||
| 681 | 0 | return(join(',', @stages)); | |||||||||||||||||||||||||||
| 682 | } | ||||||||||||||||||||||||||||
| 683 | elsif ($act eq 'out') | ||||||||||||||||||||||||||||
| 684 | { | ||||||||||||||||||||||||||||
| 685 | 0 | my @stages; | |||||||||||||||||||||||||||
| 686 | 0 | foreach my $f (keys %$file) | |||||||||||||||||||||||||||
| 687 | { | ||||||||||||||||||||||||||||
| 688 | 0 | push(@stages, "$f".'@'."$$file{$f}"); | |||||||||||||||||||||||||||
| 689 | } | ||||||||||||||||||||||||||||
| 690 | 0 | return(join(',', @stages)); | |||||||||||||||||||||||||||
| 691 | } | ||||||||||||||||||||||||||||
| 692 | } | ||||||||||||||||||||||||||||
| 693 | } | ||||||||||||||||||||||||||||
| 694 | #---------------------------------------------------------- | ||||||||||||||||||||||||||||
| 695 | |||||||||||||||||||||||||||||
| 696 | |||||||||||||||||||||||||||||
| 697 | #---------------------------------------------------------- | ||||||||||||||||||||||||||||
| 698 | # Construct the job dependency string | ||||||||||||||||||||||||||||
| 699 | # - called by genScript() | ||||||||||||||||||||||||||||
| 700 | # | ||||||||||||||||||||||||||||
| 701 | # <IN> | ||||||||||||||||||||||||||||
| 702 | # $arg -- hash reference of job dependency | ||||||||||||||||||||||||||||
| 703 | # | ||||||||||||||||||||||||||||
| 704 | # <OUT> | ||||||||||||||||||||||||||||
| 705 | # $str -- job dependency string | ||||||||||||||||||||||||||||
| 706 | sub _depend | ||||||||||||||||||||||||||||
| 707 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
_depend: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 708 | 0 | my ($arg) = @_; | |||||||||||||||||||||||||||
| 709 | 0 | my $str = ''; | |||||||||||||||||||||||||||
| 710 | |||||||||||||||||||||||||||||
| 711 | 0 | foreach my $type (keys %$arg) | |||||||||||||||||||||||||||
| 712 | { | ||||||||||||||||||||||||||||
| 713 | 0 | ▶ | $str .= ',' unless ($str eq ''); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 714 | 0 | my $joblist = join(':', @{$$arg{$type}}); | |||||||||||||||||||||||||||
| 715 | 0 | $str .= "$type:$joblist"; | |||||||||||||||||||||||||||
| 716 | } | ||||||||||||||||||||||||||||
| 717 | 0 | return($str); | |||||||||||||||||||||||||||
| 718 | } | ||||||||||||||||||||||||||||
| 719 | #---------------------------------------------------------- | ||||||||||||||||||||||||||||
| 720 | |||||||||||||||||||||||||||||
| 721 | |||||||||||||||||||||||||||||
| 722 | #---------------------------------------------------------- | ||||||||||||||||||||||||||||
| 723 | # Construct the mail address list string | ||||||||||||||||||||||||||||
| 724 | # - called by genScript() | ||||||||||||||||||||||||||||
| 725 | # | ||||||||||||||||||||||||||||
| 726 | # <IN> | ||||||||||||||||||||||||||||
| 727 | # "abc@ABC.com, def@DEF.com" or | ||||||||||||||||||||||||||||
| 728 | # [qw(abc@ABC.com def@DEF.com)] | ||||||||||||||||||||||||||||
| 729 | # | ||||||||||||||||||||||||||||
| 730 | # <OUT> | ||||||||||||||||||||||||||||
| 731 | # abc@ABC.com,def@DEF.com | ||||||||||||||||||||||||||||
| 732 | sub _mailList | ||||||||||||||||||||||||||||
| 733 | 1 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
_mailList: called CC=2 SCAR=7.4
| |||||||||||||||||||||||||||||
| 734 | 1 | my ($arg) = @_; | |||||||||||||||||||||||||||
| 735 | 1 | ▶ | if (ref($arg) eq 'ARRAY') | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 736 | { | ||||||||||||||||||||||||||||
| 737 | 0 | return(join(',', @$arg)); | |||||||||||||||||||||||||||
| 738 | } | ||||||||||||||||||||||||||||
| 739 | else | ||||||||||||||||||||||||||||
| 740 | { | ||||||||||||||||||||||||||||
| 741 | 1 | $arg =~ s/,\s+/,/g; | |||||||||||||||||||||||||||
| 742 | 1 | return($arg); | |||||||||||||||||||||||||||
| 743 | } | ||||||||||||||||||||||||||||
| 744 | } | ||||||||||||||||||||||||||||
| 745 | #---------------------------------------------------------- | ||||||||||||||||||||||||||||
| 746 | |||||||||||||||||||||||||||||
| 747 | |||||||||||||||||||||||||||||
| 748 | #---------------------------------------------------------- | ||||||||||||||||||||||||||||
| 749 | # Construct the environment variable list string | ||||||||||||||||||||||||||||
| 750 | # - called by genScript() | ||||||||||||||||||||||||||||
| 751 | # | ||||||||||||||||||||||||||||
| 752 | # <IN> | ||||||||||||||||||||||||||||
| 753 | # ['A', 'B =b', {C => '', D => 'd'}], | ||||||||||||||||||||||||||||
| 754 | # | ||||||||||||||||||||||||||||
| 755 | # <OUT> | ||||||||||||||||||||||||||||
| 756 | # A,B=b,c,D=d | ||||||||||||||||||||||||||||
| 757 | sub _varList | ||||||||||||||||||||||||||||
| 758 | 2 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
_varList: called CC=6 SCAR=18.2
| |||||||||||||||||||||||||||||
| 759 | 2 | my ($arg) = @_; | |||||||||||||||||||||||||||
| 760 | |||||||||||||||||||||||||||||
| 761 | 2 | ▶ | if (ref($arg) eq 'ARRAY') | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 762 | { | ||||||||||||||||||||||||||||
| 763 | 1 | my $str; | |||||||||||||||||||||||||||
| 764 | 1 | foreach my $ele (@$arg) | |||||||||||||||||||||||||||
| 765 | { | ||||||||||||||||||||||||||||
| 766 | 4 | ▶ | $str .= ',' if (defined $str); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 767 | 4 | ▶ | if (ref($ele) eq 'HASH') | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 768 | { | ||||||||||||||||||||||||||||
| 769 | 0 | $str .= &_hashVar($ele); | |||||||||||||||||||||||||||
| 770 | } | ||||||||||||||||||||||||||||
| 771 | else | ||||||||||||||||||||||||||||
| 772 | { | ||||||||||||||||||||||||||||
| 773 | 4 | $ele =~ s/\s*=\s*/=/; # remove possible spaces around "=" | |||||||||||||||||||||||||||
| 774 | 4 | $str .= $ele; | |||||||||||||||||||||||||||
| 775 | } | ||||||||||||||||||||||||||||
| 776 | } | ||||||||||||||||||||||||||||
| 777 | 1 | return($str); | |||||||||||||||||||||||||||
| 778 | } | ||||||||||||||||||||||||||||
| 779 | elsif (ref($arg) eq 'HASH') | ||||||||||||||||||||||||||||
| 780 | { | ||||||||||||||||||||||||||||
| 781 | 0 | return(&_hashVar($arg)); | |||||||||||||||||||||||||||
| 782 | } | ||||||||||||||||||||||||||||
| 783 | else | ||||||||||||||||||||||||||||
| 784 | { | ||||||||||||||||||||||||||||
| 785 | 1 | my $str = $arg; | |||||||||||||||||||||||||||
| 786 | 1 | $str =~ s/\s*=\s*/=/g; | |||||||||||||||||||||||||||
| 787 | 1 | $str =~ s/\s*,\s+/,/g; | |||||||||||||||||||||||||||
| 788 | 1 | return($str); | |||||||||||||||||||||||||||
| 789 | } | ||||||||||||||||||||||||||||
| 790 | |||||||||||||||||||||||||||||
| 791 | # Construct environment variable list string from hash | ||||||||||||||||||||||||||||
| 792 | sub _hashVar | ||||||||||||||||||||||||||||
| 793 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
_hashVar: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||
| 794 | 0 | my ($h) = @_; | |||||||||||||||||||||||||||
| 795 | 0 | my $str; | |||||||||||||||||||||||||||
| 796 | 0 | foreach my $key (keys %$h) | |||||||||||||||||||||||||||
| 797 | { | ||||||||||||||||||||||||||||
| 798 | 0 | ▶ | $str .= ',' if (defined $str); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 799 | 0 | $str .= "$key"; | |||||||||||||||||||||||||||
| 800 | 0 | ▶ | $str .= "=$$h{$key}" if ($$h{$key} ne ''); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 801 | } | ||||||||||||||||||||||||||||
| 802 | 0 | return($str); | |||||||||||||||||||||||||||
| 803 | } | ||||||||||||||||||||||||||||
| 804 | } | ||||||||||||||||||||||||||||
| 805 | #---------------------------------------------------------- | ||||||||||||||||||||||||||||
| 806 | |||||||||||||||||||||||||||||
| 807 | |||||||||||||||||||||||||||||
| 808 | #################### PBS::Client::Job #################### | ||||||||||||||||||||||||||||
| 809 | |||||||||||||||||||||||||||||
| 810 | package PBS::Client::Job; | ||||||||||||||||||||||||||||
| 811 | 8 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 812 | |||||||||||||||||||||||||||||
| 813 | #------------------------------------------------ | ||||||||||||||||||||||||||||
| 814 | # Job class | ||||||||||||||||||||||||||||
| 815 | #------------------------------------------------ | ||||||||||||||||||||||||||||
| 816 | |||||||||||||||||||||||||||||
| 817 | 8 | ▶ | use Cwd; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 818 | 8 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 819 | |||||||||||||||||||||||||||||
| 820 | #------------------------- | ||||||||||||||||||||||||||||
| 821 | # Constructor method | ||||||||||||||||||||||||||||
| 822 | # | ||||||||||||||||||||||||||||
| 823 | # <IN> | ||||||||||||||||||||||||||||
| 824 | # $class -- job object | ||||||||||||||||||||||||||||
| 825 | # %hash --- argument hash | ||||||||||||||||||||||||||||
| 826 | # | ||||||||||||||||||||||||||||
| 827 | # <OUT> | ||||||||||||||||||||||||||||
| 828 | # $self -- job object | ||||||||||||||||||||||||||||
| 829 | sub new | ||||||||||||||||||||||||||||
| 830 | 14 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||
| 831 | 14 | my ($class, %hash) = @_; | |||||||||||||||||||||||||||
| 832 | |||||||||||||||||||||||||||||
| 833 | #------------- | ||||||||||||||||||||||||||||
| 834 | # set defaults | ||||||||||||||||||||||||||||
| 835 | #------------- | ||||||||||||||||||||||||||||
| 836 | 14 | ▶ | $hash{wd} = cwd if (!defined $hash{wd}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 837 | 14 | ▶ | $hash{script} = 'pbsjob.sh' if (!defined $hash{script}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 838 | 14 | ▶ | $hash{tracer} = 'off' if (!defined $hash{tracer}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 839 | 14 | ▶ | $hash{shell} = '/bin/sh' if (!defined $hash{shell}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 840 | 14 | ▶ | $hash{name} = $hash{script} if (!defined $hash{name}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 841 | |||||||||||||||||||||||||||||
| 842 | 14 | my $self = \%hash; | |||||||||||||||||||||||||||
| 843 | 14 | return bless($self, $class); | |||||||||||||||||||||||||||
| 844 | } | ||||||||||||||||||||||||||||
| 845 | #------------------------- | ||||||||||||||||||||||||||||
| 846 | |||||||||||||||||||||||||||||
| 847 | |||||||||||||||||||||||||||||
| 848 | #-------------------------- | ||||||||||||||||||||||||||||
| 849 | # Generic attribute methods | ||||||||||||||||||||||||||||
| 850 | sub AUTOLOAD | ||||||||||||||||||||||||||||
| 851 | 42 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
AUTOLOAD: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 852 | 42 | my ($self, $key) = @_; | |||||||||||||||||||||||||||
| 853 | 42 | my $attr = our $AUTOLOAD; | |||||||||||||||||||||||||||
| 854 | 42 | $attr =~ s/.*:://; | |||||||||||||||||||||||||||
| 855 | 42 | ▶ | return if ($attr eq 'DESTROY'); # ignore destructor | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 856 | 25 | ▶ | $self->{$attr} = $key if (defined $key); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 857 | 25 | return($self->{$attr}); | |||||||||||||||||||||||||||
| 858 | } | ||||||||||||||||||||||||||||
| 859 | #-------------------------- | ||||||||||||||||||||||||||||
| 860 | |||||||||||||||||||||||||||||
| 861 | |||||||||||||||||||||||||||||
| 862 | #--------------------------------------- | ||||||||||||||||||||||||||||
| 863 | # Pack commands | ||||||||||||||||||||||||||||
| 864 | # | ||||||||||||||||||||||||||||
| 865 | # <IN> | ||||||||||||||||||||||||||||
| 866 | # $self -- job object | ||||||||||||||||||||||||||||
| 867 | # %args -- argument hash | ||||||||||||||||||||||||||||
| 868 | # -- numQ -- number of queues | ||||||||||||||||||||||||||||
| 869 | # -- cpq --- commands per queue | ||||||||||||||||||||||||||||
| 870 | sub pack | ||||||||||||||||||||||||||||
| 871 | 2 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
pack: called CC=10 SCAR=23.0
| |||||||||||||||||||||||||||||
| 872 | 2 | my ($self, %args) = @_; | |||||||||||||||||||||||||||
| 873 | 2 | my $cmdlist = $self->{cmd}; | |||||||||||||||||||||||||||
| 874 | 2 | ▶ | return if (ref($cmdlist) ne 'ARRAY'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 875 | |||||||||||||||||||||||||||||
| 876 | 2 | my @pack = (); | |||||||||||||||||||||||||||
| 877 | 2 | my $jc = 0; # job counter | |||||||||||||||||||||||||||
| 878 | 2 | ▶ | if (defined $args{numQ}) | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 879 | { | ||||||||||||||||||||||||||||
| 880 | 1 | ▶ | for (my $i = 0; $i < @$cmdlist; $i++) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 881 | { | ||||||||||||||||||||||||||||
| 882 | 10 | ▶ | if (ref($$cmdlist[$i])) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 883 | { | ||||||||||||||||||||||||||||
| 884 | 9 | foreach my $cell (@{$$cmdlist[$i]}) | |||||||||||||||||||||||||||
| 885 | { | ||||||||||||||||||||||||||||
| 886 | 15 | my $row = $jc % $args{numQ}; | |||||||||||||||||||||||||||
| 887 | 15 | push(@{$pack[$row]}, $cell); | |||||||||||||||||||||||||||
| 888 | 15 | $jc++; | |||||||||||||||||||||||||||
| 889 | } | ||||||||||||||||||||||||||||
| 890 | } | ||||||||||||||||||||||||||||
| 891 | else | ||||||||||||||||||||||||||||
| 892 | { | ||||||||||||||||||||||||||||
| 893 | 1 | my $row = $jc % $args{numQ}; | |||||||||||||||||||||||||||
| 894 | 1 | push(@{$pack[$row]}, $$cmdlist[$i]); | |||||||||||||||||||||||||||
| 895 | 1 | $jc++; | |||||||||||||||||||||||||||
| 896 | } | ||||||||||||||||||||||||||||
| 897 | } | ||||||||||||||||||||||||||||
| 898 | } | ||||||||||||||||||||||||||||
| 899 | elsif (defined $args{cpq}) | ||||||||||||||||||||||||||||
| 900 | { | ||||||||||||||||||||||||||||
| 901 | 1 | ▶ | for (my $i = 0; $i < @$cmdlist; $i++) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 902 | { | ||||||||||||||||||||||||||||
| 903 | 10 | ▶ | if (ref($$cmdlist[$i])) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 904 | { | ||||||||||||||||||||||||||||
| 905 | 9 | foreach my $cell (@{$$cmdlist[$i]}) | |||||||||||||||||||||||||||
| 906 | { | ||||||||||||||||||||||||||||
| 907 | 15 | my $row = int($jc / $args{cpq}); | |||||||||||||||||||||||||||
| 908 | 15 | push(@{$pack[$row]}, $cell); | |||||||||||||||||||||||||||
| 909 | 15 | $jc++; | |||||||||||||||||||||||||||
| 910 | } | ||||||||||||||||||||||||||||
| 911 | } | ||||||||||||||||||||||||||||
| 912 | else | ||||||||||||||||||||||||||||
| 913 | { | ||||||||||||||||||||||||||||
| 914 | 1 | my $row = int($jc / $args{cpq}); | |||||||||||||||||||||||||||
| 915 | 1 | push(@{$pack[$row]}, $$cmdlist[$i]); | |||||||||||||||||||||||||||
| 916 | 1 | $jc++; | |||||||||||||||||||||||||||
| 917 | } | ||||||||||||||||||||||||||||
| 918 | } | ||||||||||||||||||||||||||||
| 919 | } | ||||||||||||||||||||||||||||
| 920 | 2 | $self->cmd([@pack]); | |||||||||||||||||||||||||||
| 921 | } | ||||||||||||||||||||||||||||
| 922 | #--------------------------------------- | ||||||||||||||||||||||||||||
| 923 | |||||||||||||||||||||||||||||
| 924 | |||||||||||||||||||||||||||||
| 925 | #------------------------------- | ||||||||||||||||||||||||||||
| 926 | # Copy object using Data::Dumper | ||||||||||||||||||||||||||||
| 927 | sub copy | ||||||||||||||||||||||||||||
| 928 | 2 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
copy: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||
| 929 | 2 | my ($self, $num) = @_; | |||||||||||||||||||||||||||
| 930 | 8 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 931 | 2 | ▶ | if (!defined $num || $num == 1) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not defined $num or $num == 1
MC/DC50%1/2
not defined $num or $num == 1
not defined $num
$num == 1
Truth table66%2/3
not(A) or B
A= not defined $numB= $num == 1
| |||||||||||||||||||||||||||||
| 932 | { | ||||||||||||||||||||||||||||
| 933 | 1 | my $clone; | |||||||||||||||||||||||||||
| 934 | 1 | eval(Data::Dumper->Dump([$self], ['clone'])); | |||||||||||||||||||||||||||
| 935 | 1 | return($clone); | |||||||||||||||||||||||||||
| 936 | } | ||||||||||||||||||||||||||||
| 937 | |||||||||||||||||||||||||||||
| 938 | 1 | my @clones = (); | |||||||||||||||||||||||||||
| 939 | 1 | ▶ | for (my $i = 0; $i < $num; $i++) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 940 | { | ||||||||||||||||||||||||||||
| 941 | 2 | my $clone; | |||||||||||||||||||||||||||
| 942 | 2 | eval(Data::Dumper->Dump([$self], ['clone'])); | |||||||||||||||||||||||||||
| 943 | 2 | push(@clones, $clone) | |||||||||||||||||||||||||||
| 944 | } | ||||||||||||||||||||||||||||
| 945 | 1 | return(@clones); | |||||||||||||||||||||||||||
| 946 | } | ||||||||||||||||||||||||||||
| 947 | #------------------------------- | ||||||||||||||||||||||||||||
| 948 | |||||||||||||||||||||||||||||
| 949 | |||||||||||||||||||||||||||||
| 950 | __END__ | ||||||||||||||||||||||||||||