



      SUBROUTINE GVSCRT (A,LENGTH,N,ITAG)


























      IMPLICIT      NONE
      CHARACTER*80  T, TT
      INTEGER       N, IU(32), IL(32), ITAG(N), M, I, J, K, IJ, JTG,
     +              LENGTH, L
      CHARACTER*(*) A(N)





      TT=' '
      M=1
      I=1
      J=N
    5 CONTINUE
      IF (I .GE. J) GO TO 70
   10 CONTINUE
      K=I
      IJ=(J+I)/2
      T(1:LENGTH)=A(IJ)
      IF (A(I) .LE. T(1:LENGTH)) GO TO 20
      A(IJ)=A(I)
      A(I)=T(1:LENGTH)
      T(1:LENGTH)=A(IJ)
      JTG=ITAG(IJ)
      ITAG(IJ)=ITAG(I)
      ITAG(I)=JTG
   20 CONTINUE
      L=J
      IF (A(J) .GE. T(1:LENGTH)) GO TO 40
      A(IJ)=A(J)
      A(J)=T(1:LENGTH)
      T(1:LENGTH)=A(IJ)
      JTG=ITAG(IJ)
      ITAG(IJ)=ITAG(J)
      ITAG(J)=JTG
      IF (A(I) .LE. T(1:LENGTH)) GO TO 40
      A(IJ)=A(I)
      A(I)=T(1:LENGTH)
      T(1:LENGTH)=A(IJ)
      JTG=ITAG(IJ)
      ITAG(IJ)=ITAG(I)
      ITAG(I)=JTG
      GO TO 40
   30 CONTINUE
      A(L)=A(K)
      A(K)=TT(1:LENGTH)
      JTG=ITAG(L)
      ITAG(L)=ITAG(K)
      ITAG(K)=JTG
   40 CONTINUE
      L=L-1
      IF (A(L) .GT. T(1:LENGTH)) GO TO 40
      TT(1:LENGTH)=A(L)
   50 CONTINUE
      K=K+1
      IF (A(K) .LT. T(1:LENGTH)) 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 CONTINUE
      IL(M)=K
      IU(M)=J
      J=L
      M=M+1
      GO TO 80
   70 CONTINUE
      M=M-1
      IF (M.EQ.0) GOTO 998
      I=IL(M)
      J=IU(M)
80    CONTINUE
      IF (J-I.GE.1) GOTO 10
      IF (I.EQ.1) GOTO 5
      I=I-1
   90 CONTINUE
      I=I+1
      IF (I .EQ. J) GO TO 70
      T(1:LENGTH)=A(I+1)
      IF (A(I) .LE. T(1:LENGTH)) GO TO 90
      JTG=ITAG(I+1)
      K=I
  100 CONTINUE
      A(K+1)=A(K)
      ITAG(K+1)=ITAG(K)
      K=K-1
      IF (T(1:LENGTH) .LT. A(K)) GO TO 100
      A(K+1)=T(1:LENGTH)
      ITAG(K+1)=JTG
      GO TO 90



  998 CONTINUE


      RETURN
      END
      SUBROUTINE GVSDIS (A,N,ITAG)























      IMPLICIT      NONE
      INTEGER       N, IU(32), IL(32), ITAG(N), M, I, J, K, IJ, JTG,
     +              L, A(N), T, TT





      TT=0
      M=1
      I=1
      J=N
    5 CONTINUE
      IF (I.GE.J) GOTO 70
   10 CONTINUE
      K=I
      IJ=(J+I)/2
      T=A(IJ)
      IF (A(I).GE.T) GOTO 20
         A(IJ)=A(I)
         A(I)=T
         T=A(IJ)
         JTG=ITAG(IJ)
         ITAG(IJ)=ITAG(I)
         ITAG(I)=JTG
   20 CONTINUE
      L=J
      IF (A(J).LE.T) GOTO 40
         A(IJ)=A(J)
         A(J)=T
         T=A(IJ)
         JTG=ITAG(IJ)
         ITAG(IJ)=ITAG(J)
         ITAG(J)=JTG
      IF (A(I) .GE. T) GO TO 40
         A(IJ)=A(I)
         A(I)=T
         T=A(IJ)
         JTG=ITAG(IJ)
         ITAG(IJ)=ITAG(I)
         ITAG(I)=JTG
      GO TO 40
   30 CONTINUE
      A(L)=A(K)
      A(K)=TT
      JTG=ITAG(L)
      ITAG(L)=ITAG(K)
      ITAG(K)=JTG
   40 CONTINUE
      L=L-1
      IF (A(L) .LT. T) GO TO 40
      TT=A(L)
   50 CONTINUE
      K=K+1
      IF (A(K) .GT. 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 CONTINUE
      IL(M)=K
      IU(M)=J
      J=L
      M=M+1
      GO TO 80
   70 CONTINUE
      M=M-1
      IF (M.EQ.0) GOTO 998
      I=IL(M)
      J=IU(M)
   80 CONTINUE
      IF (J-I.GE.1) GOTO 10
      IF (I.EQ.1) GOTO 5
      I=I-1
   90 CONTINUE
      I=I+1
      IF (I .EQ. J) GO TO 70
      T=A(I+1)
      IF (A(I) .GE. T) GO TO 90
      JTG=ITAG(I+1)
      K=I
  100 CONTINUE
      A(K+1)=A(K)
      ITAG(K+1)=ITAG(K)
      K=K-1
      IF (T .GT. A(K)) GO TO 100
      A(K+1)=T
      ITAG(K+1)=JTG
      GO TO 90



  998 CONTINUE


      RETURN
      END
      SUBROUTINE GVSDRT (A,N,ITAG)























      IMPLICIT      NONE
      INTEGER       N, IU(32), IL(32), ITAG(N), M, I, J, K, IJ, JTG, L
      REAL          A(N), T, TT





      TT=0.0
      M=1
      I=1
      J=N
    5 CONTINUE
      IF (I .GE. J) GO TO 70
   10 CONTINUE
      K=I
      IJ=(J+I)/2
      T=A(IJ)
      IF (A(I) .GE. T) GO TO 20
         A(IJ)=A(I)
         A(I)=T
         T=A(IJ)
         JTG=ITAG(IJ)
         ITAG(IJ)=ITAG(I)
         ITAG(I)=JTG
   20 CONTINUE
      L=J
      IF (A(J) .LE. T) GO TO 40
         A(IJ)=A(J)
         A(J)=T
         T=A(IJ)
         JTG=ITAG(IJ)
         ITAG(IJ)=ITAG(J)
         ITAG(J)=JTG
      IF (A(I) .GE. T) GO TO 40
         A(IJ)=A(I)
         A(I)=T
         T=A(IJ)
         JTG=ITAG(IJ)
         ITAG(IJ)=ITAG(I)
         ITAG(I)=JTG
      GO TO 40
   30 CONTINUE
      A(L)=A(K)
      A(K)=TT
      JTG=ITAG(L)
      ITAG(L)=ITAG(K)
      ITAG(K)=JTG
   40 CONTINUE
      L=L-1
      IF (A(L) .LT. T) GO TO 40
      TT=A(L)
   50 CONTINUE
      K=K+1
      IF (A(K) .GT. 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 CONTINUE
      IL(M)=K
      IU(M)=J
      J=L
      M=M+1
      GO TO 80
   70 CONTINUE
      M=M-1
      IF (M.EQ.0) GOTO 998
      I=IL(M)
      J=IU(M)
   80 CONTINUE
      IF (J-I.GE.1) GOTO 10
      IF (I.EQ.1) GOTO 5
      I=I-1
   90 CONTINUE
      I=I+1
      IF (I .EQ. J) GO TO 70
      T=A(I+1)
      IF (A(I) .GE. T) GO TO 90
      JTG=ITAG(I+1)
      K=I
  100 CONTINUE
      A(K+1)=A(K)
      ITAG(K+1)=ITAG(K)
      K=K-1
      IF (T .GT. A(K)) GO TO 100
      A(K+1)=T
      ITAG(K+1)=JTG
      GO TO 90



  998 CONTINUE


      RETURN
      END
      SUBROUTINE GVSDT1 (A,N)
















      IMPLICIT      NONE
      INTEGER       IU(32), IL(32), M, I, J, K, IJ, N, L
      REAL          A(N), T, TT





      TT=0.0
      M=1
      I=1
      J=N
    5 CONTINUE
      IF (I .GE. J) GO TO 70
   10 CONTINUE
      K=I
      IJ=(J+I)/2
      T=A(IJ)
      IF (A(I) .GE. T) GO TO 20
         A(IJ)=A(I)
         A(I)=T
         T=A(IJ)
   20 CONTINUE
      L=J
      IF (A(J) .LE. T) GO TO 40
         A(IJ)=A(J)
         A(J)=T
         T=A(IJ)
      IF (A(I) .GE. T) GO TO 40
         A(IJ)=A(I)
         A(I)=T
         T=A(IJ)
      GO TO 40
   30 CONTINUE
      A(L)=A(K)
      A(K)=TT
   40 CONTINUE
      L=L-1
      IF (A(L) .LT. T) GO TO 40
      TT=A(L)
   50 CONTINUE
      K=K+1
      IF (A(K) .GT. 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 CONTINUE
      IL(M)=K
      IU(M)=J
      J=L
      M=M+1
      GO TO 80
   70 CONTINUE
      M=M-1
      IF (M.EQ.0) GOTO 998
      I=IL(M)
      J=IU(M)
   80 CONTINUE
      IF (J-I.GE.1) GOTO 10
      IF (I.EQ.1) GOTO 5
      I=I-1
   90 CONTINUE
      I=I+1
      IF (I .EQ. J) GO TO 70
      T=A(I+1)
      IF (A(I) .GE. T) GO TO 90
      K=I
  100 CONTINUE
      A(K+1)=A(K)
      K=K-1
      IF (T .GT. A(K)) GO TO 100
      A(K+1)=T
      GO TO 90



  998 CONTINUE


      RETURN
      END
      SUBROUTINE GVSDT2 (A,N)
















      IMPLICIT      NONE
      INTEGER       IU(32), IL(32), M, I, J, K, IJ, N, L
      INTEGER       A(N), T, TT





      TT=0
      M=1
      I=1
      J=N
    5 CONTINUE
      IF (I .GE. J) GO TO 70
   10 CONTINUE
      K=I
      IJ=(J+I)/2
      T=A(IJ)
      IF (A(I) .GE. T) GO TO 20
         A(IJ)=A(I)
         A(I)=T
         T=A(IJ)
   20 CONTINUE
      L=J
      IF (A(J) .LE. T) GO TO 40
         A(IJ)=A(J)
         A(J)=T
         T=A(IJ)
      IF (A(I) .GE. T) GO TO 40
         A(IJ)=A(I)
         A(I)=T
         T=A(IJ)
      GO TO 40
   30 CONTINUE
      A(L)=A(K)
      A(K)=TT
   40 CONTINUE
      L=L-1
      IF (A(L) .LT. T) GO TO 40
      TT=A(L)
   50 CONTINUE
      K=K+1
      IF (A(K) .GT. 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 CONTINUE
      IL(M)=K
      IU(M)=J
      J=L
      M=M+1
      GO TO 80
   70 CONTINUE
      M=M-1
      IF (M.EQ.0) GOTO 998
      I=IL(M)
      J=IU(M)
   80 CONTINUE
      IF (J-I.GE.1) GOTO 10
      IF (I.EQ.1) GOTO 5
      I=I-1
   90 CONTINUE
      I=I+1
      IF (I .EQ. J) GO TO 70
      T=A(I+1)
      IF (A(I) .GE. T) GO TO 90
      K=I
  100 CONTINUE
      A(K+1)=A(K)
      K=K-1
      IF (T .GT. A(K)) GO TO 100
      A(K+1)=T
      GO TO 90



  998 CONTINUE


      RETURN
      END
      SUBROUTINE GVSDT3 (A,T,TT,N)
















      IMPLICIT      NONE
      INTEGER       IU(32), IL(32), M, I, J, K, IJ, N, L
      CHARACTER*(*) A(N), T, TT





      TT=' '
      M=1
      I=1
      J=N
    5 CONTINUE
      IF (I .GE. J) GO TO 70
   10 CONTINUE
      K=I
      IJ=(J+I)/2
      T=A(IJ)
      IF (A(I) .GE. T) GO TO 20
         A(IJ)=A(I)
         A(I)=T
         T=A(IJ)
   20 CONTINUE
      L=J
      IF (A(J) .LE. T) GO TO 40
         A(IJ)=A(J)
         A(J)=T
         T=A(IJ)
      IF (A(I) .GE. T) GO TO 40
         A(IJ)=A(I)
         A(I)=T
         T=A(IJ)
      GO TO 40
   30 CONTINUE
      A(L)=A(K)
      A(K)=TT
   40 CONTINUE
      L=L-1
      IF (A(L) .LT. T) GO TO 40
      TT=A(L)
   50 CONTINUE
      K=K+1
      IF (A(K) .GT. 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 CONTINUE
      IL(M)=K
      IU(M)=J
      J=L
      M=M+1
      GO TO 80
   70 CONTINUE
      M=M-1
      IF (M.EQ.0) GOTO 998
      I=IL(M)
      J=IU(M)
   80 CONTINUE
      IF (J-I.GE.1) GOTO 10
      IF (I.EQ.1) GOTO 5
      I=I-1
   90 CONTINUE
      I=I+1
      IF (I .EQ. J) GO TO 70
      T=A(I+1)
      IF (A(I) .GE. T) GO TO 90
      K=I
  100 CONTINUE
      A(K+1)=A(K)
      K=K-1
      IF (T .GT. A(K)) GO TO 100
      A(K+1)=T
      GO TO 90



  998 CONTINUE


      RETURN
      END
      SUBROUTINE GVSDT4 (A,T,TT,N)
















      IMPLICIT      NONE
      INTEGER       IU(32), IL(32), M, I, J, K, IJ, N, L
      CHARACTER*(*) A(N), T, TT





      TT=' '
      M=1
      I=1
      J=N
    5 CONTINUE
      IF (I .GE. J) GO TO 70
   10 CONTINUE
      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 CONTINUE
      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 CONTINUE
      A(L)=A(K)
      A(K)=TT
   40 CONTINUE
      L=L-1
      IF (A(L) .GT. T) GO TO 40
      TT=A(L)
   50 CONTINUE
      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 CONTINUE
      IL(M)=K
      IU(M)=J
      J=L
      M=M+1
      GO TO 80
   70 CONTINUE
      M=M-1
      IF (M.EQ.0) GOTO 998
      I=IL(M)
      J=IU(M)
   80 CONTINUE
      IF (J-I.GE.1) GOTO 10
      IF (I.EQ.1) GOTO 5
      I=I-1
   90 CONTINUE
      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 CONTINUE
      A(K+1)=A(K)
      K=K-1
      IF (T .LT. A(K)) GO TO 100
      A(K+1)=T
      GO TO 90



  998 CONTINUE


      RETURN
      END
      SUBROUTINE GVSIT1 (A,N)
















      IMPLICIT      NONE
      INTEGER       IU(32), IL(32), M, I, J, K, IJ, N, L
      INTEGER       A(N), T, TT





      TT=0.0
      M=1
      I=1
      J=N
    5 CONTINUE
      IF (I .GE. J) GO TO 70
   10 CONTINUE
      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 CONTINUE
      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 CONTINUE
      A(L)=A(K)
      A(K)=TT
   40 CONTINUE
      L=L-1
      IF (A(L) .GT. T) GO TO 40
      TT=A(L)
   50 CONTINUE
      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 CONTINUE
      IL(M)=K
      IU(M)=J
      J=L
      M=M+1
      GO TO 80
   70 CONTINUE
      M=M-1
      IF (M.EQ.0) GOTO 998
      I=IL(M)
      J=IU(M)
   80 CONTINUE
      IF (J-I.GE.1) GOTO 10
      IF (I.EQ.1) GOTO 5
      I=I-1
   90 CONTINUE
      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 CONTINUE
      A(K+1)=A(K)
      K=K-1
      IF (T .LT. A(K)) GO TO 100
      A(K+1)=T
      GO TO 90



  998 CONTINUE


      RETURN
      END
      SUBROUTINE GVSIR1 (A,N)
















      IMPLICIT      NONE
      INTEGER       N
      INTEGER       A(N), IU(32), IL(32), M, I, J, K, IJ, L, T, TT





      TT=0
      M=1
      I=1
      J=N
    5 CONTINUE
      IF (I .GE. J) GO TO 70
   10 CONTINUE
      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 CONTINUE
      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 CONTINUE
      A(L)=A(K)
      A(K)=TT
   40 CONTINUE
      L=L-1
      IF (A(L) .GT. T) GO TO 40
      TT=A(L)
   50 CONTINUE
      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 CONTINUE
      IL(M)=K
      IU(M)=J
      J=L
      M=M+1
      GO TO 80
   70 CONTINUE
      M=M-1
      IF (M.EQ.0) GOTO 998
      I=IL(M)
      J=IU(M)
   80 CONTINUE
      IF (J-I.GE.1) GOTO 10
      IF (I.EQ.1) GOTO 5
      I=I-1
   90 CONTINUE
      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 CONTINUE
      A(K+1)=A(K)
      K=K-1
      IF (T .LT. A(K)) GO TO 100
      A(K+1)=T
      GO TO 90



  998 CONTINUE


      RETURN
      END
      SUBROUTINE GVSIRT (A,N,ITAG)






















      IMPLICIT      NONE
      INTEGER       N
      INTEGER       IU(32), IL(32), ITAG(N), M, I, J, K, IJ, JTG,
     +              L, A(N), T, TT





      TT=0
      M=1
      I=1
      J=N
    5 CONTINUE
      IF (I .GE. J) GO TO 70
   10 CONTINUE
      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)
      JTG=ITAG(IJ)
      ITAG(IJ)=ITAG(I)
      ITAG(I)=JTG
   20 CONTINUE
      L=J
      IF (A(J) .GE. T) GO TO 40
      A(IJ)=A(J)
      A(J)=T
      T=A(IJ)
      JTG=ITAG(IJ)
      ITAG(IJ)=ITAG(J)
      ITAG(J)=JTG
      IF (A(I) .LE. T) GO TO 40
      A(IJ)=A(I)
      A(I)=T
      T=A(IJ)
      JTG=ITAG(IJ)
      ITAG(IJ)=ITAG(I)
      ITAG(I)=JTG
      GO TO 40
   30 CONTINUE
      A(L)=A(K)
      A(K)=TT
      JTG=ITAG(L)
      ITAG(L)=ITAG(K)
      ITAG(K)=JTG
   40 CONTINUE
      L=L-1
      IF (A(L) .GT. T) GO TO 40
      TT=A(L)
   50 CONTINUE
      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 CONTINUE
      IL(M)=K
      IU(M)=J
      J=L
      M=M+1
      GO TO 80
   70 CONTINUE
      M=M-1
      IF (M.EQ.0) GOTO 998
      I=IL(M)
      J=IU(M)
80    CONTINUE
      IF (J-I.GE.1) GOTO 10
      IF (I.EQ.1) GOTO 5
      I=I-1
   90 CONTINUE
      I=I+1
      IF (I .EQ. J) GO TO 70
      T=A(I+1)
      IF (A(I) .LE. T) GO TO 90
      JTG=ITAG(I+1)
      K=I
  100 CONTINUE
      A(K+1)=A(K)
      ITAG(K+1)=ITAG(K)
      K=K-1
      IF (T .LT. A(K)) GO TO 100
      A(K+1)=T
      ITAG(K+1)=JTG
      GO TO 90



  998 CONTINUE


      RETURN
      END
      SUBROUTINE GVSORT (A,N,ITAG)
























      IMPLICIT      NONE
      INTEGER       N, IU(32), IL(32), ITAG(N), M, I, J, K, IJ, JTG, L
      REAL          A(N), T, TT





      TT=0.0
      M=1
      I=1
      J=N
    5 CONTINUE
      IF (I .GE. J) GO TO 70
   10 CONTINUE
      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)
      JTG=ITAG(IJ)
      ITAG(IJ)=ITAG(I)
      ITAG(I)=JTG
   20 CONTINUE
      L=J
      IF (A(J) .GE. T) GO TO 40
      A(IJ)=A(J)
      A(J)=T
      T=A(IJ)
      JTG=ITAG(IJ)
      ITAG(IJ)=ITAG(J)
      ITAG(J)=JTG
      IF (A(I) .LE. T) GO TO 40
      A(IJ)=A(I)
      A(I)=T
      T=A(IJ)
      JTG=ITAG(IJ)
      ITAG(IJ)=ITAG(I)
      ITAG(I)=JTG
      GO TO 40
   30 CONTINUE
      A(L)=A(K)
      A(K)=TT
      JTG=ITAG(L)
      ITAG(L)=ITAG(K)
      ITAG(K)=JTG
   40 CONTINUE
      L=L-1
      IF (A(L) .GT. T) GO TO 40
      TT=A(L)
   50 CONTINUE
      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 CONTINUE
      IL(M)=K
      IU(M)=J
      J=L
      M=M+1
      GO TO 80
   70 CONTINUE
      M=M-1
      IF (M.EQ.0) GOTO 998
      I=IL(M)
      J=IU(M)
80    CONTINUE
      IF (J-I.GE.1) GOTO 10
      IF (I.EQ.1) GOTO 5
      I=I-1
   90 CONTINUE
      I=I+1
      IF (I .EQ. J) GO TO 70
      T=A(I+1)
      IF (A(I) .LE. T) GO TO 90
      JTG=ITAG(I+1)
      K=I
  100 CONTINUE
      A(K+1)=A(K)
      ITAG(K+1)=ITAG(K)
      K=K-1
      IF (T .LT. A(K)) GO TO 100
      A(K+1)=T
      ITAG(K+1)=JTG
      GO TO 90



  998 CONTINUE


      RETURN
      END
      SUBROUTINE GVSRT1 (A,N)
















      IMPLICIT      NONE
      INTEGER       IU(32), IL(32), M, I, J, K, IJ, N, L
      REAL          A(N), T, TT





      TT=0.0
      M=1
      I=1
      J=N
    5 CONTINUE
      IF (I .GE. J) GO TO 70
   10 CONTINUE
      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 CONTINUE
      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 CONTINUE
      A(L)=A(K)
      A(K)=TT
   40 CONTINUE
      L=L-1
      IF (A(L) .GT. T) GO TO 40
      TT=A(L)
   50 CONTINUE
      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 CONTINUE
      IL(M)=K
      IU(M)=J
      J=L
      M=M+1
      GO TO 80
   70 CONTINUE
      M=M-1
      IF (M.EQ.0) GOTO 998
      I=IL(M)
      J=IU(M)
   80 CONTINUE
      IF (J-I.GE.1) GOTO 10
      IF (I.EQ.1) GOTO 5
      I=I-1
   90 CONTINUE
      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 CONTINUE
      A(K+1)=A(K)
      K=K-1
      IF (T .LT. A(K)) GO TO 100
      A(K+1)=T
      GO TO 90



  998 CONTINUE


      END
      SUBROUTINE GVSWAP (REAL1,REAL2)









      IMPLICIT      NONE
      REAL          TEMP, REAL1, REAL2





      TEMP=REAL1
      REAL1=REAL2
      REAL2=TEMP





      RETURN
      END
      SUBROUTINE GVSWCP (TEXT1,TEXT2)













      IMPLICIT      NONE
      INTEGER       I, LENTXT
      CHARACTER*1   TEMP
      CHARACTER*(*) TEXT1, TEXT2





      LENTXT=MIN(LEN(TEXT1),LEN(TEXT2))

      IF (LENTXT.GT.0) THEN
         DO 10 I=1,LENTXT
            TEMP=TEXT1(I:I)
            TEXT1(I:I)=TEXT2(I:I)
            TEXT2(I:I)=TEMP
   10    CONTINUE
      END IF





      RETURN
      END
      SUBROUTINE GVSWIP (INT1,INT2)









      IMPLICIT      NONE
      INTEGER       ITEMP, INT1, INT2





      ITEMP=INT1
      INT1=INT2
      INT2=ITEMP





      RETURN
      END
      SUBROUTINE GVSWLP (BOOL1,BOOL2)









      IMPLICIT      NONE
      LOGICAL       TEMP, BOOL1, BOOL2





      TEMP=BOOL1
      BOOL1=BOOL2
      BOOL2=TEMP





      RETURN
      END
      INTEGER FUNCTION GVFIMN(IROW,NUM)











      IMPLICIT      NONE
      INTEGER       NUM, IROW(NUM), I







      GVFIMN=0



      IF (NUM.GT.0) THEN



         GVFIMN=IROW(1)
         DO 10 I=1,NUM
            GVFIMN=MIN(GVFIMN,IROW(I))
   10    CONTINUE
         GOTO 998
      ELSE IF (NUM.EQ.0) THEN



         CALL GVSTTE ('?TLSB46')
      ELSE IF (NUM.LT.0) THEN



         CALL GVSTTI ('?TLSB45',NUM)
      END IF



  998 CONTINUE


      RETURN
      END
      INTEGER FUNCTION GVFIMX(IROW,NUM)











      IMPLICIT      NONE
      INTEGER       NUM, IROW(NUM), I







      GVFIMX=0



      IF (NUM.GT.0) THEN



         GVFIMX=IROW(1)
         DO 10 I=1,NUM
            GVFIMX=MAX(GVFIMX,IROW(I))
   10    CONTINUE
         GOTO 998
      ELSE IF (NUM.EQ.0) THEN



         CALL GVSTTB ('?TLSB48')
         GOTO 998
      ELSE IF (NUM.LT.0) THEN



         CALL GVSTTI ('?TLSB47',NUM)
      END IF



  998 CONTINUE


      RETURN
      END
      REAL FUNCTION GVFMAX(ROW,NUM)











      IMPLICIT      NONE
      INTEGER       NUM, I
      REAL          ROW(NUM)







      GVFMAX=0.0



      IF (NUM.GT.0) THEN



         GVFMAX=ROW(1)
         DO 10 I=1,NUM
            GVFMAX=MAX(GVFMAX,ROW(I))
   10    CONTINUE
         GOTO 998
      ELSE IF (NUM.EQ.0) THEN



         CALL GVSTTB ('?TLSB57')
         CALL GVSKIL
         GOTO 998
      ELSE IF (NUM.LT.0) THEN



         CALL GVSTTI ('?TLSB56',NUM)
         CALL GVSKIL
      END IF



  998 CONTINUE


      RETURN
      END
      REAL FUNCTION GVFMIN(ROW,NUM)











      IMPLICIT      NONE
      INTEGER       NUM, I
      REAL          ROW(NUM)







      GVFMIN=0.0



      IF (NUM.GT.0) THEN



         GVFMIN=ROW(1)
         DO 10 I=1,NUM
            GVFMIN=MIN(GVFMIN,ROW(I))
   10    CONTINUE
         GOTO 998
      ELSE IF (NUM.EQ.0) THEN



         CALL GVSTTB ('?TLSB59')
         CALL GVSKIL
         GOTO 998
      ELSE IF (NUM.LT.0) THEN



         CALL GVSTTI ('?TLSB58',NUM)
         CALL GVSKIL
      END IF



  998 CONTINUE


      RETURN
      END
      SUBROUTINE GVSMIN (ROW,NUM,RANK,MINVAL)











      IMPLICIT      NONE
      INTEGER       NUM, I, RANK
      REAL          ROW(NUM), MINVAL







      RANK=0
      MINVAL=0.0



      IF (NUM.GT.0) THEN
         MINVAL=ROW(1)



         DO 10 I=1,NUM
            IF (ROW(I).LT.MINVAL) THEN
               MINVAL=ROW(I)
               RANK=I
            END IF
   10    CONTINUE
         GOTO 998
      ELSE IF (NUM.EQ.0) THEN



         CALL GVSTTB ('?TLSB59')
         GOTO 998
      ELSE IF (NUM.LT.0) THEN



         CALL GVSTTI ('?TLSB58',NUM)
      END IF



  998 CONTINUE


      RETURN
      END
