Index: trunk/ippTasks/pantasks.pro
===================================================================
--- trunk/ippTasks/pantasks.pro	(revision 19465)
+++ trunk/ippTasks/pantasks.pro	(revision 19545)
@@ -350,6 +350,6 @@
   end
 
-  # missing camera and/or chiphosts table results in host = NULL
-  book getword chiphosts $camera $classID -var host
+  # missing camera and/or ipphosts table results in host = NULL
+  book getword ipphosts $camera $classID -var host
 
   if ("$host" == "NULL")
@@ -360,32 +360,40 @@
 end
 
-macro set.volume.by.camera
-  if ($0 != 3)
-    echo "USAGE: set.volume.by.camera (camera) (class_id) (template) (default) (varname)"
-    echo " uses global variable NEBULOUS to determine if nebulous is active"
-    break
-  end
-
-  local host default template camera classID varname
-  $camera = $1
-  $classID = $2
-  $template = $3
-  $default = $4
-  $varname = $5
-
-  # missing camera and/or chiphosts table results in host = NULL
-  book getword chiphosts $camera $classID -var host
-
-  if (not($NEBULOUS))
-    $$varname = "NULL"
-    return
-  end
-
-  if ("$host" == "NULL") 
-    $$varname = $default
-    return
-  end
-
-  strsub $template @HOST@ $host -var $varname
+macro set.workdir.by.skycell
+  if ($0 != 5)
+    echo "USAGE: set.workdir.by.skycell (skycellID) (template) (default) (varname)"
+    break
+  end
+
+  local host default template skycellID varname count
+  $skycellID = $1
+  $template = $2
+  $default = $3
+  $varname = $4
+
+  if ("$template" == "NULL")
+    $varname = $workdir_template
+    echo "WARNING: WORKDIR template not set.  Defaulting to $workdir_template"
+    break
+  end
+
+  # get the folding count for this camera  
+  book getword ipphosts skycell count -var count
+  if ("$count" == "NULL")
+    strsub $template @HOST@ $default -var $varname
+    return
+  end    
+
+  strhash $skycellID $count -var skyhash
+  sprintf skyname "sky%02d" $skyhash
+
+  # missing ipphosts table results in host = NULL
+  book getword ipphosts skycell $skyname -var host
+
+  if ("$host" == "NULL")
+    strsub $template @HOST@ $default -var $varname
+  else
+    strsub $template @HOST@ $host -var $varname
+  end
 end
 
@@ -396,4 +404,6 @@
   end
 
+  local host
+
   if (not($PARALLEL))
     host local
@@ -401,6 +411,6 @@
   end
 
-  # missing camera and/or chiphosts table results in host = NULL
-  book getword chiphosts $1 $2 -var host
+  # missing camera and/or ipphosts table results in host = NULL
+  book getword ipphosts $1 $2 -var host
 
   if ("$host" == "NULL")
@@ -411,4 +421,33 @@
 end
 
+macro set.host.for.skycell
+  if ($0 != 2)
+    echo "USAGE: set.host.for.skycell (skycellID)"
+    break
+  end
+
+  local skycellID varname count host skyname skyhash
+  $skycellID = $1
+
+  # get the folding count for this camera  
+  book getword ipphosts skycell count -var count
+  if ("$count" == "NULL")
+    host anyhost
+    return
+  end    
+
+  strhash $skycellID $count -var skyhash
+  sprintf skyname "sky%02d" $skyhash
+
+  # missing ipphosts table results in host = NULL
+  book getword ipphosts skycell $skyname -var host
+
+  if ("$host" == "NULL")
+    host anyhost
+  else
+    host $host
+  end
+end
+
 macro get.host.for.camera
   if ($0 != 3)
@@ -422,6 +461,6 @@
   end
 
-  # missing camera and/or chiphosts table results in host = NULL
-  book getword chiphosts $1 $2 -var host
+  # missing camera and/or ipphosts table results in host = NULL
+  book getword ipphosts $1 $2 -var host
 
   if ("$host" == "NULL")
