Index: trunk/ippScripts/scripts/stack_skycell.pl
===================================================================
--- trunk/ippScripts/scripts/stack_skycell.pl	(revision 35950)
+++ trunk/ippScripts/scripts/stack_skycell.pl	(revision 36397)
@@ -40,5 +40,5 @@
 }
 
-my ($stack_id, $dbname, $outroot, $debug, $run_state, $threads, $reduction, $verbose, $no_update, $no_op, $redirect, $save_temps);
+my ($stack_id, $dbname, $outroot, $debug, $run_state, $threads, $reduction, $verbose, $no_update, $no_op, $redirect, $save_temps, $delete_convolved_images);
 GetOptions(
     'stack_id|d=s'      => \$stack_id, # Stack identifier
@@ -55,4 +55,5 @@
     'redirect-output'   => \$redirect,
     'save-temps'        => \$save_temps, # Save temporary files?
+    'delete-convolved'  => \$delete_convolved_images,
 ) or pod2usage( 2 );
 
@@ -92,4 +93,5 @@
 );
 
+
 my $ipprc = PS::IPP::Config->new() or my_die( "Unable to set up", $stack_id, $PS_EXIT_CONFIG_ERROR ); # IPP configuration
 $| = 1;
@@ -360,5 +362,25 @@
 
     if (!$quality) {
+	
+
         check_outputs(\@outputFiles, $replicate_outputs);
+
+	if (($convolve)&&($delete_convolved_images)) { # We made convolved products, but do not wish to keep them anymore
+	    my @products_to_clear = ('PPSTACK.OUTPUT',
+				     'PPSTACK.OUTPUT.MASK',
+				     'PPSTACK.OUTPUT.VARIANCE',
+				     'PPSTACK.OUTPUT.EXP',
+				     'PPSTACK.OUTPUT.EXPNUM',
+				     'PPSTACK.OUTPUT.EXPWT');
+	    foreach my $product (@products_to_clear) {
+		my $file = $ipprc->filename($product,$outroot,$skycell_id);
+		print "Deleting unwanted convolved product: $file\n";
+		my $error= $ipprc->kill_file($file);
+		if ($error_code) {
+		    print "Failed to delete unwanted convolved product: $error_code\n";
+		}
+	    }
+	}
+
     }
 
