Index: trunk/ippScripts/scripts/lap_science.pl
===================================================================
--- trunk/ippScripts/scripts/lap_science.pl	(revision 31471)
+++ trunk/ippScripts/scripts/lap_science.pl	(revision 31475)
@@ -734,10 +734,12 @@
 	    $command .= " -set_dist_group $exposure->{dist_group} ";
 	}
-	
+	my $retry_command;
 	if ($exposure->{pairwise}) { # warpwarp
 	    my $companion = ${ $exposures }[$match_hash{$exposure->{chip_id}}];
 	    $command .= " -definewarpwarp ";
-	    $command .= "-input_label $label -template_label $label -backwards ";
+	    $command .= "-input_label $label -template_label $label ";
 	    $command .= "-warp_id $exposure->{warp_id} -template_warp_id $companion->{warp_id} ";
+	    $retry_command = $command;
+	    $command .= " -backwards "; # This usually works.
 	    $already_queued{$exposure->{warp_id}} = 1;
 	    $already_queued{$companion->{warp_id}} = 1;
@@ -763,8 +765,23 @@
 	my $diff_id = $diff->{diff_id};
 	unless (defined($diff_id)) {
-	    $exposure->{data_state} = 'drop';
-	    &update_this_exposure($exposure);
-	}
-	
+	    if ($retry_command) {
+		($success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
+		    run(command => $retry_command, verbose => $verbose);
+		unless ($success) {
+		    $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
+		    &my_die("unable to perform difftool -definewarp(warp|stack): $error_code", $exposure->{lap_id}, $exposure->{proj_cell});
+		}
+		
+		$diffs = $mdcParser->parse_list(join "", @$stdout_buf) or
+		    &my_die("Unable to parse metadata from difftool -definewarp(warp|stack)", $lap_id, "");
+		
+		$diff = ${ $diffs }[0];
+		$diff_id = $diff->{diff_id};
+	    }
+	    unless (defined($diff_id)) {
+		$exposure->{data_state} = 'drop';
+		&update_this_exposure($exposure);
+	    }
+	}
     }
 }
