      subroutine lsdvrad(vrad,m,n,np,bvec,parity)

C********************************************************
C
C This subroutine sets up a vector vrad which is used as
C a set of expansion coefficents in the calculation of
C the function Psquiggle(m,lj) in the routine lsdfrad
C for use in the new Lambda Basis of Lee & Saio (1990)
C 349, 570-579. The routine uses the eigenvector for the
C mode in question bvec, which is found previously using lsdtqli
C See lsdfrad for details...
C
C Started:3/7/95
C Updated:
C
C (c) Richard Townsend 1995
C
C************************************************************

      implicit none		! Turn off implicit typing

C Declare the passed variables

      integer m			! The m-value to use
      integer n			! The number of terms to calculate over
      integer np		! The total size of bvec
      double precision bvec(np)	! The column vector containing the appropiate eigenvector
      double precision vrad(np) ! The column vector to contain the expansion coefficients
      logical parity		! The parity to be used - .true.=even

C Declare the in-program variables

      integer j			! The coefficient index counter
      integer am		! The absoulte value of m
      double precision parfac	! The partial factorial (l+|m|)...(l-|m|+1)

C Set up am=|m|
   
      am=iabs(m)      
 
C Loop over j to get the coefficients...

      do j=1,n

C We set the jth coefficient, depending on whether the parity
C is even (.true.) or false (.odd.)

        if(parity) then

          vrad(j)=bvec(j)*
     :      dsqrt((am+2*(j-1)+0.5D0)/
     :      parfac(am+2*(j-1),am))
        else

          vrad(j)=bvec(j)*
     :      dsqrt((am+2*(j-1)+1.5D0)/
     :      parfac(am+1+2*(j-1),am))
        endif

C Its as simple as that - now loop back around....

      enddo

C At a little safety check, we zero all of the remaining coeffs...

      do j=n+1,np
        vrad(j)=0.D0
      enddo

C Thats all folks - return...

      return

      end

