anchor.diff:  !                   +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
   !
   ! ---------------------------------------------------------------------------------------------------------------------------------+
  -INTEGER(KIND=4) FUNCTION CALCULATE_HASH_STRING(VALUE)
  +INTEGER(KIND=4) FUNCTION HASHCODE_STRING(VALUE)
   CHARACTER(LEN=*),INTENT(IN) :: VALUE
   INTEGER  (KIND=4)           :: IVALUE,JVALUE
   CHARACTER(LEN=4)            :: CVALUE
  
positive.code: ! LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  ! CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  ! ---------------------------------------------------------------------------------------------------------------------------------+
  MODULE MODHASH
  IMPLICIT NONE
  PRIVATE
  PUBLIC :: CALCULATE_HASH,HASHTABLE_INSERT_AT
  PUBLIC :: HASHTABLE
  PUBLIC :: HASHTABLE_INIT
  TYPE HASHTABLE
    INTEGER(KIND=4)             :: TABLE_SIZE
    INTEGER(KIND=4)             :: RECORD_SIZE
    INTEGER(KIND=4)             :: RECORD_COUNT
    INTEGER(KIND=4),ALLOCATABLE :: INDICIES(:,:)
    INTEGER(KIND=1),ALLOCATABLE :: RECORDS(:)
  END TYPE HASHTABLE
  ! ---------------------------------------------------------------------------------------------------------------------------------+
  INTEGER(KIND=4)             :: HASHTABLE_COUNT, HASHTABLES_SIZE
  TYPE(HASHTABLE),ALLOCATABLE :: HASHTABLES(:)
  ! ---------------------------------------------------------------------------------------------------------------------------------+
  INTERFACE CALCULATE_HASH
    MODULE PROCEDURE CALCULATE_HASH_INT1
    MODULE PROCEDURE CALCULATE_HASH_INT2
    MODULE PROCEDURE CALCULATE_HASH_INT4
    MODULE PROCEDURE CALCULATE_HASH_INT8
    MODULE PROCEDURE CALCULATE_HASH_REAL4
    MODULE PROCEDURE CALCULATE_HASH_REAL8
    MODULE PROCEDURE CALCULATE_HASH_STRING
  END INTERFACE CALCULATE_HASH
  ! ---------------------------------------------------------------------------------------------------------------------------------+
  INTERFACE HASHTABLE_INSERT_AT
    MODULE PROCEDURE HASHTABLE_INSERT_INT1_AT
  ! MODULE PROCEDURE HASHTABLE_INSERT_INT2_AT
  ! MODULE PROCEDURE HASHTABLE_INSERT_INT4_AT
  ! MODULE PROCEDURE HASHTABLE_INSERT_INT8_AT
  ! MODULE PROCEDURE HASHTABLE_INSERT_REAL4_AT
  ! MODULE PROCEDURE HASHTABLE_INSERT_REAL8_AT
  ! MODULE PROCEDURE HASHTABLE_INSERT_STRING_AT
  END INTERFACE HASHTABLE_INSERT_AT
  ! ---------------------------------------------------------------------------------------------------------------------------------+
                                                             CONTAINS
  ! ---------------------------------------------------------------------------------------------------------------------------------+
  SUBROUTINE HASHTABLE_INSERT_INT1_AT(HTABLE,VALUE)
  TYPE(HASHTABLE),INTENT(INOUT) :: HTABLE
  INTEGER(KIND=1),INTENT(IN)    :: VALUE
  END SUBROUTINE HASHTABLE_INSERT_INT1_AT
  ! ---------------------------------------------------------------------------------------------------------------------------------+
  SUBROUTINE HASHTABLE_INIT(HTABLE, RECORDSIZE, TABLESIZE)
  TYPE(HASHTABLE),INTENT(INOUT) :: HTABLE
  INTEGER(KIND=4),INTENT(IN)    :: RECORDSIZE,TABLESIZE
    HTABLE%TABLE_SIZE   = TABLESIZE
    HTABLE%RECORD_SIZE  = RECORDSIZE
    HTABLE%RECORD_COUNT = 0
    IF (.NOT.ALLOCATED(HTABLE%INDICIES)) ALLOCATE(HTABLE%INDICIES(         3,TABLESIZE))
    IF (.NOT.ALLOCATED(HTABLE%RECORDS))  ALLOCATE( HTABLE%RECORDS(RECORDSIZE*TABLESIZE))
  END SUBROUTINE HASHTABLE_INIT
  ! ---------------------------------------------------------------------------------------------------------------------------------+
  INTEGER(KIND=4) FUNCTION CALCULATE_HASH_INT1(VALUE)
  INTEGER(KIND=1),INTENT(IN)   :: VALUE
  INTEGER(KIND=1),DIMENSION(4) :: VALUES
  INTEGER(KIND=4)              :: RVALUE = 0
  EQUIVALENCE(VALUES,RVALUE)
    VALUES(1) = VALUE
    CALCULATE_HASH_INT1 = RVALUE
  END FUNCTION CALCULATE_HASH_INT1
  ! ---------------------------------------------------------------------------------------------------------------------------------+
  INTEGER(KIND=4) FUNCTION CALCULATE_HASH_INT2(VALUE)
  INTEGER(KIND=2),INTENT(IN)   :: VALUE
  INTEGER(KIND=2),DIMENSION(2) :: VALUES
  INTEGER(KIND=4)              :: RVALUE = 0
  EQUIVALENCE(VALUES,RVALUE)
    VALUES(1) = VALUE
    CALCULATE_HASH_INT2 = RVALUE
  END FUNCTION CALCULATE_HASH_INT2
  ! ---------------------------------------------------------------------------------------------------------------------------------+
  INTEGER(KIND=4) FUNCTION CALCULATE_HASH_INT4(VALUE)
  INTEGER(KIND=4),INTENT(IN) :: VALUE
    CALCULATE_HASH_INT4 = VALUE
  END FUNCTION CALCULATE_HASH_INT4
  ! ---------------------------------------------------------------------------------------------------------------------------------+
  INTEGER(KIND=4) FUNCTION CALCULATE_HASH_INT8(VALUE)
  INTEGER(KIND=8),INTENT(IN)   :: VALUE
  INTEGER(KIND=4),DIMENSION(2) :: VALUES
  INTEGER(KIND=8)              :: SETVALUE
  EQUIVALENCE(VALUES,SETVALUE)
    SETVALUE = VALUE
    CALCULATE_HASH_INT8 = IEOR(VALUES(1),VALUES(2))
  END FUNCTION CALCULATE_HASH_INT8
  ! ---------------------------------------------------------------------------------------------------------------------------------+
  INTEGER(KIND=4) FUNCTION CALCULATE_HASH_REAL4(VALUE)
  REAL   (KIND=4),INTENT(IN)   :: VALUE
  INTEGER(KIND=4)              :: IVALUE
    IVALUE=TRANSFER(VALUE,IVALUE)
    CALCULATE_HASH_REAL4 = CALCULATE_HASH_INT4(IVALUE)
  END FUNCTION CALCULATE_HASH_REAL4
  ! ---------------------------------------------------------------------------------------------------------------------------------+
  INTEGER(KIND=4) FUNCTION CALCULATE_HASH_REAL8(VALUE)
  REAL   (KIND=8),INTENT(IN)   :: VALUE
  INTEGER(KIND=8)              :: IVALUE
    IVALUE=TRANSFER(VALUE,IVALUE)
    CALCULATE_HASH_REAL8 = CALCULATE_HASH_INT8(IVALUE)
  END FUNCTION CALCULATE_HASH_REAL8
  ! ---------------------------------------------------------------------------------------------------------------------------------+
  ! CALCULATE_HASH_STRING
  !
  ! This subroutine will loop through in 4-byte words calculating the hashcode and IEOR (XOR) it with a running hashcode. This is done
  ! ignoring leading and trailing space characters.
  
negative.code:   IF (IREM.GT.0) THEN
      CVALUE = VALUE(I:I+IREM-1)
      IVALUE = IEOR(IVALUE,JVALUE)
  !   WRITE(0,'(I4,X,A4,X,I16)') I,CVALUE,IVALUE
    END IF
    HASHCODE_STRING = IVALUE
  END FUNCTION HASHCODE_STRING
  !
  END MODULE MODHASHCODE
  ! ---------------------------------------------------------------------------------------------------------------------------------+
                                                       MODULE MODHASHTABLE
  ! ---------------------------------------------------------------------------------------------------------------------------------+
  PUBLIC :: HASHTABLE_INSERT_AT
  PUBLIC :: HASHTABLE
  PUBLIC :: HASHTABLE_INIT
  TYPE HASHTABLE
    INTEGER(KIND=4)             :: TABLESIZE
    INTEGER(KIND=4)             :: RECORDSIZE
    INTEGER(KIND=4)             :: RECORDCOUNT
    INTEGER(KIND=4),ALLOCATABLE :: INDICIES(:,:)
    INTEGER(KIND=1),ALLOCATABLE :: RECORDS(:)
  END TYPE HASHTABLE
  ! ---------------------------------------------------------------------------------------------------------------------------------+
  INTEGER(KIND=4)             :: HASHTABLE_COUNT, HASHTABLES_SIZE
  TYPE(HASHTABLE),ALLOCATABLE :: HASHTABLES(:)
  ! ---------------------------------------------------------------------------------------------------------------------------------+
  !INTERFACE HASHTABLE_INSERT_AT
  !  MODULE PROCEDURE HASHTABLE_INSERT_INT1_AT
  !  MODULE PROCEDURE HASHTABLE_INSERT_INT2_AT
  !  MODULE PROCEDURE HASHTABLE_INSERT_INT4_AT
  !  MODULE PROCEDURE HASHTABLE_INSERT_INT8_AT
  !  MODULE PROCEDURE HASHTABLE_INSERT_REAL4_AT
  !  MODULE PROCEDURE HASHTABLE_INSERT_REAL8_AT
  !  MODULE PROCEDURE HASHTABLE_INSERT_STRING_AT
  !END INTERFACE HASHTABLE_INSERT_AT
  ! ---------------------------------------------------------------------------------------------------------------------------------+
                                                             CONTAINS
  ! ---------------------------------------------------------------------------------------------------------------------------------+
  !SUBROUTINE HASHTABLE_INSERT_INT1_AT(HTABLE,VALUE)
  !TYPE(HASHTABLE),INTENT(INOUT) :: HTABLE
  !INTEGER(KIND=1),INTENT(IN)    :: VALUE
  !END SUBROUTINE HASHTABLE_INSERT_INT1_AT
  ! ---------------------------------------------------------------------------------------------------------------------------------+
  SUBROUTINE HASHTABLE_INIT(HTABLE, RECORDSIZE, TABLESIZE)
  TYPE(HASHTABLE),INTENT(INOUT) :: HTABLE
  INTEGER(KIND=4),INTENT(IN)    :: RECORDSIZE,TABLESIZE
  LOGICAL(KIND=1)               :: IA = .FALSE.   ! True if indicies are allocated
  LOGICAL(KIND=1)               :: RA = .FALSE.   ! True if records are allocated
    IA = ALLOCATED(HTABLE%INDICIES)
    RA = ALLOCATED(HTABLE%RECORDS)
    IF (.NOT.(IA.AND.RA)) THEN    ! Arrays are not allocated, so go ahead and allocate
      ALLOCATE(HTABLE%INDICIES(         3,TABLESIZE))
      ALLOCATE( HTABLE%RECORDS(RECORDSIZE*TABLESIZE))
    ELSE IF (IA.OR.RA) THEN       ! One array is allocated, and the other is not.  Something is wrong.
    ELSE                          ! Arrays are already allocated.
    END IF
  !  HTABLE%TABLESIZE   = TABLESIZE
  !  HTABLE%RECORDSIZE  = RECORDSIZE
  !  HTABLE%RECORDCOUNT = 0
  !  IF (.NOT.ALLOCATED(HTABLE%INDICIES)) ALLOCATE(HTABLE%INDICIES(         3,TABLESIZE))
  !  IF (.NOT.ALLOCATED(HTABLE%RECORDS))  ALLOCATE( HTABLE%RECORDS(RECORDSIZE*TABLESIZE))
  END SUBROUTINE HASHTABLE_INIT
  ! ---------------------------------------------------------------------------------------------------------------------------------+
  END MODULE MODHASHTABLE
  ! ---------------------------------------------------------------------------------------------------------------------------------+
  PROGRAM HASHTEST
  USE MODHASHCODE
  USE MODHASHTABLE
  IMPLICIT NONE
  INTEGER(KIND=1),PARAMETER :: IDIV = 11
  INTEGER(KIND=1)           :: INT1 = HUGE(INT1) / IDIV
  