Index: trunk/ippTasks/phase3.pro
===================================================================
--- trunk/ippTasks/phase3.pro	(revision 9506)
+++ trunk/ippTasks/phase3.pro	(revision 10758)
@@ -1,6 +1,6 @@
 ## this file contains the tasks for running the phase 0 stage
 
-## these tasks use the queue Phase3Imfiles
-## the Phase3Imfiles queue contains:
+## these tasks use the queue Phase3Exposures
+## the Phase3Exposures queue contains:
 ## STATE EXP_TAG CLASS CLASS_ID URI-FITS
 ## queue keys are counted from 0
@@ -14,9 +14,26 @@
 end
 
+$Phase3ExposureFail = 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/phase3
+exec mkdir -p $LOGSUBDIR
+
+macro phase3.status
+  queueprint Phase3Exposures
+  echo "Phase3ExposureFail: $Phase3ExposureFail"
+end
+
 # select images ready for phase3 analysis
 # new entries are added to queue Phase3Exposures
 # compare the new list with the ones already selected
 task	       phase3.exp.load
-  command      p3tool -pendingexp -simple
   host         local
 
@@ -25,6 +42,10 @@
   periods      -timeout 30
 
-  stdout phase3.exp.log
-  stderr phase3.exp.log
+  stdout $LOGSUBDIR/phase3.exp.log
+  stderr $LOGSUBDIR/phase3.exp.log
+
+  task.exec
+    command      p3tool -pendingexp -simple
+  end
 
   # success
@@ -37,4 +58,7 @@
     for i 0 $Nqueue
       queuepop stdout -var line
+      if ($VERBOSE > 2)
+        echo $line
+      end
       list word -split $line
       $EXP_TAG   = $word:0
@@ -48,14 +72,14 @@
   # default exit status
   task.exit    default
-    echo       "phase3 pending exp: failure"
+    showcommand failure
   end
 
   # operation times out?
   task.exit    timeout
-    echo       "phase3 pending exp: timeout"
+    showcommand timeout
   end
 end
 
-# run the phase3imfile script on pending images
+# run the phase3exposure script on pending images
 task	       phase3.exp.run
   periods      -poll $runpoll
@@ -68,5 +92,5 @@
     if ($network == 0) break
     
-    # look for new images on the internal DetrendImfilesToProcess queue
+    # look for new images on the internal DetrendExposuresToProcess queue
     # caution with these 'if' statements: syntax errors 
     # will make the task fail without given a good status
@@ -82,7 +106,11 @@
     $EXP_TAG   = $word:0
 
-    # XXX add $WORKDIR/$LOG_DIR
-    stdout $EXP_TAG.log
-    stderr $EXP_TAG.log
+    # XXX this is still a lame rule
+    $word = `basename $EXP_TAG | tr '.' ' '`
+    list word -split $word
+    $base = $word:0
+    stdout $LOGSUBDIR/$base/$EXP_TAG.log
+    stderr $LOGSUBDIR/$base/$EXP_TAG.log
+    exec mkdir -p $LOGSUBDIR/$base
 
     # specify choice of remote host:(need to choose based on chips)
@@ -95,6 +123,8 @@
     # create the command line
     options "$line"
-    echo command phase3.pl --exp_tag $EXP_TAG
-    command phase3.pl --exp_tag $EXP_TAG
+    if ($VERBOSE > 1)
+      echo command phase3.pl --exp_tag $EXP_TAG
+    end
+    command phase3.pl --exp_tag $EXP_TAG --camera CTIO_MOSAIC2
   end
 
@@ -107,10 +137,14 @@
   # default exit status
   task.exit    default
+    showcommand failure
     queuepush Phase3Exposures -replace -key 1 "FAIL $options:0"
+    $Phase3ExposureFail ++
   end
 
   # operation times out?
   task.exit    timeout
+    showcommand timeout
     queuepush Phase3Exposures -replace -key 1 "TIMEOUT $options:0"
+    $Phase3ExposureFail ++
   end
 end
