Open
Description
For a 1D array of integer or character data, one often wants to summarize the frequency of observations. One could have a subroutine returning two allocatable arrays of equal size, one an array of distinct values and the other an integer array of counts, for example
subroutine frequencies(ivec,ival,icount)
integer, intent(in) :: ivec(:)
integer, intent(out), allocatable :: ival(:) ! unique values
integer, intent(out), allocatable :: icount(:) ! counts of unique values
end subroutine frequencies
For integer, character, and logical 1D arrays one could define a MODE function that returns the most common value. The mode of continuous data is often not meaningful, so I exclude REAL.