fnv1a_byte Subroutine

private pure subroutine fnv1a_byte(state, byte_value)

One FNV-1a round: exclusive-or in a byte, then multiply by the prime.

The multiply is done in int64 and reduced modulo 2**32 by masking, then folded back into the signed int32 range. Doing it directly in int32 would overflow, which Fortran leaves undefined and which some compilers trap on.

Arguments

Type IntentOptional Attributes Name
integer(kind=int32), intent(inout) :: state
integer(kind=int64), intent(in) :: byte_value

A single byte, 0 to 255.


Called by

proc~~fnv1a_byte~~CalledByGraph proc~fnv1a_byte fnv1a_byte proc~feed_integer feed_integer proc~feed_integer->proc~fnv1a_byte proc~feed_logical feed_logical proc~feed_logical->proc~feed_integer proc~feed_real_record feed_real_record proc~feed_real_record->proc~feed_integer proc~update_char_0 array_hash_t%update_char_0 proc~update_char_0->proc~feed_integer proc~update_int16_0 array_hash_t%update_int16_0 proc~update_int16_0->proc~feed_integer proc~update_int16_1 array_hash_t%update_int16_1 proc~update_int16_1->proc~feed_integer proc~update_int32_0 array_hash_t%update_int32_0 proc~update_int32_0->proc~feed_integer proc~update_int32_1 array_hash_t%update_int32_1 proc~update_int32_1->proc~feed_integer proc~update_int64_0 array_hash_t%update_int64_0 proc~update_int64_0->proc~feed_integer proc~update_int64_1 array_hash_t%update_int64_1 proc~update_int64_1->proc~feed_integer proc~update_int8_0 array_hash_t%update_int8_0 proc~update_int8_0->proc~feed_integer proc~update_int8_1 array_hash_t%update_int8_1 proc~update_int8_1->proc~feed_integer none~update array_hash_t%update none~update->proc~update_char_0 none~update->proc~update_int16_0 none~update->proc~update_int16_1 none~update->proc~update_int32_0 none~update->proc~update_int32_1 none~update->proc~update_int64_0 none~update->proc~update_int64_1 none~update->proc~update_int8_0 none~update->proc~update_int8_1 proc~update_logical_0 array_hash_t%update_logical_0 none~update->proc~update_logical_0 proc~update_logical_1 array_hash_t%update_logical_1 none~update->proc~update_logical_1 proc~update_cdp_0 array_hash_t%update_cdp_0 none~update->proc~update_cdp_0 proc~update_cdp_1 array_hash_t%update_cdp_1 none~update->proc~update_cdp_1 proc~update_cdp_2 array_hash_t%update_cdp_2 none~update->proc~update_cdp_2 proc~update_cdp_3 array_hash_t%update_cdp_3 none~update->proc~update_cdp_3 proc~update_char_1 array_hash_t%update_char_1 none~update->proc~update_char_1 proc~update_csp_0 array_hash_t%update_csp_0 none~update->proc~update_csp_0 proc~update_csp_1 array_hash_t%update_csp_1 none~update->proc~update_csp_1 proc~update_csp_2 array_hash_t%update_csp_2 none~update->proc~update_csp_2 proc~update_csp_3 array_hash_t%update_csp_3 none~update->proc~update_csp_3 proc~update_int16_2 array_hash_t%update_int16_2 none~update->proc~update_int16_2 proc~update_int16_3 array_hash_t%update_int16_3 none~update->proc~update_int16_3 proc~update_int32_2 array_hash_t%update_int32_2 none~update->proc~update_int32_2 proc~update_int32_3 array_hash_t%update_int32_3 none~update->proc~update_int32_3 proc~update_int64_2 array_hash_t%update_int64_2 none~update->proc~update_int64_2 proc~update_int64_3 array_hash_t%update_int64_3 none~update->proc~update_int64_3 proc~update_int8_2 array_hash_t%update_int8_2 none~update->proc~update_int8_2 proc~update_int8_3 array_hash_t%update_int8_3 none~update->proc~update_int8_3 proc~update_logical_2 array_hash_t%update_logical_2 none~update->proc~update_logical_2 proc~update_logical_3 array_hash_t%update_logical_3 none~update->proc~update_logical_3 proc~update_rdp_0 array_hash_t%update_rdp_0 none~update->proc~update_rdp_0 proc~update_rdp_1 array_hash_t%update_rdp_1 none~update->proc~update_rdp_1 proc~update_rdp_2 array_hash_t%update_rdp_2 none~update->proc~update_rdp_2 proc~update_rdp_3 array_hash_t%update_rdp_3 none~update->proc~update_rdp_3 proc~update_rsp_0 array_hash_t%update_rsp_0 none~update->proc~update_rsp_0 proc~update_rsp_1 array_hash_t%update_rsp_1 none~update->proc~update_rsp_1 proc~update_rsp_2 array_hash_t%update_rsp_2 none~update->proc~update_rsp_2 proc~update_rsp_3 array_hash_t%update_rsp_3 none~update->proc~update_rsp_3 proc~feed_real_dp feed_real_dp proc~feed_real_dp->proc~feed_real_record proc~feed_real_sp feed_real_sp proc~feed_real_sp->proc~feed_real_record proc~update_logical_0->proc~feed_logical proc~update_logical_1->proc~feed_logical proc~hash_cdp_1 hash_cdp_1 proc~hash_cdp_1->none~update proc~hash_cdp_2 hash_cdp_2 proc~hash_cdp_2->none~update proc~hash_cdp_3 hash_cdp_3 proc~hash_cdp_3->none~update proc~hash_char_0 hash_char_0 proc~hash_char_0->none~update proc~hash_char_1 hash_char_1 proc~hash_char_1->none~update proc~hash_csp_1 hash_csp_1 proc~hash_csp_1->none~update proc~hash_csp_2 hash_csp_2 proc~hash_csp_2->none~update proc~hash_csp_3 hash_csp_3 proc~hash_csp_3->none~update proc~hash_int16_1 hash_int16_1 proc~hash_int16_1->none~update proc~hash_int16_2 hash_int16_2 proc~hash_int16_2->none~update proc~hash_int16_3 hash_int16_3 proc~hash_int16_3->none~update proc~hash_int32_1 hash_int32_1 proc~hash_int32_1->none~update proc~hash_int32_2 hash_int32_2 proc~hash_int32_2->none~update proc~hash_int32_3 hash_int32_3 proc~hash_int32_3->none~update proc~hash_int64_1 hash_int64_1 proc~hash_int64_1->none~update proc~hash_int64_2 hash_int64_2 proc~hash_int64_2->none~update proc~hash_int64_3 hash_int64_3 proc~hash_int64_3->none~update proc~hash_int8_1 hash_int8_1 proc~hash_int8_1->none~update proc~hash_int8_2 hash_int8_2 proc~hash_int8_2->none~update proc~hash_int8_3 hash_int8_3 proc~hash_int8_3->none~update proc~hash_logical_1 hash_logical_1 proc~hash_logical_1->none~update proc~hash_logical_2 hash_logical_2 proc~hash_logical_2->none~update proc~hash_logical_3 hash_logical_3 proc~hash_logical_3->none~update proc~hash_rdp_1 hash_rdp_1 proc~hash_rdp_1->none~update proc~hash_rdp_2 hash_rdp_2 proc~hash_rdp_2->none~update proc~hash_rdp_3 hash_rdp_3 proc~hash_rdp_3->none~update proc~hash_rsp_1 hash_rsp_1 proc~hash_rsp_1->none~update proc~hash_rsp_2 hash_rsp_2 proc~hash_rsp_2->none~update proc~hash_rsp_3 hash_rsp_3 proc~hash_rsp_3->none~update proc~soa_hash_begin_32 soa_hash_begin_32 proc~soa_hash_begin_32->none~update proc~soa_hash_int32_field soa_hash_int32_field proc~soa_hash_int32_field->none~update proc~soa_hash_int64_field soa_hash_int64_field proc~soa_hash_int64_field->none~update proc~soa_hash_logical_field soa_hash_logical_field proc~soa_hash_logical_field->none~update proc~soa_hash_real_dp_field soa_hash_real_dp_field proc~soa_hash_real_dp_field->none~update proc~soa_hash_real_sp_field soa_hash_real_sp_field proc~soa_hash_real_sp_field->none~update proc~update_cdp_0->proc~feed_real_dp proc~update_cdp_1->proc~feed_real_dp proc~update_cdp_2->none~update proc~update_cdp_3->none~update proc~update_char_1->none~update proc~update_csp_0->proc~feed_real_sp proc~update_csp_1->proc~feed_real_sp proc~update_csp_2->none~update proc~update_csp_3->none~update proc~update_int16_2->none~update proc~update_int16_3->none~update proc~update_int32_2->none~update proc~update_int32_3->none~update proc~update_int64_2->none~update proc~update_int64_3->none~update proc~update_int8_2->none~update proc~update_int8_3->none~update proc~update_logical_2->none~update proc~update_logical_3->none~update proc~update_rdp_0->proc~feed_real_dp proc~update_rdp_1->proc~feed_real_dp proc~update_rdp_2->none~update proc~update_rdp_3->none~update proc~update_rsp_0->proc~feed_real_sp proc~update_rsp_1->proc~feed_real_sp proc~update_rsp_2->none~update proc~update_rsp_3->none~update interface~array_hash array_hash interface~array_hash->proc~hash_cdp_1 interface~array_hash->proc~hash_cdp_2 interface~array_hash->proc~hash_cdp_3 interface~array_hash->proc~hash_char_0 interface~array_hash->proc~hash_char_1 interface~array_hash->proc~hash_csp_1 interface~array_hash->proc~hash_csp_2 interface~array_hash->proc~hash_csp_3 interface~array_hash->proc~hash_int16_1 interface~array_hash->proc~hash_int16_2 interface~array_hash->proc~hash_int16_3 interface~array_hash->proc~hash_int32_1 interface~array_hash->proc~hash_int32_2 interface~array_hash->proc~hash_int32_3 interface~array_hash->proc~hash_int64_1 interface~array_hash->proc~hash_int64_2 interface~array_hash->proc~hash_int64_3 interface~array_hash->proc~hash_int8_1 interface~array_hash->proc~hash_int8_2 interface~array_hash->proc~hash_int8_3 interface~array_hash->proc~hash_logical_1 interface~array_hash->proc~hash_logical_2 interface~array_hash->proc~hash_logical_3 interface~array_hash->proc~hash_rdp_1 interface~array_hash->proc~hash_rdp_2 interface~array_hash->proc~hash_rdp_3 interface~array_hash->proc~hash_rsp_1 interface~array_hash->proc~hash_rsp_2 interface~array_hash->proc~hash_rsp_3 interface~soa_hash_begin soa_hash_begin interface~soa_hash_begin->proc~soa_hash_begin_32 interface~soa_hash_field soa_hash_field interface~soa_hash_field->proc~soa_hash_int32_field interface~soa_hash_field->proc~soa_hash_int64_field interface~soa_hash_field->proc~soa_hash_logical_field interface~soa_hash_field->proc~soa_hash_real_dp_field interface~soa_hash_field->proc~soa_hash_real_sp_field

Variables

Type Visibility Attributes Name Initial
integer(kind=int64), private :: acc

Source Code

   pure subroutine fnv1a_byte(state, byte_value)
      !! One FNV-1a round: exclusive-or in a byte, then multiply by the prime.
      !!
      !! The multiply is done in `int64` and reduced modulo 2**32 by masking,
      !! then folded back into the signed `int32` range. Doing it directly in
      !! `int32` would overflow, which Fortran leaves undefined and which some
      !! compilers trap on.
      integer(int32), intent(inout) :: state
      integer(int64), intent(in) :: byte_value
         !! A single byte, 0 to 255.

      integer(int64) :: acc

      acc = int(ieor(state, int(byte_value, int32)), int64)
      acc = iand(acc*FNV_PRIME, MASK_32)
      if (acc > INT32_MAX) acc = acc - TWO_POW_32
      state = int(acc, int32)
   end subroutine fnv1a_byte