      SUBROUTINE Q2BSRT (INVRNM,IVRCNT,
     O                   VARPOS)
C
C     + + + PURPOSE + + +
C     routine to sort the input variable names in alphabetical order
C
C     + + + DUMMY ARGUMENTS + + +
      INTEGER     IVRCNT,VARPOS(150)
      CHARACTER*1 INVRNM(8,150)
C
C     + + + ARGUMENT DEFINITIONS + + +
C     INVRNM - character array of input variable codes
C     IVRCNT - counter for the number of input variable code
C     VARPOS - bubble sort pointer to input variable codes
C
C     + + + LOCAL VARIABLES + + +
      INTEGER   I,J,K,JPT,JPT1,DONE
C
C     + + + END SPECIFICATIONS + + +
C
C     initialize pointer array
      DO 10 I= 1,IVRCNT
        VARPOS(I)= I
 10   CONTINUE
C
C     make a pointer to INVRNM array with bubble sort
      DO 40 I= IVRCNT,2,-1
        DO 30 J= 2,I-1
          JPT = VARPOS(J)
          JPT1= VARPOS(J+1)
          K   = 0
          DONE= 0
 20       CONTINUE
            K= K+ 1
            IF (INVRNM(K,JPT).GT.INVRNM(K,JPT1)) THEN
C             exchange values
              VARPOS(J+1)= JPT
              VARPOS(J)  = JPT1
              DONE= 1
            ELSE IF (INVRNM(K,JPT).LT.INVRNM(K,JPT1)) THEN
C             dont exchange
              DONE= 1
            END IF
          IF (K.LT.8.AND.DONE.EQ.0) GO TO 20
 30     CONTINUE
 40   CONTINUE
C
      RETURN
      END
