Index: trunk/psLib/src/fits/psFitsHeader.c
===================================================================
--- trunk/psLib/src/fits/psFitsHeader.c	(revision 16822)
+++ trunk/psLib/src/fits/psFitsHeader.c	(revision 17048)
@@ -7,6 +7,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.41 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2008-03-05 02:19:28 $
+ *  @version $Revision: 1.42 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2008-03-19 00:11:36 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -18,9 +18,9 @@
 
 #include <unistd.h>
+#include <string.h>
+#include <strings.h>
 
 #include "psAssert.h"
 #include "psFits.h"
-#include "string.h"
-#include "strings.h"
 #include "psError.h"
 
@@ -479,4 +479,5 @@
     int status = 0;                     // Status of cfitsio calls
     bool simple = true;                 // If SIMPLE is T, then the file should conform to the FITS standard
+    psFitsCompressionType compress = psFitsCompressionGetType(fits); // Compression type
     if (psFitsGetExtNum(fits) == 0) {
         // We allow the user to write SIMPLE, but it must be boolean
@@ -485,5 +486,5 @@
             if (simpleItem->type != PS_DATA_BOOL) {
                 psError(PS_ERR_BAD_PARAMETER_TYPE, true, "SIMPLE in a FITS header must be of boolean type: "
-                        "not %x --- assuming TRUE.\n", simpleItem->type);
+                        "not %x --- assuming FALSE.\n", simpleItem->type);
                 int value = false;          // Temporary holder for boolean
                 fits_update_key(fits->fd, TLOGICAL, "SIMPLE", &value,
@@ -492,14 +493,28 @@
             } else if (!simpleItem->data.B) {
                 simple = false;
-                int value = false;          // Temporary holder for boolean
+                int value = false;      // Temporary holder for boolean
                 fits_update_key(fits->fd, TLOGICAL, "SIMPLE", &value,
                                 "File does not conform to FITS standard", &status);
             }
-            // SIMPLE = T is taken care of by cfitsio.
-        }
+            // Uncompressed SIMPLE = T is taken care of by cfitsio.
+        }
+    }
+    if ((!fits->options || fits->options->conventions.compression) && compress != PS_FITS_COMPRESS_NONE) {
+        psMetadataItem *simpleItem = psMetadataLookup(output, "SIMPLE"); // SIMPLE in the header
+        if (simpleItem) {
+            if (simpleItem->type != PS_DATA_BOOL) {
+                psError(PS_ERR_BAD_PARAMETER_TYPE, true, "SIMPLE in a FITS header must be of boolean type: "
+                        "not %x --- assuming FALSE.\n", simpleItem->type);
+                simple = false;
+            } else {
+                simple = simpleItem->data.B;
+            }
+        }
+        //        int value = simple;             // Temporary holder for boolean
+        //        fits_update_key(fits->fd, TLOGICAL, "ZSIMPLE", &value,
+        //                        "Uncompressed file's conformance to FITS standard", &status);
     }
 
     // Traverse the metadata list and add each key.
-    psFitsCompressionType compress = psFitsCompressionGetType(fits); // Compression type
     psListIterator* iter = psListIteratorAlloc(output->list, PS_LIST_HEAD, true); // Iterator
     psMetadataItem* item;               // Item from iteration
@@ -513,6 +528,6 @@
             // changed) so we'll take care of that for them.
             if (keywordInList(name, noWriteFitsKeys)) {
-                if ((fits->options && !fits->options->conventions.compression) ||
-                    compress == PS_FITS_COMPRESS_NONE) {
+                if (strcmp(name, "SIMPLE") == 0 || compress == PS_FITS_COMPRESS_NONE ||
+                    (fits->options && !fits->options->conventions.compression)) {
                     // No compression happening, so don't write keyword
                     continue;
