Index: trunk/ippTasks/detrend.reject.pro
===================================================================
--- trunk/ippTasks/detrend.reject.pro	(revision 10542)
+++ trunk/ippTasks/detrend.reject.pro	(revision 10692)
@@ -13,5 +13,5 @@
 ## STATE DET_ID ITER TYPE
 
-queueinit DetrendRejectExposure
+queueinit DetrendRejectExp
 if ($?network == 0)
   $network = 1
@@ -21,9 +21,26 @@
 end
 
+$DetrendRejectExpFail = 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 detreject.status
+  queueprint DetrendRejectExp
+  echo "DetrendRejectExpFail: $DetrendRejectExpFail"
+end
+
 # select images ready for copy 
-# new entries are added to queue DetrendRejectExposure
+# new entries are added to queue DetrendRejectExp
 # compare the new list with the ones already selected
 task	       dettool.reject.load
-  command      dettool -residdetrun -simple
   host         local
 
@@ -32,6 +49,10 @@
   periods      -timeout 30
 
-  stdout dettool.reject.log
-  stderr dettool.reject.log
+  stdout $LOGSUBDIR/dettool.reject.log
+  stderr $LOGSUBDIR/dettool.reject.log
+
+  task.exec
+    command dettool -residdetrun -simple -limit {$DetrendRejectExpFail + 20}
+  end
 
   # success
@@ -44,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
@@ -50,19 +74,23 @@
       $MODE     = $word:3
       $CAMERA   = $word:4
-      queuepush DetrendRejectExposure -uniq -key 1:2 "NEW $DET_ID $ITER $DET_TYPE $MODE $CAMERA"
+      queuepush DetrendRejectExp -uniq -key 1:2 "NEW $DET_ID $ITER $DET_TYPE $MODE $CAMERA"
     end
 
     # delete existing entries which are DONE
-    queuedrop DetrendRejectExposure -key 0 DONE
+    queuedrop DetrendRejectExp -key 0 DONE
   end
 
   # locked list
   task.exit    default
-    echo       "detrend.reject: failure"
+    if ($VERBOSE) 
+      echo       "detrend.reject: failure"
+    end
   end
 
   # operation times out?
   task.exit    timeout
-    echo       "detrend.reject: timeout"
+    if ($VERBOSE) 
+      echo       "detrend.reject: timeout"
+    end
   end
 end
@@ -75,18 +103,18 @@
 
   task.exec
-    queuesize DetrendRejectExposure -var N
+    queuesize DetrendRejectExp -var N
     if ($N == 0) break
     if ($network == 0) break
     
-    # look for new images on the internal DetrendRejectExposure queue
+    # look for new images on the internal DetrendRejectExp queue
     # caution with these 'if' statements: syntax errors 
     # will make the task fail without given a good status
-    queuepop DetrendRejectExposure -var line -key 0 NEW
+    queuepop DetrendRejectExp -var line -key 0 NEW
     if ("$line" == "NULL") break
 
     strpop line state
-    queuepush DetrendRejectExposure -replace -key 1:2 "RUN $line"
+    queuepush DetrendRejectExp -replace -key 1:2 "RUN $line"
 
-    ## the DetrendRejectExposure queue contains:
+    ## the DetrendRejectExp queue contains:
     ## STATE DET_ID ITER TYPE
     ## NOTE: the queue has the STATE prepended 
@@ -98,6 +126,6 @@
 
     # I'd like to add CAMERA to the log file...
-    stdout $CAMERA.$DET_TYPE.$DET_ID.$ITER.log
-    stderr $CAMERA.$DET_TYPE.$DET_ID.$ITER.log
+    stdout $LOGSUBDIR/$CAMERA.$DET_TYPE.$DET_ID.$ITER.log
+    stderr $LOGSUBDIR/$CAMERA.$DET_TYPE.$DET_ID.$ITER.log
 
     # specify choice of remote host:
@@ -110,5 +138,7 @@
     # create example job options as a demonstration
     options "$line"
-    echo command detrend_reject_exp.pl --det_id $DET_ID --iteration $ITER --det_type $DET_TYPE --camera $CAMERA
+    if ($VERBOSE > 1)
+      echo command detrend_reject_exp.pl --det_id $DET_ID --iteration $ITER --det_type $DET_TYPE --camera $CAMERA
+    end
     command detrend_reject_exp.pl --det_id $DET_ID --iteration $ITER --det_type $DET_TYPE --camera $CAMERA
  end
@@ -116,15 +146,23 @@
   # success
   task.exit 0
-    queuepush DetrendRejectExposure -replace -key 1:2 "DONE $options:0"
+    queuepush DetrendRejectExp -replace -key 1:2 "DONE $options:0"
   end
 
   # default exit status
   task.exit    default
-    queuepush DetrendRejectExposure -replace -key 1:2 "FAIL $options:0"
+    if ($VERBOSE)
+      echo "failure detrend_reject_exp.pl $options:0"
+    end
+    queuepush DetrendRejectExp -replace -key 1:2 "FAIL $options:0"
+    $DetrendRejectExpFail ++
   end
 
   # operation times out?
   task.exit    timeout
-    queuepush DetrendRejectExposure -replace -key 1:2 "TIMEOUT $options:0"
+    if ($VERBOSE)
+      echo "failure detrend_reject_exp.pl $options:0"
+    end
+    queuepush DetrendRejectExp -replace -key 1:2 "TIMEOUT $options:0"
+   $DetrendRejectExpFail ++
   end
 end
