*deck,uel104       USERDISTRIB  parallel                                pck
      subroutine uel104 (elem,ielc,elmdat,eomask,nodes,locsvrL,kelreq,
     x kelfil,nr,xyz,u,kelout,zs,zass,damp,gstif,zsc,zscnr,elvol,elmass,
     x center,elener,edindxL,lcerstL)
c
c --- This is an exact copy of uel101 (for testing purposes) ---

c         *** Copyright ANSYS.  All Rights Reserved.
c         *** ansys, inc.

c *** Notice - This file contains ANSYS Confidential information ***

c         *** Copyright ANSYS.  All Rights Reserved.
c         *** ansys, inc.

c  input arguments:
c       elem   (int,sc,in)         - element label (number)
c       ielc   (int,ar(IELCSZ),in) - array of element type characteristics
c                                     (IELCSZ = array size, defined in echprm)
c       elmdat (int,ar(EL_DIM),in) - array of element data
c       eomask (int,sc,in)         - bit pattern for element output
c                                    (see outpcm)
c       nodes  (int,ar(nnod),in)   - array of element node numbers
c                                     (nnod = number of nodes; 2 in this case)
c       locsvrL (LONGINT,sc,in)     - location of the saved variables
c                                               on file .esav for this element
c       kelreq (int,ar(10),in)     - matrix and load vector form requests
c                                    (indices for kelreq are given with output
c                                                             arguments below)
c       kelfil (int,ar(10),in)     - keys indicating incoming matrices and
c                                      load vectors (indices for kelfil are the
c                                      same as given for kelreq with output
c                                      arguments below)
c       nr     (int,sc,in)         - matrix and load vector size
c       xyz    (dp,ar(6,nnod),in)  - nodal coordinates (orig) and rotation angle
c       u      (dp,ar(nr,5),in)    - element nodal solution values

c  output arguments:
c       kelout (int,ar(10),out)    - keys indicating created matrices and
c                                         load vectors (indices for kelout
c                                            are the same as for kelreq below,
c                                            as well as kelin and kelout later)
c       zs     (dp,ar(nr,nr),inout)- stiffness/conductivity matrix (kelreq(1))
c       zass   (dp,ar(nr,nr),inout)- mass matrix                   (kelreq(2))
c       damp   (dp,ar(nr,nr),inout)- damping/specific heat matrix  (kelreq(3))
c       gstif  (dp,ar(nr,nr),inout)- stress stiffness matrix       (kelreq(4))
c       zsc    (dp,ar(nr),out)     - applied f vector              (kelreq(5))
c       zscnr  (dp,ar(nr),out)     - n-r restoring f vector        (kelreq(6))
c                                    or imaginary f vector         (kelreq(7))
c       elvol  (dp,sc,out)         - element volume
c       elmass (dp,sc,out)         - element mass
c       center (dp,ar(3),out)      - centroid location
c       elener (dp,ar(5),out)      - element energies
c       edindxL(LONG,ar(25),out)   - element result data file indexes
c       lcerstL(LONG,sc,inout)     - position on result file

c     ---- start of comdecks ___
#include "impcom.inc"
#include "ansysdef.inc"
#include "elparm.inc"
#include "echprm.inc"
#include "seldcm.inc"
c     ---- end of comdecks ___

      external TrackBegin, TrackEnd
      external erhandler,pstev1,svgidx,svrget,rvrget,plast1,
     x subrd,subwrt,xyzup3,mreuse,creep1,swell1,
     x uep104,usereo,trrot,svrput,hvrput,svpidx,mctac,
     x matxv,vzero,vmove,viinit,vamb,tmpget,fluget,tranx3,
     x vapb1,vapb,eldwrtL,eldwrnL,nlpropcheckL

      external erinqr,wrinqr,elLenPsvrBuf
      integer  erinqr,wrinqr,elLenPsvrBuf
      external         dist3d
      double precision dist3d

c     --- arguments
      LONGINT  locsvrL, lcerstL, edindxL(25)
      integer elem,ielc(IELCSZ),elmdat(EL_DIM),eomask,nodes(2),
     x kelreq(10),kelfil(10),nr,kelout(10)

c     --- local
      integer mat,ireal,dead,nrvr,nssvr,nnrsvr,npsvr,ncsvr,nusvr,
     x plopt,cropt,swopt,ktherm,kfluen,
     x kelin(10),nudb,svindx(20),iott,i,ii,j,jj,kforce,ktev,keptho,
     x kepino,lenAdd,keypls,keycrp
      LONGINT  keyplsL, keycrpL, keyswlL, kpcsL

c     --- arguments
      double precision
     x xyz(6,2),u(nr,5),zs(nr,nr),zass(nr,nr),damp(nr,nr),gstif(nr,nr),
     x zsc(nr),zscnr(nr),elvol,elmass,center(3),elener(5)

c     --- rvr,ssvr,nrsvr,psvr,csvr
      double precision
     x rvr(2), area,epinit,
     x ssvr(21),
     x eptho,epino,propo(5),tembeg(2),temold(2),rvro(2),spbsv(8),
     x nrsvr(25),
     x eptot,eptotn,epdth,epswel,flubeg(2),fluold(2),
     x tr(3,3),spnrsv(8),
cc     x psvr(9),
     x psvr(3+20+3),
     x eppl,epeq,plwork,
ccpstate(6),
     x csvr(9),
     x epcrp,crwork,cstate(7)

c     --- properties
      double precision
     x ex,prxy,gxy,alpx,dens

c     --- local
      double precision
     x prop(5),tref,tempev,xyzup(3,2),dep,sigepl,sigrat,shpres,epth,
     x sig,vect(10),alenv,aleng,force,tro(3,3),epel,temend(2),fluend(2),
     x tem(2),deltem(2),avetem,dtem,fluen(2),delflu(2),aveflu,dflu,
     x et,con,eplv,tev(1),zscse(6),extho(1),exino(1),dg(3),drot(3)

c     ---- start of comdecks ___
#include "soptcm.inc"
#include "stepcm.inc"
#include "elecom.inc"
#include "elucom.inc"
#include "outpcm.inc"
#include "usvrcm.inc"
c     ---- end of comdecks ___

      equivalence
     x (area,rvr(1)), (epinit,rvr(2))
      equivalence
     x (eptho,ssvr(1)), (epino,ssvr(2)),
     x (propo(1),ssvr(3)), (tembeg(1),ssvr(8)),
     x (temold(1),ssvr(10)), (rvro(1),ssvr(12)),
     x (spbsv(1),ssvr(14))
      equivalence
     x (eptot,nrsvr(1)), (eptotn,nrsvr(2)),
     x (epdth,nrsvr(3)), (epswel,nrsvr(4)),
     x (flubeg(1),nrsvr(5)), (fluold(1),nrsvr(7)),
     x (tr(1,1),nrsvr(9)), (spnrsv(1),nrsvr(18))
      equivalence
     x (eppl,psvr(1)), (epeq,psvr(2)),
     x (plwork,psvr(3))
cc, (pstate(1),psvr(4))
      equivalence
     x (epcrp,csvr(1)), (crwork,csvr(2)),
     x (cstate(1),csvr(3))
      equivalence
     x (ex,prop(1)), (prxy,prop(2)),
     x (gxy,prop(3)), (alpx,prop(4)),
     x (dens,prop(5))

      call TrackBegin ('uel104')

c --- define initial data
c     --- elmdat pointers defined in elparm
      mat = elmdat(EL_MAT)
      ireal = elmdat(EL_REAL)
      dead = elmdat(EL_DEAD)
c     --- ielc pointers defined in echprm and elccmt
      nrvr = ielc(NMTRLC)
      nssvr = ielc(NMSSVR)
      nnrsvr = ielc(NMNSVR)
      npsvr = ielc(NMPSVR)
      ncsvr = ielc(NMCSVR)
      nusvr = ielc(NMUSVR)
c --- get the svr index vector
      call svgidx (locsvrL,svindx(1))

c --- get the element real constant data
      call rvrget (elem,ireal,ielc(1),nrvr,rvr(1))

c --- get the element base saved variables
      call svrget (svindx(1),1,nssvr,ssvr(1))

c --- get the element current temperatures
      call nlpropcheckL (mat,tref,keyplsL,plopt,keycrpL,cropt,
     x                  keyswlL,swopt)
      if (sestrs.eq.0) then
c        --- non-superlement:
         call tmpget (elem,ielc(1),2,nodes(1),tref,2,tembeg(1),
     x     tem(1),temend(1),ktherm)
         avetem = 0.5d0*(tem(1) + tem(2))
         tev(1) = avetem
         if (kfstps.eq.1) call vmove (tembeg(1),temold(1),2)
         call vamb (tem(1),temold(1),deltem(1),2)
      else
c        --- restore data if a superelement stress pass:
         call subrd (elem,1,2,tem(1),ktherm)
         call vzero (deltem(1),2)
         avetem = 0.5d0*(tem(1) + tem(2))
         call subrd (elem,30,1,tev(1),ktev)
         call subrd (elem,14,1,extho(1),keptho)
         eptho = extho(1)
         call subrd (elem,16,1,exino(1),kepino)
         epino = exino(1)
         call subrd (elem,20,nr,zscse(1),kforce)
c        *** combine loads with acceleration loads already in zsc ***
         if (kelfil(5) .eq. 1) then
            call vapb1(zsc(1),zscse(1),nr)
         else
            call vmove(zscse(1),zsc(1),nr)
            kelout(5) = 1
         endif
      endif

c --- initializations
c     --- zero load data
      epth = 0.0d0
      if (kfstps.eq.1) then
         eptho = 0.0d0
         epino = 0.0d0
      endif
c     --- scale initial strain
      epinit = sclrvr*epinit
c     --- scale element loads used for stress calculations
      if (scleld.ne.1.0d0) then
         epino = scleld*epino
         eptho = scleld*eptho
      endif

c --- get the material properties
c     --- linear material properties
      tempev = tev(1)

c     *** compute materials for only first substructure generation
c     *** step, carry to later steps in prop part of ssvr ***
c     *** rev5.1 11/3/93
      if (antype .eq. 7) then
         if ((semake.eq.1 .and. kfstps.eq.1) .or. nssvr.eq.0) then
            call pstev1 (elem,mat,tempev,prop(1))
         else
            call vmove (propo(1),prop(1),5)
         endif
      else
c     *** compute materials for every pass for non-substructure
         call pstev1 (elem,mat,tempev,prop(1))
      endif

      et = ex
      kpcsL = keyplsL + keycrpL + keyswlL
      if (keyplsL.gt.0 .or. keycrpL.gt.0 .or. keyswlL.gt.0) then
         dtem = 0.5d0*(deltem(1) + deltem(2))
      endif

c --- retrieve the nonlinear history saved variables
c     --- nonlinear (n-r) variables
      if (nrkey.eq.1) then
         call svrget (svindx(1),4,nnrsvr,nrsvr(1))
      else
c        --- zero out variables that may be referenced
         epswel = 0.0d0
         call vzero (flubeg(1),2)
         call vzero (fluold(1),2)
      endif
c     --- plasticity variables
      if (keyplsL.gt.0) then
         lenAdd = elLenPsvrBuf (mat,plopt,1)
         npsvr = npsvr + lenAdd*1
         call svrget (svindx(1),5,npsvr,psvr(1))
      elseif (kpcsL.gt.0) then
c        --- zero out variables that may be referenced
         eppl = 0.0d0
         epeq = 0.0d0
         plwork = 0.0d0
      endif
c     --- creep variables
      if (keycrpL.gt.0) then
         call svrget (svindx(1),6,ncsvr,csvr(1))
      elseif (kpcsL.gt.0) then
         epcrp = 0.0d0
      endif
c     --- user-defined variables
      if (nusvr.gt.0) call svrget (svindx(1),8,nusvr,usvr(1))

c --- get the element current fluences
      call fluget (elem,ielc(1),2,nodes(1),2,flubeg(1),
     x  fluen(1),fluend(1),kfluen)
      aveflu = 0.5d0*(fluen(1) + fluen(2))
      if (kfstps.eq.1) call vmove (flubeg(1),fluold(1),2)
      call vamb (fluen(1),fluold(1),delflu(1),2)
      dflu = 0.5d0*(delflu(1) + delflu(2))

c --- geometry computations
c     *** rotation matrix for large deflection superelement ***
      if (senlgm .eq. 1) then
         call vamb (xyz(1,2),xyz(1,1),dg(1),3)
         call matxv (setrr(1,1),dg(1),drot(1), 3,3)
         call vapb (xyz(1,1),drot(1),xyz(1,2),3)
      endif
c     --- compute original length
      con = dist3d (xyz(1,1),xyz(1,2))
      alenv = sqrt (con)
      if (kfstps.eq.1 .and. alenv.le.0.0d0) then
         call erhandler ('uel104',3000,
     x                3,'Element %I has a zero length',dble(elem),' ')
         go to 999
      endif
c     --- compute transformations
      if (nlgeom.eq.0) then
c        --- small deformation - compute original tranformation
         call tranx3 (2,xyz(1,1),6,tr(1,1))
         call vmove (tr(1,1),tro(1,1),9)
      else
c        --- update the coordinates in a large deformation analysis
         call xyzup3 (2,u(1,putot),nr,xyz(1,1),6,xyzup(1,1))
c        --- compute and check current length
         con = dist3d (xyzup(1,1),xyzup(1,2))
         if (con.le.0.0d0) then
            call erhandler ('uel104',3010,
     x                3,'Element %I has a zero length',dble(elem),' ')
            go to 999
         endif
         aleng = sqrt (con)
c        --- update transformation terms - 1st save original terms
         if (kfstps.eq.0) then
            call vmove (tr(1,1),tro(1,1),9)
         endif
         call tranx3 (2,xyzup(1,1),3,tr(1,1))
      endif
c     --- adjust length for any initial strain accumulated when dead
      if (nrkey.eq.1) then
         alenv = alenv*(1.0d0 + epdth)
         if (nlgeom.eq.1) aleng = aleng + epdth*alenv
      endif
c     --- compute element mass and centroid
      elvol = alenv*(1.0d0 - epinit)*area
      elmass = dens*elvol
      center(1) = (xyz(1,1) + xyz(1,2))*0.5d0
      center(2) = (xyz(2,1) + xyz(2,2))*0.5d0
      center(3) = (xyz(3,1) + xyz(3,2))*0.5d0

c --- check error key  --------------------------------
      if (erinqr(1) .eq. 1) go to 999

c --- set matrix and vector formation keys
c     --- test if material properties or real constants have changed
      call mreuse (kelreq(1),kelfil(1),elem,ielc(1),0,0,i,0,3,5,
     x prop(1),propo(1),0,rvr(1),rvro(1),con,con,kelin(1))

c --- if dead suppress material nonlinearities and force matrix reformation
      if (dead.eq.1) then
         eptho = 0.0d0
         epino = 0.0d0
         kelin(1) = 1
         if (keyplsL.gt.0) then
            call vzero (psvr(1),npsvr)
         endif
         if (keycrpL.gt.0) then
            call vzero (csvr(1),ncsvr)
         endif
         if (keyswlL.gt.0) then
            epswel = 0.0d0
         endif
         kpcsL = 0
      endif

c --- compute stresses
      if (outkey.eq.1 .or. nrkey.eq.1 .or. sstif.ne.0) then
c        --- calculate total strain
         if (nrkey.eq.0) then
            eptot = (tr(1,1)*(u(4,putot) - u(1,putot)) +
     x               tr(1,2)*(u(5,putot) - u(2,putot)) +
     x               tr(1,3)*(u(6,putot) - u(3,putot)))/ alenv
         elseif (nlgeom.eq.1) then
            eptot = aleng/alenv - 1.0d0
         elseif (puinci.gt.0) then
c           --- insure that the inc disps are available - we may follow a nl
c           --- run with a linear run and we just want the tangent
            dep = (tro(1,1)*(u(4,puinci) - u(1,puinci)) +
     x             tro(1,2)*(u(5,puinci) - u(2,puinci)) +
     x             tro(1,3)*(u(6,puinci) - u(3,puinci)))/ alenv
            eptot = eptot + dep
         endif
c        ---  elastic strain - adjust for thermal, initial and nonlin strains
         epel = eptot - eptho + epino
         if (kpcsL.gt.0) epel = epel - eppl - epcrp - epswel
c        --- if dead, set the initial strains to the current strain state
         if (dead.eq.1) epdth = epel
c        --- adjust for any initial strains accumulated when dead
         if (nrkey.eq.1) epel = epel - epdth
c        --- plasticity adjustment
         if (keyplsL.gt.0) then
            call plast1 (plopt,elem,1,mat,keyplsL,tem,dtem,ex,kplupd,
     x        dens,aveflu,dflu,epel,eppl,psvr(4),usvr(1),epeq,plwork,
     x        sigepl,sigrat,et)
         endif
c        --- update stress
         sig = ex*epel
c        --- creep adjustment
         if (keycrpL.gt.0) then
            call creep1 (cropt,elem,1,mat,keycrpL,epel,ex,epcrp,
     x        cstate(1),usvr(1),avetem,dtem,aveflu,dflu,sig)
         endif
c        --- swelling
         if (keyswlL.gt.0) then
            call swell1 (swopt,elem,1,mat,keyswlL,epswel,epel,ex,
     x        aveflu,dflu,avetem,dtem,usvr(1))
         endif
c        --- compute force
         force = area*sig
c        --- strain energy
         elener(1) = 0.5d0*sig*epel*elvol
         if (keyplsL.gt.0) then
            con = plwork*elvol
            elener(1) = elener(1) + con
            elener(4) = con
         endif
         if (keycrpL.gt.0) elener(5) = crwork*elvol
      endif

c --- stiffness matrix
      if (kelin(1).eq.1) then
         call vzero (zs(1,1),36)
         zs(1,1) = et*area/alenv
         call mctac (zs(1,1),nr,tr(1,1),3, 3,3)
         do 452 i = 1,3
            ii = i + 3
            do 451 j = 1,3
               jj = j + 3
               zs(ii,j)  = -zs(i,j)
               zs(i,jj)  = -zs(i,j)
               zs(ii,jj) =  zs(i,j)
  451       continue
  452    continue
         kelout(1) = 1
      endif

c --- mass matrix
      if (kelin(2).eq.1) then
         call vzero (zass(1,1),36)
         if (lumpm.eq.0) then
c           --- consistent mass matrix
            con = alenv*(1.0d0 - epinit)*dens*area/6.0d0
            do 460 i = 1,3
               ii = i + 3
               zass(i,ii) = con
               zass(ii,i) = con
  460       continue
            con = 2.0d0*con
            call viinit (zass(1,1),7,6,con)
         else
c           --- lumped mass matrix
            con = 0.5d0*alenv*(1.0d0 - epinit)*dens*area
            call viinit (zass(1,1),7,6,con)
         endif
         kelout(2) = 1
      endif

c --- damping/specific heat matrix
      if (kelin(3) .eq. 1) then
c        **** dummy damping
         damp(1,1) = 0.0d0
         kelout(3) = 1
      endif

c --- stress stiffness matrix
      if (kelin(4).eq.1) then
         call vzero (gstif(1,1),36)
         con = epel
         if (kfstps.eq.1) con = epinit
         con = area*ex*con
         if (con.ne.0.0d0) then
            con = con/alenv
            gstif(2,2) = con
            gstif(3,3) = con
            call mctac (gstif(1,1),nr,tr(1,1),3, 3,3)
            do 472 i = 1,3
               ii = i + 3
               do 471 j = 1,3
                  jj = j + 3
                  gstif(ii,j)  = -gstif(i,j)
                  gstif(i,jj)  = -gstif(i,j)
                  gstif(ii,jj) =  gstif(i,j)
  471          continue
  472       continue
         endif
         kelout(4) = 1
      endif

c --- applied load vector
      epth = alpx*(avetem-tref)
      if (kelin(5).eq.1) then
         if (nrkey.eq.0) then
            eplv = epth - epinit
         else
            eplv = epth - eptho - epinit + epino
         endif
         vect(1) = eplv*area*et
         vect(2) = 0.0d0
         vect(3) = 0.0d0
         call matxv (tr(1,1),vect(1),zsc(4), 3,3)
         zsc(1) = -zsc(4)
         zsc(2) = -zsc(5)
         zsc(3) = -zsc(6)
         kelout(5) = 1
      endif

c --- restoring force for newton-raphson
      if (kelin(6).eq.1) then
         vect(1) = force
         vect(2) = 0.0d0
         vect(3) = 0.0d0
         call matxv (tr(1,1),vect(1),zscnr(4), 3,3)
         zscnr(1) = -zscnr(4)
         zscnr(2) = -zscnr(5)
         zscnr(3) = -zscnr(6)
         kelout(6) = 1
      endif

c --- produce output
      if (outkey.eq.1) then
         iott = wrinqr(2)
c        --- write out results
         if (btest(eomask,PPRE)) then
            shpres = sig/3.0d0
            keypls = 0
            if (keyplsL.gt.0) keypls = 1
            keycrp = 0
            if (keycrpL.gt.0) keycrp = 1
            call uep104 (iott,elem,nodes(1),mat,ktherm,tem(1),
     x        kfluen,fluen(1), 1,force, 1,sig, 1,epel,
     x        1,eptho,epswel,epino,
     x        keypls,sigepl,sigrat,shpres,epeq,
     x        keypls,eppl, keycrp,epcrp)
         endif
c        --- call user routine to produce data
         call usereo (elem,iott,nssvr,ssvr(1),nnrsvr,nrsvr(1),npsvr,
     x     psvr(1),ncsvr,csvr(1),nusvr,usvr(1),2,nodes(1),xyz(1,1),
     x     elvol,aleng,timval,timinc,nr,u(1,putot),
     x     ielc(NMNMUP),nudb,udbdat(1))
c        --- database results
         if (btest(eomask,PDBE)) then
            call eldwrtL (elem,EDEPT,lcerstL,edindxL(1),2,tem(1))
            if (keyplsL.gt.0 .or. nlgeom.eq.1) then
               call vzero (vect(1),10)
               if (keyplsL.gt.0) then
                  vect(1) = sigepl
                  vect(2) = sigrat
                  vect(3) = sig/3.0d0
                  vect(4) = epeq
               endif
               if (nlgeom.eq.1) then
                  call trrot (tr(1,1),vect(8))
               endif
               call eldwrtL (elem,EDENL,lcerstL,edindxL(1),10,vect(1))
            endif
            if (btest(eomask,PDBSIG)) then
               vect(1) = sig
               call eldwrtL (elem,EDENS,lcerstL,edindxL(1),1,vect(1))
            endif
            if (btest(eomask,PDBEEL)) then
               vect(1) = epel
               call eldwrtL (elem,EDEEL,lcerstL,edindxL(1),1,vect(1))
            endif
            if (btest(eomask,PDBEPL) .and. keyplsL.gt.0) then
               vect(1) = eppl
               call eldwrtL (elem,EDEPL,lcerstL,edindxL(1),1,vect(1))
            endif
            if (btest(eomask,PDBECR) .and. keycrpL.gt.0) then
               vect(1) = epcrp
               call eldwrtL (elem,EDECR,lcerstL,edindxL(1),1,vect(1))
            endif
            if (btest(eomask,PDBETH)) then
               vect(1) = eptho
               vect(2) = epswel
               vect(3) = epino
               call eldwrtL (elem,EDETH,lcerstL,edindxL(1),3,vect(1))
            endif
            if (btest(eomask,PDBMIS)) then
               call vzero (vect(1),ielc(NMSMIS))
               vect(1) = force
               call eldwrtL (elem,EDEMS,lcerstL,edindxL(1),
     x                      ielc(NMSMIS),vect(1))
               vect(1) = fluen(1)
               vect(2) = fluen(2)
               call eldwrnL (elem,ielc(1),lcerstL,edindxL(1),
     x                      nudb,udbdat(1),ielc(NMNMIS),vect(1),10)
            endif
         endif
      endif
c  --- update past temperature information
c      --- set temperature at beginning of next load step to end of this step
      if (kupbc.eq.1)then
         call vmove (temend(1),tembeg(1),2)
         call vmove (fluend(1),flubeg(1),2)
      endif
c     --- set temperature at beginning of next substep to end of this substep
      if (kuptpr.eq.1) then
         call vmove (tem(1),temold(1),2)
         call vmove (fluen(1),fluold(1),2)
      endif
c     --- set thermal strains at beginning of next iter to end of this iter
      eptho = epth
      epino = epinit

c --- write out the element saved variables
c     --- base variables
  999 call svrput (svindx(1),1,nssvr,ssvr(1))
c     --- nonlinear variables
      if (nrkey.eq.1) call svrput (svindx(1),4,nnrsvr,nrsvr(1))
c     --- plasticity variables
      if (keyplsL.gt.0)
     x call hvrput (kfstps,kuphvr,svindx(1),5,npsvr,psvr(1))
c     --- creep variables
      if (keycrpL.gt.0)
     x call hvrput (kfstps,kuphvr,svindx(1),6,ncsvr,csvr(1))
c     --- user-defined variables
      if (nusvr.gt.0) call svrput (svindx(1),8,nusvr,usvr(1))
c     --- write out the svr index vector
      call svpidx (locsvrL,svindx(1))

c --- save data if a superelement generation run
      if (semake.eq.1) then
         call subwrt (elem,ldstep,1,2,tem(1),tref)
         call subwrt (elem,ldstep,30,1,tev(1),0.0d0)
         extho(1) = eptho
         call subwrt (elem,ldstep,14,1,extho(1),0.0d0)
         exino(1) = epino
         call subwrt (elem,ldstep,16,1,exino(1),0.0d0)
         call subwrt (elem,ldstep,20,nr,zsc(1),0.0d0)
      endif

      call TrackEnd ('uel104')
      return
      end
