Index: trunk/Ohana/src/relastro/include/relastro.h
===================================================================
--- trunk/Ohana/src/relastro/include/relastro.h	(revision 35763)
+++ trunk/Ohana/src/relastro/include/relastro.h	(revision 36630)
@@ -6,4 +6,13 @@
 # include <pthread.h>
 
+# define MARKTIME(MSG,...) {			\
+    gettimeofday (&stopTimer, (void *) NULL);	\
+    float dtime = DTIME (stopTimer, startTimer);	\
+    fprintf (stderr, MSG, __VA_ARGS__); }
+
+# define INITTIME \
+  struct timeval startTimer, stopTimer; \
+  gettimeofday (&startTimer, (void *) NULL);
+
 // choose off_t or int depending on full-scale relphot analysis resources
 // # define IDX_T off_t
@@ -20,5 +29,7 @@
 typedef enum {FIT_NONE, FIT_AVERAGE, FIT_PM_ONLY, FIT_PAR_ONLY, FIT_PM_AND_PAR} FitMode;
 
-typedef enum {TARGET_NONE, TARGET_SIMPLE, TARGET_CHIPS, TARGET_MOSAICS, TARGET_HIGH_SPEED, TARGET_MERGE_SOURCE, TARGET_UPDATE_OBJECTS, TARGET_UPDATE_OFFSETS, TARGET_LOAD_OBJECTS, TARGET_HPM} FitTarget;
+typedef enum {OP_NONE, OP_IMAGES, OP_HIGH_SPEED, OP_MERGE_SOURCE, OP_UPDATE_OBJECTS, OP_UPDATE_OFFSETS, OP_LOAD_OBJECTS, OP_HPM, OP_PARALLEL_REGIONS, OP_PARALLEL_IMAGES} RelastroOp;
+
+typedef enum {TARGET_NONE, TARGET_SIMPLE, TARGET_CHIPS, TARGET_MOSAICS} FitTarget;
 
 typedef enum {
@@ -30,4 +41,20 @@
   MARK_BIG_OFFSET    = 0x0010,
 } MeasurementMask;
+
+typedef struct {
+  float R;
+  float D;
+  unsigned int objID;
+  unsigned int catID;
+} MeanPos;
+
+typedef struct {
+  Coords coords;
+  float dXpixSys;
+  float dYpixSys;
+  unsigned int imageID;
+  int nFitAstrom;
+  int flags;
+} ImagePos;
 
 typedef struct {
@@ -93,4 +120,5 @@
   unsigned int start;
   unsigned int stop;
+  off_t myImage;
   float Mcal;
   float dMcal;
@@ -113,10 +141,4 @@
 } StatType;
 
-# define MARKTIME(MSG,...) { \
-  float dtime; \
-  gettimeofday (&stop, (void *) NULL); \
-  dtime = DTIME (stop, start); \
-  fprintf (stderr, MSG, __VA_ARGS__); }
-
 /* global variables set in parameter file */
 # define DVO_MAX_PATH 1024
@@ -129,4 +151,10 @@
 char   SKY_TABLE[DVO_MAX_PATH];
 int    SKY_DEPTH;  /** XXX EAM : depth of catalog tables, fix usage */
+
+// globals for parallel region operations
+char  *REGION_FILE;
+char  *IMAGE_TABLE;
+int    REGION_HOST_ID;
+int    PARALLEL_REGIONS_MANUAL;
 
 int          HOST_ID;
@@ -208,4 +236,5 @@
 FitMode FIT_MODE;
 
+RelastroOp RELASTRO_OP;
 FitTarget FIT_TARGET;
 
@@ -450,2 +479,44 @@
 int hpm_catalogs_parallel (SkyList *skylist);
 int hpm_objects (SkyRegion *region, Catalog *catalog);
+
+int strextend (char *input, char *format,...);
+int launch_region_hosts (RegionHostTable *regionHosts);
+
+int assign_images (FITS_DB *db, RegionHostTable *regionHosts);
+int select_images_hostregion (RegionHostTable *regionHosts, Image *image, off_t Nimage);
+int calculate_image_bounds (Image *image, double *rmin, double *rmax, double *dmin, double *dmax, double Rmid);
+int calculate_host_image_bounds (RegionHostTable *regionHosts);
+int find_host_for_coords (RegionHostTable *regionHosts, double Rc, double Dc);
+
+int relastro_parallel_regions ();
+int relastro_parallel_images ();
+
+char *make_filename (char *dirname, char *hostname, int hostID, char *tailname);
+int check_sync_file (char *filename, int nloop);
+int clear_sync_file (char *filename);
+int update_sync_file (char *filename, int nloop);
+
+int share_mean_pos (Catalog *catalog, int Ncatalog, RegionHostTable *regionHosts, int nloop);
+int slurp_mean_pos (Catalog *catalog, int Ncatalog, RegionHostTable *regionHosts, int nloop);
+int set_mean_pos (MeanPos *meanpos, Average *average);
+MeanPos *merge_mean_pos (MeanPos *target, int *ntarget, MeanPos *source, int Nsource);
+
+int MeanPosSave(char *filename, MeanPos *meanpos, off_t Nmeanpos);
+MeanPos *MeanPosLoad(char *filename, off_t *nmeanpos);
+
+int indexCatalogs (Catalog *catalog, int Ncatalog);
+int catID_and_objID_to_seq (int catID, int objID, int *catSeq, off_t *objSeq);
+
+int markObjects (Catalog *catalog, int Ncatalog);
+
+int ImagePosSave(char *filename, ImagePos *image_pos, off_t Nimage_pos);
+ImagePos *ImagePosLoad(char *filename, off_t *nimage_pos);
+
+int share_image_pos (RegionHostTable *regionHosts, int nloop);
+int slurp_image_pos (RegionHostTable *regionHosts, int nloop);
+ImagePos *merge_image_pos (ImagePos *target, int *ntarget, ImagePos *source, int Nsource);
+int set_image_pos (ImagePos *image_pos, Image *image);
+
+Image *ImageTableLoad(char *filename, off_t *nimage);
+int ImageTableSave (char *filename, Image *images, off_t Nimages);
+int select_mosaics_hostregion (RegionHostTable *regionHosts, Image *image, off_t Nimage);
