NAME
occurrences(3f) - [M_orderpack:MULTIPLICITY] Give the multiplicity for each
array value (number of times that it appears in the array)
SYNOPSIS
Subroutine Occurrences (INVALS, IMULT)
${TYPE} (kind=${KIND}), Intent (In) :: INVALS(:)
Integer, Intent (Out) :: IMULT(:)
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
OCCURRENCES(3f) Gives, for each array element, its multiplicity
(number of times that it appears in the array).
Internally, the number of times that a value appears in the array is
computed by using inverse ranking, counting for each rank the number
of values that "collide" to this rank, and returning this sum to
the locations in the original set. It uses subroutine RANK_ORDERS(3f).
OPTIONS
INVALS input array
IMULT array containing how often the value in INVALS
appears in INVALS
EXAMPLES
Sample program:
program demo_occurrences
use M_orderpack, only : occurrences
! determine how many times each value appears in an input array
implicit none
character(len=*),parameter :: g='(*(g0,1x))'
character(len=20),allocatable :: strings(:)
integer,allocatable :: cindx(:)
integer :: csz
integer :: i
! each name appears the number of times its name represents
strings= [ character(len=20) :: &
& 'two ', 'four ', 'three', 'five', 'five', &
& 'two ', 'four ', 'three', 'five', 'five', &
& 'four ', 'four ', 'three', 'one ', 'five']
csz=size(strings)
if(allocated(cindx))deallocate(cindx)
allocate(cindx(csz))
call occurrences(strings,cindx)
write(*,g)(trim(strings(i)),i=1,csz)
write(*,g)cindx
end program demo_occurrences
Results:
two four three five five two four three five five four four three one five
2 4 3 5 5 2 4 3 5 5 4 4 3 1 5
AUTHOR
MAINTAINER
LICENSE