      subroutine pulse
*
* pulsate the prepped model
*
      implicit double precision(a-h,o-z)

      common g(650),x(650),rho(650),yliq(4,650),ray(4,650)
      common/misc/l,lhat,lindex,nsurf
      common/dmisc/period,grav,pi,pi4,p43,eps,verg,eig,eigt,y3i,y3t,amass
      common/ray/iray
      common/rs/r(650)
      common/ekint/ekin
      common/setup/isetup
      common/modect/y1m(1000),y2m(1000),nfine,nodes1,nodes2,modep
      common/eig1/rint(4,650),h(650),f(650),part(650)
      common/ms/mr(650)
      common/rot1/rone(650),rpone(650),rptwo(650),t(650),clk,crone,crtwo
      common/rot2/angfac(650),rpthr(650),rpfour(650),rpfive(650)
      common/perds/periods(1000),discr(1000),pguess(3,101),yguess(101)

      real*8 l,lhat,lindex,mr,mstar,llsun,rrsun
      integer model
      integer modes(3),numb,num

      COMMON/modelp1/gnu0,per0,tdyn,mstar,model
      COMMON/modelp2/age,llsun,rrsun,teff,np
      COMMON/cperiods/calc_per(100),num

      DATA permin, permax, nper, lmax
     &  /   400,    1000,   50,    1   /
*
* initialize index for calc_per array
*
      num = 1

      call init(model)
*
* First, calculate surface discriminant only
* in cowling approximation to obtain period guesses
*
      delper=(permax-permin)/nper

      do 7501 lind=1,lmax
         l=float(lind)
         lindex=2.-l
         lhat=l*(l+1.)

         do 210 idisc=1,nper+1
            periods(idisc)=permin+delper*(idisc-1)
            eig=(2.*pi/periods(idisc))**2
            eigt=eig
            iray=0
            call bump(discr(idisc))
            discr(idisc)=discr(idisc)/(r(nsurf)**lindex)
210      continue   ! end search for periods

         call perg(lind,modes,nper,permax)

7501  continue   ! end search for modes

*
* begin loop over l 
*
      do 7500 li=1,lmax
         limit=modes(li)
         l=float(li)
         lindex=2.-l
         lhat=l*(l+1.)
*
* begin loop over periods
*
         do 7600 nbnum=1,limit
100         nsearch=10
            numb=nbnum
*
* stop execution if period = 0.0
*
            if (pguess(li,numb).eq.0.0) then
               if(li.eq.lup)then
                  stop
               endif
               go to 7500
            endif
*
* continue with period guess
*
            eig=(2.*pi/pguess(li,numb))**2
            y3i=yguess(numb)
            nconv=0
            iray=0

            do 200 ntry=1,nsearch
               eigt=eig
               y3t=y3i
               b1 = 0.0
               b2 = 0.0
               call grind(b1,b2)
               eigt=(1.+eps)*eig
               dum1 = 0.0
               dum2 = 0.0
               call grind(dum1,dum2)
               deigb1=dum1-b1
               deigb2=dum2-b2
               eigt=eig
               y3t=(1.+eps)*y3i
               call grind (dum1,dum2)
               dy3b1=dum1-b1 
               dy3b2=dum2-b2 
               d2=(deigb1*dy3b2-deigb2*dy3b1)
               dume=b2*dy3b1-b1*dy3b2
               dumy=b1*deigb2-b2*deigb1
               deig=eps*eig*dume/d2
               dy3=eps*y3i*dumy/d2
               adeig=dabs(deig/eig)
               ady3=dabs(dy3/y3i)
               if (adeig.lt.verg.and.ady3.lt.verg) then
                 nconv=1 
               endif
               epseig=deig/eig
               epsy3=dy3/y3i
               if (adeig.gt.0.1) then
                 epseig=0.1*deig/dabs(deig) 
               endif
               if (ady3.gt.2.0) then
                 epsy3=2.*dy3*dabs(y3i)/dabs(dy3)/y3i-1.
               endif
               eig=eig*(1.+epseig)
               y3i=y3i*(1.+epsy3)
*
* if we converged to a solution, skip down a few lines to continue
*
               if (nconv.eq.1) goto 201

200         continue   ! end loop over period search
            goto 7600
*
*  continue with converged period guess
*
201         eigt=eig
            y3t=y3i
            iray=1
            call grind (b1,b2)
            period=(2.*pi)/dsqrt(eig)
*
* store periods in an array for the common block
*
            calc_per(num) = period
            num = num + 1

            write(*,*) period

7600     continue   ! end loop over periods

7500  continue   ! end loop over l

      return
      end

************************************************************************

