File indexing completed on 2024-04-06 11:56:36
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026 BEGIN {
0027 use File::Basename;
0028 unshift(@INC, dirname($0)."/mpslib");
0029 }
0030 use Mpslib;
0031 use warnings;
0032 read_db();
0033
0034 my $confname = "";
0035 my @weightedjobs;
0036 my $firstnumber = 1;
0037
0038 my $cleanall = 0;
0039 my $weight = 1.0;
0040 my $listwtx = 0;
0041
0042
0043 while (@ARGV) {
0044 my $arg = shift(@ARGV);
0045 if ($arg =~ /-N/g) {
0046 $confname = $arg;
0047 $confname =~ s/-N//;
0048 if (length($confname) == 0) {
0049 $confname = shift(@ARGV);
0050 }
0051 $confname =~ s/\s//g;
0052 if($confname =~ /\:/)
0053 {
0054 $confname =~ s/\://g;
0055 print "colons were removed in configuration name because they are not allowed: $confname\n";
0056 }
0057 }
0058 elsif($arg =~ /-c/g)
0059 {
0060 $weight = 1;
0061 $cleanall = 1;
0062 }
0063 elsif($arg =~ /-h/g)
0064 {
0065 print 'Usage:
0066 mps_weight.pl [-c] [-h] [-N name] [weight] [jobids]
0067 Parameters:
0068 -h This help
0069 -l List all weights
0070 -c Remove all weights from the data base
0071 -N name Assign a weight to the dataset "name". See the option "mps_setup.pl -N".
0072 weight The weight to be used
0073 jobids A list of job ids to which the weight is assigned. This option is only used if neither -N nor the -c option is specified.
0074
0075 The command mps_weight.pl can be used to associated weights to individual Mille binary files. Some examples are given below.
0076
0077 # Examples:
0078 #
0079 # % mps_weight.pl -N ztomumu 5.7
0080 # Assign weight 5.7 to Mille jobs which are called "ztomumu" ("mps_setup.pl -N ztomumu ..." has to be used during job creation).
0081 #
0082 # % mps_weight.pl 6.7 3 4 102
0083 # Assign weight 6.7 to Mille binaries with numbers 3, 4, and 102, respectively.
0084 #
0085 # % mps_weight.pl -c
0086 # Remove all assigned weights.
0087 ';
0088 exit;
0089 }
0090 elsif($arg =~ /-l/g)
0091 {
0092 $listwtx = 1;
0093 }
0094 else
0095 {
0096 if($firstnumber)
0097 {
0098 $firstnumber = 0;
0099 $weight = $arg;
0100 }
0101 else
0102 {
0103 push @weightedjobs, $arg;
0104 }
0105 }
0106 }
0107
0108 if($listwtx)
0109 {
0110 print "list of weights:\n\n";
0111 print "job directory | name | weight\n";
0112 for (my $i=0; $i<@JOBID; ++$i) {
0113 unless($JOBDIR[$i] =~ /jobm/)
0114 {
0115 my $name = "undefined";
0116 my $wtx = 1.0;
0117 $name = $JOBSP3[$i] if(defined $JOBSP3[$i] && $JOBSP3[$i] ne "");
0118 $wtx = $JOBSP2[$i] if(defined $JOBSP2[$i] && $JOBSP2[$i] ne "");
0119
0120 printf "%6s | %20s | %10.3f\n",$JOBDIR[$i],$name,$wtx;
0121
0122 }
0123 }
0124 }
0125
0126 if($cleanall)
0127 {
0128 print "clean-up mps.db by removing all weights.\n";
0129 for (my $i=0; $i<@JOBID; ++$i) {
0130 my $status = $JOBSTATUS[$i];
0131 unless($JOBDIR[$i] =~ /jobm/)
0132 {
0133 $JOBSP2[$i] = "";
0134 }
0135 }
0136 }
0137 elsif($confname ne "")
0138 {
0139 print "Assign weight $weight to ${confname}.\n";
0140 for (my $i=0; $i<@JOBID; ++$i) {
0141 my $status = $JOBSTATUS[$i];
0142 unless($JOBDIR[$i] =~ /jobm/)
0143 {
0144 my $name = $JOBSP3[$i];
0145 if($name eq $confname)
0146 {
0147 $weight =~ s/\://g;
0148 $weight =~ s/\,//g;
0149 $JOBSP2[$i] = $weight;
0150 }
0151 }
0152 }
0153 }
0154 else
0155 {
0156 foreach my $j (@weightedjobs) {
0157 {
0158 $weight =~ s/\://g;
0159 $weight =~ s/\,//g;
0160 $JOBSP2[$j-1] = $weight;
0161 }
0162 }
0163 }
0164 write_db();