          SUBROUTINE TRIM(XOUT,YOUT,XBOUND,XOK,YOK)
C
C  IN ORDER TO RETAIN AS MUCH ACCURACY AS POSSIBLE WHEN ONE OF 
C  THE END POINTS IS CLOSE TO THE MACHINE BOUND, WE WILL ALWAYS 
C  CALCULATE THE Y INTERCEPT BY SUBTRACTION FROM THE POINT
C  NEAREST THE XBOUND
C
          BASE = (YOUT-YOK)/(XOUT-XOK)
          DELTA1 = XBOUND-XOUT
          DELTA2 = XBOUND - XOK
          IF (ABS(DELTA1).GT.ABS(DELTA2)) GO TO 1
          YOUT = YOUT + DELTA1*BASE
          GO TO 2
1         YOUT = YOK + DELTA2*BASE
2         XOUT = XBOUND
          RETURN
          END
C
C
C
C
C
C
C
C
C
C
          SUBROUTINE SWAP
          COMMON/LINEND/ XFIRST,YFIRST,XLAST,YLAST
          TEMP = XFIRST
          XFIRST = XLAST
          XLAST = TEMP
          TEMP = YFIRST
          YFIRST = YLAST
          YLAST = TEMP
          RETURN
          END
