[UP]


Manual Reference Pages  - unique (3)

NAME

unique(3f) - [M_sort] assuming an array is sorted, return array with duplicate values removed

CONTENTS

Synopsis
Description
Options
Example

SYNOPSIS

subroutine unique(array,ivals)

    class(*),intent(inout)  :: array(:)
    integer,intent(out)     :: ivals

DESCRIPTION

Assuming an array is sorted, return the array with duplicate values removed.

OPTIONS

array may be of type INTEGER, REAL, CHARACTER, COMPLEX, DOUBLEPRECISION, or complex doubleprecision (that is, complex(kind=kind(0.0d0)) ).
ivals number of unique values packed into beginning of array

EXAMPLE

Sample program

    program demo_unique
    use M_sort, only : unique
    implicit none
    character(len=:),allocatable :: strings(:)
    integer                      :: icount

strings=[character(len=2) :: ’1’,’1’,’2’,’3’,’4’,’4’,’10’,’20’,’20’,’30’] write(*,’(a,*(a3,1x))’)’ORIGINAL:’,strings write(*,’("SIZE=",i0)’)size(strings)

call unique(strings,icount)

write(*,*) write(*,’(a,*(a3,1x))’)’AFTER :’,strings(1:icount)(:2) write(*,’("SIZE=",i0)’)size(strings) write(*,’("ICOUNT=",i0)’)icount

end program demo_unique

Expected output

    ORIGINAL: 1   1   2   3   4   4   10  20  20  30
    SIZE=10

AFTER : 1 2 3 4 10 20 30 SIZE=10 ICOUNT=7


unique (3) October 17, 2020
Generated by manServer 1.08 from a24e6d3a-0328-4546-87c4-938c688293ed using man macros.