Index: trunk/ippTasks/detrend.stack.pro
===================================================================
--- trunk/ippTasks/detrend.stack.pro	(revision 9506)
+++ trunk/ippTasks/detrend.stack.pro	(revision 10692)
@@ -9,8 +9,6 @@
 # detrend_stack.pl 1 0 mc bias
 
-## these tasks use the queue DetrendClassIDtoStack
-
-## these tasks use the queue DetrendImfilesToProcess
-## the DetrendClassIDtoStack queue contains:
+## these tasks use the queue DetrendStackClass
+## the DetrendStackClass queue contains:
 ## STATE DET_ID ITER TYPE CLASS_ID CAMERA
 
@@ -23,9 +21,26 @@
 end
 
+$DetrendStackClassFail = 0
+
+if ($?VERBOSE == 0)
+  echo "VERBOSE not defined: load pantasks.pro first"
+  break
+end
+if ($?LOGDIR == 0)
+  echo "LOGDIR not defined: load pantasks.pro first"
+  break
+end
+$LOGSUBDIR = $LOGDIR/detrend
+exec mkdir -p $LOGSUBDIR
+
+macro detstack.status
+  queueprint DetrendStackClass
+  echo "DetrendStackClassFail: $DetrendStackClassFail"
+end
+
 # select images ready for copy 
 # new entries are added to queue DetrendStackClass
 # compare the new list with the ones already selected
 task	       dettool.stack.load
-  command      dettool -tostacked -simple
   host         local
 
@@ -34,6 +49,10 @@
   periods      -timeout 30
 
-  stdout dettool.stack.log
-  stderr dettool.stack.log
+  stdout $LOGSUBDIR/detstack.log
+  stderr $LOGSUBDIR/detstack.log
+
+  task.exec
+    command dettool -tostacked -simple -limit {$DetrendStackClassFail + 20}
+  end
 
   # success
@@ -46,4 +65,7 @@
     for i 0 $Nqueue
       queuepop stdout -var line
+      if ($VERBOSE > 2)
+        echo $line
+      end
       list word -split $line
       $DET_ID   = $word:0
@@ -61,10 +83,14 @@
   # locked list
   task.exit    default
-    echo       "detrend.stack: failure"
+    if ($VERBOSE) 
+      echo       "detrend.stack: failure"
+    end
   end
 
   # operation times out?
   task.exit    timeout
-    echo       "detrend.stack: timeout"
+    if ($VERBOSE) 
+      echo       "detrend.stack: timeout"
+    end
   end
 end
@@ -78,5 +104,4 @@
   task.exec
     queuesize DetrendStackClass -var N
-   
     if ($N == 0) break
     if ($network == 0) break
@@ -103,6 +128,6 @@
 
     # XXX add $WORKDIR/$LOG_DIR
-    stdout $CAMERA.$DET_TYPE.$DET_ID.$ITER.$CLASS_ID.log
-    stderr $CAMERA.$DET_TYPE.$DET_ID.$ITER.$CLASS_ID.log
+    stdout $LOGSUBDIR/$CAMERA.$DET_TYPE.$DET_ID.$ITER.$CLASS_ID.log
+    stderr $LOGSUBDIR/$CAMERA.$DET_TYPE.$DET_ID.$ITER.$CLASS_ID.log
 
     # specify choice of remote host:
@@ -115,6 +140,7 @@
     # create example job options as a demonstration
     options "$line"
-    # detrend_stack.pl --det_id 1 --iteration 0 --class_id isp --det_type bias --camera ISP || exit 1
-    echo command detrend_stack.pl --det_id $DET_ID --iteration $ITER --class_id $CLASS_ID --det_type $DET_TYPE --camera $CAMERA
+    if ($VERBOSE > 1)
+      echo command detrend_stack.pl --det_id $DET_ID --iteration $ITER --class_id $CLASS_ID --det_type $DET_TYPE --camera $CAMERA
+    end
     command detrend_stack.pl --det_id $DET_ID --iteration $ITER --class_id $CLASS_ID --det_type $DET_TYPE --camera $CAMERA
   end
@@ -127,10 +153,18 @@
   # default exit status
   task.exit    default
-    queuepush DetrendStackClass -replace -key 1:2:4 "FAIL $options:0"
+    if ($VERBOSE)
+      echo "failure detrend_stack.pl $options:0"
+    end
+   queuepush DetrendStackClass -replace -key 1:2:4 "FAIL $options:0"
+   $DetrendStackClassFail ++
   end
 
   # operation times out?
   task.exit    timeout
+    if ($VERBOSE)
+      echo "failure detrend_stack.pl $options:0"
+    end
     queuepush DetrendStackClass -replace -key 1:2:4 "TIMEOUT $options:0"
+    $DetrendStackClassFail ++
   end
 end
