Index: trunk/Ohana/src/addstar/include/loadgalphot.h
===================================================================
--- trunk/Ohana/src/addstar/include/loadgalphot.h	(revision 38570)
+++ trunk/Ohana/src/addstar/include/loadgalphot.h	(revision 38600)
@@ -36,9 +36,9 @@
 } GalPhotIDset;
 
-AddstarClientOptions args_loadgalphot (int argc, char **argv, AddstarClientOptions options);
+AddstarClientOptions args_loadgalphot (int *argc, char **argv, AddstarClientOptions options);
 
 int loadgalphot_table (SkyList *skylistInput, HostTable *hosts, char *filename, AddstarClientOptions *options);
 
-GalPhot_Stars *loadgalphot_readstars (char *filename, int *nstars);
+GalPhot_Stars *loadgalphot_readstars (char *filename, int *nstars, AddstarClientOptions *options);
 
 int loadgalphot_sortStars (GalPhot_Stars *stars, int Nstars);
Index: trunk/Ohana/src/addstar/src/args_loadgalphot.c
===================================================================
--- trunk/Ohana/src/addstar/src/args_loadgalphot.c	(revision 38570)
+++ trunk/Ohana/src/addstar/src/args_loadgalphot.c	(revision 38600)
@@ -4,11 +4,11 @@
 static void help (void);
 
-AddstarClientOptions args_loadgalphot (int argc, char **argv, AddstarClientOptions options) {
+AddstarClientOptions args_loadgalphot (int *argc, char **argv, AddstarClientOptions options) {
   
   int N;
 
   /* check for help request */
-  if (get_argument (argc, argv, "-help") ||
-      get_argument (argc, argv, "-h")) {
+  if (get_argument (*argc, argv, "-help") ||
+      get_argument (*argc, argv, "-h")) {
     help ();
   }
@@ -27,20 +27,20 @@
   HOST_ID = 0;
   PARALLEL = FALSE;
-  if ((N = get_argument (argc, argv, "-parallel"))) {
+  if ((N = get_argument (*argc, argv, "-parallel"))) {
     PARALLEL = TRUE;
-    remove_argument (N, &argc, argv);
+    remove_argument (N, argc, argv);
   }
   // this is a test mode : rather than launching the remote jobs and waiting for completion,
   // relphot will simply list the remote command and wait for the user to signal completion
   PARALLEL_MANUAL = FALSE;
-  if ((N = get_argument (argc, argv, "-parallel-manual"))) {
+  if ((N = get_argument (*argc, argv, "-parallel-manual"))) {
     PARALLEL = TRUE; // -parallel-manual implies -parallel
     PARALLEL_MANUAL = TRUE;
-    remove_argument (N, &argc, argv);
+    remove_argument (N, argc, argv);
   }
   // this is a test mode : rather than launching the relphot_client jobs remotely, they are 
   // run in serial via 'system'
   PARALLEL_SERIAL = FALSE;
-  if ((N = get_argument (argc, argv, "-parallel-serial"))) {
+  if ((N = get_argument (*argc, argv, "-parallel-serial"))) {
     if (PARALLEL_MANUAL) {
       fprintf (stderr, "ERROR: cannot mix -parallel-manual and -parallel-serial\n");
@@ -49,35 +49,46 @@
     PARALLEL = TRUE; // -parallel-serial implies -parallel
     PARALLEL_SERIAL = TRUE;
-    remove_argument (N, &argc, argv);
+    remove_argument (N, argc, argv);
   }
 
   /* only add to existing regions */
   options.existing_regions = FALSE;
-  if ((N = get_argument (argc, argv, "-existing-regions"))) {
+  if ((N = get_argument (*argc, argv, "-existing-regions"))) {
     options.existing_regions = TRUE;
-    remove_argument (N, &argc, argv);
+    remove_argument (N, argc, argv);
   }
   /* only add to existing objects */
   options.only_match = FALSE;
-  if ((N = get_argument (argc, argv, "-only-match"))) {
+  if ((N = get_argument (*argc, argv, "-only-match"))) {
     options.only_match = TRUE;
-    remove_argument (N, &argc, argv);
+    remove_argument (N, argc, argv);
   }
   /* replace measurement, don't duplicate (ref/cat only) */
   options.replace = FALSE;
-  if ((N = get_argument (argc, argv, "-replace"))) {
+  if ((N = get_argument (*argc, argv, "-replace"))) {
     options.replace = TRUE;
-    remove_argument (N, &argc, argv);
+    remove_argument (N, argc, argv);
+  }
+  /* override any header PHOTCODE values */
+  options.photcode = 0;
+  if ((N = get_argument (*argc, argv, "-p"))) {
+    remove_argument (N, argc, argv);
+    options.photcode = GetPhotcodeCodebyName (argv[N]);
+    remove_argument (N, argc, argv);
+  }
+  if ((N = get_argument (*argc, argv, "-photcode"))) {
+    remove_argument (N, argc, argv);
+    options.photcode = GetPhotcodeCodebyName (argv[N]);
+    remove_argument (N, argc, argv);
   }
 
   /* extra error messages */
   VERBOSE = FALSE;
-  if ((N = get_argument (argc, argv, "-v"))) {
+  if ((N = get_argument (*argc, argv, "-v"))) {
     VERBOSE = TRUE;
-    remove_argument (N, &argc, argv);
+    remove_argument (N, argc, argv);
   }
 
   /* other addstar options which cannot be used in loadgalphot */
-  options.photcode = 0;
   options.timeref = 0; 
   options.mosaic = FALSE;
@@ -95,5 +106,5 @@
   DUMP = NULL;
 
-  if (argc < 2) {
+  if (*argc < 2) {
     fprintf (stderr, "USAGE: loadgalphot [options] (fitsfile) [..more files]\n");
     exit (2);
Index: trunk/Ohana/src/addstar/src/loadgalphot.c
===================================================================
--- trunk/Ohana/src/addstar/src/loadgalphot.c	(revision 38570)
+++ trunk/Ohana/src/addstar/src/loadgalphot.c	(revision 38600)
@@ -14,5 +14,5 @@
   // need to construct these options with args_loadgalphot...
   options = ConfigInit (&argc, argv);
-  options = args_loadgalphot (argc, argv, options);
+  options = args_loadgalphot (&argc, argv, options);
 
   // load the full sky description table (dvodb must exist)
Index: trunk/Ohana/src/addstar/src/loadgalphot_readstars.c
===================================================================
--- trunk/Ohana/src/addstar/src/loadgalphot_readstars.c	(revision 38570)
+++ trunk/Ohana/src/addstar/src/loadgalphot_readstars.c	(revision 38600)
@@ -15,6 +15,7 @@
 
 static float *chisqFit = NULL;
-
-GalPhot_Stars *loadgalphot_readstars (char *filename, int *nstars) {
+static float ZeroPt = 0;
+
+GalPhot_Stars *loadgalphot_readstars (char *filename, int *nstars, AddstarClientOptions *options) {
 
   // read in the full FITS files ('cause I don't have a partial read option)
@@ -67,4 +68,6 @@
     namehash[i][2] = -1;
   }
+
+  ZeroPt = GetZeroPoint();
 
   char name[256], tmpname[256];
@@ -228,4 +231,5 @@
     stars[i].galphot.modelType = MODEL_TYPE_gal[i];
     stars[i].galphot.detID     = ID_gal[i];
+    stars[i].galphot.photcode  = options->photcode;
 
     // I have a grid of measurements with (Flux, dFlux, Chisq) at each point
@@ -377,5 +381,5 @@
 
   // use bilinear interpolation to choose Flux @ (Xmin,Ymin)?
-  galphot->mag    = -2.5*log10(flux[iMin]); // correct for exptime?
+  galphot->mag    = -2.5*log10(flux[iMin]) + ZeroPt; // correct for exptime?
   galphot->magErr = sqrt(fluxErr[iMin]) / flux[iMin];
   galphot->chisq  = chisqMin;
Index: trunk/Ohana/src/addstar/src/loadgalphot_table.c
===================================================================
--- trunk/Ohana/src/addstar/src/loadgalphot_table.c	(revision 38570)
+++ trunk/Ohana/src/addstar/src/loadgalphot_table.c	(revision 38600)
@@ -6,5 +6,5 @@
   int i, Nstars;
 
-  GalPhot_Stars *stars = loadgalphot_readstars (filename, &Nstars);
+  GalPhot_Stars *stars = loadgalphot_readstars (filename, &Nstars, options);
 
   // sort the stars by RA
