Index: /branches/eam_branches/ohana.20150429/src/libfits/Makefile
===================================================================
--- /branches/eam_branches/ohana.20150429/src/libfits/Makefile	(revision 38355)
+++ /branches/eam_branches/ohana.20150429/src/libfits/Makefile	(revision 38356)
@@ -26,5 +26,5 @@
 TEST_LDFLAGS  = $(BASE_LDFLAGS) -lFITS -lohana -ltap_ohana
 
-TESTPROG = imagecomp tablecomp zlib
+TESTPROG = imagecomp tablecomp zlib ricetest
 $(TESTPROG) : % : $(TESTBIN)/%
 test: $(TESTPROG)
Index: /branches/eam_branches/ohana.20150429/src/libfits/include/gfitsio.h
===================================================================
--- /branches/eam_branches/ohana.20150429/src/libfits/include/gfitsio.h	(revision 38355)
+++ /branches/eam_branches/ohana.20150429/src/libfits/include/gfitsio.h	(revision 38356)
@@ -212,4 +212,5 @@
 int     gfits_uncompressed_data_bitpix  PROTO((char *cmptype, int out_bitpix, char **optname, char **optvalue, int Noptions));
 int     gfits_vartable_heap_pixsize     PROTO((char format));
+int     gfits_cmptype_valid             PROTO((char *cmptype));
 
 int     gfits_varlength_column_add_data PROTO((FTable *table, char *data, off_t Ndata, int row, VarLengthColumn *column));
Index: /branches/eam_branches/ohana.20150429/src/libfits/matrix/F_compress_M.c
===================================================================
--- /branches/eam_branches/ohana.20150429/src/libfits/matrix/F_compress_M.c	(revision 38355)
+++ /branches/eam_branches/ohana.20150429/src/libfits/matrix/F_compress_M.c	(revision 38356)
@@ -2,4 +2,5 @@
 # include <gfitsio.h>
 # include <zlib.h>
+# define VERBOSE_DUMP 0
 
 // the user needs to specify the various compression options:
@@ -33,4 +34,6 @@
 
   Header *theader = ftable->header;
+
+  if (!gfits_cmptype_valid(zcmptype)) ESCAPE;
 
   // determine the number of tiles (from ztile[] and image size)
@@ -147,7 +150,4 @@
   int max_tile_size = gfits_imtile_maxsize (matrix, ztile);
 
-  // size of a pixel in the image tile -- this is probably not needed
-  int tile_pixsize = abs(header[0].bitpix) / 8;
-
   // size of a pixel in the raw pixel buffer (before compression)
   int raw_pixsize = gfits_uncompressed_data_pixsize (zcmptype, header[0].bitpix, NULL, NULL, 0);
@@ -155,6 +155,7 @@
   int cmp_pixsize = gfits_compressed_data_pixsize (zcmptype, header[0].bitpix, NULL, NULL, 0);
 
-  fprintf (stderr, "raw_pixsize: %d, cmp_pixsize: %d, tile_pixsize: %d, raw_bitpix: %d\n", 
-	   raw_pixsize, cmp_pixsize, tile_pixsize, raw_bitpix);
+  // size of a pixel in the image tile -- this is probably not needed
+  // int tile_pixsize = abs(header[0].bitpix) / 8;
+  // fprintf (stderr, "raw_pixsize: %d, cmp_pixsize: %d, tile_pixsize: %d, raw_bitpix: %d\n", raw_pixsize, cmp_pixsize, tile_pixsize, raw_bitpix);
 
   // allocate the buffer for compression work
@@ -177,5 +178,5 @@
     if (!gfits_collect_data (matrix, raw, Nraw, raw_bitpix, otile, oblank, ztile, zblank, zscale, zzero)) ESCAPE;
 
-    if (0 && (i == 0)) {
+    if (VERBOSE_DUMP && (i == 0)) {
       int k;
       fprintf (stderr, "cmp mat: "); 
@@ -189,18 +190,36 @@
     // gzip compresses bytes which are in BIG-ENDIAN order
     if (!strcasecmp(zcmptype, "GZIP_1")) {
-      if (!gfits_byteswap_zdata (raw, Nraw, raw_pixsize)) ESCAPE;
-    }
-    if (0 && (i == 0)) {
+      // Nraw is number of pixels
+      if (!gfits_byteswap_zdata (raw, Nraw * raw_pixsize, raw_pixsize)) ESCAPE;
+    }
+    int Nzdata = Nzdata_alloc; // available space, replaced with actual output size on compression
+
+    if (VERBOSE_DUMP && (i == 0)) {
       int k;
       fprintf (stderr, "cmp swp: "); 
       for (k = 0; k < 32; k++) { fprintf (stderr, "0x%02hhx ", raw[k]); } 
       fprintf (stderr, "\n");
+      fprintf (stderr, "Nzdata: %d -> ", Nzdata);
     }
 
     // optname, optvalue = NULL, Noptions = 0 : defaults for RICE_1, HCOMPRESS_1
 
-    int Nzdata = Nzdata_alloc; // available space, replaced with actual output size on compression
     if (!gfits_compress_data (zdata, &Nzdata, zcmptype, NULL, NULL, 0, raw, Nraw, raw_pixsize, ztile[1], ztile[0])) ESCAPE;
-    if (0 && (i == 0)) {
+    if (VERBOSE_DUMP && (i == 0)) {
+      int k;
+      fprintf (stderr, "%d\n", Nzdata);
+      fprintf (stderr, "cmp SWP: "); 
+      for (k = 0; k < 32; k++) { fprintf (stderr, "0x%02hhx ", zdata[k]); } 
+      fprintf (stderr, "\n");
+    }
+
+    // all other compression modes require swapping after compression
+    // (compresssion & decompression operate on native ENDIAN)
+    if (strcasecmp(zcmptype, "GZIP_1")) {
+      // Nzdata is number of bytes
+      if (!gfits_byteswap_zdata (zdata, Nzdata, cmp_pixsize)) ESCAPE;
+    }
+
+    if (VERBOSE_DUMP && (i == 0)) {
       int k;
       fprintf (stderr, "cmp dat: "); 
@@ -208,12 +227,5 @@
       fprintf (stderr, "\n");
     }
-
     if (!gfits_varlength_column_add_data (ftable, zdata, Nzdata, i, &zdef)) ESCAPE;
-
-    // all other compression modes require swapping after compression
-    // (compresssion & decompression operate on native ENDIAN)
-    if (strcasecmp(zcmptype, "GZIP_1")) {
-      if (!gfits_byteswap_zdata (zdata, Nzdata, cmp_pixsize)) ESCAPE;
-    }
 
     // update the otile[] counters, carrying to the next dimension if needed
@@ -222,5 +234,5 @@
 
   if (!gfits_varlength_column_finish (ftable, &zdef)) ESCAPE;
-  if (0) { 
+  if (VERBOSE_DUMP) { 
     int k;
     fprintf (stderr, "cmp tbl: "); 
Index: /branches/eam_branches/ohana.20150429/src/libfits/matrix/F_compress_data.c
===================================================================
--- /branches/eam_branches/ohana.20150429/src/libfits/matrix/F_compress_data.c	(revision 38355)
+++ /branches/eam_branches/ohana.20150429/src/libfits/matrix/F_compress_data.c	(revision 38356)
@@ -65,5 +65,5 @@
   }
 
-  if (!strcasecmp(cmptype, "RICE_1")) {
+  if (!strcasecmp(cmptype, "RICE_1") || !strcasecmp(cmptype, "RICE_ONE")) {
     int i, blocksize;
     // look for the BLOCKSIZE
@@ -83,4 +83,7 @@
     // fprintf (stderr, "%d comp bytes; %d uncomp 'pixels', totals: %d %d\n", Nzdata, Npix, Ninsum, Noutsum);
 
+    char buffer[1000];
+    int k;
+
     switch (rawpix_size) {
       case 4:
@@ -90,5 +93,16 @@
 
       case 2:
+	// Nout is the number of bytes in the compressed buffer
 	Nout = fits_rcomp_short ((short *) rawdata, Nrawpix, (unsigned char *) zdata, *Nzdata, blocksize);
+
+	if (0) {
+	  fprintf (stderr, "Nout: %d, Nrawpix: %d\n", Nout, Nrawpix);
+	  fprintf (stderr, "cmp inp: "); 
+	  for (k = 0; k < Nout; k++) { fprintf (stderr, "0x%02hhx ", zdata[k]); } 
+	  fprintf (stderr, "\n");
+	}
+
+	status = fits_rdecomp_short ((unsigned char *) zdata, Nout, (unsigned short *) buffer, Nrawpix, blocksize);
+	myAssert (!status, "failed to rdecomp");
 	break;
 
Index: /branches/eam_branches/ohana.20150429/src/libfits/matrix/F_compress_utils.c
===================================================================
--- /branches/eam_branches/ohana.20150429/src/libfits/matrix/F_compress_utils.c	(revision 38355)
+++ /branches/eam_branches/ohana.20150429/src/libfits/matrix/F_compress_utils.c	(revision 38356)
@@ -101,4 +101,5 @@
   int i;
 
+  // fprintf (stderr, "swapping %d bytes in pix of size %d bytes...\n", Nzdata, pixsize);
   switch (pixsize) {
     case 1:
@@ -106,5 +107,5 @@
 
     case 2:
-      for (i = 0; i < 2*Nzdata; i+=2) {
+      for (i = 0; i < Nzdata; i+=2) {
 	DOSWAP (zdata[i+0], zdata[i+1]);
       }
@@ -112,5 +113,5 @@
 
     case 4:
-      for (i = 0; i < 4*Nzdata; i+=4) {
+      for (i = 0; i < Nzdata; i+=4) {
 	DOSWAP (zdata[i+0], zdata[i+3]);
 	DOSWAP (zdata[i+1], zdata[i+2]);
@@ -119,5 +120,5 @@
 
     case 8:
-      for (i = 0; i < 8*Nzdata; i+=8) {
+      for (i = 0; i < Nzdata; i+=8) {
 	DOSWAP (zdata[i+0], zdata[i+7]);
 	DOSWAP (zdata[i+1], zdata[i+6]);
@@ -168,4 +169,16 @@
 
     return (FALSE);
+}
+
+int gfits_cmptype_valid (char *cmptype) {
+
+  if (!strcasecmp(cmptype, "NONE")) return TRUE;
+  if (!strcasecmp(cmptype, "GZIP_1")) return TRUE;
+  if (!strcasecmp(cmptype, "GZIP_2")) return TRUE;
+  if (!strcasecmp(cmptype, "PLIO_1")) return TRUE;
+  if (!strcasecmp(cmptype, "RICE_1")) return TRUE;
+  if (!strcasecmp(cmptype, "RICE_ONE")) return TRUE;
+  if (!strcasecmp(cmptype, "HCOMPRESS_1")) return TRUE;
+  return FALSE;
 }
 
Index: /branches/eam_branches/ohana.20150429/src/libfits/matrix/F_uncompress_M.c
===================================================================
--- /branches/eam_branches/ohana.20150429/src/libfits/matrix/F_uncompress_M.c	(revision 38355)
+++ /branches/eam_branches/ohana.20150429/src/libfits/matrix/F_uncompress_M.c	(revision 38356)
@@ -2,4 +2,5 @@
 # include <gfitsio.h>
 # include <zlib.h>
+# define VERBOSE_DUMP 0
 
 # define ESCAPE { \
@@ -242,7 +243,4 @@
   // zdata_pixsize = gfits_vartable_heap_pixsize (zdef.format); XXX
 
-  // size of a pixel in the final image (not needed)
-  // idata_pixsize = abs(header[0].bitpix) / 8;
-
   // size of a pixel in the output from the decompression routine
   int cmp_pixsize = gfits_compressed_data_pixsize (cmptype, header[0].bitpix, optname, optvalue, Noptions);
@@ -250,4 +248,8 @@
   int raw_pixsize = gfits_uncompressed_data_pixsize (cmptype, header[0].bitpix, optname, optvalue, Noptions);
 
+  // size of a pixel in the final image (not needed)
+  // int tile_pixsize = abs(header[0].bitpix) / 8;
+  // fprintf (stderr, "raw_pixsize: %d, cmp_pixsize: %d, tile_pixsize: %d, raw_bitpix: %d\n", raw_pixsize, cmp_pixsize, tile_pixsize, raw_bitpix);
+
   int Nout_alloc = raw_pixsize*max_tile_size;
   ALLOCATE (out, char, Nout_alloc);
@@ -255,5 +257,5 @@
   off_t row;
 
-  if (0) { 
+  if (VERBOSE_DUMP) { 
     int k;
     fprintf (stderr, "unc tbl: "); 
@@ -273,9 +275,5 @@
     if (!zdata) ESCAPE;
 
-    if (strcasecmp(cmptype, "GZIP_1")) {
-      if (!gfits_byteswap_zdata (zdata, Nzdata, cmp_pixsize)) ESCAPE;
-    }
-
-    if (0 && (row == 0)) {
+    if (VERBOSE_DUMP && (row == 0)) {
       int k;
       fprintf (stderr, "unc dat: "); 
@@ -284,10 +282,25 @@
     }
 
+    if (strcasecmp(cmptype, "GZIP_1")) {
+      // Nzdata is number of bytes
+      if (!gfits_byteswap_zdata (zdata, Nzdata, cmp_pixsize)) ESCAPE;
+    }
+
+    if (VERBOSE_DUMP && (row == 0)) {
+      int k;
+      fprintf (stderr, "unc SWP: "); 
+      for (k = 0; k < 32; k++) { fprintf (stderr, "0x%02hhx ", zdata[k]); } 
+      fprintf (stderr, "\n");
+      fprintf (stderr, "Nout  : %d -> ", Nout);
+    }
+    
     // gfits_uncompress_data uncompresses from zdata to the temporary output buffer which must be allocated
     // XXX the tile must not be > 2GB
+    // Nout going in is number of bytes 
     if (!gfits_uncompress_data ((char *)zdata, Nzdata, cmptype, optname, optvalue, Noptions, out, &Nout, raw_pixsize)) ESCAPE;
 
-    if (0 && (row == 0)) {
+    if (VERBOSE_DUMP && (row == 0)) {
       int k;
+      fprintf (stderr, "%d\n", Nout);
       fprintf (stderr, "unc swp: "); 
       for (k = 0; k < 32; k++) { fprintf (stderr, "0x%02hhx ", out[k]); } 
@@ -296,8 +309,9 @@
     
     if (!strcasecmp(cmptype, "GZIP_1")) {
-      if (!gfits_byteswap_zdata (out, Nout, raw_pixsize)) ESCAPE;
+      // Nout is number of pixels
+      if (!gfits_byteswap_zdata (out, Nout * raw_pixsize, raw_pixsize)) ESCAPE;
     }
     
-    if (0 && (row == 0)) {
+    if (VERBOSE_DUMP && (row == 0)) {
       int k;
       fprintf (stderr, "unc raw: "); 
@@ -309,5 +323,5 @@
     if (!gfits_distribute_data (matrix, out, Nout, raw_bitpix, otile, oblank, ztile, zblank, zscale, zzero)) ESCAPE;
 
-    if (0 && (row == 0)) {
+    if (VERBOSE_DUMP && (row == 0)) {
       int k;
       fprintf (stderr, "unc mat: "); 
Index: /branches/eam_branches/ohana.20150429/src/libfits/matrix/F_uncompress_data.c
===================================================================
--- /branches/eam_branches/ohana.20150429/src/libfits/matrix/F_uncompress_data.c	(revision 38355)
+++ /branches/eam_branches/ohana.20150429/src/libfits/matrix/F_uncompress_data.c	(revision 38356)
@@ -31,6 +31,4 @@
 
   int status;
-  static int Ninsum = 0;
-  static int Noutsum = 0;
 
   // do not actually uncompress : this is used for testing
@@ -42,5 +40,7 @@
 
   if (!strcasecmp(cmptype, "GZIP_1")) {
-    unsigned long tNout = *Nout * out_pixsize;
+    // unsigned long tNout = *Nout * out_pixsize;
+    // input value of *Nout is number of BYTES
+    unsigned long tNout = *Nout;
 
     // for GZIP data, I need to check for and remove the header on the first block:
@@ -53,4 +53,5 @@
     if (status != Z_OK) ESCAPE(FALSE);
     *Nout = tNout / out_pixsize;
+    // output value of *Nout is number of PIXELS
 
     // the resulting uncompressed data is byteswapped
@@ -60,5 +61,5 @@
   }
 
-  if (!strcasecmp(cmptype, "RICE_1")) {
+  if (!strcasecmp(cmptype, "RICE_1") || !strcasecmp(cmptype, "RICE_ONE")) {
     int i, blocksize;
     // look for the BLOCKSIZE
@@ -74,41 +75,36 @@
     }
 
-    int Npix;
-    // Npix = *Nout * (out_pixsize / 4.0);
-    Npix = *Nout;
-
-    Ninsum += Nzdata;
-    Noutsum += *Nout;
-    // fprintf (stderr, "%d comp bytes; %d uncomp 'pixels', totals: %d %d\n", Nzdata, Npix, Ninsum, Noutsum);
+    int status = FALSE;
+    int Npix = *Nout / out_pixsize;
+    int k;
 
     switch (out_pixsize) {
       case 4:
 	// rice decompression from the CFITSIO source tree : we need to tell it the expected number of pixels
-	// is also REQUIRES 4byte output, which is fairly stupid.
-	if (fits_rdecomp ((unsigned char *) zdata, Nzdata, (unsigned int *) outdata, Npix, blocksize)) {
-	  fprintf (stderr, "error in rice decompression\n");
-	  return (FALSE);
+	status = fits_rdecomp ((unsigned char *) zdata, Nzdata, (unsigned int *) outdata, Npix, blocksize);
+	break;
+      case 2:
+	if (0) {
+	  fprintf (stderr, "Nout: %d, Nrawpix: %d\n", Nzdata, Npix);
+	  fprintf (stderr, "cmp out: "); 
+	  for (k = 0; k < Nzdata; k++) { fprintf (stderr, "0x%02hhx ", zdata[k]); } 
+	  fprintf (stderr, "\n");
 	}
-	return (TRUE);
-
-      case 2:
-	if (fits_rdecomp_short ((unsigned char *) zdata, Nzdata, (unsigned short *) outdata, Npix, blocksize)) {
-	  fprintf (stderr, "error in rice decompression\n");
-	  return (FALSE);
-	}
-	return (TRUE);
-
+	status = fits_rdecomp_short ((unsigned char *) zdata, Nzdata, (unsigned short *) outdata, Npix, blocksize);
+	break;
       case 1:
-	if (fits_rdecomp_byte ((unsigned char *) zdata, Nzdata, (unsigned char *) outdata, Npix, blocksize)) {
-	  fprintf (stderr, "error in rice decompression\n");
-	  return (FALSE);
-	}
-	return (TRUE);
-	
+	status = fits_rdecomp_byte ((unsigned char *) zdata, Nzdata, (unsigned char *) outdata, Npix, blocksize);
+	break;
       default:
 	fprintf (stderr, "invalid output pixel size %d\n", out_pixsize);
-	return (FALSE);
+	status = FALSE;
+	break;
     }
-    
+    if (status) {
+      *Nout = 0;
+      return FALSE;
+    }
+    *Nout = Npix;
+    return TRUE;
   }
   
Index: /branches/eam_branches/ohana.20150429/src/libfits/table/F_compress_T.c
===================================================================
--- /branches/eam_branches/ohana.20150429/src/libfits/table/F_compress_T.c	(revision 38355)
+++ /branches/eam_branches/ohana.20150429/src/libfits/table/F_compress_T.c	(revision 38356)
@@ -157,5 +157,5 @@
       int Nraw = Nrows*fields[j].Nvalues; // number of pixels
       if (!strcmp(fields[j].zctype, "GZIP_1")) {
-	if (!gfits_byteswap_zdata (raw, Nraw, fields[j].pixsize)) ESCAPE(A);
+	if (!gfits_byteswap_zdata (raw, Nraw * fields[j].pixsize, fields[j].pixsize)) ESCAPE(A);
       }
 
Index: /branches/eam_branches/ohana.20150429/src/libfits/table/F_uncompress_T.c
===================================================================
--- /branches/eam_branches/ohana.20150429/src/libfits/table/F_uncompress_T.c	(revision 38355)
+++ /branches/eam_branches/ohana.20150429/src/libfits/table/F_uncompress_T.c	(revision 38356)
@@ -161,5 +161,5 @@
       if (!strcasecmp(fields[i].zctype, "GZIP_1")) {
 	myAssert ((fields[i].zdef.format != 'C') && (fields[i].zdef.format != 'M'), "swap is probably wrong for C or M columns");
-	if (!gfits_byteswap_zdata (raw, Nraw, fields[i].pixsize)) ESCAPE(A);
+	if (!gfits_byteswap_zdata (raw, Nraw * fields[i].pixsize, fields[i].pixsize)) ESCAPE(A);
       }
 
Index: /branches/eam_branches/ohana.20150429/src/libfits/test/compress.sh
===================================================================
--- /branches/eam_branches/ohana.20150429/src/libfits/test/compress.sh	(revision 38355)
+++ /branches/eam_branches/ohana.20150429/src/libfits/test/compress.sh	(revision 38356)
@@ -2,5 +2,5 @@
 macro test_image_all 
 
-  foreach mode NONE GZIP_1
+  foreach mode NONE GZIP_1 RICE_1
     foreach bitpix 8 16 32 -32 -64
       echo ===== bitpix = $bitpix =====
@@ -40,7 +40,13 @@
  end
 
+ if ($cmpmode == RICE_1) 
+   echo "*** funpack fails on RICE_1 ****"
+   return
+ end
+
  if ($bitpix == -64)
    echo "*** bitpix $bitpix fails fpack / funpack ***"
  else
+   echo "run funpack on our version"
    exec funpack -S test.cmp.fits > test.fun.fits
    rd e test.fun.fits
Index: /branches/eam_branches/ohana.20150429/src/libfits/test/imagecomp.c
===================================================================
--- /branches/eam_branches/ohana.20150429/src/libfits/test/imagecomp.c	(revision 38355)
+++ /branches/eam_branches/ohana.20150429/src/libfits/test/imagecomp.c	(revision 38356)
@@ -4,4 +4,15 @@
 
 int test_compress (int bitpix, char *zcmptype);
+
+// char *cmptype[] = {"NONE", "GZIP_1", "GZIP_2", "PLIO_1", "RICE_1", "RICE_ONE", "HCOMPRESS_1", NULL};
+char *cmptype[] = {"NONE", "GZIP_1", "RICE_1", "RICE_ONE", NULL};
+int bitpix[] = {8, 16, 32, -32, -64, 0};
+
+// char *cmptype[] = {"NONE", "GZIP_1", NULL};
+// char *cmptype[] = {"PLIO_1", NULL};
+// int bitpix[] = {8, 16, 32, 0};
+
+// char *cmptype[] = {"RICE_1", NULL};
+// int bitpix[] = {-32, -64, 0};
 
 int main (int argc, char **argv) {
@@ -11,15 +22,21 @@
   diag ("libfits imagecomp.c tests");
 
-  test_compress (  8, "NONE");
-  test_compress ( 16, "NONE");
-  test_compress ( 32, "NONE");
-  test_compress (-32, "NONE");
-  test_compress (-64, "NONE");
+  int i, j;
+  for (i = 0; cmptype[i]; i++) {
+    for (j = 0; bitpix[j]; j++) {
+      test_compress (bitpix[j], cmptype[i]);
+    }
+  }
 
-  test_compress (  8, "GZIP_1");
-  test_compress ( 16, "GZIP_1");
-  test_compress ( 32, "GZIP_1");
-  test_compress (-32, "GZIP_1");
-  test_compress (-64, "GZIP_1");
+  // test_compress ( 16, "NONE");
+  // test_compress ( 32, "NONE");
+  // test_compress (-32, "NONE");
+  // test_compress (-64, "NONE");
+  // 
+  // test_compress (  8, "GZIP_1");
+  // test_compress ( 16, "GZIP_1");
+  // test_compress ( 32, "GZIP_1");
+  // test_compress (-32, "GZIP_1");
+  // test_compress (-64, "GZIP_1");
 
   exit (0);
@@ -27,5 +44,5 @@
 
 # define NX 100
-# define NY 100
+# define NY 10
 
 int test_compress (int bitpix, char *zcmptype) { // make a table, compress, uncompress, compare : use compression zcmptype
@@ -65,10 +82,11 @@
   for (ix = 0; ix < NX; ix++) {
     for (iy = 0; iy < NY; iy++) {
+      int IY = iy + 1;
       switch (bitpix) {
-	case   8: rawdata_char  [ix + NX*iy] = ix + iy*iy; break;
-	case  16: rawdata_short [ix + NX*iy] = ix + iy*iy; break;
-	case  32: rawdata_int   [ix + NX*iy] = ix + iy*iy; break;
-	case -32: rawdata_float [ix + NX*iy] = ix + iy*iy; break;
-	case -64: rawdata_double[ix + NX*iy] = ix + iy*iy; break;
+	case   8: rawdata_char  [ix + NX*iy] = ix + IY*IY; break;
+	case  16: rawdata_short [ix + NX*iy] = ix + IY*IY; break;
+	case  32: rawdata_int   [ix + NX*iy] = ix + IY*IY; break;
+	case -32: rawdata_float [ix + NX*iy] = ix + IY*IY; break;
+	case -64: rawdata_double[ix + NX*iy] = ix + IY*IY; break;
 	default: myAbort ("bad bitpix value");
       }
Index: /branches/eam_branches/ohana.20150429/src/libfits/test/ricetest.c
===================================================================
--- /branches/eam_branches/ohana.20150429/src/libfits/test/ricetest.c	(revision 38356)
+++ /branches/eam_branches/ohana.20150429/src/libfits/test/ricetest.c	(revision 38356)
@@ -0,0 +1,69 @@
+# include <ohana.h>
+# include <gfitsio.h>
+# include "tap_ohana.h"
+
+# define NPIX 100
+# define NBYTE 4*NPIX
+
+int main (int argc, char **argv) {
+  
+  plan_tests (64);
+
+  // buffers to store max array
+  char rawdata[NBYTE];
+  char cmpdata[NBYTE];
+  char outdata[NBYTE];
+
+  if (1) { 
+    short *rawvalue = (short *) rawdata;
+    short *outvalue = (short *) outdata;
+
+    int j;
+    for (j = 0; j < 5; j++) { 
+      int i;
+      for (i = 0; i < NPIX; i++) {
+	rawvalue[i] = i;
+      }
+
+      int Ncmp = fits_rcomp_short (rawvalue, NPIX, cmpdata, NBYTE, 32);
+      fprintf (stderr, "Ncmp: %d\n", Ncmp);
+
+      int status = fits_rdecomp_short (cmpdata, Ncmp, outdata, NPIX, 32);
+      fprintf (stderr, "status: %d\n", status);
+
+      int Nbad = 0;
+      for (i = 0; i < NPIX; i++) {
+	if (rawvalue[i] != outvalue[i]) Nbad ++;
+      }
+
+      ok (!Nbad, "values match");
+    }
+  }
+
+  if (0) { 
+    int *rawvalue = (int *) rawdata;
+    int *outvalue = (int *) outdata;
+
+    int j;
+    for (j = 0; j < 5; j++) { 
+      int i;
+      for (i = 0; i < NPIX; i++) {
+	rawvalue[i] = i;
+      }
+
+      int Ncmp = fits_rcomp (rawvalue, NPIX, cmpdata, NBYTE, 32);
+      fprintf (stderr, "Ncmp: %d\n", Ncmp);
+
+      int status = fits_rdecomp (cmpdata, Ncmp, outdata, NPIX, 32);
+      fprintf (stderr, "status: %d\n", status);
+
+      int Nbad = 0;
+      for (i = 0; i < NPIX; i++) {
+	if (rawvalue[i] != outvalue[i]) Nbad ++;
+      }
+
+      ok (!Nbad, "values match");
+    }
+  }
+  exit (0);
+}
