n_unique_values Function

function n_unique_values(var) result(n)

Uses

  • proc~~n_unique_values~~UsesGraph proc~n_unique_values n_unique_values iso_c_binding iso_c_binding proc~n_unique_values->iso_c_binding

Helper function that finds the number of unique values in a 1d integer array.

This function does not seem to be used, so can probably safely be removed.

Arguments

Type IntentOptional AttributesName
integer(kind=c_int), intent(in), dimension(:):: var

An 1d integer arrays.

Return Value integer(kind=ip)

The return value is the number of unique values in the input array.


Called by

proc~~n_unique_values~~CalledByGraph proc~n_unique_values n_unique_values proc~sf_init sf_init proc~sf_init->proc~n_unique_values interface~sf_init sf_init interface~sf_init->proc~sf_init

Contents

Source Code


Source Code

  function n_unique_values ( var ) result(n)
  !! Helper function that finds the number of unique values in a 1d integer
  !! array.
  !!
  !! This function does not seem to be used, so can probably safely be
  !! removed.

    use iso_c_binding

    integer(c_int), dimension(:), intent(in) :: var
    !! An 1d integer arrays.
    integer(ip) :: n
    !! The return value is the number of unique values in the input array.
    integer(c_int), dimension(size(var)) :: tmp
    integer(ip) :: i

    tmp(1) = var(1)
    n = 1

    do i=2, size(var)
      if ( .not. any ( tmp(1:n) == var(i) ) ) then
        n = n+1
        tmp(n) = var(i)
      end if
    end do
   
  end function n_unique_values