Index: /trunk/Ohana/src/opihi/Makefile.Common
===================================================================
--- /trunk/Ohana/src/opihi/Makefile.Common	(revision 11083)
+++ /trunk/Ohana/src/opihi/Makefile.Common	(revision 11084)
@@ -3,5 +3,5 @@
 # .SUFFIXES: .$(ARCH).o
 
-CFLAGS  =       -I$(INC) -I$(DESTINC) $(INCDIRS) -DHELPDIR_DEFAULT=$(HELP)
+CFLAGS  =       -I$(INC) -I$(DESTINC) $(INCDIRS) -DDATADIR_DEFAULT=$(DATA)
 
 $(BIN)/%.$(ARCH):
@@ -37,8 +37,18 @@
 
 %.help:
-	@if [ ! -d $(HELP) ]; then mkdir -p $(HELP); fi
-	rm -f $(HOME)/$*/help/*~
-	rm -f $(HOME)/$*/help/#*
-	for i in `find $(HOME)/$*/help -maxdepth 1 -type f`; do cp -f $$i $(HELP); done
+	@echo "installing help files for $*"
+	@if [ ! -d $(DATA)/help ]; then mkdir -p $(DATA)/help; fi
+	@rm -f $(HOME)/$*/help/*~
+	@rm -f $(HOME)/$*/help/#*
+	@for i in `find $(HOME)/$*/help -maxdepth 1 -type f`; do cp -f $$i $(DATA)/help; done
+
+%.modules:
+	@echo "installing modules for $*"
+	@if [ ! -d $(DATA)/modules ]; then mkdir -p $(DATA)/modules; fi
+	@if [ ! -d $(HOME)/modules/$* ]; then echo "no modules for $*"; fi
+	@if [   -d $(HOME)/modules/$* ]; then rm -f $(HOME)/modules/$*/*~; fi
+	@if [   -d $(HOME)/modules/$* ]; then rm -f $(HOME)/modules/$*/#*; fi
+	@if [   -d $(HOME)/modules/$* ]; then for i in `find $(HOME)/modules/$* -name CVS -prune -o -type f`; do cp -f $$i $(DATA)/modules; done; fi
+
 %.clean:
 	rm -f $(BIN)/$*.$(ARCH)
@@ -60,4 +70,4 @@
 
 clean-help:
-	@if [ ! -d $(HELP) ]; then mkdir -p $(HELP); fi
-	rm -f $(HELP)/*
+	@if [ ! -d $(DATA)/help ]; then mkdir -p $(DATA)/help; fi
+	rm -f $(DATA)/help/*
Index: /trunk/Ohana/src/opihi/cmd.astro/Makefile
===================================================================
--- /trunk/Ohana/src/opihi/cmd.astro/Makefile	(revision 11083)
+++ /trunk/Ohana/src/opihi/cmd.astro/Makefile	(revision 11084)
@@ -5,51 +5,51 @@
 LIB     =       $(HOME)/lib
 INC     =       $(HOME)/include
-SDIR    =       $(HOME)/cmd.astro
+SRC     =       $(HOME)/cmd.astro
 
 # astro user commands ########################
 
 srcs = \
-$(SDIR)/init.$(ARCH).o             \
-$(SDIR)/biassub.$(ARCH).o	   \
-$(SDIR)/cgrid.$(ARCH).o		   \
-$(SDIR)/coords.$(ARCH).o	   \
-$(SDIR)/cplot.$(ARCH).o		   \
-$(SDIR)/csystem.$(ARCH).o	   \
-$(SDIR)/ctimes.$(ARCH).o	   \
-$(SDIR)/cval.$(ARCH).o		   \
-$(SDIR)/czplot.$(ARCH).o	   \
-$(SDIR)/drizzle.$(ARCH).o	   \
-$(SDIR)/flux.$(ARCH).o		   \
-$(SDIR)/fixwrap.$(ARCH).o	   \
-$(SDIR)/gauss.$(ARCH).o		   \
-$(SDIR)/getvel.$(ARCH).o	   \
-$(SDIR)/getlst.$(ARCH).o	   \
-$(SDIR)/medianmap.$(ARCH).o	   \
-$(SDIR)/mkgauss.$(ARCH).o	   \
-$(SDIR)/multifit.$(ARCH).o	   \
-$(SDIR)/objload.$(ARCH).o	   \
-$(SDIR)/outline2.$(ARCH).o	   \
-$(SDIR)/outline.$(ARCH).o	   \
-$(SDIR)/polar.$(ARCH).o		   \
-$(SDIR)/precess.$(ARCH).o	   \
-$(SDIR)/profile.$(ARCH).o	   \
-$(SDIR)/region.$(ARCH).o	   \
-$(SDIR)/rotcurve.$(ARCH).o	   \
-$(SDIR)/scale.$(ARCH).o		   \
-$(SDIR)/sexigesimal.$(ARCH).o	   \
-$(SDIR)/spec.$(ARCH).o		   \
-$(SDIR)/star.$(ARCH).o		   \
-$(SDIR)/transform.$(ARCH).o        \
-$(SDIR)/imsub.$(ARCH).o		   \
-$(SDIR)/imfit.$(ARCH).o		   \
-$(SDIR)/imfit-fgauss.$(ARCH).o	   \
-$(SDIR)/imfit-pgauss.$(ARCH).o	   \
-$(SDIR)/imfit-Pgauss.$(ARCH).o	   \
-$(SDIR)/imfit-qgauss.$(ARCH).o	   \
-$(SDIR)/imfit-Qgauss.$(ARCH).o	   \
-$(SDIR)/imfit-sgauss.$(ARCH).o	   \
-$(SDIR)/imfit-Sgauss.$(ARCH).o	   \
-$(SDIR)/imfit-qfgauss.$(ARCH).o	   \
-$(SDIR)/imfit-qrgauss.$(ARCH).o	   
+$(SRC)/init.$(ARCH).o             \
+$(SRC)/biassub.$(ARCH).o	   \
+$(SRC)/cgrid.$(ARCH).o		   \
+$(SRC)/coords.$(ARCH).o	   \
+$(SRC)/cplot.$(ARCH).o		   \
+$(SRC)/csystem.$(ARCH).o	   \
+$(SRC)/ctimes.$(ARCH).o	   \
+$(SRC)/cval.$(ARCH).o		   \
+$(SRC)/czplot.$(ARCH).o	   \
+$(SRC)/drizzle.$(ARCH).o	   \
+$(SRC)/flux.$(ARCH).o		   \
+$(SRC)/fixwrap.$(ARCH).o	   \
+$(SRC)/gauss.$(ARCH).o		   \
+$(SRC)/getvel.$(ARCH).o	   \
+$(SRC)/getlst.$(ARCH).o	   \
+$(SRC)/medianmap.$(ARCH).o	   \
+$(SRC)/mkgauss.$(ARCH).o	   \
+$(SRC)/multifit.$(ARCH).o	   \
+$(SRC)/objload.$(ARCH).o	   \
+$(SRC)/outline2.$(ARCH).o	   \
+$(SRC)/outline.$(ARCH).o	   \
+$(SRC)/polar.$(ARCH).o		   \
+$(SRC)/precess.$(ARCH).o	   \
+$(SRC)/profile.$(ARCH).o	   \
+$(SRC)/region.$(ARCH).o	   \
+$(SRC)/rotcurve.$(ARCH).o	   \
+$(SRC)/scale.$(ARCH).o		   \
+$(SRC)/sexigesimal.$(ARCH).o	   \
+$(SRC)/spec.$(ARCH).o		   \
+$(SRC)/star.$(ARCH).o		   \
+$(SRC)/transform.$(ARCH).o        \
+$(SRC)/imsub.$(ARCH).o		   \
+$(SRC)/imfit.$(ARCH).o		   \
+$(SRC)/imfit-fgauss.$(ARCH).o	   \
+$(SRC)/imfit-pgauss.$(ARCH).o	   \
+$(SRC)/imfit-Pgauss.$(ARCH).o	   \
+$(SRC)/imfit-qgauss.$(ARCH).o	   \
+$(SRC)/imfit-Qgauss.$(ARCH).o	   \
+$(SRC)/imfit-sgauss.$(ARCH).o	   \
+$(SRC)/imfit-Sgauss.$(ARCH).o	   \
+$(SRC)/imfit-qfgauss.$(ARCH).o	   \
+$(SRC)/imfit-qrgauss.$(ARCH).o	   
 
 # dependancy rules for include files ########################
Index: /trunk/Ohana/src/opihi/cmd.basic/Makefile
===================================================================
--- /trunk/Ohana/src/opihi/cmd.basic/Makefile	(revision 11083)
+++ /trunk/Ohana/src/opihi/cmd.basic/Makefile	(revision 11084)
@@ -2,45 +2,46 @@
 
 HOME    =       $(ROOT)/src/opihi
+SRC     =       $(HOME)/cmd.basic
 BIN     =       $(HOME)/bin
 LIB     =       $(HOME)/lib
 INC     =       $(HOME)/include
-SDIR    =       $(HOME)/cmd.basic
 
 # basic user commands ########################
 
 srcs = \
-$(SDIR)/init.$(ARCH).o       \
-$(SDIR)/break.$(ARCH).o	     \
-$(SDIR)/cd.$(ARCH).o	     \
-$(SDIR)/config.$(ARCH).o     \
-$(SDIR)/continue.$(ARCH).o   \
-$(SDIR)/date.$(ARCH).o	     \
-$(SDIR)/echo.$(ARCH).o	     \
-$(SDIR)/file.$(ARCH).o	     \
-$(SDIR)/getchr.$(ARCH).o     \
-$(SDIR)/help.$(ARCH).o	     \
-$(SDIR)/input.$(ARCH).o	     \
-$(SDIR)/list.$(ARCH).o	     \
-$(SDIR)/list_help.$(ARCH).o  \
-$(SDIR)/list_vars.$(ARCH).o  \
-$(SDIR)/local.$(ARCH).o	     \
-$(SDIR)/macro.$(ARCH).o	     \
-$(SDIR)/memory.$(ARCH).o     \
-$(SDIR)/output.$(ARCH).o     \
-$(SDIR)/quit.$(ARCH).o	     \
-$(SDIR)/run_for.$(ARCH).o    \
-$(SDIR)/run_if.$(ARCH).o     \
-$(SDIR)/run_while.$(ARCH).o  \
-$(SDIR)/scan.$(ARCH).o	     \
-$(SDIR)/shell.$(ARCH).o	     \
-$(SDIR)/sprintf.$(ARCH).o    \
-$(SDIR)/fprintf.$(ARCH).o    \
-$(SDIR)/strlen.$(ARCH).o     \
-$(SDIR)/substr.$(ARCH).o     \
-$(SDIR)/strpop.$(ARCH).o     \
-$(SDIR)/usleep.$(ARCH).o     \
-$(SDIR)/sleep.$(ARCH).o	     \
-$(SDIR)/wait.$(ARCH).o	     \
-$(SDIR)/which.$(ARCH).o
+$(SRC)/init.$(ARCH).o       \
+$(SRC)/break.$(ARCH).o	     \
+$(SRC)/cd.$(ARCH).o	     \
+$(SRC)/config.$(ARCH).o     \
+$(SRC)/continue.$(ARCH).o   \
+$(SRC)/date.$(ARCH).o	     \
+$(SRC)/echo.$(ARCH).o	     \
+$(SRC)/file.$(ARCH).o	     \
+$(SRC)/getchr.$(ARCH).o     \
+$(SRC)/help.$(ARCH).o	     \
+$(SRC)/input.$(ARCH).o	     \
+$(SRC)/list.$(ARCH).o	     \
+$(SRC)/list_help.$(ARCH).o  \
+$(SRC)/list_vars.$(ARCH).o  \
+$(SRC)/local.$(ARCH).o	     \
+$(SRC)/macro.$(ARCH).o	     \
+$(SRC)/memory.$(ARCH).o     \
+$(SRC)/module.$(ARCH).o     \
+$(SRC)/output.$(ARCH).o     \
+$(SRC)/quit.$(ARCH).o	     \
+$(SRC)/run_for.$(ARCH).o    \
+$(SRC)/run_if.$(ARCH).o     \
+$(SRC)/run_while.$(ARCH).o  \
+$(SRC)/scan.$(ARCH).o	     \
+$(SRC)/shell.$(ARCH).o	     \
+$(SRC)/sprintf.$(ARCH).o    \
+$(SRC)/fprintf.$(ARCH).o    \
+$(SRC)/strlen.$(ARCH).o     \
+$(SRC)/substr.$(ARCH).o     \
+$(SRC)/strpop.$(ARCH).o     \
+$(SRC)/usleep.$(ARCH).o     \
+$(SRC)/sleep.$(ARCH).o	     \
+$(SRC)/wait.$(ARCH).o	     \
+$(SRC)/which.$(ARCH).o
 
 # dependancy rules for include files ########################
Index: /trunk/Ohana/src/opihi/cmd.basic/help.c
===================================================================
--- /trunk/Ohana/src/opihi/cmd.basic/help.c	(revision 11083)
+++ /trunk/Ohana/src/opihi/cmd.basic/help.c	(revision 11084)
@@ -3,6 +3,7 @@
 int help (int argc, char **argv) {
 
+  int Nbytes;
   FILE *f;
-  char *helpdir, file[1024], buff[512];
+  char *helpdir, *file, buff[512];
 
   helpdir = get_variable ("HELPDIR");
@@ -18,7 +19,11 @@
   }
 
-  sprintf (file, "%s/%s", helpdir, argv[1]);
+  Nbytes = strlen(helpdir) + strlen(argv[1]) + 2;
+  ALLOCATE (file, char, Nbytes);
+  snprintf (file, Nbytes, "%s/%s", helpdir, argv[1]);
 
   f = fopen (file, "r");
+  free (file);
+
   if (f == NULL) {
     gprint (GP_ERR, "No help for: %s\n", argv[1]);
Index: /trunk/Ohana/src/opihi/cmd.basic/init.c
===================================================================
--- /trunk/Ohana/src/opihi/cmd.basic/init.c	(revision 11083)
+++ /trunk/Ohana/src/opihi/cmd.basic/init.c	(revision 11084)
@@ -20,4 +20,5 @@
 int macro      	    PROTO((int, char **));
 int memory          PROTO((int, char **));
+int module    	    PROTO((int, char **));
 int output     	    PROTO((int, char **));
 int pwd        	    PROTO((int, char **));
@@ -59,4 +60,5 @@
   {"macro",   	    macro,              "deal with the macros *"}, 
   {"memory",        memory,             "long listing of the allocated memory"},
+  {"module",        module,             "load script file from the modules directories"},
   {"output",  	    output,             "redirect output to file"},
   {"pwd",     	    pwd,                "print current working directory"},
Index: /trunk/Ohana/src/opihi/cmd.basic/module.c
===================================================================
--- /trunk/Ohana/src/opihi/cmd.basic/module.c	(revision 11084)
+++ /trunk/Ohana/src/opihi/cmd.basic/module.c	(revision 11084)
@@ -0,0 +1,77 @@
+# include "basic.h"
+# define D_NLINES 100
+
+/* module loads an opihi script files from the installed module tree */
+int module (int argc, char **argv) {
+  
+  int i, NLINES, Nmodules, Nbytes, status;
+  FILE *infile;
+  Macro inlist;
+  char modname[16], *modpath, *filename;
+
+  if (argc != 2) {
+    gprint (GP_ERR, "USAGE: module <filename>\n");
+    return (FALSE);
+  }
+
+  Nmodules = get_int_variable ("MODULES:n", &status);
+  if (!status) {
+    gprint (GP_ERR, "MODULES list not found\n");
+    return (FALSE);
+  }
+
+  /* search for requested file in MODULES:0 - MODULES:n */
+  for (i = 0; i < Nmodules; i++) {
+    snprintf (modname, 16, "MODULES:%d", i);
+    modpath = get_variable (modname);
+    if (modpath == NULL) {
+      gprint (GP_ERR, "MODULES list element %d not found\n", i);
+      return (FALSE);
+    }
+
+    Nbytes = strlen(modpath) + strlen(argv[1]) + 2;
+    ALLOCATE (filename, char, Nbytes);
+    snprintf (filename, Nbytes, "%s/%s", modpath, argv[1]);
+    
+    infile = fopen (filename, "r");
+    free (filename);
+
+    if (infile != NULL) break;
+  }
+  if (infile == NULL) {
+    gprint (GP_ERR, "module %s not found\n", argv[1]); 
+    return (FALSE);
+  }
+    
+  /* read file into the current list */
+  NLINES = D_NLINES;
+  ALLOCATE (inlist.line, char *, NLINES);
+  ALLOCATE (inlist.line[0], char, 1024);
+  for (i = 0; (scan_line (infile, inlist.line[i]) != EOF);) {
+    stripwhite (inlist.line[i]);
+    if (inlist.line[i][0] == 0) continue;
+    if (inlist.line[i][0] == '#') continue;
+    if (inlist.line[i][0] == '!') continue;
+
+    REALLOCATE (inlist.line[i], char, strlen(inlist.line[i]) + 1);
+    if (i == NLINES - 1) {
+      NLINES += D_NLINES;
+      REALLOCATE (inlist.line, char *, NLINES)
+    }
+    i++;
+    ALLOCATE (inlist.line[i], char, 1024);
+  }
+  inlist.Nlines = i;
+  fclose (infile);
+
+  /* process this list */
+  status = exec_loop (&inlist);
+
+  /* cleanup list */
+  for (i = 0; i < inlist.Nlines; i++) {
+    free (inlist.line[i]);
+  }
+  free (inlist.line[i]); /* note that we always alloc one extra line */
+  free (inlist.line);
+  return (status);
+}
Index: /trunk/Ohana/src/opihi/cmd.basic/run_for.c
===================================================================
--- /trunk/Ohana/src/opihi/cmd.basic/run_for.c	(revision 11083)
+++ /trunk/Ohana/src/opihi/cmd.basic/run_for.c	(revision 11084)
@@ -5,5 +5,5 @@
 int run_for (int argc, char **argv) {
 
-  int ThisList, depth, i, done, status, NLINES, j;
+  int ThisList, depth, i, done, status, found, NLINES, j;
   double start, end, delta;
   char *input;
@@ -86,5 +86,5 @@
       set_variable (argv[1], value);
     status = exec_loop (&loop);
-    value = get_double_variable (argv[1]);
+    value = get_double_variable (argv[1], &found);
     if (loop_next) continue;
     if (loop_last) break;
Index: /trunk/Ohana/src/opihi/cmd.data/Makefile
===================================================================
--- /trunk/Ohana/src/opihi/cmd.data/Makefile	(revision 11083)
+++ /trunk/Ohana/src/opihi/cmd.data/Makefile	(revision 11084)
@@ -2,123 +2,124 @@
 
 HOME    =       $(ROOT)/src/opihi
+SRC     =       $(HOME)/cmd.data
 BIN     =       $(HOME)/bin
 LIB     =       $(HOME)/lib
 INC     =       $(HOME)/include
-SDIR    =       $(HOME)/cmd.data
+DATA    =       $(DESTDATA)/mana
 
 # data user commands ########################
 srcs = \
-$(SDIR)/init.$(ARCH).o          \
-$(SDIR)/accum.$(ARCH).o		\
-$(SDIR)/applyfit2d.$(ARCH).o	\
-$(SDIR)/applyfit.$(ARCH).o	\
-$(SDIR)/box.$(ARCH).o		\
-$(SDIR)/book.$(ARCH).o		\
-$(SDIR)/book_commands.$(ARCH).o	\
-$(SDIR)/center.$(ARCH).o	\
-$(SDIR)/clear.$(ARCH).o		\
-$(SDIR)/clip.$(ARCH).o		\
-$(SDIR)/close.$(ARCH).o		\
-$(SDIR)/concat.$(ARCH).o	\
-$(SDIR)/contour.$(ARCH).o	\
-$(SDIR)/create.$(ARCH).o	\
-$(SDIR)/cumulative.$(ARCH).o	\
-$(SDIR)/cursor.$(ARCH).o	\
-$(SDIR)/cut.$(ARCH).o		\
-$(SDIR)/delete.$(ARCH).o	\
-$(SDIR)/device.$(ARCH).o	\
-$(SDIR)/dimendown.$(ARCH).o	\
-$(SDIR)/dimenup.$(ARCH).o	\
-$(SDIR)/erase.$(ARCH).o		\
-$(SDIR)/extract.$(ARCH).o	\
-$(SDIR)/fft1d.$(ARCH).o		\
-$(SDIR)/fft2d.$(ARCH).o		\
-$(SDIR)/fit2d.$(ARCH).o		\
-$(SDIR)/fit.$(ARCH).o		\
-$(SDIR)/gaussj.$(ARCH).o	\
-$(SDIR)/gaussdeviate.$(ARCH).o	\
-$(SDIR)/grid.$(ARCH).o		\
-$(SDIR)/gridify.$(ARCH).o       \
-$(SDIR)/ungridify.$(ARCH).o     \
-$(SDIR)/histogram.$(ARCH).o	\
-$(SDIR)/imcut.$(ARCH).o	 	\
-$(SDIR)/imhist.$(ARCH).o	\
-$(SDIR)/imsmooth.$(ARCH).o	\
-$(SDIR)/integrate.$(ARCH).o	\
-$(SDIR)/interpolate.$(ARCH).o	\
-$(SDIR)/jpeg.$(ARCH).o		\
-$(SDIR)/kern.$(ARCH).o		\
-$(SDIR)/keyword.$(ARCH).o	\
-$(SDIR)/labels.$(ARCH).o	\
-$(SDIR)/limits.$(ARCH).o	\
-$(SDIR)/line.$(ARCH).o		\
-$(SDIR)/list_buffers.$(ARCH).o	\
-$(SDIR)/list_header.$(ARCH).o	\
-$(SDIR)/list_vectors.$(ARCH).o	\
-$(SDIR)/load.$(ARCH).o		\
-$(SDIR)/lookup.$(ARCH).o	\
-$(SDIR)/mkrgb.$(ARCH).o	\
-$(SDIR)/mcreate.$(ARCH).o	\
-$(SDIR)/medacc.$(ARCH).o	\
-$(SDIR)/mget.$(ARCH).o		\
-$(SDIR)/minterpolate.$(ARCH).o	\
-$(SDIR)/mset.$(ARCH).o		\
-$(SDIR)/peak.$(ARCH).o		\
-$(SDIR)/periodogram.$(ARCH).o	\
-$(SDIR)/plot.$(ARCH).o		\
-$(SDIR)/dot.$(ARCH).o		\
-$(SDIR)/point.$(ARCH).o		\
-$(SDIR)/ps.$(ARCH).o		\
-$(SDIR)/queuedelete.$(ARCH).o	\
-$(SDIR)/queuedrop.$(ARCH).o	\
-$(SDIR)/queuelist.$(ARCH).o	\
-$(SDIR)/queueload.$(ARCH).o	\
-$(SDIR)/queuesize.$(ARCH).o	\
-$(SDIR)/queuepush.$(ARCH).o	\
-$(SDIR)/queuepop.$(ARCH).o	\
-$(SDIR)/queueprint.$(ARCH).o	\
-$(SDIR)/queueinit.$(ARCH).o	\
-$(SDIR)/radial.$(ARCH).o	\
-$(SDIR)/rd.$(ARCH).o		\
-$(SDIR)/rdseg.$(ARCH).o		\
-$(SDIR)/read_vectors.$(ARCH).o	\
-$(SDIR)/rebin.$(ARCH).o		\
-$(SDIR)/resize.$(ARCH).o	\
-$(SDIR)/roll.$(ARCH).o		\
-$(SDIR)/rotate.$(ARCH).o	\
-$(SDIR)/save.$(ARCH).o		\
-$(SDIR)/section.$(ARCH).o	\
-$(SDIR)/select.$(ARCH).o	\
-$(SDIR)/set.$(ARCH).o		\
-$(SDIR)/shift.$(ARCH).o		\
-$(SDIR)/sort.$(ARCH).o		\
-$(SDIR)/spline_apply.$(ARCH).o	\
-$(SDIR)/spline_construct.$(ARCH).o \
-$(SDIR)/stats.$(ARCH).o		   \
-$(SDIR)/style.$(ARCH).o		   \
-$(SDIR)/subraster.$(ARCH).o	   \
-$(SDIR)/subset.$(ARCH).o	   \
-$(SDIR)/svd.$(ARCH).o		   \
-$(SDIR)/swapbytes.$(ARCH).o	   \
-$(SDIR)/textline.$(ARCH).o	   \
-$(SDIR)/tv.$(ARCH).o		   \
-$(SDIR)/tvcontour.$(ARCH).o	   \
-$(SDIR)/tvgrid.$(ARCH).o	   \
-$(SDIR)/uniq.$(ARCH).o		   \
-$(SDIR)/unsign.$(ARCH).o	   \
-$(SDIR)/vbin.$(ARCH).o		   \
-$(SDIR)/vclip.$(ARCH).o		   \
-$(SDIR)/vgauss.$(ARCH).o           \
-$(SDIR)/vmaxwell.$(ARCH).o           \
-$(SDIR)/vgrid.$(ARCH).o		   \
-$(SDIR)/vload.$(ARCH).o		   \
-$(SDIR)/vpop.$(ARCH).o		   \
-$(SDIR)/vroll.$(ARCH).o		   \
-$(SDIR)/vsmooth.$(ARCH).o	\
-$(SDIR)/vstat.$(ARCH).o		   \
-$(SDIR)/wd.$(ARCH).o		   \
-$(SDIR)/write_vectors.$(ARCH).o	   \
-$(SDIR)/zap.$(ARCH).o		   \
-$(SDIR)/zplot.$(ARCH).o
+$(SRC)/init.$(ARCH).o          \
+$(SRC)/accum.$(ARCH).o		\
+$(SRC)/applyfit2d.$(ARCH).o	\
+$(SRC)/applyfit.$(ARCH).o	\
+$(SRC)/box.$(ARCH).o		\
+$(SRC)/book.$(ARCH).o		\
+$(SRC)/book_commands.$(ARCH).o	\
+$(SRC)/center.$(ARCH).o	\
+$(SRC)/clear.$(ARCH).o		\
+$(SRC)/clip.$(ARCH).o		\
+$(SRC)/close.$(ARCH).o		\
+$(SRC)/concat.$(ARCH).o	\
+$(SRC)/contour.$(ARCH).o	\
+$(SRC)/create.$(ARCH).o	\
+$(SRC)/cumulative.$(ARCH).o	\
+$(SRC)/cursor.$(ARCH).o	\
+$(SRC)/cut.$(ARCH).o		\
+$(SRC)/delete.$(ARCH).o	\
+$(SRC)/device.$(ARCH).o	\
+$(SRC)/dimendown.$(ARCH).o	\
+$(SRC)/dimenup.$(ARCH).o	\
+$(SRC)/erase.$(ARCH).o		\
+$(SRC)/extract.$(ARCH).o	\
+$(SRC)/fft1d.$(ARCH).o		\
+$(SRC)/fft2d.$(ARCH).o		\
+$(SRC)/fit2d.$(ARCH).o		\
+$(SRC)/fit.$(ARCH).o		\
+$(SRC)/gaussj.$(ARCH).o	\
+$(SRC)/gaussdeviate.$(ARCH).o	\
+$(SRC)/grid.$(ARCH).o		\
+$(SRC)/gridify.$(ARCH).o       \
+$(SRC)/ungridify.$(ARCH).o     \
+$(SRC)/histogram.$(ARCH).o	\
+$(SRC)/imcut.$(ARCH).o	 	\
+$(SRC)/imhist.$(ARCH).o	\
+$(SRC)/imsmooth.$(ARCH).o	\
+$(SRC)/integrate.$(ARCH).o	\
+$(SRC)/interpolate.$(ARCH).o	\
+$(SRC)/jpeg.$(ARCH).o		\
+$(SRC)/kern.$(ARCH).o		\
+$(SRC)/keyword.$(ARCH).o	\
+$(SRC)/labels.$(ARCH).o	\
+$(SRC)/limits.$(ARCH).o	\
+$(SRC)/line.$(ARCH).o		\
+$(SRC)/list_buffers.$(ARCH).o	\
+$(SRC)/list_header.$(ARCH).o	\
+$(SRC)/list_vectors.$(ARCH).o	\
+$(SRC)/load.$(ARCH).o		\
+$(SRC)/lookup.$(ARCH).o	\
+$(SRC)/mkrgb.$(ARCH).o	\
+$(SRC)/mcreate.$(ARCH).o	\
+$(SRC)/medacc.$(ARCH).o	\
+$(SRC)/mget.$(ARCH).o		\
+$(SRC)/minterpolate.$(ARCH).o	\
+$(SRC)/mset.$(ARCH).o		\
+$(SRC)/peak.$(ARCH).o		\
+$(SRC)/periodogram.$(ARCH).o	\
+$(SRC)/plot.$(ARCH).o		\
+$(SRC)/dot.$(ARCH).o		\
+$(SRC)/point.$(ARCH).o		\
+$(SRC)/ps.$(ARCH).o		\
+$(SRC)/queuedelete.$(ARCH).o	\
+$(SRC)/queuedrop.$(ARCH).o	\
+$(SRC)/queuelist.$(ARCH).o	\
+$(SRC)/queueload.$(ARCH).o	\
+$(SRC)/queuesize.$(ARCH).o	\
+$(SRC)/queuepush.$(ARCH).o	\
+$(SRC)/queuepop.$(ARCH).o	\
+$(SRC)/queueprint.$(ARCH).o	\
+$(SRC)/queueinit.$(ARCH).o	\
+$(SRC)/radial.$(ARCH).o	\
+$(SRC)/rd.$(ARCH).o		\
+$(SRC)/rdseg.$(ARCH).o		\
+$(SRC)/read_vectors.$(ARCH).o	\
+$(SRC)/rebin.$(ARCH).o		\
+$(SRC)/resize.$(ARCH).o	\
+$(SRC)/roll.$(ARCH).o		\
+$(SRC)/rotate.$(ARCH).o	\
+$(SRC)/save.$(ARCH).o		\
+$(SRC)/section.$(ARCH).o	\
+$(SRC)/select.$(ARCH).o	\
+$(SRC)/set.$(ARCH).o		\
+$(SRC)/shift.$(ARCH).o		\
+$(SRC)/sort.$(ARCH).o		\
+$(SRC)/spline_apply.$(ARCH).o	\
+$(SRC)/spline_construct.$(ARCH).o \
+$(SRC)/stats.$(ARCH).o		   \
+$(SRC)/style.$(ARCH).o		   \
+$(SRC)/subraster.$(ARCH).o	   \
+$(SRC)/subset.$(ARCH).o	   \
+$(SRC)/svd.$(ARCH).o		   \
+$(SRC)/swapbytes.$(ARCH).o	   \
+$(SRC)/textline.$(ARCH).o	   \
+$(SRC)/tv.$(ARCH).o		   \
+$(SRC)/tvcontour.$(ARCH).o	   \
+$(SRC)/tvgrid.$(ARCH).o	   \
+$(SRC)/uniq.$(ARCH).o		   \
+$(SRC)/unsign.$(ARCH).o	   \
+$(SRC)/vbin.$(ARCH).o		   \
+$(SRC)/vclip.$(ARCH).o		   \
+$(SRC)/vgauss.$(ARCH).o           \
+$(SRC)/vmaxwell.$(ARCH).o           \
+$(SRC)/vgrid.$(ARCH).o		   \
+$(SRC)/vload.$(ARCH).o		   \
+$(SRC)/vpop.$(ARCH).o		   \
+$(SRC)/vroll.$(ARCH).o		   \
+$(SRC)/vsmooth.$(ARCH).o	\
+$(SRC)/vstat.$(ARCH).o		   \
+$(SRC)/wd.$(ARCH).o		   \
+$(SRC)/write_vectors.$(ARCH).o	   \
+$(SRC)/zap.$(ARCH).o		   \
+$(SRC)/zplot.$(ARCH).o
 
 # dependancy rules for include files ########################
Index: /trunk/Ohana/src/opihi/dimm/Makefile
===================================================================
--- /trunk/Ohana/src/opihi/dimm/Makefile	(revision 11083)
+++ /trunk/Ohana/src/opihi/dimm/Makefile	(revision 11084)
@@ -7,5 +7,5 @@
 INC     =       $(HOME)/include
 SRC     =       $(HOME)/dimm
-HELP    =       $(DESTHELP)/dimm
+DATA    =       $(DESTDATA)/dimm
 
 # link flags 
@@ -42,7 +42,9 @@
 $(BIN)/dimm.$(ARCH)   : $(funcs) $(cmds)
 
-install: $(DESTBIN)/dimm help
+install: $(DESTBIN)/dimm help modules
 
 help: cmd.basic.help cmd.data.help cmd.astro.help dimm.help
+
+modules: dimm.modules
 
 # SBIG install functions
Index: /trunk/Ohana/src/opihi/dimm/dimm.c
===================================================================
--- /trunk/Ohana/src/opihi/dimm/dimm.c	(revision 11083)
+++ /trunk/Ohana/src/opihi/dimm/dimm.c	(revision 11084)
@@ -25,6 +25,21 @@
   set_str_variable ("RCFILE", opihi_rcfile);
 
-# ifdef HELPDIR_DEFAULT
-  set_str_variable ("HELPDIR", MACRO_NAME(HELPDIR_DEFAULT));
+# ifdef DATADIR_DEFAULT
+  { 
+    char *datadir;
+    char *helpdir;
+    char *modules;
+    datadir = MACRO_NAME(DATADIR_DEFAULT);
+    /* set_str_variable ("DATADIR", datadir); */
+    ALLOCATE (helpdir, char, strlen(datadir) + strlen("/help") + 2);
+    sprintf (helpdir, "%s/help", datadir);
+    set_str_variable ("HELPDIR", helpdir);
+    free (helpdir);
+    ALLOCATE (modules, char, strlen(datadir) + strlen("/modules") + 2);
+    sprintf (modules, "%s/modules", datadir);
+    set_str_variable ("MODULES:0", modules);
+    set_int_variable ("MODULES:n", 1);
+    free (helpdir);
+  }
 # endif
 
Index: /trunk/Ohana/src/opihi/dvo/Makefile
===================================================================
--- /trunk/Ohana/src/opihi/dvo/Makefile	(revision 11083)
+++ /trunk/Ohana/src/opihi/dvo/Makefile	(revision 11084)
@@ -6,6 +6,6 @@
 LIB     =       $(HOME)/lib
 INC     =       $(HOME)/include
-SRC    =       $(HOME)/dvo
-HELP    =       $(DESTHELP)/dvo
+SRC     =       $(HOME)/dvo
+DATA    =       $(DESTDATA)/dvo
 
 # link flags 
@@ -88,9 +88,11 @@
 $(BIN)/dvo.$(ARCH)   : $(funcs) $(cmds)
 
-install: $(DESTBIN)/dvo help
+install: $(DESTBIN)/dvo help modules
 
 help: clean-help cmd.basic.help cmd.data.help cmd.astro.help dvo.help
 
 $(funcs) $(cmds) $(libs) : $(INC)/dvoshell.h
+
+modules: dvo.modules
 
 .PHONY: dvo
Index: /trunk/Ohana/src/opihi/dvo/dvo.c
===================================================================
--- /trunk/Ohana/src/opihi/dvo/dvo.c	(revision 11083)
+++ /trunk/Ohana/src/opihi/dvo/dvo.c	(revision 11084)
@@ -29,6 +29,21 @@
   set_str_variable ("RCFILE", opihi_rcfile);
 
-# ifdef HELPDIR_DEFAULT
-  set_str_variable ("HELPDIR", MACRO_NAME(HELPDIR_DEFAULT));
+# ifdef DATADIR_DEFAULT
+  {
+    char *datadir;
+    char *helpdir;
+    char *modules;
+    datadir = MACRO_NAME(DATADIR_DEFAULT);
+    /* set_str_variable ("DATADIR", datadir); */
+    ALLOCATE (helpdir, char, strlen(datadir) + strlen("/help") + 2);
+    sprintf (helpdir, "%s/help", datadir);
+    set_str_variable ("HELPDIR", helpdir);
+    free (helpdir);
+    ALLOCATE (modules, char, strlen(datadir) + strlen("/modules") + 2);
+    sprintf (modules, "%s/modules", datadir);
+    set_str_variable ("MODULES:0", modules);
+    set_int_variable ("MODULES:n", 1);
+    free (helpdir);
+  }
 # endif
 
Index: /trunk/Ohana/src/opihi/include/dvomath.h
===================================================================
--- /trunk/Ohana/src/opihi/include/dvomath.h	(revision 11083)
+++ /trunk/Ohana/src/opihi/include/dvomath.h	(revision 11084)
@@ -67,5 +67,6 @@
 char         *get_variable_ptr      PROTO((char *name));
 char         *get_local_variable_ptr PROTO((char *name));
-double        get_double_variable   PROTO((char *name));
+double        get_double_variable   PROTO((char *name, int *found));
+int           get_int_variable      PROTO((char *name, int *found));
 int           DeleteNamedScalar     PROTO((char *name));
 int           IsScalar              PROTO((char *name));
Index: /trunk/Ohana/src/opihi/include/pantasks.h
===================================================================
--- /trunk/Ohana/src/opihi/include/pantasks.h	(revision 11083)
+++ /trunk/Ohana/src/opihi/include/pantasks.h	(revision 11084)
@@ -178,5 +178,5 @@
 int RemoveTask (Task *task);
 Task *SetNewTask (Task *task);
-void ListTaskStats ();
+void ListTaskStats (char *regex);
 void UpdateTaskTimerStats (Task *task, int mode, double dtime);
 
Index: /trunk/Ohana/src/opihi/lib.shell/variable.c
===================================================================
--- /trunk/Ohana/src/opihi/lib.shell/variable.c	(revision 11083)
+++ /trunk/Ohana/src/opihi/lib.shell/variable.c	(revision 11084)
@@ -244,17 +244,18 @@
 }
 
-double get_double_variable (char *name) {
-  
-  int i;
-  char *local, *MacroName;
-
-  MacroName = GetMacroName ();
-
-  /* look for local variable first */
-  ALLOCATE (local, char, strlen(name) + strlen(MacroName) + 2);
-  sprintf (local, "%s.%s", MacroName, name);
-  for (i = 0; i < Nvariables; i++) { /* find the variable mentioned */
-    if (!strcmp(local, variables[i].name)) {
-      free (local);
+double get_double_variable (char *name, int *found) {
+  
+  int i;
+  char *local, *MacroName;
+
+  MacroName = GetMacroName ();
+
+  /* look for local variable first */
+  ALLOCATE (local, char, strlen(name) + strlen(MacroName) + 2);
+  sprintf (local, "%s.%s", MacroName, name);
+  for (i = 0; i < Nvariables; i++) { /* find the variable mentioned */
+    if (!strcmp(local, variables[i].name)) {
+      free (local);
+      *found = TRUE;
       return (atof (variables[i].value));
     }
@@ -265,7 +266,39 @@
   for (i = 0; i < Nvariables; i++) { /* find the variable mentioned */
     if (!strcmp(name, variables[i].name)) {
+      *found = TRUE;
       return (atof (variables[i].value));
     }
   }
+  *found = FALSE;
+  return (0.0);
+}
+
+int get_int_variable (char *name, int *found) {
+  
+  int i;
+  char *local, *MacroName;
+
+  MacroName = GetMacroName ();
+
+  /* look for local variable first */
+  ALLOCATE (local, char, strlen(name) + strlen(MacroName) + 2);
+  sprintf (local, "%s.%s", MacroName, name);
+  for (i = 0; i < Nvariables; i++) { /* find the variable mentioned */
+    if (!strcmp(local, variables[i].name)) {
+      *found = TRUE;
+      free (local);
+      return (atof (variables[i].value));
+    }
+  }
+  free (local);
+
+  /* look for global variable */
+  for (i = 0; i < Nvariables; i++) { /* find the variable mentioned */
+    if (!strcmp(name, variables[i].name)) {
+      *found = TRUE;
+      return (atof (variables[i].value));
+    }
+  }
+  *found = FALSE;
   return (0.0);
 }
Index: /trunk/Ohana/src/opihi/mana/Makefile
===================================================================
--- /trunk/Ohana/src/opihi/mana/Makefile	(revision 11083)
+++ /trunk/Ohana/src/opihi/mana/Makefile	(revision 11084)
@@ -7,5 +7,5 @@
 LIB     =       $(HOME)/lib
 INC     =       $(HOME)/include
-HELP    =       $(DESTHELP)/mana
+DATA    =       $(DESTDATA)/mana
 
 # link flags 
@@ -39,8 +39,9 @@
 $(BIN)/mana.$(ARCH)   : $(cmds) $(funcs)
 
-install: $(DESTBIN)/mana help
+install: $(DESTBIN)/mana help modules
 
 help: clean-help cmd.basic.help cmd.data.help cmd.astro.help
-# mana.help
+
+modules: mana.modules
 
 .PHONY: mana
Index: /trunk/Ohana/src/opihi/mana/mana.c
===================================================================
--- /trunk/Ohana/src/opihi/mana/mana.c	(revision 11083)
+++ /trunk/Ohana/src/opihi/mana/mana.c	(revision 11084)
@@ -25,6 +25,21 @@
   set_str_variable ("RCFILE", opihi_rcfile);
 
-# ifdef HELPDIR_DEFAULT
-  set_str_variable ("HELPDIR", MACRO_NAME(HELPDIR_DEFAULT));
+# ifdef DATADIR_DEFAULT
+  {
+    char *datadir;
+    char *helpdir;
+    char *modules;
+    datadir = MACRO_NAME(DATADIR_DEFAULT);
+    /* set_str_variable ("DATADIR", datadir); */
+    ALLOCATE (helpdir, char, strlen(datadir) + strlen("/help") + 2);
+    sprintf (helpdir, "%s/help", datadir);
+    set_str_variable ("HELPDIR", helpdir);
+    free (helpdir);
+    ALLOCATE (modules, char, strlen(datadir) + strlen("/modules") + 2);
+    sprintf (modules, "%s/modules", datadir);
+    set_str_variable ("MODULES:0", modules);
+    set_int_variable ("MODULES:n", 1);
+    free (helpdir);
+  }
 # endif
 
Index: /trunk/Ohana/src/opihi/modules/dvo/navigate
===================================================================
--- /trunk/Ohana/src/opihi/modules/dvo/navigate	(revision 11084)
+++ /trunk/Ohana/src/opihi/modules/dvo/navigate	(revision 11084)
@@ -0,0 +1,623 @@
+# -*- perl -*-
+
+macro navigate
+  style -n 0
+  limits
+  $DRAWSTARS  = -1
+  $DRAWIMAGES =  1
+  $DRAWGRID   = -1
+  $ZOOM = 180 / ($YMAX - $YMIN)
+  #this should be changed to a while loop, except 'while' is broken for some reason
+  $KEY = "none"
+  while ("$KEY" != "q")
+    cursor -g 1
+
+    # help list
+    if ("$KEY" == "h")
+     echo "Arrow Keys - pan in that direction"
+     echo "PgUp,PgDn - zoom in/out a factor of 1.2"
+     echo "Home,End  - zoom in/out a factor of 2"
+     echo "1 - zoom in factor of 2 at the cursor"
+     echo "2 - zoom in factor of 1.2 at the cursor"
+     echo "3 - recenter at cursor"
+     echo "4 - zoom out factor of 1.2 at the cursor"
+     echo "5 - zoom out factor of 2 at the cursor"
+     echo "6 - zoom out factor of 10 at the cursor"
+     echo "z - zoom to radius (requires 2nd keystroke)"
+     echo "f - show full sky"
+     echo ""
+     echo "q - quit"
+     echo "S - toggle auto-plotting of stars"
+     echo "A - toggle auto-plotting of image borders"
+     echo "g - toggle skygrid on/off"
+     echo "c - plot status catalog boundaries"
+     echo "C - list catalog at cursor location"
+     echo "i - list info about images touching cursor location" 
+     echo "I - list info about images, with pixel coords of cursor position"
+     echo "j - adjust mag scale, +0.5"
+     echo "k - adjust mag scale, -0.5"
+     echo "J - adjust dmag scale, /1.25"
+     echo "K - adjust dmag scale, *1.25"
+     echo "r - plot detected asteroids (rocks)"
+     echo "l - plot HST GSC"
+     echo "L - plot Landolt stars"
+     echo "m - list measurements for stars within 1 pixel of cursor"
+     echo "M - list measurements for stars within 1.8 arcsec of cursor"
+     echo "p - ****(don't know what this does)"
+     echo "s - ****(don't know what this does)"
+     echo "t - plot light curve for star within 2 arcsec of cursor position"
+     echo "T - plot 'galaxy' light curve for star within 2 arcsec of cursor position"
+     echo "u - ****(don't know what this does)"
+     echo "x - plot stars scaled by magnitude Chisq"
+     echo "X - plot stars by magnitude scatter"
+     echo "y - ****(don't know what this does)"
+     echo ""
+     echo "@ - execute macro `user_macro`"
+     echo ": - ****input a line and execute (not yet implemented)"
+    end
+
+    # quit from navigate
+    if ("$KEY" == "q") continue
+
+    #pan controls
+    if (("$KEY" == "Left") || ("$KEY" == "Right") || ("$KEY" == "Up") || ("$KEY" == "Down"))
+      $SHIFT = 0.2
+      $R$KEY  = $RMAX-$XMAX  
+      $D$KEY  = $DMAX-$YMAX
+      #assumes standard sky orientation!! (N up, E left)
+      if ("$KEY"=="Left")
+        $R$KEY = $R$KEY + $SHIFT*$XMAX
+      end
+      if ("$KEY"=="Right")
+        $R$KEY = $R$KEY + $SHIFT*$XMIN
+      end
+      if ("$KEY"=="Up")
+        $D$KEY = $D$KEY + $SHIFT*$YMAX
+      end
+      if ("$KEY"=="Down")
+        $D$KEY = $D$KEY + $SHIFT*$YMIN
+      end
+      #pretend like I hit '3' in the place to recenter it
+      nav_zoom 1      
+    end
+
+    # NEW zoom controls
+    if (("$KEY" == "Prior") || ("$KEY" == "Next") || ("$KEY" == "Home") || ("$KEY" == "End") || ("$KEY" == "Button4") || ("$KEY" == "Button5"))    
+      #move where key was hit to center      
+      $R$KEY  = $RMAX-$XMAX  
+      $D$KEY  = $DMAX-$YMAX
+      if ("$KEY" == "Prior")
+        $zfac=1.2
+      end
+      if ("$KEY" == "Next")
+        $zfac={1/1.2}
+      end
+      if ("$KEY" == "Home")
+        $zfac=2
+      end
+      if ("$KEY" == "End")
+        $zfac={1/2.}
+      end
+      if ("$KEY"=="Button4")
+        $zfac=1.6
+      end
+      if ("$KEY"=="Button5")
+        $zfac={1/1.6}
+      end
+      nav_zoom $zfac
+    end
+
+    if ("$KEY"=="Button1")
+      nav_zoom 1
+    end
+    if ("$KEY"=="Button2")
+      nav_zoom {1/2.}
+    end
+    if ("$KEY"=="Button3")
+      nav_zoom 2
+    end
+
+
+
+    # zoom controls
+    if ("$KEY" == "1")
+      nav_zoom 2
+    end
+    if ("$KEY" == "2")
+      nav_zoom 1.2
+    end
+    if ("$KEY" == "3")
+      nav_zoom 1
+    end
+    if ("$KEY" == "4")
+      nav_zoom {1/1.2}
+    end
+    if ("$KEY" == "5")
+      nav_zoom {1/2.}
+    end
+    if ("$KEY" == "6")
+      nav_zoom {1/20.}
+    end
+
+ 
+   # measure distance
+    if ("$KEY" == "d")
+      $r0 = $R$KEY
+      $d0 = $D$KEY
+      $ok = $KEY
+      echo "type 'd' again at endpoint"
+      cursor -g 1
+      $r1 = $R$KEY
+      $d1 = $D$KEY
+      $dr = 3600*((dcos($d0)*($r0-$r1))^2 + ($d0-$d1)^2)^0.5
+      echo "$dr arcsec"
+    end
+    # show ra, dec
+    if ("$KEY" == "w")
+      $tmp = $R$KEY
+      if ($tmp < 0) 
+        $tmp = $R$KEY + 360.0
+      end
+      echo "$tmp $D$KEY" 
+      exec echo $tmp $D$KEY | radec -hh
+    end
+    # zoom to radius
+    if ("$KEY" == "z")
+      $r0 = $R$KEY
+      $d0 = $D$KEY
+      $ok = $KEY
+      echo "type 'z' again at radius"
+      cursor -g 1
+      $r1 = $R$KEY
+      $d1 = $D$KEY
+      $dr = (($r0-$r1)^2 + ($d0-$d1)^2)^0.5
+      $ZOOM = $RAD / $dr
+      nav_recenter
+      nav_redraw
+      $KEY = $ok
+      $R$KEY = $r0
+      $D$KEY = $d0
+    end
+
+    # adjust mag scaling
+    if ("$KEY" == "J")
+      $MAG = $MAG - 0.5
+      nav_redraw
+    end
+    if ("$KEY" == "K")
+      $MAG = $MAG + 0.5
+      nav_redraw
+    end
+    if ("$KEY" == "j")
+      $dMAG = $dMAG * 0.8
+      nav_redraw
+    end
+    if ("$KEY" == "k")
+      $dMAG = $dMAG * 1.25
+      nav_redraw
+    end
+    echo "mag, dmag: $MAG, $dMAG"
+
+
+
+    # plot full sky
+    if ("$KEY" == "f") 
+      echo "full"
+      $ZOOM = 1
+      resize 1150 600		      
+      region 0 0 90 ait
+      $RMIN = 0
+      $RMAX = 360
+      $DMIN = -90
+      $DMAX = +90
+      style -c red; cgrid
+      style -c black
+      images
+    end
+
+    # plot rocks
+    if ("$KEY" == "r") 
+#      plot.rocks
+      style -c blue   -pt 1; procks -speed 0.0041 1
+      style -c red    -pt 1; procks -speed 0.00041 0.0041
+      style -c indigo -pt 1; procks -speed 0 0.00041
+      style -c black -lw 0;
+    end
+    # plot HST-GSC
+    if ("$KEY" == "l") 
+      style -c blue -pt 7; cat -all -g -m 9 16
+      style -c black
+    end
+    # plot Landolt
+    if ("$KEY" == "L") 
+#      style -c red  -lw 2 -pt 3; cat -a 1 2 3 /data/elixir/srcdir/refs/stetson/stetsonBn.txt -m 9 18
+#      style -c blue -lw 2 -pt 3; cat -a 25 26 8 /data/elixir/srcdir/refs/landolt/new/Landolt92.fix -m 9 18
+      style -c red -lw 2 -pt 7; cat -a 1 2 3 /data/elixir/srcdir/refs/sdss/g_SDSS.dat -m 9 14
+#      style -c red -lw 2 -pt 3; cat -a 25 26 8 /data/elixir/srcdir/refs/landolt/new/Landolt92.hq -m 9 18
+#      style -c red -lw 2 -pt 3; cat -a 22 23 8 /data/elixir/srcdir/refs/landolt/new/Landolt92.unfix -m 9 18
+#      style -c blue -lw 2 -pt 7; cat -a 1 2 4 /data/elixir/srcdir/refs/landolt/extreme/extreme.match -m 0 20
+#      style -x 2 -c red -pt 7 ; cplot RA DEC
+      style -c black -lw 0
+    end
+
+    # list star measurements
+    if ("$KEY" == "m") 
+        $dR = $RAD/$ZOOM/300
+        if ($dR < 0.0005)
+	 $dR = 0.0005
+        end
+	gstar $R$KEY $D$KEY $dR -m
+    end
+
+    # plot mag residuals
+    if ("$KEY" == "R") 
+      echo "filter: "
+      cursor 1
+      clear -n 1 -s; lim 10 22 -0.2 0.2; clear; box
+      dmags $KEY\:rel - $KEY : $KEY -type 0
+      plot -x 2 -pt 0 -sz 0.3 -c red yv xv
+      dmags $KEY\:rel - $KEY : $KEY -type 0 -flag 0 -nphot +3 -chisq 2.0
+      plot -x 2 -pt 2 -sz 0.5 -c black yv xv
+      $KEY = R
+      style -n 0
+    end
+
+    if ("$KEY" == "M") 
+	gstar $R$KEY $D$KEY 0.0005 -m
+    end
+    # list images
+    if ("$KEY" == "i") 
+	gimages $R$KEY $D$KEY
+    end
+    if ("$KEY" == "I") 
+	gimages $R$KEY $D$KEY -pix
+    end
+
+    #toggle images on / off
+    if ("$KEY" == "A")
+      $DRAWIMAGES = $DRAWIMAGES * -1
+      if ($DRAWIMAGES == 1)
+        images
+      end
+    end
+    # toggle stars on / off
+    if ("$KEY" == "S")
+      $DRAWSTARS = $DRAWSTARS * -1
+      if (($ZOOM > 20) && ($DRAWSTARS == 1))
+       style -pt 7
+       pmeasure -all -m $MAG {$MAG + $dMAG}
+      end
+    end
+    # turn grid on / off
+    if ("$KEY" == "g")
+      $DRAWGRID = $DRAWGRID * -1
+      if (($ZOOM > 20) && ($DRAWGRID==1))
+        style -c black; cgrid
+      end
+      if (($ZOOM > 20) && ($DRAWGRID==-1))
+        nav_redraw
+      end
+    end
+
+    # plot light-curve interactive
+    if ("$KEY" == "t")
+      style -n 1 -pt 2 -x 2
+      clear
+      if ($R$KEY < 0) 
+       $R$KEY = $R$KEY + 360
+      end
+      lcurve -l $R$KEY $D$KEY {30/3600} -d -v time mag
+      box
+      lcv
+      style -n 0
+    end
+    # plot light-curve 
+    if ("$KEY" == "T")
+      style -n 1 -pt 1 -c red -x 2
+      lcurve $R$KEY $D$KEY {30/3600} -d
+      style -c black
+      style -n 0 
+    end
+    # plot catalogs
+    if ("$KEY" == "c")
+      style -c blue; pcat; style -c black
+    end
+    # list catalogs
+    if ("$KEY" == "C")
+      gcat $R$KEY $D$KEY
+    end
+
+    # plot image chisqs
+    if ("$KEY" == "x") 
+       gcat $R$KEY $D$KEY
+       extract $CATNAME Xm -photcode R
+       extract $CATNAME ra
+       extract $CATNAME dec
+       style -x 2 -pt 7 -c blue
+       czplot ra dec Xm 3 30
+       style -c black -pt 1
+    end
+    # plot meas errors
+    if ("$KEY" == "X") 
+       gcat $R$KEY $D$KEY
+       extract $CATNAME dM -photcode R
+       extract $CATNAME ra
+       extract $CATNAME dec
+       style -x 2 -pt 7 -c red
+       czplot ra dec dM 0 30
+       style -c black -pt 1
+    end
+
+
+    # temp plot for skyprobe
+    if ("$KEY" == "u") 
+      imextract -region time
+      imextract -region mcal
+      imextract -region airmass
+      imextract -region nstar
+      vstat time
+      clear -n 1;
+      section a 0 0.00 1 0.33
+      lim {$MEDIAN-0.3} {$MEDIAN+0.3} -0.8 -0.5; box; plot time mcal
+      section b 0 0.33 1 0.33
+      lim {$MEDIAN-0.3} {$MEDIAN+0.3}  0.95 3.0; box; plot time airmass
+      section c 0 0.66 1 0.33
+      lim {$MEDIAN-0.3} {$MEDIAN+0.3} 0 3000; box; plot time nstar
+      style -n 0
+    end
+    if ("$KEY" == "s")
+      $tmp = $R$KEY
+      if ($tmp < 0) 
+        $tmp = $R$KEY + 360.0
+      end
+      $line = `echo $tmp $D$KEY | radec -hh`
+      imextract -region photcode
+      imextract -region time
+     
+      subset t = time if (int(photcode/100) == 1)
+      uniq t T
+      $Bn = t[]
+      $BN = T[]
+      
+      subset t = time if (int(photcode/100) == 2)
+      uniq t T
+      $Vn = t[]
+      $VN = T[]
+      
+      subset t = time if (int(photcode/100) == 3)
+      uniq t T
+      $Rn = t[]
+      $RN = T[]
+      
+      subset t = time if (int(photcode/100) == 4)
+      uniq t T
+      $In = t[]
+      $IN = T[]
+     
+      echo "$line  $Bn $BN  $Vn $VN  $Rn $RN  $In $IN"
+    end
+
+    if ("$KEY" == "p") 
+      echo "P - new coords; p - old coords"
+      cursor -g 1
+      exec echo $Rp $Dp $RP $DP >> fix.coords
+    end
+
+    if ("$KEY" == "y")
+      ccd I - 2MASS_J : 2MASS_J - 2MASS_K
+      lim -n 1 -1 10 -1 3; clear; box; plot -x 2 -pt 2 -sz 0.5 xv yv
+      dev -n 0 -g
+    end
+
+    #  User-defined macro
+    if ("$KEY" == "at")
+      user_macro
+    end
+
+    if ("$KEY" == "colon")
+      #make this work similar to ':' in vi or iraf
+      #does not work correctly now.
+      scan stdin line
+      $line
+    end
+
+  end
+end
+
+#define this so navigate doesn't crash if you try to call it.
+#If you define a user_macro, be sure to do so AFTER this in .dvorc.
+macro user_macro
+  #echo "success!"
+  $do_nothing=0
+end
+    
+
+macro nav_zoom
+  $ZOOM = $ZOOM * $1
+  nav_recenter
+  nav_redraw
+  $Rnum = $R$KEY		      
+  $Dnum = $D$KEY
+  $KEY = num
+end
+
+macro nav_recenter
+  region $R$KEY $D$KEY {$RAD/$ZOOM} sin
+  #assumes standard sky orientation!! (N up, E left)
+  $RMIN = $R$KEY + $XMIN
+  $RMAX = $R$KEY + $XMAX
+  $DMIN = $D$KEY + $YMIN
+  $DMAX = $D$KEY + $YMAX
+end
+
+macro nav_redraw
+  clear
+  if ($ZOOM <= 20) 
+    style -c red; cgrid
+  end
+  if (($ZOOM > 20) && ($DRAWGRID==1))
+    style -c black; cgrid
+  end
+  if (($ZOOM > 20) && ($DRAWSTARS == 1))
+    pmeasure -all -m $MAG {$MAG + $dMAG}
+  end    
+  style -c black
+  if ($DRAWIMAGES == 1)
+    images
+  end
+end
+
+
+
+#==================================================
+#=================   END BSNAV   ==================
+#==================================================
+
+
+macro sigclip
+  if ("$0" == "1")
+    echo ""
+    echo "sigclip <clipvector> <N_iterations> <N_sigma> [other vectors ..]"
+    echo ""
+  end
+
+  #required parameters
+  $CLIPVECT = $1
+  $NITERATE = $2
+  $NSIGCLIP = $3
+  
+  for i 0 $NITERATE
+    vstat -q $CLIPVECT
+    #clip boundaries
+    $top = $MEAN + ($NSIGCLIP*$SIGMA)
+    $bot = $MEAN - ($NSIGCLIP*$SIGMA)
+    
+    #clip it good.
+    subset temp = $CLIPVECT if (($CLIPVECT < $top) && ($CLIPVECT > $bot))
+    
+    #if you specify other vectors, clip the same elements from them too.
+    #they must all be the same length, of course!!
+    if ($0>4)
+      for j 4 $0
+        subset $$j = $$j if (($CLIPVECT < $top) && ($CLIPVECT > $bot))
+      end
+    end
+    
+    #copy temp back to $CLIPVECT and reiterate!
+    delete $CLIPVECT
+    concat temp $CLIPVECT  
+  end
+end
+
+
+macro binvec
+  if ("$0" == "1")
+    echo ""
+    echo "binvec <vec> <Nbins> [other vectors...]"
+    echo ""
+    echo "Bin the vector 'vec' into Nbin bins.  Listing other vectors will"
+    echo "put the corresponding elements of those into other vectors which"
+    echo "are the subset of the vector in that bin.  (That can probably be"
+    echo "stated better.)  This macro makes lots of new vectors.  Hooray!"
+    echo ""
+    echo "Creates"
+  end
+
+  #REQUIRED PARAMS
+  $binvect = $1
+  $NBINS   = $2
+
+  vstat -q $binvect
+  $step = ($MAX-$MIN)/$NBINS
+  $vmin = $MIN
+  $vmax = $MAX
+  delete -q $binvect\_bins
+  delete -q $binvect\_num
+  for i 1 {$NBINS+1}
+    $top = $vmin + ( $i   *$step)
+    $bot = $vmin + (($i-1)*$step)
+    #      sightly different behavior for last bin    -------v
+    if ($i != $NBINS)
+      subset temp = $binvect if (($binvect>=$bot)&&($binvect< $top))
+    else
+      subset temp = $binvect if (($binvect>=$bot)&&($binvect<=$top))
+    end
+    set $binvect\_bin$i = temp
+    set temp2 = temp
+    delete temp
+    #if you specify other vectors, grab the same elements from them too.
+    #they must all be the same length, of course!!
+
+    if ($0>3)
+      for j 3 $0
+        if ($i != $NBINS)
+          subset temp = $$j if (($binvect>=$bot)&&($binvect< $top))
+        else 
+          subset temp = $$j if (($binvect>=$bot)&&($binvect<=$top))
+        end
+        set $$j\_bin$i = temp
+        delete temp
+      end
+    end
+
+
+    concat {$bot+($step/2)} $binvect\_bins
+    concat temp2[] $binvect\_num
+    #dvo didn't like me saying 'concat $binvect\_bin$i[] $binvect\_num
+    delete temp2
+  end
+end
+
+macro binvec.2
+  if ("$0" == "1")
+    echo ""
+    echo "binvec.2 <vec> <min> <max> <binsize> [other vectors...]"
+    echo ""
+    echo ""
+    echo "see also 'binvec'"
+  end
+
+  #REQUIRED PARAMS
+  $binvect = $1
+  $vmin    = $2
+  $vmax    = $3
+  $step    = $4
+
+  $NBINS = ($MAX-$MIN)/$step
+
+  delete -q $binvect\_bins
+  delete -q $binvect\_num
+  for i 1 {$NBINS+1}
+    $top = $vmin + ( $i   *$step)
+    $bot = $vmin + (($i-1)*$step)
+    #      sightly different behavior for last bin    -------v
+    if ($i != $NBINS)
+      subset temp = $binvect if (($binvect>=$bot)&&($binvect< $top))
+    else
+      subset temp = $binvect if (($binvect>=$bot)&&($binvect<=$top))
+    end
+    set $binvect\_bin$i = temp
+    set temp2 = temp
+    delete temp
+    #if you specify other vectors, grab the same elements from them too.
+    #they must all be the same length, of course!!
+
+    if ($0>5)
+      for j 5 $0
+        if ($i != $NBINS)
+          subset temp = $$j if (($binvect>=$bot)&&($binvect< $top))
+        else 
+          subset temp = $$j if (($binvect>=$bot)&&($binvect<=$top))
+        end
+        set $$j\_bin$i = temp
+        delete temp
+      end
+    end
+
+
+    concat {$bot+($step/2)} $binvect\_bins
+    concat temp2[] $binvect\_num
+    #dvo didn't like me saying 'concat $binvect\_bin$i[] $binvect\_num
+    delete temp2
+  end
+end
Index: /trunk/Ohana/src/opihi/modules/mana/plots
===================================================================
--- /trunk/Ohana/src/opihi/modules/mana/plots	(revision 11084)
+++ /trunk/Ohana/src/opihi/modules/mana/plots	(revision 11084)
@@ -0,0 +1,41 @@
+
+macro cvplot 
+  if ($0 != 6)
+    echo "USAGE: cvplot r d ur ud scale"
+    break
+  end
+ 
+  local i
+  delete -q _tmpr _tmpd
+
+  for i 0 $1[]
+   concat $1[$i] _tmpr
+   concat $2[$i] _tmpd
+   concat {$1[$i]+$3[$i]*$5} _tmpr
+   concat {$2[$i]+$4[$i]*$5} _tmpd
+  end
+  style -pt 100
+  cplot _tmpr _tmpd
+  style -pt 7
+end
+
+macro vplot 
+  if ($0 != 6)
+    echo "USAGE: cvplot r d ur ud scale"
+    break
+  end
+ 
+  local i
+  delete -q _tmpr _tmpd
+
+  for i 0 $1[]
+   concat $1[$i] _tmpr
+   concat $2[$i] _tmpd
+   concat {$1[$i]+$3[$i]*$5} _tmpr
+   concat {$2[$i]+$4[$i]*$5} _tmpd
+  end
+  style -pt 100
+  plot _tmpr _tmpd
+  style -pt 7
+end
+
Index: /trunk/Ohana/src/opihi/pantasks/Makefile
===================================================================
--- /trunk/Ohana/src/opihi/pantasks/Makefile	(revision 11083)
+++ /trunk/Ohana/src/opihi/pantasks/Makefile	(revision 11084)
@@ -7,5 +7,5 @@
 LIB     =       $(HOME)/lib
 INC     =       $(HOME)/include
-HELP    =       $(DESTHELP)/pantasks
+DATA    =       $(DESTDATA)/pantasks
 
 # link flags 
@@ -16,4 +16,10 @@
 # sched user commands and support functions ########################
 
+client = \
+$(SRC)/pantasks_client.$(ARCH).o \
+$(SRC)/client_shell.$(ARCH).o \
+$(SRC)/invalid.$(ARCH).o \
+$(SRC)/init_client.$(ARCH).o
+
 single = \
 $(SRC)/init.$(ARCH).o \
@@ -21,5 +27,24 @@
 $(SRC)/stop.$(ARCH).o \
 $(SRC)/pantasks.$(ARCH).o \
-$(SRC)/CheckSystem.$(ARCH).o
+$(SRC)/thread_locks.$(ARCH).o \
+$(SRC)/job_threads.$(ARCH).o \
+$(SRC)/task_threads.$(ARCH).o \
+$(SRC)/controller_threads.$(ARCH).o 
+
+server = \
+$(SRC)/pantasks_server.$(ARCH).o \
+$(SRC)/server_run.$(ARCH).o \
+$(SRC)/server_load.$(ARCH).o \
+$(SRC)/InputQueue.$(ARCH).o \
+$(SRC)/ListenClients.$(ARCH).o \
+$(SRC)/server.$(ARCH).o \
+$(SRC)/status_server.$(ARCH).o \
+$(SRC)/init_server.$(ARCH).o \
+$(SRC)/CheckPassword.$(ARCH).o \
+$(SRC)/thread_locks.$(ARCH).o \
+$(SRC)/job_threads.$(ARCH).o \
+$(SRC)/task_threads.$(ARCH).o \
+$(SRC)/controller_threads.$(ARCH).o \
+$(SRC)/input_threads.$(ARCH).o
 
 funcs = \
@@ -61,22 +86,4 @@
 $(SRC)/ipptool2book.$(ARCH).o
 
-client = \
-$(SRC)/pantasks_client.$(ARCH).o \
-$(SRC)/client_shell.$(ARCH).o \
-$(SRC)/invalid.$(ARCH).o \
-$(SRC)/init_client.$(ARCH).o
-
-server = \
-$(SRC)/pantasks_server.$(ARCH).o \
-$(SRC)/server_threads.$(ARCH).o \
-$(SRC)/server_run.$(ARCH).o \
-$(SRC)/server_load.$(ARCH).o \
-$(SRC)/InputQueue.$(ARCH).o \
-$(SRC)/ListenClients.$(ARCH).o \
-$(SRC)/server.$(ARCH).o \
-$(SRC)/status_server.$(ARCH).o \
-$(SRC)/init_server.$(ARCH).o \
-$(SRC)/CheckPassword.$(ARCH).o
-
 libs = \
 $(DESTLIB)/libshell.a \
@@ -103,7 +110,9 @@
 $(single) $(client) $(server) $(funcs) $(cmds) : $(INC)/pantasks.h
 
-install: $(DESTBIN)/pantasks $(DESTBIN)/pantasks_client $(DESTBIN)/pantasks_server help
+install: $(DESTBIN)/pantasks $(DESTBIN)/pantasks_client $(DESTBIN)/pantasks_server help modules
 
 help: clean-help cmd.basic.help cmd.data.help cmd.astro.help pantasks.help
+
+modules: pantasks.modules
 
 .PHONY: pantasks pantasks_client pantasks_server
Index: /trunk/Ohana/src/opihi/pantasks/TaskOps.c
===================================================================
--- /trunk/Ohana/src/opihi/pantasks/TaskOps.c	(revision 11083)
+++ /trunk/Ohana/src/opihi/pantasks/TaskOps.c	(revision 11084)
@@ -1,3 +1,4 @@
 # include "pantasks.h"
+# include <regex.h>
 
 static Task **tasks;
@@ -75,8 +76,8 @@
   gprint (GP_LOG, " Task Status\n");
 
-  snprintf (format, 128, "  AV %%-%ds %5s %%-%ds\n", nameLength, "Njobs", cmdLength);
+  snprintf (format, 128, "  AV %%-%ds %5s  %5s %5s %5s %%-%ds\n", nameLength, "Njobs", "Ngood", "Nfail", "Ntime", cmdLength);
   gprint (GP_LOG, format, "Name", "Command");
 
-  snprintf (format, 128, "%%-%ds %%5d %%-%ds\n", nameLength, cmdLength);
+  snprintf (format, 128, "%%-%ds %%5d  %%5d %%5d %%5d %%-%ds\n", nameLength, cmdLength);
   for (i = 0; i < Ntasks; i++) {
     valid = CheckTimeRanges (tasks[i][0].ranges, tasks[i][0].Nranges);
@@ -93,7 +94,7 @@
     }
     if (tasks[i][0].argv == NULL) {
-      gprint (GP_LOG, format, tasks[i][0].name, tasks[i][0].Njobs, "(dynamic)");
-    } else {
-      gprint (GP_LOG, format, tasks[i][0].name, tasks[i][0].Njobs, tasks[i][0].argv[0]);
+      gprint (GP_LOG, format, tasks[i][0].name, tasks[i][0].Njobs, tasks[i][0].Nsuccess, tasks[i][0].Nfailure, tasks[i][0].Ntimeout, "(dynamic)");
+    } else {
+      gprint (GP_LOG, format, tasks[i][0].name, tasks[i][0].Njobs, tasks[i][0].Nsuccess, tasks[i][0].Nfailure, tasks[i][0].Ntimeout, tasks[i][0].argv[0]);
     }
     if (verbose) {
@@ -146,9 +147,10 @@
 
 /* list known tasks */
-void ListTaskStats () {
+void ListTaskStats (char *regex) {
 
   int i, j, valid, nameLength;
   char *start, *stop;
   char format[128];
+  regex_t preg;
 
   gprint (GP_LOG, "\n");
@@ -158,4 +160,8 @@
   }
 
+  if (regex != NULL) {
+    regcomp (&preg, regex, REG_EXTENDED);
+  }
+
   /* find string lengths */
   nameLength = 0;
@@ -173,4 +179,7 @@
   snprintf (format, 128, "%%-%ds", nameLength);
   for (i = 0; i < Ntasks; i++) {
+      
+    if ((regex != NULL) && regexec (&preg, tasks[i][0].name, 0, NULL, 0)) continue;
+
     valid = CheckTimeRanges (tasks[i][0].ranges, tasks[i][0].Nranges);
     if (tasks[i][0].active) {
Index: /trunk/Ohana/src/opihi/pantasks/controller_threads.c
===================================================================
--- /trunk/Ohana/src/opihi/pantasks/controller_threads.c	(revision 11084)
+++ /trunk/Ohana/src/opihi/pantasks/controller_threads.c	(revision 11084)
@@ -0,0 +1,32 @@
+# include "pantasks.h"
+
+/** things related to CheckController **/
+
+static int CheckControllerRun = FALSE;
+
+void CheckControllerSetState (int state) {
+  CheckControllerRun = state;
+}
+int CheckControllerGetState () {
+  return (CheckControllerRun);
+}
+
+void *CheckControllerThread (void *data) {
+
+  gprintInit ();  // each thread needs to init the printing system
+  while (1) {
+
+    // check for thread suspend
+    if (!CheckControllerRun) {
+      usleep (100000); // idle if thread action is suspended
+      continue;
+    }
+
+    // one run of the task checker
+    SerialThreadLock ();
+    CheckController ();
+    CheckControllerOutput ();
+    SerialThreadUnlock ();
+    usleep (10000); // allow other threads a chance to run
+  }
+}
Index: /trunk/Ohana/src/opihi/pantasks/init.c
===================================================================
--- /trunk/Ohana/src/opihi/pantasks/init.c	(revision 11083)
+++ /trunk/Ohana/src/opihi/pantasks/init.c	(revision 11084)
@@ -15,4 +15,5 @@
 int run             PROTO((int, char **));
 int stop            PROTO((int, char **));
+int halt            PROTO((int, char **));
 int pulse           PROTO((int, char **));
 int status_sys      PROTO((int, char **));
@@ -38,5 +39,6 @@
   {"stderr",     task_stderr,  "define a file for the job stderr dump"},
   {"run",        run,          "run the scheduler"},
-  {"stop",       stop,         "stop the scheduler"},
+  {"stop",       stop,         "stop the scheduler (continue job harvesting)"},
+  {"halt",       halt,         "halt the scheduler (no job harvesting)"},
   {"pulse",      pulse,        "set the scheduler update period"},
   {"status",     status_sys,   "get system status"},
Index: /trunk/Ohana/src/opihi/pantasks/input_threads.c
===================================================================
--- /trunk/Ohana/src/opihi/pantasks/input_threads.c	(revision 11084)
+++ /trunk/Ohana/src/opihi/pantasks/input_threads.c	(revision 11084)
@@ -0,0 +1,32 @@
+# include "pantasks.h"
+
+/** things related to CheckInputs **/
+
+static int CheckInputsRun = TRUE;
+
+void CheckInputsSetState (int state) {
+  CheckInputsRun = state;
+}
+int CheckInputsGetState () {
+  return (CheckInputsRun);
+}
+
+void *CheckInputsThread (void *data) {
+
+  gprintInit ();  // each thread needs to init the printing system
+  while (1) {
+
+    // check for thread suspend
+    if (!CheckInputsRun) {
+      usleep (100000); // idle if thread action is suspended
+      continue;
+    }
+
+    // one run of the task checker
+    SerialThreadLock ();
+    CheckInputs ();
+    SerialThreadUnlock ();
+    fprintf (stderr, "I");
+    usleep (10000); // allow other threads a chance to run
+  }
+}
Index: /trunk/Ohana/src/opihi/pantasks/ipptool2book.c
===================================================================
--- /trunk/Ohana/src/opihi/pantasks/ipptool2book.c	(revision 11083)
+++ /trunk/Ohana/src/opihi/pantasks/ipptool2book.c	(revision 11084)
@@ -80,5 +80,5 @@
   }
   if (strcmp(bookName, argv[2])) {
-    gprint (GP_ERR, "WARNING: metadata output name does not match expected bookname\n");
+    gprint (GP_ERR, "WARNING: metadata output name %s does not match expected bookname %s\n", bookName, argv[2]);
   }
   free (line);
Index: /trunk/Ohana/src/opihi/pantasks/job_threads.c
===================================================================
--- /trunk/Ohana/src/opihi/pantasks/job_threads.c	(revision 11084)
+++ /trunk/Ohana/src/opihi/pantasks/job_threads.c	(revision 11084)
@@ -0,0 +1,31 @@
+# include "pantasks.h"
+
+/** things related to CheckJobs **/
+
+static int CheckJobsRun = FALSE;
+
+void CheckJobsSetState (int state) {
+  CheckJobsRun = state;
+}
+int CheckJobsGetState () {
+  return (CheckJobsRun);
+}
+
+void *CheckJobsThread (void *data) {
+
+  gprintInit ();  // each thread needs to init the printing system
+  while (1) {
+
+    // check for thread suspend
+    if (!CheckJobsRun) {
+      usleep (100000); // idle if thread action is suspended
+      continue;
+    }
+
+    // one run of the task checker
+    SerialThreadLock ();
+    CheckJobs ();
+    SerialThreadUnlock ();
+    usleep (10000); // allow other threads a chance to run
+  }
+}
Index: /trunk/Ohana/src/opihi/pantasks/pantasks.c
===================================================================
--- /trunk/Ohana/src/opihi/pantasks/pantasks.c	(revision 11083)
+++ /trunk/Ohana/src/opihi/pantasks/pantasks.c	(revision 11084)
@@ -10,4 +10,8 @@
 void program_init (int *argc, char **argv) {
   
+  pthread_t jobsThread;
+  pthread_t tasksThread;
+  pthread_t controllerThread;
+
   auto_break = TRUE;
 
@@ -26,6 +30,21 @@
   set_str_variable ("RCFILE", opihi_rcfile);
 
-# ifdef HELPDIR_DEFAULT
-  set_str_variable ("HELPDIR", MACRO_NAME(HELPDIR_DEFAULT));
+# ifdef DATADIR_DEFAULT
+  { 
+    char *datadir;
+    char *helpdir;
+    char *modules;
+    datadir = MACRO_NAME(DATADIR_DEFAULT);
+    /* set_str_variable ("DATADIR", datadir); */
+    ALLOCATE (helpdir, char, strlen(datadir) + strlen("/help") + 2);
+    sprintf (helpdir, "%s/help", datadir);
+    set_str_variable ("HELPDIR", helpdir);
+    free (helpdir);
+    ALLOCATE (modules, char, strlen(datadir) + strlen("/modules") + 2);
+    sprintf (modules, "%s/modules", datadir);
+    set_str_variable ("MODULES:0", modules);
+    set_int_variable ("MODULES:n", 1);
+    free (helpdir);
+  }
 # endif
 
@@ -33,4 +52,9 @@
   signal (SIGTSTP, gotsignal);
   signal (SIGTTIN, gotsignal);
+
+  /* start up the background threads here */
+  pthread_create (&tasksThread,      NULL, &CheckTasksThread, 	   NULL);
+  pthread_create (&jobsThread,       NULL, &CheckJobsThread, 	   NULL);
+  pthread_create (&controllerThread, NULL, &CheckControllerThread, NULL);
   return;
 }
@@ -61,2 +85,9 @@
   exit (status);
 }
+
+/* pantasks runs three (or four) threads:
+   - one thread parses commands from the connected clients
+   - one thread runs the scheduler loop
+   - one thread may run the controller loop independently
+   - the main thread runs readline and accepts user input
+*/
Index: /trunk/Ohana/src/opihi/pantasks/pantasks_client.c
===================================================================
--- /trunk/Ohana/src/opihi/pantasks/pantasks_client.c	(revision 11083)
+++ /trunk/Ohana/src/opihi/pantasks/pantasks_client.c	(revision 11084)
@@ -25,6 +25,21 @@
   set_str_variable ("RCFILE", opihi_rcfile);
 
-# ifdef HELPDIR_DEFAULT
-  set_str_variable ("HELPDIR", MACRO_NAME(HELPDIR_DEFAULT));
+# ifdef DATADIR_DEFAULT
+  {
+      char *datadir;
+      char *helpdir;
+      char *modules;
+      datadir = MACRO_NAME(DATADIR_DEFAULT);
+      /* set_str_variable ("DATADIR", datadir); */
+      ALLOCATE (helpdir, char, strlen(datadir) + strlen("/help") + 2);
+      sprintf (helpdir, "%s/help", datadir);
+      set_str_variable ("HELPDIR", helpdir);
+      free (helpdir);
+      ALLOCATE (modules, char, strlen(datadir) + strlen("/modules") + 2);
+      sprintf (modules, "%s/modules", datadir);
+      set_str_variable ("MODULES:0", modules);
+      set_int_variable ("MODULES:n", 1);
+      free (helpdir);
+  }
 # endif
 
Index: /trunk/Ohana/src/opihi/pantasks/pantasks_server.c
===================================================================
--- /trunk/Ohana/src/opihi/pantasks/pantasks_server.c	(revision 11083)
+++ /trunk/Ohana/src/opihi/pantasks/pantasks_server.c	(revision 11084)
@@ -16,8 +16,8 @@
 int main (int argc, char **argv) {
   
+  pthread_t jobsThread;
+  pthread_t tasksThread;
+  pthread_t inputsThread;
   pthread_t clientsThread;
-  pthread_t tasksThread;
-  // pthread_t jobsThread;
-  pthread_t inputsThread;
   pthread_t controllerThread;
   int InitSocket, BindSocket;
@@ -47,5 +47,5 @@
   pthread_create (&clientsThread,    NULL, &ListenClients,    	   NULL);
   pthread_create (&tasksThread,      NULL, &CheckTasksThread, 	   NULL);
-  // pthread_create (&jobsThread,       NULL, &CheckJobsThread,  	   NULL);
+  pthread_create (&jobsThread,       NULL, &CheckJobsThread,  	   NULL);
   pthread_create (&controllerThread, NULL, &CheckControllerThread, NULL);
   pthread_create (&inputsThread,     NULL, &CheckInputsThread,     NULL);
Index: /trunk/Ohana/src/opihi/pantasks/run.c
===================================================================
--- /trunk/Ohana/src/opihi/pantasks/run.c	(revision 11083)
+++ /trunk/Ohana/src/opihi/pantasks/run.c	(revision 11084)
@@ -15,6 +15,10 @@
   }
 
-  InitTaskTimers ();
-  rl_event_hook = CheckSystem;
+  CheckTasksSetState (TRUE);
+  CheckControllerSetState (TRUE);
+  CheckJobsSetState (TRUE);
+
+  // InitTaskTimers ();
+  // rl_event_hook = CheckSystem;
 
   return (TRUE);
Index: /trunk/Ohana/src/opihi/pantasks/server.c
===================================================================
--- /trunk/Ohana/src/opihi/pantasks/server.c	(revision 11083)
+++ /trunk/Ohana/src/opihi/pantasks/server.c	(revision 11084)
@@ -7,4 +7,5 @@
 int server_run	    PROTO((int, char **));
 int server_stop	    PROTO((int, char **));
+int server_halt	    PROTO((int, char **));
 int cd              PROTO((int, char **));
 int pwd        	    PROTO((int, char **));
@@ -20,4 +21,5 @@
   {"run",    server_run,  "run scheduler"},
   {"stop",   server_stop, "stop scheduler"},
+  {"halt",   server_halt, "halt scheduler"},
   {"cd",     cd,     "set local directory"},
   {"pwd",    pwd,    "check local directory"},
Index: /trunk/Ohana/src/opihi/pantasks/server_run.c
===================================================================
--- /trunk/Ohana/src/opihi/pantasks/server_run.c	(revision 11083)
+++ /trunk/Ohana/src/opihi/pantasks/server_run.c	(revision 11084)
@@ -9,5 +9,5 @@
 
   CheckTasksSetState (TRUE);
-  // CheckJobsSetState (TRUE);
+  CheckJobsSetState (TRUE);
   CheckControllerSetState (TRUE);
   CheckInputsSetState (TRUE);
@@ -24,4 +24,18 @@
   CheckTasksSetState (FALSE);
   // CheckJobsSetState (FALSE);
+  // CheckControllerSetState (FALSE);
+  CheckInputsSetState (FALSE);
+  return (TRUE);
+}
+
+int server_halt (int argc, char **argv) {
+
+  if (argc != 1) {
+    gprint (GP_ERR, "USAGE: server halt\n");
+    return (FALSE);
+  }
+
+  CheckTasksSetState (FALSE);
+  CheckJobsSetState (FALSE);
   CheckControllerSetState (FALSE);
   CheckInputsSetState (FALSE);
Index: /trunk/Ohana/src/opihi/pantasks/status.c
===================================================================
--- /trunk/Ohana/src/opihi/pantasks/status.c	(revision 11083)
+++ /trunk/Ohana/src/opihi/pantasks/status.c	(revision 11084)
@@ -4,8 +4,15 @@
 
   gprint (GP_LOG, "\n");
-  if (rl_event_hook == NULL) {
-    gprint (GP_LOG, " Scheduler is stopped\n");
+
+  // if (rl_event_hook == NULL) {
+
+  if (CheckTasksGetState()) {
+    gprint (GP_LOG, " Scheduler is running\n");
   } else {
-    gprint (GP_LOG, " Scheduler is running\n");
+    if (CheckJobsGetState()) {
+      gprint (GP_LOG, " Scheduler is stopped, harvesting jobs\n");
+    } else {
+      gprint (GP_LOG, " Scheduler is running\n");
+    }
   }
   if (CheckControllerStatus()) {
Index: /trunk/Ohana/src/opihi/pantasks/stop.c
===================================================================
--- /trunk/Ohana/src/opihi/pantasks/stop.c	(revision 11083)
+++ /trunk/Ohana/src/opihi/pantasks/stop.c	(revision 11084)
@@ -8,6 +8,22 @@
   }
 
-  rl_event_hook = NULL;
+  CheckTasksSetState (FALSE);
+  // CheckControllerSetState (FALSE);
+  // CheckJobsSetState (FALSE);
 
   return (TRUE);
 }
+
+int halt (int argc, char **argv) {
+
+  if (argc != 1) {
+    gprint (GP_ERR, "USAGE: halt\n");
+    return (FALSE);
+  }
+
+  CheckTasksSetState (FALSE);
+  CheckControllerSetState (FALSE);
+  CheckJobsSetState (FALSE);
+
+  return (TRUE);
+}
Index: /trunk/Ohana/src/opihi/pantasks/task.c
===================================================================
--- /trunk/Ohana/src/opihi/pantasks/task.c	(revision 11083)
+++ /trunk/Ohana/src/opihi/pantasks/task.c	(revision 11084)
@@ -23,5 +23,9 @@
   if ((N = get_argument (argc, argv, "-stats"))) {
     remove_argument (N, &argc, argv);
-    ListTaskStats ();
+    if (argc == 2) {
+      ListTaskStats (argv[N]);
+    } else {
+      ListTaskStats (NULL);
+    }      
     return (TRUE);
   }
Index: /trunk/Ohana/src/opihi/pantasks/task_threads.c
===================================================================
--- /trunk/Ohana/src/opihi/pantasks/task_threads.c	(revision 11084)
+++ /trunk/Ohana/src/opihi/pantasks/task_threads.c	(revision 11084)
@@ -0,0 +1,40 @@
+# include "pantasks.h"
+
+/** things related to CheckTasks **/
+
+static int CheckTasksRun = FALSE;
+
+void CheckTasksSetState (int state) {
+  CheckTasksRun = state;
+}
+int CheckTasksGetState () {
+  return (CheckTasksRun);
+}
+
+void *CheckTasksThread (void *data) {
+
+  gprintInit ();  // each thread needs to init the printing system
+  while (1) {
+
+    // check for thread suspend
+    if (!CheckTasksRun) {
+      usleep (100000); // idle if thread action is suspended
+      continue;
+    }
+
+    // one run of the task checker
+    SerialThreadLock ();
+    CheckTasks ();
+    SerialThreadUnlock ();
+    usleep (10000); // allow other threads a chance to run
+  }
+}
+
+/* the threaded version of pantasks does not worry about limiting the 
+   time spent in one of the test loops -- comms with the client are
+   in a separate thread anyway...
+*/
+
+int TestElapsedCheck () {
+  return (FALSE);
+}
Index: /trunk/Ohana/src/opihi/pantasks/thread_locks.c
===================================================================
--- /trunk/Ohana/src/opihi/pantasks/thread_locks.c	(revision 11084)
+++ /trunk/Ohana/src/opihi/pantasks/thread_locks.c	(revision 11084)
@@ -0,0 +1,14 @@
+# include "pantasks.h"
+
+/* this mutex is used by the serialized threads */
+
+static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
+
+void SerialThreadLock () {
+    pthread_mutex_lock (&mutex);
+}
+
+void SerialThreadUnlock () {
+    pthread_mutex_unlock (&mutex);
+}
+
Index: /trunk/Ohana/src/opihi/pclient/Makefile
===================================================================
--- /trunk/Ohana/src/opihi/pclient/Makefile	(revision 11083)
+++ /trunk/Ohana/src/opihi/pclient/Makefile	(revision 11084)
@@ -7,5 +7,5 @@
 INC     =       $(HOME)/include
 SDIR    =       $(HOME)/pclient
-HELP    =       $(DESTHELP)/pclient
+DATA    =       $(DESTDATA)/pclient
 
 # link flags 
Index: /trunk/Ohana/src/opihi/pclient/pclient.c
===================================================================
--- /trunk/Ohana/src/opihi/pclient/pclient.c	(revision 11083)
+++ /trunk/Ohana/src/opihi/pclient/pclient.c	(revision 11084)
@@ -30,6 +30,22 @@
   set_str_variable ("PROMPT", opihi_prompt);
   set_str_variable ("RCFILE", opihi_rcfile);
-# ifdef HELPDIR_DEFAULT
-  set_str_variable ("HELPDIR", MACRO_NAME(HELPDIR_DEFAULT));
+
+# ifdef DATADIR_DEFAULT
+  {
+    char *datadir;
+    char *helpdir;
+    char *modules;
+    datadir = MACRO_NAME(DATADIR_DEFAULT);
+    /* set_str_variable ("DATADIR", datadir); */
+    ALLOCATE (helpdir, char, strlen(datadir) + strlen("/help") + 2);
+    sprintf (helpdir, "%s/help", datadir);
+    set_str_variable ("HELPDIR", helpdir);
+    free (helpdir);
+    ALLOCATE (modules, char, strlen(datadir) + strlen("/modules") + 2);
+    sprintf (modules, "%s/modules", datadir);
+    set_str_variable ("MODULES:0", modules);
+    set_int_variable ("MODULES:n", 1);
+    free (helpdir);
+  }
 # endif
 
Index: /trunk/Ohana/src/opihi/pcontrol/Makefile
===================================================================
--- /trunk/Ohana/src/opihi/pcontrol/Makefile	(revision 11083)
+++ /trunk/Ohana/src/opihi/pcontrol/Makefile	(revision 11084)
@@ -6,6 +6,6 @@
 LIB     =       $(HOME)/lib
 INC     =       $(HOME)/include
-SRC    =       $(HOME)/pcontrol
-HELP    =       $(DESTHELP)/pcontrol
+SRC     =       $(HOME)/pcontrol
+DATA    =       $(DESTDATA)/pcontrol
 
 # link flags 
Index: /trunk/Ohana/src/opihi/pcontrol/pcontrol.c
===================================================================
--- /trunk/Ohana/src/opihi/pcontrol/pcontrol.c	(revision 11083)
+++ /trunk/Ohana/src/opihi/pcontrol/pcontrol.c	(revision 11084)
@@ -44,6 +44,21 @@
   set_str_variable ("RCFILE", opihi_rcfile);
 
-# ifdef HELPDIR_DEFAULT
-  set_str_variable ("HELPDIR", MACRO_NAME(HELPDIR_DEFAULT));
+# ifdef DATADIR_DEFAULT
+  {
+    char *datadir;
+    char *helpdir;
+    char *modules;
+    datadir = MACRO_NAME(DATADIR_DEFAULT);
+    /* set_str_variable ("DATADIR", datadir); */
+    ALLOCATE (helpdir, char, strlen(datadir) + strlen("/help") + 2);
+    sprintf (helpdir, "%s/help", datadir);
+    set_str_variable ("HELPDIR", helpdir);
+    free (helpdir);
+    ALLOCATE (modules, char, strlen(datadir) + strlen("/modules") + 2);
+    sprintf (modules, "%s/modules", datadir);
+    set_str_variable ("MODULES:0", modules);
+    set_int_variable ("MODULES:n", 1);
+    free (helpdir);
+  }
 # endif
 
