subroutine sort (irpa, ndif) c c----------------------------------------------------------------------- c c Routine puts the ndif values in irpa(ndif) into ascending c (positive) order c c----------------------------------------------------------------------- c integer*4 irpa(ndif), ndif c c----------------------------------------------------------------------- c----------------------------------------------------------------------- c if (ndif .le. 1) return c c----------------------------------------------------------------------- c *** perform a bubble sort, ic flags *** c *** whether a swap has been made or not *** c----------------------------------------------------------------------- c do ik = 1, ndif ic = 0 c c----------------------------------------------------------------------- c *** scan though all the values, compare adjacent ones *** c----------------------------------------------------------------------- c do i = 2, ndif if (irpa(i-1) .gt. irpa(i)) then c c----------------------------------------------------------------------- c *** first one large, so swap *** c----------------------------------------------------------------------- c ic = 1 itemp = irpa(i) irpa(i) = irpa(i-1) irpa(i-1) = itemp end if end do c c----------------------------------------------------------------------- c *** if no swaps made, we can return prematurely *** c----------------------------------------------------------------------- c if (ic .eq. 0) return end do c c----------------------------------------------------------------------- c----------------------------------------------------------------------- c return end