diff options
Diffstat (limited to 'map65/libm65/chkhist.f90')
| -rw-r--r-- | map65/libm65/chkhist.f90 | 54 |
1 files changed, 40 insertions, 14 deletions
diff --git a/map65/libm65/chkhist.f90 b/map65/libm65/chkhist.f90 index c814c3ca..51d1ee72 100644 --- a/map65/libm65/chkhist.f90 +++ b/map65/libm65/chkhist.f90 @@ -1,23 +1,49 @@ -subroutine chkhist(mrsym,nmax,ipk) +module chkhist_mod + implicit none +contains - integer mrsym(63) - integer hist(0:63) +subroutine chkhist(mrsym, nmax, ipk) + implicit none - do i=0,63 - hist(i)=0 + !-------------------------------------------------------------------- + ! Arguments + !-------------------------------------------------------------------- + integer, intent(in) :: mrsym(63) + integer, intent(out) :: nmax + integer, intent(out) :: ipk + + !-------------------------------------------------------------------- + ! Locals + !-------------------------------------------------------------------- + integer :: hist(0:63) + integer :: i, j + + !-------------------------------------------------------------------- + ! Initialize histogram + !-------------------------------------------------------------------- + do i = 0, 63 + hist(i) = 0 enddo - do j=1,63 - i=mrsym(j) - hist(i)=hist(i)+1 + + !-------------------------------------------------------------------- + ! Count occurrences + !-------------------------------------------------------------------- + do j = 1, 63 + i = mrsym(j) + hist(i) = hist(i) + 1 enddo - nmax=0 - do i=0,63 - if(hist(i).gt.nmax) then - nmax=hist(i) - ipk=i+1 + !-------------------------------------------------------------------- + ! Find maximum bin and its index + !-------------------------------------------------------------------- + nmax = 0 + do i = 0, 63 + if (hist(i) > nmax) then + nmax = hist(i) + ipk = i + 1 endif enddo - return end subroutine chkhist + +end module chkhist_mod |
