sort_unique Function

public function sort_unique(list) result(output)

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: list(:)

Return Value integer, allocatable, (:)


Contents

Source Code


Source Code

    function sort_unique(list) result(output)
        integer, intent(in) :: list(:)
        integer, allocatable :: output(:)

        integer :: i, min_val, max_val, unique(size(list))

        unique = 0
        i = 0
        min_val = minval(list) - 1
        max_val = maxval(list)

        do while (min_val < max_val)
            i = i + 1
            min_val = minval(list, mask=list > min_val)
            unique(i) = min_val
        end do
        allocate(output(i), source=unique(1:i))

    end function sort_unique