File indexing completed on 2023-10-25 09:32:17
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 BEGIN {
0018 use File::Basename;
0019 unshift(@INC, dirname($0)."/mpslib");
0020 }
0021 use Mpslib;
0022 use POSIX;
0023
0024 $inScript = "undefined";
0025 $outScript = "undefined";
0026 $runDir = "undefined";
0027 $cfgName = "undefined";
0028 $nJobs = "undefined";
0029 $mssDirLocal = "undefined";
0030 $castorPool = "undefined";
0031
0032
0033
0034 while (@ARGV) {
0035 $arg = shift(@ARGV);
0036 if ($arg =~ /\A-/) {
0037 if ($arg =~ "h") {
0038 $helpwanted = 1;
0039 }
0040 elsif ($arg =~ "c") {
0041
0042 $checkok = 1;
0043 }
0044 elsif ($arg =~ "d") {
0045 $localdir = 1;
0046 }
0047 elsif ($arg =~ "u") {
0048 $updateDb = 1;
0049 }
0050 $optionstring = "$optionstring$arg";
0051 }
0052 else {
0053 $i = $i + 1;
0054 if ($i eq 1) {
0055 $inScript = $arg;
0056 }
0057 elsif ($i eq 2) {
0058 $outScript = $arg;
0059 }
0060 elsif ($i eq 3) {
0061 $runDir = $arg;
0062 }
0063 elsif ($i eq 4) {
0064 $cfgName = $arg;
0065 }
0066 elsif ($i eq 5) {
0067 $nJobs = $arg;
0068 }
0069 elsif ($i eq 6) {
0070 $mssDirLocal = $arg;
0071 }
0072 elsif ($i eq 7) {
0073 $castorPool = $arg;
0074 }
0075 }
0076 }
0077
0078 if ($cfgName eq "undefined") {
0079 print "Insufficient information given\n";
0080 exit 1;
0081 }
0082
0083 if ($checkok == 1) {
0084 read_db();
0085 }
0086
0087
0088 open INFILE,"$inScript";
0089 undef $/;
0090 $body = <INFILE>;
0091 close INFILE;
0092 $/ = "\n";
0093
0094
0095 $nn = ($body =~ );
0096 if ($nn != 1) {
0097 print "mps_script.pl: no (unambiguous) RUNDIR directive found in runscript\n";
0098 exit 1;
0099 }
0100 $nn = ($body =~ s/RUNDIR=(.+)$/RUNDIR=$runDir/
0101
0102
0103 $/CONFIG_FILE=\$RUNDIR\/$cfgName/
0104 {
0105 print "Warning: mps_script matches cfg: $nn\n";
0106 }
0107
0108
0109 $body =~ s/cd\s+CMSSW_RELEASE_AREA/cd $ENV{'CMSSW_BASE'}/g;
0110
0111
0112 $nn = ($body =~ );
0113 if ($nn != 1) {
0114 print "mps_script.pl: no (unambiguous) MSSDIR directive found in runscript\n";
0115 }
0116 $nn = ($body =~ s/MSSDIR=(.+)$/MSSDIR=$mssDirLocal/
0117
0118 {
0119
0120 $nn = ($body =~ s/MSSDIRPOOL=(.*)$/MSSDIRPOOL=$castorPool/
0121
0122
0123 $/MSSDIRPOOL=/
0124
0125
0126
0127
0128
0129 {
0130 if ($theLine =~ ) {
0131 $newBlock = "";
0132 for ($i = 1; $i <= $nJobs; ++$i) {
0133
0134 if ($checkok==1 && @JOBSTATUS[$i-1] ne "OK") {next;}
0135
0136 $newLine = $theLine;
0137 $isnRep = sprintf "%03d",$i;
0138 $newLine =~ s/ISN/$isnRep/g;
0139 if ($i != 1) { $newBlock = $newBlock . "\n"; }
0140 $newBlock = $newBlock . $newLine;
0141 }
0142 $theLine = $newBlock;
0143 }
0144 }
0145 $body = join "\n",@LINES;
0146
0147
0148 open OUTFILE,">$outScript";
0149 print OUTFILE $body;
0150 close OUTFILE;
0151 system "chmod a+x $outScript";
0152
0153