IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 25, 2012, 9:21:15 AM (14 years ago)
Author:
eugene
Message:

fix mmatch for parallel ops

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/dvo/mmatch.c

    r34462 r34463  
    7878  DECvec = NULL;
    7979  if (PARALLEL && !HOST_ID) {
     80
     81    // We need to copy the args to a temp array and modify them so that we send the
     82    // correct set to the remote client.  The args list looks like this:
     83    // if (!CoordsFile) : mmatch (RA) (DEC) (RADIUS) field, ...
     84    // if ( CoordsFile) : mmatch (RADIUS) field, ... [because we stripped off the -coords filename elements]
     85
     86    // allocate the temp array and copy all but (RA) (DEC)
     87    int targc = 0;
     88    char **targv = NULL;
     89    ALLOCATE (targv, char *, argc + 2);
     90    for (i = 0; i < argc; i++) {
     91      if (!CoordsFile && (i == 1)) continue;
     92      if (!CoordsFile && (i == 2)) continue;
     93      targv[targc] = strcreate (argv[i]);
     94      targc ++;
     95    }
     96
     97    // if not specified, create the coords.fits input file
    8098    if (!CoordsFile) {
    8199      // get vectors corresponding to coordinates of interest
     
    92110    }
    93111
    94     char *targv1 = argv[1];
    95     char *targv2 = argv[2];
    96     argv[1] = strcreate ("-coords");
    97     argv[2] = strcreate (CoordsFile);
    98     free (CoordsFile);
    99 
    100     // I need to pass the RA & DEC vectors to the remote clients...
    101     int status = HostTableParallelOps (argc, argv, RESULT_FILE, 0, VERBOSE);
     112    // add the coords file to the args list
     113    targv[targc+0] = strcreate ("-coords");
     114    targv[targc+1] = CoordsFile; // this gets freed with targv
     115    targc += 2;
     116   
     117    // if needed, add the index vector to the args list
     118    if (IDXvec) {
     119      REALLOCATE (targv, char *, targc + 2);
     120      targv[targc+0] = strcreate ("-index");
     121      targv[targc+1] = strcreate (IDXvec[0].name);
     122      targc += 2;
     123    }     
     124
     125    // call the remote client
     126    int status = HostTableParallelOps (targc, targv, RESULT_FILE, 0, VERBOSE);
    102127    if (vec) free (vec);
    103128   
    104     free (argv[1]);
    105     free (argv[2]);
    106     argv[1] = targv1;
    107     argv[2] = targv2;
     129    // free up targv
     130    for (i = 0; i < targc; i++) {
     131      free (targv[i]);
     132    }
     133    free (targv);
    108134
    109135    return status;
     
    278304  // only write the fields which were in a valid catalog
    279305  if (RESULT_FILE) {
    280     // extend the array by one to hold index array
    281     REALLOCATE (vec, Vector *, Nfields + 1);
    282     vec[Nfields] = IDXvec;
    283 
    284     int status = WriteVectorTableFITS (RESULT_FILE, "RESULT", vec, Nfields + 1, FALSE, NULL);
     306    if (IDXvec) {
     307      // extend the array by one to hold index array
     308      Nfields ++;
     309      REALLOCATE (vec, Vector *, Nfields);
     310      vec[Nfields-1] = IDXvec;
     311    }
     312    int status = WriteVectorTableFITS (RESULT_FILE, "RESULT", vec, Nfields, FALSE, NULL);
    285313    if (!status) goto escape;
    286314  }
Note: See TracChangeset for help on using the changeset viewer.