********************************************************************************
*                                                                              *
*  2DHF version 1-2003                                                         *
*  Copyright (C) 1996  Jacek Kobus, Leif Laaksonen, Dage Sundholm              *
*                                                                              *
*  This software may be used and distributed according to the terms            *
*  of the GNU General Public License, see README and COPYING.                  *
*                                                                              *
********************************************************************************
c ### plegend ###		  	    
c
c
      function plegend(l,m,costh)
      implicit integer*4 (i-n)
      implicit real*8 (a-h,o-z)		

      plegend=0.d0
      p00=1.d0
      if (l.eq.0) then
         plegend=p00
         return
      endif
c     P10	
      p10=costh
      if (l.eq.0.and.m.eq.0) then
         plegend=p10
         return
      endif
c     P11
      costh2=sqrt(costh*costh-1.d0)
      p11=1.d0/costh2*(costh*p10-p00)
      if (l.eq.1.and.m.eq.1) then
         plegend=p11
         return  
      endif

      write(*,*) 'No spherical harmonics for l>1'
      
      return
      end
