      subroutine xstarcalc(lnerrd,nlimdt,lfpi,
     $       lpri,lprid,lun11,tinf,vturbi,critf,
     $       t,trad,r,delr,xee,xpx,ababs,cfrac,p,lcdd,
     $       epi,ncn2,bremsa,bremsint,
     $       zrems,zremso,elumab,elumabo,elum,elumo,
     $       decomp,ecomp,sxcomp,
     $       tau0,tauc,
     $       idat1,rdat1,kdat1,nptrs,np2,
     $       npar,npnxt,npfi,npfirst,
     $       nplin,nplini,nlsvn,npcon,npconi,npilev,npilevi,
     $       npconi2,nlevs,ncsvn,rates,vsav,idrates,
     $       ntotit,
     $       xii,rrrt,pirt,htt,cll,httot,cltot,hmctot,elcter,
     $         cllines,clcont,htcomp,clcomp,clbrems,
     $       xilev,bilev,rniss,nmat,
     $       rcem,oplin,rccemis,brcems,opakc,opakscatt,cemab,
     $       opakab,fline,flinel)

      implicit none
c     
c
      include './PARAM'
c
c
c     global xstar data
c     master data
      integer idat1(nidat1)
      real rdat1(nrdat1)
      integer nptrs(nptt,ndat2)
      character*1 kdat1(nkdat1)
c     pointers to master data
      integer npar(ndat2),npnxt(ndat2),
     $      npfirst(ntyp)
      integer npfi(ntyp,nni)
c     pointers to line data
      integer nplin(nnnl),nplini(ndat2)
c     pointers to line data
      integer npcon(nnml),npconi2(ndat2),npconi(ndat2)
      integer npilev(nd,nni),npilevi(nnml)
c     line luminosities
      real elum(3,nnnl),elumo(3,nnnl)
c     line emissivities
      real rcem(2,nnnl)
c     line opacities
      real oplin(nnnl)
      real fline(ncn),flinel(ncn)
c     line optical depths
      real tau0(2,nnnl)
c     energy bins
      real epi(ncn)
c      continuum lum
      real zrems(4,ncn),zremso(4,ncn)
c     continuum flux
      real bremsa(ncn),bremsint(ncn)
c     continuum emissivities
      real rccemis(2,ncn),brcems(ncn)
c     continuum opacities
      real opakc(ncn),opakscatt(ncn)
c     level populations
      real xilev(nnml),bilev(nnml),rniss(nnml)
      real cemab(2,nnml),opakab(nnml)
      real elumab(2,nnml),elumabo(2,nnml)
      real tauc(2,nnml)
c     ion abundances
      real xii(nni)
c     heating and cooling
      real htt(nni),cll(nni)
      real rrrt(nni),pirt(nni)
      integer nlevs(nni)
c     element abundances
      real ababs(nl)
c     the saved rates
      real rates(4,ndat2)
      integer idrates(2,ndat2)
      real vsav(4,ndat2)
c     compton heating data
      real decomp(ncomp,ncomp),ecomp(ncomp),sxcomp(ncomp)
c
c     state variables
      real p,r,t,xpx,delr
c     heating-cooling variables
      real httot,cltot,htcomp,clcomp,clbrems,elcter,cllines,
     $     clcont,hmctot
      real trad
      real cfrac,critf,vturbi,xee,tinf
      integer lcdd,ncn2
c     variables associated with thermal equilibrium solution
      integer nmat,ntotit,lnerrd
c     switches
      integer lprid,lpri,nlimdt,lfpi
c     strings for atomic data read
      integer nlsvn,ncsvn,lun11,np2,lfpi2,lprisv
c
c
      lprisv=lpri
      lpri=0
      if (nlimdt.ne.0) then
        call dsec(lnerrd,nlimdt,lfpi,
     $       lpri,lprid,lun11,tinf,vturbi,critf,
     $       t,trad,r,delr,xee,xpx,ababs,cfrac,p,lcdd,
     $       epi,ncn2,bremsa,bremsint,
     $       zrems,zremso,elumab,elumabo,elum,elumo,
     $       decomp,ecomp,sxcomp,
     $       tau0,tauc,
     $       idat1,rdat1,kdat1,nptrs,np2,
     $       npar,npnxt,npfi,npfirst,
     $       nplin,nplini,nlsvn,npcon,npconi,npilev,npilevi,
     $       npconi2,nlevs,ncsvn,rates,vsav,idrates,
     $       ntotit,
     $       xii,rrrt,pirt,htt,cll,httot,cltot,hmctot,elcter,
     $         cllines,clcont,htcomp,clcomp,clbrems,
     $       xilev,bilev,rniss,nmat,
     $       rcem,oplin,rccemis,brcems,opakc,opakscatt,cemab,
     $       opakab,fline,flinel)
        endif
c       do ll=1,nnml
c         xilev(ll)=0.
c         enddo
c
       lfpi2=2
       call func(lpri,lun11,lfpi2,vturbi,critf,
     $       t,trad,r,delr,xee,xpx,ababs,cfrac,p,lcdd,
     $       epi,ncn2,bremsa,bremsint,
     $       zrems,zremso,elumab,elumabo,elum,elumo,
     $       decomp,ecomp,sxcomp,
     $       tau0,tauc,
     $       idat1,rdat1,kdat1,nptrs,np2,
     $       npar,npnxt,npfi,npfirst,
     $       nplin,nplini,nlsvn,npcon,npconi,npilev,npilevi,
     $       npconi2,nlevs,ncsvn,rates,vsav,idrates,
     $       xii,rrrt,pirt,htt,cll,httot,cltot,hmctot,elcter,
     $         cllines,clcont,htcomp,clcomp,clbrems,
     $       xilev,bilev,rniss,nmat,
     $       rcem,oplin,rccemis,brcems,opakc,opakscatt,cemab,
     $       opakab,fline,flinel)
c
       lpri=lprisv
c
c
      return
      end
