Index: trunk/Ohana/src/opihi/cmd.astro/czplot.c
===================================================================
--- trunk/Ohana/src/opihi/cmd.astro/czplot.c	(revision 31666)
+++ trunk/Ohana/src/opihi/cmd.astro/czplot.c	(revision 31667)
@@ -3,5 +3,5 @@
 int czplot (int argc, char **argv) {
   
-  int i, kapa;
+  int i, kapa, Npts, status;
   double min, range, Rmin, Rmax;
   opihi_flt *out, *r, *d, *x, *y;
@@ -18,6 +18,6 @@
   min = atof(argv[4]);
   range = atof(argv[5]) - min;
-  Rmin = graphmode.coords.crval1 - 180.0;
-  Rmax = graphmode.coords.crval1 + 180.0;
+  Rmin = graphmode.coords.crval1 - 182.0;
+  Rmax = graphmode.coords.crval1 + 182.0;
 
   /* find vectors */
@@ -46,21 +46,30 @@
   x   = Xvec.elements.Flt;
   y   = Yvec.elements.Flt;
-  for (i = 0; i < Zvec.Nelements; i++, r++, d++, x++, y++) {
+  out = Zvec.elements.Flt;
+
+  Npts = 0;
+  for (i = 0; i < xvec[0].Nelements; i++, r++, d++) {
     *r = ohana_normalize_angle (*r);
-    RD_to_XY (x, y, *r, *d, &graphmode.coords);
+    while (*r < Rmin) *r += 360.0;
+    while (*r > Rmax) *r -= 360.0;
+
+    status = RD_to_XY (x, y, *r, *d, &graphmode.coords);
+    if (!status) continue;
+
+    if (zvec->type == OPIHI_FLT) {
+      opihi_flt *in  = zvec[0].elements.Flt;
+      *out = MIN (1.0, MAX (0.01, (in[i] - min) / range));
+    } else {
+      opihi_int *in  = zvec[0].elements.Int;
+      *out = MIN (1.0, MAX (0.01, (in[i] - min) / range));
+    }
+    x++;
+    y++;
+    out++;
+    Npts++;
   }
-
-  out = Zvec.elements.Flt;
-  if (zvec->type == OPIHI_FLT) {
-    opihi_flt *in  = zvec[0].elements.Flt;
-    for (i = 0; i < Zvec.Nelements; i++, in++, out++) {
-      *out = MIN (1.0, MAX (0.01, (*in - min) / range));
-    }
-  } else {
-    opihi_int *in  = zvec[0].elements.Int;
-    for (i = 0; i < Zvec.Nelements; i++, in++, out++) {
-      *out = MIN (1.0, MAX (0.01, (*in - min) / range));
-    }
-  }
+  Xvec.Nelements = Npts;
+  Yvec.Nelements = Npts;
+  Zvec.Nelements = Npts;
 
   graphmode.style = 2;
Index: trunk/Ohana/src/opihi/cmd.basic/cd.c
===================================================================
--- trunk/Ohana/src/opihi/cmd.basic/cd.c	(revision 31666)
+++ trunk/Ohana/src/opihi/cmd.basic/cd.c	(revision 31667)
@@ -24,6 +24,5 @@
     }
     if (VERBOSE) gprint (GP_LOG, "cwd: %s\n", cwd);
-    ohana_memregister (cwd);
-    free (cwd);
+    real_free (cwd);
     return (TRUE);
   }
@@ -62,6 +61,5 @@
       free (var);
   }
-  ohana_memregister (cwd);
-  free (cwd);
+  real_free (cwd);
   return (TRUE);
   
Index: trunk/Ohana/src/opihi/cmd.basic/list.c
===================================================================
--- trunk/Ohana/src/opihi/cmd.basic/list.c	(revision 31666)
+++ trunk/Ohana/src/opihi/cmd.basic/list.c	(revision 31667)
@@ -223,5 +223,5 @@
     /* get the next line (from correct place) */
     if (ThisList == 0) {
-      input = readline (prompt);
+      input = opihi_readline (prompt);
     } else {
       input = get_next_listentry (ThisList);
@@ -236,5 +236,4 @@
       input = strcreate ("end");
     }
-    if (ThisList == 0) ohana_memregister (input);
 
     stripwhite (input);
Index: trunk/Ohana/src/opihi/cmd.basic/run_for.c
===================================================================
--- trunk/Ohana/src/opihi/cmd.basic/run_for.c	(revision 31666)
+++ trunk/Ohana/src/opihi/cmd.basic/run_for.c	(revision 31667)
@@ -48,5 +48,5 @@
     /* get the next line (from correct place) */
     if (ThisList == 0) 
-      input = readline (prompt);
+      input = opihi_readline (prompt);
     else 
       input = get_next_listentry (ThisList);
@@ -67,5 +67,4 @@
       }	
     }
-    if (ThisList == 0) ohana_memregister (input);
 
     /* test for new macro (or other list, in the future?) */
Index: trunk/Ohana/src/opihi/cmd.basic/run_if.c
===================================================================
--- trunk/Ohana/src/opihi/cmd.basic/run_if.c	(revision 31666)
+++ trunk/Ohana/src/opihi/cmd.basic/run_if.c	(revision 31667)
@@ -66,5 +66,5 @@
     /* get the next line (from correct place) */
     if (ThisList == 0) {
-      input = readline (prompt);
+      input = opihi_readline (prompt);
     } else {
       input = get_next_listentry (ThisList);
@@ -79,5 +79,4 @@
       input = strcreate ("end");
     }
-    if (ThisList == 0) ohana_memregister (input);
 
     stripwhite (input);
Index: trunk/Ohana/src/opihi/cmd.basic/run_while.c
===================================================================
--- trunk/Ohana/src/opihi/cmd.basic/run_while.c	(revision 31666)
+++ trunk/Ohana/src/opihi/cmd.basic/run_while.c	(revision 31667)
@@ -25,5 +25,5 @@
     /* get the next line (from correct place) */
     if (ThisList == 0) 
-      input = readline (prompt);
+      input = opihi_readline (prompt);
     else 
       input = get_next_listentry (ThisList);
@@ -44,5 +44,4 @@
       }	
     }
-    if (ThisList == 0) ohana_memregister (input);
 
     /* test for new macro (or other list, in the future?) */
Index: trunk/Ohana/src/opihi/cmd.data/init.c
===================================================================
--- trunk/Ohana/src/opihi/cmd.data/init.c	(revision 31666)
+++ trunk/Ohana/src/opihi/cmd.data/init.c	(revision 31667)
@@ -137,4 +137,5 @@
 int zap              PROTO((int, char **));
 int zplot            PROTO((int, char **));
+int zcplot            PROTO((int, char **));
 
 static Command cmds[] = {  
@@ -284,4 +285,5 @@
   {1, "zap",          zap,              "assign values to pixel regions"},
   {1, "zplot",        zplot,            "plot x y with size scaled by z"},
+  {1, "zcplot",       zcplot,           "plot x y with color scaled by z"},
 }; 
 
Index: trunk/Ohana/src/opihi/cmd.data/read_vectors.c
===================================================================
--- trunk/Ohana/src/opihi/cmd.data/read_vectors.c	(revision 31666)
+++ trunk/Ohana/src/opihi/cmd.data/read_vectors.c	(revision 31667)
@@ -2,5 +2,5 @@
 
 FILE *f = (FILE *) NULL;
-char filename[256];
+char filename[2048];
 
 int datafile (int argc, char **argv) {
@@ -23,5 +23,5 @@
 int read_vectors (int argc, char **argv) {
   
-  int i, j, Nskip, Nvec, *col, done, status;
+  int i, j, Nskip, Nvec, *col, done, status, IsCSV;
   int Nbytes, nbytes, Nstart, NELEM, N, nread;
   char *colstr, *c0, *c1, *buffer, *extname;
@@ -47,4 +47,10 @@
   }
 
+  IsCSV = FALSE;
+  if ((N = get_argument (argc, argv, "-csv"))) {
+    remove_argument (N, &argc, argv);
+    IsCSV = TRUE;
+  }
+
   if ((argc < 3) || !(argc % 2)) {
     gprint (GP_ERR, "USAGE: read name N name N ...\n");
@@ -58,4 +64,9 @@
   }
   fseeko (f, 0LL, SEEK_SET);
+
+//  if (IsCSV) {
+//    status = read_vectors_csv (argc, argv, Nskip, f);
+//    return status;
+//  }
 
   Nvec = (argc - 1) / 2;
@@ -73,12 +84,28 @@
     colstr = argv[2*i+2];
     for (j = 0; j < strlen (colstr); j++) {
-      if (!isdigit(colstr[j])) {
-	gprint (GP_ERR, "USAGE: read name N name N ...\n");
-	free (vec);
-	free (col);
-	return (FALSE);    
-      }
-    }
-    col[i] = atof (colstr);
+      if (isdigit(colstr[j])) {
+	col[i] = atof (colstr);
+	continue;
+      }
+      // allow 'excel' columns names of the form A-Z, AA-AZ, BA-BZ, .. ZA-ZZ
+      if (strlen(colstr) >= 3) goto bad_colname;
+      if (colstr[0] < 'A') goto bad_colname;
+      if (colstr[0] > 'Z') goto bad_colname;
+      if (colstr[1] && colstr[1] < 'A') goto bad_colname;
+      if (colstr[1] && colstr[1] > 'Z') goto bad_colname;
+
+      col[i] = colstr[0] - 'A' + 1;
+      if (colstr[1]) {
+	col[i] *= 26;
+	col[i] += colstr[1] - 'A' + 1;
+      }
+      continue;
+
+    bad_colname:
+      gprint (GP_ERR, "USAGE: read name N name N ...\n");
+      free (vec);
+      free (col);
+      return (FALSE);    
+    }
   }
 
@@ -94,4 +121,7 @@
     scan_line (f, buffer);
   }
+
+  int Nfield = 0;
+  int Nline = 0;
 
   Nstart = 0;
@@ -122,10 +152,22 @@
       if ((*c0 != '#') && (*c0 != '!')) {
 	for (i = 0; (i < Nvec) && status; i++) {
-	  status = dparse (&value, col[i], c0);
+	  if (IsCSV) {
+	    status = dparse_csv (&value, col[i], c0);
+	  } else {
+	    status = dparse (&value, col[i], c0);
+	  }
 	  vec[i][0].elements.Flt[N] = value;
+	  if (status) {
+	      Nfield ++;
+	  }
 	  if (!status) vec[i][0].elements.Flt[N] = NAN;
 	}
 	if (status) N++;
       }
+      Nline ++;
+      if (c1) {
+	  // fprintf (stderr, "line %d, chars %ld, fields %d\n", Nline, (c1 - c0), Nfield);
+      }
+      Nfield = 0;
       c0 = c1 + 1;
       if (N == NELEM) {
@@ -341,2 +383,104 @@
   return (TRUE);
 }
+
+# if (0)
+int read_vectors_csv (int argc, char **argv, int Nskip, FILE *f) {
+  
+  int i, j, Nvec, *col, done, status;
+  int Nbytes, nbytes, Nstart, NELEM, N, nread;
+  char *colstr, *c0, *c1, *buffer, *extname;
+  double value;
+  Vector **vec;
+
+  Nvec = (argc - 1) / 2;
+  ALLOCATE (vec, Vector *, Nvec);
+  ALLOCATE (col, int, Nvec);
+
+  for (i = 0; i < Nvec; i++) {
+    if ((vec[i] = SelectVector (argv[2*i + 1], ANYVECTOR, TRUE)) == NULL) {
+      gprint (GP_ERR, "USAGE: read name N name N ...\n");
+      free (vec);
+      free (col);
+      return (FALSE);    
+    }
+    // XXX we could allow flags (eg, N.i) to specify INT vs FLT types vectors...
+    colstr = argv[2*i+2];
+    for (j = 0; j < strlen (colstr); j++) {
+      if (!isdigit(colstr[j])) {
+	gprint (GP_ERR, "USAGE: read name N name N ...\n");
+	free (vec);
+	free (col);
+	return (FALSE);    
+      }
+    }
+    col[i] = atof (colstr);
+  }
+
+  // currently, all read vectors are forced to be type FLT
+  NELEM = 1000;
+  for (i = 0; i < Nvec; i++) {
+    ResetVector (vec[i], OPIHI_FLT, NELEM);
+  }
+  
+  ALLOCATE (buffer, char, 0x10001);
+  bzero (buffer, 0x10001);
+  for (i = 0; i < Nskip; i++) {
+    scan_line (f, buffer);
+  }
+
+  Nstart = 0;
+  N = 0;
+  done = FALSE;
+  while (!done) {
+    Nbytes = 0x10000 - Nstart;
+    bzero (&buffer[Nstart], Nbytes);
+    nread = fread (&buffer[Nstart], 1, Nbytes, f);
+    if (ferror (f)) {
+      perror ("error reading data file");
+      break;
+    }
+    if (nread == 0) break;
+    nbytes = nread + Nstart;
+    
+    status = TRUE;
+    c0 = buffer; 
+    while (status) {
+      c1 = strchr (c0, '\n');
+      if (c1 == (char *) NULL) {
+	Nstart = strlen (c0);
+	memmove (buffer, c0, Nstart);
+	status = FALSE;
+      } else {
+	*c1 = 0;
+      }      
+      if ((*c0 != '#') && (*c0 != '!')) {
+	for (i = 0; (i < Nvec) && status; i++) {
+	  status = dparse_csv (&value, col[i], c0);
+	  vec[i][0].elements.Flt[N] = value;
+	  if (!status) vec[i][0].elements.Flt[N] = NAN;
+	}
+	if (status) N++;
+      }
+      c0 = c1 + 1;
+      if (N == NELEM) {
+	NELEM += 1000;
+	for (i = 0; i < Nvec; i++) {
+	  REALLOCATE (vec[i][0].elements.Flt, opihi_flt, NELEM);
+	}
+      }
+	
+    }
+  }
+  for (i = 0; i < Nvec; i++) {
+    REALLOCATE (vec[i][0].elements.Flt, opihi_flt, MAX (N,1));
+    vec[i][0].Nelements = N;
+  }
+  
+  free (vec);
+  free (col);
+  free (buffer);
+  return (TRUE);
+
+}
+
+# endif
Index: trunk/Ohana/src/opihi/cmd.data/test/csv.dat
===================================================================
--- trunk/Ohana/src/opihi/cmd.data/test/csv.dat	(revision 31667)
+++ trunk/Ohana/src/opihi/cmd.data/test/csv.dat	(revision 31667)
@@ -0,0 +1,3 @@
+word,1,5,10
+foo,2,4,8
+sam,3,3,6
Index: trunk/Ohana/src/opihi/cmd.data/test/csv1.dat
===================================================================
--- trunk/Ohana/src/opihi/cmd.data/test/csv1.dat	(revision 31667)
+++ trunk/Ohana/src/opihi/cmd.data/test/csv1.dat	(revision 31667)
@@ -0,0 +1,3 @@
+word,1,5,10
+foo,,4,8
+sam,3,,6
Index: trunk/Ohana/src/opihi/cmd.data/tvcolors.c
===================================================================
--- trunk/Ohana/src/opihi/cmd.data/tvcolors.c	(revision 31666)
+++ trunk/Ohana/src/opihi/cmd.data/tvcolors.c	(revision 31667)
@@ -5,5 +5,5 @@
   int N, kapa;
   char *name;
-  KapaImageData data;
+  // KapaImageData data;
 
   name = NULL;
@@ -13,5 +13,5 @@
     remove_argument (N, &argc, argv);
   }
-  if (!GetImage (&data, &kapa, name)) return (FALSE);
+  if (!GetGraph (NULL, &kapa, name)) return (FALSE);
   FREE (name);
 
Index: trunk/Ohana/src/opihi/cmd.data/zplot.c
===================================================================
--- trunk/Ohana/src/opihi/cmd.data/zplot.c	(revision 31666)
+++ trunk/Ohana/src/opihi/cmd.data/zplot.c	(revision 31667)
@@ -58,3 +58,60 @@
 }
 
+int zcplot (int argc, char **argv) {
+  
+  int i, kapa;
+  opihi_flt *out;
+  double min, range;
+  Graphdata graphmode;
+  Vector *xvec, *yvec, *zvec, Zvec;
 
+  if (!style_args (&graphmode, &argc, argv, &kapa)) return (FALSE);
+
+  if (argc != 6) {
+    gprint (GP_ERR, "USAGE: zplot <x> <y> <z> min max\n");
+    return (FALSE);
+  }
+
+  min = atof(argv[4]);
+  range = atof(argv[5]) - min;
+
+  /* find vectors */
+  if ((xvec = SelectVector (argv[1], OLDVECTOR, TRUE)) == NULL) return (FALSE);
+  if ((yvec = SelectVector (argv[2], OLDVECTOR, TRUE)) == NULL) return (FALSE);
+  if ((zvec = SelectVector (argv[3], OLDVECTOR, TRUE)) == NULL) return (FALSE);
+  if (xvec[0].Nelements != yvec[0].Nelements) {
+    gprint (GP_ERR, "vectors %s and %s not the same length\n", argv[1], argv[2]);
+    return (FALSE);
+  }
+  if (xvec[0].Nelements != zvec[0].Nelements) {
+    gprint (GP_ERR, "vectors %s and %s not the same length\n", argv[1], argv[3]);
+    return (FALSE);
+  }
+  SetVector (&Zvec, OPIHI_FLT, zvec[0].Nelements);
+  out = Zvec.elements.Flt;
+ 
+  if (zvec[0].type == OPIHI_FLT) {
+    opihi_flt *in = zvec[0].elements.Flt;
+    for (i = 0; i < Zvec.Nelements; i++, in++, out++) {
+      *out = MIN (1.0, MAX (0.01, (*in - min) / range));
+    }
+  } else {
+    opihi_int *in = zvec[0].elements.Int;
+    for (i = 0; i < Zvec.Nelements; i++, in++, out++) {
+      *out = MIN (1.0, MAX (0.01, (*in - min) / range));
+    }
+  }
+
+  /* point size determined by Zvec */
+  graphmode.style = 2; /* plot points */
+  graphmode.color = -1; /* point color determined by Zvec */
+  graphmode.etype = 0; /* no errorbars */
+  PlotVectorTriplet (kapa, xvec, yvec, &Zvec, &graphmode);
+
+  free (Zvec.elements.Ptr);
+
+  return (TRUE);
+
+}
+
+
Index: trunk/Ohana/src/opihi/dvo/gstar.c
===================================================================
--- trunk/Ohana/src/opihi/dvo/gstar.c	(revision 31666)
+++ trunk/Ohana/src/opihi/dvo/gstar.c	(revision 31667)
@@ -155,5 +155,5 @@
     if (dec1 < DEC[i]) found = TRUE;
     
-    r = SQ(Dec - DEC[i]) + SQ(Ra - RA[i]);
+    r = SQ(Dec - DEC[i]) + SQ((Ra - RA[i])*cos(Dec*RAD_DEG));
     if (r < Radius2) {
       k = N1[i];
Index: trunk/Ohana/src/opihi/include/pantasks.h
===================================================================
--- trunk/Ohana/src/opihi/include/pantasks.h	(revision 31666)
+++ trunk/Ohana/src/opihi/include/pantasks.h	(revision 31667)
@@ -108,4 +108,5 @@
   int Nfailure;
   int Ntimeout;
+  int Nskipexec;
 
   double dtimeAve_alljobs, dtimeMin_alljobs, dtimeMax_alljobs;
@@ -216,4 +217,5 @@
 int DeleteJob (Job *job);
 void FreeJob (Job *job);
+char *JobStateToString (JobStat state);
 
 float CheckJobs (void);
Index: trunk/Ohana/src/opihi/include/shell.h
===================================================================
--- trunk/Ohana/src/opihi/include/shell.h	(revision 31666)
+++ trunk/Ohana/src/opihi/include/shell.h	(revision 31667)
@@ -163,4 +163,7 @@
 char 	     *strip_version 		PROTO((char *input));
 
+// wrap readline in ohana mem functions:
+char         *opihi_readline            PROTO((char *prompt));
+
 /* gprint functions */
 void          gprintInit      		PROTO((void));
Index: trunk/Ohana/src/opihi/lib.shell/CommandOps.c
===================================================================
--- trunk/Ohana/src/opihi/lib.shell/CommandOps.c	(revision 31666)
+++ trunk/Ohana/src/opihi/lib.shell/CommandOps.c	(revision 31667)
@@ -106,4 +106,19 @@
 }  
 
+/* we need a strcreate function that does NOT use the ohana memory management
+ * system to interact with some external libraries (which themselves free the memory)
+ */
+char *strcreate_sans_ohana (char *string) {
+
+  char *line;
+
+  if (string == (char *) NULL) return ((char *) NULL);
+  
+  line = malloc (MAX (1, strlen(string)) + 1);
+  line = strcpy (line, string);
+
+  return (line);
+}
+
 /* generate a command completion list for readline */
 /**** these probably do not interact well with OHANA memory!!! ****/
@@ -122,7 +137,9 @@
   for (i++; i < Ncommands; i++) {
     if (!len) 
-      return (strcreate(commands[i].name));
+
+
+      return (strcreate_sans_ohana(commands[i].name));
     if (!strncmp (commands[i].name, text, len)) {
-      return (strcreate(commands[i].name));
+      return (strcreate_sans_ohana(commands[i].name));
     }
   }
Index: trunk/Ohana/src/opihi/lib.shell/macro_create.c
===================================================================
--- trunk/Ohana/src/opihi/lib.shell/macro_create.c	(revision 31666)
+++ trunk/Ohana/src/opihi/lib.shell/macro_create.c	(revision 31667)
@@ -68,8 +68,9 @@
 
     /* get the next line (from correct place) */
-    if (ThisList == 0) 
-      input = readline (prompt);
-    else 
+    if (ThisList == 0) {
+      input = opihi_readline (prompt);
+    } else {
       input = get_next_listentry (ThisList);
+    }
 
     if ((ThisList == 0) && (input == (char *) NULL)) {
@@ -77,5 +78,4 @@
       continue;
     }
-    if (ThisList == 0) ohana_memregister (input);
 
     if ((ThisList > 0) && (input == (char *) NULL)) {
Index: trunk/Ohana/src/opihi/lib.shell/opihi.c
===================================================================
--- trunk/Ohana/src/opihi/lib.shell/opihi.c	(revision 31666)
+++ trunk/Ohana/src/opihi/lib.shell/opihi.c	(revision 31667)
@@ -19,5 +19,5 @@
     if (Nbad == 10) exit (20);
 
-    line = readline (prompt);
+    line = opihi_readline (prompt);
 
     if (line == NULL) { 
@@ -36,5 +36,4 @@
 
     Nbad = 0;
-    ohana_memregister (line);
 
     stripwhite (line);
Index: trunk/Ohana/src/opihi/lib.shell/string.c
===================================================================
--- trunk/Ohana/src/opihi/lib.shell/string.c	(revision 31666)
+++ trunk/Ohana/src/opihi/lib.shell/string.c	(revision 31667)
@@ -276,4 +276,17 @@
 }
 
+char *opihi_readline (char *prompt) {
+
+# ifdef OHANA_MEMORY
+    char *raw = readline (prompt);
+    char *line = strcreate (raw);
+    real_free (raw);
+    return line;
+# else
+    char *line = readline (prompt);
+    return line;
+# endif
+}
+
 /* replace all instances of \A with A in line */
 void interpolate_slash (char *line) {
