*
* $Id$
*
* $Log$
* Revision 1.1  1996/04/01 15:03:24  mclareni
* Initial revision
*
*
#include "gen/pilot.h"
      SUBROUTINE BUFOPT (N,RXMIN,RXMAX,RXLOW,RXHI,RFMIN,RFMAX,RFLOBD,RFU
     1PBD,W,LENW,IW,LENIW,NFCNT,IRESLT)
      INTEGER N, LENW, LENIW, NFCNT, IRESLT
      INTEGER IW(LENIW)
      REAL RXMIN(N), RXMAX(N), RXLOW(N), RXHI(N), RFMIN, RFMAX,
     1     RFLOBD, RFUPBD
      DOUBLE PRECISION W(LENW)
      INTEGER I, IPRINT, IXHI, IXLOW, IXMAX, JAHESS, JGACTV, JGFREE,
     1        JGNEW, JIACTV, JIFREE, JPFREE, JX, JXHI, JXLOW, JXMAX,
     2        JXMIN, JXTEMP, MAXFUN
      REAL RFDIF, SNGL
      DOUBLE PRECISION ALFMAX, DELTA, ETA, FLOBD, FMAX, FMIN,
     1   FTOL, FUPBD, GTOL
      JXMIN=1
      JXMAX=JXMIN+N
      JXLOW=JXMAX+N
      JXHI=JXLOW+N
      DO 10 I=1,N
      W(I)=DBLE(RXMIN(I))
      IXMAX=JXMAX-1+I
      W(IXMAX)=DBLE(RXMAX(I))
      IXLOW=JXLOW-1+I
      W(IXLOW)=DBLE(RXLOW(I))
      IXHI=JXHI-1+I
      W(IXHI)=DBLE(RXHI(I))
 10   CONTINUE
      FMAX=DBLE(RFMAX)
      FMIN=DBLE(RFMIN)
      FLOBD=DBLE(RFLOBD)
      FUPBD=DBLE(RFUPBD)
      CALL SETTOL(N,FTOL,GTOL,DELTA,ETA,ALFMAX,MAXFUN,IPRINT)
      IF(IPRINT.LT.0) GOTO 20
      WRITE(6,70) (RXLOW(I),I=1,N)
      WRITE(6,80) (RXHI(I),I=1,N)
 20   JX=JXHI+N
      JXTEMP=JX+N
      JGFREE=JXTEMP+N
      JPFREE=JGFREE+N
      JGACTV=JPFREE+N
      JGNEW=JGACTV+N
      JAHESS=JGNEW+N
      JIFREE=1
      JIACTV=JIFREE+N
      CALL BNDOPT(N,W(JXMIN),W(JXMAX),W(JXLOW),W(JXHI),FMIN,FMAX,FLOBD,
     1FUPBD,W(JX),W(JXTEMP),W(JGFREE),W(JPFREE),W(JGACTV),W(JGNEW),W(JAH
     2ESS),DELTA,FTOL,GTOL,ETA,ALFMAX,MAXFUN,NFCNT,IW(JIFREE),IW(JIACTV)
     3,IPRINT,IRESLT)
      DO 30 I=1,N
      RXMIN(I)=SNGL(W(I))
      IXMAX=N+I
      RXMAX(I)=SNGL(W(IXMAX))
 30   CONTINUE
      RFMIN=SNGL(FMIN)
      RFMAX=SNGL(FMAX)
      RFDIF=RFMAX-RFMIN
      IF(IPRINT.LT.0) RETURN
      WRITE(6,40) RFDIF,RFMAX,RFMIN,NFCNT
      WRITE(6,50) (RXMIN(I),I=1,N)
      WRITE(6,60) (RXMAX(I),I=1,N)
      RETURN
 40   FORMAT('0 END OF OPTIMIZATION -- FDIF =', 1PE15.5, 4X,
     1  'FMAX =',1PE15.5,4X,'FMIN =',1PE15.5,4X,'NFCNT =',I7)
 50   FORMAT(' XMIN',5(1PE15.5))
 60   FORMAT(' XMAX',5(1PE15.5))
 70   FORMAT(' LOWER BOUNDS',5(1PE15.5))
 80   FORMAT(' UPPER BOUNDS',5(1PE15.5))
      END
