IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 36519


Ignore:
Timestamp:
Feb 18, 2014, 9:08:37 AM (12 years ago)
Author:
eugene
Message:

relphot parallel almost builds (but not quite)

Location:
branches/eam_branches/ipp-20140206/Ohana/src
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20140206/Ohana/src/libdvo/include/dvo.h

    r36518 r36519  
    409409  uint32_t       flags;
    410410  int            catID;
     411  int            nOwn;
    411412} AverageTiny;
    412413
  • branches/eam_branches/ipp-20140206/Ohana/src/libdvo/src/RegionHostTable.c

    r36518 r36519  
    8585    if (line[i] == '#') continue;
    8686    if (line[i] == 0) continue;
     87
     88    UserPatch.Rmin = 360;
     89    UserPatch.Rmax =   0;
     90    UserPatch.Dmin = +90;
     91    UserPatch.Dmax = -90;
    8792
    8893    double Rmin, Rmax, Dmin, Dmax;
     
    116121    hosts[Nhosts].Dmax = Dmax;
    117122   
     123    UserPatch.Rmin = MIN(Rmin, UserPatch.Rmin);
     124    UserPatch.Rmax = MIN(Rmax, UserPatch.Rmax);
     125    UserPatch.Dmin = MIN(Dmin, UserPatch.Dmin);
     126    UserPatch.Dmax = MIN(Dmax, UserPatch.Dmax);
     127
    118128    // InitIOBuffer (&hosts[Nhosts].stdout, 1000);
    119129    // InitIOBuffer (&hosts[Nhosts].stderr, 1000);
     
    147157  return table;
    148158}
     159
     160// wait for all children to complete, report output to stdout
     161int RegionHostTableWaitJobs (RegionHostTable *regionHosts, char *file, int lineno) {
     162
     163  int i;
     164
     165  // we have launched regionHosts->Nhosts jobs; wait for all of them to complete...
     166  // if one (N) failed to launch, we will get an ECHILD error from the last (N) calls
     167  int done = FALSE;
     168  for (i = 0; !done  && (i < regionHosts->Nhosts); i++) {
     169    int status = 0;
     170
     171    // XXX we'll need to pass in WNOHANG and keep retrying if we want to have a timeout...
     172    int pid = waitpid (-1, &status, 0);
     173    if (!pid) {
     174      // this should only occur if we called waitpid with the WNOHANG option
     175      fprintf (stderr, "programming error (1)? %s %d", file, lineno);
     176      exit (2);
     177    }
     178    if (pid == -1) {
     179      switch (errno) {
     180        case ECHILD:
     181          done = TRUE;
     182          break;
     183        default:
     184          fprintf (stderr, "programming error (2)? %s %d", file, lineno);
     185          exit (2);
     186      }
     187    }
     188
     189    // when the host has finished, close the open sockets
     190
     191    // find the host which has finished
     192    int Nout, j;
     193    int found = FALSE;
     194    for (j = 0; j < regionHosts->Nhosts; j++) {
     195      if (regionHosts->hosts[j].pid != pid) continue;
     196      found = TRUE;
     197      // check on the status of this and report any output?
     198      fprintf (stderr, "job finished for %s (%d)\n", regionHosts->hosts[j].hostname, pid);
     199      // read the stderr and stdout
     200      IOBuffer buffer;
     201      InitIOBuffer (&buffer, 100);
     202      EmptyIOBuffer (&buffer, 100, regionHosts->hosts[j].stdio[HOST_STDOUT]);
     203      fprintf (stderr, "--- stdout from %s ---\n", regionHosts->hosts[j].hostname);
     204      Nout = write (STDOUT_FILENO, buffer.buffer, buffer.Nbuffer);
     205      if (Nout != buffer.Nbuffer) { fprintf (stderr, "(error writing log?)\n"); }
     206      fprintf (stderr, "\n");
     207         
     208      InitIOBuffer (&buffer, 100);
     209      EmptyIOBuffer (&buffer, 100, regionHosts->hosts[j].stdio[HOST_STDERR]);
     210      fprintf (stderr, "--- stderr from %s ---\n", regionHosts->hosts[j].hostname);
     211      Nout = write (STDOUT_FILENO, buffer.buffer, buffer.Nbuffer);
     212      if (Nout != buffer.Nbuffer) { fprintf (stderr, "(error writing log?)\n"); }
     213      fprintf (stderr, "\n");
     214      if (WIFEXITED(status)) {
     215        fprintf (stderr, "normal completion, exit status is %d\n", WEXITSTATUS(status));
     216        regionHosts->hosts[j].status = WEXITSTATUS(status);
     217        if (regionHosts->hosts[j].status) {
     218          fprintf (stderr, "job failed on %s\n", regionHosts->hosts[j].hostname);
     219          continue;
     220        }
     221      } else {
     222        regionHosts->hosts[j].status = -1;
     223        fprintf (stderr, "job exited abnormally on %s\n", regionHosts->hosts[j].hostname);
     224        continue;
     225      }
     226    }
     227    if (!found) {
     228      fprintf (stderr, "Programming error: failed to matched finished job to known host!\n");
     229      exit (2);
     230    }
     231  }
     232  return TRUE;
     233}
     234
  • branches/eam_branches/ipp-20140206/Ohana/src/libdvo/src/dvo_catalog.c

    r36518 r36519  
    119119  average->measureOffset   = -1;
    120120  average->catID           = 0;
     121  average->nOwn            = 0;
    121122}
    122123
  • branches/eam_branches/ipp-20140206/Ohana/src/relphot/include/relphot.h

    r36518 r36519  
    178178char   SKY_TABLE[DVO_MAX_PATH];
    179179int    SKY_DEPTH;  /** XXX EAM : depth of catalog tables, fix usage */
     180
     181// globals for parallel region operations
     182char  *REGION_FILE;
     183char  *IMAGE_TABLE;
     184int    REGION_HOST_ID;
    180185
    181186int          HOST_ID;
     
    290295void          InterpolateGrid     PROTO((float *buffer, int Nx, int Ny, Coords *ccd, Coords *gcoords));
    291296off_t        *SelectRefMosaic     PROTO((Mosaic **refmosaic, off_t *Nimage));
    292 int           args                PROTO((int argc, char **argv));
     297RelphotMode   args                PROTO((int argc, char **argv));
    293298int           args_client         PROTO((int argc, char **argv));
    294299int           bcatalog            PROTO((Catalog *subcatalog, Catalog *catalog, int Ncat));
     
    339344void          initMosaics         PROTO((Image *subset, off_t Nsubset, Image *image, char *inSubset, off_t Nimage));
    340345void          initMrel            PROTO((Catalog *catalog, int Ncatalog));
    341 void          initialize          PROTO((int argc, char **argv));
     346RelphotMode   initialize          PROTO((int argc, char **argv));
    342347void          initialize_client   PROTO((int argc, char **argv));
    343348void          liststats_setmode   PROTO((StatType *stats, char *strmode));
     
    487492ImageMag *ImageMagLoad(char *filename, off_t *nimage_mags);
    488493int ImageMagSave(char *filename, ImageMag *image_mags, off_t Nimage_mags);
     494
     495int markObjects (Catalog *catalog, int Ncatalog);
     496
     497int relphot_parallel_images ();
     498int relphot_parallel_regions ();
  • branches/eam_branches/ipp-20140206/Ohana/src/relphot/src/ImageMagIO.c

    r36518 r36519  
    6969  ALLOCATE (image_mags, ImageMag, Nrow);
    7070  for (i = 0; i < Nrow; i++) {
    71     image_mag[i].Mcal                      = Mcal       [i];
    72     image_mag[i].dMcal                     = dMcal      [i];
    73     image_mag[i].dMagSys                   = dMagSys    [i];
    74     image_mag[i].Xm                        = Xm         [i];
    75     image_mag[i].nFitPhotom                = nFitPhotom [i];
    76     image_mag[i].flags                     = flags      [i];
    77     image_mag[i].ubercalDist               = ubercalDist[i];
    78     image_mag[i].imageID                   = imageID    [i];
     71    image_mags[i].Mcal                      = Mcal       [i];
     72    image_mags[i].dMcal                     = dMcal      [i];
     73    image_mags[i].dMagSys                   = dMagSys    [i];
     74    image_mags[i].Xm                        = Xm         [i];
     75    image_mags[i].nFitPhotom                = nFitPhotom [i];
     76    image_mags[i].flags                     = flags      [i];
     77    image_mags[i].ubercalDist               = ubercalDist[i];
     78    image_mags[i].imageID                   = imageID    [i];
    7979  }
    8080  fprintf (stderr, "loaded data for %lld images\n", (long long) Nrow);
     
    8989  free (imageID    );
    9090
    91   *nimage_mag = Nrow;
    92   return image_mag;
     91  *nimage_mags = Nrow;
     92  return image_mags;
    9393}
    9494
     
    148148  // assign the storage arrays
    149149  for (i = 0; i < Nimage_mags; i++) {
    150     Mcal       [i]   = image_mag[i].Mcal       ;
    151     dMcal      [i]   = image_mag[i].dMcal      ;
    152     dMagSys    [i]   = image_mag[i].dMagSys    ;
    153     Xm         [i]   = image_mag[i].Xm         ;
    154     nFitPhotom [i]   = image_mag[i].nFitPhotom ;
    155     flags      [i]   = image_mag[i].flags      ;
    156     ubercalDist[i]   = image_mag[i].ubercalDist;
    157     imageID    [i]   = image_mag[i].imageID    ;
     150    Mcal       [i]   = image_mags[i].Mcal       ;
     151    dMcal      [i]   = image_mags[i].dMcal      ;
     152    dMagSys    [i]   = image_mags[i].dMagSys    ;
     153    Xm         [i]   = image_mags[i].Xm         ;
     154    nFitPhotom [i]   = image_mags[i].nFitPhotom ;
     155    flags      [i]   = image_mags[i].flags      ;
     156    ubercalDist[i]   = image_mags[i].ubercalDist;
     157    imageID    [i]   = image_mags[i].imageID    ;
    158158  }
    159159
     
    179179  FILE *f = fopen (filename, "w");
    180180  if (!f) {
    181     fprintf (stderr, "ERROR: cannot open image_mag file for output %s\n", filename);
     181    fprintf (stderr, "ERROR: cannot open image_mags file for output %s\n", filename);
    182182    return FALSE;
    183183  }
  • branches/eam_branches/ipp-20140206/Ohana/src/relphot/src/ImageTable.c

    r36516 r36519  
    33Image *ImageTableLoad(char *filename, off_t *nimage) {
    44
    5   int i, Ncol;
    6   off_t Nrow;
    7   Header header;
    8   Header theader;
    9   Matrix matrix;
    10   FTable ftable;
     5  int status;
     6  off_t Nimage;
     7  FITS_DB db;
    118
    129  db.mode   = dvo_catalog_catmode (CATMODE);
     
    3027  // convert database table to internal structure (binary to Image)
    3128  // 'image' points to the same memory as db->ftable->buffer
    32   Image *image = gfits_table_get_Image (&db[0].ftable, &Nimage, &db[0].swapped);
     29  Image *image = gfits_table_get_Image (&db.ftable, &Nimage, &db.swapped);
    3330  if (!image) {
    3431    Shutdown ("ERROR: failed to read images");
     
    4138int ImageTableSave (char *filename, Image *images, off_t Nimages) {
    4239
    43   int i;
     40  int status;
    4441  FITS_DB db;
    4542
  • branches/eam_branches/ipp-20140206/Ohana/src/relphot/src/StarOps.c

    r36516 r36519  
    898898int markObjects (Catalog *catalog, int Ncatalog) {
    899899
     900  int i, n;
     901  off_t j;
     902
    900903  // How strongly do I own this object?
    901904  for (i = 0; i < Ncatalog; i++) {
  • branches/eam_branches/ipp-20140206/Ohana/src/relphot/src/args.c

    r36516 r36519  
    343343  }
    344344
     345  REGION_FILE = NULL;
    345346  if ((N = get_argument (argc, argv, "-region-hosts"))) {
    346347    remove_argument (N, &argc, argv);
    347     REGION_FILE = strcreate (argv[N])
     348    REGION_FILE = strcreate (argv[N]);
    348349    remove_argument (N, &argc, argv);
    349350  }
     
    352353  if ((N = get_argument (argc, argv, "-region-hostID"))) {
    353354    remove_argument (N, &argc, argv);
    354     REGION_HOST_ID = atoi (argv[N])
     355    REGION_HOST_ID = atoi (argv[N]);
    355356    remove_argument (N, &argc, argv);
    356357  }
     
    365366    mode = APPLY_OFFSETS;
    366367  }
     368  IMAGE_TABLE = NULL;
    367369  if ((N = get_argument (argc, argv, "-parallel-images"))) {
    368370    remove_argument (N, &argc, argv);
    369371    mode = PARALLEL_IMAGES;
    370372    if (N >= argc) relphot_usage();
    371     IMAGE_TABLE = strcreate (argv[N])
     373    IMAGE_TABLE = strcreate (argv[N]);
    372374    remove_argument (N, &argc, argv);
    373375    if (!REGION_FILE) relphot_usage();
  • branches/eam_branches/ipp-20140206/Ohana/src/relphot/src/assign_images.c

    r36516 r36519  
    3434
    3535// assign images to the region hosts; at the end, each host will have its list of images
    36 int select_images_hostregion (RegionHostTable *hosts, Image *image, off_t Nimage) {
     36int select_images_hostregion (RegionHostTable *regionHosts, Image *image, off_t Nimage) {
    3737
    38   INITTIME;
     38  int i, j, ecode, found;
     39
     40  // INITTIME;
    3941 
    4042  for (i = 0; i < regionHosts->Nhosts; i++) {
    41     regionHosts->host[i].Nimage = 0;
    42     regionHosts->host[i].NIMAGE = D_NIMAGE;
    43     ALLOCATE (regionHosts->host[i].image, Image, regionHosts->host[i].NIMAGE);
     43    regionHosts->hosts[i].Nimage = 0;
     44    regionHosts->hosts[i].NIMAGE = D_NIMAGE;
     45    ALLOCATE (regionHosts->hosts[i].image, Image, regionHosts->hosts[i].NIMAGE);
    4446  }
    4547
     
    7173
    7274    /* define image center - note the DIS images (mosaic phu) are special */
     75    double Xc, Yc, Rc, Dc;
    7376    if (!strcmp(&image[j].coords.ctype[4], "-DIS")) {
    7477      Xc = 0.0; Yc = 0.0;
     
    8285
    8386    i = find_host_for_coords (regionHosts, Rc, Dc);
     87    if (i == -1) continue;
    8488
    8589    // this is a bit memory expensive : I am making a complete copy of the image table here
    86     off_t Nsubset = regionHosts->host[i].Nimage;
    87     regionHosts->host[i].image[Nsubset] = image[j];
    88     // regionHosts->host[i].line_number[Nsubset] = j;
     90    off_t Nsubset = regionHosts->hosts[i].Nimage;
     91    regionHosts->hosts[i].image[Nsubset] = image[j];
     92    // regionHosts->hosts[i].line_number[Nsubset] = j;
    8993
    90     regionHosts->host[i].Nimage ++;
    91     if (regionHosts->host[i].Nimage == regionHosts->host[i].NIMAGE) {
    92       regionHosts->host[i].NIMAGE += D_NIMAGE;
    93       REALLOCATE (regionHosts->host[i].image, Image, regionHosts->host[i].NIMAGE);
    94       // REALLOCATE (regionHosts->host[i].line_number, off_t, regionHosts->host[i].NIMAGE);
     94    regionHosts->hosts[i].Nimage ++;
     95    if (regionHosts->hosts[i].Nimage == regionHosts->hosts[i].NIMAGE) {
     96      regionHosts->hosts[i].NIMAGE += D_NIMAGE;
     97      REALLOCATE (regionHosts->hosts[i].image, Image, regionHosts->hosts[i].NIMAGE);
     98      // REALLOCATE (regionHosts->hosts[i].line_number, off_t, regionHosts->hosts[i].NIMAGE);
    9599    }
    96100  }
     
    99103
    100104// XXX add a search tree to speed this up?
    101 int find_host_for_coords (RegionHostTable *regionHosts, double R, double d) {
     105int find_host_for_coords (RegionHostTable *regionHosts, double Rc, double Dc) {
     106
     107  int i;
    102108
    103109  for (i = 0; i < regionHosts->Nhosts; i++) {
    104110
    105     RegionHostInfo *host = regionHosts->hosts[i];
     111    RegionHostInfo *host = &regionHosts->hosts[i];
    106112    if (Rc <  host->Rmin) continue;
    107113    if (Rc >= host->Rmax) continue;
     
    111117    return i;
    112118  }
     119  return -1;
    113120}
    114121
  • branches/eam_branches/ipp-20140206/Ohana/src/relphot/src/launch_region_hosts.c

    r36516 r36519  
    11# include "relphot.h"
     2# define DEBUG 0
    23
    3 // strextend (command, "-v");
    4 int strextend (char *input, char *format,..) {
     4int strextend (char *input, char *format,...) {
    55
    66  char tmpfmt[1024], tmpline[1024];
     
    1010 
    1111  snprintf (tmpfmt, 1024, "%%s %s", format);
    12   vsnprintf (tmpline, 1024, tmpfmt, input, argp);
     12  vsnprintf (tmpline, 1024, tmpfmt, argp);
    1313  strcpy (input, tmpline);
    1414
     
    2626    // communication files:
    2727    // subset images per host : CATDIR/Image.HOSTNAME.fits
    28     sprintf (filename, "%s/Image.%s.fits", CATDIR, host->hostname);
     28    char filename[1024];
     29    snprintf (filename, 1024, "%s/Image.%s.fits", CATDIR, host->hostname);
    2930
    3031    // write the image subset for this host
    31     ImageTableSave (filename, host->images, host->Nimages);
     32    ImageTableSave (filename, host->image, host->Nimage);
    3233
    3334    char command[1024];
     
    5859
    5960  // XXX probably need an alternate function here...
    60   HostTableWaitJobs (table, __FILE__, __LINE__, VERBOSE);
    61 
     61  RegionHostTableWaitJobs (regionHosts, __FILE__, __LINE__);
     62 
     63  return TRUE;
    6264}
  • branches/eam_branches/ipp-20140206/Ohana/src/relphot/src/relphot_parallel_images.c

    r36516 r36519  
    1212int relphot_parallel_images () {
    1313
    14   int i, status, Ncatalog;
     14  int i, Ncatalog;
    1515  Catalog *catalog = NULL;
    16   FITS_DB db;
    17   SkyList *skylist = NULL;
    1816
    1917  INITTIME;
     
    3735  SkyTable *sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, TRUE, SKY_DEPTH, VERBOSE);
    3836  SkyTableSetFilenames (sky, CATDIR, "cpt");
    39   SkyList *skylist = SkyListByBounds (sky, UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax);
     37  SkyList *skylist = SkyListByBounds (sky, -1, UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax);
    4038
    4139  /* load catalog data from region files (hostID is 0 since we are not a client */
     
    111109  MARKTIME("-- finalize Mcal values: %f sec\n", dtime);
    112110
    113   share_image_mags (regionHosts, i);
     111  share_image_mags (regionHosts, -1);
    114112
    115113  // save_image_subset ();
  • branches/eam_branches/ipp-20140206/Ohana/src/relphot/src/relphot_parallel_regions.c

    r36516 r36519  
    55int relphot_parallel_regions () {
    66
    7   int i, status, Ncatalog;
    8   Catalog *catalog = NULL;
     7  int status;
    98  FITS_DB db;
    10   SkyList *skylist = NULL;
    119
    1210  INITTIME;
     11
     12  // load the flat correction table (if defined)
     13  char flatcorrfile[256];
     14  sprintf (flatcorrfile, "%s/flatcorr.fits", CATDIR);
     15  FlatCorrectionTable *flatcorr = FlatCorrectionLoad (flatcorrfile, VERBOSE);
     16
     17  SkyTable *sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, TRUE, SKY_DEPTH, VERBOSE);
     18  SkyTableSetFilenames (sky, CATDIR, "cpt");
     19  SkyList *skylist = SkyListByBounds (sky, -1, UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax);
    1320
    1421  // load the RegionTable (UserRegion should not be used at this level)
     
    4552
    4653  // retrieve updated image parameters from the remote hosts (also set Image.mcal)
    47   slurp_image_mags (regionHosts, XXX);
     54  slurp_image_mags (regionHosts, -1);
    4855
    4956  /* update catalogs (in parallel) */
    50   reload_catalogs ();
     57  reload_catalogs (skylist, flatcorr, 0, NULL);
    5158
    5259  // do not save changes if we did not make changes.
  • branches/eam_branches/ipp-20140206/Ohana/src/relphot/src/share_image_mags.c

    r36517 r36519  
    66int share_image_mags (RegionHostTable *regionHosts, int nloop) {
    77
     8  off_t i, Nimages;
    89  Image *images = getimages (&Nimages, NULL);
    910
     
    1617  for (i = 0; i < Nimages; i++) {
    1718    // XXX does this image have missing detections (does someone else need it?)
    18     if (imageExtra[i].Nmiss == 0) continue;
     19    // XXX : NOTE NEED TO FIX THIS: if (imageExtra[i].Nmiss == 0) continue;
    1920   
    2021    set_image_mags (&image_mags[Nimage_mags], &images[i]);
     
    3031  char filename[1024];
    3132  snprintf (filename, 1024, "%s/%s.imagemags.fits", CATDIR, hostname);
    32   ImageMagsSave (filename, image_mags, Nimage_mags);
     33  ImageMagSave (filename, image_mags, Nimage_mags);
    3334
    3435  update_imsync_file (hostname, nloop);
     
    3940int slurp_image_mags (RegionHostTable *regionHosts, int nloop) {
    4041
    41   Image *getimages (&Nimage, NULL);
     42  off_t Nimage, i;
     43  Image *images = getimages (&Nimage, NULL);
    4244
    4345  int Nimage_mags = 0;
     
    4547  ALLOCATE (image_mags, ImageMag, 1);
    4648
    47   for (i = 0; i < Nhost; i++) {
     49  for (i = 0; i < regionHosts->Nhosts; i++) {
    4850    if (regionHosts->hosts.hostsID == REGION_HOST_ID) continue;
    4951    // XXX add neighbor check? : if (not_neighbor(host[i])) continue;
     
    5355    char filename[1024];
    5456    snprintf (filename, 1024, "%s/%s.imagemags.fits", CATDIR, regionHosts->hosts[i].hostname);
    55     ImageMag *image_mags_subset = ImageMagLoad (host[i], &Nsubset);
     57
     58    off_t Nsubset;
     59    ImageMag *image_mags_subset = ImageMagLoad (regionHosts->hosts[i], &Nsubset);
    5660
    5761    image_mags = merge_image_mags (image_mags, &Nimage_mags, image_mags_subset, Nsubset);
     
    5963
    6064  for (i = 0; i < Nimage_mags; i++) {
    61     seq = getImageByID (image_mags[i].ID);
     65    off_t seq = getImageByID (image_mags[i].ID);
    6266    if (seq < 0) {
    6367      // XXX is this a problem? (no, other hosts don't know which images I own)
    6468      continue;
    6569    }
    66     image[seq].Mcal        = image_mags[i].Mcal;
    67     image[seq].dMcal       = image_mags[i].dMcal;
    68     image[seq].dMagSys     = image_mags[i].dMagSys;
    69     image[seq].Xm          = image_mags[i].Xm;
    70     image[seq].nFitPhotom  = image_mags[i].nFitPhotom;
    71     image[seq].flags       = image_mags[i].flags;
    72     image[seq].ubercalDist = image_mags[i].ubercalDist;
     70    images[seq].Mcal       = image_mags[i].Mcal;
     71    images[seq].dMcal      = image_mags[i].dMcal;
     72    images[seq].dMagSys    = image_mags[i].dMagSys;
     73    images[seq].Xm         = image_mags[i].Xm;
     74    images[seq].nFitPhotom  = image_mags[i].nFitPhotom;
     75    images[seq].flags      = image_mags[i].flags;
     76    images[seq].ubercalDist = image_mags[i].ubercalDist;
    7377  }
    7478}
     
    7882int check_imsync_file (char *hostname, int nloop) {
    7983
     84  char message[MSG_LENGTH];
    8085  char filename[1024];
    8186  sprintf (filename, "%s/%s.image.sync", CATDIR, hostname);
     
    8388  FILE *f = NULL;
    8489
    85   while (retry) {
     90  while (TRUE) {
    8691
    8792    f = fopen (filename);
     
    100105
    101106    // message is of the form: NLOOP: %03d
     107    int loop;
    102108    sscanf (message, "%s %d", &loop);
    103109    if (loop != nloop) {
     
    111117int update_imsync_file (char *hostname, int nloop) {
    112118
     119  char message[MSG_LENGTH];
    113120  char filename[1024];
    114121  sprintf (filename, "%s/%s.image.sync", CATDIR, hostname);
     
    140147int set_image_mags (ImageMag *image_mags, Image *image) {
    141148
    142   image_mags->M  = image->Mcal;
     149  fprintf (stderr, "ERROR: need to fix this function\n");
     150  exit (2);
     151
     152  image_mags->Mcal  = image->Mcal;
    143153
    144154  return TRUE;
     
    147157ImageMag *merge_image_mags (ImageMag *target, int *ntarget, ImageMag *source, int Nsource) {
    148158
     159  off_t i;
     160
    149161  REALLOCATE (target, ImageMag, *ntarget + Nsource);
    150162  for (i = 0; i < Nsource; i++) {
    151     int n = i + *ntarget;
     163    off_t n = i + *ntarget;
    152164    target[n] = source[i];
    153165  }
  • branches/eam_branches/ipp-20140206/Ohana/src/relphot/src/share_mean_mags.c

    r36518 r36519  
    55# define D_NMEANMAGS 10000
    66int share_mean_mags (Catalog *catalog, int Ncatalog, RegionHostTable *regionHosts, int nloop) {
     7
     8  int i;
     9  off_t j;
    710
    811  off_t Nmeanmags = 0;
     
    5558int slurp_mean_mags (Catalog *catalog, int Ncatalog, RegionHostTable *regionHosts, int nloop) {
    5659
     60  off_t i;
     61
    5762  int Nmeanmags = 0;
    5863  MeanMag *meanmags = NULL;
    5964  ALLOCATE (meanmags, MeanMag, 1);
    6065
    61   for (i = 0; i < Nhost; i++) {
    62     if (not_neighbor(host[i])) continue;
    63     // XXX skip regions->hosts[i].hostID == REGION_HOST_ID
     66  int Nsecfilt = GetPhotcodeNsecfilt();
     67
     68  for (i = 0; i < regionHosts->Nhosts; i++) {
     69    // if (not_neighbor(host[i])) continue;
     70    if (regionHosts->hosts[i].hostID == REGION_HOST_ID) continue;
    6471
    6572    check_sync_file (regionHosts->hosts[i].hostname, nloop);
     
    6875    snprintf (filename, 1024, "%s/%s.meanmags.fits", CATDIR, regionHosts->hosts[i].hostname);
    6976
    70     int Nsubset = 0;
    71     MeanMag *meanmagsSubset = MeanMagLoad (host[i], &Nsubset);
     77    off_t Nsubset = 0;
     78    MeanMag *meanmagsSubset = MeanMagLoad (regionHosts->hosts[i].hostname, &Nsubset);
    7279
    7380    // merge_mean_mags reallocs meanmags and frees the input meanmagsSubset
     
    8794    }
    8895
    89     Nsecfit = photcode_to_secfilt (meanmags[i].photcode);
    90     catalog[catSeq].secfilt[objSeq*Nsec + Nsecfilt].mag = meanmags[i].mag;
    91   }
     96    int Nsec = photcode_to_secfilt (meanmags[i].photcode);
     97    catalog[catSeq].secfilt[objSeq*Nsecfilt + Nsec].mag = meanmags[i].mag;
     98  }
     99  return TRUE;
    92100}
    93101
     
    96104int check_sync_file (char *hostname, int nloop) {
    97105
     106  char message[MSG_LENGTH];
    98107  char filename[1024];
    99108  sprintf (filename, "%s/%s.meanmags.sync", CATDIR, hostname);
     
    102111  FILE *f = NULL;
    103112
    104   while (retry) {
    105 
    106     f = fopen (filename);
     113  while (TRUE) {
     114
     115    f = fopen (filename, "r");
    107116    if (!f) {
    108117      usleep (2000000);
     
    110119    }
    111120
     121    // XXX MSG_LENGTH : 0 EOL byte?
    112122    int Nread = fread (message, MSG_LENGTH, 1, f);
    113123    if (Nread < MSG_LENGTH) {
     
    119129
    120130    // message is of the form: NLOOP: %03d
     131    int loop;
    121132    sscanf (message, "%s %d", &loop);
    122133    if (loop != nloop) {
     
    126137    return TRUE;
    127138  }
     139  return FALSE;
    128140}
    129141
     
    141153int update_sync_file (char *hostname, int nloop) {
    142154
     155  char message[MSG_LENGTH];
    143156  char filename[1024];
    144157  sprintf (filename, "%s/%s.meanmags.sync", CATDIR, hostname);
     
    172185MeanMag *merge_mean_mags (MeanMag *target, int *ntarget, MeanMag *source, int Nsource) {
    173186
     187  off_t i;
     188
    174189  REALLOCATE (target, MeanMag, *ntarget + Nsource);
    175190  for (i = 0; i < Nsource; i++) {
    176     int n = i + *ntarget;
     191    off_t n = i + *ntarget;
    177192    target[n] = source[i];
    178193  }
Note: See TracChangeset for help on using the changeset viewer.