      SUBROUTINE GUSTEP
C+SEQ, GCKINE.
      COMMON /GCKINE/ IKINE,PKINE(10),ITRA,ISTAK,IVERT,IPART,ITRTYP,
     +    NAPART(5),AMASS,CHARGE,TLIFE,VERT(3),PVERT(4),IPAOLD
c                                                           
c-----------------------------------------------------------------------------
      include 'ntpl.inc'
c-----------------------------------------------------------------------------
      COMMON/GCTRAK/VECT(7),GETOT,GEKIN,VOUT(7),NMEC,LMEC(30),NAMEC(30)  
     + ,NSTEP ,MAXNST,DESTEP,DESTEL,SAFETY,SLENG ,STEP  ,SNEXT ,SFIELD   
     + ,TOFG  ,GEKRAT,UPWGHT,IGNEXT,INWVOL,ISTOP ,IGAUTO,IEKBIN, ILOSL   
     + , IMULL,INGOTO,NLDOWN,NLEVIN,NLVSAV,ISTORY        

      COMMON/GCKING/KCASE,NGKINE,GKIN(5,100),TOFD(100),IFLGK(100)          

      COMMON/GCVOLU/NLEVEL,NAMES(15),NUMBER(15),
     +LVOLUM(15),LINDEX(15),INFROM,NLEVMX,NLDEV(15),LINMX(15),
     +GTRAN(3,15),GRMAT(10,15),GONLY(15),GLX(3)
      INTEGER NLEVEL,NAMES,NUMBER,LVOLUM,LINDEX,INFROM,NLEVMX,
     +        NLDEV,LINMX
      REAL GTRAN,GRMAT,GONLY,GLX

      COMMON/GCKIN3/GPOS(3,100)

      COMMON/GCSETS/IUSET,IUDET,ISET,IDET,IDTYPE,NVNAME,NUMBV(20)        
      COMMON/GCTMED/ NUMED,NATMED(5),ISVOL,IFIELD,FIELDM,TMAXFD,DMAXMS, 
     +  DEEMAX,EPSIL,STMIN,CFIELD,CMULS,IUPD,ISTPAR,NUMOLD           
      COMMON/GCFLAG/IDEBUG,IDEMIN,IDEMAX,ITEST,IDRUN,IDEVT,IEORUN,     
     +          IEOTRI,IEVENT,ISWIT(10),IFINIT(20),NEVENT,NRNDM(2)      

      integer med(30),ii
      data med/ 4*0, 1, 3*0, 1, 0, 2, 7*0, 1, 0, 1, 0, 1, 0, 1, 0,
     +            1, 0 , 1, 0/
      data init/0/, am/0.93957/
      dimension xlab(3), xquad(3), ulab(3), uquad(3), rndm(2)
      include 'jbgsav.inc'
c--------------------------------*** this is a temporary fix ***
      if(init.eq.0) then
         init = 1
         maxnst = 1000000
      end if

      if (IEOTRI.eq.1) return

      call jbgtrk(3)

      IF(NGKINE.GT.0) THEN            ! Secondary particles generated   
         DO IT=1,NGKINE
            ip = gkin(5,it)
            if(ip.le.3.or.ip.eq.13) then
               CALL GSKING(IT)  ! store particles in stack              
               call jbgtrk(6)
            else
c               write(6,622) ip
c 622           format(2x,'*** particle not transported IPART=',i4)
            end if
         end do                                                 
      endif

c      write(6,708) ipart,(vect(ii),ii=1,6),destep,inwvol,numed
c 708  format(2x,i3,3f10.5,3f10.5,' edep=',e12.5,2i3)

      if(lentry.and.nh.lt.nb.and.(abs(vect(1)).gt.5e-3*vect(3))) then
cx      if(destep.gt.0.0.and.inwvol.eq.2) then
c         write(6,777)
c 777     format(2x,'** hit **')
         call jbgtrk(7)
         call rnorml(rndm, 2)
         nh = nh + 1
         irl(nh) = itra
         ql(nh) = charge
         el(nh) = getot
cx         xl(nh) = vect(1) + 0.0010 * rndm(1)
cx         yl(nh) = vect(2) + 0.0010 * rndm(2)
         xl(nh) = vect(1) 
         yl(nh) = vect(2) 
         zl(nh) = vect(3)
         ul(nh) = vect(4)
         vl(nh) = vect(5)
         wl(nh) = vect(6)
         ph(nh) = primhit
         fh(nh) = farhit
         evnt(nh) = ievnt
c         write(6,709) itra,istak,vect,lvolum(nlevel)
c 709     format(2x,'itra,istak=',2i3,7f10.5,' vol=',i3)
      end if

c      write(6,709) vect(1),vect(2),vect(3),lvolum(nlevel),inwvol
c 709  format(2x,3f10.3,2i4)
c-----------------
      call gdcxyz   ! this added for the interactive version        
c-----------------

      return                                                                  
      END
