* * $Id: sorttf.F,v 1.2 2001/10/08 14:03:14 mclareni Exp $ * * $Log: sorttf.F,v $ * Revision 1.2 2001/10/08 14:03:14 mclareni * Version 7.58 from author * * #include "sys/CERNLIB_machine.h" #include "pilot.h" #if defined(CERNLIB_NOCERN) SUBROUTINE SORTTF(A,INDEX,N1) C======================================================================= C Given real array and corresponding index INDEX, find new C INDEX for which A is sorted into ascending order. C C From CERN PROGLIB# M101 C======================================================================= DIMENSION A(N1),INDEX(N1) C N = N1 DO 3 I1=2,N I3 = I1 I33 = INDEX(I3) AI = A(I33) 1 I2 = I3/2 IF (I2) 3,3,2 2 I22 = INDEX(I2) IF (AI.LE.A (I22)) GO TO 3 INDEX (I3) = I22 I3 = I2 GO TO 1 3 INDEX (I3) = I33 4 I3 = INDEX (N) INDEX (N) = INDEX (1) AI = A(I3) N = N-1 IF (N-1) 12,12,5 5 I1 = 1 6 I2 = I1 + I1 IF (I2.LE.N) I22= INDEX(I2) IF (I2-N) 7,9,11 7 I222 = INDEX (I2+1) IF (A(I22)-A(I222)) 8,9,9 8 I2 = I2+1 I22 = I222 9 IF (AI-A(I22)) 10,11,11 10 INDEX(I1) = I22 I1 = I2 GO TO 6 11 INDEX (I1) = I3 GO TO 4 12 INDEX (1) = I3 RETURN END #endif