Index: trunk/ippTasks/dist.pro
===================================================================
--- trunk/ippTasks/dist.pro	(revision 26045)
+++ trunk/ippTasks/dist.pro	(revision 26050)
@@ -74,13 +74,14 @@
 macro set.dist.workdir.by.component
     # component template default varname
-    if ($0 != 5)
-        echo "USAGE: set.workdir.by.component (componentID) (template) (default) (varname)"
-        break
-    end
-    local host component default template varname length start count component_id random_number
-    $component = $1
-    $template = $2
-    $default = $3
-    $varname = $4
+    if ($0 != 6)
+        echo "USAGE: set.workdir.by.component (stage_id) (componentID) (template) (default) (varname)"
+        break
+    end
+    local host stage_id component default template varname length start count selector component_id random_number
+    $stage_id = $2
+    $component = $2
+    $template = $3
+    $default = $4
+    $varname = $5
     if ("$template" == "NULL")
         echo "ERROR: WORKDIR template not set."
@@ -92,17 +93,16 @@
         break
     end
-    if ("$component" != "exposure") 
-        # take last two letters of component id
-        # treat it as an integer and use modulous of length of distribution hosts
-        # to compute a host
-        strlen $component length
-        $start = $length - 2
-        substr $component $start 2 index
-        $component_id = $index % $count
+    if ("$component" == "exposure") 
+        $selector = $stage_id
     else
-        # randomly chose one of the hosts
-        $random_number = int(100 * rnd(0)) % $count
-        sprintf component_id "%d" $random_number
-    end
+        $selector = $component
+    end
+    # take last two letters of selector
+    # treat it as an integer and use modulous of length of distribution hosts
+    # to compute an index into the host table
+    strlen $selector length
+    $start = $length - 2
+    substr $selector $start 2 index
+    $component_id = $index % $count
 
     book getword ipphosts distribution $component_id -var host
@@ -231,5 +231,5 @@
 #    host anyhost
 
-    set.dist.workdir.by.component $COMPONENT $OUTDIR_TEMPLATE ipp049 OUTDIR 
+    set.dist.workdir.by.component $STAGE_ID $COMPONENT $OUTDIR_TEMPLATE ipp049 OUTDIR 
     if ("$OUTDIR" == "NULL")
         echo ERROR failed to set workdir for $COMPONENT
@@ -355,5 +355,5 @@
     # using $DIST_ID as the "component" works fine here since we only look
     # at the last two digits
-    set.dist.workdir.by.component $DIST_ID $OUTDIR_TEMPLATE ipp049 OUTDIR 
+    set.dist.workdir.by.component $STAGE_ID $DIST_ID $OUTDIR_TEMPLATE ipp049 OUTDIR 
     if ("$OUTDIR" == "NULL")
         echo ERROR failed to set workdir for $DIST_ID
