is_sorted_integer_int64 Function

private pure function is_sorted_integer_int64(V, ascending) result(res)

Arguments

Type IntentOptional Attributes Name
integer(kind=int64), intent(in) :: V(:)
logical, intent(in), optional :: ascending

Return Value logical


Contents


Source Code

    pure function is_sorted_integer_int64 (V, ascending) result(res)
        integer (int64), intent(in) :: V(:)
        logical, intent(in), optional :: ascending
        logical :: ascending_
        logical :: res

        integer :: i

if(present(ascending)) then
    ascending_ = ascending
else
    ascending_ = .true.
endif

        res = .true.
        if (ascending_) then
            do i = 1, size(V) - 1
                if (V(i) > V(i + 1)) then
                    res = .false.
                    return
                end if
            end do
        else
            do i = 1, size(V) - 1
                if (V(i) < V(i + 1)) then
                    res = .false.
                    return
                end if
            end do
        end if
    end function is_sorted_integer_int64