C   07/06/96 606071919  MEMBER NAME  XBINS    (S4)          FORTG1
      SUBROUTINE XBINS(XXA,XXZ,NB,A,B)
      REAL BINS(10) /0.1,0.15,0.2,0.25,0.4,0.5,0.6,0.8,1.0,1.5/
      REAL*8 BN,BIN,FEX,ST,AW,TEN
      TEN=10
      BN=NB
      XA=AMIN1(XXA,XXZ)
      XZ=AMAX1(XXA,XXZ)
      DX=XZ-XA
      IF(DX.LE.0.0) DX=1.E-6
      XM=0.5*(XA+XZ)
      XA=XM-0.4999*DX
      XZ=XM+0.4999*DX
      BIN=DX/BN
      DN=DLOG10(BIN)
      ND=DN
      FEX=TEN**ND
      IF(BIN/FEX.LE.1.0) GOTO 10
      FEX=FEX*TEN
   10 BIN=BIN/FEX
      DO 20 I=1,9
      KI=I
      IF(BINS(I).GE.BIN) GOTO 30
   20 CONTINUE
      KI=9
   30 BIN=BINS(KI)
      ST=BIN*FEX
      AW=IDINT(XA/(TEN*ST))*ST*TEN
      IF(XA-AW.LT.0.0) AW=AW-ST*TEN
      IF(AW+BN*ST.GE.XZ) GOTO 40
      KI=KI+1
      IF(KI.LE.10) GOTO 30
   40 A=AW
      B=ST
      RETURN
      END
