Index: trunk/ippScripts/scripts/detrend_process_exp.pl
===================================================================
--- trunk/ippScripts/scripts/detrend_process_exp.pl	(revision 15643)
+++ trunk/ippScripts/scripts/detrend_process_exp.pl	(revision 16196)
@@ -35,5 +35,5 @@
 use Pod::Usage qw( pod2usage );
 
-my ($det_id, $exp_id, $det_type, $exp_tag, $camera, $dbname, $workdir, $reduction, $no_update, $no_op);
+my ($det_id, $exp_id, $det_type, $exp_tag, $camera, $outroot, $dbname, $reduction, $no_update, $no_op);
 GetOptions(
     'det_id|d=s'        => \$det_id,
@@ -42,6 +42,6 @@
     'exp_tag|=s'        => \$exp_tag,
     '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,
     'no-update'         => \$no_update,
@@ -50,11 +50,12 @@
 
 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
-pod2usage( -msg => "Required options: --det_id --det_type --exp_id --exp_tag --camera",
-	   -exitval => 3) 
-    unless defined $det_id
-    and defined $det_type
-    and defined $exp_id
-    and defined $exp_tag
-    and defined $camera;
+pod2usage( -msg => "Required options: --det_id --det_type --exp_id --exp_tag --camera --outroot",
+	   -exitval => 3) unless 
+    defined $det_id   and 
+    defined $det_type and 
+    defined $exp_id   and 
+    defined $exp_tag  and 
+    defined $camera   and
+    defined $outroot;
 
 $ipprc->define_camera($camera);
@@ -129,13 +130,18 @@
 close $list2File;
 
-# Output files
-$workdir = caturi( $workdir, "$camera.$det_type.$det_id" ) if defined $workdir;
-my $outputRoot = $ipprc->file_prepare( "$exp_tag/$exp_tag.detproc.$det_id", $workdir, ${$files}[0]->{path_base} );
-my $jpeg1 = $ipprc->filename("PPIMAGE.JPEG1", $outputRoot); # Binned JPEG #1
-my $jpeg2 = $ipprc->filename("PPIMAGE.JPEG2", $outputRoot); # Binned JPEG #2
+# 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);
+
+my $jpeg1 = $ipprc->filename("PPIMAGE.JPEG1", $outroot); # Binned JPEG #1
+my $jpeg2 = $ipprc->filename("PPIMAGE.JPEG2", $outroot); # Binned JPEG #2
 
 unless ($no_op) {
     # Make the jpeg for binning 1
-    $command = "$ppImage -list $list1Name $outputRoot -recipe PPIMAGE $recipe1"; # Command to run
+    $command = "$ppImage -list $list1Name $outroot -recipe PPIMAGE $recipe1"; # Command to run
     ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
 	run(command => $command, verbose => 1);
@@ -147,5 +153,5 @@
     
     # Make the jpeg for binning 2
-    $command = "$ppImage -list $list2Name $outputRoot -recipe PPIMAGE $recipe2"; # Command to run
+    $command = "$ppImage -list $list2Name $outroot -recipe PPIMAGE $recipe2"; # Command to run
     ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
 	run(command => $command, verbose => 1);
@@ -161,5 +167,5 @@
 $command .= " -det_id $det_id";
 $command .= " -exp_id $exp_id";
-$command .= " -recip $recipe1,$recipe2 -path_base $outputRoot";
+$command .= " -recip $recipe1,$recipe2 -path_base $outroot";
 $command .= " -dbname $dbname" if defined $dbname;
 $command .= $stats->cmdflags();
