Changeset 36519
- Timestamp:
- Feb 18, 2014, 9:08:37 AM (12 years ago)
- Location:
- branches/eam_branches/ipp-20140206/Ohana/src
- Files:
-
- 14 edited
-
libdvo/include/dvo.h (modified) (1 diff)
-
libdvo/src/RegionHostTable.c (modified) (3 diffs)
-
libdvo/src/dvo_catalog.c (modified) (1 diff)
-
relphot/include/relphot.h (modified) (4 diffs)
-
relphot/src/ImageMagIO.c (modified) (4 diffs)
-
relphot/src/ImageTable.c (modified) (3 diffs)
-
relphot/src/StarOps.c (modified) (1 diff)
-
relphot/src/args.c (modified) (3 diffs)
-
relphot/src/assign_images.c (modified) (5 diffs)
-
relphot/src/launch_region_hosts.c (modified) (4 diffs)
-
relphot/src/relphot_parallel_images.c (modified) (3 diffs)
-
relphot/src/relphot_parallel_regions.c (modified) (2 diffs)
-
relphot/src/share_image_mags.c (modified) (13 diffs)
-
relphot/src/share_mean_mags.c (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20140206/Ohana/src/libdvo/include/dvo.h
r36518 r36519 409 409 uint32_t flags; 410 410 int catID; 411 int nOwn; 411 412 } AverageTiny; 412 413 -
branches/eam_branches/ipp-20140206/Ohana/src/libdvo/src/RegionHostTable.c
r36518 r36519 85 85 if (line[i] == '#') continue; 86 86 if (line[i] == 0) continue; 87 88 UserPatch.Rmin = 360; 89 UserPatch.Rmax = 0; 90 UserPatch.Dmin = +90; 91 UserPatch.Dmax = -90; 87 92 88 93 double Rmin, Rmax, Dmin, Dmax; … … 116 121 hosts[Nhosts].Dmax = Dmax; 117 122 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 118 128 // InitIOBuffer (&hosts[Nhosts].stdout, 1000); 119 129 // InitIOBuffer (&hosts[Nhosts].stderr, 1000); … … 147 157 return table; 148 158 } 159 160 // wait for all children to complete, report output to stdout 161 int 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 119 119 average->measureOffset = -1; 120 120 average->catID = 0; 121 average->nOwn = 0; 121 122 } 122 123 -
branches/eam_branches/ipp-20140206/Ohana/src/relphot/include/relphot.h
r36518 r36519 178 178 char SKY_TABLE[DVO_MAX_PATH]; 179 179 int SKY_DEPTH; /** XXX EAM : depth of catalog tables, fix usage */ 180 181 // globals for parallel region operations 182 char *REGION_FILE; 183 char *IMAGE_TABLE; 184 int REGION_HOST_ID; 180 185 181 186 int HOST_ID; … … 290 295 void InterpolateGrid PROTO((float *buffer, int Nx, int Ny, Coords *ccd, Coords *gcoords)); 291 296 off_t *SelectRefMosaic PROTO((Mosaic **refmosaic, off_t *Nimage)); 292 intargs PROTO((int argc, char **argv));297 RelphotMode args PROTO((int argc, char **argv)); 293 298 int args_client PROTO((int argc, char **argv)); 294 299 int bcatalog PROTO((Catalog *subcatalog, Catalog *catalog, int Ncat)); … … 339 344 void initMosaics PROTO((Image *subset, off_t Nsubset, Image *image, char *inSubset, off_t Nimage)); 340 345 void initMrel PROTO((Catalog *catalog, int Ncatalog)); 341 voidinitialize PROTO((int argc, char **argv));346 RelphotMode initialize PROTO((int argc, char **argv)); 342 347 void initialize_client PROTO((int argc, char **argv)); 343 348 void liststats_setmode PROTO((StatType *stats, char *strmode)); … … 487 492 ImageMag *ImageMagLoad(char *filename, off_t *nimage_mags); 488 493 int ImageMagSave(char *filename, ImageMag *image_mags, off_t Nimage_mags); 494 495 int markObjects (Catalog *catalog, int Ncatalog); 496 497 int relphot_parallel_images (); 498 int relphot_parallel_regions (); -
branches/eam_branches/ipp-20140206/Ohana/src/relphot/src/ImageMagIO.c
r36518 r36519 69 69 ALLOCATE (image_mags, ImageMag, Nrow); 70 70 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]; 79 79 } 80 80 fprintf (stderr, "loaded data for %lld images\n", (long long) Nrow); … … 89 89 free (imageID ); 90 90 91 *nimage_mag = Nrow;92 return image_mag ;91 *nimage_mags = Nrow; 92 return image_mags; 93 93 } 94 94 … … 148 148 // assign the storage arrays 149 149 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 ; 158 158 } 159 159 … … 179 179 FILE *f = fopen (filename, "w"); 180 180 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); 182 182 return FALSE; 183 183 } -
branches/eam_branches/ipp-20140206/Ohana/src/relphot/src/ImageTable.c
r36516 r36519 3 3 Image *ImageTableLoad(char *filename, off_t *nimage) { 4 4 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; 11 8 12 9 db.mode = dvo_catalog_catmode (CATMODE); … … 30 27 // convert database table to internal structure (binary to Image) 31 28 // '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); 33 30 if (!image) { 34 31 Shutdown ("ERROR: failed to read images"); … … 41 38 int ImageTableSave (char *filename, Image *images, off_t Nimages) { 42 39 43 int i;40 int status; 44 41 FITS_DB db; 45 42 -
branches/eam_branches/ipp-20140206/Ohana/src/relphot/src/StarOps.c
r36516 r36519 898 898 int markObjects (Catalog *catalog, int Ncatalog) { 899 899 900 int i, n; 901 off_t j; 902 900 903 // How strongly do I own this object? 901 904 for (i = 0; i < Ncatalog; i++) { -
branches/eam_branches/ipp-20140206/Ohana/src/relphot/src/args.c
r36516 r36519 343 343 } 344 344 345 REGION_FILE = NULL; 345 346 if ((N = get_argument (argc, argv, "-region-hosts"))) { 346 347 remove_argument (N, &argc, argv); 347 REGION_FILE = strcreate (argv[N]) 348 REGION_FILE = strcreate (argv[N]); 348 349 remove_argument (N, &argc, argv); 349 350 } … … 352 353 if ((N = get_argument (argc, argv, "-region-hostID"))) { 353 354 remove_argument (N, &argc, argv); 354 REGION_HOST_ID = atoi (argv[N]) 355 REGION_HOST_ID = atoi (argv[N]); 355 356 remove_argument (N, &argc, argv); 356 357 } … … 365 366 mode = APPLY_OFFSETS; 366 367 } 368 IMAGE_TABLE = NULL; 367 369 if ((N = get_argument (argc, argv, "-parallel-images"))) { 368 370 remove_argument (N, &argc, argv); 369 371 mode = PARALLEL_IMAGES; 370 372 if (N >= argc) relphot_usage(); 371 IMAGE_TABLE = strcreate (argv[N]) 373 IMAGE_TABLE = strcreate (argv[N]); 372 374 remove_argument (N, &argc, argv); 373 375 if (!REGION_FILE) relphot_usage(); -
branches/eam_branches/ipp-20140206/Ohana/src/relphot/src/assign_images.c
r36516 r36519 34 34 35 35 // 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) {36 int select_images_hostregion (RegionHostTable *regionHosts, Image *image, off_t Nimage) { 37 37 38 INITTIME; 38 int i, j, ecode, found; 39 40 // INITTIME; 39 41 40 42 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); 44 46 } 45 47 … … 71 73 72 74 /* define image center - note the DIS images (mosaic phu) are special */ 75 double Xc, Yc, Rc, Dc; 73 76 if (!strcmp(&image[j].coords.ctype[4], "-DIS")) { 74 77 Xc = 0.0; Yc = 0.0; … … 82 85 83 86 i = find_host_for_coords (regionHosts, Rc, Dc); 87 if (i == -1) continue; 84 88 85 89 // 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; 89 93 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); 95 99 } 96 100 } … … 99 103 100 104 // XXX add a search tree to speed this up? 101 int find_host_for_coords (RegionHostTable *regionHosts, double R, double d) { 105 int find_host_for_coords (RegionHostTable *regionHosts, double Rc, double Dc) { 106 107 int i; 102 108 103 109 for (i = 0; i < regionHosts->Nhosts; i++) { 104 110 105 RegionHostInfo *host = regionHosts->hosts[i];111 RegionHostInfo *host = ®ionHosts->hosts[i]; 106 112 if (Rc < host->Rmin) continue; 107 113 if (Rc >= host->Rmax) continue; … … 111 117 return i; 112 118 } 119 return -1; 113 120 } 114 121 -
branches/eam_branches/ipp-20140206/Ohana/src/relphot/src/launch_region_hosts.c
r36516 r36519 1 1 # include "relphot.h" 2 # define DEBUG 0 2 3 3 // strextend (command, "-v"); 4 int strextend (char *input, char *format,..) { 4 int strextend (char *input, char *format,...) { 5 5 6 6 char tmpfmt[1024], tmpline[1024]; … … 10 10 11 11 snprintf (tmpfmt, 1024, "%%s %s", format); 12 vsnprintf (tmpline, 1024, tmpfmt, input,argp);12 vsnprintf (tmpline, 1024, tmpfmt, argp); 13 13 strcpy (input, tmpline); 14 14 … … 26 26 // communication files: 27 27 // 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); 29 30 30 31 // write the image subset for this host 31 ImageTableSave (filename, host->image s, host->Nimages);32 ImageTableSave (filename, host->image, host->Nimage); 32 33 33 34 char command[1024]; … … 58 59 59 60 // XXX probably need an alternate function here... 60 HostTableWaitJobs (table, __FILE__, __LINE__, VERBOSE); 61 61 RegionHostTableWaitJobs (regionHosts, __FILE__, __LINE__); 62 63 return TRUE; 62 64 } -
branches/eam_branches/ipp-20140206/Ohana/src/relphot/src/relphot_parallel_images.c
r36516 r36519 12 12 int relphot_parallel_images () { 13 13 14 int i, status,Ncatalog;14 int i, Ncatalog; 15 15 Catalog *catalog = NULL; 16 FITS_DB db;17 SkyList *skylist = NULL;18 16 19 17 INITTIME; … … 37 35 SkyTable *sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, TRUE, SKY_DEPTH, VERBOSE); 38 36 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); 40 38 41 39 /* load catalog data from region files (hostID is 0 since we are not a client */ … … 111 109 MARKTIME("-- finalize Mcal values: %f sec\n", dtime); 112 110 113 share_image_mags (regionHosts, i);111 share_image_mags (regionHosts, -1); 114 112 115 113 // save_image_subset (); -
branches/eam_branches/ipp-20140206/Ohana/src/relphot/src/relphot_parallel_regions.c
r36516 r36519 5 5 int relphot_parallel_regions () { 6 6 7 int i, status, Ncatalog; 8 Catalog *catalog = NULL; 7 int status; 9 8 FITS_DB db; 10 SkyList *skylist = NULL;11 9 12 10 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); 13 20 14 21 // load the RegionTable (UserRegion should not be used at this level) … … 45 52 46 53 // retrieve updated image parameters from the remote hosts (also set Image.mcal) 47 slurp_image_mags (regionHosts, XXX);54 slurp_image_mags (regionHosts, -1); 48 55 49 56 /* update catalogs (in parallel) */ 50 reload_catalogs ( );57 reload_catalogs (skylist, flatcorr, 0, NULL); 51 58 52 59 // 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 6 6 int share_image_mags (RegionHostTable *regionHosts, int nloop) { 7 7 8 off_t i, Nimages; 8 9 Image *images = getimages (&Nimages, NULL); 9 10 … … 16 17 for (i = 0; i < Nimages; i++) { 17 18 // 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; 19 20 20 21 set_image_mags (&image_mags[Nimage_mags], &images[i]); … … 30 31 char filename[1024]; 31 32 snprintf (filename, 1024, "%s/%s.imagemags.fits", CATDIR, hostname); 32 ImageMag sSave (filename, image_mags, Nimage_mags);33 ImageMagSave (filename, image_mags, Nimage_mags); 33 34 34 35 update_imsync_file (hostname, nloop); … … 39 40 int slurp_image_mags (RegionHostTable *regionHosts, int nloop) { 40 41 41 Image *getimages (&Nimage, NULL); 42 off_t Nimage, i; 43 Image *images = getimages (&Nimage, NULL); 42 44 43 45 int Nimage_mags = 0; … … 45 47 ALLOCATE (image_mags, ImageMag, 1); 46 48 47 for (i = 0; i < Nhost; i++) {49 for (i = 0; i < regionHosts->Nhosts; i++) { 48 50 if (regionHosts->hosts.hostsID == REGION_HOST_ID) continue; 49 51 // XXX add neighbor check? : if (not_neighbor(host[i])) continue; … … 53 55 char filename[1024]; 54 56 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); 56 60 57 61 image_mags = merge_image_mags (image_mags, &Nimage_mags, image_mags_subset, Nsubset); … … 59 63 60 64 for (i = 0; i < Nimage_mags; i++) { 61 seq = getImageByID (image_mags[i].ID);65 off_t seq = getImageByID (image_mags[i].ID); 62 66 if (seq < 0) { 63 67 // XXX is this a problem? (no, other hosts don't know which images I own) 64 68 continue; 65 69 } 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; 73 77 } 74 78 } … … 78 82 int check_imsync_file (char *hostname, int nloop) { 79 83 84 char message[MSG_LENGTH]; 80 85 char filename[1024]; 81 86 sprintf (filename, "%s/%s.image.sync", CATDIR, hostname); … … 83 88 FILE *f = NULL; 84 89 85 while ( retry) {90 while (TRUE) { 86 91 87 92 f = fopen (filename); … … 100 105 101 106 // message is of the form: NLOOP: %03d 107 int loop; 102 108 sscanf (message, "%s %d", &loop); 103 109 if (loop != nloop) { … … 111 117 int update_imsync_file (char *hostname, int nloop) { 112 118 119 char message[MSG_LENGTH]; 113 120 char filename[1024]; 114 121 sprintf (filename, "%s/%s.image.sync", CATDIR, hostname); … … 140 147 int set_image_mags (ImageMag *image_mags, Image *image) { 141 148 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; 143 153 144 154 return TRUE; … … 147 157 ImageMag *merge_image_mags (ImageMag *target, int *ntarget, ImageMag *source, int Nsource) { 148 158 159 off_t i; 160 149 161 REALLOCATE (target, ImageMag, *ntarget + Nsource); 150 162 for (i = 0; i < Nsource; i++) { 151 int n = i + *ntarget;163 off_t n = i + *ntarget; 152 164 target[n] = source[i]; 153 165 } -
branches/eam_branches/ipp-20140206/Ohana/src/relphot/src/share_mean_mags.c
r36518 r36519 5 5 # define D_NMEANMAGS 10000 6 6 int share_mean_mags (Catalog *catalog, int Ncatalog, RegionHostTable *regionHosts, int nloop) { 7 8 int i; 9 off_t j; 7 10 8 11 off_t Nmeanmags = 0; … … 55 58 int slurp_mean_mags (Catalog *catalog, int Ncatalog, RegionHostTable *regionHosts, int nloop) { 56 59 60 off_t i; 61 57 62 int Nmeanmags = 0; 58 63 MeanMag *meanmags = NULL; 59 64 ALLOCATE (meanmags, MeanMag, 1); 60 65 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; 64 71 65 72 check_sync_file (regionHosts->hosts[i].hostname, nloop); … … 68 75 snprintf (filename, 1024, "%s/%s.meanmags.fits", CATDIR, regionHosts->hosts[i].hostname); 69 76 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); 72 79 73 80 // merge_mean_mags reallocs meanmags and frees the input meanmagsSubset … … 87 94 } 88 95 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; 92 100 } 93 101 … … 96 104 int check_sync_file (char *hostname, int nloop) { 97 105 106 char message[MSG_LENGTH]; 98 107 char filename[1024]; 99 108 sprintf (filename, "%s/%s.meanmags.sync", CATDIR, hostname); … … 102 111 FILE *f = NULL; 103 112 104 while ( retry) {105 106 f = fopen (filename );113 while (TRUE) { 114 115 f = fopen (filename, "r"); 107 116 if (!f) { 108 117 usleep (2000000); … … 110 119 } 111 120 121 // XXX MSG_LENGTH : 0 EOL byte? 112 122 int Nread = fread (message, MSG_LENGTH, 1, f); 113 123 if (Nread < MSG_LENGTH) { … … 119 129 120 130 // message is of the form: NLOOP: %03d 131 int loop; 121 132 sscanf (message, "%s %d", &loop); 122 133 if (loop != nloop) { … … 126 137 return TRUE; 127 138 } 139 return FALSE; 128 140 } 129 141 … … 141 153 int update_sync_file (char *hostname, int nloop) { 142 154 155 char message[MSG_LENGTH]; 143 156 char filename[1024]; 144 157 sprintf (filename, "%s/%s.meanmags.sync", CATDIR, hostname); … … 172 185 MeanMag *merge_mean_mags (MeanMag *target, int *ntarget, MeanMag *source, int Nsource) { 173 186 187 off_t i; 188 174 189 REALLOCATE (target, MeanMag, *ntarget + Nsource); 175 190 for (i = 0; i < Nsource; i++) { 176 int n = i + *ntarget;191 off_t n = i + *ntarget; 177 192 target[n] = source[i]; 178 193 }
Note:
See TracChangeset
for help on using the changeset viewer.
