Index: /trunk/tools/eam/rawfix.20230221/src/check.rawfix.sh
===================================================================
--- /trunk/tools/eam/rawfix.20230221/src/check.rawfix.sh	(revision 42444)
+++ /trunk/tools/eam/rawfix.20230221/src/check.rawfix.sh	(revision 42445)
@@ -49,5 +49,5 @@
 
   set mynight = $2
-  mysql $DBOPTS -e "select dateobs, state from nights where (dateobs = '$mynight')"
+  mysql $DBOPTS -e "select * from nights where (dateobs = '$mynight')"
   exit 0
 endif
@@ -74,31 +74,4 @@
   if ($mystate == "md5chk.fail")   goto good_state
 
-  # stage 2:
-  if ($mystate == "fixchip_s2.new")   goto good_state
-  if ($mystate == "fixchip_s2.done")  goto good_state
-  if ($mystate == "fixchip_s2.fail")  goto good_state
-  if ($mystate == "md5sum_s2.new")    goto good_state
-  if ($mystate == "md5sum_s2.done")   goto good_state
-  if ($mystate == "md5sum_s2.fail")   goto good_state
-  if ($mystate == "md5chk_s2.new")    goto good_state
-  if ($mystate == "md5chk_s2.done")   goto good_state
-  if ($mystate == "md5chk_s2.fail")   goto good_state
-
-  # stage 3:
-  if ($mystate == "fixchip_s3.new")   goto good_state
-  if ($mystate == "fixchip_s3.done")  goto good_state
-  if ($mystate == "fixchip_s3.fail")  goto good_state
-  if ($mystate == "ckchip_s3.new")    goto good_state
-  if ($mystate == "ckchip_s3.done")   goto good_state
-  if ($mystate == "ckchip_s3.fail")   goto good_state
-
-# disable the rsyncs stages: run in directory from b-node 
-#  if ($mystate == "rsync_s1.new")  goto good_state
-#  if ($mystate == "rsync_s1.done") goto good_state
-#  if ($mystate == "rsync_s1.fail") goto good_state
-#  if ($mystate == "rsync_s2.new")  goto good_state
-#  if ($mystate == "rsync_s2.done") goto good_state
-#  if ($mystate == "rsync_s2.fail") goto good_state
-
   echo "ERROR: unknown mode $mystate"
   exit 2
@@ -106,5 +79,5 @@
   good_state:
   set t = `date +%T..%N`
-  mysql $DBOPTS -e "select dateobs, curtime() as timestamp from nights where (state = '$mystate')" | awk -v T=$t '(NR == 1){print $0}(NR > 1){print $1, T}'
+  mysql $DBOPTS -e "select dateobs, iter from nights where (state = '$mystate')" | awk -v T=$t '(NR == 1){print $0, "timestamp"}(NR > 1){print $1, $2, T}'
   exit 0
 endif
Index: /trunk/tools/eam/rawfix.20230221/src/check_chip_locations.pl
===================================================================
--- /trunk/tools/eam/rawfix.20230221/src/check_chip_locations.pl	(revision 42444)
+++ /trunk/tools/eam/rawfix.20230221/src/check_chip_locations.pl	(revision 42445)
@@ -17,5 +17,5 @@
 
 my ($fulldate, $dateword, $chiplist, $stage, $topdir) = &parse_cmdopts;
-my ($neb_dbh, $gpc_dbh) = &parse_db_config ("$topdir/nebulous.config");
+my ($neb_dbh, $gpc_dbh, $raw_dbh) = &parse_db_config ("$topdir/nebulous.config");
 
 # read the list of chip_ids:
@@ -32,4 +32,18 @@
 # instance lists by host: YYYYMMDD/HOSTNAME.inst.STAGE.txt
 # chip states by chip: YYYYMMDD/CHIPNAME.uris.STAGE.txt 
+
+my $Nchip = 0;
+
+my $Ngood = 0;
+my $Ndead = 0;
+my $Ngone = 0;
+my $Nsing = 0;
+my $Ndups = 0;
+my $Nsbck = 0;
+my $Nxbck = 0;
+
+my $Ncul1 = 0;
+my $Ncul2 = 0;
+my $Ncul3 = 0;
 
 foreach my $chip_id (@chip_ids) {
@@ -90,15 +104,36 @@
 }
 
-# run neb-replicate for SING entries?
-# run neb-replicate for SBCK entries?  (does this put a second copy at ATRC or ITC?)
-# save the list of instances on each host
-## run md5sum on the instances for each host
-## only note inconsistent md5sums?  (need to save the gpc1 md5sum values)
-# rerun to generate a list of the host with max instances per chip?
-
-### when to cull entries?
-## neb-replicate puts the new entry at ATRC by default
-## neb-replicate --volume VOL puts the new entry at the specified location
-### in order to use this, I need to choose the target volume
+print "Nchip: $Nchip\n";
+print "Ngood: $Ngood\n";
+print "Ngone: $Ngone\n";
+print "Ndead: $Ndead\n";
+print "Nsing: $Nsing\n";
+print "Ndups: $Ndups\n";
+print "Nsbck: $Nsbck\n";
+print "Nxbck: $Nxbck\n";
+print "Ncul1: $Ncul1\n";
+print "Ncul2: $Ncul2\n";
+print "Ncul3: $Ncul3\n";
+
+my $Ntotal = $Ngood + $Ngone + $Ndead + $Nsing + $Ndups + $Nsbck + $Nxbck + $Ncul1 + $Ncul2 + $Ncul3;
+if ($Ntotal != $Nchip) { die "ERROR: inconsistent count of chips\n"; } 
+
+# update the stats in the database
+my $sql_update_stats = "UPDATE nights set";
+$sql_update_stats .= "  Nchip = $Nchip";
+$sql_update_stats .= ", Ngood = $Ngood";
+$sql_update_stats .= ", Ndead = $Ndead";
+$sql_update_stats .= ", Ngone = $Ngone";
+$sql_update_stats .= ", Nsing = $Nsing";
+$sql_update_stats .= ", Ndups = $Ndups";
+$sql_update_stats .= ", Nsbck = $Nsbck";
+$sql_update_stats .= ", Nxbck = $Nxbck";
+$sql_update_stats .= ", Ncul1 = $Ncul1";
+$sql_update_stats .= ", Ncul2 = $Ncul2";
+$sql_update_stats .= ", Ncul3 = $Ncul3";
+$sql_update_stats .= " WHERE dateobs = $dateword";
+
+my $query = $raw_dbh->prepare($sql_update_stats);
+$query->execute () or die "invalid response from RAW database\n";
 
 exit 0;
@@ -256,8 +291,10 @@
 
     my $outinfo = "$extID $data_st $md5_sum";
+    $Nchip ++;
 
     # GOOD : already fixed 
     if (($Nmain == 1) && ($Nback == 1)) {
 	print $outfh "GOOD: $outinfo\n";
+	$Ngood ++;
 	return;
     }
@@ -267,4 +304,5 @@
     if (($Nmain == 1) && ($Nback == 0)) {
 	print $outfh "SING: $outinfo\n";
+	$Nsing ++;
 	return;
     }
@@ -274,4 +312,5 @@
     if (($Nmain == 0) && ($Nback == 1)) {
 	print $outfh "SBCK: $outinfo\n";
+	$Nsbck ++;
 	return;
     }
@@ -281,4 +320,5 @@
     if (($Nmain > 1) && ($Nback == 0)) {
 	print $outfh "DUPS: $outinfo\n";
+	$Ndups ++;
 	return;
     }
@@ -288,4 +328,5 @@
     if (($Nmain == 0) &&  ($Nback > 1)) {
 	print $outfh "XBCK: $outinfo\n";
+	$Nxbck ++;
 	return;
     }
@@ -294,4 +335,5 @@
     if (($Nmain == 0) && ($Nback == 0) && $Ndead) {
 	print $outfh "DEAD: $outinfo\n";
+	$Ndead ++;
 	return;
     }
@@ -299,4 +341,5 @@
     if (($Nmain == 0) && ($Nback == 0) && ($Ndead == 0)) {
 	print $outfh "GONE: $outinfo\n";
+	$Ngone ++;
 	return;
     }
@@ -306,4 +349,5 @@
     if (($Nmain > 1) && ($Nback == 1)) {
 	print $outfh "CUL1: $outinfo\n";
+	$Ncul1 ++;
 	return;
     }
@@ -313,4 +357,5 @@
     if (($Nback > 1) && ($Nmain == 1)) {
 	print $outfh "CUL2: $outinfo\n";
+	$Ncul2 ++;
 	return;
     }
@@ -320,4 +365,5 @@
     if (($Nback > 1) && ($Nmain > 1)) {
 	print $outfh "CUL3: $outinfo\n";
+	$Ncul3 ++;
 	return;
     }
@@ -335,5 +381,5 @@
     pod2usage( -msg => "Cannot determine target date, use --dateobs YYYY/MM/DD", -exitval => 2) unless defined $dateobs;
     pod2usage( -msg => "Provide a list of chips with --chiplist", -exitval => 2) unless defined $chiplist;
-    pod2usage( -msg => "Define the stage (v0, v1, etc) with --stage", -exitval => 2) unless defined $stage;
+    pod2usage( -msg => "Define the stage (0, 1, etc) with --stage", -exitval => 2) unless defined $stage;
     pod2usage( -msg => "Specify the top-level output directory with --topdir", -exitval => 2) unless defined $topdir;
     
@@ -363,4 +409,5 @@
     my ( $nebdb_name, $nebdb_host, $nebdb_port, $nebdb_pass, $nebdb_user );
     my ( $gpcdb_name, $gpcdb_host, $gpcdb_port, $gpcdb_pass, $gpcdb_user );
+    my ( $rawdb_name, $rawdb_host, $rawdb_port, $rawdb_pass, $rawdb_user );
 
     if (-e $conffile) {
@@ -380,8 +427,15 @@
 	    if ($_ =~ /GPC1_PASS /) { $gpcdb_pass = (split /\s+/,$_)[2]; }
 	    if ($_ =~ /GPC1_PORT /) { $gpcdb_port = (split /\s+/,$_)[2]; }
+
+	    if ($_ =~ /RAW_NAME /)  { $rawdb_name = (split /\s+/,$_)[2]; }
+	    if ($_ =~ /RAW_HOST /)  { $rawdb_host = (split /\s+/,$_)[2]; }
+	    if ($_ =~ /RAW_USER /)  { $rawdb_user = (split /\s+/,$_)[2]; }
+	    if ($_ =~ /RAW_PASS /)  { $rawdb_pass = (split /\s+/,$_)[2]; }
+	    if ($_ =~ /RAW_PORT /)  { $rawdb_port = (split /\s+/,$_)[2]; }
 	}
 	close(IN);
 	print STDERR  "nebulous config: $nebdb_name $nebdb_host $nebdb_port $nebdb_user $nebdb_pass\n";
 	print STDERR  "gpc1 dbh config: $gpcdb_name $gpcdb_host $gpcdb_port $gpcdb_user $gpcdb_pass\n";
+	print STDERR  "raw  dbh config: $rawdb_name $rawdb_host $rawdb_port $rawdb_user $rawdb_pass\n";
     }
 
@@ -398,4 +452,10 @@
     pod2usage( -msg => "Cannot configure gpc1 database (dbpass)", -exitval => 2) unless defined $gpcdb_pass;
 
+    pod2usage( -msg => "Cannot configure raw database (dbname)", -exitval => 2) unless defined $rawdb_name;
+    pod2usage( -msg => "Cannot configure raw database (dbhost)", -exitval => 2) unless defined $rawdb_host;
+    pod2usage( -msg => "Cannot configure raw database (dbuser)", -exitval => 2) unless defined $rawdb_user;
+    pod2usage( -msg => "Cannot configure raw database (dbport)", -exitval => 2) unless defined $rawdb_port;
+    pod2usage( -msg => "Cannot configure raw database (dbpass)", -exitval => 2) unless defined $rawdb_pass;
+
     my $nebdb_dsn = "DBI:mysql:database=$nebdb_name:host=$nebdb_host";
     if ($nebdb_port ne "NONE") { $nebdb_dsn .= ":port=$nebdb_port"; }
@@ -406,5 +466,9 @@
     my $gpc_dbh = DBI->connect($gpcdb_dsn, $gpcdb_user, $gpcdb_pass, { RaiseError => 1, AutoCommit => 1} ) or die "Unable to connect to database $DBI::errstr\n";
 
-    return ($neb_dbh, $gpc_dbh);
+    my $rawdb_dsn = "DBI:mysql:database=$rawdb_name:host=$rawdb_host";
+    if ($rawdb_port ne "NONE") { $rawdb_dsn .= ":port=$rawdb_port"; }
+    my $raw_dbh = DBI->connect($rawdb_dsn, $rawdb_user, $rawdb_pass, { RaiseError => 1, AutoCommit => 1} ) or die "Unable to connect to database $DBI::errstr\n";
+
+    return ($neb_dbh, $gpc_dbh, $raw_dbh);
 }
 
Index: /trunk/tools/eam/rawfix.20230221/src/check_night_status.pl
===================================================================
--- /trunk/tools/eam/rawfix.20230221/src/check_night_status.pl	(revision 42444)
+++ /trunk/tools/eam/rawfix.20230221/src/check_night_status.pl	(revision 42445)
@@ -37,4 +37,6 @@
 
     my $urifile = "$dateword/$chip_id.uris.$stage.txt";
+    unless (-e $urifile) { die "missing chip URI list $urifile\n"; }
+
     open (FILE, "$urifile");
     my @lines = <FILE>;
Index: /trunk/tools/eam/rawfix.20230221/src/create.rawfix.sh
===================================================================
--- /trunk/tools/eam/rawfix.20230221/src/create.rawfix.sh	(revision 42444)
+++ /trunk/tools/eam/rawfix.20230221/src/create.rawfix.sh	(revision 42445)
@@ -4,4 +4,15 @@
 set DBNAME = "rawfix"
 set DBUSER = "dvo"
+
+# add in the iteration and the state summary
+
+mysql -h localhost -u root <<EOF
+  use $DBNAME;
+  ALTER TABLE nights ADD COLUMN iter SMALLINT, ADD COLUMN Ngood SMALLINT, ADD COLUMN Ndead SMALLINT, ADD COLUMN Ngone SMALLINT;
+  ALTER TABLE nights ADD COLUMN Nsing SMALLINT, ADD COLUMN Ndups SMALLINT, ADD COLUMN Nsbck SMALLINT, ADD COLUMN Nxbck SMALLINT;
+  ALTER TABLE nights ADD COLUMN Ncul1 SMALLINT, ADD COLUMN Ncul2 SMALLINT, ADD COLUMN Ncul3 SMALLINT;
+EOF
+
+exit 0
 
 mysql -h localhost -u root <<EOF
Index: /trunk/tools/eam/rawfix.20230221/src/fix_chip_failures.pl
===================================================================
--- /trunk/tools/eam/rawfix.20230221/src/fix_chip_failures.pl	(revision 42444)
+++ /trunk/tools/eam/rawfix.20230221/src/fix_chip_failures.pl	(revision 42445)
@@ -1,3 +1,5 @@
 #! /usr/bin/env perl
+
+XXX: not yet ready
 
 # NOTE: in this script, we are using database connections to both NEBULOUS and GPC1 databases
@@ -13,6 +15,6 @@
 use Getopt::Long qw( GetOptions :config auto_help auto_version );
 
-# USAGE: fix_chip_failures.pl --dateobs (night) --chiplist (file) --stage (v0,v1,etc)
-# USAGE: fix_chip_failures.pl --dateobs 2010/05/01 --chiplist gpc1.chips.txt --stage v0
+# USAGE: fix_chip_failures.pl --dateobs (night) --chiplist (file) --stage (0,1,etc)
+# USAGE: fix_chip_failures.pl --dateobs 2010/05/01 --chiplist gpc1.chips.txt --stage 0
 
 my ($fulldate, $dateword, $chiplist, $stage, $topdir) = &parse_cmdopts;
@@ -53,5 +55,5 @@
     pod2usage( -msg => "Cannot determine target date, use --dateobs YYYY/MM/DD", -exitval => 2) unless defined $dateobs;
     pod2usage( -msg => "Provide a list of chips with --chiplist", -exitval => 2) unless defined $chiplist;
-    pod2usage( -msg => "Define the stage (v0, v1, etc) with --stage", -exitval => 2) unless defined $stage;
+    pod2usage( -msg => "Define the stage (0, 1, etc) with --stage", -exitval => 2) unless defined $stage;
     pod2usage( -msg => "Specify the top-level output directory with --topdir", -exitval => 2) unless defined $topdir;
     
Index: /trunk/tools/eam/rawfix.20230221/src/fix_chip_locations.pl
===================================================================
--- /trunk/tools/eam/rawfix.20230221/src/fix_chip_locations.pl	(revision 42444)
+++ /trunk/tools/eam/rawfix.20230221/src/fix_chip_locations.pl	(revision 42445)
@@ -19,5 +19,5 @@
 
 my ($fulldate, $dateword, $chiplist, $stage, $topdir) = &parse_cmdopts;
-my ($neb_dbh) = &parse_db_config ("$topdir/nebulous.config");
+my ($neb_dbh, $raw_dbh) = &parse_db_config ("$topdir/nebulous.config");
 
 # read the list of chip_ids:
@@ -68,4 +68,6 @@
 }
 
+my $Nchip = 0;
+
 foreach my $chip_id (@chip_ids) {
 
@@ -96,4 +98,5 @@
 	if ($failchips{$ext_id}) { $haveMD5 = 1; }
 
+	$Nchip ++;
 
 	# nothing to be done, or need be done for these:
@@ -143,5 +146,5 @@
 		close (OUTFILE);
 	    }
-	    $Ndups++; 
+	    if ($goodMD5) { $Ndups++; } else { $Nfail ++; }
 	    next; 
 	}
@@ -160,5 +163,5 @@
 		close (OUTFILE);
 	    }
-	    $Nxbck++; 
+	    if ($goodMD5) { $Nxbck++; } else { $Nfail ++; }
 	    next; 
 	}
@@ -191,7 +194,9 @@
 
 	    # these are done in stage 3:
-	    if ($state eq "CUL1:") { $Ncul1++; next; }
-	    if ($state eq "CUL2:") { $Ncul2++; next; }
-	    if ($state eq "CUL3:") { $Ncul3++; next; }
+	    if ($goodMD5) { 
+		if ($state eq "CUL1:") { $Ncul1++; next; }
+		if ($state eq "CUL2:") { $Ncul2++; next; }
+		if ($state eq "CUL3:") { $Ncul3++; next; }
+	    } else { $Nfail ++; }
 	}
     }
@@ -199,4 +204,5 @@
 }
 
+print "Nchip: $Nchip\n";
 print "Ngood: $Ngood\n";
 print "Ngone: $Ngone\n";
@@ -209,4 +215,27 @@
 print "Ncul2: $Ncul2\n";
 print "Ncul3: $Ncul3\n";
+print "Nfail: $Nfail\n";
+
+my $Ntotal = $Ngood + $Ngone + $Ndead + $Nsing + $Ndups + $Nsbck + $Nxbck + $Ncul1 + $Ncul2 + $Ncul3 + $Nfail;
+if ($Ntotal != $Nchip) { die "ERROR: inconsistent count of chips\n"; } 
+
+# update the stats in the database
+my $sql_update_stats = "UPDATE nights set";
+$sql_update_stats .= "  Nchip = $Nchip";
+$sql_update_stats .= ", Ngood = $Ngood";
+$sql_update_stats .= ", Ndead = $Ndead";
+$sql_update_stats .= ", Ngone = $Ngone";
+$sql_update_stats .= ", Nsing = $Nsing";
+$sql_update_stats .= ", Ndups = $Ndups";
+$sql_update_stats .= ", Nsbck = $Nsbck";
+$sql_update_stats .= ", Nxbck = $Nxbck";
+$sql_update_stats .= ", Ncul1 = $Ncul1";
+$sql_update_stats .= ", Ncul2 = $Ncul2";
+$sql_update_stats .= ", Ncul3 = $Ncul3";
+$sql_update_stats .= ", Nfail = $Nfail";
+$sql_update_stats .= " WHERE dateobs = $dateword";
+
+my $query = $raw_dbh->prepare($sql_update_stats);
+$query->execute () or die "invalid response from RAW database\n";
 
 exit 0;
@@ -398,4 +427,5 @@
 
     my ( $nebdb_name, $nebdb_host, $nebdb_port, $nebdb_pass, $nebdb_user );
+    my ( $rawdb_name, $rawdb_host, $rawdb_port, $rawdb_pass, $rawdb_user );
 
     if (-e $conffile) {
@@ -409,7 +439,14 @@
 	    if ($_ =~ /NEB_PASS /)  { $nebdb_pass = (split /\s+/,$_)[2]; }
 	    if ($_ =~ /NEB_PORT /)  { $nebdb_port = (split /\s+/,$_)[2]; }
+
+	    if ($_ =~ /RAW_NAME /)  { $rawdb_name = (split /\s+/,$_)[2]; }
+	    if ($_ =~ /RAW_HOST /)  { $rawdb_host = (split /\s+/,$_)[2]; }
+	    if ($_ =~ /RAW_USER /)  { $rawdb_user = (split /\s+/,$_)[2]; }
+	    if ($_ =~ /RAW_PASS /)  { $rawdb_pass = (split /\s+/,$_)[2]; }
+	    if ($_ =~ /RAW_PORT /)  { $rawdb_port = (split /\s+/,$_)[2]; }
 	}
 	close(IN);
 	print STDERR  "nebulous config: $nebdb_name $nebdb_host $nebdb_port $nebdb_user $nebdb_pass\n";
+	print STDERR  "raw  dbh config: $rawdb_name $rawdb_host $rawdb_port $rawdb_user $rawdb_pass\n";
     }
 
@@ -420,9 +457,19 @@
     pod2usage( -msg => "Cannot configure nebulous database (dbpass)", -exitval => 2) unless defined $nebdb_pass;
 
+    pod2usage( -msg => "Cannot configure raw database (dbname)", -exitval => 2) unless defined $rawdb_name;
+    pod2usage( -msg => "Cannot configure raw database (dbhost)", -exitval => 2) unless defined $rawdb_host;
+    pod2usage( -msg => "Cannot configure raw database (dbuser)", -exitval => 2) unless defined $rawdb_user;
+    pod2usage( -msg => "Cannot configure raw database (dbport)", -exitval => 2) unless defined $rawdb_port;
+    pod2usage( -msg => "Cannot configure raw database (dbpass)", -exitval => 2) unless defined $rawdb_pass;
+
     my $nebdb_dsn = "DBI:mysql:database=$nebdb_name:host=$nebdb_host";
     if ($nebdb_port ne "NONE") { $nebdb_dsn .= ":port=$nebdb_port"; }
     my $neb_dbh = DBI->connect($nebdb_dsn, $nebdb_user, $nebdb_pass, { RaiseError => 1, AutoCommit => 1} ) or die "Unable to connect to database $DBI::errstr\n";
 
-    return ($neb_dbh);
+    my $rawdb_dsn = "DBI:mysql:database=$rawdb_name:host=$rawdb_host";
+    if ($rawdb_port ne "NONE") { $rawdb_dsn .= ":port=$rawdb_port"; }
+    my $raw_dbh = DBI->connect($rawdb_dsn, $rawdb_user, $rawdb_pass, { RaiseError => 1, AutoCommit => 1} ) or die "Unable to connect to database $DBI::errstr\n";
+
+    return ($neb_dbh, $raw_dbh);
 }
 
Index: /trunk/tools/eam/rawfix.20230221/src/get_hosts_md5s.sh
===================================================================
--- /trunk/tools/eam/rawfix.20230221/src/get_hosts_md5s.sh	(revision 42444)
+++ /trunk/tools/eam/rawfix.20230221/src/get_hosts_md5s.sh	(revision 42445)
@@ -21,4 +21,4 @@
 
 # report both the dateobs and the hostnames 
-ls $topdir/$dateobs/*.inst.$stage.txt | awk -v dateobs=$dateobs -F/ '(NR == 1){print "dateobs md5host"}{print dateobs, $NF}' | sed s/.inst.$stage.txt//
+ls $topdir/$dateobs/*.inst.$stage.txt | awk -v dateobs=$dateobs -v stage=$stage -F/ '(NR == 1){print "dateobs stage md5host"}{print dateobs, stage, $NF}' | sed s/.inst.$stage.txt//
 exit 0
Index: /trunk/tools/eam/rawfix.20230221/src/rawfix.ckchip.pt
===================================================================
--- /trunk/tools/eam/rawfix.20230221/src/rawfix.ckchip.pt	(revision 42444)
+++ /trunk/tools/eam/rawfix.20230221/src/rawfix.ckchip.pt	(revision 42445)
@@ -75,10 +75,11 @@
     book setword ckchip.book $pageName pantaskState RUN
     book getword ckchip.book $pageName dateobs -var DATEOBS
+    book getword ckchip.book $pageName iter    -var ITER
     option $pageName
 
     # this is the first place in the proces that this location is known
     mkdir  $mypath/$DATEOBS
-    stdout $mypath/$DATEOBS/log.ckchip.runhosts.v0  
-    stderr $mypath/$DATEOBS/log.ckchip.runhosts.v0  
+    stdout $mypath/$DATEOBS/log.ckchip.runhosts.v$ITER
+    stderr $mypath/$DATEOBS/log.ckchip.runhosts.v$ITER  
 
     substr $DATEOBS 0 4 YEAR
@@ -88,5 +89,5 @@
     sprintf FULLDATE "%s/%s/%s" $YEAR $MONTH $DAY
 
-    command $mypath/check_chip_locations.pl --topdir $mypath --dateobs $FULLDATE --chiplist gpc1.chips.txt --stage v0
+    command $mypath/check_chip_locations.pl --topdir $mypath --dateobs $FULLDATE --chiplist gpc1.chips.txt --stage $ITER
   end
 
@@ -120,5 +121,5 @@
 # option for writing stdout / stderr to a file
 # queuepush stdout "------- end of stdout ---------"
-# queuesave stdout $options:0/log.ckchip.v0
+# queuesave stdout $options:0/log.ckchip.v$ITER
 # queuepush stderr "------- end of stderr ---------"
-# queuesave stderr $options:0/log.ckchip.v0
+# queuesave stderr $options:0/log.ckchip.v$ITER
Index: /trunk/tools/eam/rawfix.20230221/src/rawfix.fixchip.pt
===================================================================
--- /trunk/tools/eam/rawfix.20230221/src/rawfix.fixchip.pt	(revision 42444)
+++ /trunk/tools/eam/rawfix.20230221/src/rawfix.fixchip.pt	(revision 42445)
@@ -74,8 +74,9 @@
     book setword fixchip.book $pageName pantaskState RUN
     book getword fixchip.book $pageName dateobs -var DATEOBS
+    book getword fixchip.book $pageName iter    -var ITER
     option $pageName
 
-    stdout $pageName/log.fixchip.v0  
-    stderr $pageName/log.fixchip.v0
+    stdout $pageName/log.fixchip.v$ITER
+    stderr $pageName/log.fixchip.v$ITER
 
     substr $DATEOBS 0 4 YEAR
@@ -84,5 +85,5 @@
     sprintf FULLDATE "%s/%s/%s" $YEAR $MONTH $DAY
 
-    command $mypath/fix_chip_locations.pl --topdir $mypath --dateobs $FULLDATE --chiplist gpc1.chips.txt --stage v0
+    command $mypath/fix_chip_locations.pl --topdir $mypath --dateobs $FULLDATE --chiplist gpc1.chips.txt --stage $ITER
   end
 
Index: /trunk/tools/eam/rawfix.20230221/src/rawfix.md5chk.pt
===================================================================
--- /trunk/tools/eam/rawfix.20230221/src/rawfix.md5chk.pt	(revision 42444)
+++ /trunk/tools/eam/rawfix.20230221/src/rawfix.md5chk.pt	(revision 42445)
@@ -73,4 +73,5 @@
     book setword md5chk.book $pageName pantaskState RUN
     book getword md5chk.book $pageName dateobs -var DATEOBS
+    book getword md5chk.book $pageName iter    -var ITER
     option $pageName
 
@@ -81,8 +82,8 @@
 
     # does the output go here?
-    stdout $mypath/$DATEOBS/log.md5chk.v0  
-    stderr $mypath/$DATEOBS/log.md5chk.v0  
+    stdout $mypath/$DATEOBS/log.md5chk.v$ITER
+    stderr $mypath/$DATEOBS/log.md5chk.v$ITER
 
-    command $mypath/check_md5s_dateobs.pl --topdir $mypath --dateobs $FULLDATE --stage v0
+    command $mypath/check_md5s_dateobs.pl --topdir $mypath --dateobs $FULLDATE --stage $ITER
   end
 
Index: /trunk/tools/eam/rawfix.20230221/src/rawfix.md5sum.pt
===================================================================
--- /trunk/tools/eam/rawfix.20230221/src/rawfix.md5sum.pt	(revision 42444)
+++ /trunk/tools/eam/rawfix.20230221/src/rawfix.md5sum.pt	(revision 42445)
@@ -80,13 +80,16 @@
     book setword md5sum.book $pageName pantaskState RUN
     book getword md5sum.book $pageName dateobs -var DATEOBS
+    book getword md5sum.book $pageName iter    -var ITER
     option $pageName
     # save the page so we can use it below
 
     # write an entry point in the log for this night
-    sprintf tmpline "%s/%s/log.md5sum.runhosts.v0" $mypath $DATEOBS
+    sprintf tmpline "%s/%s/log.md5sum.runhosts.v%d" $mypath $DATEOBS $ITER
     date -var mydate
     exec echo "# start runhosts $mydate" >> $tmpline
 
-    command $mypath/get_hosts_md5s.sh $mypath $DATEOBS v0
+    # the command returns these fields: dateobs stage md5host
+    # NOTE: stage == ITER
+    command $mypath/get_hosts_md5s.sh $mypath $DATEOBS $ITER
   end
 
@@ -142,6 +145,8 @@
     if ("$pageName" == "NULL") break
 
+    # XXX NOTE: the output field is called 'stage'
     book setword md5host.book $pageName pantaskState RUN
     book getword md5host.book $pageName dateobs -var DATEOBS
+    book getword md5host.book $pageName stage   -var ITER
     book getword md5host.book $pageName md5host -var MD5HOST
 
@@ -150,6 +155,6 @@
 
     # does the output go here?
-    stdout $mypath/$DATEOBS/log.md5sum.runhosts.v0  
-    stderr $mypath/$DATEOBS/log.md5sum.runhosts.v0  
+    stdout $mypath/$DATEOBS/log.md5sum.runhosts.v$ITER  
+    stderr $mypath/$DATEOBS/log.md5sum.runhosts.v$ITER  
 
     # XXX TEST: $USE_HOST = ipp060
@@ -167,10 +172,10 @@
 
     ## even when testing, use the original hostname here:
-    $input = $mypath/$DATEOBS/$MD5HOST.inst.v0.txt
+    $input = $mypath/$DATEOBS/$MD5HOST.inst.$ITER.txt
 
     # need to make sure this will work on the ipp b-nodes:
     # if we are able to run the 'exec', use a short retry time to launch all outstanding jobs
     periods -exec 0.05
-    command $mypath/get_md5s_instances.pl --hostname $USE_HOST --input $input --stage v0
+    command $mypath/get_md5s_instances.pl --hostname $USE_HOST --input $input --stage $ITER
   end
 
@@ -271,9 +276,10 @@
   book getword md5sum.book $options:1 NHOST -var Nhosts
   book getword md5sum.book $options:1 NDONE -var Ndone
+  book getword md5sum.book $options:1 stage -var ITER
   $Ndone ++
   book setword md5sum.book $options:1 NDONE $Ndone
   if ("$1" != "OK")
     book setword md5sum.book $options:1 pantasksQuality $1
-    sprintf tmpline "%s/%s/log.md5sum.runhosts.v0" $mypath $options:1
+    sprintf tmpline "%s/%s/log.md5sum.runhosts.v%d" $mypath $options:1 $ITER
     exec echo "failure $1 $options:0" >> $tmpline
   else
Index: /trunk/tools/eam/rawfix.20230221/src/rawfix.pt
===================================================================
--- /trunk/tools/eam/rawfix.20230221/src/rawfix.pt	(revision 42444)
+++ /trunk/tools/eam/rawfix.20230221/src/rawfix.pt	(revision 42445)
@@ -23,18 +23,9 @@
 # order is this file is not determinative, only the
 # change of state from STAGE1.new -> STAGE1.done -> STAGE2.new
-input rawfix.advance.pt
+# input rawfix.advance.pt
 input rawfix.ckchip.pt
 input rawfix.fixchip.pt
 input rawfix.md5sum.pt
 input rawfix.md5chk.pt
-input rawfix.fixchip_s2.pt
-input rawfix.md5sum_s2.pt
-input rawfix.md5chk_s2.pt
-input rawfix.fixchip_s3.pt
-input rawfix.ckchip_s3.pt
-
-# no need to run rsync if we use the b-node working directory:
-# input rawfix.rsync_s1.pt
-# input rawfix.rsync_s2.pt
 
 ######################### UTILITIES #################################
