Index: /branches/eam_branches/ohana.20150429/src/libfits/Makefile
===================================================================
--- /branches/eam_branches/ohana.20150429/src/libfits/Makefile	(revision 38403)
+++ /branches/eam_branches/ohana.20150429/src/libfits/Makefile	(revision 38404)
@@ -1,5 +1,5 @@
 default: install
 help:
-	@echo "make options: install libfits man clean dist"
+	@echo "make options: install libfits man clean dist test test.verbose test.clean"
 
 include ../../Makefile.System
@@ -26,8 +26,11 @@
 TEST_LDFLAGS  = $(BASE_LDFLAGS) -lFITS -lohana -ltap_ohana
 
-TESTPROG = imagecomp tablecomp zlib ricetest
+# zlib
+TESTPROG = imagecomp tablecomp ricetest
 $(TESTPROG) : % : $(TESTBIN)/%
 test: $(TESTPROG)
-	for i in $(TESTPROG); do $(TESTBIN)/$$i; done
+	for i in $(TESTPROG); do $(TESTBIN)/$$i 2>&1 | $(TESTHARNESS); done
+test.verbose: $(TESTPROG)
+	for i in $(TESTPROG); do $(TESTBIN)/$$i 2>&1 |& $(TESTHARNESS) -v; done
 
 install: $(DESTLIB)/libFITS.a $(DESTLIB)/libFITS.$(DLLTYPE) $(DESTMAN)/fits.1
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 38403)
+++ /branches/eam_branches/ohana.20150429/src/libfits/table/F_compress_T.c	(revision 38404)
@@ -149,7 +149,7 @@
 
 
-    // RICE can only be used on integer fields
+    // OVERRIDE: RICE can only be used on integer fields
     if (!strcasecmp (fields[i].zctype, "RICE_1") || !strcasecmp (fields[i].zctype, "RICE_ONE")) {
-      if (!strcmp (fields[i].datatype, "float") || !strcmp (fields[i].datatype, "double")) {
+      if (!strcmp (fields[i].datatype, "float") || !strcmp (fields[i].datatype, "double") || !strcmp (fields[i].datatype, "int64_t")) {
 	strcpy (fields[i].zctype, "GZIP_2");
       }
Index: /branches/eam_branches/ohana.20150429/src/libfits/table/F_get_column.c
===================================================================
--- /branches/eam_branches/ohana.20150429/src/libfits/table/F_get_column.c	(revision 38403)
+++ /branches/eam_branches/ohana.20150429/src/libfits/table/F_get_column.c	(revision 38404)
@@ -76,15 +76,19 @@
   }
 
-  /* convert data in-situ with correct type, byte swap and Bzero/Bscale */
+  // NOTE: we have already copied the data to 'array', so the blocks below
+  // only need to swap if this is a direct copy
   Pin  = array;
   Pout = array;
+  int directCopy = (Bzero == 0.0) && (Bscale == 1.0);
+
+  /* convert data in-situ with correct type, byte swap and Bzero/Bscale */
   if (!strcmp (type, "char")) {
     for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) {
-      *(char *)Pout = *(char *)Pin*Bscale + Bzero;
+      if (!directCopy) { *(char *)Pout = *(char *)Pin*Bscale + Bzero; }
     }
   }
   if (!strcmp (type, "byte")) {
     for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) {
-      *(char *)Pout = *(char *)Pin*Bscale + Bzero;
+      if (!directCopy) { *(char *)Pout = *(char *)Pin*Bscale + Bzero; }
     }
   }
@@ -94,5 +98,5 @@
       if (!nativeOrder) { SWAP_BYTE; }
 # endif
-      *(short *)Pout = *(short *)Pin*Bscale + Bzero;
+      if (!directCopy) { *(short *)Pout = *(short *)Pin*Bscale + Bzero; }
     }  
   }
@@ -102,22 +106,13 @@
       if (!nativeOrder) { SWAP_WORD; }
 # endif
-      *(int *)Pout = *(int *)Pin*Bscale + Bzero;
+      if (!directCopy) { *(int *)Pout = *(int *)Pin*Bscale + Bzero; }
     }
   }
   if (!strcmp (type, "int64_t")) {
-    if ((Bzero == 0.0) && (Bscale == 1.0)) {
-      for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) {
-# ifdef BYTE_SWAP
-	if (!nativeOrder) { SWAP_DBLE; }
-# endif
-	*(int64_t *)Pout = *(int64_t *)Pin;
-      }
-    } else {
-      for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) {
-# ifdef BYTE_SWAP
-	if (!nativeOrder) { SWAP_DBLE; }
-# endif
-	*(int64_t *)Pout = *(int64_t *)Pin*Bscale + Bzero;
-      }
+    for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) {
+# ifdef BYTE_SWAP
+      if (!nativeOrder) { SWAP_DBLE; }
+# endif
+      if (!directCopy) { *(int64_t *)Pout = *(int64_t *)Pin*Bscale + Bzero; }
     }
   }
@@ -127,5 +122,5 @@
       if (!nativeOrder) { SWAP_WORD; }
 # endif
-      *(float *)Pout = *(float *)Pin*Bscale + Bzero;
+      if (!directCopy) { *(float *)Pout = *(float *)Pin*Bscale + Bzero; }
     }
   }
@@ -135,5 +130,5 @@
       if (!nativeOrder) { SWAP_DBLE; }
 # endif
-      *(double *)Pout = *(double *)Pin*Bscale + Bzero;
+      if (!directCopy) { *(double *)Pout = *(double *)Pin*Bscale + Bzero; }
     }
   }
Index: /branches/eam_branches/ohana.20150429/src/libfits/table/F_set_column.c
===================================================================
--- /branches/eam_branches/ohana.20150429/src/libfits/table/F_set_column.c	(revision 38403)
+++ /branches/eam_branches/ohana.20150429/src/libfits/table/F_set_column.c	(revision 38404)
@@ -1,4 +1,8 @@
 # include <ohana.h>
 # include <gfitsio.h>
+
+# define SWAP_NONE 
+
+# ifdef BYTE_SWAP 
 # define SWAP_BYTE { \
   char tmp; \
@@ -14,4 +18,9 @@
   tmp = Pout[2]; Pout[2] = Pout[5]; Pout[5] = tmp; \
   tmp = Pout[3]; Pout[3] = Pout[4]; Pout[4] = tmp; }
+# else
+# define SWAP_BYTE 
+# define SWAP_WORD 
+# define SWAP_DBLE 
+# endif
 
 /***********************/
@@ -239,9 +248,81 @@
   // if (!strcmp (intype, #ITYPE)) {
 
+  int directCopy = (Bzero == 0.0) && (Bscale == 1.0);
+
+# define SET_VALUES(OUTNAME, OUTTYPE, INNAME, INTYPE, SWAP_OP, NBYTES_IN) \
+  if (!strcmp (outtype, OUTNAME) && !strcmp (intype, INNAME)) {		\
+    int NbytesIn = NBYTES_IN;						\
+    for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) { \
+      if (directCopy) {							\
+	*(OUTTYPE *)Pout = *(INTYPE *)Pin;				\
+      } else {								\
+	*(OUTTYPE *)Pout = (*(INTYPE *)Pin - Bzero) / Bscale;		\
+      }									\
+      if (!nativeOrder) { SWAP_OP; }}}					
+
+  SET_VALUES("char",       char, "char", char, SWAP_NONE, 1);
+  SET_VALUES("byte",       char, "char", char, SWAP_NONE, 1);
+  SET_VALUES("short",     short, "char", char, SWAP_BYTE, 1);
+  SET_VALUES("int",         int, "char", char, SWAP_WORD, 1);
+  SET_VALUES("int64_t", int64_t, "char", char, SWAP_DBLE, 1);
+  SET_VALUES("double",   double, "char", char, SWAP_DBLE, 1);
+  SET_VALUES("float",     float, "char", char, SWAP_WORD, 1);
+
+  SET_VALUES("char",       char, "byte", char, SWAP_NONE, 1);
+  SET_VALUES("byte",       char, "byte", char, SWAP_NONE, 1);
+  SET_VALUES("short",     short, "byte", char, SWAP_BYTE, 1);
+  SET_VALUES("int",         int, "byte", char, SWAP_WORD, 1);
+  SET_VALUES("int64_t", int64_t, "byte", char, SWAP_DBLE, 1);
+  SET_VALUES("float",     float, "byte", char, SWAP_DBLE, 1);
+  SET_VALUES("double",   double, "byte", char, SWAP_WORD, 1);
+
+  SET_VALUES("char",       char, "short", short, SWAP_NONE, 2);
+  SET_VALUES("byte",       char, "short", short, SWAP_NONE, 2);
+  SET_VALUES("short",     short, "short", short, SWAP_BYTE, 2);
+  SET_VALUES("int",         int, "short", short, SWAP_WORD, 2);
+  SET_VALUES("int64_t", int64_t, "short", short, SWAP_DBLE, 2);
+  SET_VALUES("float",     float, "short", short, SWAP_DBLE, 2);
+  SET_VALUES("double",   double, "short", short, SWAP_WORD, 2);
+
+  SET_VALUES("char",       char, "int", int, SWAP_NONE, 4);
+  SET_VALUES("byte",       char, "int", int, SWAP_NONE, 4);
+  SET_VALUES("short",     short, "int", int, SWAP_BYTE, 4);
+  SET_VALUES("int",         int, "int", int, SWAP_WORD, 4);
+  SET_VALUES("int64_t", int64_t, "int", int, SWAP_DBLE, 4);
+  SET_VALUES("float",     float, "int", int, SWAP_DBLE, 4);
+  SET_VALUES("double",   double, "int", int, SWAP_WORD, 4);
+
+  SET_VALUES("char",       char, "int64_t", int64_t, SWAP_NONE, 8);
+  SET_VALUES("byte",       char, "int64_t", int64_t, SWAP_NONE, 8);
+  SET_VALUES("short",     short, "int64_t", int64_t, SWAP_BYTE, 8);
+  SET_VALUES("int",         int, "int64_t", int64_t, SWAP_WORD, 8);
+  SET_VALUES("int64_t", int64_t, "int64_t", int64_t, SWAP_DBLE, 8);
+  SET_VALUES("float",     float, "int64_t", int64_t, SWAP_DBLE, 8);
+  SET_VALUES("double",   double, "int64_t", int64_t, SWAP_WORD, 8);
+
+  SET_VALUES("char",       char, "float", float, SWAP_NONE, 4);
+  SET_VALUES("byte",       char, "float", float, SWAP_NONE, 4);
+  SET_VALUES("short",     short, "float", float, SWAP_BYTE, 4);
+  SET_VALUES("int",         int, "float", float, SWAP_WORD, 4);
+  SET_VALUES("int64_t", int64_t, "float", float, SWAP_DBLE, 4);
+  SET_VALUES("float",     float, "float", float, SWAP_DBLE, 4);
+  SET_VALUES("double",   double, "float", float, SWAP_WORD, 4);
+
+  SET_VALUES("char",       char, "double", double, SWAP_NONE, 8);
+  SET_VALUES("byte",       char, "double", double, SWAP_NONE, 8);
+  SET_VALUES("short",     short, "double", double, SWAP_BYTE, 8);
+  SET_VALUES("int",         int, "double", double, SWAP_WORD, 8);
+  SET_VALUES("int64_t", int64_t, "double", double, SWAP_DBLE, 8);
+  SET_VALUES("float",     float, "double", double, SWAP_DBLE, 8);
+  SET_VALUES("double",   double, "double", double, SWAP_WORD, 8);
+
+# if (0)
   /** input == char **/
   if (!strcmp (outtype, "char") && !strcmp (intype, "char")) {
     int NbytesIn = 1;
     for (i = 0; i < Nval*Nrow; i++, Pin+=NbytesIn, Pout+=NbytesOut) {
-      *(char *)Pout = (*(char *)Pin - Bzero) / Bscale;
+      if (directCopy) { *(char *)Pout = *(char *)Pin; } else {
+	*(char *)Pout = (*(char *)Pin - Bzero) / Bscale;
+      }
     }
   }
@@ -249,5 +330,7 @@
     int NbytesIn = 1;
     for (i = 0; i < Nval*Nrow; i++, Pin+=NbytesIn, Pout+=NbytesOut) {
-      *(char *)Pout = (*(char *)Pin - Bzero) / Bscale;
+      if (directCopy) { *(char *)Pout = *(char *)Pin; } else {
+	*(char *)Pout = (*(char *)Pin - Bzero) / Bscale;
+      }
     }
   }
@@ -255,5 +338,7 @@
     int NbytesIn = 1;
     for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {
-      *(short *)Pout = (*(char *)Pin - Bzero) / Bscale;
+      if (directCopy) { *(short *)Pout = *(char *)Pin; } else {
+	*(short *)Pout = (*(char *)Pin - Bzero) / Bscale;
+      }
 # ifdef BYTE_SWAP
       if (!nativeOrder) { SWAP_BYTE; }
@@ -651,4 +736,5 @@
     }
   }
+# endif
 
   /* check array space */
Index: /branches/eam_branches/ohana.20150429/src/libfits/test/compress.sh
===================================================================
--- /branches/eam_branches/ohana.20150429/src/libfits/test/compress.sh	(revision 38403)
+++ /branches/eam_branches/ohana.20150429/src/libfits/test/compress.sh	(revision 38404)
@@ -330,5 +330,6 @@
  # lrnd generates rnd int between 0 and 0x7fffff (2^31 - 1 inclusive)
 
- $NPT = 1000
+ # $NPT = 1000
+ $NPT = 30
  create ni 0 $NPT -int
  set Achar  = lrnd(ni) & 0x7f
@@ -339,5 +340,5 @@
  create nf 0 $NPT
  set Ffloat = drnd(nf)*1e20
- set Fdouble = drnd(nf)*1e100
+ set Fdouble = drnd(nf)*1e50
 
  local format
@@ -346,4 +347,7 @@
  $format = BIJKED
 
+ #$fields = Ffloat
+ #$format = E
+
  write -fits test test.raw.tbl $fields -format $format
  write -fits test test.cmp.tbl $fields -format $format -compress-mode $cmpmode
Index: /branches/eam_branches/ohana.20150429/src/libfits/test/ricetest.c
===================================================================
--- /branches/eam_branches/ohana.20150429/src/libfits/test/ricetest.c	(revision 38403)
+++ /branches/eam_branches/ohana.20150429/src/libfits/test/ricetest.c	(revision 38404)
@@ -16,4 +16,6 @@
   char cmpdata[NBYTE];
   char outdata[NBYTE];
+
+  // ok (1, "failure");
 
   if (1) { 
Index: /branches/eam_branches/ohana.20150429/src/libfits/test/tablecomp.c
===================================================================
--- /branches/eam_branches/ohana.20150429/src/libfits/test/tablecomp.c	(revision 38403)
+++ /branches/eam_branches/ohana.20150429/src/libfits/test/tablecomp.c	(revision 38404)
@@ -11,7 +11,10 @@
 int main (int argc, char **argv) {
   
-  plan_tests (286);
+  plan_tests (668);
 
   diag ("libfits tablecomp.c tests");
+
+  // test_compress ("RICE_1");
+  // test_compress_fullrange ("RICE_1");
 
 # if (1)
Index: /branches/eam_branches/ohana.20150429/src/libfits/test/zlib.c
===================================================================
--- /branches/eam_branches/ohana.20150429/src/libfits/test/zlib.c	(revision 38403)
+++ /branches/eam_branches/ohana.20150429/src/libfits/test/zlib.c	(revision 38404)
@@ -53,9 +53,9 @@
     err = deflateInit(&zdn, 5);
     // fprintf (stderr, "inp buffers cmp 0: %d => %d => %d\n", zdn.avail_in, zdn.avail_out, (int) zdn.total_out);
-    if (err != Z_OK) { fprintf (stderr, "error 1: %d vs %d\n", err, Z_OK); exit (1); }
+    if (err != Z_OK) { fprintf (stdout, "not ok: error 1: %d vs %d\n", err, Z_OK); exit (1); }
   
     err = deflate(&zdn, Z_FINISH);
     // fprintf (stderr, "out buffers cmp 1: %d => %d => %d\n", zdn.avail_in, zdn.avail_out, (int) zdn.total_out);
-    if (err != Z_STREAM_END) { fprintf (stderr, "error 2: %d vs %d\n", err, Z_STREAM_END); exit (2); }
+    if (err != Z_STREAM_END) { fprintf (stdout, "not ok: error 2: %d vs %d\n", err, Z_STREAM_END); exit (2); }
     // fprintf (stderr, "out buffers cmp 2: %d => %d => %d\n", zdn.avail_in, zdn.avail_out, (int) zdn.total_out);
 
@@ -92,5 +92,5 @@
     err = inflateInit(&zup);
     // fprintf (stderr, "out buffers unc 0: %d => %d => %d\n", zup.avail_in, zup.avail_out, (int) zup.total_out);
-    if (err != Z_OK) { fprintf (stderr, "error 1: %d vs %d\n", err, Z_OK); exit (1); }
+    if (err != Z_OK) { fprintf (stdout, "not ok: error 1: %d vs %d\n", err, Z_OK); exit (1); }
   
     err = inflate(&zup, Z_FINISH);
@@ -116,4 +116,5 @@
     }
   }
+
   return exit_status();
 }
