subroutine sort ( a, ii, jj ) c*********************************************************************72 c cc sort sorts an array into increasing order. c c sorts array a into increasing order, from a(ii) to a(jj). c ordering is by integer subtraction, thus floating point c numbers must be in normalized form. c arrays iu(k) and il(k) permit sorting up to 2**(k+1)-1 elements. c implicit none integer a(*) integer i integer ii integer ij integer il(16) integer iu(16) integer j integer jj integer k integer l integer m integer t integer tt m = 1 i = ii j = jj 5 if ( i .ge. j ) go to 70 10 k = i ij = ( j + i ) / 2 t = a(ij) if ( a(i) .le. t ) go to 20 a(ij) = a(i) a(i) = t t = a(ij) 20 l = j if ( a(j) .ge. t ) go to 40 a(ij) = a(j) a(j) = t t = a(ij) if ( a(i) .le. t ) go to 40 a(ij) = a(i) a(i) = t t = a(ij) go to 40 30 a(l) = a(k) a(k) = tt 40 l = l - 1 if ( a(l) .gt. t ) go to 40 tt = a(l) 50 k = k + 1 if ( a(k) .lt. t ) go to 50 if ( k .le. l ) go to 30 if ( l - i .le. j - k ) go to 60 il(m) = i iu(m) = l i = k m = m + 1 go to 80 60 il(m) = k iu(m) = j j = l m = m + 1 go to 80 70 m = m - 1 if ( m .eq. 0 ) return i = il(m) j = iu(m) 80 if ( j - i .ge. ii ) go to 10 if ( i .eq. ii ) go to 5 i = i - 1 90 i = i + 1 if ( i .eq. j ) go to 70 t = a(i+1) if ( a(i) .le. t ) go to 90 k = i 100 a(k+1) = a(k) k = k - 1 if ( t .lt. a(k) ) go to 100 a(k+1) = t go to 90 end