Index: /branches/eam_branches/ipp-20111122/Ohana/src/photdbc/Makefile
===================================================================
--- /branches/eam_branches/ipp-20111122/Ohana/src/photdbc/Makefile	(revision 33584)
+++ /branches/eam_branches/ipp-20111122/Ohana/src/photdbc/Makefile	(revision 33585)
@@ -1,5 +1,5 @@
-default: photdbc dvodist
+default: photdbc photdbc_client dvodist
 help:
-	@echo "make options: photdbc (default)"
+	@echo "make options: photdbc photdbc_client dvodist"
 
 include ../../Makefile.System
@@ -18,9 +18,23 @@
 
 photdbc: $(BIN)/photdbc.$(ARCH)
+photdbc_client: $(BIN)/photdbc_client.$(ARCH)
+
 dvodist: $(BIN)/dvodist.$(ARCH)
-install: $(DESTBIN)/photdbc $(DESTBIN)/dvodist
+
+install: $(DESTBIN)/photdbc $(DESTBIN)/photdbc_client $(DESTBIN)/dvodist
 
 PHOTDBC = \
 $(SRC)/photdbc.$(ARCH).o	   \
+$(SRC)/photdbc_catalogs.$(ARCH).o  \
+$(SRC)/initialize.$(ARCH).o	   \
+$(SRC)/ConfigInit.$(ARCH).o	   \
+$(SRC)/args.$(ARCH).o		   \
+$(SRC)/copy_images.$(ARCH).o	   \
+$(SRC)/Shutdown.$(ARCH).o          \
+$(SRC)/join_stars.$(ARCH).o        \
+$(SRC)/make_subcatalog.$(ARCH).o        
+
+PHOTDBC_CLIENT = \
+$(SRC)/photdbc_client.$(ARCH).o	   \
 $(SRC)/photdbc_catalogs.$(ARCH).o  \
 $(SRC)/initialize.$(ARCH).o	   \
@@ -72,4 +86,7 @@
 $(BIN)/photdbc.$(ARCH): $(PHOTDBC)
 
+$(PHOTDBC_CLIENT): $(INC)/photdbc.h
+$(BIN)/photdbc_client.$(ARCH): $(PHOTDBC_CLIENT)
+
 $(DVODIST): $(INC)/dvodist.h
 $(BIN)/dvodist.$(ARCH): $(DVODIST)
Index: /branches/eam_branches/ipp-20111122/Ohana/src/photdbc/include/dvodist.h
===================================================================
--- /branches/eam_branches/ipp-20111122/Ohana/src/photdbc/include/dvodist.h	(revision 33584)
+++ /branches/eam_branches/ipp-20111122/Ohana/src/photdbc/include/dvodist.h	(revision 33585)
@@ -26,4 +26,6 @@
 char     *srcHostname;
 char     *dstHostname;
+
+# define MAX_PATH_LENGTH 1024
 
 void          usage();
Index: /branches/eam_branches/ipp-20111122/Ohana/src/photdbc/include/photdbc.h
===================================================================
--- /branches/eam_branches/ipp-20111122/Ohana/src/photdbc/include/photdbc.h	(revision 33584)
+++ /branches/eam_branches/ipp-20111122/Ohana/src/photdbc/include/photdbc.h	(revision 33585)
@@ -30,4 +30,6 @@
 // need to get RADIUS from Config 
 
+# define MAX_PATH_LENGTH 1024
+
 /* global variables */
 int    SHOW_PARAMS;
@@ -36,10 +38,10 @@
 double UNIQ_RADIUS;
 double DMCAL_MIN;;
-char   ImageCat[256];
-char   GSCFILE[256];
-char   CATDIR[256];
-char   CATMODE[16];    /* raw, mef, split, mysql */
-char   CATFORMAT[16];  /* internal, elixir, loneos, panstarrs */
-char   PhotCodeFile[256];
+char   ImageCat[MAX_PATH_LENGTH];
+char   GSCFILE[MAX_PATH_LENGTH];
+char   CATDIR[MAX_PATH_LENGTH];
+char  *CATMODE;    /* raw, mef, split, mysql */
+char  *CATFORMAT;  /* internal, elixir, loneos, panstarrs */
+char   PhotCodeFile[MAX_PATH_LENGTH];
 
 double RMIN;
@@ -132,4 +134,6 @@
 void usage();
 
-int photdbc_catalogs (SkyList *skylist, int hostID);
-int photdbc_parallel (SkyList *skylist);
+int photdbc_catalogs (char *outroot, SkyList *skylist, int hostID);
+int photdbc_parallel (char *outroot, SkyList *skylist);
+int args_client (int argc, char **argv);
+void initialize_client (int argc, char **argv);
Index: /branches/eam_branches/ipp-20111122/Ohana/src/photdbc/src/ConfigInit.c
===================================================================
--- /branches/eam_branches/ipp-20111122/Ohana/src/photdbc/src/ConfigInit.c	(revision 33584)
+++ /branches/eam_branches/ipp-20111122/Ohana/src/photdbc/src/ConfigInit.c	(revision 33585)
@@ -52,8 +52,12 @@
   ScanConfig (config, "NMEAS_MIN_FILTERED",     "%d",  0, &NMEAS_MIN_FILTERED);
 
-  WarnConfig (config, "GSCFILE",                "%s",  0, GSCFILE);
+  // do not apply this limit for now
+  NCODE_MIN = 0;
+
   WarnConfig (config, "CATDIR",                 "%s",  0, CATDIR);
-  ScanConfig (config, "CATMODE",                "%s",  0, CATMODE);
-  ScanConfig (config, "CATFORMAT",              "%s",  0, CATFORMAT);
+  char *tmpcatdir = abspath (CATDIR, MAX_PATH_LENGTH);
+  strcpy (CATDIR, tmpcatdir);
+  free (tmpcatdir);
+
   ScanConfig (config, "PHOTCODE_FILE",         	"%s",  0, MasterPhotcodeFile);
 
@@ -67,11 +71,8 @@
   }
 
-  if (*CATMODE == 0) strcpy (CATMODE, "RAW");
-  if (*CATFORMAT == 0) strcpy (CATFORMAT, "ELIXIR");
-
   /* XXX this does not yet write out the master photcode table */
   sprintf (CatdirPhotcodeFile, "%s/Photcodes.dat", CATDIR);
-  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile, TRUE)) {
-    fprintf (stderr, "error loading photcode table %s or master file %s\n", CatdirPhotcodeFile, MasterPhotcodeFile);
+  if (!LoadPhotcodes (CatdirPhotcodeFile, NULL, TRUE)) {
+    fprintf (stderr, "error loading photcode table %s\n", CatdirPhotcodeFile);
     exit (1);
   }
Index: /branches/eam_branches/ipp-20111122/Ohana/src/photdbc/src/args.c
===================================================================
--- /branches/eam_branches/ipp-20111122/Ohana/src/photdbc/src/args.c	(revision 33584)
+++ /branches/eam_branches/ipp-20111122/Ohana/src/photdbc/src/args.c	(revision 33585)
@@ -40,4 +40,20 @@
     remove_argument (N, &argc, argv);
     MAX_MIN_MAG = atof(argv[N]);
+    remove_argument (N, &argc, argv);
+  }
+
+  // override input catalog format (PS1_V1, PS1_REF, etc)
+  CATFORMAT = NULL;
+  if ((N = get_argument (argc, argv, "-set-format"))) {
+    remove_argument (N, &argc, argv);
+    CATFORMAT = strcreate (argv[N]);
+    remove_argument (N, &argc, argv);
+  }
+
+  // override input catalog mode (raw, mef, split, mysql)
+  CATMODE = NULL;
+  if ((N = get_argument (argc, argv, "-set-mode"))) {
+    remove_argument (N, &argc, argv);
+    CATMODE = strcreate (argv[N]);
     remove_argument (N, &argc, argv);
   }
@@ -127,4 +143,138 @@
 }
 
+int args_client (int argc, char **argv) {
+
+  int N;
+
+  PARALLEL = FALSE;
+  PARALLEL_MANUAL = FALSE;
+  PARALLEL_SERIAL = FALSE;
+
+  HOST_ID = 0;
+  if ((N = get_argument (argc, argv, "-hostID"))) {
+    remove_argument (N, &argc, argv);
+    HOST_ID = atoi (argv[N]);
+    remove_argument (N, &argc, argv);
+  }
+  if (!HOST_ID) usage();
+
+  HOSTDIR = NULL;
+  if ((N = get_argument (argc, argv, "-hostdir"))) {
+    remove_argument (N, &argc, argv);
+    HOSTDIR = strcreate (argv[N]);
+    remove_argument (N, &argc, argv);
+  }
+  if (!HOSTDIR) usage();
+
+  VERBOSE = FALSE;
+  if ((N = get_argument (argc, argv, "-v"))) {
+    VERBOSE = TRUE;
+    remove_argument (N, &argc, argv);
+  }
+
+  SHOW_PARAMS = FALSE;
+  if ((N = get_argument (argc, argv, "-params"))) {
+    remove_argument (N, &argc, argv);
+    SHOW_PARAMS = TRUE;
+  }
+
+  ExcludeByInstMag = FALSE;
+  if ((N = get_argument (argc, argv, "-instmag"))) {
+    ExcludeByInstMag = TRUE;
+    remove_argument (N, &argc, argv);
+    INST_MAG_MIN = atof(argv[N]);
+    remove_argument (N, &argc, argv);
+    INST_MAG_MAX = atof(argv[N]);
+    remove_argument (N, &argc, argv);
+  }
+
+  ExcludeByMinSigma = FALSE;
+  if ((N = get_argument (argc, argv, "-min-sigma"))) {
+    ExcludeByMinSigma = TRUE;
+    remove_argument (N, &argc, argv);
+    SIGMA_MIN_KEEP = atof(argv[N]);
+    remove_argument (N, &argc, argv);
+  }
+
+  ExcludeByMaxMinMag = FALSE;
+  if ((N = get_argument (argc, argv, "-maxminmag"))) {
+    ExcludeByMaxMinMag = TRUE;
+    remove_argument (N, &argc, argv);
+    MAX_MIN_MAG = atof(argv[N]);
+    remove_argument (N, &argc, argv);
+  }
+
+  // override input catalog format (PS1_V1, PS1_REF, etc)
+  CATFORMAT = NULL;
+  if ((N = get_argument (argc, argv, "-set-format"))) {
+    remove_argument (N, &argc, argv);
+    CATFORMAT = strcreate (argv[N]);
+    remove_argument (N, &argc, argv);
+  }
+
+  // override input catalog mode (raw, mef, split, mysql)
+  CATMODE = NULL;
+  if ((N = get_argument (argc, argv, "-set-mode"))) {
+    remove_argument (N, &argc, argv);
+    CATMODE = strcreate (argv[N]);
+    remove_argument (N, &argc, argv);
+  }
+
+  /* specify portion of the sky */
+  REGION.Rmin = 0;
+  REGION.Rmax = 360;
+  REGION.Dmin = -90;
+  REGION.Dmax = +90;
+  if ((N = get_argument (argc, argv, "-region"))) {
+    remove_argument (N, &argc, argv);
+    REGION.Rmin = atof (argv[N]);
+    remove_argument (N, &argc, argv);
+    REGION.Rmax = atof (argv[N]);
+    remove_argument (N, &argc, argv);
+    REGION.Dmin = atof (argv[N]);
+    remove_argument (N, &argc, argv);
+    REGION.Dmax = atof (argv[N]);
+    remove_argument (N, &argc, argv);
+
+    if (REGION.Rmin == REGION.Rmax) {
+      fprintf (stderr, "ERROR: selected region is ill-defined: Rmin == Rmax\n");
+      exit (2);
+    }
+    if (REGION.Dmin == REGION.Dmax) {
+      fprintf (stderr, "ERROR: selected region is ill-defined: Dmin == Dmax\n");
+      exit (2);
+    }
+  }
+
+  PHOTCODE_DROP_LIST = NULL;
+  if ((N = get_argument (argc, argv, "-photcode-drop"))) {
+    remove_argument (N, &argc, argv);
+    PHOTCODE_DROP_LIST = strcreate(argv[N]);
+    remove_argument (N, &argc, argv);
+  }
+
+  PHOTCODE_SKIP_LIST = NULL;
+  if ((N = get_argument (argc, argv, "-photcode-skip"))) {
+    remove_argument (N, &argc, argv);
+    PHOTCODE_SKIP_LIST = strcreate(argv[N]);
+    remove_argument (N, &argc, argv);
+  }
+
+  if (argc != 2) usage();
+
+  if ((REGION.Rmin == 0) && (REGION.Rmax == 360) && (REGION.Dmin == -90) && (REGION.Dmax == +90)) {
+    int i;
+    fprintf (stderr, "you have requested a copy of the entire sky in one pass\n");
+    fprintf (stderr, "this could be a time consuming operation.  type Ctrl-C within 5 seconds to cancel\n");
+    for (i = 5; i > 0; i--) {
+      fprintf (stderr, "%d.. ", i);
+      usleep (1000000);
+    }
+    fprintf (stderr, "\n");
+  }
+
+  return (TRUE);
+}
+
 void usage() {
 
Index: /branches/eam_branches/ipp-20111122/Ohana/src/photdbc/src/copy_images.c
===================================================================
--- /branches/eam_branches/ipp-20111122/Ohana/src/photdbc/src/copy_images.c	(revision 33584)
+++ /branches/eam_branches/ipp-20111122/Ohana/src/photdbc/src/copy_images.c	(revision 33585)
@@ -41,6 +41,6 @@
   if (out.dbstate != LCK_EMPTY) Shutdown ("ERROR: image table exists %s", ImageOut);
 
-  out.mode   = dvo_catalog_catmode (CATMODE);
-  out.format = dvo_catalog_catformat (CATFORMAT);
+  out.mode   = CATMODE   ? dvo_catalog_catmode (CATMODE)     : in.mode;
+  out.format = CATFORMAT ? dvo_catalog_catformat (CATFORMAT) : in.format;
   dvo_image_create (&out, ZERO_POINT);
     
Index: /branches/eam_branches/ipp-20111122/Ohana/src/photdbc/src/initialize.c
===================================================================
--- /branches/eam_branches/ipp-20111122/Ohana/src/photdbc/src/initialize.c	(revision 33584)
+++ /branches/eam_branches/ipp-20111122/Ohana/src/photdbc/src/initialize.c	(revision 33585)
@@ -12,6 +12,6 @@
   args (argc, argv);
 
-  photcodesDrop = ParsePhotcodeList (PHOTCODE_DROP_LIST, &NphotcodeDrop, FALSE);
-  photcodesSkip = ParsePhotcodeList (PHOTCODE_SKIP_LIST, &NphotcodeSkip, FALSE);
+  photcodesDrop = ParsePhotcodeList (PHOTCODE_DROP_LIST, &NphotcodesDrop, FALSE);
+  photcodesSkip = ParsePhotcodeList (PHOTCODE_SKIP_LIST, &NphotcodesSkip, FALSE);
 
   if (SHOW_PARAMS) {
@@ -41,2 +41,43 @@
   }
 }
+
+void initialize_client (int argc, char **argv) {
+
+  /* are these set correctly? */
+  if (get_argument (argc, argv, "-h")) usage();
+  if (get_argument (argc, argv, "--h")) usage();
+  if (get_argument (argc, argv, "-help")) usage();
+  if (get_argument (argc, argv, "--help")) usage();
+
+  ConfigInit (&argc, argv);
+  args_client (argc, argv);
+
+  photcodesDrop = ParsePhotcodeList (PHOTCODE_DROP_LIST, &NphotcodesDrop, FALSE);
+  photcodesSkip = ParsePhotcodeList (PHOTCODE_SKIP_LIST, &NphotcodesSkip, FALSE);
+
+  if (SHOW_PARAMS) {
+    fprintf (stderr, "current parameter settings:\n");
+    fprintf (stderr, "VERBOSE:                %d\n", VERBOSE);
+    fprintf (stderr, "JOIN_RADIUS:           %lf\n", JOIN_RADIUS);
+    fprintf (stderr, "UNIQ_RADIUS:           %lf\n", UNIQ_RADIUS);
+						     
+    fprintf (stderr, "XMIN:                  %lf\n", XMIN);
+    fprintf (stderr, "XMAX:                  %lf\n", XMAX);
+    fprintf (stderr, "YMIN:                  %lf\n", YMIN);
+    fprintf (stderr, "YMAX:                  %lf\n", YMAX);
+    fprintf (stderr, "MMIN:                  %lf\n", MMIN);
+    fprintf (stderr, "MMAX:                  %lf\n", MMAX);
+    fprintf (stderr, "DMCAL_MIN:             %lf\n", DMCAL_MIN);
+    fprintf (stderr, "DMSYS:                 %lf\n", DMSYS);
+						     
+    fprintf (stderr, "CHISQ_MAX:             %lf\n", CHISQ_MAX);
+    fprintf (stderr, "NMEAS_MIN:             %d\n",  NMEAS_MIN);
+
+    fprintf (stderr, "IMAGE_CATALOG          %s\n",  ImageCat);
+    fprintf (stderr, "GSCFILE                %s\n",  GSCFILE);
+    fprintf (stderr, "CATDIR                 %s\n",  CATDIR);
+    fprintf (stderr, "PHOTCODE_FILE          %s\n",  PhotCodeFile);
+
+    exit (0);
+  }
+}
Index: /branches/eam_branches/ipp-20111122/Ohana/src/photdbc/src/md5_ops.c
===================================================================
--- /branches/eam_branches/ipp-20111122/Ohana/src/photdbc/src/md5_ops.c	(revision 33584)
+++ /branches/eam_branches/ipp-20111122/Ohana/src/photdbc/src/md5_ops.c	(revision 33585)
@@ -60,7 +60,7 @@
   IOBuffer buffer;
 
-  char line[1024];
-  int Nline = snprintf (line, 1024, "md5sum %s\n", filename);
-  assert (Nline < 1024);
+  char line[MAX_PATH_LENGTH];
+  int Nline = snprintf (line, MAX_PATH_LENGTH, "md5sum %s\n", filename);
+  assert (Nline < MAX_PATH_LENGTH);
 
   write (host->stdio[0], line, Nline);
@@ -72,5 +72,5 @@
   fprintf (stderr, "buffer: %s\n", buffer.buffer);
 
-  char result[1024], fileout[1024];
+  char result[MAX_PATH_LENGTH], fileout[MAX_PATH_LENGTH];
   int Nscan = sscanf (buffer.buffer, "%s %s", result, fileout);
   assert (Nscan == 2);
@@ -86,7 +86,7 @@
   IOBuffer buffer, stdout_buf, stderr_buf;
 
-  char line[1024];
-  int Nline = snprintf (line, 1024, "job md5sum %s\n", filename);
-  assert (Nline < 1024);
+  char line[MAX_PATH_LENGTH];
+  int Nline = snprintf (line, MAX_PATH_LENGTH, "job md5sum %s\n", filename);
+  assert (Nline < MAX_PATH_LENGTH);
 
   // fprintf (stderr, "command: %s\n", line);
@@ -119,5 +119,5 @@
   // fprintf (stderr, "result from md5sum: %s\n", stdout_buf.buffer);
 
-  char result[1024], fileout[1024];
+  char result[MAX_PATH_LENGTH], fileout[MAX_PATH_LENGTH];
   int Nscan = sscanf (stdout_buf.buffer, "%s %s", result, fileout);
   if (Nscan != 2) {
Index: /branches/eam_branches/ipp-20111122/Ohana/src/photdbc/src/photdbc.c
===================================================================
--- /branches/eam_branches/ipp-20111122/Ohana/src/photdbc/src/photdbc.c	(revision 33584)
+++ /branches/eam_branches/ipp-20111122/Ohana/src/photdbc/src/photdbc.c	(revision 33585)
@@ -13,10 +13,13 @@
 
   // the output catalog needs to inherit the SKY_DEPTH of the input catalog
-  sky = SkyTableLoadOptimal (CATDIR, NULL, GSCFILE, TRUE, SKY_DEPTH_HST, VERBOSE);
+  sky = SkyTableLoadOptimal (CATDIR, NULL, NULL, TRUE, 0, VERBOSE);
   SkyTableSetFilenames (sky, CATDIR, "cpt");
   skylist = SkyListByPatch (sky, -1, &REGION);
 
   // hostID is 0 for master program
-  photdbc_catalogs (skylist, 0);
+  photdbc_catalogs (argv[1], skylist, 0);
+
+  char *skyfile = SkyTableFilename (argv[1]);
+  SkyTableSave (sky, skyfile);
   exit (0);
 }
Index: /branches/eam_branches/ipp-20111122/Ohana/src/photdbc/src/photdbc_catalogs.c
===================================================================
--- /branches/eam_branches/ipp-20111122/Ohana/src/photdbc/src/photdbc_catalogs.c	(revision 33584)
+++ /branches/eam_branches/ipp-20111122/Ohana/src/photdbc/src/photdbc_catalogs.c	(revision 33585)
@@ -1,14 +1,14 @@
 # include "photdbc.h"
+# define DEBUG 1
 
-int photdbc_catalogs (SkyList *skylist, int hostID) {
+int photdbc_catalogs (char *outroot, SkyList *skylist, int hostID) {
 
   int i;
-  char *skyfile;
   Catalog incatalog;
   Catalog outcatalog;
 
   if (PARALLEL && !hostID) {
-      photdbc_parallel (skylist);
-      exit (0);
+    photdbc_parallel (outroot, skylist);
+    return FALSE;
   }
 
@@ -20,6 +20,6 @@
 
     // set the parameters which guide catalog open/load/create
-    char hostfile[1024];
-    snprintf (hostfile, 1024, "%s/%s.cpt", hostpath, skylist[0].regions[i]->name);
+    char hostfile[MAX_PATH_LENGTH];
+    snprintf (hostfile, MAX_PATH_LENGTH, "%s/%s.cpt", HOSTDIR, skylist[0].regions[i]->name);
     incatalog.filename  = hostID ? hostfile : skylist[0].filename[i];
     incatalog.Nsecfilt = GetPhotcodeNsecfilt ();
@@ -39,10 +39,12 @@
 
     // create output catalog filename
-    outcatalog.filename = strsubs (incatalog.filename, CATDIR, argv[1]);
+    char outfile[MAX_PATH_LENGTH];
+    snprintf (outfile, MAX_PATH_LENGTH, "%s/%s.cpt", outroot, skylist[0].regions[i]->name);
+    outcatalog.filename = outfile;
     if (outcatalog.filename == NULL) Shutdown ("error with input catalog name");
 
     // define outcatalog open parameters
-    outcatalog.catformat = dvo_catalog_catformat (CATFORMAT);  // set the default catformat from config data
-    outcatalog.catmode   = dvo_catalog_catmode (CATMODE);      // set the default catmode from config data
+    outcatalog.catformat = CATFORMAT ? dvo_catalog_catformat (CATFORMAT) : incatalog.catformat;
+    outcatalog.catmode   = CATMODE   ? dvo_catalog_catmode (CATMODE)     : incatalog.catmode;
     outcatalog.Nsecfilt  = incatalog.Nsecfilt;                 // inherit from the incatalog
     outcatalog.catflags  = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;
@@ -79,10 +81,8 @@
   }
 
-  skyfile = SkyTableFilename (argv[1]);
-  SkyTableSave (sky, skyfile);
-  exit (0);
+  return TRUE;
 }
 
-int photdbc_parallel (SkyList *skylist) {
+int photdbc_parallel (char *outroot, SkyList *skylist) {
 
   // launch the photdbo_client jobs to the parallel hosts
@@ -103,16 +103,24 @@
     table->hosts[i].pathname = tmppath;
 
+    // ensure that the paths are absolute path names
+    char *tmproot = abspath (outroot, MAX_PATH_LENGTH);
+
     // options / arguments that can affect relastro_client -update-objects:
-    char command[1024];
-    snprintf (command, 1024, "photdbc_client -hostID %d -D CATDIR %s -hostdir %s -region %f %f %f %f", 
-	      table->hosts[i].hostID, CATDIR, table->hosts[i].pathname, REGION.Rmin, REGION.Rmax, REGION.Dmin, REGION.Dmax);
+    char command[MAX_PATH_LENGTH];
+    snprintf (command, MAX_PATH_LENGTH, "photdbc_client %s -hostID %d -D CATDIR %s -hostdir %s -region %f %f %f %f -D NMEAS_MIN %d -D NMEAS_MIN_FILTERED %d -D AVE_SIGMA_LIM %f -D SIGMA_MAX %f", 
+	      tmproot, table->hosts[i].hostID, CATDIR, table->hosts[i].pathname, 
+	      REGION.Rmin, REGION.Rmax, REGION.Dmin, REGION.Dmax,
+	      NMEAS_MIN, NMEAS_MIN_FILTERED, AVE_SIGMA_LIM, SIGMA_MAX
+      );
 
-    char tmpline[1024];
-    if (VERBOSE)            { snprintf (tmpline, 1024, "%s -v",                command);                             strcpy (command, tmpline); }
-    if (ExcludeByInstMag)   { snprintf (tmpline, 1024, "%s -instmag %f %f",    command, INST_MAG_MIN, INST_MAG_MAX); strcpy (command, tmpline); }
-    if (ExcludeByMinSigma)  { snprintf (tmpline, 1024, "%s -min-sigma %f",     command, SIGMA_MIN_KEEP); 	     strcpy (command, tmpline); }
-    if (ExcludeByMaxMinMag) { snprintf (tmpline, 1024, "%s -maxminmag %f",     command, MAX_MIN_MAG);    	     strcpy (command, tmpline); }
-    if (PHOTCODE_DROP_LIST) { snprintf (tmpline, 1024, "%s -photcode-drop %s", command, PHOTCODE_DROP_LIST); 	     strcpy (command, tmpline); }
-    if (PHOTCODE_SKIP_LIST) { snprintf (tmpline, 1024, "%s -photcode-skip %s", command, PHOTCODE_SKIP_LIST); 	     strcpy (command, tmpline); }
+    char tmpline[MAX_PATH_LENGTH];
+    if (VERBOSE)            { snprintf (tmpline, MAX_PATH_LENGTH, "%s -v",                command);                             strcpy (command, tmpline); }
+    if (ExcludeByInstMag)   { snprintf (tmpline, MAX_PATH_LENGTH, "%s -instmag %f %f",    command, INST_MAG_MIN, INST_MAG_MAX); strcpy (command, tmpline); }
+    if (ExcludeByMinSigma)  { snprintf (tmpline, MAX_PATH_LENGTH, "%s -min-sigma %f",     command, SIGMA_MIN_KEEP); 	        strcpy (command, tmpline); }
+    if (ExcludeByMaxMinMag) { snprintf (tmpline, MAX_PATH_LENGTH, "%s -maxminmag %f",     command, MAX_MIN_MAG);    	        strcpy (command, tmpline); }
+    if (PHOTCODE_DROP_LIST) { snprintf (tmpline, MAX_PATH_LENGTH, "%s -photcode-drop %s", command, PHOTCODE_DROP_LIST); 	strcpy (command, tmpline); }
+    if (PHOTCODE_SKIP_LIST) { snprintf (tmpline, MAX_PATH_LENGTH, "%s -photcode-skip %s", command, PHOTCODE_SKIP_LIST); 	strcpy (command, tmpline); }
+    if (CATFORMAT)          { snprintf (tmpline, MAX_PATH_LENGTH, "%s -catformat %s",     command, CATFORMAT); 	                strcpy (command, tmpline); }
+    if (CATMODE)            { snprintf (tmpline, MAX_PATH_LENGTH, "%s -catmode %s",       command, CATMODE);        	        strcpy (command, tmpline); }
 
     fprintf (stderr, "command: %s\n", command);
Index: /branches/eam_branches/ipp-20111122/Ohana/src/photdbc/src/photdbc_client.c
===================================================================
--- /branches/eam_branches/ipp-20111122/Ohana/src/photdbc/src/photdbc_client.c	(revision 33585)
+++ /branches/eam_branches/ipp-20111122/Ohana/src/photdbc/src/photdbc_client.c	(revision 33585)
@@ -0,0 +1,25 @@
+# include "photdbc.h"
+
+int main (int argc, char **argv) {
+
+  initialize_client (argc, argv);
+
+  // load the current sky table (layout of all SkyRegions) 
+  SkyTable *sky = SkyTableLoadOptimal (CATDIR, NULL, NULL, TRUE, -1, VERBOSE);
+  if (!sky) {
+      fprintf (stderr, "ERROR running loading sky table from %s\n", CATDIR);
+      exit (2);
+  }
+  SkyTableSetFilenames (sky, CATDIR, "cpt");
+
+  SkyList *skylist = SkyListByPatch (sky, -1, &REGION);
+  if (!skylist) {
+      fprintf (stderr, "ERROR setting up skylist for %s\n", CATDIR);
+      exit (2);
+  }
+  
+  // hostID is 0 for master program
+  photdbc_catalogs (argv[1], skylist, HOST_ID);
+
+  exit (0);
+}
