C$TEST LRPB
C TO RUN AS A MAIN PROGRAM REMOVE NEXT LINE
      SUBROUTINE LRPB
C***********************************************************************
C
C  FIRST EXAMPLE OF USE OF THE PORT PROGRAM LINPA
C
C***********************************************************************
       REAL X(4),B(3),C(4),A(3,4),SIMP(8)
       EXTERNAL LPMAN, PRINT
       INTEGER ISIMP(8),IPTG(3)
       REAL U(4)
       N=4
       IA=3
       M=3
       IE=1
C
C SET UP GENERAL CONSTRAINTS
C
       DO 10 J=1,N
          A(1,J)=FLOAT(J)
          A(2,J)=0.0
          A(3,J)=0.0
  10   CONTINUE
       A(2,1)=1.0
       A(2,2)=1.0
       A(3,2)=-1.0
       A(3,4)=-1.0
       B(1)=5
       B(2)=1.0
       B(3)=-5.0
C
C SET UP SIMPLE CONSTRAINTS
C
      IS=8
      DO 20 I=1,N
         SIMP(I)=FLOAT(-I)
         ISIMP(I)=I
         SIMP(I+N)=10.0
         ISIMP(I+N)=-I
  20   CONTINUE
C
C SET UP COST VECTOR AND INITIAL GUESS
C
      DO 30 I=1,N
         C(I)=FLOAT(I+1)
         X(I)=1.0
  30  CONTINUE
C
C CALL LINEAR PROGRAMMING PACKAGE
C
      CALL LINPA(A,M,N,LPMAN,IA,B,C,X,15,CTX,IS,SIMP,ISIMP,IE,
     1PRINT,IAG,IAS,IPTG,U)
      IWRITE=I1MACH(2)
      WRITE(IWRITE,21)(X(I),I=1,N)
 21   FORMAT(11H SOLUTION: ,4E15.6)
      WRITE(IWRITE,22)CTX
 22   FORMAT(17H FUNCTION VALUE: ,E15.5)
      STOP
      END
       SUBROUTINE PRINT(A,M,N,AMAN,IA,B,C,X,CTX,IS,SIMP,ISIMP,IE,
     1 ITER,IPTG,IAG,IAS,U,IEND)
C
C THIS IS A PRINT ROUTINE
C
       REAL CTX,A(1),X(N),B(1)
       LOGICAL IEND
       EXTERNAL AMAN
       INTEGER IA(1),IPTG(N),ISIMP(1),S
       REAL SIMP(1),C(1),U(1)
       IEND = .FALSE.
       IWRITE=I1MACH(2)
       TOL = -R1MACH(4)*(5.0+4.0*SASUM(N,X,1))*10.0
       IAGPE=IAG+IE
       WRITE(IWRITE,1)ITER,CTX,IAGPE,IAS
  1    FORMAT(/14H AT ITERATION ,I5,6H CTX= ,E15.5,
     1  /18H NO.OF ACT. GEN.= ,I5,15H NO.OF ACT.SIM=,I5)
       WRITE(IWRITE,2)(X(I),I=1,N)
  2    FORMAT(3H X ,5E15.5)
       DO 10 I=1,M
          CALL AMAN(.TRUE.,A,IA,N,I,X,TOUT)
          TOUT=TOUT-B(I)
          IF (TOUT .LT. TOL)IEND=.TRUE.
          WRITE(IWRITE,9)I,TOUT
  9       FORMAT(15H AT CONSTRAINT ,I5,11H RESIDUAL= ,E15.5)
 10    CONTINUE
       IF (IAGPE .EQ. 0)GO TO 12
       WRITE(IWRITE,11)(IPTG(I),I=1,IAGPE)
 11    FORMAT(29H  ACTIVE GENERAL CONSTRAINTS ,10I4)
 12    IF (IAS .LT. 1)RETURN
       DO 15 I=1,IAS
          IP=IABS(ISIMP(I))
          IF (ISIMP(I) .GT. 0)WRITE(IWRITE,13)IP
 13       FORMAT(18H LOWER BOUND ON X(,I2,11H) IS ACTIVE)
          IF (ISIMP(I) .LT. 0)WRITE(IWRITE,14)IP
 14       FORMAT(18H UPPER BOUND ON X(,I2,11H) IS ACTIVE)
 15    CONTINUE
       RETURN
       END
