Index: trunk/ippScripts/scripts/automate_stacks.pl
===================================================================
--- trunk/ippScripts/scripts/automate_stacks.pl	(revision 29653)
+++ trunk/ippScripts/scripts/automate_stacks.pl	(revision 29656)
@@ -1267,5 +1267,9 @@
     my $stack_done_sth = "SELECT * from stackRun LEFT JOIN stackSumSkyfile USING(stack_id) WHERE $where ";
     $stack_done_sth .= " AND ((state = 'full') OR (state = 'new' && fault != 0)) ";
-
+    if ($debug == 1) {
+	print STDERR "post_stack_queue: database queries:\n";
+	print STDERR "$stack_full_sth\n";
+	print STDERR "$stack_done_sth\n";
+    }
     my $stack_full_ref = $db->selectall_arrayref( $stack_full_sth );
     my $stack_done_ref = $db->selectall_arrayref( $stack_done_sth );
@@ -1281,12 +1285,20 @@
         if ($stackable_list{$target} == 1) {
 	    my ($Nstacks, $Nattempted) = post_stack_queue($date,$target);
+	    if ($debug == 1) {
+		print STDERR "confirm_stacks: Target $target on $date has $Nattempted attempts on $Nstacks.\n";
+	    }
 	    if ($Nstacks != $Nattempted) {
 		if ($debug == 1) {
-		    print STDERR "confirm_stacks: Target $target on $date is not done stacking. $Nstacks $Nattempted\n"
+		    print STDERR "confirm_stacks: Target $target on $date is not done stacking. $Nstacks $Nattempted\n";
 		}
 		if ($metadata_out{nsState} eq 'CONFIRM_STACKING') {
 		    $metadata_out{nsState} = 'STACKING';
 		}
-		    
+		next;
+	    }
+	    if ($Nstacks == 0) {
+		if ($debug == 1) {
+		    print STDERR "confirm_stacks: Target $target on $date has no stacks. Skipping.\n";
+		}
 		next;
 	    }
@@ -1531,5 +1543,7 @@
 	my $N = $metadata_out{N_MACROS};
 	$metadata_out{"ns${N}Macro"} = $macro_formats{$proc_mode};
-#	print STDERR "WORKING ON A MACRO: ns${N}Macro $proc_mode $macro_formats{$proc_mode}\n";
+	if ($debug == 1) {
+	    print STDERR "WORKING ON A MACRO: ns${N}Macro $proc_mode $macro_formats{$proc_mode}\n";
+	}
 	if (defined($date)&&(defined($target))) {
 
@@ -1552,4 +1566,7 @@
 	    $metadata_out{"ns${N}Macro"} =~ s/\@DATE\@/$date/;
 	}
+	if ($debug == 1) {
+	    print STDERR "DONE WITH A MACRO: ns${N}Macro $proc_mode $macro_formats{$proc_mode}\n";
+	}
 	$metadata_out{N_MACROS} ++;
     }
