Index: trunk/psModules/src/pmReadoutCombine.c
===================================================================
--- trunk/psModules/src/pmReadoutCombine.c	(revision 2810)
+++ trunk/psModules/src/pmReadoutCombine.c	(revision 2812)
@@ -5,6 +5,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-12-23 20:27:51 $
+ *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-12-23 23:16:36 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -27,13 +27,16 @@
 psCombineParams;
 
-
-int p_psDetermineNumBits(unsigned int data)
+/******************************************************************************
+p_psDetermineNumBits(data): This routine takes an enum psStatsOptions as an
+argument and returns the number of non-zero bits.
+ *****************************************************************************/
+psStatsOptions p_psDetermineNumBits(psStatsOptions data)
 {
-    int i;
-    unsigned int tmpData = data;
-    int numBits = 0;
-
-    for (i=0;i<sizeof(unsigned int);i++) {
-        if (0x0001 && tmpData) {
+    psS32 i;
+    psU64 tmpData = data;
+    psS32 numBits = 0;
+
+    for (i=0;i<4 * sizeof(psStatsOptions);i++) {
+        if (0x0001 & tmpData) {
             numBits++;
         }
@@ -43,4 +46,5 @@
 }
 
+// XXX: Whats this?
 #define MAX_INT 10000
 psImage *pmReadoutCombine(psImage *output,
@@ -55,4 +59,17 @@
     PS_PTR_CHECK_NULL(inputs, NULL);
     PS_PTR_CHECK_NULL(params, NULL);
+    PS_PTR_CHECK_NULL(params->stats, NULL);
+    if (zero != NULL) {
+        PS_VECTOR_CHECK_TYPE(zero, PS_TYPE_F32, NULL);
+    }
+    if (scale != NULL) {
+        PS_VECTOR_CHECK_TYPE(scale, PS_TYPE_F32, NULL);
+    }
+    if ((zero != NULL) && (scale != NULL)) {
+        PS_VECTOR_CHECK_TYPE_EQUAL(zero, scale, NULL);
+        // XXX: Currently only type F32 is implemented.
+        // PS_VECTOR_CHECK_TYPE_S16_S32_F32(scale, NULL);
+    }
+
     psStats *stats = params->stats;
     int i;
@@ -66,4 +83,11 @@
     int numInputs = 0;
     int tmpI;
+    psElemType outputType = PS_TYPE_F32;
+
+    if (1 < p_psDetermineNumBits(params->stats->options)) {
+        psError(PS_ERR_UNKNOWN, true,
+                "Multiple statistical options have been requested.\n");
+        return(NULL);
+    }
 
     //
@@ -86,4 +110,5 @@
         PS_READOUT_CHECK_EMPTY(tmpReadout, output);
         PS_READOUT_CHECK_TYPE(tmpReadout, PS_TYPE_F32, output);
+        outputType = tmpReadout->image->type.type;
 
         minInputRows = PS_MIN(minInputRows,
@@ -105,11 +130,13 @@
 
     // We ensure that the zero vector is of the proper size.
+
     if (zero != NULL) {
         PS_VECTOR_CHECK_TYPE(zero, PS_TYPE_F32, NULL);
         if (numInputs > zero->n) {
-            // XXX: ERROR: the zero vector does not have enough elements.
+            psError(PS_ERR_UNKNOWN, true, "zero vector has incorrect size (%d)\n", zero->n);
             return(NULL);
         } else if (numInputs < zero->n) {
-            // XXX: WARNING: the zero vector too many elements.
+            psLogMsg(__func__, PS_LOG_WARN,
+                     "WARNING: the zero vector too many elements (%d)\n", zero->n);
         }
     }
@@ -119,8 +146,9 @@
         PS_VECTOR_CHECK_TYPE(scale, PS_TYPE_F32, NULL);
         if (numInputs > scale->n) {
-            // XXX: ERROR: the scale vector does not have enough elements.
+            psError(PS_ERR_UNKNOWN, true, "scale vector has incorrect size (%d)\n", scale->n);
             return(NULL);
         } else if (numInputs < scale->n) {
-            // XXX: WARNING: the scale vector too many elements.
+            psLogMsg(__func__, PS_LOG_WARN,
+                     "WARNING: the scale vector too many elements (%d)\n", scale->n);
         }
     }
@@ -134,5 +162,5 @@
     if (output == NULL) {
         output = psImageAlloc(maxInputCols-minInputCols,
-                              maxInputRows-minInputRows, PS_TYPE_F32);
+                              maxInputRows-minInputRows, outputType);
         *(int *) &(output->col0) = minInputCols;
         *(int *) &(output->row0) = minInputRows;
@@ -140,7 +168,8 @@
         if (((output->col0 + output->numCols) < maxInputCols) ||
                 ((output->row0 + output->numRows) < maxInputRows)) {
-            //XXX ERROR: "Output image (%d, %d) is too small to hold combined images.\n",
-            //                    output->row0 + output->numRows,
-            //                    output->col0 + output->numCols);
+            psError(PS_ERR_UNKNOWN, true,
+                    "Output image (%d, %d) is too small to hold combined images.\n",
+                    output->row0 + output->numRows,
+                    output->col0 + output->numCols);
             return(NULL);
         }
@@ -150,9 +179,4 @@
             return(NULL);
         }
-    }
-
-    if (1 < p_psDetermineNumBits(params->stats->options)) {
-        //XXX        psError(PS_ERR_UNKNOWN,true, "Multiple statistical options have been requested.\n");
-        return(NULL);
     }
 
@@ -254,4 +278,5 @@
             // XXX: Is this correct?
             // We add the zero vector, if non-NULL.
+
             if (zero != NULL) {
                 for (int r = 0; r < numInputs ; r++) {
