      SUBROUTINE INVERF(Y,X)
      IMPLICIT real*4 (A-H,O-Z)
      save
c  this program calculates the inverse of the area under the normal curve.
c  if y=area(x), then given y, this program will calculate x.
c  A table lookup is performed.
      dimension xx(18),yy(18)
      data xx/3.4,3.2,3.,2.8,2.6,2.4,2.2,2.,1.8,1.6,1.4,
     x        1.2,1.,.8,.6,.4,.2,0./
      data yy/.9997,.9993,.9987,.9974,.9953,.9918,.9861,.9772,.9641,
     x        .9452,.9192,.8849,.8413,.7881,.7257,.6554,.5793,.5/
c
      fac = 1.
c  check to see if y is within range
      if(y.lt.0.0228)then
         x = -2.0
         return
      elseif(y.lt.0.5)then
        yp = 1.-y
        fac = -1.
      elseif(y.gt.0.9997)then
        x = 3.5
        return
      else
        yp = y
      endif
c  search for range
      do 10 i=18,1,-1
        if(yp.le.yy(i-1))then
          x = xx(i) + (yp-yy(i))*(xx(i-1)-xx(i))/(yy(i-1)-yy(i))
          x = fac*x
          return
        endif
10    continue
      return
      end
