unique(3f) - [M_orderpack:UNIQUE] removes duplicates from an array otherwise retaining original order (i.e. it is "stable")
Synopsis
Description
Options
Examples
Author
Maintainer
License
Subroutine Unique (INOUTVALS, NUNI)
${TYPE} (kind=${KIND}), Intent (InOut) :: INOUTVALS(:) Integer, Intent (Out) :: NUNIWhere ${TYPE}(kind=${KIND}) may be
o Real(kind=real32) o Real(kind=real64) o Integer(kind=int8) o Integer(kind=int16) o Integer(kind=int32) o Integer(kind=int64) o Character(kind=selected_char_kind("DEFAULT"),len=*)
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.
INOUTVALS input array to reduce to unique values NUNI number of values comprising the returned set of unique values
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 :: nuniResults: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
ORIGINAL:, 44, 33, 33, 33, 22, 11, 33, 44, 55, 33 UNIQUE:, 44, 33, 22, 11, 55
Michel Olagnon - Feb. 2000
John Urban, 2022.04.16
CC0-1.0
Nemo Release 3.1 | unique (3) | February 23, 2025 |