!&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
      Function Atang(y,x,pihlf)
!     ******************************************************************
!     *                                                                *
!     *                   Arctan(y/x)                                  *
!     *                                                                *
!     ******************************************************************
!-----------------------------------------------------------------------
      If(x.eq.0.) Then
        If(y.eq.0) Then
           Atang=0.
        Else If(y.gt.0.) Then
           Atang=pihlf
        Else
           Atang=-pihlf
        End If
      Else
           Atang=Atan(y/x)+(Sign(1.,-x)+1)*pihlf
      End If
!-----------------------------------------------------------------------
      Return
      End 

      function Atang1(y,x)
!     ******************************************************************
!     *                                                                *
!     *               Arctan (y/x) in range of (0,2*pi)                *
!     *                                                                *
!     ******************************************************************
      parameter (pi=3.14159265359,pi2=pi*2.,pi05=pi*0.5,pi305=3.*pi05)
!-----------------------------------------------------------------------
      If(y.lt.0.) Then
        If(x.lt.0.) Then
          Atang1=pi+Atan(y/x)
          Return
        Else If(x.gt.0.) Then
          Atang1=pi2+Atan(y/x)
          Return
        Else
          Atang1=pi305
          Return
        End If
      Else If(y.gt.0.) Then
        If(x.lt.0.) Then
          Atang1=pi+Atan(y/x)
          Return
        Else If(x.gt.0.) Then
          Atang1=Atan(y/x)
          Return
        Else
          Atang1=pi05
          Return
        End If
      Else
        If(x.ge.0.) Then
          Atang1=0.
          Return
        Else
          Atang1=pi
          Return
        End If
      End If

!-----------------------------------------------------------------------
                               End

