This is a Fortran port of the Murmur3 hash function, based on the C port by Peter Scott.
Compile m_murmur3.f90
and include it with use m_murmur3
. Two hash functions are included:
# 32 bit hash, low throughput, low latency (good for short small keys)
MurmurHash3_x86_32 (key, klen, seed, hash)
# 128 bit hash, 250% higher throughput, similar latency (good for long keys)
MurmurHash3_x64_128(key, klen, seed, hash)
The arguments are:
key
: string you wish to hash. A generic interface is provided, so that you can give either a string (character(len=klen) :: key
) or a character array (character :: key(klen)
)klen
: the length of the stringseed
: seed for the hashhash
: resulting hash
MurmurHash3_x86_128
has been omitted, since it is only useful on older x86 hardware.
- ffhash Fast Fortran Hash table
- Hash tables on Fortran Wiki
All this code is in the public domain. Murmur3 was created by Austin Appleby, and the C port and general tidying up (that this code is based on) was done by Peter Scott.