      subroutine pptoll(pp,ppll,k)

      implicit none
      integer,parameter::nm=6
      integer::k
      real,dimension(k,k,nm,4,4,3)::pp
      real,dimension(k,k,nm,4,4,2)::ppll
      real::atang1,atang,pihlf,xi,yi,zi
      integer::i,j,n,c1,c2

      pihlf=0.5*3.1415926

      do n=1,nm
      do i=1,k
      do j=1,k
      do c1=1,4
      do c2=1,4
        xi=pp(i,j,n,c1,c2,1)
        yi=pp(i,j,n,c1,c2,2)
        zi=pp(i,j,n,c1,c2,3)
	ppll(i,j,n,c1,c2,1)=atang1(yi,xi)
	ppll(i,j,n,c1,c2,2)=atang(zi,sqrt(xi**2+yi**2),pihlf)
      enddo
      enddo
      enddo
      enddo
      enddo

      end subroutine pptoll
