- Timestamp:
- Apr 13, 2023, 9:30:40 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/eam/rawfix.20230221/src/fix_chip_locations.pl
r42447 r42449 12 12 use Getopt::Long qw( GetOptions :config auto_help auto_version ); 13 13 14 # USAGE: fix_chip_locations.pl --dateobs (night) -- chiplist (file) --stage (0,1,etc)14 # USAGE: fix_chip_locations.pl --dateobs (night) --stage (0,1,etc) [--chiplist (file) | --chipID (ID)] 15 15 16 16 # we need to select targets for ITC copies of files currently only at ATRC: … … 18 18 # for each chip, target a single host? 19 19 20 my ($fulldate, $dateword, $chiplist, $ stage, $topdir) = &parse_cmdopts;20 my ($fulldate, $dateword, $chiplist, $chipID, $stage, $topdir) = &parse_cmdopts; 21 21 my ($neb_dbh, $raw_dbh) = &parse_db_config ("$topdir/nebulous.config"); 22 23 # read the list of chip_ids:24 my @chip_ids = &load_chip_list ($chiplist);25 22 26 23 # choose ITC machines on which to place backup copies: 27 24 my @vol_copy = &get_neb_volumes_copy; # array of neb hosts to copy data to at ITC 28 25 my %vol_good = &get_neb_volumes_good; # hash of valid neb hosts 29 my $volnum = 0;30 26 31 27 my $Ngood = 0; … … 41 37 my $Ncul3 = 0; 42 38 my $Nfail = 0; 39 40 my $Nchip = 0; # counts the number of instances 43 41 44 42 # load the lists of good and fail chips … … 69 67 } 70 68 71 my $Nchip = 0; 72 69 # read the list of chip_ids: 70 my @chip_ids = &load_chip_list ($chiplist); 71 72 my $volnum = 0; # select the volume to be used from the list of @vol_copy 73 74 # loop over all chip_ids so we can distribute the target volumes 73 75 foreach my $chip_id (@chip_ids) { 76 if (not defined $chipID or ($chipID eq $chip_id)) { 77 &fix_chip_locations_chipID ($chip_id, $volnum); 78 } 79 $volnum ++; 80 if ($volnum > @vol_copy) { $volnum = 0; } 81 } 82 83 my $Ntotal = $Ngood + $Ngone + $Ndead + $Nsing + $Ndups + $Nsbck + $Nxbck + $Ncul1 + $Ncul2 + $Ncul3 + $Nfail; 84 if ($Ntotal != $Nchip) { die "ERROR: inconsistent count of chips\n"; } 85 86 if (not defined $chipID) { 87 # update the stats in the database 88 my $sql_update_stats = "UPDATE nights set"; 89 $sql_update_stats .= " Nchip = $Nchip"; 90 $sql_update_stats .= ", Ngood = $Ngood"; 91 $sql_update_stats .= ", Ndead = $Ndead"; 92 $sql_update_stats .= ", Ngone = $Ngone"; 93 $sql_update_stats .= ", Nsing = $Nsing"; 94 $sql_update_stats .= ", Ndups = $Ndups"; 95 $sql_update_stats .= ", Nsbck = $Nsbck"; 96 $sql_update_stats .= ", Nxbck = $Nxbck"; 97 $sql_update_stats .= ", Ncul1 = $Ncul1"; 98 $sql_update_stats .= ", Ncul2 = $Ncul2"; 99 $sql_update_stats .= ", Ncul3 = $Ncul3"; 100 $sql_update_stats .= ", Nfail = $Nfail"; 101 $sql_update_stats .= " WHERE dateobs = $dateword"; 102 103 my $query = $raw_dbh->prepare($sql_update_stats); 104 $query->execute () or die "invalid response from RAW database\n"; 105 } else { 106 107 open (OUTFILE, ">$topdir/$dateword/$chipID.stats.$stage.txt"); 108 109 print OUTFILE "Nchip: $Nchip\n"; 110 print OUTFILE "Ngood: $Ngood\n"; 111 print OUTFILE "Ngone: $Ngone\n"; 112 print OUTFILE "Ndead: $Ndead\n"; 113 print OUTFILE "Nsing: $Nsing\n"; 114 print OUTFILE "Ndups: $Ndups\n"; 115 print OUTFILE "Nsbck: $Nsbck\n"; 116 print OUTFILE "Nxbck: $Nxbck\n"; 117 print OUTFILE "Ncul1: $Ncul1\n"; 118 print OUTFILE "Ncul2: $Ncul2\n"; 119 print OUTFILE "Ncul3: $Ncul3\n"; 120 print OUTFILE "Nfail: $Nfail\n"; 121 122 close (OUTFILE); 123 } 124 125 exit 0; 126 127 sub fix_chip_locations_chipID { 128 129 my $chip_id = $_[0]; 130 my $volnum = $_[1]; 74 131 75 132 # read from chip_id file, update to next stage number … … 216 273 } 217 274 } 218 $volnum ++; 219 } 220 221 print "Nchip: $Nchip\n"; 222 print "Ngood: $Ngood\n"; 223 print "Ngone: $Ngone\n"; 224 print "Ndead: $Ndead\n"; 225 print "Nsing: $Nsing\n"; 226 print "Ndups: $Ndups\n"; 227 print "Nsbck: $Nsbck\n"; 228 print "Nxbck: $Nxbck\n"; 229 print "Ncul1: $Ncul1\n"; 230 print "Ncul2: $Ncul2\n"; 231 print "Ncul3: $Ncul3\n"; 232 print "Nfail: $Nfail\n"; 233 234 my $Ntotal = $Ngood + $Ngone + $Ndead + $Nsing + $Ndups + $Nsbck + $Nxbck + $Ncul1 + $Ncul2 + $Ncul3 + $Nfail; 235 if ($Ntotal != $Nchip) { die "ERROR: inconsistent count of chips\n"; } 236 237 # update the stats in the database 238 my $sql_update_stats = "UPDATE nights set"; 239 $sql_update_stats .= " Nchip = $Nchip"; 240 $sql_update_stats .= ", Ngood = $Ngood"; 241 $sql_update_stats .= ", Ndead = $Ndead"; 242 $sql_update_stats .= ", Ngone = $Ngone"; 243 $sql_update_stats .= ", Nsing = $Nsing"; 244 $sql_update_stats .= ", Ndups = $Ndups"; 245 $sql_update_stats .= ", Nsbck = $Nsbck"; 246 $sql_update_stats .= ", Nxbck = $Nxbck"; 247 $sql_update_stats .= ", Ncul1 = $Ncul1"; 248 $sql_update_stats .= ", Ncul2 = $Ncul2"; 249 $sql_update_stats .= ", Ncul3 = $Ncul3"; 250 $sql_update_stats .= ", Nfail = $Nfail"; 251 $sql_update_stats .= " WHERE dateobs = $dateword"; 252 253 my $query = $raw_dbh->prepare($sql_update_stats); 254 $query->execute () or die "invalid response from RAW database\n"; 255 256 exit 0; 275 } 257 276 258 277 sub get_new_instance { … … 412 431 sub parse_cmdopts { 413 432 414 my ($dateobs, $chiplist, $ stage, $topdir);415 GetOptions( 'dateobs=s' => \$dateobs, 'chiplist=s' => \$chiplist, ' topdir=s' => \$topdir, 'stage=s' => \$stage) || pod2usage(2);433 my ($dateobs, $chiplist, $chipID, $stage, $topdir); 434 GetOptions( 'dateobs=s' => \$dateobs, 'chiplist=s' => \$chiplist, 'chipID=s' => \$chipID, 'topdir=s' => \$topdir, 'stage=s' => \$stage) || pod2usage(2); 416 435 417 436 pod2usage( -msg => "Cannot determine target date, use --dateobs YYYY/MM/DD", -exitval => 2) unless defined $dateobs; 418 pod2usage( -msg => "Provide a list of chips with --chiplist", -exitval => 2) unless defined $chiplist;419 437 pod2usage( -msg => "Define the stage (0, 1, etc) with --stage", -exitval => 2) unless defined $stage; 420 438 pod2usage( -msg => "Specify the top-level output directory with --topdir", -exitval => 2) unless defined $topdir; 421 439 pod2usage( -msg => "Provide a list of chips with --chiplist", -exitval => 2) unless defined $chiplist; 440 422 441 # check that stage is an integer 423 442 unless (is_integer ($stage)) { die "stage must be a non-negative integer\n"; } … … 435 454 my $dateword = sprintf ("%4d%02d%02d", $date_year, $date_month, $date_day); 436 455 437 return ($fulldate, $dateword, $chiplist, $ stage, $topdir);456 return ($fulldate, $dateword, $chiplist, $chipID, $stage, $topdir); 438 457 } 439 458
Note:
See TracChangeset
for help on using the changeset viewer.
