Index: trunk/psLib/src/math/psStats.c
===================================================================
--- trunk/psLib/src/math/psStats.c	(revision 2370)
+++ trunk/psLib/src/math/psStats.c	(revision 2406)
@@ -9,6 +9,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.97 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-11-15 21:13:17 $
+ *  @version $Revision: 1.98 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-11-23 19:35:30 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -146,8 +146,8 @@
 this routine sets stats->sampleMean to NAN.
  *****************************************************************************/
-void p_psVectorSampleMean(const psVector* restrict myVector,
-                          const psVector* restrict maskVector,
-                          psU32 maskVal,
-                          psStats* stats)
+int p_psVectorSampleMean(const psVector* restrict myVector,
+                         const psVector* restrict maskVector,
+                         psU32 maskVal,
+                         psStats* stats)
 {
     psS32 i = 0;                // Loop index variable
@@ -210,4 +210,10 @@
 
     stats->sampleMean = mean;
+    if (isnan(mean)) {
+        return(0);
+    } else {
+        return(-1);
+    }
+
 }
 
@@ -217,8 +223,8 @@
 this routine sets stats->max to NAN.
  *****************************************************************************/
-void p_psVectorMax(const psVector* restrict myVector,
-                   const psVector* restrict maskVector,
-                   psU32 maskVal,
-                   psStats* stats)
+int p_psVectorMax(const psVector* restrict myVector,
+                  const psVector* restrict maskVector,
+                  psU32 maskVal,
+                  psStats* stats)
 {
     psS32 i = 0;                // Loop index variable
@@ -272,5 +278,7 @@
     } else {
         stats->max = NAN;
-    }
+        return(1);
+    }
+    return(0);
 }
 
@@ -280,8 +288,8 @@
 this routine sets stats->min to NAN.
  *****************************************************************************/
-void p_psVectorMin(const psVector* restrict myVector,
-                   const psVector* restrict maskVector,
-                   psU32 maskVal,
-                   psStats* stats)
+int p_psVectorMin(const psVector* restrict myVector,
+                  const psVector* restrict maskVector,
+                  psU32 maskVal,
+                  psStats* stats)
 {
     psS32 i = 0;                // Loop index variable
@@ -335,5 +343,7 @@
     } else {
         stats->min = NAN;
-    }
+        return(1);
+    }
+    return(0);
 }
 
@@ -1205,8 +1215,14 @@
     // Determine minimum and maximum values in the data vector.
     if (isnan(stats->min)) {
-        p_psVectorMin(myVector, maskVector, maskVal, stats);
-    }
+        if (0 != p_psVectorMin(myVector, maskVector, maskVal, stats)) {
+            psLogMsg(__func__, PS_LOG_WARN,
+                     "WARNING: p_psVectorMin(): p_psVectorMin() reported a NAN mean.\n");
+            return(1);
+        }
+    }
+
+
     if (isnan(stats->max)) {
-        p_psVectorMax(myVector, maskVector, maskVal, stats);
+        if (0 != p_psVectorMax(myVector, maskVector, maskVal, stats)) {}
     }
 
@@ -1771,9 +1787,19 @@
     // ************************************************************************
     if (stats->options & PS_STAT_MAX) {
-        p_psVectorMax(inF32, mask, maskVal, stats);
+        if (0 != p_psVectorMax(inF32, mask, maskVal, stats)) {
+            psError(PS_ERR_UNKNOWN, false,
+                    "Failed to calculate vector maximum");
+            psFree(stats);
+            return(NULL);
+        }
     }
     // ************************************************************************
     if (stats->options & PS_STAT_MIN) {
-        p_psVectorMin(inF32, mask, maskVal, stats);
+        if (0 != p_psVectorMin(inF32, mask, maskVal, stats)) {
+            psError(PS_ERR_UNKNOWN, false,
+                    "Failed to calculate vector minimum");
+            psFree(stats);
+            return(NULL);
+        }
     }
 
