Index: /trunk/Ohana/src/opihi/include/pcontrol.h
===================================================================
--- /trunk/Ohana/src/opihi/include/pcontrol.h	(revision 19123)
+++ /trunk/Ohana/src/opihi/include/pcontrol.h	(revision 19124)
@@ -25,4 +25,10 @@
   PCONTROL_JOB_NEEDHOST,
 } JobMode;
+
+/** job thread options values **/
+typedef enum {
+  PCONTROL_JOB_THREADS_NONE,
+  PCONTROL_JOB_THREADS_MAX,
+} JobThreadMode;
 
 /** host status values **/
@@ -106,4 +112,5 @@
   int         stdout_fd;
   int         stderr_fd;
+  int         max_threads;
   int         markoff;
   int         pid;
@@ -228,5 +235,5 @@
 Host  *PullHostFromStackByID (int StackID, IDtype ID);
 Host  *PullHostFromStackByName (int StackID, char *name);
-IDtype AddHost (char *hostname);
+IDtype AddHost (char *hostname, int max_threads);
 void   DelHost (Host *host);
 
Index: /trunk/Ohana/src/opihi/pcontrol/HostOps.c
===================================================================
--- /trunk/Ohana/src/opihi/pcontrol/HostOps.c	(revision 19123)
+++ /trunk/Ohana/src/opihi/pcontrol/HostOps.c	(revision 19124)
@@ -189,5 +189,5 @@
 }
 
-IDtype AddHost (char *hostname) {
+IDtype AddHost (char *hostname, int max_threads) {
 
   Host *host;
@@ -195,13 +195,14 @@
   ALLOCATE (host, Host, 1);
 
-  host[0].hostname  = strcreate (hostname);
-  host[0].stdin_fd  = 0;
-  host[0].stdout_fd = 0;
-  host[0].stderr_fd = 0;
-  host[0].HostID    = NextHostID();
-
-  host[0].lasttry.tv_sec = 0;
+  host[0].hostname    = strcreate (hostname);
+  host[0].max_threads = max_threads;
+  host[0].stdin_fd    = 0;
+  host[0].stdout_fd   = 0;
+  host[0].stderr_fd   = 0;
+  host[0].HostID      = NextHostID();
+
+  host[0].lasttry.tv_sec  = 0;
   host[0].lasttry.tv_usec = 0;
-  host[0].nexttry.tv_sec = 0;
+  host[0].nexttry.tv_sec  = 0;
   host[0].nexttry.tv_usec = 0;
 
Index: /trunk/Ohana/src/opihi/pcontrol/StartJob.c
===================================================================
--- /trunk/Ohana/src/opihi/pcontrol/StartJob.c	(revision 19123)
+++ /trunk/Ohana/src/opihi/pcontrol/StartJob.c	(revision 19124)
@@ -14,4 +14,5 @@
 
   /* construct command line : job arg0 arg1 ... argN\n */
+  // arguments of the form @MAX_THREADS@ are replaced here
   Nline = 10 + job[0].argc;
   for (i = 0; i < job[0].argc; i++) {
@@ -23,6 +24,14 @@
   for (i = 0; i < job[0].argc; i++) {
     strcat (line, " ");
+    if (!strcmp (job[0].argv[i], "@MAX_THREADS@")) {
+      char threads[10];
+      snprintf (threads, 10, "%5d", host[0].max_threads);
+      strcat (line, threads);
+      continue;
+    } 
     strcat (line, job[0].argv[i]);
   }
+
+  fprintf (stderr, "command: %s\n", line);
 
   status = PclientCommand (host, line, PCLIENT_PROMPT, PCONTROL_RESP_START_JOB);
Index: /trunk/Ohana/src/opihi/pcontrol/host.c
===================================================================
--- /trunk/Ohana/src/opihi/pcontrol/host.c	(revision 19123)
+++ /trunk/Ohana/src/opihi/pcontrol/host.c	(revision 19124)
@@ -3,7 +3,15 @@
 int host (int argc, char **argv) {
 
+  int N, max_threads;
   IDtype HostID;
   Host *host;
   Stack *AllHosts;
+
+  max_threads = 0;
+  if ((N = get_argument (argc, argv, "-threads"))) {
+    remove_argument (N, &argc, argv);
+    max_threads = atoi(argv[N]);
+    remove_argument (N, &argc, argv);
+  }
 
   if (argc != 3) goto usage;
@@ -12,8 +20,10 @@
 
   if (!strcasecmp (argv[1], "ADD")) {
-    HostID = AddHost (argv[2]);
+    HostID = AddHost (argv[2], max_threads);
     gprint (GP_LOG, "HostID: %d\n", (int) HostID);
     return (TRUE);
   }
+
+  if (max_threads) goto usage;
 
   // this one is safe from in-flight entries: no one else pulls from OFF
@@ -87,4 +97,5 @@
   gprint (GP_LOG, "USAGE: host (command) (hostname)\n");
   gprint (GP_ERR, "  valid commands: add, on, retry, check, off, delete\n");
+  gprint (GP_ERR, "  -threads Nthreads is optional for 'add'\n");
   return (FALSE);
 }
Index: /trunk/Ohana/src/opihi/pcontrol/job.c
===================================================================
--- /trunk/Ohana/src/opihi/pcontrol/job.c	(revision 19123)
+++ /trunk/Ohana/src/opihi/pcontrol/job.c	(revision 19124)
@@ -37,4 +37,5 @@
   if (argc < 2) {
     gprint (GP_ERR, "USAGE: job [options] (arg0) (arg1) ... (argN)\n");
+    gprint (GP_ERR, "  arguments of the form @MAX_THREADS@ will be replaced when the job is launched\n");
     FREE (Host);
     return (FALSE);
