Index: trunk/ippScripts/scripts/diff_skycell.pl
===================================================================
--- trunk/ippScripts/scripts/diff_skycell.pl	(revision 13663)
+++ trunk/ippScripts/scripts/diff_skycell.pl	(revision 13698)
@@ -80,6 +80,6 @@
 
 # Identify the input and the template
-my $input;			# Input file
-my $template;			# Template file
+my $input, $inputMask;		# Input file and mask
+my $template, $templateMask;	# Template file and mask
 my $tess_id;			# Tesselation identifier
 my $skycell_id;			# Skycell identifier
@@ -88,6 +88,8 @@
     if (defined $file->{template} and $file->{template}) {
 	$template = $file->{uri};
+	$templateMask = $ipprc->filename("PSWARP.OUTPUT.MASK", $file->{path_base});
     } else {
 	$input = $file->{uri};
+	$inputMask = $ipprc->filename("PSWARP.OUTPUT.MASK", $file->{path_base});
     }
     if (defined $tess_id) {
@@ -115,11 +117,16 @@
 $ipprc->define_camera($camera);
 
+&my_die("Couldn't find input: $template", $diff_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($template);
+&my_die("Couldn't find input: $templateMask", $diff_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($templateMask);
+&my_die("Couldn't find input: $nput", $diff_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($input);
+&my_die("Couldn't find input: $nputMask", $diff_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($inputMask);
 
 # Get the output filenames
 $workdir = caturi( $workdir, "tess_" . $tess_id, "sky_" . $skycell_id ) if defined $workdir;
 my $outputRoot = $ipprc->file_prepare( "$tess_id.$skycell_id.dif$diff_id", $workdir, $input );
-my $outputName = $outputRoot . ".fits";
-my $bin1Name =  $ipprc->filename("PPIMAGE.BIN1", $outputRoot);
-my $bin2Name =  $ipprc->filename("PPIMAGE.BIN2", $outputRoot);
+my $outputName = $ipprc->filename("PPSUB.OUTPUT", $outputRoot);
+my $outputMask = $ipprc->filename("PPSUB.OUTPUT.MASK", $outputRoot);
+#my $bin1Name =  $ipprc->filename("PPSUB.BIN1", $outputRoot);
+#my $bin2Name =  $ipprc->filename("PPSUB.BIN2", $outputRoot);
 my $outputStats = $outputRoot . '.stats';
 
@@ -133,5 +140,5 @@
 my $stats = PS::IPP::Metadata::Stats->new(); # Stats parser
 unless ($no_op) {
-    my $command = "$ppSub $input $template $outputName"; # Command to run ppSub
+    my $command = "$ppSub $input $template $outputName -inmask $inputMask -refmask $templateMask -stat $outputStats"; # Command to run ppSub
 
     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
@@ -141,8 +148,9 @@
 	&my_die("Unable to perform ppSub: $error_code", $diff_id, $error_code);
     }
-    &my_die("Couldn't find expected output file: $outputName", $diff_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputName);
-#    &my_die("Couldn't find expected output file: $bin1Name",    $diff_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($bin1Name);
-#    &my_die("Couldn't find expected output file: $bin2Name",    $diff_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($bin2Name);
-#    &my_die("Couldn't find expected output file: $outputStats", $diff_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputStats);
+    &my_die("Couldn't find expected output file: $outputName", $diff_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputName);
+    &my_die("Couldn't find expected output file: $outputMask", $diff_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputMask);
+#    &my_die("Couldn't find expected output file: $bin1Name",    $diff_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($bin1Name);
+#    &my_die("Couldn't find expected output file: $bin2Name",    $diff_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($bin2Name);
+    &my_die("Couldn't find expected output file: $outputStats", $diff_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputStats);
 
     # Get the statistics on the residual image
@@ -164,5 +172,5 @@
     # Add the subtraction result
     {
-	my $command = "$difftool -adddiffskyfile -diff_id $diff_id -uri $outputName"; # -path_base $outputRoot";
+	my $command = "$difftool -adddiffskyfile -diff_id $diff_id -uri $outputName -path_base $outputRoot";
 	$command .= " -bg $bg -bg_stdev $bg_stdev";
 	$command .= " -dbname $dbname" if defined $dbname;
@@ -202,5 +210,5 @@
 	my $command = "$difftool -updaterun -diff_id $diff_id -state stop -code $exit_code";
 	$command .= " -dbname $dbname" if defined $dbname;
-        system ($command);
+###        system ($command);
     }
     exit $exit_code;
