SUBROUTINE SORTIT( X, Y, N, M ) C C This subroutine performs a "bubble" sort of the X and the C Y values such that the X values are in non-decreasing order C with index. C C X Independent array, dimensioned N. C Y Dependent array, dimensioned N by M. C N Number of values in the X array. C M Number of dependent values associated with C each independent array value. C DIMENSION X(N), Y(N,M) LOGICAL SORTED C C - INITIALIZE FOR THE SORT. I = 1 NSORT = N SORTED = .TRUE. C C - SWITCH VALUES? 100 IF( X(I+1) .GE. X(I) ) GO TO 200 C C - SWITCH X VALUES. XT = X(I) X(I) = X(I+1) X(I+1) = XT C C - SWITCH Y VALUES. DO 1000 J=1,M YT = Y(I,J) Y(I,J) = Y(I+1,J) 1000 Y(I+1,J) = YT C C - REMEMBER THAT VALUES HAVE BEEN SWITCHED, SORT NOT YET DONE. LAST = I SORTED = .FALSE. C C - CONTINUE UNTIL SORTED. 200 I = I + 1 IF( I .LT. NSORT ) GO TO 100 IF( SORTED ) RETURN I = 1 NSORT = LAST SORTED = .TRUE. GO TO 100 END