idlastro / FITS I/O: FITS_ADD_CHECKSUM

[Source code]

NAME
FITS_ADD_CHECKSUM
PURPOSE
Add or update the CHECKSUM and DATASUM keywords in a FITS header
EXPLANATION
Follows the May 2002 version of the FITS checksum proposal at 
http://fits.gsfc.nasa.gov/registry/checksum.html 
CALLING SEQUENCE
FITS_ADD_CHECKSUM, Hdr, [ Data, /No_TIMESTAMP, /FROM_IEEE ]
INPUT-OUTPUT
Hdr - FITS header (string array), it will be updated with new 
      (or modified) CHECKSUM and DATASUM keywords 
OPTIONAL INPUT
Data - data array associated with the FITS header.   If not supplied, or
      set to a scalar, then the program checks whether there is a 
      DATASUM keyword already in the FITS header containing the 32bit
      checksum for the data.  If there is no such keyword then there 
      assumed to be no data array associated with the FITS header.
OPTIONAL INPUT KEYWORDS
/FROM_IEEE - If this keyword is set, then the input is assumed to be in 
         big endian format (e.g. an untranslated FITS array).    This 
         keyword only has an effect on little endian machines (e.g. 
         a Linux box).
/No_TIMESTAMP - If set, then a time stamp is not included in the comment
         field of the CHECKSUM and DATASUM keywords.   Unless the 
         /No_TIMESTAMP keyword is set, repeated calls to FITS_ADD_CHECKSUM
         with the same header and data will yield different values of 
         CHECKSUM (as the date stamp always changes).   However, use of the
         date stamp is recommended in the checksum proposal. 
PROCEDURES USED
CHECKSUM32, FITS_ASCII_ENCODE(), GET_DATE, SXADDPAR, SXPAR()
REVISION HISTORY
W. Landsman    SSAI    December 2002
Fix problem with images with a multiple of 2880 bytes.  W.L. May 2008
Avoid conversion error when DATASUM is an empty string  W.L.  June 2008
Don't update DATASUM if not already present and no data array supplied 
                  W.L. July 2008 
Make sure input header array has 80 chars/line  W.L. Aug 2009
Make sure CHECKSUM is placed right after an already present DATASUM
keyword. Mats Löfdahl October 2019