Changeset 33207
- Timestamp:
- Feb 7, 2012, 11:48:36 AM (14 years ago)
- Location:
- branches/eam_branches/ipp-20111122/Ohana/src/photdbc
- Files:
-
- 4 added
- 4 edited
- 1 moved
-
include/dvodist.h (added)
-
src/AssignSkyToHost.c (modified) (1 diff)
-
src/CopyFromHostLocation.c (added)
-
src/CopyToHostLocation.c (modified) (3 diffs)
-
src/HostTableLoad.c (modified) (2 diffs)
-
src/Shutdown_dvodist.c (added)
-
src/dvodist.c (modified) (3 diffs)
-
src/initialize_dvodist.c (moved) (moved from branches/eam_branches/ipp-20111122/Ohana/src/photdbc/src/args_dvodist.c ) (5 diffs)
-
src/md5_ops.c (added)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20111122/Ohana/src/photdbc/src/AssignSkyToHost.c
r33206 r33207 29 29 } 30 30 31 32 33 31 // assign all regions to one of the Nhost hosts 34 32 int N = MAX(table->Nhosts - 1, table->Nhosts * drand48()); -
branches/eam_branches/ipp-20111122/Ohana/src/photdbc/src/CopyToHostLocation.c
r33206 r33207 1 1 # include "photdbc.h" 2 # include <md5.h>3 # include <unistd.h> // needed?4 2 5 3 # define DEBUG 1 6 # define NBUFFER 5127 # define NDIGEST 168 9 # define DATA_ON_TGT 0x400010 # define DATA_COPY_FAILURE 0x800011 # define DATA_HOST_ID 0x3fff12 4 13 5 int CostToHostLocation (SkyList *skylist, HostTable *table) { … … 85 77 86 78 // need to re-open and re-read tgtname to check md5sum 79 md5_byte_t tgtDigest[NDIGEST]; 87 80 get_md5_with_copy (tgtname, NULL, tgtDigest); 88 81 … … 141 134 */ 142 135 143 // read a file, get the md5 sum, optionally write to 'output'144 int get_md5_with_copy (char *input, char *output, md5_byte_t *digest) {145 146 // open the src file147 FILE *fInput = fopen (input, "r");148 int fdInput = fileno (fInput);149 150 // open the tgt file151 FILE *fOutput = NULL;152 int fdOutput = 0;153 if (output) {154 fOutput = fopen (tgtname, "w");155 fdOutput = fileno (fOutput);156 }157 158 int nbytes;159 md5_state_t state;160 md5_byte_t buffer[NBUFFER];161 162 md5_init (&state);163 while ((nbytes = read (fdInput, buffer, NBUFFER)) > 0) {164 md5_append (&state, buffer, nbytes);165 if (output) {166 nbytes = write (fdOutput, buffer, NBUFFER);167 // XXX check that we actually write out all nbytes...168 }169 }170 md5_finish(&state, digest);171 172 fclose (fInput);173 flush (fInput);174 175 if (output) {176 fclose (fOutput);177 flush (fOutput);178 }179 return TRUE;180 }181 182 136 /* need to think a bit about behavior in the context of SPLIT vs MEF: 183 137 -
branches/eam_branches/ipp-20111122/Ohana/src/photdbc/src/HostTableLoad.c
r33204 r33207 1 1 # include "photdbc.h" 2 2 # define DEBUG 1 3 4 typedef struct {5 char *hostname;6 char *pathname;7 int hostID;8 } HostInfo9 10 typedef struct {11 int Nhosts;12 HostInfo *hosts;13 } HostTable14 3 15 4 void InitHosts (HostInfo *hosts, int Nhosts, int NHOSTS) { … … 34 23 } 35 24 36 HostTable *HostTableLoad () { 25 HostTable *HostTableLoad (char *catdir) { 26 27 char *filename = NULL; 28 29 ALLOCATE (filename, char, strlen(catdir) + strlen("/HostTable.dat") + 1); 30 sprintf (filename, "%s/HostTable.dat", catdir); 37 31 38 32 FILE *f = fopen (filename, "r"); -
branches/eam_branches/ipp-20111122/Ohana/src/photdbc/src/dvodist.c
r33206 r33207 1 # include " photdbc.h"1 # include "dvodist.h" 2 2 3 3 int main (int argc, char **argv) { … … 8 8 9 9 /* get configuration info, args, lockfile */ 10 initialize_dvodist (argc, argv); 10 initialize (argc, argv); 11 char *catdir = strcreate (argv[1]); 12 13 LockDatabase (catdir); 11 14 12 15 // dvodist (-out | -in) 13 16 // dvodist -out : host table represents new target locations 14 17 15 hosts = HostTableLoad (); 18 HostTable *hosts = HostTableLoad (catdir); 19 if (NULL) { 20 Shutdown ("failed to load Host Table for %s\n", catdir); 21 } 16 22 17 // the output catalog needs to inherit the SKY_DEPTH of the input catalog18 sky = SkyTableLoadOptimal ( CATDIR, NULL, GSCFILE, TRUE, SKY_DEPTH_HST, VERBOSE);19 SkyTableSetFilenames (sky, CATDIR, "cpt");20 skylist = SkyListByPatch (sky, -1, & REGION);23 // load the current SkyTable. If SkyTable does not exist, we must fail 24 sky = SkyTableLoadOptimal (catdir, NULL, NULL, TRUE, SKY_DEPTH_HST, VERBOSE); 25 SkyTableSetFilenames (sky, catdir, "cpt"); 26 skylist = SkyListByPatch (sky, -1, &UserPatch); 21 27 22 AssignSkyToHost (skylist, hosts); 28 switch (MODE) { 29 case MODE_OUT: 30 AssignSkyToHost (skylist, hosts); 31 CopyToHostLocation (skylist, hosts); 32 break; 33 case MODE_IN: 34 CopyFromHostLocation (skylist, hosts); 35 break; 36 default: 37 fprintf (stderr, "impossible!"); 38 abort(); 39 } 23 40 24 CopyToHostLocation (skylist, hosts);25 41 // XXX probably need to make this a skyregion_io.c function 42 // char *SkyTableFilename (char *catdir); 26 43 char *skyfile; 27 44 ALLOCATE (skyfile, char, strlen(catdir) + strlen("/SkyTable.fits") + 1); … … 31 48 exit (0); 32 49 } 50 51 /* things still missing AFAIK : 52 53 * switch based on MODE 54 * add header keyword to SkyTable to note existence of hostID 55 * code for CopyFromHostLocation 56 57 */ -
branches/eam_branches/ipp-20111122/Ohana/src/photdbc/src/initialize_dvodist.c
r33206 r33207 1 # include " photdbc.h"1 # include "dvodist.h" 2 2 3 void initialize _dvodist(int argc, char **argv) {3 void initialize (int argc, char **argv) { 4 4 5 5 /* are these set correctly? */ 6 if (get_argument (argc, argv, "-h")) usage _dvodist();7 if (get_argument (argc, argv, "--h")) usage _dvodist();8 if (get_argument (argc, argv, "-help")) usage _dvodist();9 if (get_argument (argc, argv, "--help")) usage _dvodist();6 if (get_argument (argc, argv, "-h")) usage(); 7 if (get_argument (argc, argv, "--h")) usage(); 8 if (get_argument (argc, argv, "-help")) usage(); 9 if (get_argument (argc, argv, "--help")) usage(); 10 10 11 11 // XXX anything? ConfigInit (&argc, argv); … … 13 13 } 14 14 15 void usage _dvodist() {15 void usage() { 16 16 17 17 fprintf (stderr, "USAGE: dvodist (-out | -in) (catdir)\n\n"); … … 36 36 37 37 /* specify portion of the sky */ 38 REGION.Rmin = 0;39 REGION.Rmax = 360;40 REGION.Dmin = -90;41 REGION.Dmax = +90;38 UserPatch.Rmin = 0; 39 UserPatch.Rmax = 360; 40 UserPatch.Dmin = -90; 41 UserPatch.Dmax = +90; 42 42 if ((N = get_argument (argc, argv, "-region"))) { 43 43 remove_argument (N, &argc, argv); 44 REGION.Rmin = atof (argv[N]);44 UserPatch.Rmin = atof (argv[N]); 45 45 remove_argument (N, &argc, argv); 46 REGION.Rmax = atof (argv[N]);46 UserPatch.Rmax = atof (argv[N]); 47 47 remove_argument (N, &argc, argv); 48 REGION.Dmin = atof (argv[N]);48 UserPatch.Dmin = atof (argv[N]); 49 49 remove_argument (N, &argc, argv); 50 REGION.Dmax = atof (argv[N]);50 UserPatch.Dmax = atof (argv[N]); 51 51 remove_argument (N, &argc, argv); 52 52 53 if ( REGION.Rmin == REGION.Rmax) {53 if (UserPatch.Rmin == UserPatch.Rmax) { 54 54 fprintf (stderr, "ERROR: selected region is ill-defined: Rmin == Rmax\n"); 55 55 exit (2); 56 56 } 57 if ( REGION.Dmin == REGION.Dmax) {57 if (UserPatch.Dmin == UserPatch.Dmax) { 58 58 fprintf (stderr, "ERROR: selected region is ill-defined: Dmin == Dmax\n"); 59 59 exit (2); … … 61 61 } 62 62 63 MODE = 0;63 MODE = MODE_NONE; 64 64 if ((N = get_argument (argc, argv, "-in"))) { 65 MODE = COPY_IN;65 MODE = MODE_IN; 66 66 remove_argument (N, &argc, argv); 67 67 } … … 69 69 if (!MODE) { 70 70 fprintf (stderr, "ERROR: cannot use both -in and -out options!\n"); 71 usage _dvodist();71 usage(); 72 72 } 73 MODE = COPY_OUT;73 MODE = MODE_OUT; 74 74 remove_argument (N, &argc, argv); 75 75 } 76 if (!MODE) usage(); 76 77 77 78 if (argc != 2) usage();
Note:
See TracChangeset
for help on using the changeset viewer.
