Index: trunk/ippScripts/scripts/detrend_stack.pl
===================================================================
--- trunk/ippScripts/scripts/detrend_stack.pl	(revision 15467)
+++ trunk/ippScripts/scripts/detrend_stack.pl	(revision 16196)
@@ -33,5 +33,5 @@
 use Pod::Usage qw( pod2usage );
 
-my ($det_id, $iter, $class_id, $det_type, $camera, $dbname, $workdir, $reduction, $no_update, $no_op, $quiet);
+my ($det_id, $iter, $class_id, $det_type, $camera, $outroot, $dbname, $reduction, $no_update, $no_op, $quiet);
 GetOptions(
     'det_id|d=s'        => \$det_id,
@@ -40,6 +40,6 @@
     'det_type|t=s'      => \$det_type,
     'camera|c=s'        => \$camera,
+    'outroot|w=s'       => \$outroot,   # output file base name
     'dbname|d=s'        => \$dbname, # Database name
-    'workdir|w=s'       => \$workdir, # Working directory, for output files
     'reduction=s'       => \$reduction,	# Reduction class for processing
     'no-update'         => \$no_update,
@@ -49,11 +49,12 @@
 
 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
-pod2usage( -msg => "Required options: --det_id --iteration --class_id --det_type --camera", 
-	   -exitval => 3) 
-    unless defined $det_id
-    and defined $iter
-    and defined $class_id
-    and defined $det_type
-    and defined $camera;
+pod2usage( -msg => "Required options: --det_id --iteration --class_id --det_type --camera --outroot", 
+	   -exitval => 3) unless 
+    defined $det_id   and 
+    defined $iter     and 
+    defined $class_id and 
+    defined $det_type and 
+    defined $camera   and
+    defined $outroot;
 
 my $verbose = 1;
@@ -111,12 +112,17 @@
 }
 
-$workdir = caturi( $workdir, "$camera.$det_type.$det_id" ) if defined $workdir;
-
-my $outputRoot  = $ipprc->file_prepare( "$camera.$det_type.$det_id.$iter.$class_id", $workdir, ${$files}[0]->{uri} );
-my $outputStack = $outputRoot . '.fits'; # Output name
-my $outputStats = $outputRoot . '.stats'; # Statistics name
-
-my $traceDest = 'file:' . $ipprc->file_resolve($outputRoot) . ".trace"; # Trace messages
-my $logDest = 'file:' . $ipprc->file_resolve($outputRoot) . ".log"; # Log messages
+# outroot examples (HOST components must be set)
+# file://data/ipp004.0/gpc1/20080130
+# neb:///ipp004-v1/gpc1/20080130
+# neb:///*/gpc1/20080130 (volume not specified)
+
+# check for existing directory, generate if needed
+$ipprc->outroot_prepare($outroot);
+
+## XXX should we be using the filerules here?
+my $outputStack = $outroot . '.fits'; # Output name
+my $outputStats = $outroot . '.stats'; # Statistics name
+my $traceDest   = $outroot . '.trace'; # Trace messages
+my $logDest     = $outroot . '.log'; # Log messages
 
 $command = "$ppMerge $outputStack"; # Command to run
