IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 39409


Ignore:
Timestamp:
Feb 26, 2016, 8:31:22 PM (10 years ago)
Author:
eugene
Message:

working on very pedantic gcc to track down memory corruption issues

Location:
branches/eam_branches/ohana.20160226/src
Files:
40 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ohana.20160226/src/libdvo/include/libdvo_astro.h

    r39245 r39409  
    6868  AstromOffsetMap **map;
    6969   int *imageIDtoTableSeq;
    70   int MaxImageID;
    71   int MaxTableID;
     70  unsigned int MaxImageID;
     71  unsigned int MaxTableID;
    7272} AstromOffsetTable;
    7373
  • branches/eam_branches/ohana.20160226/src/libdvo/src/AstromOffsetMapIO.c

    r38986 r39409  
    148148AstromOffsetTable *AstromOffsetMapToTable(AstromOffsetMap_Disk_6x6 *map_disk, off_t Nmap) {
    149149
    150   int i, j, k;
     150  unsigned int i;
     151  int j, k;
    151152
    152153  AstromOffsetTable *table = NULL;
     
    157158
    158159  // find the max value of imageID
    159   int MaxTableID = 0;
    160   int MaxImageID = 0;
     160  unsigned int MaxTableID = 0;
     161  unsigned int MaxImageID = 0;
    161162  for (i = 0; i < Nmap; i++) {
    162     MaxTableID = MAX(map_disk[i].tableID, MaxTableID);
    163     MaxImageID = MAX(map_disk[i].imageID, MaxImageID);
     163    MaxTableID = MAX(MaxTableID, map_disk[i].tableID);
     164    MaxImageID = MAX(MaxImageID, map_disk[i].imageID);
    164165  }
    165166  table->MaxTableID = MaxTableID;
     
    312313int AstromOffsetTableSetIDs (AstromOffsetTable *table) {
    313314
    314   int i;
    315 
    316315  // find the max value of imageID
    317   int MaxTableID = 0;
    318   int MaxImageID = 0;
    319   for (i = 0; i < table->Nmap; i++) {
    320     MaxTableID = MAX(table->map[i][0].tableID, MaxTableID);
    321     MaxImageID = MAX(table->map[i][0].imageID, MaxImageID);
    322   }
    323   table->MaxTableID = MaxTableID;
    324   table->MaxImageID = MaxImageID;
     316  unsigned int MaxTableID = 0;
     317  unsigned int MaxImageID = 0;
     318  {
     319    int j;
     320    for (j = 0; j < table->Nmap; j++) {
     321      MaxTableID = MAX(MaxTableID, table->map[j][0].tableID);
     322      MaxImageID = MAX(MaxImageID, table->map[j][0].imageID);
     323    }
     324    table->MaxTableID = MaxTableID;
     325    table->MaxImageID = MaxImageID;
     326  }
    325327
    326328  // generate the index and init values to -1
    327   ALLOCATE (table->imageIDtoTableSeq, int, MaxImageID + 1);
    328   for (i = 0; i <= MaxImageID; i++) {
    329     table->imageIDtoTableSeq[i] = -1;
     329  {
     330    unsigned int i;
     331    ALLOCATE (table->imageIDtoTableSeq, int, MaxImageID + 1);
     332    for (i = 0; i <= MaxImageID; i++) {
     333      table->imageIDtoTableSeq[i] = -1;
     334    }
    330335  }
    331336
    332337  // assign the ID values
    333   for (i = 0; i < table->Nmap; i++) {
    334     int ImageID = table->map[i][0].imageID;
    335     myAssert (table->imageIDtoTableSeq[ImageID] == -1, "oops, duplicate image IDs");
    336     table->imageIDtoTableSeq[ImageID] = i;
     338  {
     339    int j;
     340    for (j = 0; j < table->Nmap; j++) {
     341      int ImageID = table->map[j][0].imageID;
     342      myAssert (table->imageIDtoTableSeq[ImageID] == -1, "oops, duplicate image IDs");
     343      table->imageIDtoTableSeq[ImageID] = j;
     344    }
    337345  }
    338346  return TRUE;
  • branches/eam_branches/ohana.20160226/src/libdvo/src/AstromOffsetMapUtils.c

    r38986 r39409  
    1111  off_t i;
    1212  for (i = 0; i < Nimages; i++) {
    13     int imageID = images[i].imageID;
    14     if (imageID < 0) continue;
     13    if (images[i].imageID < 0) continue;
     14
     15    unsigned int imageID = images[i].imageID;
    1516    if (imageID > table->MaxImageID) continue;
    1617   
  • branches/eam_branches/ohana.20160226/src/libdvo/src/dvo_catalog_chipcoords.c

    r37035 r39409  
    11# include <dvo.h>
    22
    3 int dvo_match_image (Image *image, int Nimage, unsigned int T, short int S) {
     3int dvo_match_image (Image *image, int Nimage, int T, short int S) {
    44
    55  int N, Nlo, Nhi, N1, N2;
  • branches/eam_branches/ohana.20160226/src/libdvo/src/dvo_catalog_mef.c

    r38441 r39409  
    1717     it is not defined for a legacy database, we can generate them using the existing index values.
    1818     If it is missing, give a warning and recommend the user upgrade the DB */
    19   if (!gfits_scan (&catalog[0].header, "OBJID",    "%d", 1, &catalog[0].objID)) {
     19  if (!gfits_scan (&catalog[0].header, "OBJID",    "%u", 1, &catalog[0].objID)) {
    2020    if (VERBOSE) fprintf (stderr, "WARNING: OBJID is not set for %s: upgrade for full feature set\n", catalog[0].filename);
    2121    catalog[0].objID = 0;
    2222  }
    23   if (!gfits_scan (&catalog[0].header, "CATID",    "%d", 1, &catalog[0].catID)) {
     23  if (!gfits_scan (&catalog[0].header, "CATID",    "%u", 1, &catalog[0].catID)) {
    2424    if (VERBOSE) fprintf (stderr, "WARNING: CATID is not set for %s: upgrade for full feature set\n", catalog[0].filename);
    2525    catalog[0].catID = 0;
  • branches/eam_branches/ohana.20160226/src/libdvo/src/dvo_catalog_raw.c

    r38441 r39409  
    2929     it is not defined for a legacy database, we can generate them using the existing index values.
    3030     If it is missing, give a warning and recommend the user upgrade the DB */
    31   if (!gfits_scan (&catalog[0].header, "OBJID",    "%d", 1, &catalog[0].objID)) {
     31  if (!gfits_scan (&catalog[0].header, "OBJID",    "%u", 1, &catalog[0].objID)) {
    3232    if (VERBOSE) fprintf (stderr, "WARNING: OBJID is not set for this database: upgrade for full feature set\n");
    3333    catalog[0].objID = 0;
    3434  }
    35   if (!gfits_scan (&catalog[0].header, "CATID",    "%d", 1, &catalog[0].catID)) {
     35  if (!gfits_scan (&catalog[0].header, "CATID",    "%u", 1, &catalog[0].catID)) {
    3636    if (VERBOSE) fprintf (stderr, "WARNING: CATID is not set for this database: upgrade for full feature set\n");
    3737    catalog[0].catID = 0;
  • branches/eam_branches/ohana.20160226/src/libdvo/src/dvo_convert.c

    r38986 r39409  
    320320
    321321Missing *FtableToMissing (FTable *ftable, Average *average, off_t *Nmissing, DVOCatFormat *format, char nativeBytes) {
     322  OHANA_UNUSED_PARAM(average);
    322323
    323324  Missing *missing;
     
    397398
    398399SecFilt *FtableToSecFilt (FTable *ftable, Average *average, off_t *Nsecfilt, DVOCatFormat *format, char nativeBytes) {
     400  OHANA_UNUSED_PARAM(average);
    399401
    400402  SecFilt *secfilt;
     
    509511
    510512Lensing *FtableToLensing (FTable *ftable, Average *average, off_t *Nlensing, DVOCatFormat *format, char nativeBytes) {
     513  OHANA_UNUSED_PARAM(average);
    511514
    512515  Lensing *lensing;
     
    652655
    653656Lensobj *FtableToLensobj (FTable *ftable, Average *average, off_t *Nlensobj, DVOCatFormat *format, char nativeBytes) {
     657  OHANA_UNUSED_PARAM(average);
    654658
    655659  Lensobj *lensobj;
     
    769773
    770774StarPar *FtableToStarPar (FTable *ftable, Average *average, off_t *Nstarpar, DVOCatFormat *format, char nativeBytes) {
     775  OHANA_UNUSED_PARAM(average);
    771776
    772777  StarPar *starpar;
     
    874879
    875880GalPhot *FtableToGalPhot (FTable *ftable, Average *average, off_t *Ngalphot, DVOCatFormat *format, char nativeBytes) {
     881  OHANA_UNUSED_PARAM(average);
    876882
    877883  GalPhot *galphot;
  • branches/eam_branches/ohana.20160226/src/libdvo/src/dvo_convert_PS1_DEV_1.c

    r38462 r39409  
    100100// 'primary' is needed to conform with the API for Loneos and Elixir, but is not used
    101101Average *Average_PS1_DEV_1_ToInternal (Average_PS1_DEV_1 *in, off_t Nvalues, SecFilt **primary) {
     102  OHANA_UNUSED_PARAM(primary);
    102103
    103104  off_t i;
     
    138139// 'primary' is needed to conform with the API for Loneos and Elixir, but is not used
    139140Average_PS1_DEV_1 *AverageInternalTo_PS1_DEV_1 (Average *in, off_t Nvalues, SecFilt *primary) {
     141  OHANA_UNUSED_PARAM(primary);
    140142
    141143  off_t i;
  • branches/eam_branches/ohana.20160226/src/libdvo/src/dvo_convert_PS1_DEV_2.c

    r38462 r39409  
    9797// 'primary' is needed to conform with the API for Loneos and Elixir, but is not used
    9898Average *Average_PS1_DEV_2_ToInternal (Average_PS1_DEV_2 *in, off_t Nvalues, SecFilt **primary) {
     99  OHANA_UNUSED_PARAM(primary);
    99100
    100101  off_t i;
     
    133134// 'primary' is needed to conform with the API for Loneos and Elixir, but is not used
    134135Average_PS1_DEV_2 *AverageInternalTo_PS1_DEV_2 (Average *in, off_t Nvalues, SecFilt *primary) {
     136  OHANA_UNUSED_PARAM(primary);
    135137
    136138  off_t i;
  • branches/eam_branches/ohana.20160226/src/libdvo/src/dvo_convert_PS1_REF.c

    r38462 r39409  
    5555// 'primary' is needed to conform with the API for Loneos and Elixir, but is not used
    5656Average *Average_PS1_REF_ToInternal (Average_PS1_REF *in, off_t Nvalues, SecFilt **primary) {
     57  OHANA_UNUSED_PARAM(primary);
    5758
    5859  off_t i;
     
    8081// 'primary' is needed to conform with the API for Loneos and Elixir, but is not used
    8182Average_PS1_REF *AverageInternalTo_PS1_REF (Average *in, off_t Nvalues, SecFilt *primary) {
     83  OHANA_UNUSED_PARAM(primary);
    8284
    8385  off_t i;
  • branches/eam_branches/ohana.20160226/src/libdvo/src/dvo_convert_PS1_SIM.c

    r39262 r39409  
    44
    55Measure *Measure_PS1_SIM_ToInternal (Average *ave, Measure_PS1_SIM *in, off_t Nvalues) {
     6  OHANA_UNUSED_PARAM(ave);
    67
    78  off_t i;
     
    5152
    5253Measure_PS1_SIM *MeasureInternalTo_PS1_SIM (Average *ave, Measure *in, off_t Nvalues) {
     54  OHANA_UNUSED_PARAM(ave);
    5355
    5456  off_t i;
     
    9799// 'primary' is needed to conform with the API for Loneos and Elixir, but is not used
    98100Average *Average_PS1_SIM_ToInternal (Average_PS1_SIM *in, off_t Nvalues, SecFilt **primary) {
     101  OHANA_UNUSED_PARAM(primary);
    99102
    100103  off_t i;
     
    143146// 'primary' is needed to conform with the API for Loneos and Elixir, but is not used
    144147Average_PS1_SIM *AverageInternalTo_PS1_SIM (Average *in, off_t Nvalues, SecFilt *primary) {
     148  OHANA_UNUSED_PARAM(primary);
    145149
    146150  off_t i;
  • branches/eam_branches/ohana.20160226/src/libdvo/src/dvo_convert_PS1_V1.c

    r38462 r39409  
    115115// 'primary' is needed to conform with the API for Loneos and Elixir, but is not used
    116116Average *Average_PS1_V1_ToInternal (Average_PS1_V1 *in, off_t Nvalues, SecFilt **primary) {
     117  OHANA_UNUSED_PARAM(primary);
    117118
    118119  off_t i;
     
    152153// 'primary' is needed to conform with the API for Loneos and Elixir, but is not used
    153154Average_PS1_V1 *AverageInternalTo_PS1_V1 (Average *in, off_t Nvalues, SecFilt *primary) {
     155  OHANA_UNUSED_PARAM(primary);
    154156
    155157  off_t i;
  • branches/eam_branches/ohana.20160226/src/libdvo/src/dvo_convert_PS1_V2.c

    r38462 r39409  
    116116// 'primary' is needed to conform with the API for Loneos and Elixir, but is not used
    117117Average *Average_PS1_V2_ToInternal (Average_PS1_V2 *in, off_t Nvalues, SecFilt **primary) {
     118  OHANA_UNUSED_PARAM(primary);
    118119
    119120  off_t i;
     
    157158// 'primary' is needed to conform with the API for Loneos and Elixir, but is not used
    158159Average_PS1_V2 *AverageInternalTo_PS1_V2 (Average *in, off_t Nvalues, SecFilt *primary) {
     160  OHANA_UNUSED_PARAM(primary);
    159161
    160162  off_t i;
  • branches/eam_branches/ohana.20160226/src/libdvo/src/dvo_convert_PS1_V3.c

    r38462 r39409  
    116116// 'primary' is needed to conform with the API for Loneos and Elixir, but is not used
    117117Average *Average_PS1_V3_ToInternal (Average_PS1_V3 *in, off_t Nvalues, SecFilt **primary) {
     118  OHANA_UNUSED_PARAM(primary);
    118119
    119120  off_t i;
     
    159160// 'primary' is needed to conform with the API for Loneos and Elixir, but is not used
    160161Average_PS1_V3 *AverageInternalTo_PS1_V3 (Average *in, off_t Nvalues, SecFilt *primary) {
     162  OHANA_UNUSED_PARAM(primary);
    161163
    162164  off_t i;
  • branches/eam_branches/ohana.20160226/src/libdvo/src/dvo_convert_PS1_V4.c

    r38462 r39409  
    134134// 'primary' is needed to conform with the API for Loneos and Elixir, but is not used
    135135Average *Average_PS1_V4_ToInternal (Average_PS1_V4 *in, off_t Nvalues, SecFilt **primary) {
     136  OHANA_UNUSED_PARAM(primary);
    136137
    137138  off_t i;
     
    180181// 'primary' is needed to conform with the API for Loneos and Elixir, but is not used
    181182Average_PS1_V4 *AverageInternalTo_PS1_V4 (Average *in, off_t Nvalues, SecFilt *primary) {
     183  OHANA_UNUSED_PARAM(primary);
    182184
    183185  off_t i;
  • branches/eam_branches/ohana.20160226/src/libdvo/src/dvo_convert_PS1_V5.c

    r39262 r39409  
    44
    55Measure *Measure_PS1_V5_ToInternal (Average *ave, Measure_PS1_V5 *in, off_t Nvalues) {
     6  OHANA_UNUSED_PARAM(ave);
    67
    78  off_t i;
     
    7980
    8081Measure_PS1_V5 *MeasureInternalTo_PS1_V5 (Average *ave, Measure *in, off_t Nvalues) {
     82  OHANA_UNUSED_PARAM(ave);
    8183
    8284  off_t i;
     
    153155// 'primary' is needed to conform with the API for Loneos and Elixir, but is not used
    154156Average *Average_PS1_V5_ToInternal (Average_PS1_V5 *in, off_t Nvalues, SecFilt **primary) {
     157  OHANA_UNUSED_PARAM(primary);
    155158
    156159  off_t i;
     
    225228// 'primary' is needed to conform with the API for Loneos and Elixir, but is not used
    226229Average_PS1_V5 *AverageInternalTo_PS1_V5 (Average *in, off_t Nvalues, SecFilt *primary) {
     230  OHANA_UNUSED_PARAM(primary);
    227231
    228232  off_t i;
     
    16401644
    16411645Measure *Measure_PS1_V5alt_ToInternal (Average *ave, Measure_PS1_V5alt *in, off_t Nvalues) {
     1646  OHANA_UNUSED_PARAM(ave);
    16421647
    16431648  off_t i;
  • branches/eam_branches/ohana.20160226/src/libdvo/src/dvo_convert_panstarrs_DEV_0.c

    r38462 r39409  
    106106// 'primary is needed to conform with the API for Loneos and Elixir, but is not used
    107107Average *Average_Panstarrs_DEV_0_ToInternal (Average_Panstarrs_DEV_0 *in, off_t Nvalues, SecFilt **primary) {
     108  OHANA_UNUSED_PARAM(primary);
    108109
    109110  off_t i;
     
    143144// 'primary is needed to conform with the API for Loneos and Elixir, but is not used
    144145Average_Panstarrs_DEV_0 *AverageInternalTo_Panstarrs_DEV_0 (Average *in, off_t Nvalues, SecFilt *primary) {
     146  OHANA_UNUSED_PARAM(primary);
    145147
    146148  off_t i;
  • branches/eam_branches/ohana.20160226/src/libdvo/src/dvo_convert_panstarrs_DEV_1.c

    r38462 r39409  
    106106// 'primary is needed to conform with the API for Loneos and Elixir, but is not used
    107107Average *Average_Panstarrs_DEV_1_ToInternal (Average_Panstarrs_DEV_1 *in, off_t Nvalues, SecFilt **primary) {
     108  OHANA_UNUSED_PARAM(primary);
    108109
    109110  off_t i;
     
    143144// 'primary is needed to conform with the API for Loneos and Elixir, but is not used
    144145Average_Panstarrs_DEV_1 *AverageInternalTo_Panstarrs_DEV_1 (Average *in, off_t Nvalues, SecFilt *primary) {
     146  OHANA_UNUSED_PARAM(primary);
    145147
    146148  off_t i;
  • branches/eam_branches/ohana.20160226/src/libdvo/src/dvo_photcode_ops.c

    r39277 r39409  
    467467/***/
    468468float PhotAve (PhotCode *code, Average *average, SecFilt *secfilt, dvoMagClassType class, dvoMagSourceType source) {
     469  OHANA_UNUSED_PARAM(average);
    469470
    470471  if (code == NULL) return NAN;
     
    572573
    573574float PhotCalErr (Measure *measure, dvoMagClassType class) {
     575  OHANA_UNUSED_PARAM(class);
    574576
    575577  float dMcal = measure[0].dMcal;
     
    578580
    579581float PhotAveErr (PhotCode *code, Average *average, SecFilt *secfilt, dvoMagClassType class, dvoMagSourceType source) {
     582  OHANA_UNUSED_PARAM(average);
    580583
    581584  if (code == NULL) return NAN;
     
    640643
    641644float PhotZeroPoint (Measure *measure, Average *average, SecFilt *secfilt) {
     645  OHANA_UNUSED_PARAM(average);
     646  OHANA_UNUSED_PARAM(secfilt);
    642647
    643648  int Np;
     
    710715
    711716float PhotMstdev (PhotCode *code, Average *average, SecFilt *secfilt, dvoMagClassType class, dvoMagSourceType source) {
     717  OHANA_UNUSED_PARAM(average);
    712718
    713719  if (code == NULL) return NAN;
     
    757763// return the number of detections in this filter (gpc1)
    758764int PhotNcode (PhotCode *code, Average *average, SecFilt *secfilt) {
     765  OHANA_UNUSED_PARAM(average);
    759766
    760767  if (code == NULL) return 0;
     
    768775// return the number of detections in this filter (gpc1)
    769776int PhotSecfiltFlags (PhotCode *code, Average *average, SecFilt *secfilt) {
     777  OHANA_UNUSED_PARAM(average);
    770778
    771779  if (code == NULL) return 0;
     
    778786
    779787int PhotNphot (PhotCode *code, Average *average, SecFilt *secfilt, dvoMagClassType class, dvoMagSourceType source) {
     788  OHANA_UNUSED_PARAM(average);
    780789
    781790  if (code == NULL) return 0;
     
    824833
    825834float PhotAveFluxPSF (PhotCode *code, Average *average, SecFilt *secfilt) {
     835  OHANA_UNUSED_PARAM(average);
    826836
    827837  int Ns;
     
    836846
    837847float PhotAvedFluxPSF (PhotCode *code, Average *average, SecFilt *secfilt) {
     848  OHANA_UNUSED_PARAM(average);
    838849
    839850  int Ns;
     
    848859
    849860float PhotAveFluxKron (PhotCode *code, Average *average, SecFilt *secfilt) {
     861  OHANA_UNUSED_PARAM(average);
    850862
    851863  int Ns;
     
    860872
    861873float PhotAvedFluxKron (PhotCode *code, Average *average, SecFilt *secfilt) {
     874  OHANA_UNUSED_PARAM(average);
    862875
    863876  int Ns;
     
    872885
    873886float PhotMmin (PhotCode *code, Average *average, SecFilt *secfilt) {
     887  OHANA_UNUSED_PARAM(average);
    874888
    875889  int Ns;
     
    884898
    885899float PhotMmax (PhotCode *code, Average *average, SecFilt *secfilt) {
     900  OHANA_UNUSED_PARAM(average);
    886901
    887902  int Ns;
     
    896911
    897912float PhotUCdist (PhotCode *code, Average *average, SecFilt *secfilt) {
     913  OHANA_UNUSED_PARAM(average);
    898914
    899915  int Ns;
     
    921937// Xm is now (2014.07.03) stored as the chisq except in dvo formats which use as short
    922938float PhotXm (PhotCode *code, Average *average, SecFilt *secfilt) {
     939  OHANA_UNUSED_PARAM(average);
    923940
    924941  int Ns;
     
    11881205/***/
    11891206float PhotFluxAve (PhotCode *code, Average *average, SecFilt *secfilt, dvoMagClassType class, dvoMagSourceType source) {
     1207  OHANA_UNUSED_PARAM(average);
    11901208
    11911209  if (code == NULL) return NAN;
     
    12481266
    12491267float PhotFluxAveErr (PhotCode *code, Average *average, SecFilt *secfilt, dvoMagClassType class, dvoMagSourceType source) {
     1268  OHANA_UNUSED_PARAM(average);
    12501269
    12511270  if (code == NULL) return NAN;
     
    16101629/***/
    16111630float PhotAveTiny (PhotCode *code, AverageTiny *average, SecFilt *secfilt, dvoMagClassType class, dvoMagSourceType source) {
     1631  OHANA_UNUSED_PARAM(average);
    16121632
    16131633  if (code == NULL) return NAN;
     
    17461766
    17471767float PhotdMTiny (PhotCode *code, AverageTiny *average, SecFilt *secfilt) {
     1768  OHANA_UNUSED_PARAM(average);
    17481769
    17491770  int Ns;
     
    17591780// Xm is now (2014.07.03) stored as the chisq except in dvo formats which use as short
    17601781float PhotXmTiny (PhotCode *code, AverageTiny *average, SecFilt *secfilt) {
     1782  OHANA_UNUSED_PARAM(average);
    17611783
    17621784  int Ns;
     
    18531875}
    18541876
    1855 LENSFIELD(X11_sm_obj);
    1856 LENSFIELD(X12_sm_obj);
    1857 LENSFIELD(X22_sm_obj);
    1858 LENSFIELD(E1_sm_obj);
    1859 LENSFIELD(E2_sm_obj);
    1860 
    1861 LENSFIELD(X11_sh_obj);
    1862 LENSFIELD(X12_sh_obj);
    1863 LENSFIELD(X22_sh_obj);
    1864 LENSFIELD(E1_sh_obj);
    1865 LENSFIELD(E2_sh_obj);
    1866 
    1867 LENSFIELD(X11_sm_psf);
    1868 LENSFIELD(X12_sm_psf);
    1869 LENSFIELD(X22_sm_psf);
    1870 LENSFIELD(E1_sm_psf);
    1871 LENSFIELD(E2_sm_psf);
    1872 
    1873 LENSFIELD(X11_sh_psf);
    1874 LENSFIELD(X12_sh_psf);
    1875 LENSFIELD(X22_sh_psf);
    1876 LENSFIELD(E1_sh_psf);
    1877 LENSFIELD(E2_sh_psf);
    1878 
    1879 LENSFIELD( F_ApR5);
    1880 LENSFIELD(dF_ApR5);
    1881 LENSFIELD(sF_ApR5);
    1882 LENSFIELD(fF_ApR5);
    1883 
    1884 LENSFIELD( F_ApR6);
    1885 LENSFIELD(dF_ApR6);
    1886 LENSFIELD(sF_ApR6);
    1887 LENSFIELD(fF_ApR6);
    1888 
    1889 LENSFIELD( F_ApR7);
    1890 LENSFIELD(dF_ApR7);
    1891 LENSFIELD(sF_ApR7);
    1892 LENSFIELD(fF_ApR7);
    1893 
    1894 LENSFIELD(E1);
    1895 LENSFIELD(E2);
     1877LENSFIELD(X11_sm_obj)
     1878LENSFIELD(X12_sm_obj)
     1879LENSFIELD(X22_sm_obj)
     1880LENSFIELD(E1_sm_obj)
     1881LENSFIELD(E2_sm_obj)
     1882
     1883LENSFIELD(X11_sh_obj)
     1884LENSFIELD(X12_sh_obj)
     1885LENSFIELD(X22_sh_obj)
     1886LENSFIELD(E1_sh_obj)
     1887LENSFIELD(E2_sh_obj)
     1888
     1889LENSFIELD(X11_sm_psf)
     1890LENSFIELD(X12_sm_psf)
     1891LENSFIELD(X22_sm_psf)
     1892LENSFIELD(E1_sm_psf)
     1893LENSFIELD(E2_sm_psf)
     1894
     1895LENSFIELD(X11_sh_psf)
     1896LENSFIELD(X12_sh_psf)
     1897LENSFIELD(X22_sh_psf)
     1898LENSFIELD(E1_sh_psf)
     1899LENSFIELD(E2_sh_psf)
     1900
     1901LENSFIELD( F_ApR5)
     1902LENSFIELD(dF_ApR5)
     1903LENSFIELD(sF_ApR5)
     1904LENSFIELD(fF_ApR5)
     1905
     1906LENSFIELD( F_ApR6)
     1907LENSFIELD(dF_ApR6)
     1908LENSFIELD(sF_ApR6)
     1909LENSFIELD(fF_ApR6)
     1910
     1911LENSFIELD( F_ApR7)
     1912LENSFIELD(dF_ApR7)
     1913LENSFIELD(sF_ApR7)
     1914LENSFIELD(fF_ApR7)
     1915
     1916LENSFIELD(E1)
     1917LENSFIELD(E2)
    18961918
    18971919# if (1)
  • branches/eam_branches/ohana.20160226/src/libdvo/src/dvosorts.c

    r36084 r39409  
    7676/* sort a coordinate pair (X,Y) and the associated index (S) */
    7777void sort_coords_indexonly (double *X, double *Y, off_t *S, off_t N) {
     78  OHANA_UNUSED_PARAM(Y);
    7879 
    7980# define SWAPFUNC(A,B){ off_t itmp; \
  • branches/eam_branches/ohana.20160226/src/libfits/extern/gzip.c

    r38986 r39409  
    122122
    123123  z_stream stream;
    124   int i, err;
     124  int err;
    125125 
    126126  stream.next_in = (Bytef*)source;
     
    140140  if (EXTRA_VERBOSE) {
    141141    fprintf (stderr, "inp cmp: ");
     142    unsigned long int i;
    142143    for (i = 0; i < sourceLen; i++) {
    143144      fprintf (stderr, "0x%02hhx ", source[i]);
     
    165166  if (EXTRA_VERBOSE) {
    166167    fprintf (stderr, "out cmp: ");
     168    unsigned long int i;
    167169    for (i = 0; i < stream.total_out; i++) {
    168170      fprintf (stderr, "0x%02hhx ", dest[i]);
     
    182184
    183185  z_stream stream;
    184   int i, err;
     186  int err;
    185187 
    186188  stream.next_in = (Bytef*)source;
     
    200202  if (EXTRA_VERBOSE) {
    201203    fprintf (stderr, "inp unc: ");
     204    unsigned long int i;
    202205    for (i = 0; i < sourceLen; i++) {
    203206      fprintf (stderr, "0x%02hhx ", source[i]);
     
    226229  if (EXTRA_VERBOSE) {
    227230    fprintf (stderr, "out unc: ");
     231    unsigned long int i;
    228232    for (i = 0; i < stream.total_out; i++) {
    229233      fprintf (stderr, "0x%02hhx ", dest[i]);
  • branches/eam_branches/ohana.20160226/src/libfits/header/F_write_H.c

    r38553 r39409  
    2525    myAssert (myBlock->startblock == OHANA_MEMMAGIC, "bad memory");
    2626    myAssert (myBlock->endblock == OHANA_MEMMAGIC, "bad memory");
    27     myAssert (myBlock->size >= header[0].datasize, "overflow");
     27    myAssert (myBlock->size >= (size_t) header[0].datasize, "overflow");
    2828  }
    2929# endif
  • branches/eam_branches/ohana.20160226/src/libfits/include/gfitsio.h

    r39394 r39409  
    193193
    194194int     gfits_uncompress_image         PROTO((Header *header, Matrix *matrix, FTable *ftable));
    195 int     gfits_uncompress_data          PROTO((char *zdata, int Nzdata, char *cmptype, char **optname, char **optvalue, int Nopt, char *outdata, int *Nout, int Nout_alloc, int out_pixsize));
    196 int     gfits_distribute_data          PROTO((Matrix *matrix, char *data, int Ndata, int bitpix, int *otile, int oblank, int *ztile, int zblank, float zscale, float zzero));
    197 
    198 int     gfits_compress_data            PROTO((char *zdata, int *Nzdata, char *cmptype, char **optname, char **optvalue, int Nopt, char *rawdata, int Nraw, int raw_pixsize, int Nx, int Ny));
    199 int     gfits_compress_image           PROTO((Header *header, Matrix *matrix, FTable *ftable, int *Ztile, char *zcmptype));
    200 int     gfits_collect_data             PROTO((Matrix *matrix, char *raw, int Nraw, int raw_pixsize, int *otile, int oblank, int *ztile, int zblank, float zscale, float zzero));
     195int     gfits_uncompress_data          PROTO((char *zdata, unsigned long int Nzdata, char *cmptype, char **optname, char **optvalue, int Nopt, char *outdata, unsigned long int *Nout, unsigned long int Nout_alloc, int out_pixsize));
     196int     gfits_distribute_data          PROTO((Matrix *matrix, char *data, unsigned long int Ndata, int bitpix, int *otile, int oblank, unsigned long int *ztile, int zblank, float zscale, float zzero));
     197
     198int     gfits_compress_data            PROTO((char *zdata, unsigned long int *Nzdata, char *cmptype, char **optname, char **optvalue, int Nopt, char *rawdata, unsigned long int Nraw, int raw_pixsize, int Nx, int Ny));
     199int     gfits_compress_image           PROTO((Header *header, Matrix *matrix, FTable *ftable, unsigned long int *Ztile, char *zcmptype));
     200int     gfits_collect_data             PROTO((Matrix *matrix, char *raw, unsigned long int Nraw, int raw_pixsize, int *otile, int oblank, unsigned long int *ztile, int zblank, float zscale, float zzero));
    201201
    202202int     gfits_copy_keywords_compress   PROTO((Header *srchead, Header *tgthead));
    203203int     gfits_swap_raw                 PROTO((Matrix *matrix));
    204204
    205 off_t   gfits_tile_size                PROTO((Matrix *matrix, int *otile, int *ztile));
    206 int     gfits_imtile_maxsize           PROTO((Matrix *matrix, int *ztile));
    207 int     gfits_imtile_count             PROTO((Matrix *matrix, int *ztile, int *ntile));
     205off_t   gfits_tile_size                PROTO((Matrix *matrix, int *otile, unsigned long int *ztile));
     206int     gfits_imtile_maxsize           PROTO((Matrix *matrix, unsigned long int *ztile));
     207int     gfits_imtile_count             PROTO((Matrix *matrix, unsigned long int *ztile, int *ntile));
    208208int     gfits_imtile_start             PROTO((Matrix *matrix, int *otile));
    209 int     gfits_imtile_next              PROTO((Matrix *matrix, int *ztile, int *ntile, int *otile));
     209int     gfits_imtile_next              PROTO((Matrix *matrix, unsigned long int *ztile, int *ntile, int *otile));
    210210
    211211int     gfits_extension_is_compressed_image  PROTO((Header *header));
    212212int     gfits_extension_is_compressed_table  PROTO((Header *header));
    213 int     gfits_byteswap_zdata            PROTO((char *zdata, int Nzdata, int pixsize));
     213int     gfits_byteswap_zdata            PROTO((char *zdata, off_t Nzdata, int pixsize));
    214214int     gfits_compressed_data_pixsize   PROTO((char *cmptype, int out_bitpix, char **optname, char **optvalue, int Noptions));
    215215int     gfits_uncompressed_data_pixsize PROTO((char *cmptype, int out_bitpix, char **optname, char **optvalue, int Noptions));
     
    279279int     gfits_write_Theader            PROTO((char *filename, Header *header));
    280280
    281 int     gfits_compress_table           PROTO((FTable *srctable, FTable *tgttable, int ztilelen, char *zcmptype));
     281int     gfits_compress_table           PROTO((FTable *srctable, FTable *tgttable, unsigned long int ztilelen, char *zcmptype));
    282282int     gfits_uncompress_table         PROTO((FTable *srctable, FTable *tgttable));
    283283
  • branches/eam_branches/ohana.20160226/src/libfits/matrix/F_compress_M.c

    r38441 r39409  
    44# define VERBOSE_DUMP 0
    55
    6 int gfits_collect_gzp2 (Matrix *matrix, char *raw, int Nraw, int raw_bitpix, int *otile, int oblank, int *ztile, int zblank, float zscale, float zzero);
     6int gfits_collect_gzp2 (Matrix *matrix, char *raw, unsigned long int Nraw, int raw_bitpix, int *otile, int oblank, unsigned long int *ztile, int zblank, float zscale, float zzero);
    77
    88// the user needs to specify the various compression options:
     
    2323# define ESCAPE { fprintf (stderr, "error in %s @ line %d\n", __func__, __LINE__); goto escape; }
    2424
    25 int gfits_compress_image (Header *header, Matrix *matrix, FTable *ftable, int *Ztile, char *zcmptype) {
     25int gfits_compress_image (Header *header, Matrix *matrix, FTable *ftable, unsigned long int *Ztile, char *zcmptype) {
    2626
    2727  int i;
     
    3333  char *zdata = NULL;
    3434
    35   int *ztile = Ztile;
     35  unsigned long int *ztile = Ztile;
    3636
    3737  Header *theader = ftable->header;
     
    4141  // determine the number of tiles (from ztile[] and image size)
    4242  if (!ztile) {
    43     ALLOCATE (ztile, int, matrix->Naxes);
     43    ALLOCATE (ztile, unsigned long int, matrix->Naxes);
    4444    ztile[0] = matrix->Naxis[0];
    4545    for (i = 1; i < matrix->Naxes; i++) ztile[i] = 1;
     
    9999  for (i = 0; i < header->Naxes; i++) {
    100100    snprintf (keyword, 10, "ZTILE%d", i + 1);
    101     if (!gfits_modify (theader, keyword, "%d", 1, ztile[i])) ESCAPE;
     101    if (!gfits_modify (theader, keyword, "%lu", 1, ztile[i])) ESCAPE;
    102102  }
    103103
     
    157157
    158158  // size (in pixels) of the largest tile
    159   int max_tile_size = gfits_imtile_maxsize (matrix, ztile);
     159  unsigned long int max_tile_size = gfits_imtile_maxsize (matrix, ztile);
    160160
    161161  // size of a pixel in the raw pixel buffer (before compression)
     
    179179
    180180  // allocate the buffer for compression work
    181   int Nzdata_alloc = raw_pixsize*max_tile_size + 100;
     181  unsigned long int Nzdata_alloc = raw_pixsize*max_tile_size + 100;
    182182  ALLOCATE (raw,   char, raw_pixsize*max_tile_size);
    183183  ALLOCATE (zdata, char, Nzdata_alloc);
     
    191191
    192192    // size of the current tile in pixels
    193     int Nraw = gfits_tile_size (matrix, otile, ztile);
     193    unsigned long int Nraw = gfits_tile_size (matrix, otile, ztile);
    194194
    195195    // copy the raw pixels from their native matrix locations to the temporary output buffer
     
    216216      if (!gfits_byteswap_zdata (raw, Nraw * raw_pixsize, raw_pixsize)) ESCAPE;
    217217    }
    218     int Nzdata = Nzdata_alloc; // available space, replaced with actual output size on compression
     218    unsigned long int Nzdata = Nzdata_alloc; // available space, replaced with actual output size on compression
    219219
    220220    if (VERBOSE_DUMP && (i == 0)) {
     
    223223      for (k = 0; k < 64; k++) { fprintf (stderr, "%02hhx", raw[k]); if (k % 4 == 3) fprintf (stderr, " "); }
    224224      fprintf (stderr, "\n");
    225       fprintf (stderr, "Nzdata: %d -> ", Nzdata);
     225      fprintf (stderr, "Nzdata: %lu -> ", Nzdata);
    226226    }
    227227
     
    231231    if (VERBOSE_DUMP && (i == 0)) {
    232232      int k;
    233       fprintf (stderr, "%d\n", Nzdata);
     233      fprintf (stderr, "%lu\n", Nzdata);
    234234      fprintf (stderr, "cmp SWP: ");
    235235      for (k = 0; k < 64; k++) { fprintf (stderr, "%02hhx", zdata[k]); if (k % 4 == 3) fprintf (stderr, " "); }
     
    290290
    291291int gfits_copy_keywords_compress (Header *srchead, Header *tgthead) {
    292 
     292  OHANA_UNUSED_PARAM(tgthead);
     293  OHANA_UNUSED_PARAM(srchead);
     294
     295# if (0)
    293296  int i;
    294297
    295298  for (i = 0; i < srchead->datasize; i += FT_LINE_LENGTH) {
    296299  }
     300# endif
     301
    297302  return TRUE;
    298303}
     
    303308// * ztile gives the size of the i-th dimension of the current tile
    304309// * raw_bitpix defines the size and type of the raw buffer
    305 int gfits_collect_data (Matrix *matrix, char *raw, int Nraw, int raw_bitpix, int *otile, int oblank, int *ztile, int zblank, float zscale, float zzero) {
    306 
    307   int i, j, start, offset, coord, Nline;
    308   int *counter = NULL;
    309   int *Ztile = NULL;
    310 
    311   ALLOCATE (counter, int, matrix->Naxes); // counter for current row in tile to copy
    312   ALLOCATE (Ztile, int, matrix->Naxes); // true sizes of this tile (in pixels)
     310int gfits_collect_data (Matrix *matrix, char *raw, unsigned long int Nraw, int raw_bitpix, int *otile, int oblank, unsigned long int *ztile, int zblank, float zscale, float zzero) {
     311
     312  int i, k, start, offset, coord, Nline;
     313  unsigned int *counter = NULL;
     314  unsigned long int *Ztile = NULL;
     315
     316  ALLOCATE (counter, unsigned int, matrix->Naxes); // counter for current row in tile to copy
     317  ALLOCATE (Ztile, unsigned long int, matrix->Naxes); // true sizes of this tile (in pixels)
    313318 
    314319  for (i = 0; i < matrix->Naxes; i++) {
     
    343348  // this macro is used at the inner switch to run the actual loop
    344349# define SCALE_AND_DIST_INT_PRINT(TYPE, SIZE, INTYPE) {                 \
     350    unsigned long int j;                                                \
    345351    TYPE *TILEptr = (TYPE *) &matrix->buffer[SIZE*(offset + start)];    \
    346352    for (j = 0; j < Ztile[0]; j++, TILEptr++, RAWptr++) {               \
     
    356362  // this macro is used at the inner switch to run the actual loop
    357363# define SCALE_AND_DIST_INT(OTYPE, OSIZE) {                             \
     364    unsigned long int j;                                                \
    358365    OTYPE *TILEptr = (OTYPE *) &matrix->buffer[OSIZE*(offset + start)]; \
    359366    for (j = 0; j < Ztile[0]; j++, TILEptr++, RAWptr++) {               \
     
    370377  // this macro is used at the inner switch to run the actual loop
    371378# define SCALE_AND_DIST_FLOAT(OTYPE, OSIZE) {                           \
     379    unsigned long int j;                                                \
    372380    OTYPE *TILEptr = (OTYPE *) &matrix->buffer[OSIZE*(offset + start)]; \
    373381    for (j = 0; j < Ztile[0]; j++, TILEptr++, RAWptr++) {               \
     
    419427
    420428    // update the counters, carrying to the next dimension if needed
    421     for (j = 1; j < matrix->Naxes; j++) {
    422       counter[j] ++;
    423       if (counter[j] == Ztile[j]) {
    424         counter[j] = 0;
     429    for (k = 1; k < matrix->Naxes; k++) {
     430      counter[k] ++;
     431      if (counter[k] == Ztile[k]) {
     432        counter[k] = 0;
    425433      } else {
    426434        break;
    427435      }
    428436    }
    429     if (j == matrix->Naxes) assert (i == Nline - 1); // we should be done here...
     437    if (k == matrix->Naxes) assert (i == Nline - 1); // we should be done here...
    430438
    431439    // Naxes = 3
     
    435443    // determine the offset of the next line relative to the start position
    436444    offset = counter[matrix->Naxes - 1];
    437     for (j = matrix->Naxes - 2; j >= 0; j--) {
    438       offset = offset*matrix->Naxis[j] + counter[j];
     445    for (k = matrix->Naxes - 2; k >= 0; k--) {
     446      offset = offset*matrix->Naxis[k] + counter[k];
    439447    }     
    440448  }
     
    453461// * ztile gives the size of the i-th dimension of the current tile
    454462// * raw_bitpix defines the size and type of the raw buffer
    455 int gfits_collect_gzp2 (Matrix *matrix, char *raw, int Nraw, int raw_bitpix, int *otile, int oblank, int *ztile, int zblank, float zscale, float zzero) {
    456 
    457   int i, j, k;
    458   int *counter = NULL;
    459   int *Ztile = NULL;
    460 
    461   ALLOCATE (counter, int, matrix->Naxes); // counter for current row in tile to copy
    462   ALLOCATE (Ztile, int, matrix->Naxes); // true sizes of this tile (in pixels)
     463int gfits_collect_gzp2 (Matrix *matrix, char *raw, unsigned long int Nraw, int raw_bitpix, int *otile, int oblank, unsigned long int *ztile, int zblank, float zscale, float zzero) {
     464  OHANA_UNUSED_PARAM(oblank);
     465  OHANA_UNUSED_PARAM(zblank);
     466  OHANA_UNUSED_PARAM(zzero);
     467  OHANA_UNUSED_PARAM(zscale);
     468
     469  unsigned long int i, j;
     470  unsigned int *counter = NULL;
     471  unsigned long int *Ztile = NULL;
     472
     473  ALLOCATE (counter, unsigned int, matrix->Naxes); // counter for current row in tile to copy
     474  ALLOCATE (Ztile, unsigned long int, matrix->Naxes); // true sizes of this tile (in pixels)
    463475 
    464   for (i = 0; i < matrix->Naxes; i++) {
    465     counter[i] = 0;
    466     Ztile[i] = MIN ((matrix->Naxis[i] - otile[i]*ztile[i]), ztile[i]);
     476  int k;
     477  for (k = 0; k < matrix->Naxes; k++) {
     478    counter[k] = 0;
     479    Ztile[k] = MIN ((matrix->Naxis[k] - otile[k]*ztile[k]), ztile[k]);
    467480  }
    468481
    469482  // number of lines in the tile (in pixels)
    470   int Nline = 1;
    471   int Npix = matrix->Naxis[0];
    472   for (i = 1; i < matrix->Naxes; i++) {
    473     Nline *= Ztile[i];
    474     Npix  *= matrix->Naxis[i];
     483  unsigned long int Nline = 1;
     484  unsigned long int Npix = matrix->Naxis[0];
     485  for (k = 1; k < matrix->Naxes; k++) {
     486    Nline *= Ztile[k];
     487    Npix  *= matrix->Naxis[k];
    475488  }
    476489
     
    482495  // start = otile[0]*ztile[0] + Naxis[0]*(otile[1]*ztile[1] + Naxis[1]*(otile[2]*ztile[2] + ...));
    483496  int start = otile[matrix->Naxes-1]*ztile[matrix->Naxes-1];
    484   for (i = matrix->Naxes - 2; i >= 0; i--) {
    485     int coord = otile[i]*ztile[i];
    486     start = start*matrix->Naxis[i] + coord;
     497  for (k = matrix->Naxes - 2; k >= 0; k--) {
     498    unsigned long int coord = otile[k]*ztile[k];
     499    start = start*matrix->Naxis[k] + coord;
    487500  }
    488501 
     
    519532
    520533      // update the counters, carrying to the next dimension if needed
    521       for (j = 1; j < matrix->Naxes; j++) {
    522         counter[j] ++;
    523         if (counter[j] == Ztile[j]) {
    524           counter[j] = 0;
     534      int axis;
     535      for (axis = 1; axis < matrix->Naxes; axis++) {
     536        counter[axis] ++;
     537        if (counter[axis] == Ztile[axis]) {
     538          counter[axis] = 0;
    525539        } else {
    526540          break;
    527541        }
    528542      }
    529       if (j == matrix->Naxes) assert (i == Nline - 1); // we should be done here...
     543      if (axis == matrix->Naxes) assert (i == Nline - 1); // we should be done here...
    530544
    531545      // Naxes = 3
     
    535549      // determine the offset of the next line relative to the start position
    536550      offset = counter[matrix->Naxes - 1];
    537       for (j = matrix->Naxes - 2; j >= 0; j--) {
    538         offset = offset*matrix->Naxis[j] + counter[j];
     551      for (axis = matrix->Naxes - 2; axis >= 0; axis--) {
     552        offset = offset*matrix->Naxis[axis] + counter[axis];
    539553      }     
    540554    }
  • branches/eam_branches/ohana.20160226/src/libfits/matrix/F_compress_data.c

    r38986 r39409  
    22# include <gfitsio.h>
    33# include <zlib.h>
    4 
    5 /* functions defined in ricecomp.c */
    6 int fits_rcomp(int a[], int nx, unsigned char *c, int clen, int nblock);
    7 int fits_rcomp_short(short a[], int nx, unsigned char *c, int clen, int nblock);
    8 int fits_rcomp_byte(char a[], int nx, unsigned char *c, int clen, int nblock);
    9 int fits_rdecomp (unsigned char *c, int clen, unsigned int array[], int nx, int nblock);
    10 int fits_rdecomp_short (unsigned char *c, int clen, unsigned short array[], int nx, int nblock);
    11 int fits_rdecomp_byte (unsigned char *c, int clen, unsigned char array[], int nx, int nblock);
    12 
    13 /* functions defined in fits_hcompress.c */
    14 # define LONGLONG long long
    15 int fits_hcompress(int *a, int ny, int nx, int scale, char *output, long *nbytes, int *status);
    16 int fits_hcompress64(LONGLONG *a, int ny, int nx, int scale, char *output, long *nbytes, int *status);
    17 
    18 /* functions defined in fits_hdeccompress.c */
    19 int fits_hdecompress(unsigned char *input, int smooth, int *a, int *ny, int *nx, int *scale, int *status);
    20 int fits_hdecompress64(unsigned char *input, int smooth, LONGLONG *a, int *ny, int *nx, int *scale, int *status);
    21 
    22 /* functions defined in pliocomp.c */
    23 int pl_p2li (int *pxsrc, int xs, short *lldst, int npix);
    24 int pl_l2pi (short *ll_src, int xs, int *px_dst, int npix);
    25 
    26 /* functions defined in gzip.c */
    27 int gfits_gz_stripheader (unsigned char *data, int *ndata);
    28 int gfits_uncompress (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen);
    29 int gfits_compress (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen);
     4# include <gfits_compress.h>
    305
    316# define ESCAPE(RET) { fprintf (stderr, "gzip error in %s @ %s:%d\n", __func__, __FILE__, __LINE__); return (RET); }
     
    338// XXX I'm putting Nx and Ny on the argument list -- only used by hcompress
    349// with a little work, these could go on the option list
    35 int gfits_compress_data (char *zdata, int *Nzdata, char *cmptype,
    36                          char **optname, char **optvalue, int Nopt,
    37                          char *rawdata, int Nrawpix, int rawpix_size,
    38                          int Nx, int Ny) {
     10int gfits_compress_data (char *zdata, unsigned long int *Nzdata, char *cmptype, char **optname, char **optvalue, int Nopt, char *rawdata, unsigned long int Nrawpix, int rawpix_size, int Nx, int Ny) {
    3911
    40   int Nout;
    4112  int status;
    4213
     
    6839
    6940  if (!strcasecmp(cmptype, "RICE_1") || !strcasecmp(cmptype, "RICE_ONE")) {
     41    long int Nout;
    7042    int i, blocksize;
    7143    // look for the BLOCKSIZE
     
    8557    // fprintf (stderr, "%d comp bytes; %d uncomp 'pixels', totals: %d %d\n", Nzdata, Npix, Ninsum, Noutsum);
    8658
    87     int k;
    88 
    8959    switch (rawpix_size) {
    9060      case 4:
     
    9868
    9969        if (0) {
    100           fprintf (stderr, "Nout: %d, Nrawpix: %d\n", Nout, Nrawpix);
     70          long int k;
     71          fprintf (stderr, "Nout: %lu, Nrawpix: %lu\n", Nout, Nrawpix);
    10172          fprintf (stderr, "cmp inp: ");
    10273          for (k = 0; k < Nout; k++) { fprintf (stderr, "%02hhx", zdata[k]); if (k % 2) fprintf (stderr, " "); }
     
    11990      return (FALSE);
    12091    }
    121     if (Nout > *Nzdata) {
    122       fprintf (stderr, "buffer overrun! %d out, %d available\n", Nout, *Nzdata);
     92    if (Nout > (long int) *Nzdata) {
     93      fprintf (stderr, "buffer overrun! %ld out, %lu available\n", Nout, *Nzdata);
    12394      return FALSE;
    12495    }
    125     *Nzdata = Nout;
     96    *Nzdata = (unsigned long int) Nout;
    12697    return TRUE;
    12798  }
     
    129100  if (!strcasecmp(cmptype, "PLIO_1")) {
    130101    // note the fortan starting point: zdata is decremented at start
    131     Nout = pl_p2li ((int *) rawdata, 1, (short *) zdata, Nrawpix);
     102    int Nout = pl_p2li ((int *) rawdata, 1, (short *) zdata, Nrawpix);
    132103    *Nzdata = Nout;
    133104    if (!Nout) return (FALSE);
  • branches/eam_branches/ohana.20160226/src/libfits/matrix/F_compress_utils.c

    r38441 r39409  
    1717
    1818typedef struct {
    19   int *ztile; // max size of a tile (edge tiles may be smaller)
     19  unsigned long int *ztile; // max size of a tile (edge tiles may be smaller)
    2020  int *otile; // counter for current tile (eg, for (2,3,0) otile[0] = 2, otile[1] = 3, otile[2] = 0)
    2121  int *ntile; // number of tiles in dimension [i]
     
    2323
    2424// advance the otile counter.
    25 int gfits_imtile_next (Matrix *matrix, int *ztile, int *ntile, int *otile) {
     25int gfits_imtile_next (Matrix *matrix, unsigned long int *ztile, int *ntile, int *otile) {
     26  OHANA_UNUSED_PARAM(ztile);
    2627
    2728  int i;
     
    5354
    5455// how many tiles needed for this image (given ztile[])
    55 int gfits_imtile_count (Matrix *matrix, int *ztile, int *ntile) {
     56int gfits_imtile_count (Matrix *matrix, unsigned long int *ztile, int *ntile) {
    5657
    5758  int i;
     
    6768
    6869// how many tiles needed for this image (given ztile[])
    69 int gfits_imtile_maxsize (Matrix *matrix, int *ztile) {
     70int gfits_imtile_maxsize (Matrix *matrix, unsigned long int *ztile) {
    7071
    7172  int i;
    7273
    73   int max_tile_size = 1;
     74  unsigned long int max_tile_size = 1;
    7475  for (i = 0; i < matrix->Naxes; i++) {
    7576    max_tile_size *= ztile[i];
     
    8081
    8182// true sizes of this tile (in pixels)
    82 off_t gfits_tile_size (Matrix *matrix, int *otile, int *ztile) {
     83off_t gfits_tile_size (Matrix *matrix, int *otile, unsigned long int *ztile) {
    8384
    8485  off_t i, Npixels, Ndimen;
     
    9394}
    9495
    95 int gfits_byteswap_zdata (char *zdata, int Nzdata, int pixsize) {
     96int gfits_byteswap_zdata (char *zdata, off_t Nzdata, int pixsize) {
    9697
    9798# define DOSWAP(A,B) { char tmp = A; A = B; B = tmp; }
     
    99100# ifdef BYTE_SWAP
    100101
    101   int i;
     102  off_t i;
    102103
    103104  // fprintf (stderr, "swapping %d bytes in pix of size %d bytes...\n", Nzdata, pixsize);
  • branches/eam_branches/ohana.20160226/src/libfits/matrix/F_convert_format.c

    r38062 r39409  
    1919  in  = (inMode  *) matrix[0].buffer;                   \
    2020  for (i = 0; i < Npixels; i++, out++, in++)            \
    21     if (*in == inBlank) {                               \
     21    if (*in == (inMode) inBlank) {                      \
    2222      *out = (MY_NAN);                                  \
    2323    } else {                                            \
     
    3232  in  = (inMode  *) matrix[0].buffer;           \
    3333  for (i = 0; i < Npixels; i++, out++, in++)    \
    34     if (*in == inBlank) {                       \
     34    if (*in == (inMode) inBlank) {                      \
    3535      *out = (MY_NAN);                          \
    3636    } else {                                    \
     
    4545  in  = (inMode  *)matrix[0].buffer + Npixels - 1;      \
    4646  for (i = 0; i < Npixels; i++, out--, in--)            \
    47     if (*in == inBlank) {                               \
     47    if (*in == (inMode) inBlank) {                              \
    4848      *out = (MY_NAN);                                  \
    4949    } else {                                            \
  • branches/eam_branches/ohana.20160226/src/libfits/matrix/F_uncompress_M.c

    r38989 r39409  
    44# define VERBOSE_DUMP 0
    55
    6 int gfits_distribute_gzp2 (Matrix *matrix, char *raw, int Nraw, int raw_bitpix, int *otile, int oblank, int *ztile, int zblank, float zscale, float zzero);
    7 
    8 # define ESCAPE { \
    9   fprintf (stderr, "error in %s @ line %d\n", __func__, __LINE__); \
    10   if (ztile != NULL) free (ztile); \
    11   if (optname != NULL) { \
    12     for (j = 0; j < Noptions; j++) { \
    13       free (optname[j]); \
    14       free (optvalue[j]); \
    15     } \
    16     free (optname); \
    17     free (optvalue); \
    18   } \
    19   if (out != NULL) free (out); \
    20   if (otile != NULL) free (otile); \
    21   if (ntile != NULL) free (ntile); \
    22   return (FALSE); }
    23 
    24 # define MOD_KEYWORD(ZNAME,NAME,TYPE,IN,OUT) { \
     6int gfits_distribute_gzp2 (Matrix *matrix, char *raw, unsigned long int Nraw, int raw_bitpix, int *otile, int oblank, unsigned long int *ztile, int zblank, float zscale, float zzero);
     7
     8# define ESCAPE {                                                       \
     9    fprintf (stderr, "error in %s @ line %d\n", __func__, __LINE__);    \
     10    if (ztile != NULL) free (ztile);                                    \
     11    if (optname != NULL) {                                              \
     12      int opt;                                                          \
     13      for (opt = 0; opt < Noptions; opt++) {                            \
     14        free (optname[opt]);                                            \
     15        free (optvalue[opt]);                                           \
     16      }                                                                 \
     17      free (optname);                                                   \
     18      free (optvalue);                                                  \
     19    }                                                                   \
     20    if (out != NULL) free (out);                                        \
     21    if (otile != NULL) free (otile);                                    \
     22    if (ntile != NULL) free (ntile);                                    \
     23    return (FALSE); }
     24
     25# define MOD_KEYWORD(ZNAME,NAME,TYPE,IN,OUT) {     \
    2526    if (gfits_scan (header, ZNAME, TYPE, 1, IN)) { \
    26       gfits_modify (header, NAME, TYPE, 1, OUT); \
    27     } \
     27      gfits_modify (header, NAME, TYPE, 1, OUT);   \
     28    }                                              \
    2829    gfits_delete (header, ZNAME, 1); }
    2930
    30 # define MOD_KEYWORD_ALT(ZNAME,NAME,TYPE,IN,OUT) { \
     31# define MOD_KEYWORD_ALT(ZNAME,NAME,TYPE,IN,OUT) {     \
    3132    if (gfits_scan_alt (header, ZNAME, TYPE, 1, IN)) { \
    32       gfits_modify_alt (header, NAME, TYPE, 1, OUT); \
    33     } \
     33      gfits_modify_alt (header, NAME, TYPE, 1, OUT);   \
     34    }                                                  \
    3435    gfits_delete (header, ZNAME, 1); }
    3536
    36 # define MOD_KEYWORD_REQUIRED(ZNAME,NAME,TYPE,IN,OUT) { \
    37   if (!gfits_scan (header, ZNAME, TYPE, 1, IN)) ESCAPE; \
    38   gfits_delete (header, ZNAME, 1); \
    39   gfits_modify (header, NAME, TYPE, 1, OUT); }
     37# define MOD_KEYWORD_REQUIRED(ZNAME,NAME,TYPE,IN,OUT) {         \
     38    if (!gfits_scan (header, ZNAME, TYPE, 1, IN)) ESCAPE;       \
     39    gfits_delete (header, ZNAME, 1);                            \
     40    gfits_modify (header, NAME, TYPE, 1, OUT); }
    4041
    4142int gfits_uncompress_image (Header *header, Matrix *matrix, FTable *ftable) {
    4243
     44  int status, zimage;
    4345  off_t Nzdata, Nzrows, zcol;
    44   int i, j, status, zimage, Nout, max_tile_size;
     46  unsigned long int max_tile_size;
    4547  char cmptype[80];
    4648  char zaxis[10], naxis[10], key[10], word[81], exttype[81], checksum[81], datasum[81];
     
    4951  float zscale, zzero;
    5052
    51   int *ztile = NULL;
     53  unsigned long int *ztile = NULL;
    5254  int *otile = NULL;
    5355  int *ntile = NULL;
     
    7779  MOD_KEYWORD_REQUIRED ("ZNAXIS",  "NAXIS",  "%d", &header->Naxes,  header->Naxes);
    7880
    79   for (i = 0; i < header->Naxes; i++) {
    80     snprintf (zaxis, 10, "ZNAXIS%d", i + 1);
    81     snprintf (naxis, 10, "NAXIS%d", i + 1);
    82     MOD_KEYWORD_REQUIRED (zaxis,  naxis,  OFF_T_FMT,  &header->Naxis[i],  header->Naxis[i]);
     81  int axis;
     82  for (axis = 0; axis < header->Naxes; axis++) {
     83    snprintf (zaxis, 10, "ZNAXIS%d", axis + 1);
     84    snprintf (naxis, 10, "NAXIS%d", axis + 1);
     85    MOD_KEYWORD_REQUIRED (zaxis,  naxis,  OFF_T_FMT,  &header->Naxis[axis],  header->Naxis[axis]);
    8386  }   
    8487
     
    8689  // the actual tile size may be smaller at the edge of a dimension.  if the ZTILEn
    8790  // entries are not found, default to [Nx,1,1,...]
    88   ALLOCATE (ztile, int, header->Naxes);
    89   if (!gfits_scan (header, "ZTILE1", "%d", 1, &ztile[0])) {
     91  ALLOCATE (ztile, unsigned long int, header->Naxes);
     92  if (!gfits_scan (header, "ZTILE1", "%lu", 1, &ztile[0])) {
    9093    ztile[0] = header->Naxis[0];
    91     for (i = 1; i < header->Naxes; i++) {
    92       ztile[i] = 1;
     94    for (axis = 1; axis < header->Naxes; axis++) {
     95      ztile[axis] = 1;
    9396    }
    9497  } else {
    9598    gfits_delete (header, "ZTILE1", 1);
    96     for (i = 1; i < header->Naxes; i++) {
    97       snprintf (key, 10, "ZTILE%d", i + 1);
    98       if (!gfits_scan (header, key, "%d", 1, &ztile[i])) ESCAPE;
     99    for (axis = 1; axis < header->Naxes; axis++) {
     100      snprintf (key, 10, "ZTILE%d", axis + 1);
     101      if (!gfits_scan (header, key, "%lu", 1, &ztile[axis])) ESCAPE;
    99102      gfits_delete (header, key, 1);
    100103    }
     
    199202  // find the COMPRESSED_DATA column (format should be 1PB, 1PI, 1PJ)
    200203  // is it required that this be the only column?
    201   for (i = 1; TRUE; i++) {
    202     snprintf (key, 10, "TTYPE%d", i);
     204  int colnum;
     205  for (colnum = 1; TRUE; colnum++) {
     206    snprintf (key, 10, "TTYPE%d", colnum);
    203207    if (!gfits_scan (ftable->header, key, "%s", 1, word)) ESCAPE;
    204208    if (!strcmp (word, "COMPRESSED_DATA")) break;
    205209  }
    206   zcol = i;
     210  zcol = colnum;
    207211
    208212  if (!gfits_varlength_column_define (ftable, &zdef, zcol)) ESCAPE;
     
    220224  ALLOCATE (ntile, int, matrix->Naxes);
    221225  max_tile_size = 1;
    222   for (i = 0; i < matrix->Naxes; i++) {
    223     otile[i] = 0;
    224     ntile[i] = (matrix->Naxis[i] % ztile[i]) ? (matrix->Naxis[i] / ztile[i] + 1) : (matrix->Naxis[i] / ztile[i]);
    225     max_tile_size *= ztile[i];
    226 
    227     // ztile[i] is the default (or max) tile size in the i-th dimension
    228     // ntile[i] is the number of tiles in the i-th dimension
    229     // otile[i] is the current output tile counter in the i-th dimension
     226  for (axis = 0; axis < matrix->Naxes; axis++) {
     227    otile[axis] = 0;
     228    ntile[axis] = (matrix->Naxis[axis] % ztile[axis]) ? (matrix->Naxis[axis] / ztile[axis] + 1) : (matrix->Naxis[axis] / ztile[axis]);
     229    max_tile_size *= ztile[axis];
     230
     231    // ztile[axis] is the default (or max) tile size in the i-th dimension
     232    // ntile[axis] is the number of tiles in the i-th dimension
     233    // otile[axis] is the current output tile counter in the i-th dimension
    230234  }
    231235
     
    254258  // fprintf (stderr, "raw_pixsize: %d, cmp_pixsize: %d, tile_pixsize: %d, raw_bitpix: %d\n", raw_pixsize, cmp_pixsize, tile_pixsize, raw_bitpix);
    255259
    256   int Nout_alloc = raw_pixsize*max_tile_size;
     260  unsigned long int Nout_alloc = raw_pixsize*max_tile_size;
    257261  ALLOCATE (out, char, Nout_alloc);
    258262
     
    271275
    272276    // expected output size for this tile
    273     Nout = raw_pixsize*gfits_tile_size (matrix, otile, ztile);
     277    unsigned long Nout = raw_pixsize*gfits_tile_size (matrix, otile, ztile);
    274278
    275279    zdata = gfits_varlength_column_pointer (ftable, &zdef, row, &Nzdata);
     
    297301      for (k = 0; k < 64; k++) { fprintf (stderr, "%02hhx", zdata[k]); if (k % 4 == 3) fprintf (stderr, " "); }
    298302      fprintf (stderr, "\n");
    299       fprintf (stderr, "Nout  : %d -> ", Nout);
     303      fprintf (stderr, "Nout  : %lu -> ", Nout);
    300304    }
    301305   
     
    307311    if (VERBOSE_DUMP && (row == 0)) {
    308312      int k;
    309       fprintf (stderr, "%d\n", Nout);
     313      fprintf (stderr, "%lu\n", Nout);
    310314      fprintf (stderr, "unc swp: ");
    311315      for (k = 0; k < 64; k++) { fprintf (stderr, "%02hhx", out[k]); if (k % 4 == 3) fprintf (stderr, " "); }
     
    315319    if (!strcasecmp(cmptype, "GZIP_1")) {
    316320      // Nout is number of pixels
    317       if (!gfits_byteswap_zdata (out, Nout * raw_pixsize, raw_pixsize)) ESCAPE;
     321      if (!gfits_byteswap_zdata (out, (off_t) (Nout * raw_pixsize), raw_pixsize)) ESCAPE;
    318322    }
    319323   
     
    340344
    341345    // update the tile counters, carrying to the next dimension if needed
    342     for (j = 0; j < matrix->Naxes; j++) {
    343       otile[j] ++;
    344       if (otile[j] == ntile[j]) {
    345         otile[j] = 0;
     346    for (axis = 0; axis < matrix->Naxes; axis++) {
     347      otile[axis] ++;
     348      if (otile[axis] == ntile[axis]) {
     349        otile[axis] = 0;
    346350      } else {
    347351        break;
     
    352356  FREE (ztile);
    353357  if (optname != NULL) {
    354     for (j = 0; j < Noptions; j++) {
    355       FREE (optname[j]);
    356       FREE (optvalue[j]);
     358    int opt;
     359    for (opt = 0; opt < Noptions; opt++) {
     360      FREE (optname[opt]);
     361      FREE (optvalue[opt]);
    357362    }
    358363    FREE (optname);
     
    366371
    367372// bitpix is the input data size/type
    368 int gfits_distribute_data (Matrix *matrix, char *raw, int Nraw, int raw_bitpix, int *otile, int oblank, int *ztile, int zblank, float zscale, float zzero) {
    369 
    370   int i, j;
    371   int *counter = NULL;
    372   int *Ztile = NULL;
    373 
    374   ALLOCATE (counter, int, matrix->Naxes);
    375   ALLOCATE (Ztile, int, matrix->Naxes);
     373int gfits_distribute_data (Matrix *matrix, char *raw, unsigned long int Nraw, int raw_bitpix, int *otile, int oblank, unsigned long int *ztile, int zblank, float zscale, float zzero) {
     374
     375  int axis;
     376  unsigned int *counter = NULL;
     377  unsigned long int *Ztile = NULL;
     378
     379  ALLOCATE (counter, unsigned int, matrix->Naxes);
     380  ALLOCATE (Ztile, unsigned long int, matrix->Naxes);
    376381
    377382  // counter for current row in tile to copy
    378383  // true sizes of this tile (in pixels)
    379   for (i = 0; i < matrix->Naxes; i++) {
    380     counter[i] = 0;
    381     Ztile[i] = MIN ((matrix->Naxis[i] - otile[i]*ztile[i]), ztile[i]);
     384  for (axis = 0; axis < matrix->Naxes; axis++) {
     385    counter[axis] = 0;
     386    Ztile[axis] = MIN ((matrix->Naxis[axis] - otile[axis]*ztile[axis]), ztile[axis]);
    382387  }
    383388
    384389  // number of lines in the tile (in pixels)
    385   int Nline = 1;
    386   for (i = 1; i < matrix->Naxes; i++) {
    387     Nline *= Ztile[i];
     390  unsigned long int Nline = 1;
     391  for (axis = 1; axis < matrix->Naxes; axis++) {
     392    Nline *= Ztile[axis];
    388393  }
    389394
     
    394399  // start = otile[0]*ztile[0] + otile[1]*ztile[1]*Naxis[0] + otile[2]*ztile[2]*Naxis[0]*Naxis[1] + ...;
    395400  // start = otile[0]*ztile[0] + Naxis[0]*(otile[1]*ztile[1] + Naxis[1]*(otile[2]*ztile[2] + ...));
    396   int start = otile[matrix->Naxes-1]*ztile[matrix->Naxes-1];
    397   for (i = matrix->Naxes - 2; i >= 0; i--) {
    398     int coord = otile[i]*ztile[i];
    399     start = start*matrix->Naxis[i] + coord;
     401  unsigned long int start = otile[matrix->Naxes-1]*ztile[matrix->Naxes-1];
     402  for (axis = matrix->Naxes - 2; axis >= 0; axis--) {
     403    unsigned long int coord = otile[axis]*ztile[axis];
     404    start = start*matrix->Naxis[axis] + coord;
    400405  }
    401406 
    402407  // pixel offset in output array relative to tile start
    403   int offset = 0;
     408  unsigned long int offset = 0;
    404409
    405410  int directCopy = (zzero == 0.0) && (zscale == 1.0);
    406411
    407412# define SCALE_AND_DIST_INT_PRINT(TYPE, SIZE) {                         \
     413    unsigned long j;                                                    \
    408414    TYPE *TILEptr = (TYPE *) &matrix->buffer[SIZE*(offset + start)];    \
    409415    for (j = 0; j < Ztile[0]; j++, TILEptr++, RAWptr++) {               \
     
    418424  // this macro is used at the inner switch to run the actual loop
    419425# define SCALE_AND_DIST_INT(OTYPE, OSIZE) {                             \
     426    unsigned long j;                                                    \
    420427    OTYPE *TILEptr = (OTYPE *) &matrix->buffer[OSIZE*(offset + start)]; \
    421428    for (j = 0; j < Ztile[0]; j++, TILEptr++, RAWptr++) {               \
     
    432439  // this macro is used at the inner switch to run the actual loop
    433440# define SCALE_AND_DIST_FLOAT(OTYPE, OSIZE) {                           \
     441    unsigned long j;                                                    \
    434442    OTYPE *TILEptr = (OTYPE *) &matrix->buffer[OSIZE*(offset + start)]; \
    435443    for (j = 0; j < Ztile[0]; j++, TILEptr++, RAWptr++) {               \
     
    461469      case   8: SCALE_AND_DIST_INT   (char,   1); break; \
    462470      case  16: SCALE_AND_DIST_INT   (short,  2); break; \
    463       case  32: SCALE_AND_DIST_INT (int,    4); break; \
     471      case  32: SCALE_AND_DIST_INT   (int,    4); break; \
    464472      case -32: SCALE_AND_DIST_FLOAT (float,  4); break; \
    465473      case -64: SCALE_AND_DIST_FLOAT (double, 8); break; \
     
    468476
    469477  // loop over lines in the tile
     478  unsigned long int i;
    470479  for (i = 0; i < Nline; i++) {
    471480    switch (raw_bitpix) {
     
    479488
    480489    // update the counters, carrying to the next dimension if needed
    481     for (j = 1; j < matrix->Naxes; j++) {
    482       counter[j] ++;
    483       if (counter[j] == Ztile[j]) {
    484         counter[j] = 0;
     490    for (axis = 1; axis < matrix->Naxes; axis++) {
     491      counter[axis] ++;
     492      if (counter[axis] == Ztile[axis]) {
     493        counter[axis] = 0;
    485494      } else {
    486495        break;
    487496      }
    488497    }
    489     if (j == matrix->Naxes) assert (i == Nline - 1); // we should be done here...
     498    if (axis == matrix->Naxes) assert (i == Nline - 1); // we should be done here...
    490499
    491500    // Naxes = 3
     
    495504    // determine the offset of the next line relative to the start position
    496505    offset = counter[matrix->Naxes - 1];
    497     for (j = matrix->Naxes - 2; j >= 0; j--) {
    498       offset = offset*matrix->Naxis[j] + counter[j];
     506    for (axis = matrix->Naxes - 2; axis >= 0; axis--) {
     507      offset = offset*matrix->Naxis[axis] + counter[axis];
    499508    }     
    500509  }
     
    506515
    507516// bitpix is the input data size/type
    508 int gfits_distribute_gzp2 (Matrix *matrix, char *raw, int Nraw, int raw_bitpix, int *otile, int oblank, int *ztile, int zblank, float zscale, float zzero) {
    509 
    510   int i, j, k;
    511   int *counter = NULL;
    512   int *Ztile = NULL;
    513 
    514   ALLOCATE (counter, int, matrix->Naxes);
    515   ALLOCATE (Ztile, int, matrix->Naxes);
     517int gfits_distribute_gzp2 (Matrix *matrix, char *raw, unsigned long int Nraw, int raw_bitpix, int *otile, int oblank, unsigned long int *ztile, int zblank, float zscale, float zzero) {
     518  OHANA_UNUSED_PARAM(oblank);
     519  OHANA_UNUSED_PARAM(zblank);
     520  OHANA_UNUSED_PARAM(zzero);
     521  OHANA_UNUSED_PARAM(zscale);
     522
     523  int axis;
     524  unsigned int *counter = NULL;
     525  unsigned long int *Ztile = NULL;
     526
     527  ALLOCATE (counter, unsigned int, matrix->Naxes);
     528  ALLOCATE (Ztile, unsigned long int, matrix->Naxes);
    516529
    517530  // counter for current row in tile to copy
    518531  // true sizes of this tile (in pixels)
    519   for (i = 0; i < matrix->Naxes; i++) {
    520     counter[i] = 0;
    521     Ztile[i] = MIN ((matrix->Naxis[i] - otile[i]*ztile[i]), ztile[i]);
     532  for (axis = 0; axis < matrix->Naxes; axis++) {
     533    counter[axis] = 0;
     534    Ztile[axis] = MIN ((matrix->Naxis[axis] - otile[axis]*ztile[axis]), ztile[axis]);
    522535  }
    523536
    524537  // number of lines in the tile (in pixels)
    525   int Nline = 1;
    526   int Npix = matrix->Naxis[0];
    527   for (i = 1; i < matrix->Naxes; i++) {
    528     Nline *= Ztile[i];
    529     Npix  *= matrix->Naxis[i];
     538  unsigned long int Nline = 1;
     539  unsigned long int Npix = matrix->Naxis[0];
     540  for (axis = 1; axis < matrix->Naxes; axis++) {
     541    Nline *= Ztile[axis];
     542    Npix  *= matrix->Naxis[axis];
    530543  }
    531544
     
    536549  // start = otile[0]*ztile[0] + otile[1]*ztile[1]*Naxis[0] + otile[2]*ztile[2]*Naxis[0]*Naxis[1] + ...;
    537550  // start = otile[0]*ztile[0] + Naxis[0]*(otile[1]*ztile[1] + Naxis[1]*(otile[2]*ztile[2] + ...));
    538   int start = otile[matrix->Naxes-1]*ztile[matrix->Naxes-1];
    539   for (i = matrix->Naxes - 2; i >= 0; i--) {
    540     int coord = otile[i]*ztile[i];
    541     start = start*matrix->Naxis[i] + coord;
     551  unsigned long int start = otile[matrix->Naxes-1]*ztile[matrix->Naxes-1];
     552  for (axis = matrix->Naxes - 2; axis >= 0; axis--) {
     553    unsigned long int coord = otile[axis]*ztile[axis];
     554    start = start*matrix->Naxis[axis] + coord;
    542555  }
    543556 
     
    553566
    554567  // pixel offset in output array relative to tile start
    555   int offset = 0;
     568  unsigned long int offset = 0;
    556569
    557570  static int pass = 0;
     571  int k;
    558572  for (k = 0; k < size; k++) {
     573    unsigned long int i;
    559574    for (i = 0; i < Nline; i++) {
    560575# ifdef BYTE_SWAP     
     
    564579# endif
    565580      char *rawptr = &raw[i*Ztile[0] + k*Nraw];
     581      unsigned long j;
    566582      for (j = 0; j < Ztile[0]; j++, srcptr += size, rawptr ++) {               
    567583        if (FALSE && (i == 0) && (j < 4) && (pass == 0)) {
     
    574590
    575591      // update the counters, carrying to the next dimension if needed
    576       for (j = 1; j < matrix->Naxes; j++) {
    577         counter[j] ++;
    578         if (counter[j] == Ztile[j]) {
    579           counter[j] = 0;
     592      for (axis = 1; axis < matrix->Naxes; axis++) {
     593        counter[axis] ++;
     594        if (counter[axis] == Ztile[axis]) {
     595          counter[axis] = 0;
    580596        } else {
    581597          break;
    582598        }
    583599      }
    584       if (j == matrix->Naxes) assert (i == Nline - 1); // we should be done here...
     600      if (axis == matrix->Naxes) assert (i == Nline - 1); // we should be done here...
    585601
    586602      // Naxes = 3
     
    590606      // determine the offset of the next line relative to the start position
    591607      offset = counter[matrix->Naxes - 1];
    592       for (j = matrix->Naxes - 2; j >= 0; j--) {
    593         offset = offset*matrix->Naxis[j] + counter[j];
     608      for (axis = matrix->Naxes - 2; axis >= 0; axis--) {
     609        offset = offset*matrix->Naxis[axis] + counter[axis];
    594610      }     
    595611    }
  • branches/eam_branches/ohana.20160226/src/libfits/matrix/F_uncompress_data.c

    r38441 r39409  
    22# include <gfitsio.h>
    33# include <zlib.h>
    4 
    5 /* functions defined in ricecomp.c */
    6 int fits_rcomp(int a[], int nx, unsigned char *c, int clen, int nblock);
    7 int fits_rdecomp (unsigned char *c, int clen, unsigned int array[], int nx, int nblock);
    8 int fits_rdecomp_short (unsigned char *c, int clen, unsigned short array[], int nx, int nblock);
    9 int fits_rdecomp_byte (unsigned char *c, int clen, unsigned char array[], int nx, int nblock);
    10 
    11 /* functions defined in fits_hcompress.c */
    12 # define LONGLONG long long
    13 int fits_hcompress(int *a, int ny, int nx, int scale, char *output, long *nbytes, int *status);
    14 int fits_hcompress64(LONGLONG *a, int ny, int nx, int scale, char *output, long *nbytes, int *status);
    15 
    16 /* functions defined in fits_hdeccompress.c */
    17 int fits_hdecompress(unsigned char *input, int smooth, int *a, int *ny, int *nx, int *scale, int *status);
    18 int fits_hdecompress64(unsigned char *input, int smooth, LONGLONG *a, int *ny, int *nx, int *scale, int *status);
    19 
    20 /* functions defined in pliocomp.c */
    21 int pl_p2li (int *pxsrc, int xs, short *lldst, int npix);
    22 int pl_l2pi (short *ll_src, int xs, int *px_dst, int npix);
    23 
    24 /* functions defined in gzip.c */
    25 int gfits_gz_stripheader (unsigned char *data, int *ndata);
    26 int gfits_uncompress (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen);
     4# include <gfits_compress.h>
    275
    286# define ESCAPE(RET) { fprintf (stderr, "gzip error in %s @ %s:%d\n", __func__, __FILE__, __LINE__); return (RET); }
    297
    30 int gfits_uncompress_data (char *zdata, int Nzdata, char *cmptype, char **optname, char **optvalue, int Nopt, char *outdata, int *Nout, int Nout_alloc, int out_pixsize) {
     8int gfits_uncompress_data (char *zdata, unsigned long Nzdata, char *cmptype, char **optname, char **optvalue, int Nopt, char *outdata, unsigned long int *Nout, unsigned long int Nout_alloc, int out_pixsize) {
    319
    3210  int status;
     
    7856
    7957    int status = FALSE;
    80     int Npix = *Nout / out_pixsize;
    81     int k;
     58    unsigned long int Npix = *Nout / out_pixsize;
    8259
    8360    switch (out_pixsize) {
     
    8865      case 2:
    8966        if (0) {
    90           fprintf (stderr, "Nout: %d, Nrawpix: %d\n", Nzdata, Npix);
     67          unsigned long int k;
     68          fprintf (stderr, "Nout: %lu, Nrawpix: %lu\n", Nzdata, Npix);
    9169          fprintf (stderr, "cmp out: ");
    9270          for (k = 0; k < Nzdata; k++) { fprintf (stderr, "0x%02hhx ", zdata[k]); }
     
    11290 
    11391  if (!strcasecmp(cmptype, "PLIO_1")) {
     92    int Ntru = *Nout;
    11493    int Npix;
    115     Npix = pl_l2pi ((short *) zdata, 1, (int *) outdata, *Nout);
    116     if (Npix != *Nout) {
     94    Npix = pl_l2pi ((short *) zdata, 1, (int *) outdata, Ntru);
     95    if (Npix != Ntru) {
    11796      fprintf (stderr, "error in plio decompression\n");
    11897      return (FALSE);
     
    122101
    123102  if (!strcasecmp(cmptype, "HCOMPRESS_1")) {
     103    unsigned long int Ntru = *Nout;
    124104    int Nx, Ny, scale;
    125105    status = 0;
     
    132112    // fprintf (stderr, "decompression yields image %d x %d (scale: %d)\n", Nx, Ny, scale);
    133113   
    134     if (Nx * Ny != *Nout) {
     114    unsigned long Npix = Nx * Ny;
     115    if (Npix != Ntru) {
    135116      fprintf (stderr, "error in hdecompress: mismatched output size\n");
    136117      return (FALSE);
  • branches/eam_branches/ohana.20160226/src/libfits/table/F_compress_T.c

    r39358 r39409  
    2323# define ESCAPE { fprintf (stderr, "error in %s @ line %d\n", __func__, __LINE__); goto escape; }
    2424
    25 int gfits_collect_table_data (FTable *table, TableField *field, char *raw, int row_start, int Nrows);
    26 int gfits_collect_table_gzp2 (FTable *table, TableField *field, char *raw, int row_start, int Nrows);
     25int gfits_collect_table_data (FTable *table, TableField *field, char *raw, unsigned long int row_start, unsigned long int Nrows);
     26int gfits_collect_table_gzp2 (FTable *table, TableField *field, char *raw, unsigned long int row_start, unsigned long int Nrows);
    2727
    2828static float timeSum1 = 0.0;
     
    5151}
    5252
    53 int gfits_compress_table (FTable *srctable, FTable *tgttable, int ztilelen, char *zcmptype) {
    54 
    55   int i, j;
     53int gfits_compress_table (FTable *srctable, FTable *tgttable, unsigned long int ztilelen, char *zcmptype) {
    5654
    5755  char keyword[81];
     
    6967  gettimeofday (&startTimer, (void *) NULL);
    7068
    71   int Ntile, ztilelast;
     69  unsigned long int Ntile, ztilelast;
    7270  if (!ztilelen) ztilelen = srcheader->Naxis[1];
    7371
     
    104102
    105103  ALLOCATE_ZERO (fields, TableField, Nfields);
    106   for (i = 0; i < Nfields; i++) {
    107     snprintf (keyword, 80, "TTYPE%d", i+1);
    108     if (!gfits_scan (srcheader, keyword, "%s", 1, fields[i].ttype)) ESCAPE;
    109     if (!gfits_scan_alt (srcheader, keyword, "%C", 1, fields[i].ttype_cmt)) ESCAPE;
     104
     105  int field;
     106  for (field = 0; field < Nfields; field++) {
     107    snprintf (keyword, 80, "TTYPE%d", field+1);
     108    if (!gfits_scan (srcheader, keyword, "%s", 1, fields[field].ttype)) ESCAPE;
     109    if (!gfits_scan_alt (srcheader, keyword, "%C", 1, fields[field].ttype_cmt)) ESCAPE;
    110110
    111111    // TUNIT is not mandatory
    112     snprintf (keyword, 80, "TUNIT%d", i+1);
    113     if (!gfits_scan (srcheader, keyword, "%s", 1, fields[i].tunit)) {
    114       fields[i].tunit[0] = 0;
     112    snprintf (keyword, 80, "TUNIT%d", field+1);
     113    if (!gfits_scan (srcheader, keyword, "%s", 1, fields[field].tunit)) {
     114      fields[field].tunit[0] = 0;
    115115    } else {
    116       if (!gfits_scan_alt (srcheader, keyword, "%C", 1, fields[i].tunit_cmt)) ESCAPE;
     116      if (!gfits_scan_alt (srcheader, keyword, "%C", 1, fields[field].tunit_cmt)) ESCAPE;
    117117    }
    118118   
    119     snprintf (keyword, 80, "TFORM%d", i+1);
    120     if (!gfits_scan (srcheader, keyword, "%s", 1, fields[i].tformat)) ESCAPE;
    121     if (!gfits_scan_alt (srcheader, keyword, "%C", 1, fields[i].tformat_cmt)) ESCAPE;
     119    snprintf (keyword, 80, "TFORM%d", field+1);
     120    if (!gfits_scan (srcheader, keyword, "%s", 1, fields[field].tformat)) ESCAPE;
     121    if (!gfits_scan_alt (srcheader, keyword, "%C", 1, fields[field].tformat_cmt)) ESCAPE;
    122122
    123123    // for now we set all fields to the requested type.  since I do not yet know the column data types I cannot yet assign automatic cmptypes
    124     strcpy (fields[i].zctype, zcmptype);
     124    strcpy (fields[field].zctype, zcmptype);
    125125
    126126    // by using "P" format, we are limited to 32bit pointers (2GB heap)
    127     if (!gfits_define_bintable_column (tgtheader, "1QB(0)", fields[i].ttype, fields[i].ttype_cmt, fields[i].tunit, 1.0, 0.0)) ESCAPE;
     127    if (!gfits_define_bintable_column (tgtheader, "1QB(0)", fields[field].ttype, fields[field].ttype_cmt, fields[field].tunit, 1.0, 0.0)) ESCAPE;
    128128  }   
    129129
     
    137137  char *tmpbuffer = NULL;
    138138  ALLOCATE_ZERO (tmpbuffer, char, 16*Ntile); // need space for Ntile entries, each of width 16 bytes (2 long)
    139   for (i = 0; i < Nfields; i++) {
    140     if (!gfits_set_bintable_column (tgtheader, tgttable, fields[i].ttype, tmpbuffer, Ntile)) ESCAPE;
     139  for (field = 0; field < Nfields; field++) {
     140    if (!gfits_set_bintable_column (tgtheader, tgttable, fields[field].ttype, tmpbuffer, Ntile)) ESCAPE;
    141141  }
    142142  free (tmpbuffer);
     
    146146
    147147  // define compression-specific keywords, update header as needed.
    148   if (!gfits_modify (tgtheader, "ZTILELEN", "%d", 1, ztilelen)) ESCAPE;
     148  if (!gfits_modify (tgtheader, "ZTILELEN", "%lud", 1, ztilelen)) ESCAPE;
    149149
    150150  if (!gfits_modify (tgtheader, "ZNAXIS1", OFF_T_FMT, 1, srcheader->Naxis[0])) ESCAPE;
     
    163163  int offset = 0; // bytes from first column of first field to the current field (accumulate to set)
    164164
    165   for (i = 0; i < Nfields; i++) {
    166     snprintf (keyword, 81, "ZFORM%d", i+1);
    167     if (!gfits_modify (tgtheader, keyword, "%s", 1, fields[i].tformat)) ESCAPE;
    168     if (!gfits_varlength_column_define (tgttable, &fields[i].zdef, i+1)) ESCAPE;
    169     if (!gfits_bintable_format (fields[i].tformat, fields[i].datatype, &fields[i].Nvalues, &fields[i].pixsize)) ESCAPE; //
    170     fields[i].rowsize = fields[i].Nvalues*fields[i].pixsize;
    171     max_width = MAX(max_width, fields[i].rowsize);
    172 
    173     if (!strcasecmp (fields[i].zctype, "AUTO")) {
    174       if (!strcmp (fields[i].datatype, "short") ||
    175           !strcmp (fields[i].datatype, "float") ||
    176           !strcmp (fields[i].datatype, "double")||
    177           !strcmp (fields[i].datatype, "int64_t")) {
    178         strcpy (fields[i].zctype, "GZIP_2");
     165  for (field = 0; field < Nfields; field++) {
     166    snprintf (keyword, 81, "ZFORM%d", field+1);
     167    if (!gfits_modify (tgtheader, keyword, "%s", 1, fields[field].tformat)) ESCAPE;
     168    if (!gfits_varlength_column_define (tgttable, &fields[field].zdef, field+1)) ESCAPE;
     169    if (!gfits_bintable_format (fields[field].tformat, fields[field].datatype, &fields[field].Nvalues, &fields[field].pixsize)) ESCAPE; //
     170    fields[field].rowsize = fields[field].Nvalues*fields[field].pixsize;
     171    max_width = MAX(max_width, fields[field].rowsize);
     172
     173    if (!strcasecmp (fields[field].zctype, "AUTO")) {
     174      if (!strcmp (fields[field].datatype, "short") ||
     175          !strcmp (fields[field].datatype, "float") ||
     176          !strcmp (fields[field].datatype, "double")||
     177          !strcmp (fields[field].datatype, "int64_t")) {
     178        strcpy (fields[field].zctype, "GZIP_2");
    179179        goto got_cmptype;
    180180      }
    181       if (!strcmp (fields[i].datatype, "int")) {
    182         strcpy (fields[i].zctype, "RICE_1");
     181      if (!strcmp (fields[field].datatype, "int")) {
     182        strcpy (fields[field].zctype, "RICE_1");
    183183        goto got_cmptype;
    184184      }
    185       if (!strcmp (fields[i].datatype, "byte") ||
    186           !strcmp (fields[i].datatype, "char")) {
    187         strcpy (fields[i].zctype, "GZIP_1");
     185      if (!strcmp (fields[field].datatype, "byte") ||
     186          !strcmp (fields[field].datatype, "char")) {
     187        strcpy (fields[field].zctype, "GZIP_1");
    188188        goto got_cmptype;
    189189      }
     
    193193
    194194    // OVERRIDE: RICE can only be used on integer fields
    195     if (!strcasecmp (fields[i].zctype, "RICE_1") || !strcasecmp (fields[i].zctype, "RICE_ONE")) {
    196       if (!strcmp (fields[i].datatype, "float") || !strcmp (fields[i].datatype, "double") || !strcmp (fields[i].datatype, "int64_t")) {
    197         strcpy (fields[i].zctype, "GZIP_2");
     195    if (!strcasecmp (fields[field].zctype, "RICE_1") || !strcasecmp (fields[field].zctype, "RICE_ONE")) {
     196      if (!strcmp (fields[field].datatype, "float") || !strcmp (fields[field].datatype, "double") || !strcmp (fields[field].datatype, "int64_t")) {
     197        strcpy (fields[field].zctype, "GZIP_2");
    198198      }
    199199    }
    200200
    201201    // OVERRIDE: GZIP_2 invalid for B (use GZIP_1)
    202     if (!strcasecmp (fields[i].zctype, "GZIP_2") && !strcmp (fields[i].datatype, "byte")) {
    203       strcpy (fields[i].zctype, "GZIP_1");
     202    if (!strcasecmp (fields[field].zctype, "GZIP_2") && !strcmp (fields[field].datatype, "byte")) {
     203      strcpy (fields[field].zctype, "GZIP_1");
    204204    }
    205205
    206206    // compression type per column (XXX for now we are just using zcmptype, as set above)
    207     snprintf (keyword, 81, "ZCTYP%d", i+1);
    208     if (!gfits_modify (tgtheader, keyword, "%s", 1, fields[i].zctype)) ESCAPE;
    209 
    210     fields[i].offset = offset;
    211     offset += fields[i].rowsize;
     207    snprintf (keyword, 81, "ZCTYP%d", field+1);
     208    if (!gfits_modify (tgtheader, keyword, "%s", 1, fields[field].zctype)) ESCAPE;
     209
     210    fields[field].offset = offset;
     211    offset += fields[field].rowsize;
    212212  }
    213213
    214214  // allocate the intermediate storage buffers
    215   int Nzdata_alloc = 2*max_width*ztilelen + 100;
     215  unsigned long int Nzdata_alloc = 2*max_width*ztilelen + 100;
    216216  ALLOCATE (raw,   char, max_width*ztilelen);
    217217  ALLOCATE (zdata, char, Nzdata_alloc);
     
    229229  // compress the data : copy into a tile, compress the tile, then add to the output table
    230230  // each tile -> 1 row of the output table
    231   for (i = 0; i < Ntile; i++) {
    232 
    233     for (j = 0; j < Nfields; j++) {
    234 
    235       gettimeofday (&startTimer, (void *) NULL);
    236 
    237       int Nrows = (i == Ntile - 1) ? ztilelast : ztilelen;
    238       int row_start = i*ztilelen;
     231  unsigned long int tile;
     232  for (tile = 0; tile < Ntile; tile++) {
     233
     234    for (field = 0; field < Nfields; field++) {
     235
     236      gettimeofday (&startTimer, (void *) NULL);
     237
     238      unsigned long int Nrows = (tile == Ntile - 1) ? ztilelast : ztilelen;
     239      unsigned long int row_start = tile*ztilelen;
    239240      // ^- first row for this tile & field
    240241      // NOTE: assumes each tile has the same length, ex the last (true for now)
    241242
    242243      // copy the raw pixels from their native matrix locations to the temporary output buffer
    243       if (!strcasecmp(fields[j].zctype, "GZIP_2") || !strcasecmp(fields[j].zctype, "NONE_2")) {
    244         if (!gfits_collect_table_gzp2 (srctable, &fields[j], raw, row_start, Nrows)) ESCAPE;
     244      if (!strcasecmp(fields[field].zctype, "GZIP_2") || !strcasecmp(fields[field].zctype, "NONE_2")) {
     245        if (!gfits_collect_table_gzp2 (srctable, &fields[field], raw, row_start, Nrows)) ESCAPE;
    245246      } else {
    246         if (!gfits_collect_table_data (srctable, &fields[j], raw, row_start, Nrows)) ESCAPE;
     247        if (!gfits_collect_table_data (srctable, &fields[field], raw, row_start, Nrows)) ESCAPE;
    247248      }
    248249     
     
    256257 
    257258      if (VERBOSE_DUMP) {
    258         int k;
     259        unsigned long int k;
    259260        fprintf (stderr, "c1: ");
    260         for (k = 0; k < Nrows*fields[j].Nvalues*fields[j].pixsize; k++) {
     261        for (k = 0; k < Nrows*fields[field].Nvalues*fields[field].pixsize; k++) {
    261262          fprintf (stderr, "%02hhx", raw[k]);
    262263          if (k % 2) fprintf (stderr, " ");
     
    269270      // optname, optvalue = NULL, Noptions = 0
    270271     
    271       int Nraw = Nrows*fields[j].Nvalues; // number of pixels
    272       if (!strcasecmp(fields[j].zctype, "GZIP_1")) {
    273         if (!gfits_byteswap_zdata (raw, Nraw * fields[j].pixsize, fields[j].pixsize)) ESCAPE;
     272      unsigned long int Nraw = Nrows*fields[field].Nvalues; // number of pixels
     273      if (!strcasecmp(fields[field].zctype, "GZIP_1")) {
     274        if (!gfits_byteswap_zdata (raw, Nraw * fields[field].pixsize, fields[field].pixsize)) ESCAPE;
    274275      }
    275276
     
    281282 
    282283      if (VERBOSE_DUMP) {
    283         int k;
     284        unsigned long int k;
    284285        fprintf (stderr, "c2: ");
    285         for (k = 0; k < Nrows*fields[j].Nvalues*fields[j].pixsize; k++) {
     286        for (k = 0; k < Nrows*fields[field].Nvalues*fields[field].pixsize; k++) {
    286287          fprintf (stderr, "%02hhx", raw[k]);
    287288          if (k % 2) fprintf (stderr, " ");
     
    291292      }
    292293
    293       int Nzdata = Nzdata_alloc; // available space, replaced with actual output size on compression
    294       if (!gfits_compress_data (zdata, &Nzdata, fields[j].zctype, NULL, NULL, 0, raw, Nraw, fields[j].pixsize, 0, 0)) ESCAPE;
     294      unsigned long int Nzdata = Nzdata_alloc; // available space, replaced with actual output size on compression
     295      if (!gfits_compress_data (zdata, &Nzdata, fields[field].zctype, NULL, NULL, 0, raw, Nraw, fields[field].pixsize, 0, 0)) ESCAPE;
    295296     
    296297      // XXX TIMER 2c
     
    301302 
    302303      if (VERBOSE_DUMP) {
    303         int k;
     304        unsigned long int k;
    304305        fprintf (stderr, "c3: ");
    305306        for (k = 0; k < Nzdata; k++) {
     
    311312      }
    312313
    313       if (strcasecmp(fields[j].zctype, "NONE_2") && // NONE and NONE_1 not swapped?
    314           strcasecmp(fields[j].zctype, "GZIP_1") &&
    315           strcasecmp(fields[j].zctype, "GZIP_2") &&
    316           strcasecmp(fields[j].zctype, "RICE_1") &&
    317           strcasecmp(fields[j].zctype, "RICE_ONE")) {
    318         if (!gfits_byteswap_zdata (zdata, Nzdata, fields[j].pixsize)) ESCAPE;
     314      if (strcasecmp(fields[field].zctype, "NONE_2") && // NONE and NONE_1 not swapped?
     315          strcasecmp(fields[field].zctype, "GZIP_1") &&
     316          strcasecmp(fields[field].zctype, "GZIP_2") &&
     317          strcasecmp(fields[field].zctype, "RICE_1") &&
     318          strcasecmp(fields[field].zctype, "RICE_ONE")) {
     319        if (!gfits_byteswap_zdata (zdata, Nzdata, fields[field].pixsize)) ESCAPE;
    319320      }
    320321
     
    326327 
    327328      if (VERBOSE_DUMP) {
    328         int k;
     329        unsigned long int k;
    329330        fprintf (stderr, "c4: ");
    330331        for (k = 0; k < Nzdata; k++) {
     
    336337      }
    337338
    338       if (!gfits_varlength_column_add_data (tgttable, zdata, Nzdata, i, &fields[j].zdef)) ESCAPE;
     339      if (!gfits_varlength_column_add_data (tgttable, zdata, Nzdata, field, &fields[field].zdef)) ESCAPE;
    339340      // XXX TIMER 2e
    340341      gettimeofday (&stopTimer, (void *) NULL);
     
    347348  if (OHANA_MEMCHECK) ohana_memcheck (TRUE);
    348349
    349   for (i = 0; i < Nfields; i++) {
    350     if (!gfits_varlength_column_finish (tgttable, &fields[i].zdef)) ESCAPE;
     350  for (field = 0; field < Nfields; field++) {
     351    if (!gfits_varlength_column_finish (tgttable, &fields[field].zdef)) ESCAPE;
    351352  }
    352353
     
    375376// raw_pixsize is the bytes / pixel for the input matrix
    376377// place the raw image bytes for the current tile into the tile buffer
    377 int gfits_collect_table_data (FTable *table, TableField *field, char *raw, int row_start, int Nrows) {
    378 
    379   off_t i;
     378int gfits_collect_table_data (FTable *table, TableField *field, char *raw, unsigned long int row_start, unsigned long int Nrows) {
     379
     380  unsigned long int i;
    380381
    381382  // we are copying NN rows into the column which starts at XX and has MM bytes per row
     
    399400}
    400401
    401 int gfits_collect_table_data_alt (FTable *table, TableField *field, char *raw, int row_start, int Nrows) {
    402 
    403   off_t i;
     402int gfits_collect_table_data_alt (FTable *table, TableField *field, char *raw, unsigned long int row_start, unsigned long int Nrows) {
     403
     404  unsigned long int i;
    404405
    405406  // we are copying NN rows of the column which starts at XX and has MM bytes per row
     
    420421}
    421422
    422 int gfits_collect_table_gzp2 (FTable *table, TableField *field, char *raw, int row_start, int Nrows) {
    423 
    424   off_t i, j, k;
     423int gfits_collect_table_gzp2 (FTable *table, TableField *field, char *raw, unsigned long int row_start, unsigned long int Nrows) {
     424
     425  off_t j, k;
    425426
    426427  // we are copying NN rows into the column which starts at XX and has MM bytes per row
     
    439440    char *tblptr_start = &table->buffer[Nx*row_start + offset + k];
    440441# endif
     442    unsigned long int i;
    441443    for (i = 0; i < Nrows; i++, tblptr_start += Nx) {
    442444      char *tblptr = tblptr_start;
     
    449451}
    450452
    451 int gfits_collect_table_gzp2_alt (FTable *table, TableField *field, char *raw, int row_start, int Nrows) {
    452 
    453   off_t i, j, k;
     453int gfits_collect_table_gzp2_alt (FTable *table, TableField *field, char *raw, unsigned long int row_start, unsigned long int Nrows) {
     454
     455  off_t j, k;
    454456
    455457  // we are copying NN rows into the column which starts at XX and has MM bytes per row
     
    458460
    459461  for (k = 0; k < field->pixsize; k++) {
     462    unsigned long int i;
    460463    for (i = 0; i < Nrows; i++) {
    461       int row = row_start + i;
     464      unsigned long int row = row_start + i;
    462465      char *rawptr = &raw[i*field->Nvalues + k*Nrows*field->Nvalues];
    463466# ifdef BYTE_SWAP     
     
    468471      for (j = 0; j < field->Nvalues; j++, tblptr += field->pixsize, rawptr++) {
    469472        *rawptr = *tblptr;
    470         myAssert (rawptr - raw < Nrows*field->Nvalues*field->pixsize, "oops");
     473        myAssert (rawptr >= raw, "oops");
     474        myAssert ((unsigned long int)(rawptr - raw) < Nrows*field->Nvalues*field->pixsize, "oops");
    471475        myAssert (tblptr - table->buffer < table->header->Naxis[0]*table->header->Naxis[1], "oops");
    472476      }
  • branches/eam_branches/ohana.20160226/src/libfits/table/F_uncompress_T.c

    r39358 r39409  
    2222  }
    2323  fprintf (stderr, "\n");
     24# else
     25  OHANA_UNUSED_PARAM(table);
     26  OHANA_UNUSED_PARAM(message);
    2427# endif
    2528  return TRUE;
     
    4447  }
    4548  fprintf (stderr, "\n");
     49# else
     50  OHANA_UNUSED_PARAM(table);
     51  OHANA_UNUSED_PARAM(message);
    4652# endif
    4753  return TRUE;
     
    266272      gettimeofday (&startTimer, (void *) NULL);
    267273 
    268       int Nrows = (row == Ntile - 1) ? ztilelast : ztilelen;
    269       int Nraw = Nrows*fields[i].Nvalues*fields[i].pixsize; // expected number of bytes
     274      unsigned long int Nrows = (row == Ntile - 1) ? ztilelast : ztilelen;
     275      unsigned long int Nraw = Nrows*fields[i].Nvalues*fields[i].pixsize; // expected number of bytes
    270276      if (!gfits_uncompress_data (zdata, Nzdata, fields[i].zctype, NULL, NULL, 0, raw, &Nraw, Nraw_alloc, fields[i].pixsize)) ESCAPE;
    271277
    272278      if (VERBOSE_DUMP) {
    273         int k;
     279        unsigned long int k;
    274280        fprintf (stderr, "u2: ");
    275281        for (k = 0; k < Nraw*fields[i].pixsize; k++) {
     
    299305 
    300306      if (VERBOSE_DUMP) {
    301         int k;
     307        unsigned long int k;
    302308        fprintf (stderr, "u1: ");
    303309        for (k = 0; k < Nraw*fields[i].pixsize; k++) {
  • branches/eam_branches/ohana.20160226/src/libfits/table/F_write_T.c

    r38553 r39409  
    2727    myAssert (myBlock->startblock == OHANA_MEMMAGIC, "bad memory");
    2828    myAssert (myBlock->endblock == OHANA_MEMMAGIC, "bad memory");
    29     myAssert (myBlock->size >= table[0].datasize, "overflow");
     29    myAssert (myBlock->size >= (size_t) table[0].datasize, "overflow");
    3030  }
    3131# endif
  • branches/eam_branches/ohana.20160226/src/libfits/table/F_write_TH.c

    r38553 r39409  
    2727    myAssert (myBlock->startblock == OHANA_MEMMAGIC, "bad memory");
    2828    myAssert (myBlock->endblock == OHANA_MEMMAGIC, "bad memory");
    29     myAssert (myBlock->size >= header[0].datasize, "overflow");
     29    myAssert (myBlock->size >= (size_t) header[0].datasize, "overflow");
    3030  }
    3131# endif
  • branches/eam_branches/ohana.20160226/src/libohana/include/ohana.h

    r39407 r39409  
    400400int     write_fmt              PROTO((int fd, char *format, ...)) OHANA_FORMAT(printf, 2, 3);
    401401
    402 char   **isolate_elements      PROTO((int argc, char **argv, int *nstack));
     402char   **isolate_elements      PROTO((unsigned int argc, char **argv, unsigned int *nstack));
    403403
    404404// functions used to manage "last error message"
  • branches/eam_branches/ohana.20160226/src/libohana/src/Fread.c

    r29537 r39409  
    4444
    4545static int ByteSwap (char *ptr, off_t size, off_t nitems, char *type) {
     46  OHANA_UNUSED_PARAM(size);
    4647
    47 # ifdef BYTE_SWAP
     48# ifndef BYTE_SWAP
     49  OHANA_UNUSED_PARAM(ptr);
     50  OHANA_UNUSED_PARAM(nitems);
     51  OHANA_UNUSED_PARAM(type);
     52  return (TRUE);
     53
     54# else
    4855
    4956  off_t i;
     
    108115  return (FALSE);
    109116
    110 # else
    111 
    112   return (TRUE);
    113 
    114117# endif
    115118
  • branches/eam_branches/ohana.20160226/src/libohana/src/config.c

    r39393 r39409  
    4343  uid_t uid;
    4444  gid_t gid;
    45   int i, N, NDEF, status;
     45  int unsigned i, N, NDEF, status;
    4646 
    4747  /* first look for -C CONFIG variable */
  • branches/eam_branches/ohana.20160226/src/libohana/src/gaussj.c

    r39369 r39409  
    2020// numerical precision, I am raising an error if |growth| > 1e8
    2121int dgaussjordan_pivot (double **A, double **B, int N, int M, double MIN_PIVOT) {
     22  OHANA_UNUSED_PARAM(MIN_PIVOT);
    2223
    2324  int *colIndex;
  • branches/eam_branches/ohana.20160226/src/libohana/src/isolate_elements.c

    r31635 r39409  
    1 // # include "opihi.h"
    2 //
    3 #include "ohana.h"
     1# include "ohana.h"
    42
    53/* local private functions */
    6 char **InsertValue (char **myOutput, int *Nout, int *Nchar, int *NCHAR, char c);
    7 char **EndOfString (char **myOutput, int *Nout, int *Nchar, int *NOUT, int *NCHAR);
     4char **InsertValue (char **myOutput, unsigned int *Nout, unsigned int *Nchar, unsigned int *NCHAR, char c);
     5char **EndOfString (char **myOutput, unsigned int *Nout, unsigned int *Nchar, unsigned int *NOUT, unsigned int *NCHAR);
    86int IsAnOp (char *c);
    97int IsTwoOp (char *c);
    108
    11 char **isolate_elements (int Nin, char **in, int *nout) {
     9char **isolate_elements (unsigned int Nin, char **in, unsigned int *nout) {
    1210 
    1311  /* local private static variables */
    14   int NCHAR, Nchar, Nout, NOUT;
     12  unsigned int NCHAR, Nchar, Nout, NOUT;
    1513  char **myOutput;
    1614
    17   int i, j, minus, negate, plus, posate, OpStat, SciNotation;
     15  unsigned int i, j, minus, negate, plus, posate, OpStat, SciNotation;
    1816
    1917  NOUT = Nin;
     
    142140}
    143141
    144 char **InsertValue (char **myOutput, int *Nout, int *Nchar, int *NCHAR, char c) {
     142char **InsertValue (char **myOutput, unsigned int *Nout, unsigned int *Nchar, unsigned int *NCHAR, char c) {
    145143  myOutput[*Nout][*Nchar] = c;
    146144  (*Nchar) ++;
     
    153151}
    154152
    155 char **EndOfString (char **myOutput, int *Nout, int *Nchar, int *NOUT, int *NCHAR) {
     153char **EndOfString (char **myOutput, unsigned int *Nout, unsigned int *Nchar, unsigned int *NOUT, unsigned int *NCHAR) {
    156154  if ((*Nchar) > 0) {
    157155    myOutput[*Nout][*Nchar] = 0;
  • branches/eam_branches/ohana.20160226/src/libohana/src/ohana_allocate.c

    r39407 r39409  
    1717# define TRUE 1
    1818# define MAX(X,Y) ((X) > (Y) ? (X) : (Y))
     19
     20// a no-op to mark unused parameters in a function
     21# define OHANA_UNUSED_PARAM(x)(void)(x)
    1922
    2023static OhanaMemblock *lastBlock = NULL;
  • branches/eam_branches/ohana.20160226/src/relastro/src/UpdateObjects.c

    r39390 r39409  
    257257    }
    258258
     259    // if we have fitted (and accepted) a parallax model, get the best pm fit and chisq
     260    // given the set of points (mask is respected)
    259261    if (average[0].flags & ID_OBJ_USE_PAR) {
    260       // get the best pm fit and chisq given the set of points (mask is respected)
    261262      if (!FitPM_Basic (&fitPM, fitStats->fitdataPM, fitStats->points, fitStats->Npoints)) {
    262263        average[0].flags |= ID_OBJ_BAD_PM;
Note: See TracChangeset for help on using the changeset viewer.