17#ifdef ADLER32_CHECKSUM
45#if defined DISTRIBUTE && (defined JEDI || defined PIO_LIB)
55#ifdef ADLER32_CHECKSUM
65 integer(i8b) :: crc32_table(0:255)
77 logical,
intent(in),
optional :: lreduce
79 integer,
intent(in) :: asize
80 integer(i8b),
intent(out) :: hash
82 real(
r8),
intent(in) :: a(:)
86 logical,
save :: first = .true.
95#ifdef ADLER32_CHECKSUM
97 CALL adler32 (a, asize, hash)
100 CALL bitsum (a, asize, hash, lreduce)
107 CALL crc32 (a, asize, hash)
114 10
FORMAT (/,
' GET_HASH - Illegal checksum method: ',a)
119#ifdef ADLER32_CHECKSUM
122 SUBROUTINE adler32 (A, Asize, hash)
132 integer,
intent(in) :: asize
136 real(
r8),
intent(in) :: a(:)
140 integer :: alpha, beta, i, j
142 integer(i8b),
parameter :: mod_adler = 65521_i8b
144 integer(i8b),
allocatable :: awrk(:)
156 awrk=transfer(a(i), [0])
158 alpha=mod(alpha+awrk(j), mod_adler)
159 beta=mod(beta+alpha, mod_adler)
162 hash=ior(beta*65536_i8b, alpha)
165 END SUBROUTINE adler32
169 SUBROUTINE bitsum (A, Asize, hash, Lreduce)
187 logical,
intent(in),
optional :: lreduce
189 integer,
intent(in) :: asize
193 real(
r8),
intent(in) :: a(:)
197 integer,
parameter :: ak = kind(a)
200 integer(i8b) :: ac, asum
201#if defined DISTRIBUTE && (defined JEDI || defined PIO_LIB)
202 integer(i8b) :: ibuffer(1)
204 character (len=3) :: op_handle(1)
227 ac=popcnt(transfer(abs(a(i)), 1_ak))
232#if defined DISTRIBUTE && (defined JEDI || defined PIO_LIB)
241 IF (
PRESENT(lreduce))
THEN
245 CALL mp_reduce (1, 1, 1, ibuffer, op_handle)
257 SUBROUTINE crc32 (A, Asize, hash)
267 integer,
intent(in) :: asize
268 integer(i8b),
intent(inout) :: hash
270 real(
r8),
intent(in) :: a(:)
283 ai=transfer(a(i), 1_i8b)
284 hash=ieor(shiftr(hash, 8_i8b), &
285 & crc32_table(iand(ieor(hash, ai), 255_i8b)))
308 IF (btest(k, 0))
THEN
309 k=ieor(shiftr(k, 1), -306674912_i8b)
318 END SUBROUTINE crc32_ini
subroutine, private bitsum(a, asize, hash, lreduce)
subroutine, public get_hash(a, asize, hash, lreduce)
character(len= *), parameter hashmethod
character(len(sinp)) function, public uppercase(sinp)