bin_to_int4 Subroutine

public subroutine bin_to_int4(r, binstr)

String of binary number converted to integer of kind 4

Arguments

Type IntentOptional AttributesName
integer(kind=4), intent(out) :: r
character(len=*) :: binstr

Called by

proc~~bin_to_int4~~CalledByGraph proc~bin_to_int4 bin_to_int4 interface~bin2int bin2int interface~bin2int->proc~bin_to_int4 proc~int4_from_string int4_from_string proc~int4_from_string->interface~bin2int proc~int8_from_string int8_from_string proc~int8_from_string->interface~bin2int interface~assignment(=) assignment(=) interface~assignment(=)->proc~int4_from_string interface~assignment(=)->proc~int8_from_string

Contents

Source Code


Source Code

        subroutine bin_to_int4(r, binstr)
          !< String of binary number converted to integer of kind 4
            implicit none
            character(len=*) :: binstr
            integer(kind=4), intent(out) :: r
            integer :: current_digit
            integer :: i
            i = len(binstr)
            r = 0
            do while (i > 0)
                read (binstr(i:i), *) current_digit
                r = r + ((2 ** (len(binstr) - i)) * current_digit)
                i = i - 1
            end do
        end subroutine bin_to_int4