Index: trunk/ippTasks/detrend.stack.pro
===================================================================
--- trunk/ippTasks/detrend.stack.pro	(revision 12126)
+++ trunk/ippTasks/detrend.stack.pro	(revision 12368)
@@ -134,7 +134,9 @@
     end
 
-    # XXX add $WORKDIR/$LOG_DIR
-    # XXX use ipp_filename.pl to lookup output file names
-    $outroot = `ipp_datapath.pl $WORKDIR`
+    if ($WORKDIR == NULL)
+      $outroot = `pwd`
+    else
+      $outroot = `ipp_datapath.pl $WORKDIR`
+    end
     $outroot = $outroot/$CAMERA.$DET_TYPE.$DET_ID
     $logfile = $outroot/detstack.$DET_ID.$ITERATION.$CLASS_ID.log
@@ -148,7 +150,7 @@
     # create the command line
     if ($VERBOSE > 1)
-      echo command detrend_stack.pl --det_id $DET_ID --iteration $ITERATION --class_id $CLASS_ID --det_type $DET_TYPE --camera $CAMERA $ARGS
+      echo command detrend_stack.pl --det_id $DET_ID --iteration $ITERATION --class_id $CLASS_ID --det_type $DET_TYPE --camera $CAMERA --workdir $outroot $ARGS
     end
-    command detrend_stack.pl --det_id $DET_ID --iteration $ITERATION --class_id $CLASS_ID --det_type $DET_TYPE --camera $CAMERA $ARGS
+    command detrend_stack.pl --det_id $DET_ID --iteration $ITERATION --class_id $CLASS_ID --det_type $DET_TYPE --camera $CAMERA --workdir $outroot $ARGS
   end
 
