diff --git a/src/framework/MOM_checksums.F90 b/src/framework/MOM_checksums.F90 index 0f2db2c955..ad269f3530 100644 --- a/src/framework/MOM_checksums.F90 +++ b/src/framework/MOM_checksums.F90 @@ -1852,20 +1852,12 @@ end subroutine chksum_error !> Does a bitcount of a number by first casting to an integer and then using BTEST !! to check bit by bit integer function bitcount(x) - real :: x !< Number to be bitcount + real, intent(in) :: x !< Number to be bitcount - ! Local variables - integer(kind(x)) :: y !< Store the integer representation of the memory used by x - integer :: bit - - bitcount = 0 - y = transfer(x,y) - - ! Fortran standard says that bit indexing start at 0 - do bit = 0, bit_size(y)-1 - if (BTEST(y,bit)) bitcount = bitcount+1 - enddo + integer, parameter :: xk = kind(x) !< Kind type of x + ! NOTE: Assumes that reals and integers of kind=xk are the same size + bitcount = popcnt(transfer(x, 1_xk)) end function bitcount end module MOM_checksums