Index: trunk/ippScripts/scripts/publish_file.pl
===================================================================
--- trunk/ippScripts/scripts/publish_file.pl	(revision 25074)
+++ trunk/ippScripts/scripts/publish_file.pl	(revision 25100)
@@ -83,4 +83,5 @@
 my %exp_id;                     # Exposure identifiers
 my %exp_name;                   # Exposure names
+my %direction;                  # Direction of subtraction
 {
     my $command;                # Command to run
@@ -114,13 +115,21 @@
         if ($stage eq 'diff') {
             my $skycell_id = $comp->{skycell_id};
+
+            # Positive direction
             $files{"$skycell_id.pos"} = $ipprc->filename( "PPSUB.OUTPUT.SOURCES", $path_base );
-            $files{"$skycell_id.neg"} = $ipprc->filename( "PPSUB.INVERSE.SOURCES", $path_base ) if
-                defined $comp->{bothways} and $comp->{bothways};
             $zp{"$skycell_id.pos"} = $zp;
-            $zp{"$skycell_id.neg"} = $zp if defined $comp->{bothways} and $comp->{bothways};
             $exp_id{"$skycell_id.pos"} = $comp->{exp_id_1};
-            $exp_id{"$skycell_id.neg"} = $comp->{exp_id_2} if defined $comp->{bothways} and $comp->{bothways};
             $exp_name{"$skycell_id.pos"} = $comp->{exp_name_1};
-            $exp_name{"$skycell_id.neg"} = $comp->{exp_name_2} if defined $comp->{bothways} and $comp->{bothways};
+            $direction{"$skycell_id.pos"} = 1;
+
+            # Negative direction
+            if (defined $comp->{bothways} and $comp->{bothways}) {
+                $files{"$skycell_id.neg"} = $ipprc->filename( "PPSUB.INVERSE.SOURCES", $path_base );
+                $zp{"$skycell_id.neg"} = $zp;
+                $exp_id{"$skycell_id.neg"} = $comp->{exp_id_2};
+                $direction{"$skycell_id.neg"} = 0;
+                $exp_name{"$skycell_id.neg"} = $comp->{exp_name_2};
+            }
+
         } elsif ($stage eq 'camera') {
             my $cam_id = $comp->{cam_id};
@@ -129,4 +138,5 @@
             $exp_id{$cam_id} = $comp->{exp_id};
             $exp_name{$cam_id} = $comp->{exp_name};
+            $direction{$cam_id} = 1;
         }
     }
@@ -145,4 +155,5 @@
     my $exp_id = $exp_id{$comp};
     my $exp_name = $exp_name{$comp};
+    my $direction = $direction{$comp};
     if ($product eq "IPP-MOPS") {
         my $outuri = "$outroot.$comp.fits";
@@ -150,5 +161,5 @@
             &my_die( "Unable to resolve output file $outuri", $pub_id, $PS_EXIT_SYS_ERROR);
 
-        my $command = "$ppMops $file $zp $exp_id $exp_name $out";
+        my $command = "$ppMops $file $zp $exp_id $exp_name $direction $out";
         my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
             run(command => $command, verbose => $verbose);
