program test
implicit None
integer(8) :: i,j,k
integer(8),allocatable :: array(:),rpt_time(:)
integer(8) :: length,max_len,mode
length = 9
allocate(array(length))
allocate(rpt_time(length))
array = (/100, 98, 87, 65, 82, 99, 92, 99, 100/)
!write(*,*) array
rpt_time = 0
max_len = 0
do i = 1, length
do j = i, length
if (array(i) == array(j)) then
rpt_time(i) = rpt_time(i) + 1
endif
enddo
!write(*,*) array(i),rpt_time(i)
if (i==1) then
max_len = rpt_time(i)
else
if (rpt_time(i) >= max_len) then
max_len = rpt_time(i)
endif
endif
enddo
do i = 1, length
if (max_len == rpt_time(i)) then
write(*,*) array(i),rpt_time(i)
endif
enddo
End program test
From J