IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 6, 2017, 11:30:10 AM (10 years ago)
Author:
eugene
Message:

merging changes from czw dev branch (compare with r39924)

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/Ohana

  • trunk/Ohana/src/dvomerge/src/build_links.c

    r39536 r39926  
    1515data: they refer to the sequence number in the data blocks.
    1616
    17 next_meas is a list of the equivalent sequence of the measure block as if it were sorted.
     17next_measure is a list of the equivalent sequence of the measure block as if it were sorted.
    1818
    1919to find the sequence of measurements for a given average:
    2020n_0 = average->measureOffset
    21 n_1 = next_meas[n_0]
    22 n_i = next_meas[n_i-1]
     21n_1 = next_measure[n_0]
     22n_i = next_measure[n_i-1]
    2323
    2424*/
     
    3131
    3232  off_t i, j, N;
    33   off_t *next_meas;
     33  off_t *next_measure;
    3434
    3535  if (!measure) return NULL;
     
    3838  N = 0;
    3939
    40   ALLOCATE (next_meas, off_t, Nmeasure);
     40  ALLOCATE (next_measure, off_t, Nmeasure);
    4141  for (i = 0; i < Naverage; i++) {
    4242    if (!average[i].Nmeasure) continue;
     
    4545    for (j = 0; j < average[i].Nmeasure - 1; j++, N++) {
    4646      myAssert (measure[m+j+1].averef == i, "not sorted");
    47       next_meas[N] = N + 1;
     47      next_measure[N] = N + 1;
    4848      if (N >= Nmeasure) {
    4949        fprintf (stderr, "WARNING: N out of bounds (1)\n");
    5050      }
    5151    }
    52     next_meas[N] = -1;
     52    next_measure[N] = -1;
    5353    if (N >= Nmeasure) {
    5454      fprintf (stderr, "WARNING: N out of bounds (2)\n");
     
    6161    N++;
    6262  }
    63   return (next_meas);
     63  return (next_measure);
    6464}
    6565
     
    7474
    7575  off_t i, m, k, Nm, averef;
    76   off_t *next_meas;
    77 
    78   ALLOCATE (next_meas, off_t, Nmeasure);
     76  off_t *next_measure;
     77
     78  ALLOCATE (next_measure, off_t, Nmeasure);
    7979
    8080  /* reset the Nm, offset values for average */
     
    8787    averef = measure[Nm].averef;
    8888    m = average[averef].measureOffset; 
    89     next_meas[Nm] = -1;
     89    next_measure[Nm] = -1;
    9090
    9191    if (m == -1) { /* no links yet for source */
     
    9595    }
    9696
    97     for (k = 0; next_meas[m] != -1; k++) {
    98       m = next_meas[m];
     97    for (k = 0; next_measure[m] != -1; k++) {
     98      m = next_measure[m];
    9999      if (m >= Nmeasure) {
    100100        fprintf (stderr, "WARNING: m out of bounds (1)\n");
     
    103103
    104104    average[averef].Nmeasure = k + 2;
    105     next_meas[m] = Nm;
     105    next_measure[m] = Nm;
    106106    if (m >= Nmeasure) {
    107107      fprintf (stderr, "WARNING: m out of bounds (2)\n");
    108108    }
    109109  }
    110   return (next_meas);
     110  return (next_measure);
    111111}
    112112
    113113/* average[].measureOffset, average[].Nmeasure are valid within an addstar run */
    114 int add_meas_link (Average *average, off_t *next_meas, off_t Nmeasure, off_t NMEASURE) {
     114int add_measure_link (Average *average, off_t *next_measure, off_t Nmeasure, off_t NMEASURE) {
    115115
    116116  off_t k, m;
    117117
    118   /* if we have trouble, check validity of next_meas[m] : m < Nmeasure */
     118  /* if we have trouble, check validity of next_measure[m] : m < Nmeasure */
    119119  m = average[0].measureOffset; 
    120120
    121121  for (k = 0; k < average[0].Nmeasure - 1; k++)  {
    122     m = next_meas[m];
     122    m = next_measure[m];
    123123    if (m >= NMEASURE) {
    124124      fprintf (stderr, "WARNING: m out of bounds (3)\n");
     
    127127
    128128  /* set up references */
    129   next_meas[Nmeasure] = -1;
     129  next_measure[Nmeasure] = -1;
    130130  if (Nmeasure >= NMEASURE) {
    131131    fprintf (stderr, "WARNING: Nmeasure out of bounds (1)\n");
     
    136136    average[0].measureOffset = Nmeasure;
    137137  } else {
    138     next_meas[m] = Nmeasure;
     138    next_measure[m] = Nmeasure;
    139139    if (m >= NMEASURE) {
    140140      fprintf (stderr, "WARNING: m out of bounds (4)\n");
     
    145145}
    146146
    147 Measure *sort_measure (Average *average, off_t Naverage, Measure *measure, off_t Nmeasure, off_t *next_meas) {
     147Measure *sort_measure (Average *average, off_t Naverage, Measure *measure, off_t Nmeasure, off_t *next_measure) {
    148148
    149149  off_t i, k, n, np, N;
     
    169169      tmpmeasure[N].averef = i;
    170170      np = n;
    171       n = next_meas[n];
     171      n = next_measure[n];
    172172    }
    173173  }
     
    183183
    184184  off_t i, j, N;
    185   off_t *next_miss;
     185  off_t *next_missing;
    186186
    187187  N = 0;
    188188
    189   ALLOCATE (next_miss, off_t, Nmissing);
     189  ALLOCATE (next_missing, off_t, Nmissing);
    190190  for (i = 0; i < Naverage; i++) {
    191191    for (j = 0; j < average[i].Nmissing - 1; j++, N++) {
    192       next_miss[N] = N + 1;
     192      next_missing[N] = N + 1;
    193193    }
    194194    if (average[i].Nmissing > 0) {
    195       next_miss[N] = -1;
     195      next_missing[N] = -1;
    196196      if (N >= Nmissing) {
    197197        fprintf (stderr, "overflow in init_missing_links");
     
    202202
    203203  }
    204   return (next_miss);
    205 }
    206 
    207 int add_miss_link (Average *average, off_t *next_miss, off_t Nmissing) {
     204  return (next_missing);
     205}
     206
     207int add_missing_link (Average *average, off_t *next_missing, off_t Nmissing) {
    208208
    209209  off_t k, m;
     
    212212  if (average[0].Nmissing < 1) {
    213213    average[0].missingOffset = Nmissing;
    214     next_miss[Nmissing] = -1;
     214    next_missing[Nmissing] = -1;
    215215    return (TRUE);
    216216  }
    217217
    218218  m = average[0].missingOffset; 
    219   for (k = 0; k < average[0].Nmissing - 1; k++) m = next_miss[m];
     219  for (k = 0; k < average[0].Nmissing - 1; k++) m = next_missing[m];
    220220  /* set up references */
    221   next_miss[Nmissing] = -1;
    222   next_miss[m] = Nmissing;
     221  next_missing[Nmissing] = -1;
     222  next_missing[m] = Nmissing;
    223223  return (TRUE);
    224224}
     
    227227   we must always save the missing table, if it exists */
    228228
    229 Missing *sort_missing (Average *average, off_t Naverage, Missing *missing, off_t Nmissing, off_t *next_miss) {
     229Missing *sort_missing (Average *average, off_t Naverage, Missing *missing, off_t Nmissing, off_t *next_missing) {
    230230
    231231  off_t i, k, n, N;
     
    240240    for (k = 0; k < average[i].Nmissing; k++, N++) {
    241241      tmpmissing[N] = missing[n];
    242       n = next_miss[n];
     242      n = next_missing[n];
    243243    }
    244244  }
     
    254254
    255255  off_t i, j, N;
    256   off_t *next_lens;
     256  off_t *next_lensing;
    257257
    258258  if (!lensing) return NULL;
     
    261261  N = 0;
    262262
    263   ALLOCATE (next_lens, off_t, Nlensing);
     263  ALLOCATE (next_lensing, off_t, Nlensing);
    264264  for (i = 0; i < Naverage; i++) {
    265265    if (!average[i].Nlensing) continue;
     
    268268    for (j = 0; j < average[i].Nlensing - 1; j++, N++) {
    269269      myAssert (lensing[m+j+1].averef == i, "not sorted");
    270       next_lens[N] = N + 1;
     270      next_lensing[N] = N + 1;
    271271      if (N >= Nlensing) {
    272272        fprintf (stderr, "WARNING: N out of bounds (1)\n");
    273273      }
    274274    }
    275     next_lens[N] = -1;
     275    next_lensing[N] = -1;
    276276    if (N >= Nlensing) {
    277277      fprintf (stderr, "WARNING: N out of bounds (2)\n");
     
    284284    N++;
    285285  }
    286   return (next_lens);
     286  return (next_lensing);
    287287}
    288288
     
    297297
    298298  off_t i, m, k, Nm, averef;
    299   off_t *next_lens;
    300 
    301   ALLOCATE (next_lens, off_t, Nlensing);
     299  off_t *next_lensing;
     300
     301  ALLOCATE (next_lensing, off_t, Nlensing);
    302302
    303303  /* reset the Nm, offset values for average */
     
    310310    averef = lensing[Nm].averef;
    311311    m = average[averef].lensingOffset; 
    312     next_lens[Nm] = -1;
     312    next_lensing[Nm] = -1;
    313313
    314314    if (m == -1) { /* no links yet for source */
     
    318318    }
    319319
    320     for (k = 0; next_lens[m] != -1; k++) {
    321       m = next_lens[m];
     320    for (k = 0; next_lensing[m] != -1; k++) {
     321      m = next_lensing[m];
    322322      if (m >= Nlensing) {
    323323        fprintf (stderr, "WARNING: m out of bounds (1)\n");
     
    326326
    327327    average[averef].Nlensing = k + 2;
    328     next_lens[m] = Nm;
     328    next_lensing[m] = Nm;
    329329    if (m >= Nlensing) {
    330330      fprintf (stderr, "WARNING: m out of bounds (2)\n");
    331331    }
    332332  }
    333   return (next_lens);
     333  return (next_lensing);
    334334}
    335335
    336336/* average[].lensingOffset, average[].Nlensing are valid within an addstar run */
    337 int add_lens_link (Average *average, off_t *next_lens, off_t Nlensing, off_t NLENSING) {
     337int add_lensing_link (Average *average, off_t *next_lensing, off_t Nlensing, off_t NLENSING) {
    338338
    339339  off_t k, m;
    340340
    341   /* if we have trouble, check validity of next_lens[m] : m < Nlensing */
     341  /* if we have trouble, check validity of next_lensing[m] : m < Nlensing */
    342342  m = average[0].lensingOffset; 
    343343
    344344  for (k = 0; k < average[0].Nlensing - 1; k++)  {
    345     m = next_lens[m];
     345    m = next_lensing[m];
    346346    if (m >= NLENSING) {
    347347      fprintf (stderr, "WARNING: m out of bounds (3)\n");
     
    350350
    351351  /* set up references */
    352   next_lens[Nlensing] = -1;
     352  next_lensing[Nlensing] = -1;
    353353  if (Nlensing >= NLENSING) {
    354354    fprintf (stderr, "WARNING: Nlensing out of bounds (1)\n");
     
    359359    average[0].lensingOffset = Nlensing;
    360360  } else {
    361     next_lens[m] = Nlensing;
     361    next_lensing[m] = Nlensing;
    362362    if (m >= NLENSING) {
    363363      fprintf (stderr, "WARNING: m out of bounds (4)\n");
     
    368368}
    369369
    370 Lensing *sort_lensing (Average *average, off_t Naverage, Lensing *lensing, off_t Nlensing, off_t *next_lens) {
     370Lensing *sort_lensing (Average *average, off_t Naverage, Lensing *lensing, off_t Nlensing, off_t *next_lensing) {
    371371
    372372  off_t i, k, n, np, N;
     
    392392      tmplensing[N].averef = i;
    393393      np = n;
    394       n = next_lens[n];
     394      n = next_lensing[n];
    395395    }
    396396  }
    397397  free (lensing);
    398398  return (tmplensing);
     399}
     400
     401/*** Lensobj ****************************************************************************************/
     402
     403/* build the initial links assuming the table is sorted,
     404   not partial, and has a correct set of average[].lensobjOffset,Nlensobj values */
     405off_t *init_lensobj_links (Average *average, off_t Naverage, Lensobj *lensobj, off_t Nlensobj) {
     406
     407  off_t i, j, N;
     408  off_t *next_lensobj;
     409
     410  if (!lensobj) return NULL;
     411  if (SKIP_LENSOBJ) return NULL;
     412
     413  N = 0;
     414
     415  ALLOCATE (next_lensobj, off_t, Nlensobj);
     416  for (i = 0; i < Naverage; i++) {
     417    if (!average[i].Nlensobj) continue;
     418    // off_t m = average[i].lensobjOffset;
     419    // myAssert (lensobj[m].averef == i, "not sorted");
     420    for (j = 0; j < average[i].Nlensobj - 1; j++, N++) {
     421      // myAssert (lensobj[m+j+1].averef == i, "not sorted");
     422      next_lensobj[N] = N + 1;
     423      if (N >= Nlensobj) {
     424        fprintf (stderr, "WARNING: N out of bounds (1)\n");
     425      }
     426    }
     427    next_lensobj[N] = -1;
     428    if (N >= Nlensobj) {
     429      fprintf (stderr, "WARNING: N out of bounds (2)\n");
     430    }
     431
     432    if (N >= Nlensobj) {
     433      fprintf (stderr, "overflow in init_lensobj_links\n");
     434      abort ();
     435    }
     436    N++;
     437  }
     438  return (next_lensobj);
     439}
     440
     441/* construct lensobj links which are valid FOR THIS LOAD
     442 * - if we have a full load, we will get links which can
     443 *   be used by other programs (eg, relphot, etc)
     444 * - if we have a partial load, the links are only valid
     445 *   for that partial load
     446 */
     447
     448off_t *build_lensobj_links (Average *average, off_t Naverage, Lensobj *lensobj, off_t Nlensobj) {
     449
     450  fprintf (stderr, "input is not sorted but contains lensobj -- trouble\n");
     451  exit (2);
     452
     453# if (0)
     454
     455  off_t i, m, k, Nm, averef;
     456  off_t *next_lensobj;
     457
     458  ALLOCATE (next_lensobj, off_t, Nlensobj);
     459
     460  /* reset the Nm, offset values for average */
     461  for (i = 0; i < Naverage; i++) {
     462    average[i].lensobjOffset = -1;
     463    average[i].Nlensobj     =  0;
     464  }
     465
     466  for (Nm = 0; Nm < Nlensobj; Nm++) {
     467    averef = lensobj[Nm].averef;
     468    m = average[averef].lensobjOffset; 
     469    next_lensobj[Nm] = -1;
     470
     471    if (m == -1) { /* no links yet for source */
     472      average[averef].lensobjOffset = Nm;
     473      average[averef].Nlensobj     = 1;
     474      continue;
     475    }
     476
     477    for (k = 0; next_lensobj[m] != -1; k++) {
     478      m = next_lensobj[m];
     479      if (m >= Nlensobj) {
     480        fprintf (stderr, "WARNING: m out of bounds (1)\n");
     481      }
     482    }
     483
     484    average[averef].Nlensobj = k + 2;
     485    next_lensobj[m] = Nm;
     486    if (m >= Nlensobj) {
     487      fprintf (stderr, "WARNING: m out of bounds (2)\n");
     488    }
     489  }
     490  return (next_lensobj);
     491# endif
     492}
     493
     494/* average[].lensobjOffset, average[].Nlensobj are valid within an addstar run */
     495int add_lensobj_link (Average *average, off_t *next_lensobj, off_t Nlensobj, off_t NLENSOBJ) {
     496
     497  off_t k, m;
     498
     499  /* if we have trouble, check validity of next_lensobj[m] : m < Nlensobj */
     500  m = average[0].lensobjOffset; 
     501
     502  for (k = 0; k < average[0].Nlensobj - 1; k++)  {
     503    m = next_lensobj[m];
     504    if (m >= NLENSOBJ) {
     505      fprintf (stderr, "WARNING: m out of bounds (3)\n");
     506    }
     507  }
     508
     509  /* set up references */
     510  next_lensobj[Nlensobj] = -1;
     511  if (Nlensobj >= NLENSOBJ) {
     512    fprintf (stderr, "WARNING: Nlensobj out of bounds (1)\n");
     513  }
     514
     515  // if Nlensobj is 0, m may have been mis-set; add to the end
     516  if ((average[0].Nlensobj == 0) || (m == -1)) {
     517    average[0].lensobjOffset = Nlensobj;
     518  } else {
     519    next_lensobj[m] = Nlensobj;
     520    if (m >= NLENSOBJ) {
     521      fprintf (stderr, "WARNING: m out of bounds (4)\n");
     522    }
     523  }
     524
     525  return (TRUE);
     526}
     527
     528Lensobj *sort_lensobj (Average *average, off_t Naverage, Lensobj *lensobj, off_t Nlensobj, off_t *next_lensobj) {
     529
     530  off_t i, k, n, np, N;
     531  Lensobj *tmplensobj;
     532
     533  /* fix order of Lensobj (memory intensive, but fast) */
     534  np = -1;
     535  N = 0;
     536  ALLOCATE (tmplensobj, Lensobj, Nlensobj);
     537  for (i = 0; i < Naverage; i++) {
     538    if (!average[i].Nlensobj) continue;
     539    n = average[i].lensobjOffset;
     540    average[i].lensobjOffset = N;
     541    int myObjID = average[i].objID;
     542    for (k = 0; k < average[i].Nlensobj; k++, N++) {
     543      if (n == -1) {
     544        fprintf (stderr, "entry after %d has a problem\n", (int) np);
     545        abort();
     546      }
     547      tmplensobj[N] = lensobj[n];
     548      // myAssert (lensobj[n].averef == i, "error in averef");
     549      myAssert ((lensobj[n].objID == myObjID) || (lensobj[n].objID == -1), "error in objID?");
     550      // tmplensobj[N].averef = i;
     551      np = n;
     552      n = next_lensobj[n];
     553    }
     554  }
     555  free (lensobj);
     556  return (tmplensobj);
    399557}
    400558
     
    406564
    407565  off_t i, j, N;
    408   off_t *next_star;
     566  off_t *next_starpar;
    409567
    410568  if (!starpar) return NULL;
     
    415573  // NOTE that is we choose DVO_SKIP_STARPAR, catalog.starpar is NULL.
    416574  // this code will let merge_catalogs_old.c do nothing for starpar
    417   ALLOCATE (next_star, off_t, Nstarpar);
    418   if (!starpar) return next_star;
     575  ALLOCATE (next_starpar, off_t, Nstarpar);
     576  if (!starpar) return next_starpar;
    419577
    420578  for (i = 0; i < Naverage; i++) {
     
    424582    for (j = 0; j < average[i].Nstarpar - 1; j++, N++) {
    425583      myAssert (starpar[m+j+1].averef == i, "not sorted");
    426       next_star[N] = N + 1;
     584      next_starpar[N] = N + 1;
    427585      if (N >= Nstarpar) {
    428586        fprintf (stderr, "WARNING: N out of bounds (1)\n");
    429587      }
    430588    }
    431     next_star[N] = -1;
     589    next_starpar[N] = -1;
    432590    if (N >= Nstarpar) {
    433591      fprintf (stderr, "WARNING: N out of bounds (2)\n");
     
    440598    N++;
    441599  }
    442   return (next_star);
     600  return (next_starpar);
    443601}
    444602
     
    453611
    454612  off_t i, m, k, Nm, averef;
    455   off_t *next_star;
    456 
    457   ALLOCATE (next_star, off_t, Nstarpar);
    458   if (!starpar) return next_star;
     613  off_t *next_starpar;
     614
     615  ALLOCATE (next_starpar, off_t, Nstarpar);
     616  if (!starpar) return next_starpar;
    459617
    460618  /* reset the Nm, offset values for average */
     
    467625    averef = starpar[Nm].averef;
    468626    m = average[averef].starparOffset; 
    469     next_star[Nm] = -1;
     627    next_starpar[Nm] = -1;
    470628
    471629    if (m == -1) { /* no links yet for source */
     
    475633    }
    476634
    477     for (k = 0; next_star[m] != -1; k++) {
    478       m = next_star[m];
     635    for (k = 0; next_starpar[m] != -1; k++) {
     636      m = next_starpar[m];
    479637      if (m >= Nstarpar) {
    480638        fprintf (stderr, "WARNING: m out of bounds (1)\n");
     
    483641
    484642    average[averef].Nstarpar = k + 2;
    485     next_star[m] = Nm;
     643    next_starpar[m] = Nm;
    486644    if (m >= Nstarpar) {
    487645      fprintf (stderr, "WARNING: m out of bounds (2)\n");
    488646    }
    489647  }
    490   return (next_star);
     648  return (next_starpar);
    491649}
    492650
    493651/* average[].starparOffset, average[].Nstarpar are valid within an addstar run */
    494 int add_star_link (Average *average, off_t *next_star, off_t Nstarpar, off_t NSTARPAR) {
     652int add_starpar_link (Average *average, off_t *next_starpar, off_t Nstarpar, off_t NSTARPAR) {
    495653
    496654  off_t k, m;
    497655
    498   /* if we have trouble, check validity of next_star[m] : m < Nstarpar */
     656  /* if we have trouble, check validity of next_starpar[m] : m < Nstarpar */
    499657  m = average[0].starparOffset; 
    500658
    501659  for (k = 0; k < average[0].Nstarpar - 1; k++)  {
    502     m = next_star[m];
     660    m = next_starpar[m];
    503661    if (m >= NSTARPAR) {
    504662      fprintf (stderr, "WARNING: m out of bounds (3)\n");
     
    507665
    508666  /* set up references */
    509   next_star[Nstarpar] = -1;
     667  next_starpar[Nstarpar] = -1;
    510668  if (Nstarpar >= NSTARPAR) {
    511669    fprintf (stderr, "WARNING: Nstarpar out of bounds (1)\n");
     
    516674    average[0].starparOffset = Nstarpar;
    517675  } else {
    518     next_star[m] = Nstarpar;
     676    next_starpar[m] = Nstarpar;
    519677    if (m >= NSTARPAR) {
    520678      fprintf (stderr, "WARNING: m out of bounds (4)\n");
     
    525683}
    526684
    527 StarPar *sort_starpar (Average *average, off_t Naverage, StarPar *starpar, off_t Nstarpar, off_t *next_star) {
     685StarPar *sort_starpar (Average *average, off_t Naverage, StarPar *starpar, off_t Nstarpar, off_t *next_starpar) {
    528686
    529687  off_t i, k, n, np, N;
     
    552710      tmpstarpar[N].averef = i;
    553711      np = n;
    554       n = next_star[n];
     712      n = next_starpar[n];
    555713    }
    556714  }
     
    566724
    567725  off_t i, j, N;
    568   off_t *next_galp;
     726  off_t *next_galphot;
    569727
    570728  if (galphot) return NULL;
     
    573731  N = 0;
    574732
    575   ALLOCATE (next_galp, off_t, Ngalphot);
     733  ALLOCATE (next_galphot, off_t, Ngalphot);
    576734  for (i = 0; i < Naverage; i++) {
    577735    if (!average[i].Ngalphot) continue;
     
    580738    for (j = 0; j < average[i].Ngalphot - 1; j++, N++) {
    581739      myAssert (galphot[m+j+1].averef == i, "not sorted");
    582       next_galp[N] = N + 1;
     740      next_galphot[N] = N + 1;
    583741      if (N >= Ngalphot) {
    584742        fprintf (stderr, "WARNING: N out of bounds (1)\n");
    585743      }
    586744    }
    587     next_galp[N] = -1;
     745    next_galphot[N] = -1;
    588746    if (N >= Ngalphot) {
    589747      fprintf (stderr, "WARNING: N out of bounds (2)\n");
     
    596754    N++;
    597755  }
    598   return (next_galp);
     756  return (next_galphot);
    599757}
    600758
     
    609767
    610768  off_t i, m, k, Nm, averef;
    611   off_t *next_galp;
    612 
    613   ALLOCATE (next_galp, off_t, Ngalphot);
     769  off_t *next_galphot;
     770
     771  ALLOCATE (next_galphot, off_t, Ngalphot);
    614772
    615773  /* reset the Nm, offset values for average */
     
    622780    averef = galphot[Nm].averef;
    623781    m = average[averef].galphotOffset; 
    624     next_galp[Nm] = -1;
     782    next_galphot[Nm] = -1;
    625783
    626784    if (m == -1) { /* no links yet for source */
     
    630788    }
    631789
    632     for (k = 0; next_galp[m] != -1; k++) {
    633       m = next_galp[m];
     790    for (k = 0; next_galphot[m] != -1; k++) {
     791      m = next_galphot[m];
    634792      if (m >= Ngalphot) {
    635793        fprintf (stderr, "WARNING: m out of bounds (1)\n");
     
    638796
    639797    average[averef].Ngalphot = k + 2;
    640     next_galp[m] = Nm;
     798    next_galphot[m] = Nm;
    641799    if (m >= Ngalphot) {
    642800      fprintf (stderr, "WARNING: m out of bounds (2)\n");
    643801    }
    644802  }
    645   return (next_galp);
     803  return (next_galphot);
    646804}
    647805
    648806/* average[].galphotOffset, average[].Ngalphot are valid within an addstar run */
    649 int add_galp_link (Average *average, off_t *next_galp, off_t Ngalphot, off_t NGALPHOT) {
     807int add_galphot_link (Average *average, off_t *next_galphot, off_t Ngalphot, off_t NGALPHOT) {
    650808
    651809  off_t k, m;
    652810
    653   /* if we have trouble, check validity of next_galp[m] : m < Ngalphot */
     811  /* if we have trouble, check validity of next_galphot[m] : m < Ngalphot */
    654812  m = average[0].galphotOffset; 
    655813
    656814  for (k = 0; k < average[0].Ngalphot - 1; k++)  {
    657     m = next_galp[m];
     815    m = next_galphot[m];
    658816    if (m >= NGALPHOT) {
    659817      fprintf (stderr, "WARNING: m out of bounds (3)\n");
     
    662820
    663821  /* set up references */
    664   next_galp[Ngalphot] = -1;
     822  next_galphot[Ngalphot] = -1;
    665823  if (Ngalphot >= NGALPHOT) {
    666824    fprintf (stderr, "WARNING: Ngalphot out of bounds (1)\n");
     
    671829    average[0].galphotOffset = Ngalphot;
    672830  } else {
    673     next_galp[m] = Ngalphot;
     831    next_galphot[m] = Ngalphot;
    674832    if (m >= NGALPHOT) {
    675833      fprintf (stderr, "WARNING: m out of bounds (4)\n");
     
    680838}
    681839
    682 GalPhot *sort_galphot (Average *average, off_t Naverage, GalPhot *galphot, off_t Ngalphot, off_t *next_galp) {
     840GalPhot *sort_galphot (Average *average, off_t Naverage, GalPhot *galphot, off_t Ngalphot, off_t *next_galphot) {
    683841
    684842  off_t i, k, n, np, N;
     
    704862      tmpgalphot[N].averef = i;
    705863      np = n;
    706       n = next_galp[n];
     864      n = next_galphot[n];
    707865    }
    708866  }
Note: See TracChangeset for help on using the changeset viewer.