C Library Functions  - unique (3)

NAME

unique(3f) - [M_orderpack:UNIQUE] removes duplicates from an array otherwise retaining original order (i.e. it is "stable")

CONTENTS

Synopsis
Description
Options
Examples
Author
Maintainer
License

SYNOPSIS

Subroutine Unique (INOUTVALS, NUNI)

     ${TYPE} (kind=${KIND}), Intent (InOut) :: INOUTVALS(:)
     Integer, Intent (Out)                  :: NUNI

Where ${TYPE}(kind=${KIND}) may be
o Real(kind=real32)
o Real(kind=real64)
o Integer(kind=int32)
o Character(kind=selected_char_kind("DEFAULT"),len=*)

DESCRIPTION

UNIQUE(3f) does a stable removal of duplicates from an array.

It leaves in the initial set only those entries that are unique, packing the array, and leaving the order of the retained values unchanged.

Internally this subroutine uses Merge-sort unique inverse ranking.

OPTIONS

INOUTVALS
  input array to reduce to unique values
NUNI number of values comprising the returned set of unique values

EXAMPLES

Sample program:

   program demo_unique
   ! remove duplicates with remaining elements remaining in initial order
   use M_orderpack, only : unique
   implicit none
   character(len=*),parameter :: list= ’(*(g0:,", "))’
   integer :: nuni

int : block integer,allocatable :: INOUTVALS(:) INOUTVALS=[44,33,33,33,22,11,33,44,55,33] print list,’ORIGINAL:’,INOUTVALS call unique(INOUTVALS,nuni) INOUTVALS=INOUTVALS(:nuni) print list,’UNIQUE:’,INOUTVALS endblock int

end program demo_unique

Results:

   ORIGINAL:, 44, 33, 33, 33, 22, 11, 33, 44, 55, 33
   UNIQUE:, 44, 33, 22, 11, 55

AUTHOR

Michel Olagnon - Feb. 2000

MAINTAINER

John Urban, 2022.04.16

LICENSE

CC0-1.0


Nemo Release 3.1 unique (3) July 22, 2023
Generated by manServer 1.08 from 250334f9-449f-4616-94e8-91549fc265d8 using man macros.