Index: trunk/ippScripts/scripts/detrend_resid.pl
===================================================================
--- trunk/ippScripts/scripts/detrend_resid.pl	(revision 11297)
+++ trunk/ippScripts/scripts/detrend_resid.pl	(revision 11298)
@@ -20,5 +20,5 @@
 
 my ($det_id, $iter, $exp_tag, $class_id, $det_type, $detrend,
-        $input_uri, $camera, $mode, $dbname, $no_update);
+        $input_uri, $camera, $mode, $dbname, $workdir, $no_update);
 GetOptions(
     'det_id|d=s'        => \$det_id,
@@ -32,4 +32,5 @@
     'mode|m=s'          => \$mode,
     'dbname|d=s'        => \$dbname, # Database name
+    'workdir|w=s'       => \$workdir,	# Working directory, for output files
     'no-update'         => \$no_update,
 ) or pod2usage( 2 );
@@ -99,7 +100,10 @@
 
 ### Output file names --- must match camera configuration!
-my ($vol, $dir, $file) = File::Spec->splitpath( $input_uri );
+unless (defined $workdir) {
+    my ($vol, $dir, $file) = File::Spec->splitpath( $input_uri );
+    $workdir = $dir;
+}
 my $outputRoot = $exp_tag . '.detresid.' . $det_id . '.' . $iter; # Root name
-$outputRoot = File::Spec->catpath( $vol, $dir, $outputRoot );
+$outputRoot = File::Spec->catfile( $workdir, $outputRoot );
 $outputRoot = $ipprc->convert_filename_absolute( $outputRoot );
 $input_uri = $ipprc->convert_filename_absolute( $input_uri );
