*dk phical
      subroutine phical (phi)
c
c   $RCSfile: phical.f,v $ $Revision: 1.4 $
c   $Date: 89/08/04 14:22:13 $
c   $State: Stable $
c
c   subroutine from blais version: xxdriv.for;48
      implicit real*8 (a-h,o-z)
      common /coscom/ cosphi,ratio,x2,y2,z2,rc3,x1,y,z1
      common /fh2pot/r(3),e,dedr(3)
      ratio=r(1)/r(3)
      if(ratio.gt.1.0d0)go to 100
      x1=r(1)
      y=r(3)
      go to 200
  100 x1=r(3)
      y=r(1)
  200 x2=x1**2
      y2=y**2
      z1=r(2)
      z2=z1**2
      rc2=0.5d0*(x2+y2-0.5d0*z2)
      if(rc2.le.0.d0)rc2=1.d-14
      rc1=sqrt(rc2)
      rc3=rc2*rc1
      cphi=0.5d0*(y2-x2)/(z1*rc1)
      if(cphi.gt.1.0d0)cphi=1.0d0
      if(cphi.lt.-1.0d0)cphi=-1.0d0
      cosphi = cphi
      phi = acos(cosphi)
      return
      end
