chksum_mod is a set of overloaded functions returning checksums of integer and floating point arrays.
Introduction to chksum_mod.
Using chksum_mod.
Acquiring chksum_mod source.
Linking with chksum_mod.
Portability issues.
Checksums are required for testing code that is in constant
flux. These reduce arrays to a single number that will show whether
modifications to code have changed answers.
This is particularly critical in floating-point codes. Simply
summing arrays may not show changes to small numbers. The f90
intrinsic epsilon() is the smallest floating point
number that can be added to 1 and show a change: i.e
1.+epsilon(1.) is different from 1. in the last bit;
where as 1.+0.5*epsilon(1.) is identical to
1. in FP arithmetic. (epsilon is of the order
10^-16 for 8-byte reals).
Integer arithmetic however exactly recovers changes to every bit.
chksum_mod uses Cray pointers to treat FP
arrays as though they were integers (an operation that is otherwise
forbidden in the F90 standard). Cray pointers, while not in the
official F90 standard, is a de facto standard, available on
most compilers used in technical and scientific computing.
This module provides checksums for serial code. Parallel checksums,
that will provide identical answers no matter how the same array is
partitioned across processors, are provided by mpp_mod.
chksum_mod provides a single public interface, the
integer function chksum(var). var can
be an integer, real, or complex scalar or array of rank up to 4. For
example:
returns the checksum of the array var in
i.
GFDL users can copy the file
/net/vb/public/utils/chksum.F90. External users can
download the source here. The
current public version number is 1.1.
Any module or program unit using chksum_mod must contain the
line
Compiling chksum_mod requires cpp macro expansion on
every line of code, not just those beginning with #. Turning this on
usually requires a compiler flag (e.g -F on Cray
systems and -macro_expand on SGI MipsPro). Please
consult your compiler manual for this flag.
The source file for chksum_mod is chksum.F90.
Compiling with the cpp flag test_chksum turned on:
will produce a program that will exercise the
chksum_mod module.
If your compiler does not support Cray pointers, you are restricted
to integer arguments.
On non-SGI/Cray systems, you may also wish to examine carefully the
definition of the various _KIND macros defined in the
preamble.
Introduction
Using chksum_mod
real :: var(:,:,:,:)
i = chksum(var)
Acquiring chksum_mod source
Compiling and linking to chksum_mod
use chksum_mod
f90 -F -Dtest_chksum chksum.F90
Portability issues
chksum_mod requires the use of Cray pointers in order
to treat floating point arguments. If your compiler supports Cray
pointers, add it to the list in the preamble that defines
use_CRI_pointers, or else turn on the cpp flag
-Duse_CRI_pointers by hand.
Changes
The RCS log for
chksum.F90 contains a comprehensive list of changes. In the
unlikely event that you should wish to check out a retro version,
please get in touch with me, Balaji.