# include "relphot.h"

int main (int argc, char **argv) {

  // get configuration info, args
  RelphotMode mode = initialize (argc, argv);
  if (!mode) exit (2);

  switch (mode) {
    case UPDATE_IMAGES:
      relphot_images ();
      exit (0);

    case UPDATE_AVERAGES:
      // take the current set of detections and set the mean magnitudes
      relphot_objects (0, NULL);
      exit (0);

    case PARALLEL_REGIONS:
      // run image updates in parallel across multiple remote machines
      relphot_parallel_regions ();
      exit (0);

    case PARALLEL_IMAGES:
      // operation on the remote machines in the PARALLEL_REGION mode
      relphot_parallel_images ();
      exit (0);

    case APPLY_OFFSETS:
      // re-run this step from a previous attempt (assumes an existing Images.subset.dat file)
      if (!PARALLEL) {
	fprintf (stderr, "-apply-offsets only makes sense in an parallel context\n");
	exit (2);
      }
      reload_catalogs (NULL, NULL, 0, NULL);
      exit (0);

    default:
      fprintf (stderr, "ERROR: no valid relphot mode chosen\n");
      exit (2);
  }
  fprintf (stderr, "IMPOSSIBLE: skipped out of switch?\n");
  exit (1);
}
