Changeset 33875 for branches/eam_branches/ipp-20120405/Ohana
- Timestamp:
- May 16, 2012, 4:20:32 PM (14 years ago)
- Location:
- branches/eam_branches/ipp-20120405/Ohana/src/dvomerge
- Files:
-
- 1 added
- 2 edited
-
doc/failsafe.txt (added)
-
include/dvomerge.h (modified) (1 diff)
-
src/dvomergeUpdate_catalogs.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20120405/Ohana/src/dvomerge/include/dvomerge.h
r33834 r33875 17 17 # include <glob.h> 18 18 19 # define MAX_PATH_LENGTH 102419 # define DVO_MAX_PATH 1024 20 20 21 21 int PARALLEL; -
branches/eam_branches/ipp-20120405/Ohana/src/dvomerge/src/dvomergeUpdate_catalogs.c
r33834 r33875 36 36 found = (found || HostTableTestHost(outlist[0].regions[j], HOST_ID)); 37 37 } 38 38 39 // skip this input table for if no output files are on this machine 39 40 if (!found) { … … 42 43 } 43 44 44 // load / create output catalog (if catalog does not exist, it will be created) 45 // get the stats on this input file (for comparison with the output headers) 46 struct stat instats; 47 int stat_result = stat (inlist[0].filename[i], &instats); 48 if (stat_result) { 49 if (errno == ENOENT) continue; 50 fprintf (stderr, "cannot read stats on input file %s\n", inlist[0].filename[i]); 51 perror ("stats error message:"); 52 exit (2); 53 } 54 55 // instats.st_size & instats.st_mtime 56 57 // check if any of the output files have NOT yet received data from this input file 58 59 int missed = FALSE; 60 for (j = 0; !missed && (j < outlist[0].Nregions); j++) { 61 if (!HostTableTestHost(outlist[0].regions[j], HOST_ID)) continue; 62 63 // set the parameters which guide catalog open/load/create 64 char hostfile[DVO_MAX_PATH]; 65 snprintf (hostfile, DVO_MAX_PATH, "%s/%s.cpt", HOSTDIR, outlist[0].regions[j]->name); 66 char *filename = HOST_ID ? hostfile : outlist[0].filename[j]; 67 68 // get the stats on this input file (for comparison with the output headers) 69 struct stat outstats; 70 stat_result = stat (filename, &outstats); 71 if (stat_result) { 72 if (errno == ENOENT) { 73 missed = TRUE; 74 break; 75 } 76 fprintf (stderr, "cannot read stats on output file %s\n", filename); 77 perror ("stats error message:"); 78 exit (2); 79 } 80 81 FILE *fout = fopen (filename, "r"); 82 if (!fout) { 83 fprintf (stderr, "problem opening output file to read header %s\n", filename); 84 perror ("stats error message:"); 85 exit (2); 86 } 87 88 Header outheader; 89 if (!gfits_fread_header (fout, &outheader)) { 90 fprintf (stderr, "problem reading header for output file %s\n", filename); 91 exit (2); 92 } 93 94 // update header of output catalog 95 long long last_size; 96 char last_moddate[80]; 97 gfits_scan (&outheader, "LMRG_SZ", "%lld", 1, &last_size); 98 gfits_scan (&outheader, "LMRG_DT", "%s", 1, last_moddate); 99 100 time_t last_mod = ohana_date_to_sec (last_moddate); 101 102 if (last_size != instats.st_size) { 103 missed = TRUE; 104 break; 105 } 106 107 if (last_mod != instats.st_mtime) { 108 missed = TRUE; 109 break; 110 } 111 } 112 if (!missed) { 113 fprintf (stderr, "skipping %s, already merged\n", inlist[0].filename[i]); 114 continue; 115 } 116 117 // read the input catalog 45 118 LoadCatalog (&incatalog, &inlist[0].regions[i][0], inlist[0].filename[i], "r", NsecfiltInput); 119 46 120 // skip empty input catalogs 47 121 if (!incatalog.Naves_disk) { … … 52 126 } 53 127 128 char *moddate = ohana_sec_to_date (instats.st_mtime); 129 54 130 // merge input into the appropriate output tables 55 131 for (j = 0; j < outlist[0].Nregions; j++) { … … 60 136 61 137 // set the parameters which guide catalog open/load/create 62 char hostfile[ MAX_PATH_LENGTH];63 snprintf (hostfile, MAX_PATH_LENGTH, "%s/%s.cpt", HOSTDIR, outlist[0].regions[j]->name);138 char hostfile[DVO_MAX_PATH]; 139 snprintf (hostfile, DVO_MAX_PATH, "%s/%s.cpt", HOSTDIR, outlist[0].regions[j]->name); 64 140 outcatalog.filename = HOST_ID ? hostfile : outlist[0].filename[j]; 65 141 … … 71 147 72 148 outcatalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF; 149 150 // update header of output catalog 151 gfits_modify (&outcatalog.header, "LMRG_SZ", "%lld", 1, (long long) instats.st_size); 152 gfits_modify (&outcatalog.header, "LMRG_DT", "%s", 1, moddate); 153 154 if (!dvo_catalog_backup (&outcatalog, TRUE)) { 155 fprintf (stderr, "ERROR: failed to make backup for catalog %s\n", outlist[0].filename[j]); 156 exit (1); 157 } 73 158 74 159 // if we receive a signal which would cause us to exit, wait until the full catalog is written … … 80 165 SetProtect (FALSE); 81 166 167 if (!dvo_catalog_unlink_backup (&outcatalog, TRUE)) { 168 fprintf (stderr, "WARNING: failed to remove backup for catalog %s\n", outlist[0].filename[j]); 169 } 170 82 171 dvo_catalog_unlock (&outcatalog); 83 172 dvo_catalog_free (&outcatalog); … … 86 175 } 87 176 SkyListFree (outlist); 177 free (moddate); 88 178 89 179 dvo_catalog_unlock (&incatalog); … … 108 198 109 199 // ensure that the paths are absolute path names 110 char *tmppath = abspath (table->hosts[i].pathname, MAX_PATH_LENGTH);200 char *tmppath = abspath (table->hosts[i].pathname, DVO_MAX_PATH); 111 201 free (table->hosts[i].pathname); 112 202 table->hosts[i].pathname = tmppath; 113 203 114 204 // ensure that the paths are absolute path names 115 char *absinput = abspath (input, MAX_PATH_LENGTH);116 char *absoutput = abspath (output, MAX_PATH_LENGTH);205 char *absinput = abspath (input, DVO_MAX_PATH); 206 char *absoutput = abspath (output, DVO_MAX_PATH); 117 207 118 208 // options / arguments that can affect relastro_client -update-objects: 119 char command[ MAX_PATH_LENGTH];120 snprintf (command, MAX_PATH_LENGTH, "dvomerge_client %s into %s -hostID %d -hostdir %s -region %f %f %f %f -D ADDSTAR_RADIUS %f",209 char command[DVO_MAX_PATH]; 210 snprintf (command, DVO_MAX_PATH, "dvomerge_client %s into %s -hostID %d -hostdir %s -region %f %f %f %f -D ADDSTAR_RADIUS %f", 121 211 absinput, absoutput, table->hosts[i].hostID, table->hosts[i].pathname, 122 212 UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax, RADIUS 123 213 ); 124 214 125 char tmpline[ MAX_PATH_LENGTH];126 if (VERBOSE) { snprintf (tmpline, MAX_PATH_LENGTH, "%s -v", command); strcpy (command, tmpline); }215 char tmpline[DVO_MAX_PATH]; 216 if (VERBOSE) { snprintf (tmpline, DVO_MAX_PATH, "%s -v", command); strcpy (command, tmpline); } 127 217 128 218 // XXX these do not make sense for dvomerge client, where the output is required to exist 129 // if (CATFORMAT) { snprintf (tmpline, MAX_PATH_LENGTH, "%s -D CATFORMAT %s", command, CATFORMAT); strcpy (command, tmpline); }130 // if (CATMODE) { snprintf (tmpline, MAX_PATH_LENGTH, "%s -D CATMODE %s", command, CATMODE); strcpy (command, tmpline); }131 // if (SKY_DEPTH) { snprintf (tmpline, MAX_PATH_LENGTH, "%s -D SKY_DEPTH %d", command, SKY_DEPTH); strcpy (command, tmpline); }219 // if (CATFORMAT) { snprintf (tmpline, DVO_MAX_PATH, "%s -D CATFORMAT %s", command, CATFORMAT); strcpy (command, tmpline); } 220 // if (CATMODE) { snprintf (tmpline, DVO_MAX_PATH, "%s -D CATMODE %s", command, CATMODE); strcpy (command, tmpline); } 221 // if (SKY_DEPTH) { snprintf (tmpline, DVO_MAX_PATH, "%s -D SKY_DEPTH %d", command, SKY_DEPTH); strcpy (command, tmpline); } 132 222 133 223 fprintf (stderr, "command: %s\n", command);
Note:
See TracChangeset
for help on using the changeset viewer.
