
c/* %W%      latest revision %G% %U% */
      subroutine Tcex ( tr, ti, tbr, tbi, sigl, ldum, nsex, n )
********************************************************************************

      implicit real*8 (a-h, o-z)

      dimension tbr(100,12), tbi(100,12), tr(100,12),ti(100,12)
      dimension   nifty(20)

      common /switch/   nifty

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

      l = ldum
      rhl6 = COS( 2. * sigl )
      rhl7 = SIN( 2. * sigl )

c *** mods for proton with 6 possible spins and delayed evaluation

      np2m = n + 2
      if (nifty(6) .eq. 8) np2m = n + 6
      np2i = np2m
      if (n .eq. 6) np2i = 9
      if ((n .gt. 2) .AND. (n .lt. 6)) then
         RETURN
      endif
      nx = n

c *** 1st time thru, store t"s

      if (nsex .ne. 2) then
         do 10 np2 = np2i,np2m
            if (np2i .eq. 9) nx = np2 - 6
            tbr(l,np2) = tbr(l,nx)
            tbi(l,np2) = tbi(l,nx)
            tr(l,np2) = tr(l,nx)
            ti(l,np2) = ti(l,nx)
  10     continue

c *** 2nd time thru, take difference and store for latter

      else
         do 20 np2 = np2i,np2m
            if (np2i .eq. 9) nx = np2 - 6
            tbr(l,np2) = tbr(l,np2) - tbr(l,nx)
            tbi(l,np2) = tbi(l,np2) - tbi(l,nx)
            tr(l,np2) = tr(l,np2) - tr(l,nx)
            ti(l,np2) = ti(l,np2) - ti(l,nx)
  20     continue
      endif

      RETURN
      end
