Index: /branches/eam_branches/ipp-20120405/Ohana/src/addstar/Makefile
===================================================================
--- /branches/eam_branches/ipp-20120405/Ohana/src/addstar/Makefile	(revision 33898)
+++ /branches/eam_branches/ipp-20120405/Ohana/src/addstar/Makefile	(revision 33899)
@@ -29,7 +29,7 @@
 mkcmf       : $(BIN)/mkcmf.$(ARCH)
 
-all: addstar sedstar load2mass skycells mkcmf loadwise loadsupercos dumpskycells
-
-INSTALL = addstar sedstar load2mass skycells mkcmf loadwise loadsupercos dumpskycells
+all: addstar addstar_client sedstar load2mass skycells mkcmf loadwise loadsupercos dumpskycells
+
+INSTALL = addstar addstar_client sedstar load2mass skycells mkcmf loadwise loadsupercos dumpskycells
 
 # I need to fix the client/server version of addstar now that I have dropped Stars
@@ -98,4 +98,5 @@
 $(SRC)/SkyListForStars.$(ARCH).o \
 $(SRC)/SkyRegionUtils.$(ARCH).o \
+$(SRC)/build_links.$(ARCH).o \
 $(SRC)/addstar_client.$(ARCH).o \
 $(SRC)/args_parallel_client.$(ARCH).o \
@@ -298,26 +299,28 @@
 $(SRC)/SetSignals.$(ARCH).o \
 
-$(ADDSTARC)   : $(INC)/addstar.h
-$(ADDSTARD)   : $(INC)/addstar.h
-$(ADDSTART)   : $(INC)/addstar.h
-$(ADDSTAR)    : $(INC)/addstar.h
-$(SKYCELLS)   : $(INC)/addstar.h
-$(DUMPSKYCELLS): $(INC)/addstar.h
-$(LOAD-2MASS) : $(INC)/addstar.h $(INC)/2mass.h
-$(LOAD-WISE)  : $(INC)/addstar.h $(INC)/WISE.h
-$(MKCMF)      : $(INC)/mkcmf.h
-
-$(BIN)/addstar.$(ARCH) 	   : $(ADDSTAR)
-$(BIN)/addstard.$(ARCH)	   : $(ADDSTARD)
-$(BIN)/addstart.$(ARCH)	   : $(ADDSTART)
-$(BIN)/addstarc.$(ARCH)	   : $(ADDSTARC)
-$(BIN)/mkacc-2mass.$(ARCH) : $(MKACC-2MASS)
-$(BIN)/sedstar.$(ARCH)     : $(SEDSTAR)
-$(BIN)/load2mass.$(ARCH)   : $(LOAD-2MASS)
-$(BIN)/loadwise.$(ARCH)    : $(LOAD-WISE)
-$(BIN)/loadsupercos.$(ARCH): $(LOAD-SUPERCOS)
-$(BIN)/skycells.$(ARCH)    : $(SKYCELLS)
-$(BIN)/dumpskycells.$(ARCH) : $(DUMPSKYCELLS)
-$(BIN)/mkcmf.$(ARCH)       : $(MKCMF)
+$(ADDSTARC)   	  : $(INC)/addstar.h
+$(ADDSTARD)   	  : $(INC)/addstar.h
+$(ADDSTART)   	  : $(INC)/addstar.h
+$(ADDSTAR)    	  : $(INC)/addstar.h
+$(ADDSTAR_CLIENT) : $(INC)/addstar.h
+$(SKYCELLS)    	  : $(INC)/addstar.h
+$(DUMPSKYCELLS)	  : $(INC)/addstar.h
+$(LOAD-2MASS)  	  : $(INC)/addstar.h $(INC)/2mass.h
+$(LOAD-WISE)   	  : $(INC)/addstar.h $(INC)/WISE.h
+$(MKCMF)       	  : $(INC)/mkcmf.h
+
+$(BIN)/addstar.$(ARCH) 	      : $(ADDSTAR)
+$(BIN)/addstar_client.$(ARCH) : $(ADDSTAR_CLIENT)
+$(BIN)/addstard.$(ARCH)	      : $(ADDSTARD)
+$(BIN)/addstart.$(ARCH)	      : $(ADDSTART)
+$(BIN)/addstarc.$(ARCH)	      : $(ADDSTARC)
+$(BIN)/mkacc-2mass.$(ARCH)    : $(MKACC-2MASS)
+$(BIN)/sedstar.$(ARCH)        : $(SEDSTAR)
+$(BIN)/load2mass.$(ARCH)      : $(LOAD-2MASS)
+$(BIN)/loadwise.$(ARCH)       : $(LOAD-WISE)
+$(BIN)/loadsupercos.$(ARCH)   : $(LOAD-SUPERCOS)
+$(BIN)/skycells.$(ARCH)       : $(SKYCELLS)
+$(BIN)/dumpskycells.$(ARCH)   : $(DUMPSKYCELLS)
+$(BIN)/mkcmf.$(ARCH)          : $(MKCMF)
 
 # I need to fix the client/server version of addstar now that I have dropped Stars
Index: /branches/eam_branches/ipp-20120405/Ohana/src/addstar/include/addstar.h
===================================================================
--- /branches/eam_branches/ipp-20120405/Ohana/src/addstar/include/addstar.h	(revision 33898)
+++ /branches/eam_branches/ipp-20120405/Ohana/src/addstar/include/addstar.h	(revision 33899)
@@ -64,7 +64,7 @@
 
 /* globals which define database info / data sources (KEEP) */
-char   ImageCat[256];
+char   ImageCat[DVO_MAX_PATH];
 char   GSCFILE[256];
-char   CATDIR[256];
+char  *CATDIR;
 char   CATMODE[16];    /* raw, mef, split, mysql */
 char   CATFORMAT[16];  /* internal, elixir, loneos, panstarrs */
@@ -166,6 +166,7 @@
 /*** addstar prototypes ***/
 
-AddstarClientOptions ConfigInit   PROTO((int *argc, char **argv));
-AddstarClientOptions args         PROTO((int argc, char **argv, AddstarClientOptions options));
+AddstarClientOptions ConfigInit   	  PROTO((int *argc, char **argv));
+AddstarClientOptions args         	  PROTO((int argc, char **argv, AddstarClientOptions options));
+AddstarClientOptions args_parallel_client PROTO((int argc, char **argv, AddstarClientOptions options));
 
 void       AddToCalibration       PROTO((Average *average, SecFilt *secfilt, Measure *measure, Measure *new, off_t *next, off_t Nstar));
Index: /branches/eam_branches/ipp-20120405/Ohana/src/addstar/src/ConfigInit.c
===================================================================
--- /branches/eam_branches/ipp-20120405/Ohana/src/addstar/src/ConfigInit.c	(revision 33898)
+++ /branches/eam_branches/ipp-20120405/Ohana/src/addstar/src/ConfigInit.c	(revision 33899)
@@ -125,6 +125,10 @@
   ScanConfig (config, "TYCHO_DIR",             	"%s",  0, TYCHO_DIR);
 
+  // force CATDIR to be absolute (so parallel mode will work)
+  char tmpcatdir[DVO_MAX_PATH];
+  GetConfig (config, "CATDIR" ,                 "%s",  0, tmpcatdir);
+  CATDIR = abspath (tmpcatdir, DVO_MAX_PATH);
+
   GetConfig (config, "GSCFILE",                	"%s",  0, GSCFILE);
-  GetConfig (config, "CATDIR",                 	"%s",  0, CATDIR);
   GetConfig (config, "PHOTCODE_FILE",          	"%s",  0, MasterPhotcodeFile);
   ScanConfig (config, "CATMODE",                "%s",  0, CATMODE);
Index: /branches/eam_branches/ipp-20120405/Ohana/src/addstar/src/addstar_client.c
===================================================================
--- /branches/eam_branches/ipp-20120405/Ohana/src/addstar/src/addstar_client.c	(revision 33898)
+++ /branches/eam_branches/ipp-20120405/Ohana/src/addstar/src/addstar_client.c	(revision 33899)
@@ -24,5 +24,5 @@
   SkyTableSetFilenames (sky, CATDIR, "cpt");
 
-  if (options.mode == M_RESORT) {
+  if (options.mode == ADDSTAR_MODE_RESORT) {
     resort_unthreaded (&options, sky, HOST_ID, HOSTDIR);
     exit (0);
Index: /branches/eam_branches/ipp-20120405/Ohana/src/addstar/src/args_parallel_client.c
===================================================================
--- /branches/eam_branches/ipp-20120405/Ohana/src/addstar/src/args_parallel_client.c	(revision 33898)
+++ /branches/eam_branches/ipp-20120405/Ohana/src/addstar/src/args_parallel_client.c	(revision 33899)
@@ -8,8 +8,7 @@
 //   options.nosort
 
-AddstarClientOptions args (int argc, char **argv, AddstarClientOptions options) {
+AddstarClientOptions args_parallel_client (int argc, char **argv, AddstarClientOptions options) {
   
-  int i, N;
-  int QUALITY_AIRMASS;
+  int N;
 
   NREFSTAR_GROUP = 1; // not used by -resort
@@ -22,4 +21,6 @@
     help ();
   }
+
+  memset (&options, 0, sizeof(AddstarClientOptions));
 
   /* basic mode: image, list, refcat */
@@ -73,5 +74,5 @@
 
   /*** modify behavior ***/
-  /* only add to existing objects */
+  /* only add to or resort existing objects */
   options.existing_regions = FALSE;
   if ((N = get_argument (argc, argv, "-existing-regions"))) {
@@ -80,17 +81,5 @@
   }
 
-  /* don't re-sort the measure sequence */
-  options.nosort = FALSE;
-  if ((N = get_argument (argc, argv, "-nosort"))) {
-    options.nosort = TRUE;
-    remove_argument (N, &argc, argv);
-  }
-  /* only add new rows (-update) or re-write complete measure table (forces -nosort) */
-  options.update = FALSE;
-  if ((N = get_argument (argc, argv, "-update"))) {
-    options.update = TRUE;
-    options.nosort = TRUE;
-    remove_argument (N, &argc, argv);
-  }
+  // resort even tables that claim to have been sorted
   if ((N = get_argument (argc, argv, "-force-sort"))) {
     options.nosort = 3;  // temporary mode to mean 'force-sort'
Index: /branches/eam_branches/ipp-20120405/Ohana/src/addstar/src/resort_unthreaded.c
===================================================================
--- /branches/eam_branches/ipp-20120405/Ohana/src/addstar/src/resort_unthreaded.c	(revision 33898)
+++ /branches/eam_branches/ipp-20120405/Ohana/src/addstar/src/resort_unthreaded.c	(revision 33899)
@@ -40,9 +40,9 @@
   }
 
-  resort_unthreaded_catalogs (options, 0, NULL)
+  resort_unthreaded_catalogs (options, skylist, 0, NULL);
 
   gettimeofday (&stop, NULL);
   dtime = DTIME (stop, start);
-  fprintf (stderr, "SUCCESS: elapsed time %9.4f sec for, "OFF_T_FMT" average, "OFF_T_FMT" measure\n", dtime, Naverage, Nmeasure);
+  fprintf (stderr, "SUCCESS: elapsed time %9.4f sec\n", dtime);
 
   return TRUE;
Index: /branches/eam_branches/ipp-20120405/Ohana/src/addstar/src/resort_unthreaded_catalogs.c
===================================================================
--- /branches/eam_branches/ipp-20120405/Ohana/src/addstar/src/resort_unthreaded_catalogs.c	(revision 33898)
+++ /branches/eam_branches/ipp-20120405/Ohana/src/addstar/src/resort_unthreaded_catalogs.c	(revision 33899)
@@ -1,3 +1,5 @@
 # include "addstar.h"
+
+int resort_unthreaded_parallel (AddstarClientOptions *options, SkyList *sky);
 
 // pass in options and skylist?
@@ -92,6 +94,7 @@
 
     char tmpline[1024];
-    if (VERBOSE)       { snprintf (tmpline, 1024, "%s -v",              command);                    strcpy (command, tmpline); }
-    if (VERBOSE2)      { snprintf (tmpline, 1024, "%s -vv",             command); 		     strcpy (command, tmpline); }
+    if (VERBOSE)                   { snprintf (tmpline, 1024, "%s -v",                command); strcpy (command, tmpline); }
+    if (options->nosort == 3)      { snprintf (tmpline, 1024, "%s -force-sort",       command); strcpy (command, tmpline); }
+    if (options->existing_regions) { snprintf (tmpline, 1024, "%s -existing-regions", command); strcpy (command, tmpline); }
 
     fprintf (stderr, "command: %s\n", command);
