      SUBROUTINE eomccsdt_y2_10_1(d_a,k_a_offset,d_c,k_c_offset)
C     $Id: eomccsdt_y2_all12.F 24184 2013-05-04 00:43:17Z edo $
C     This is a Fortran77 program generated by Tensor Contraction Engine v.1.0
C     Copyright (c) Battelle & Pacific Northwest National Laboratory (2002)
C     i1 ( h3 p13 h11 h14 )_v + = -1 * v ( h3 p13 h11 h14 )_v
      IMPLICIT NONE
#include "global.fh"
#include "mafdecls.fh"
#include "sym.fh"
#include "errquit.fh"
#include "tce.fh"
      INTEGER d_a
      INTEGER k_a_offset
      INTEGER d_c
      INTEGER k_c_offset
      INTEGER NXTASK
      INTEGER next
      INTEGER nprocs
      INTEGER count
      INTEGER h3b
      INTEGER p13b
      INTEGER h11b
      INTEGER h14b
      INTEGER dimc
      INTEGER h3b_1
      INTEGER p13b_1
      INTEGER h11b_1
      INTEGER h14b_1
      INTEGER dim_common
      INTEGER dima_sort
      INTEGER dima
      INTEGER l_a_sort
      INTEGER k_a_sort
      INTEGER l_a
      INTEGER k_a
      INTEGER l_c
      INTEGER k_c
      EXTERNAL NXTASK
      nprocs = GA_NNODES()
      count = 0
      next = NXTASK(nprocs,1)
      DO h3b = 1,noab
      DO p13b = noab+1,noab+nvab
      DO h11b = 1,noab
      DO h14b = h11b,noab
      IF (next.eq.count) THEN
      IF ((.not.restricted).or.(int_mb(k_spin+h3b-1)+int_mb(k_spin+p13b-
     &1)+int_mb(k_spin+h11b-1)+int_mb(k_spin+h14b-1).ne.8)) THEN
      IF (int_mb(k_spin+h3b-1)+int_mb(k_spin+p13b-1) .eq. int_mb(k_spin+
     &h11b-1)+int_mb(k_spin+h14b-1)) THEN
      IF (ieor(int_mb(k_sym+h3b-1),ieor(int_mb(k_sym+p13b-1),ieor(int_mb
     &(k_sym+h11b-1),int_mb(k_sym+h14b-1)))) .eq. irrep_v) THEN
      dimc = int_mb(k_range+h3b-1) * int_mb(k_range+p13b-1) * int_mb(k_r
     &ange+h11b-1) * int_mb(k_range+h14b-1)
      CALL TCE_RESTRICTED_4(h3b,p13b,h11b,h14b,h3b_1,p13b_1,h11b_1,h14b_
     &1)
      dim_common = 1
      dima_sort = int_mb(k_range+h3b-1) * int_mb(k_range+p13b-1) * int_m
     &b(k_range+h11b-1) * int_mb(k_range+h14b-1)
      dima = dim_common * dima_sort
      IF (dima .gt. 0) THEN
      IF (.not.MA_PUSH_GET(mt_dbl,dima,'noname',l_a_sort,k_a_sort)) CALL
     & ERRQUIT('eomccsdt_y2_10_1',0,MA_ERR)
      IF (.not.MA_PUSH_GET(mt_dbl,dima,'noname',l_a,k_a)) CALL ERRQUIT('
     &eomccsdt_y2_10_1',1,MA_ERR)
      IF ((h3b .le. p13b)) THEN
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(h14b_
     &1 - 1 + (noab+nvab) * (h11b_1 - 1 + (noab+nvab) * (p13b_1 - 1 + (n
     &oab+nvab) * (h3b_1 - 1)))))
      CALL TCE_SORT_4(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+h3b-1)
     &,int_mb(k_range+p13b-1),int_mb(k_range+h11b-1),int_mb(k_range+h14b
     &-1),4,3,2,1,1.0d0)
      END IF
      IF (.not.MA_POP_STACK(l_a)) CALL ERRQUIT('eomccsdt_y2_10_1',2,MA_E
     &RR)
      IF (.not.MA_PUSH_GET(mt_dbl,dimc,'noname',l_c,k_c)) CALL ERRQUIT('
     &eomccsdt_y2_10_1',3,MA_ERR)
      CALL TCE_SORT_4(dbl_mb(k_a_sort),dbl_mb(k_c),int_mb(k_range+h14b-1
     &),int_mb(k_range+h11b-1),int_mb(k_range+p13b-1),int_mb(k_range+h3b
     &-1),4,3,2,1,-1.0d0)
      CALL ADD_HASH_BLOCK(d_c,dbl_mb(k_c),dimc,int_mb(k_c_offset),(h14b 
     &- 1 + noab * (h11b - 1 + noab * (p13b - noab - 1 + nvab * (h3b - 1
     &)))))
      IF (.not.MA_POP_STACK(l_c)) CALL ERRQUIT('eomccsdt_y2_10_1',4,MA_E
     &RR)
      IF (.not.MA_POP_STACK(l_a_sort)) CALL ERRQUIT('eomccsdt_y2_10_1',5
     &,MA_ERR)
      END IF
      END IF
      END IF
      END IF
      next = NXTASK(nprocs,1)
      END IF
      count = count + 1
      END DO
      END DO
      END DO
      END DO
      next = NXTASK(-nprocs,1)
      call GA_SYNC()
      RETURN
      END
      SUBROUTINE eomccsdt_y2_10_2_1(d_a,k_a_offset,d_c,k_c_offset)
C     $Id: eomccsdt_y2_all12.F 24184 2013-05-04 00:43:17Z edo $
C     This is a Fortran77 program generated by Tensor Contraction Engine v.1.0
C     Copyright (c) Battelle & Pacific Northwest National Laboratory (2002)
C     i2 ( h3 h9 h11 h14 )_v + = 1 * v ( h3 h9 h11 h14 )_v
      IMPLICIT NONE
#include "global.fh"
#include "mafdecls.fh"
#include "sym.fh"
#include "errquit.fh"
#include "tce.fh"
      INTEGER d_a
      INTEGER k_a_offset
      INTEGER d_c
      INTEGER k_c_offset
      INTEGER NXTASK
      INTEGER next
      INTEGER nprocs
      INTEGER count
      INTEGER h3b
      INTEGER h9b
      INTEGER h11b
      INTEGER h14b
      INTEGER dimc
      INTEGER h3b_1
      INTEGER h9b_1
      INTEGER h11b_1
      INTEGER h14b_1
      INTEGER dim_common
      INTEGER dima_sort
      INTEGER dima
      INTEGER l_a_sort
      INTEGER k_a_sort
      INTEGER l_a
      INTEGER k_a
      INTEGER l_c
      INTEGER k_c
      EXTERNAL NXTASK
      nprocs = GA_NNODES()
      count = 0
      next = NXTASK(nprocs,1)
      DO h3b = 1,noab
      DO h9b = 1,noab
      DO h11b = 1,noab
      DO h14b = h11b,noab
      IF (next.eq.count) THEN
      IF ((.not.restricted).or.(int_mb(k_spin+h3b-1)+int_mb(k_spin+h9b-1
     &)+int_mb(k_spin+h11b-1)+int_mb(k_spin+h14b-1).ne.8)) THEN
      IF (int_mb(k_spin+h3b-1)+int_mb(k_spin+h9b-1) .eq. int_mb(k_spin+h
     &11b-1)+int_mb(k_spin+h14b-1)) THEN
      IF (ieor(int_mb(k_sym+h3b-1),ieor(int_mb(k_sym+h9b-1),ieor(int_mb(
     &k_sym+h11b-1),int_mb(k_sym+h14b-1)))) .eq. irrep_v) THEN
      dimc = int_mb(k_range+h3b-1) * int_mb(k_range+h9b-1) * int_mb(k_ra
     &nge+h11b-1) * int_mb(k_range+h14b-1)
      CALL TCE_RESTRICTED_4(h3b,h9b,h11b,h14b,h3b_1,h9b_1,h11b_1,h14b_1)
      dim_common = 1
      dima_sort = int_mb(k_range+h3b-1) * int_mb(k_range+h9b-1) * int_mb
     &(k_range+h11b-1) * int_mb(k_range+h14b-1)
      dima = dim_common * dima_sort
      IF (dima .gt. 0) THEN
      IF (.not.MA_PUSH_GET(mt_dbl,dima,'noname',l_a_sort,k_a_sort)) CALL
     & ERRQUIT('eomccsdt_y2_10_2_1',0,MA_ERR)
      IF (.not.MA_PUSH_GET(mt_dbl,dima,'noname',l_a,k_a)) CALL ERRQUIT('
     &eomccsdt_y2_10_2_1',1,MA_ERR)
      IF ((h9b .lt. h3b)) THEN
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(h14b_
     &1 - 1 + (noab+nvab) * (h11b_1 - 1 + (noab+nvab) * (h3b_1 - 1 + (no
     &ab+nvab) * (h9b_1 - 1)))))
      CALL TCE_SORT_4(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+h9b-1)
     &,int_mb(k_range+h3b-1),int_mb(k_range+h11b-1),int_mb(k_range+h14b-
     &1),4,3,1,2,-1.0d0)
      END IF
      IF ((h3b .le. h9b)) THEN
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(h14b_
     &1 - 1 + (noab+nvab) * (h11b_1 - 1 + (noab+nvab) * (h9b_1 - 1 + (no
     &ab+nvab) * (h3b_1 - 1)))))
      CALL TCE_SORT_4(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+h3b-1)
     &,int_mb(k_range+h9b-1),int_mb(k_range+h11b-1),int_mb(k_range+h14b-
     &1),4,3,2,1,1.0d0)
      END IF
      IF (.not.MA_POP_STACK(l_a)) CALL ERRQUIT('eomccsdt_y2_10_2_1',2,MA
     &_ERR)
      IF (.not.MA_PUSH_GET(mt_dbl,dimc,'noname',l_c,k_c)) CALL ERRQUIT('
     &eomccsdt_y2_10_2_1',3,MA_ERR)
      CALL TCE_SORT_4(dbl_mb(k_a_sort),dbl_mb(k_c),int_mb(k_range+h14b-1
     &),int_mb(k_range+h11b-1),int_mb(k_range+h9b-1),int_mb(k_range+h3b-
     &1),4,3,2,1,1.0d0)
      CALL ADD_HASH_BLOCK(d_c,dbl_mb(k_c),dimc,int_mb(k_c_offset),(h14b 
     &- 1 + noab * (h11b - 1 + noab * (h9b - 1 + noab * (h3b - 1)))))
      IF (.not.MA_POP_STACK(l_c)) CALL ERRQUIT('eomccsdt_y2_10_2_1',4,MA
     &_ERR)
      IF (.not.MA_POP_STACK(l_a_sort)) CALL ERRQUIT('eomccsdt_y2_10_2_1'
     &,5,MA_ERR)
      END IF
      END IF
      END IF
      END IF
      next = NXTASK(nprocs,1)
      END IF
      count = count + 1
      END DO
      END DO
      END DO
      END DO
      next = NXTASK(-nprocs,1)
      call GA_SYNC()
      RETURN
      END
      SUBROUTINE eomccsdt_y2_10_2_2_1(d_a,k_a_offset,d_c,k_c_offset)
C     $Id: eomccsdt_y2_all12.F 24184 2013-05-04 00:43:17Z edo $
C     This is a Fortran77 program generated by Tensor Contraction Engine v.1.0
C     Copyright (c) Battelle & Pacific Northwest National Laboratory (2002)
C     i3 ( h3 h9 h11 p5 )_v + = 1 * v ( h3 h9 h11 p5 )_v
      IMPLICIT NONE
#include "global.fh"
#include "mafdecls.fh"
#include "sym.fh"
#include "errquit.fh"
#include "tce.fh"
      INTEGER d_a
      INTEGER k_a_offset
      INTEGER d_c
      INTEGER k_c_offset
      INTEGER NXTASK
      INTEGER next
      INTEGER nprocs
      INTEGER count
      INTEGER h3b
      INTEGER h9b
      INTEGER h11b
      INTEGER p5b
      INTEGER dimc
      INTEGER h3b_1
      INTEGER h9b_1
      INTEGER h11b_1
      INTEGER p5b_1
      INTEGER dim_common
      INTEGER dima_sort
      INTEGER dima
      INTEGER l_a_sort
      INTEGER k_a_sort
      INTEGER l_a
      INTEGER k_a
      INTEGER l_c
      INTEGER k_c
      EXTERNAL NXTASK
      nprocs = GA_NNODES()
      count = 0
      next = NXTASK(nprocs,1)
      DO h3b = 1,noab
      DO h9b = 1,noab
      DO h11b = 1,noab
      DO p5b = noab+1,noab+nvab
      IF (next.eq.count) THEN
      IF ((.not.restricted).or.(int_mb(k_spin+h3b-1)+int_mb(k_spin+h9b-1
     &)+int_mb(k_spin+h11b-1)+int_mb(k_spin+p5b-1).ne.8)) THEN
      IF (int_mb(k_spin+h3b-1)+int_mb(k_spin+h9b-1) .eq. int_mb(k_spin+h
     &11b-1)+int_mb(k_spin+p5b-1)) THEN
      IF (ieor(int_mb(k_sym+h3b-1),ieor(int_mb(k_sym+h9b-1),ieor(int_mb(
     &k_sym+h11b-1),int_mb(k_sym+p5b-1)))) .eq. irrep_v) THEN
      dimc = int_mb(k_range+h3b-1) * int_mb(k_range+h9b-1) * int_mb(k_ra
     &nge+h11b-1) * int_mb(k_range+p5b-1)
      CALL TCE_RESTRICTED_4(h3b,h9b,h11b,p5b,h3b_1,h9b_1,h11b_1,p5b_1)
      dim_common = 1
      dima_sort = int_mb(k_range+h3b-1) * int_mb(k_range+h9b-1) * int_mb
     &(k_range+h11b-1) * int_mb(k_range+p5b-1)
      dima = dim_common * dima_sort
      IF (dima .gt. 0) THEN
      IF (.not.MA_PUSH_GET(mt_dbl,dima,'noname',l_a_sort,k_a_sort)) CALL
     & ERRQUIT('eomccsdt_y2_10_2_2_1',0,MA_ERR)
      IF (.not.MA_PUSH_GET(mt_dbl,dima,'noname',l_a,k_a)) CALL ERRQUIT('
     &eomccsdt_y2_10_2_2_1',1,MA_ERR)
      IF ((h9b .lt. h3b)) THEN
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(p5b_1
     & - 1 + (noab+nvab) * (h11b_1 - 1 + (noab+nvab) * (h3b_1 - 1 + (noa
     &b+nvab) * (h9b_1 - 1)))))
      CALL TCE_SORT_4(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+h9b-1)
     &,int_mb(k_range+h3b-1),int_mb(k_range+h11b-1),int_mb(k_range+p5b-1
     &),4,3,1,2,-1.0d0)
      END IF
      IF ((h3b .le. h9b)) THEN
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(p5b_1
     & - 1 + (noab+nvab) * (h11b_1 - 1 + (noab+nvab) * (h9b_1 - 1 + (noa
     &b+nvab) * (h3b_1 - 1)))))
      CALL TCE_SORT_4(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+h3b-1)
     &,int_mb(k_range+h9b-1),int_mb(k_range+h11b-1),int_mb(k_range+p5b-1
     &),4,3,2,1,1.0d0)
      END IF
      IF (.not.MA_POP_STACK(l_a)) CALL ERRQUIT('eomccsdt_y2_10_2_2_1',2,
     &MA_ERR)
      IF (.not.MA_PUSH_GET(mt_dbl,dimc,'noname',l_c,k_c)) CALL ERRQUIT('
     &eomccsdt_y2_10_2_2_1',3,MA_ERR)
      CALL TCE_SORT_4(dbl_mb(k_a_sort),dbl_mb(k_c),int_mb(k_range+p5b-1)
     &,int_mb(k_range+h11b-1),int_mb(k_range+h9b-1),int_mb(k_range+h3b-1
     &),4,3,2,1,1.0d0)
      CALL ADD_HASH_BLOCK(d_c,dbl_mb(k_c),dimc,int_mb(k_c_offset),(p5b -
     & noab - 1 + nvab * (h11b - 1 + noab * (h9b - 1 + noab * (h3b - 1))
     &)))
      IF (.not.MA_POP_STACK(l_c)) CALL ERRQUIT('eomccsdt_y2_10_2_2_1',4,
     &MA_ERR)
      IF (.not.MA_POP_STACK(l_a_sort)) CALL ERRQUIT('eomccsdt_y2_10_2_2_
     &1',5,MA_ERR)
      END IF
      END IF
      END IF
      END IF
      next = NXTASK(nprocs,1)
      END IF
      count = count + 1
      END DO
      END DO
      END DO
      END DO
      next = NXTASK(-nprocs,1)
      call GA_SYNC()
      RETURN
      END
      SUBROUTINE eomccsdt_y2_10_2_2_2(d_a,k_a_offset,d_b,k_b_offset,d_c,
     &k_c_offset)
C     $Id: eomccsdt_y2_all12.F 24184 2013-05-04 00:43:17Z edo $
C     This is a Fortran77 program generated by Tensor Contraction Engine v.1.0
C     Copyright (c) Battelle & Pacific Northwest National Laboratory (2002)
C     i3 ( h3 h9 h11 p5 )_vt + = -1/2 * Sum ( p7 ) * t ( p7 h11 )_t * v ( h3 h9 p5 p7 )_v
      IMPLICIT NONE
#include "global.fh"
#include "mafdecls.fh"
#include "sym.fh"
#include "errquit.fh"
#include "tce.fh"
      INTEGER d_a
      INTEGER k_a_offset
      INTEGER d_b
      INTEGER k_b_offset
      INTEGER d_c
      INTEGER k_c_offset
      INTEGER NXTASK
      INTEGER next
      INTEGER nprocs
      INTEGER count
      INTEGER h3b
      INTEGER h9b
      INTEGER h11b
      INTEGER p5b
      INTEGER dimc
      INTEGER l_c_sort
      INTEGER k_c_sort
      INTEGER p7b
      INTEGER p7b_1
      INTEGER h11b_1
      INTEGER h3b_2
      INTEGER h9b_2
      INTEGER p5b_2
      INTEGER p7b_2
      INTEGER dim_common
      INTEGER dima_sort
      INTEGER dima
      INTEGER dimb_sort
      INTEGER dimb
      INTEGER l_a_sort
      INTEGER k_a_sort
      INTEGER l_a
      INTEGER k_a
      INTEGER l_b_sort
      INTEGER k_b_sort
      INTEGER l_b
      INTEGER k_b
      INTEGER l_c
      INTEGER k_c
      EXTERNAL NXTASK
      nprocs = GA_NNODES()
      count = 0
      next = NXTASK(nprocs,1)
      DO h3b = 1,noab
      DO h9b = 1,noab
      DO h11b = 1,noab
      DO p5b = noab+1,noab+nvab
      IF (next.eq.count) THEN
      IF ((.not.restricted).or.(int_mb(k_spin+h3b-1)+int_mb(k_spin+h9b-1
     &)+int_mb(k_spin+h11b-1)+int_mb(k_spin+p5b-1).ne.8)) THEN
      IF (int_mb(k_spin+h3b-1)+int_mb(k_spin+h9b-1) .eq. int_mb(k_spin+h
     &11b-1)+int_mb(k_spin+p5b-1)) THEN
      IF (ieor(int_mb(k_sym+h3b-1),ieor(int_mb(k_sym+h9b-1),ieor(int_mb(
     &k_sym+h11b-1),int_mb(k_sym+p5b-1)))) .eq. ieor(irrep_v,irrep_t)) T
     &HEN
      dimc = int_mb(k_range+h3b-1) * int_mb(k_range+h9b-1) * int_mb(k_ra
     &nge+h11b-1) * int_mb(k_range+p5b-1)
      IF (.not.MA_PUSH_GET(mt_dbl,dimc,'noname',l_c_sort,k_c_sort)) CALL
     & ERRQUIT('eomccsdt_y2_10_2_2_2',0,MA_ERR)
      CALL DFILL(dimc,0.0d0,dbl_mb(k_c_sort),1)
      DO p7b = noab+1,noab+nvab
      IF (int_mb(k_spin+p7b-1) .eq. int_mb(k_spin+h11b-1)) THEN
      IF (ieor(int_mb(k_sym+p7b-1),int_mb(k_sym+h11b-1)) .eq. irrep_t) T
     &HEN
      CALL TCE_RESTRICTED_2(p7b,h11b,p7b_1,h11b_1)
      CALL TCE_RESTRICTED_4(h3b,h9b,p5b,p7b,h3b_2,h9b_2,p5b_2,p7b_2)
      dim_common = int_mb(k_range+p7b-1)
      dima_sort = int_mb(k_range+h11b-1)
      dima = dim_common * dima_sort
      dimb_sort = int_mb(k_range+h3b-1) * int_mb(k_range+h9b-1) * int_mb
     &(k_range+p5b-1)
      dimb = dim_common * dimb_sort
      IF ((dima .gt. 0) .and. (dimb .gt. 0)) THEN
      IF (.not.MA_PUSH_GET(mt_dbl,dima,'noname',l_a_sort,k_a_sort)) CALL
     & ERRQUIT('eomccsdt_y2_10_2_2_2',1,MA_ERR)
      IF (.not.MA_PUSH_GET(mt_dbl,dima,'noname',l_a,k_a)) CALL ERRQUIT('
     &eomccsdt_y2_10_2_2_2',2,MA_ERR)
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(h11b_
     &1 - 1 + noab * (p7b_1 - noab - 1)))
      CALL TCE_SORT_2(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+p7b-1)
     &,int_mb(k_range+h11b-1),2,1,1.0d0)
      IF (.not.MA_POP_STACK(l_a)) CALL ERRQUIT('eomccsdt_y2_10_2_2_2',3,
     &MA_ERR)
      IF (.not.MA_PUSH_GET(mt_dbl,dimb,'noname',l_b_sort,k_b_sort)) CALL
     & ERRQUIT('eomccsdt_y2_10_2_2_2',4,MA_ERR)
      IF (.not.MA_PUSH_GET(mt_dbl,dimb,'noname',l_b,k_b)) CALL ERRQUIT('
     &eomccsdt_y2_10_2_2_2',5,MA_ERR)
      IF ((h9b .lt. h3b) .and. (p7b .lt. p5b)) THEN
      CALL GET_HASH_BLOCK(d_b,dbl_mb(k_b),dimb,int_mb(k_b_offset),(p5b_2
     & - 1 + (noab+nvab) * (p7b_2 - 1 + (noab+nvab) * (h3b_2 - 1 + (noab
     &+nvab) * (h9b_2 - 1)))))
      CALL TCE_SORT_4(dbl_mb(k_b),dbl_mb(k_b_sort),int_mb(k_range+h9b-1)
     &,int_mb(k_range+h3b-1),int_mb(k_range+p7b-1),int_mb(k_range+p5b-1)
     &,4,1,2,3,1.0d0)
      END IF
      IF ((h9b .lt. h3b) .and. (p5b .le. p7b)) THEN
      CALL GET_HASH_BLOCK(d_b,dbl_mb(k_b),dimb,int_mb(k_b_offset),(p7b_2
     & - 1 + (noab+nvab) * (p5b_2 - 1 + (noab+nvab) * (h3b_2 - 1 + (noab
     &+nvab) * (h9b_2 - 1)))))
      CALL TCE_SORT_4(dbl_mb(k_b),dbl_mb(k_b_sort),int_mb(k_range+h9b-1)
     &,int_mb(k_range+h3b-1),int_mb(k_range+p5b-1),int_mb(k_range+p7b-1)
     &,3,1,2,4,-1.0d0)
      END IF
      IF ((h3b .le. h9b) .and. (p7b .lt. p5b)) THEN
      CALL GET_HASH_BLOCK(d_b,dbl_mb(k_b),dimb,int_mb(k_b_offset),(p5b_2
     & - 1 + (noab+nvab) * (p7b_2 - 1 + (noab+nvab) * (h9b_2 - 1 + (noab
     &+nvab) * (h3b_2 - 1)))))
      CALL TCE_SORT_4(dbl_mb(k_b),dbl_mb(k_b_sort),int_mb(k_range+h3b-1)
     &,int_mb(k_range+h9b-1),int_mb(k_range+p7b-1),int_mb(k_range+p5b-1)
     &,4,2,1,3,-1.0d0)
      END IF
      IF ((h3b .le. h9b) .and. (p5b .le. p7b)) THEN
      CALL GET_HASH_BLOCK(d_b,dbl_mb(k_b),dimb,int_mb(k_b_offset),(p7b_2
     & - 1 + (noab+nvab) * (p5b_2 - 1 + (noab+nvab) * (h9b_2 - 1 + (noab
     &+nvab) * (h3b_2 - 1)))))
      CALL TCE_SORT_4(dbl_mb(k_b),dbl_mb(k_b_sort),int_mb(k_range+h3b-1)
     &,int_mb(k_range+h9b-1),int_mb(k_range+p5b-1),int_mb(k_range+p7b-1)
     &,3,2,1,4,1.0d0)
      END IF
      IF (.not.MA_POP_STACK(l_b)) CALL ERRQUIT('eomccsdt_y2_10_2_2_2',6,
     &MA_ERR)
      CALL dgemm('T','N',dima_sort,dimb_sort,dim_common,1.0d0,dbl_mb(k_a
     &_sort),dim_common,dbl_mb(k_b_sort),dim_common,1.0d0,dbl_mb(k_c_sor
     &t),dima_sort)
      IF (.not.MA_POP_STACK(l_b_sort)) CALL ERRQUIT('eomccsdt_y2_10_2_2_
     &2',7,MA_ERR)
      IF (.not.MA_POP_STACK(l_a_sort)) CALL ERRQUIT('eomccsdt_y2_10_2_2_
     &2',8,MA_ERR)
      END IF
      END IF
      END IF
      END DO
      IF (.not.MA_PUSH_GET(mt_dbl,dimc,'noname',l_c,k_c)) CALL ERRQUIT('
     &eomccsdt_y2_10_2_2_2',9,MA_ERR)
      CALL TCE_SORT_4(dbl_mb(k_c_sort),dbl_mb(k_c),int_mb(k_range+p5b-1)
     &,int_mb(k_range+h9b-1),int_mb(k_range+h3b-1),int_mb(k_range+h11b-1
     &),3,2,4,1,-1.0d0/2.0d0)
      CALL ADD_HASH_BLOCK(d_c,dbl_mb(k_c),dimc,int_mb(k_c_offset),(p5b -
     & noab - 1 + nvab * (h11b - 1 + noab * (h9b - 1 + noab * (h3b - 1))
     &)))
      IF (.not.MA_POP_STACK(l_c)) CALL ERRQUIT('eomccsdt_y2_10_2_2_2',10
     &,MA_ERR)
      IF (.not.MA_POP_STACK(l_c_sort)) CALL ERRQUIT('eomccsdt_y2_10_2_2_
     &2',11,MA_ERR)
      END IF
      END IF
      END IF
      next = NXTASK(nprocs,1)
      END IF
      count = count + 1
      END DO
      END DO
      END DO
      END DO
      next = NXTASK(-nprocs,1)
      call GA_SYNC()
      RETURN
      END
      SUBROUTINE eomccsdt_y2_10_2_2(d_a,k_a_offset,d_b,k_b_offset,d_c,k_
     &c_offset)
C     $Id: eomccsdt_y2_all12.F 24184 2013-05-04 00:43:17Z edo $
C     This is a Fortran77 program generated by Tensor Contraction Engine v.1.0
C     Copyright (c) Battelle & Pacific Northwest National Laboratory (2002)
C     i2 ( h3 h9 h11 h14 )_vt + = 2 * Sum ( p5 ) * t ( p5 h14 )_t * i3 ( h3 h9 h11 p5 )_v
      IMPLICIT NONE
#include "global.fh"
#include "mafdecls.fh"
#include "sym.fh"
#include "errquit.fh"
#include "tce.fh"
      INTEGER d_a
      INTEGER k_a_offset
      INTEGER d_b
      INTEGER k_b_offset
      INTEGER d_c
      INTEGER k_c_offset
      INTEGER NXTASK
      INTEGER next
      INTEGER nprocs
      INTEGER count
      INTEGER h3b
      INTEGER h9b
      INTEGER h14b
      INTEGER h11b
      INTEGER dimc
      INTEGER l_c_sort
      INTEGER k_c_sort
      INTEGER p5b
      INTEGER p5b_1
      INTEGER h14b_1
      INTEGER h3b_2
      INTEGER h9b_2
      INTEGER h11b_2
      INTEGER p5b_2
      INTEGER dim_common
      INTEGER dima_sort
      INTEGER dima
      INTEGER dimb_sort
      INTEGER dimb
      INTEGER l_a_sort
      INTEGER k_a_sort
      INTEGER l_a
      INTEGER k_a
      INTEGER l_b_sort
      INTEGER k_b_sort
      INTEGER l_b
      INTEGER k_b
      INTEGER l_c
      INTEGER k_c
      EXTERNAL NXTASK
      nprocs = GA_NNODES()
      count = 0
      next = NXTASK(nprocs,1)
      DO h3b = 1,noab
      DO h9b = 1,noab
      DO h14b = 1,noab
      DO h11b = 1,noab
      IF (next.eq.count) THEN
      IF ((.not.restricted).or.(int_mb(k_spin+h3b-1)+int_mb(k_spin+h9b-1
     &)+int_mb(k_spin+h11b-1)+int_mb(k_spin+h14b-1).ne.8)) THEN
      IF (int_mb(k_spin+h3b-1)+int_mb(k_spin+h9b-1) .eq. int_mb(k_spin+h
     &11b-1)+int_mb(k_spin+h14b-1)) THEN
      IF (ieor(int_mb(k_sym+h3b-1),ieor(int_mb(k_sym+h9b-1),ieor(int_mb(
     &k_sym+h11b-1),int_mb(k_sym+h14b-1)))) .eq. ieor(irrep_v,irrep_t)) 
     &THEN
      dimc = int_mb(k_range+h3b-1) * int_mb(k_range+h9b-1) * int_mb(k_ra
     &nge+h11b-1) * int_mb(k_range+h14b-1)
      IF (.not.MA_PUSH_GET(mt_dbl,dimc,'noname',l_c_sort,k_c_sort)) CALL
     & ERRQUIT('eomccsdt_y2_10_2_2',0,MA_ERR)
      CALL DFILL(dimc,0.0d0,dbl_mb(k_c_sort),1)
      DO p5b = noab+1,noab+nvab
      IF (int_mb(k_spin+p5b-1) .eq. int_mb(k_spin+h14b-1)) THEN
      IF (ieor(int_mb(k_sym+p5b-1),int_mb(k_sym+h14b-1)) .eq. irrep_t) T
     &HEN
      CALL TCE_RESTRICTED_2(p5b,h14b,p5b_1,h14b_1)
      CALL TCE_RESTRICTED_4(h3b,h9b,h11b,p5b,h3b_2,h9b_2,h11b_2,p5b_2)
      dim_common = int_mb(k_range+p5b-1)
      dima_sort = int_mb(k_range+h14b-1)
      dima = dim_common * dima_sort
      dimb_sort = int_mb(k_range+h3b-1) * int_mb(k_range+h9b-1) * int_mb
     &(k_range+h11b-1)
      dimb = dim_common * dimb_sort
      IF ((dima .gt. 0) .and. (dimb .gt. 0)) THEN
      IF (.not.MA_PUSH_GET(mt_dbl,dima,'noname',l_a_sort,k_a_sort)) CALL
     & ERRQUIT('eomccsdt_y2_10_2_2',1,MA_ERR)
      IF (.not.MA_PUSH_GET(mt_dbl,dima,'noname',l_a,k_a)) CALL ERRQUIT('
     &eomccsdt_y2_10_2_2',2,MA_ERR)
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(h14b_
     &1 - 1 + noab * (p5b_1 - noab - 1)))
      CALL TCE_SORT_2(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+p5b-1)
     &,int_mb(k_range+h14b-1),2,1,1.0d0)
      IF (.not.MA_POP_STACK(l_a)) CALL ERRQUIT('eomccsdt_y2_10_2_2',3,MA
     &_ERR)
      IF (.not.MA_PUSH_GET(mt_dbl,dimb,'noname',l_b_sort,k_b_sort)) CALL
     & ERRQUIT('eomccsdt_y2_10_2_2',4,MA_ERR)
      IF (.not.MA_PUSH_GET(mt_dbl,dimb,'noname',l_b,k_b)) CALL ERRQUIT('
     &eomccsdt_y2_10_2_2',5,MA_ERR)
      IF ((h11b .le. p5b)) THEN
      CALL GET_HASH_BLOCK(d_b,dbl_mb(k_b),dimb,int_mb(k_b_offset),(p5b_2
     & - noab - 1 + nvab * (h11b_2 - 1 + noab * (h9b_2 - 1 + noab * (h3b
     &_2 - 1)))))
      CALL TCE_SORT_4(dbl_mb(k_b),dbl_mb(k_b_sort),int_mb(k_range+h3b-1)
     &,int_mb(k_range+h9b-1),int_mb(k_range+h11b-1),int_mb(k_range+p5b-1
     &),3,2,1,4,1.0d0)
      END IF
      IF (.not.MA_POP_STACK(l_b)) CALL ERRQUIT('eomccsdt_y2_10_2_2',6,MA
     &_ERR)
      CALL dgemm('T','N',dima_sort,dimb_sort,dim_common,1.0d0,dbl_mb(k_a
     &_sort),dim_common,dbl_mb(k_b_sort),dim_common,1.0d0,dbl_mb(k_c_sor
     &t),dima_sort)
      IF (.not.MA_POP_STACK(l_b_sort)) CALL ERRQUIT('eomccsdt_y2_10_2_2'
     &,7,MA_ERR)
      IF (.not.MA_POP_STACK(l_a_sort)) CALL ERRQUIT('eomccsdt_y2_10_2_2'
     &,8,MA_ERR)
      END IF
      END IF
      END IF
      END DO
      IF (.not.MA_PUSH_GET(mt_dbl,dimc,'noname',l_c,k_c)) CALL ERRQUIT('
     &eomccsdt_y2_10_2_2',9,MA_ERR)
      IF ((h11b .le. h14b)) THEN
      CALL TCE_SORT_4(dbl_mb(k_c_sort),dbl_mb(k_c),int_mb(k_range+h11b-1
     &),int_mb(k_range+h9b-1),int_mb(k_range+h3b-1),int_mb(k_range+h14b-
     &1),3,2,1,4,1.0d0)
      CALL ADD_HASH_BLOCK(d_c,dbl_mb(k_c),dimc,int_mb(k_c_offset),(h14b 
     &- 1 + noab * (h11b - 1 + noab * (h9b - 1 + noab * (h3b - 1)))))
      END IF
      IF ((h14b .le. h11b)) THEN
      CALL TCE_SORT_4(dbl_mb(k_c_sort),dbl_mb(k_c),int_mb(k_range+h11b-1
     &),int_mb(k_range+h9b-1),int_mb(k_range+h3b-1),int_mb(k_range+h14b-
     &1),3,2,4,1,-1.0d0)
      CALL ADD_HASH_BLOCK(d_c,dbl_mb(k_c),dimc,int_mb(k_c_offset),(h11b 
     &- 1 + noab * (h14b - 1 + noab * (h9b - 1 + noab * (h3b - 1)))))
      END IF
      IF (.not.MA_POP_STACK(l_c)) CALL ERRQUIT('eomccsdt_y2_10_2_2',10,M
     &A_ERR)
      IF (.not.MA_POP_STACK(l_c_sort)) CALL ERRQUIT('eomccsdt_y2_10_2_2'
     &,11,MA_ERR)
      END IF
      END IF
      END IF
      next = NXTASK(nprocs,1)
      END IF
      count = count + 1
      END DO
      END DO
      END DO
      END DO
      next = NXTASK(-nprocs,1)
      call GA_SYNC()
      RETURN
      END
      SUBROUTINE eomccsdt_y2_10_2_3(d_a,k_a_offset,d_b,k_b_offset,d_c,k_
     &c_offset)
C     $Id: eomccsdt_y2_all12.F 24184 2013-05-04 00:43:17Z edo $
C     This is a Fortran77 program generated by Tensor Contraction Engine v.1.0
C     Copyright (c) Battelle & Pacific Northwest National Laboratory (2002)
C     i2 ( h3 h9 h11 h14 )_vt + = 1/2 * Sum ( p5 p6 ) * t ( p5 p6 h11 h14 )_t * v ( h3 h9 p5 p6 )_v
      IMPLICIT NONE
#include "global.fh"
#include "mafdecls.fh"
#include "sym.fh"
#include "errquit.fh"
#include "tce.fh"
      INTEGER d_a
      INTEGER k_a_offset
      INTEGER d_b
      INTEGER k_b_offset
      INTEGER d_c
      INTEGER k_c_offset
      INTEGER NXTASK
      INTEGER next
      INTEGER nprocs
      INTEGER count
      INTEGER h3b
      INTEGER h9b
      INTEGER h11b
      INTEGER h14b
      INTEGER dimc
      INTEGER l_c_sort
      INTEGER k_c_sort
      INTEGER p5b
      INTEGER p6b
      INTEGER p5b_1
      INTEGER p6b_1
      INTEGER h11b_1
      INTEGER h14b_1
      INTEGER h3b_2
      INTEGER h9b_2
      INTEGER p5b_2
      INTEGER p6b_2
      INTEGER dim_common
      INTEGER dima_sort
      INTEGER dima
      INTEGER dimb_sort
      INTEGER dimb
      INTEGER l_a_sort
      INTEGER k_a_sort
      INTEGER l_a
      INTEGER k_a
      INTEGER l_b_sort
      INTEGER k_b_sort
      INTEGER l_b
      INTEGER k_b
      INTEGER nsuperp(2)
      INTEGER isuperp
      INTEGER l_c
      INTEGER k_c
      DOUBLE PRECISION FACTORIAL
      EXTERNAL NXTASK
      EXTERNAL FACTORIAL
      nprocs = GA_NNODES()
      count = 0
      next = NXTASK(nprocs,1)
      DO h3b = 1,noab
      DO h9b = 1,noab
      DO h11b = 1,noab
      DO h14b = h11b,noab
      IF (next.eq.count) THEN
      IF ((.not.restricted).or.(int_mb(k_spin+h3b-1)+int_mb(k_spin+h9b-1
     &)+int_mb(k_spin+h11b-1)+int_mb(k_spin+h14b-1).ne.8)) THEN
      IF (int_mb(k_spin+h3b-1)+int_mb(k_spin+h9b-1) .eq. int_mb(k_spin+h
     &11b-1)+int_mb(k_spin+h14b-1)) THEN
      IF (ieor(int_mb(k_sym+h3b-1),ieor(int_mb(k_sym+h9b-1),ieor(int_mb(
     &k_sym+h11b-1),int_mb(k_sym+h14b-1)))) .eq. ieor(irrep_v,irrep_t)) 
     &THEN
      dimc = int_mb(k_range+h3b-1) * int_mb(k_range+h9b-1) * int_mb(k_ra
     &nge+h11b-1) * int_mb(k_range+h14b-1)
      IF (.not.MA_PUSH_GET(mt_dbl,dimc,'noname',l_c_sort,k_c_sort)) CALL
     & ERRQUIT('eomccsdt_y2_10_2_3',0,MA_ERR)
      CALL DFILL(dimc,0.0d0,dbl_mb(k_c_sort),1)
      DO p5b = noab+1,noab+nvab
      DO p6b = p5b,noab+nvab
      IF (int_mb(k_spin+p5b-1)+int_mb(k_spin+p6b-1) .eq. int_mb(k_spin+h
     &11b-1)+int_mb(k_spin+h14b-1)) THEN
      IF (ieor(int_mb(k_sym+p5b-1),ieor(int_mb(k_sym+p6b-1),ieor(int_mb(
     &k_sym+h11b-1),int_mb(k_sym+h14b-1)))) .eq. irrep_t) THEN
      CALL TCE_RESTRICTED_4(p5b,p6b,h11b,h14b,p5b_1,p6b_1,h11b_1,h14b_1)
      CALL TCE_RESTRICTED_4(h3b,h9b,p5b,p6b,h3b_2,h9b_2,p5b_2,p6b_2)
      dim_common = int_mb(k_range+p5b-1) * int_mb(k_range+p6b-1)
      dima_sort = int_mb(k_range+h11b-1) * int_mb(k_range+h14b-1)
      dima = dim_common * dima_sort
      dimb_sort = int_mb(k_range+h3b-1) * int_mb(k_range+h9b-1)
      dimb = dim_common * dimb_sort
      IF ((dima .gt. 0) .and. (dimb .gt. 0)) THEN
      IF (.not.MA_PUSH_GET(mt_dbl,dima,'noname',l_a_sort,k_a_sort)) CALL
     & ERRQUIT('eomccsdt_y2_10_2_3',1,MA_ERR)
      IF (.not.MA_PUSH_GET(mt_dbl,dima,'noname',l_a,k_a)) CALL ERRQUIT('
     &eomccsdt_y2_10_2_3',2,MA_ERR)
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(h14b_
     &1 - 1 + noab * (h11b_1 - 1 + noab * (p6b_1 - noab - 1 + nvab * (p5
     &b_1 - noab - 1)))))
      CALL TCE_SORT_4(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+p5b-1)
     &,int_mb(k_range+p6b-1),int_mb(k_range+h11b-1),int_mb(k_range+h14b-
     &1),4,3,2,1,1.0d0)
      IF (.not.MA_POP_STACK(l_a)) CALL ERRQUIT('eomccsdt_y2_10_2_3',3,MA
     &_ERR)
      IF (.not.MA_PUSH_GET(mt_dbl,dimb,'noname',l_b_sort,k_b_sort)) CALL
     & ERRQUIT('eomccsdt_y2_10_2_3',4,MA_ERR)
      IF (.not.MA_PUSH_GET(mt_dbl,dimb,'noname',l_b,k_b)) CALL ERRQUIT('
     &eomccsdt_y2_10_2_3',5,MA_ERR)
      IF ((h9b .lt. h3b)) THEN
      CALL GET_HASH_BLOCK(d_b,dbl_mb(k_b),dimb,int_mb(k_b_offset),(p6b_2
     & - 1 + (noab+nvab) * (p5b_2 - 1 + (noab+nvab) * (h3b_2 - 1 + (noab
     &+nvab) * (h9b_2 - 1)))))
      CALL TCE_SORT_4(dbl_mb(k_b),dbl_mb(k_b_sort),int_mb(k_range+h9b-1)
     &,int_mb(k_range+h3b-1),int_mb(k_range+p5b-1),int_mb(k_range+p6b-1)
     &,1,2,4,3,-1.0d0)
      END IF
      IF ((h3b .le. h9b)) THEN
      CALL GET_HASH_BLOCK(d_b,dbl_mb(k_b),dimb,int_mb(k_b_offset),(p6b_2
     & - 1 + (noab+nvab) * (p5b_2 - 1 + (noab+nvab) * (h9b_2 - 1 + (noab
     &+nvab) * (h3b_2 - 1)))))
      CALL TCE_SORT_4(dbl_mb(k_b),dbl_mb(k_b_sort),int_mb(k_range+h3b-1)
     &,int_mb(k_range+h9b-1),int_mb(k_range+p5b-1),int_mb(k_range+p6b-1)
     &,2,1,4,3,1.0d0)
      END IF
      IF (.not.MA_POP_STACK(l_b)) CALL ERRQUIT('eomccsdt_y2_10_2_3',6,MA
     &_ERR)
      nsuperp(1) = 1
      nsuperp(2) = 1
      isuperp = 1
      IF (p5b .eq. p6b) THEN
      nsuperp(isuperp) = nsuperp(isuperp) + 1
      ELSE
      isuperp = isuperp + 1
      END IF
      CALL dgemm('T','N',dima_sort,dimb_sort,dim_common,2.0d0/FACTORIAL(
     &nsuperp(1))/FACTORIAL(nsuperp(2)),dbl_mb(k_a_sort),dim_common,dbl_
     &mb(k_b_sort),dim_common,1.0d0,dbl_mb(k_c_sort),dima_sort)
      IF (.not.MA_POP_STACK(l_b_sort)) CALL ERRQUIT('eomccsdt_y2_10_2_3'
     &,7,MA_ERR)
      IF (.not.MA_POP_STACK(l_a_sort)) CALL ERRQUIT('eomccsdt_y2_10_2_3'
     &,8,MA_ERR)
      END IF
      END IF
      END IF
      END DO
      END DO
      IF (.not.MA_PUSH_GET(mt_dbl,dimc,'noname',l_c,k_c)) CALL ERRQUIT('
     &eomccsdt_y2_10_2_3',9,MA_ERR)
      CALL TCE_SORT_4(dbl_mb(k_c_sort),dbl_mb(k_c),int_mb(k_range+h9b-1)
     &,int_mb(k_range+h3b-1),int_mb(k_range+h14b-1),int_mb(k_range+h11b-
     &1),2,1,4,3,1.0d0/2.0d0)
      CALL ADD_HASH_BLOCK(d_c,dbl_mb(k_c),dimc,int_mb(k_c_offset),(h14b 
     &- 1 + noab * (h11b - 1 + noab * (h9b - 1 + noab * (h3b - 1)))))
      IF (.not.MA_POP_STACK(l_c)) CALL ERRQUIT('eomccsdt_y2_10_2_3',10,M
     &A_ERR)
      IF (.not.MA_POP_STACK(l_c_sort)) CALL ERRQUIT('eomccsdt_y2_10_2_3'
     &,11,MA_ERR)
      END IF
      END IF
      END IF
      next = NXTASK(nprocs,1)
      END IF
      count = count + 1
      END DO
      END DO
      END DO
      END DO
      next = NXTASK(-nprocs,1)
      call GA_SYNC()
      RETURN
      END
      SUBROUTINE eomccsdt_y2_10_2(d_a,k_a_offset,d_b,k_b_offset,d_c,k_c_
     &offset)
C     $Id: eomccsdt_y2_all12.F 24184 2013-05-04 00:43:17Z edo $
C     This is a Fortran77 program generated by Tensor Contraction Engine v.1.0
C     Copyright (c) Battelle & Pacific Northwest National Laboratory (2002)
C     i1 ( h3 p13 h11 h14 )_vt + = 1 * Sum ( h9 ) * t ( p13 h9 )_t * i2 ( h3 h9 h11 h14 )_v
      IMPLICIT NONE
#include "global.fh"
#include "mafdecls.fh"
#include "sym.fh"
#include "errquit.fh"
#include "tce.fh"
      INTEGER d_a
      INTEGER k_a_offset
      INTEGER d_b
      INTEGER k_b_offset
      INTEGER d_c
      INTEGER k_c_offset
      INTEGER NXTASK
      INTEGER next
      INTEGER nprocs
      INTEGER count
      INTEGER h3b
      INTEGER p13b
      INTEGER h11b
      INTEGER h14b
      INTEGER dimc
      INTEGER l_c_sort
      INTEGER k_c_sort
      INTEGER h9b
      INTEGER p13b_1
      INTEGER h9b_1
      INTEGER h3b_2
      INTEGER h9b_2
      INTEGER h11b_2
      INTEGER h14b_2
      INTEGER dim_common
      INTEGER dima_sort
      INTEGER dima
      INTEGER dimb_sort
      INTEGER dimb
      INTEGER l_a_sort
      INTEGER k_a_sort
      INTEGER l_a
      INTEGER k_a
      INTEGER l_b_sort
      INTEGER k_b_sort
      INTEGER l_b
      INTEGER k_b
      INTEGER l_c
      INTEGER k_c
      EXTERNAL NXTASK
      nprocs = GA_NNODES()
      count = 0
      next = NXTASK(nprocs,1)
      DO h3b = 1,noab
      DO p13b = noab+1,noab+nvab
      DO h11b = 1,noab
      DO h14b = h11b,noab
      IF (next.eq.count) THEN
      IF ((.not.restricted).or.(int_mb(k_spin+h3b-1)+int_mb(k_spin+p13b-
     &1)+int_mb(k_spin+h11b-1)+int_mb(k_spin+h14b-1).ne.8)) THEN
      IF (int_mb(k_spin+h3b-1)+int_mb(k_spin+p13b-1) .eq. int_mb(k_spin+
     &h11b-1)+int_mb(k_spin+h14b-1)) THEN
      IF (ieor(int_mb(k_sym+h3b-1),ieor(int_mb(k_sym+p13b-1),ieor(int_mb
     &(k_sym+h11b-1),int_mb(k_sym+h14b-1)))) .eq. ieor(irrep_v,irrep_t))
     & THEN
      dimc = int_mb(k_range+h3b-1) * int_mb(k_range+p13b-1) * int_mb(k_r
     &ange+h11b-1) * int_mb(k_range+h14b-1)
      IF (.not.MA_PUSH_GET(mt_dbl,dimc,'noname',l_c_sort,k_c_sort)) CALL
     & ERRQUIT('eomccsdt_y2_10_2',0,MA_ERR)
      CALL DFILL(dimc,0.0d0,dbl_mb(k_c_sort),1)
      DO h9b = 1,noab
      IF (int_mb(k_spin+p13b-1) .eq. int_mb(k_spin+h9b-1)) THEN
      IF (ieor(int_mb(k_sym+p13b-1),int_mb(k_sym+h9b-1)) .eq. irrep_t) T
     &HEN
      CALL TCE_RESTRICTED_2(p13b,h9b,p13b_1,h9b_1)
      CALL TCE_RESTRICTED_4(h3b,h9b,h11b,h14b,h3b_2,h9b_2,h11b_2,h14b_2)
      dim_common = int_mb(k_range+h9b-1)
      dima_sort = int_mb(k_range+p13b-1)
      dima = dim_common * dima_sort
      dimb_sort = int_mb(k_range+h3b-1) * int_mb(k_range+h11b-1) * int_m
     &b(k_range+h14b-1)
      dimb = dim_common * dimb_sort
      IF ((dima .gt. 0) .and. (dimb .gt. 0)) THEN
      IF (.not.MA_PUSH_GET(mt_dbl,dima,'noname',l_a_sort,k_a_sort)) CALL
     & ERRQUIT('eomccsdt_y2_10_2',1,MA_ERR)
      IF (.not.MA_PUSH_GET(mt_dbl,dima,'noname',l_a,k_a)) CALL ERRQUIT('
     &eomccsdt_y2_10_2',2,MA_ERR)
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(h9b_1
     & - 1 + noab * (p13b_1 - noab - 1)))
      CALL TCE_SORT_2(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+p13b-1
     &),int_mb(k_range+h9b-1),1,2,1.0d0)
      IF (.not.MA_POP_STACK(l_a)) CALL ERRQUIT('eomccsdt_y2_10_2',3,MA_E
     &RR)
      IF (.not.MA_PUSH_GET(mt_dbl,dimb,'noname',l_b_sort,k_b_sort)) CALL
     & ERRQUIT('eomccsdt_y2_10_2',4,MA_ERR)
      IF (.not.MA_PUSH_GET(mt_dbl,dimb,'noname',l_b,k_b)) CALL ERRQUIT('
     &eomccsdt_y2_10_2',5,MA_ERR)
      CALL GET_HASH_BLOCK(d_b,dbl_mb(k_b),dimb,int_mb(k_b_offset),(h14b_
     &2 - 1 + noab * (h11b_2 - 1 + noab * (h9b_2 - 1 + noab * (h3b_2 - 1
     &)))))
      CALL TCE_SORT_4(dbl_mb(k_b),dbl_mb(k_b_sort),int_mb(k_range+h3b-1)
     &,int_mb(k_range+h9b-1),int_mb(k_range+h11b-1),int_mb(k_range+h14b-
     &1),4,3,1,2,1.0d0)
      IF (.not.MA_POP_STACK(l_b)) CALL ERRQUIT('eomccsdt_y2_10_2',6,MA_E
     &RR)
      CALL dgemm('T','N',dima_sort,dimb_sort,dim_common,1.0d0,dbl_mb(k_a
     &_sort),dim_common,dbl_mb(k_b_sort),dim_common,1.0d0,dbl_mb(k_c_sor
     &t),dima_sort)
      IF (.not.MA_POP_STACK(l_b_sort)) CALL ERRQUIT('eomccsdt_y2_10_2',7
     &,MA_ERR)
      IF (.not.MA_POP_STACK(l_a_sort)) CALL ERRQUIT('eomccsdt_y2_10_2',8
     &,MA_ERR)
      END IF
      END IF
      END IF
      END DO
      IF (.not.MA_PUSH_GET(mt_dbl,dimc,'noname',l_c,k_c)) CALL ERRQUIT('
     &eomccsdt_y2_10_2',9,MA_ERR)
      CALL TCE_SORT_4(dbl_mb(k_c_sort),dbl_mb(k_c),int_mb(k_range+h14b-1
     &),int_mb(k_range+h11b-1),int_mb(k_range+h3b-1),int_mb(k_range+p13b
     &-1),3,4,2,1,1.0d0)
      CALL ADD_HASH_BLOCK(d_c,dbl_mb(k_c),dimc,int_mb(k_c_offset),(h14b 
     &- 1 + noab * (h11b - 1 + noab * (p13b - noab - 1 + nvab * (h3b - 1
     &)))))
      IF (.not.MA_POP_STACK(l_c)) CALL ERRQUIT('eomccsdt_y2_10_2',10,MA_
     &ERR)
      IF (.not.MA_POP_STACK(l_c_sort)) CALL ERRQUIT('eomccsdt_y2_10_2',1
     &1,MA_ERR)
      END IF
      END IF
      END IF
      next = NXTASK(nprocs,1)
      END IF
      count = count + 1
      END DO
      END DO
      END DO
      END DO
      next = NXTASK(-nprocs,1)
      call GA_SYNC()
      RETURN
      END
      SUBROUTINE eomccsdt_y2_10_3_1(d_a,k_a_offset,d_c,k_c_offset)
C     $Id: eomccsdt_y2_all12.F 24184 2013-05-04 00:43:17Z edo $
C     This is a Fortran77 program generated by Tensor Contraction Engine v.1.0
C     Copyright (c) Battelle & Pacific Northwest National Laboratory (2002)
C     i2 ( h3 p13 h11 p5 )_v + = 1 * v ( h3 p13 h11 p5 )_v
      IMPLICIT NONE
#include "global.fh"
#include "mafdecls.fh"
#include "sym.fh"
#include "errquit.fh"
#include "tce.fh"
      INTEGER d_a
      INTEGER k_a_offset
      INTEGER d_c
      INTEGER k_c_offset
      INTEGER NXTASK
      INTEGER next
      INTEGER nprocs
      INTEGER count
      INTEGER h3b
      INTEGER p13b
      INTEGER h11b
      INTEGER p5b
      INTEGER dimc
      INTEGER h3b_1
      INTEGER p13b_1
      INTEGER h11b_1
      INTEGER p5b_1
      INTEGER dim_common
      INTEGER dima_sort
      INTEGER dima
      INTEGER l_a_sort
      INTEGER k_a_sort
      INTEGER l_a
      INTEGER k_a
      INTEGER l_c
      INTEGER k_c
      EXTERNAL NXTASK
      nprocs = GA_NNODES()
      count = 0
      next = NXTASK(nprocs,1)
      DO h3b = 1,noab
      DO p13b = noab+1,noab+nvab
      DO h11b = 1,noab
      DO p5b = noab+1,noab+nvab
      IF (next.eq.count) THEN
      IF ((.not.restricted).or.(int_mb(k_spin+h3b-1)+int_mb(k_spin+p13b-
     &1)+int_mb(k_spin+h11b-1)+int_mb(k_spin+p5b-1).ne.8)) THEN
      IF (int_mb(k_spin+h3b-1)+int_mb(k_spin+p13b-1) .eq. int_mb(k_spin+
     &h11b-1)+int_mb(k_spin+p5b-1)) THEN
      IF (ieor(int_mb(k_sym+h3b-1),ieor(int_mb(k_sym+p13b-1),ieor(int_mb
     &(k_sym+h11b-1),int_mb(k_sym+p5b-1)))) .eq. irrep_v) THEN
      dimc = int_mb(k_range+h3b-1) * int_mb(k_range+p13b-1) * int_mb(k_r
     &ange+h11b-1) * int_mb(k_range+p5b-1)
      CALL TCE_RESTRICTED_4(h3b,p13b,h11b,p5b,h3b_1,p13b_1,h11b_1,p5b_1)
      dim_common = 1
      dima_sort = int_mb(k_range+h3b-1) * int_mb(k_range+p13b-1) * int_m
     &b(k_range+h11b-1) * int_mb(k_range+p5b-1)
      dima = dim_common * dima_sort
      IF (dima .gt. 0) THEN
      IF (.not.MA_PUSH_GET(mt_dbl,dima,'noname',l_a_sort,k_a_sort)) CALL
     & ERRQUIT('eomccsdt_y2_10_3_1',0,MA_ERR)
      IF (.not.MA_PUSH_GET(mt_dbl,dima,'noname',l_a,k_a)) CALL ERRQUIT('
     &eomccsdt_y2_10_3_1',1,MA_ERR)
      IF ((h3b .le. p13b)) THEN
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(p5b_1
     & - 1 + (noab+nvab) * (h11b_1 - 1 + (noab+nvab) * (p13b_1 - 1 + (no
     &ab+nvab) * (h3b_1 - 1)))))
      CALL TCE_SORT_4(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+h3b-1)
     &,int_mb(k_range+p13b-1),int_mb(k_range+h11b-1),int_mb(k_range+p5b-
     &1),4,3,2,1,1.0d0)
      END IF
      IF (.not.MA_POP_STACK(l_a)) CALL ERRQUIT('eomccsdt_y2_10_3_1',2,MA
     &_ERR)
      IF (.not.MA_PUSH_GET(mt_dbl,dimc,'noname',l_c,k_c)) CALL ERRQUIT('
     &eomccsdt_y2_10_3_1',3,MA_ERR)
      CALL TCE_SORT_4(dbl_mb(k_a_sort),dbl_mb(k_c),int_mb(k_range+p5b-1)
     &,int_mb(k_range+h11b-1),int_mb(k_range+p13b-1),int_mb(k_range+h3b-
     &1),4,3,2,1,1.0d0)
      CALL ADD_HASH_BLOCK(d_c,dbl_mb(k_c),dimc,int_mb(k_c_offset),(p5b -
     & noab - 1 + nvab * (h11b - 1 + noab * (p13b - noab - 1 + nvab * (h
     &3b - 1)))))
      IF (.not.MA_POP_STACK(l_c)) CALL ERRQUIT('eomccsdt_y2_10_3_1',4,MA
     &_ERR)
      IF (.not.MA_POP_STACK(l_a_sort)) CALL ERRQUIT('eomccsdt_y2_10_3_1'
     &,5,MA_ERR)
      END IF
      END IF
      END IF
      END IF
      next = NXTASK(nprocs,1)
      END IF
      count = count + 1
      END DO
      END DO
      END DO
      END DO
      next = NXTASK(-nprocs,1)
      call GA_SYNC()
      RETURN
      END
      SUBROUTINE eomccsdt_y2_10_3_2(d_a,k_a_offset,d_b,k_b_offset,d_c,k_
     &c_offset)
C     $Id: eomccsdt_y2_all12.F 24184 2013-05-04 00:43:17Z edo $
C     This is a Fortran77 program generated by Tensor Contraction Engine v.1.0
C     Copyright (c) Battelle & Pacific Northwest National Laboratory (2002)
C     i2 ( h3 p13 h11 p5 )_vt + = -1/2 * Sum ( p7 ) * t ( p7 h11 )_t * v ( h3 p13 p5 p7 )_v
      IMPLICIT NONE
#include "global.fh"
#include "mafdecls.fh"
#include "sym.fh"
#include "errquit.fh"
#include "tce.fh"
      INTEGER d_a
      INTEGER k_a_offset
      INTEGER d_b
      INTEGER k_b_offset
      INTEGER d_c
      INTEGER k_c_offset
      INTEGER NXTASK
      INTEGER next
      INTEGER nprocs
      INTEGER count
      INTEGER h3b
      INTEGER p13b
      INTEGER h11b
      INTEGER p5b
      INTEGER dimc
      INTEGER l_c_sort
      INTEGER k_c_sort
      INTEGER p7b
      INTEGER p7b_1
      INTEGER h11b_1
      INTEGER h3b_2
      INTEGER p13b_2
      INTEGER p5b_2
      INTEGER p7b_2
      INTEGER dim_common
      INTEGER dima_sort
      INTEGER dima
      INTEGER dimb_sort
      INTEGER dimb
      INTEGER l_a_sort
      INTEGER k_a_sort
      INTEGER l_a
      INTEGER k_a
      INTEGER l_b_sort
      INTEGER k_b_sort
      INTEGER l_b
      INTEGER k_b
      INTEGER l_c
      INTEGER k_c
      EXTERNAL NXTASK
      nprocs = GA_NNODES()
      count = 0
      next = NXTASK(nprocs,1)
      DO h3b = 1,noab
      DO p13b = noab+1,noab+nvab
      DO h11b = 1,noab
      DO p5b = noab+1,noab+nvab
      IF (next.eq.count) THEN
      IF ((.not.restricted).or.(int_mb(k_spin+h3b-1)+int_mb(k_spin+p13b-
     &1)+int_mb(k_spin+h11b-1)+int_mb(k_spin+p5b-1).ne.8)) THEN
      IF (int_mb(k_spin+h3b-1)+int_mb(k_spin+p13b-1) .eq. int_mb(k_spin+
     &h11b-1)+int_mb(k_spin+p5b-1)) THEN
      IF (ieor(int_mb(k_sym+h3b-1),ieor(int_mb(k_sym+p13b-1),ieor(int_mb
     &(k_sym+h11b-1),int_mb(k_sym+p5b-1)))) .eq. ieor(irrep_v,irrep_t)) 
     &THEN
      dimc = int_mb(k_range+h3b-1) * int_mb(k_range+p13b-1) * int_mb(k_r
     &ange+h11b-1) * int_mb(k_range+p5b-1)
      IF (.not.MA_PUSH_GET(mt_dbl,dimc,'noname',l_c_sort,k_c_sort)) CALL
     & ERRQUIT('eomccsdt_y2_10_3_2',0,MA_ERR)
      CALL DFILL(dimc,0.0d0,dbl_mb(k_c_sort),1)
      DO p7b = noab+1,noab+nvab
      IF (int_mb(k_spin+p7b-1) .eq. int_mb(k_spin+h11b-1)) THEN
      IF (ieor(int_mb(k_sym+p7b-1),int_mb(k_sym+h11b-1)) .eq. irrep_t) T
     &HEN
      CALL TCE_RESTRICTED_2(p7b,h11b,p7b_1,h11b_1)
      CALL TCE_RESTRICTED_4(h3b,p13b,p5b,p7b,h3b_2,p13b_2,p5b_2,p7b_2)
      dim_common = int_mb(k_range+p7b-1)
      dima_sort = int_mb(k_range+h11b-1)
      dima = dim_common * dima_sort
      dimb_sort = int_mb(k_range+h3b-1) * int_mb(k_range+p13b-1) * int_m
     &b(k_range+p5b-1)
      dimb = dim_common * dimb_sort
      IF ((dima .gt. 0) .and. (dimb .gt. 0)) THEN
      IF (.not.MA_PUSH_GET(mt_dbl,dima,'noname',l_a_sort,k_a_sort)) CALL
     & ERRQUIT('eomccsdt_y2_10_3_2',1,MA_ERR)
      IF (.not.MA_PUSH_GET(mt_dbl,dima,'noname',l_a,k_a)) CALL ERRQUIT('
     &eomccsdt_y2_10_3_2',2,MA_ERR)
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(h11b_
     &1 - 1 + noab * (p7b_1 - noab - 1)))
      CALL TCE_SORT_2(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+p7b-1)
     &,int_mb(k_range+h11b-1),2,1,1.0d0)
      IF (.not.MA_POP_STACK(l_a)) CALL ERRQUIT('eomccsdt_y2_10_3_2',3,MA
     &_ERR)
      IF (.not.MA_PUSH_GET(mt_dbl,dimb,'noname',l_b_sort,k_b_sort)) CALL
     & ERRQUIT('eomccsdt_y2_10_3_2',4,MA_ERR)
      IF (.not.MA_PUSH_GET(mt_dbl,dimb,'noname',l_b,k_b)) CALL ERRQUIT('
     &eomccsdt_y2_10_3_2',5,MA_ERR)
      IF ((h3b .le. p13b) .and. (p7b .lt. p5b)) THEN
      CALL GET_HASH_BLOCK(d_b,dbl_mb(k_b),dimb,int_mb(k_b_offset),(p5b_2
     & - 1 + (noab+nvab) * (p7b_2 - 1 + (noab+nvab) * (p13b_2 - 1 + (noa
     &b+nvab) * (h3b_2 - 1)))))
      CALL TCE_SORT_4(dbl_mb(k_b),dbl_mb(k_b_sort),int_mb(k_range+h3b-1)
     &,int_mb(k_range+p13b-1),int_mb(k_range+p7b-1),int_mb(k_range+p5b-1
     &),4,2,1,3,-1.0d0)
      END IF
      IF ((h3b .le. p13b) .and. (p5b .le. p7b)) THEN
      CALL GET_HASH_BLOCK(d_b,dbl_mb(k_b),dimb,int_mb(k_b_offset),(p7b_2
     & - 1 + (noab+nvab) * (p5b_2 - 1 + (noab+nvab) * (p13b_2 - 1 + (noa
     &b+nvab) * (h3b_2 - 1)))))
      CALL TCE_SORT_4(dbl_mb(k_b),dbl_mb(k_b_sort),int_mb(k_range+h3b-1)
     &,int_mb(k_range+p13b-1),int_mb(k_range+p5b-1),int_mb(k_range+p7b-1
     &),3,2,1,4,1.0d0)
      END IF
      IF (.not.MA_POP_STACK(l_b)) CALL ERRQUIT('eomccsdt_y2_10_3_2',6,MA
     &_ERR)
      CALL dgemm('T','N',dima_sort,dimb_sort,dim_common,1.0d0,dbl_mb(k_a
     &_sort),dim_common,dbl_mb(k_b_sort),dim_common,1.0d0,dbl_mb(k_c_sor
     &t),dima_sort)
      IF (.not.MA_POP_STACK(l_b_sort)) CALL ERRQUIT('eomccsdt_y2_10_3_2'
     &,7,MA_ERR)
      IF (.not.MA_POP_STACK(l_a_sort)) CALL ERRQUIT('eomccsdt_y2_10_3_2'
     &,8,MA_ERR)
      END IF
      END IF
      END IF
      END DO
      IF (.not.MA_PUSH_GET(mt_dbl,dimc,'noname',l_c,k_c)) CALL ERRQUIT('
     &eomccsdt_y2_10_3_2',9,MA_ERR)
      CALL TCE_SORT_4(dbl_mb(k_c_sort),dbl_mb(k_c),int_mb(k_range+p5b-1)
     &,int_mb(k_range+p13b-1),int_mb(k_range+h3b-1),int_mb(k_range+h11b-
     &1),3,2,4,1,-1.0d0/2.0d0)
      CALL ADD_HASH_BLOCK(d_c,dbl_mb(k_c),dimc,int_mb(k_c_offset),(p5b -
     & noab - 1 + nvab * (h11b - 1 + noab * (p13b - noab - 1 + nvab * (h
     &3b - 1)))))
      IF (.not.MA_POP_STACK(l_c)) CALL ERRQUIT('eomccsdt_y2_10_3_2',10,M
     &A_ERR)
      IF (.not.MA_POP_STACK(l_c_sort)) CALL ERRQUIT('eomccsdt_y2_10_3_2'
     &,11,MA_ERR)
      END IF
      END IF
      END IF
      next = NXTASK(nprocs,1)
      END IF
      count = count + 1
      END DO
      END DO
      END DO
      END DO
      next = NXTASK(-nprocs,1)
      call GA_SYNC()
      RETURN
      END
      SUBROUTINE eomccsdt_y2_10_3(d_a,k_a_offset,d_b,k_b_offset,d_c,k_c_
     &offset)
C     $Id: eomccsdt_y2_all12.F 24184 2013-05-04 00:43:17Z edo $
C     This is a Fortran77 program generated by Tensor Contraction Engine v.1.0
C     Copyright (c) Battelle & Pacific Northwest National Laboratory (2002)
C     i1 ( h3 p13 h11 h14 )_vt + = -2 * Sum ( p5 ) * t ( p5 h14 )_t * i2 ( h3 p13 h11 p5 )_v
      IMPLICIT NONE
#include "global.fh"
#include "mafdecls.fh"
#include "sym.fh"
#include "errquit.fh"
#include "tce.fh"
      INTEGER d_a
      INTEGER k_a_offset
      INTEGER d_b
      INTEGER k_b_offset
      INTEGER d_c
      INTEGER k_c_offset
      INTEGER NXTASK
      INTEGER next
      INTEGER nprocs
      INTEGER count
      INTEGER h3b
      INTEGER p13b
      INTEGER h14b
      INTEGER h11b
      INTEGER dimc
      INTEGER l_c_sort
      INTEGER k_c_sort
      INTEGER p5b
      INTEGER p5b_1
      INTEGER h14b_1
      INTEGER h3b_2
      INTEGER p13b_2
      INTEGER h11b_2
      INTEGER p5b_2
      INTEGER dim_common
      INTEGER dima_sort
      INTEGER dima
      INTEGER dimb_sort
      INTEGER dimb
      INTEGER l_a_sort
      INTEGER k_a_sort
      INTEGER l_a
      INTEGER k_a
      INTEGER l_b_sort
      INTEGER k_b_sort
      INTEGER l_b
      INTEGER k_b
      INTEGER l_c
      INTEGER k_c
      EXTERNAL NXTASK
      nprocs = GA_NNODES()
      count = 0
      next = NXTASK(nprocs,1)
      DO h3b = 1,noab
      DO p13b = noab+1,noab+nvab
      DO h14b = 1,noab
      DO h11b = 1,noab
      IF (next.eq.count) THEN
      IF ((.not.restricted).or.(int_mb(k_spin+h3b-1)+int_mb(k_spin+p13b-
     &1)+int_mb(k_spin+h11b-1)+int_mb(k_spin+h14b-1).ne.8)) THEN
      IF (int_mb(k_spin+h3b-1)+int_mb(k_spin+p13b-1) .eq. int_mb(k_spin+
     &h11b-1)+int_mb(k_spin+h14b-1)) THEN
      IF (ieor(int_mb(k_sym+h3b-1),ieor(int_mb(k_sym+p13b-1),ieor(int_mb
     &(k_sym+h11b-1),int_mb(k_sym+h14b-1)))) .eq. ieor(irrep_v,irrep_t))
     & THEN
      dimc = int_mb(k_range+h3b-1) * int_mb(k_range+p13b-1) * int_mb(k_r
     &ange+h11b-1) * int_mb(k_range+h14b-1)
      IF (.not.MA_PUSH_GET(mt_dbl,dimc,'noname',l_c_sort,k_c_sort)) CALL
     & ERRQUIT('eomccsdt_y2_10_3',0,MA_ERR)
      CALL DFILL(dimc,0.0d0,dbl_mb(k_c_sort),1)
      DO p5b = noab+1,noab+nvab
      IF (int_mb(k_spin+p5b-1) .eq. int_mb(k_spin+h14b-1)) THEN
      IF (ieor(int_mb(k_sym+p5b-1),int_mb(k_sym+h14b-1)) .eq. irrep_t) T
     &HEN
      CALL TCE_RESTRICTED_2(p5b,h14b,p5b_1,h14b_1)
      CALL TCE_RESTRICTED_4(h3b,p13b,h11b,p5b,h3b_2,p13b_2,h11b_2,p5b_2)
      dim_common = int_mb(k_range+p5b-1)
      dima_sort = int_mb(k_range+h14b-1)
      dima = dim_common * dima_sort
      dimb_sort = int_mb(k_range+h3b-1) * int_mb(k_range+p13b-1) * int_m
     &b(k_range+h11b-1)
      dimb = dim_common * dimb_sort
      IF ((dima .gt. 0) .and. (dimb .gt. 0)) THEN
      IF (.not.MA_PUSH_GET(mt_dbl,dima,'noname',l_a_sort,k_a_sort)) CALL
     & ERRQUIT('eomccsdt_y2_10_3',1,MA_ERR)
      IF (.not.MA_PUSH_GET(mt_dbl,dima,'noname',l_a,k_a)) CALL ERRQUIT('
     &eomccsdt_y2_10_3',2,MA_ERR)
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(h14b_
     &1 - 1 + noab * (p5b_1 - noab - 1)))
      CALL TCE_SORT_2(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+p5b-1)
     &,int_mb(k_range+h14b-1),2,1,1.0d0)
      IF (.not.MA_POP_STACK(l_a)) CALL ERRQUIT('eomccsdt_y2_10_3',3,MA_E
     &RR)
      IF (.not.MA_PUSH_GET(mt_dbl,dimb,'noname',l_b_sort,k_b_sort)) CALL
     & ERRQUIT('eomccsdt_y2_10_3',4,MA_ERR)
      IF (.not.MA_PUSH_GET(mt_dbl,dimb,'noname',l_b,k_b)) CALL ERRQUIT('
     &eomccsdt_y2_10_3',5,MA_ERR)
      IF ((h11b .le. p5b)) THEN
      CALL GET_HASH_BLOCK(d_b,dbl_mb(k_b),dimb,int_mb(k_b_offset),(p5b_2
     & - noab - 1 + nvab * (h11b_2 - 1 + noab * (p13b_2 - noab - 1 + nva
     &b * (h3b_2 - 1)))))
      CALL TCE_SORT_4(dbl_mb(k_b),dbl_mb(k_b_sort),int_mb(k_range+h3b-1)
     &,int_mb(k_range+p13b-1),int_mb(k_range+h11b-1),int_mb(k_range+p5b-
     &1),3,2,1,4,1.0d0)
      END IF
      IF (.not.MA_POP_STACK(l_b)) CALL ERRQUIT('eomccsdt_y2_10_3',6,MA_E
     &RR)
      CALL dgemm('T','N',dima_sort,dimb_sort,dim_common,1.0d0,dbl_mb(k_a
     &_sort),dim_common,dbl_mb(k_b_sort),dim_common,1.0d0,dbl_mb(k_c_sor
     &t),dima_sort)
      IF (.not.MA_POP_STACK(l_b_sort)) CALL ERRQUIT('eomccsdt_y2_10_3',7
     &,MA_ERR)
      IF (.not.MA_POP_STACK(l_a_sort)) CALL ERRQUIT('eomccsdt_y2_10_3',8
     &,MA_ERR)
      END IF
      END IF
      END IF
      END DO
      IF (.not.MA_PUSH_GET(mt_dbl,dimc,'noname',l_c,k_c)) CALL ERRQUIT('
     &eomccsdt_y2_10_3',9,MA_ERR)
      IF ((h11b .le. h14b)) THEN
      CALL TCE_SORT_4(dbl_mb(k_c_sort),dbl_mb(k_c),int_mb(k_range+h11b-1
     &),int_mb(k_range+p13b-1),int_mb(k_range+h3b-1),int_mb(k_range+h14b
     &-1),3,2,1,4,-1.0d0)
      CALL ADD_HASH_BLOCK(d_c,dbl_mb(k_c),dimc,int_mb(k_c_offset),(h14b 
     &- 1 + noab * (h11b - 1 + noab * (p13b - noab - 1 + nvab * (h3b - 1
     &)))))
      END IF
      IF ((h14b .le. h11b)) THEN
      CALL TCE_SORT_4(dbl_mb(k_c_sort),dbl_mb(k_c),int_mb(k_range+h11b-1
     &),int_mb(k_range+p13b-1),int_mb(k_range+h3b-1),int_mb(k_range+h14b
     &-1),3,2,4,1,1.0d0)
      CALL ADD_HASH_BLOCK(d_c,dbl_mb(k_c),dimc,int_mb(k_c_offset),(h11b 
     &- 1 + noab * (h14b - 1 + noab * (p13b - noab - 1 + nvab * (h3b - 1
     &)))))
      END IF
      IF (.not.MA_POP_STACK(l_c)) CALL ERRQUIT('eomccsdt_y2_10_3',10,MA_
     &ERR)
      IF (.not.MA_POP_STACK(l_c_sort)) CALL ERRQUIT('eomccsdt_y2_10_3',1
     &1,MA_ERR)
      END IF
      END IF
      END IF
      next = NXTASK(nprocs,1)
      END IF
      count = count + 1
      END DO
      END DO
      END DO
      END DO
      next = NXTASK(-nprocs,1)
      call GA_SYNC()
      RETURN
      END
      SUBROUTINE eomccsdt_y2_10_4_1(d_a,k_a_offset,d_c,k_c_offset)
C     $Id: eomccsdt_y2_all12.F 24184 2013-05-04 00:43:17Z edo $
C     This is a Fortran77 program generated by Tensor Contraction Engine v.1.0
C     Copyright (c) Battelle & Pacific Northwest National Laboratory (2002)
C     i2 ( h3 p7 )_f + = 1 * f ( h3 p7 )_f
      IMPLICIT NONE
#include "global.fh"
#include "mafdecls.fh"
#include "sym.fh"
#include "errquit.fh"
#include "tce.fh"
      INTEGER d_a
      INTEGER k_a_offset
      INTEGER d_c
      INTEGER k_c_offset
      INTEGER NXTASK
      INTEGER next
      INTEGER nprocs
      INTEGER count
      INTEGER h3b
      INTEGER p7b
      INTEGER dimc
      INTEGER h3b_1
      INTEGER p7b_1
      INTEGER dim_common
      INTEGER dima_sort
      INTEGER dima
      INTEGER l_a_sort
      INTEGER k_a_sort
      INTEGER l_a
      INTEGER k_a
      INTEGER l_c
      INTEGER k_c
      EXTERNAL NXTASK
      nprocs = GA_NNODES()
      count = 0
      next = NXTASK(nprocs,1)
      DO h3b = 1,noab
      DO p7b = noab+1,noab+nvab
      IF (next.eq.count) THEN
      IF ((.not.restricted).or.(int_mb(k_spin+h3b-1)+int_mb(k_spin+p7b-1
     &).ne.4)) THEN
      IF (int_mb(k_spin+h3b-1) .eq. int_mb(k_spin+p7b-1)) THEN
      IF (ieor(int_mb(k_sym+h3b-1),int_mb(k_sym+p7b-1)) .eq. irrep_f) TH
     &EN
      dimc = int_mb(k_range+h3b-1) * int_mb(k_range+p7b-1)
      CALL TCE_RESTRICTED_2(h3b,p7b,h3b_1,p7b_1)
      dim_common = 1
      dima_sort = int_mb(k_range+h3b-1) * int_mb(k_range+p7b-1)
      dima = dim_common * dima_sort
      IF (dima .gt. 0) THEN
      IF (.not.MA_PUSH_GET(mt_dbl,dima,'noname',l_a_sort,k_a_sort)) CALL
     & ERRQUIT('eomccsdt_y2_10_4_1',0,MA_ERR)
      IF (.not.MA_PUSH_GET(mt_dbl,dima,'noname',l_a,k_a)) CALL ERRQUIT('
     &eomccsdt_y2_10_4_1',1,MA_ERR)
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(p7b_1
     & - 1 + (noab+nvab) * (h3b_1 - 1)))
      CALL TCE_SORT_2(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+h3b-1)
     &,int_mb(k_range+p7b-1),2,1,1.0d0)
      IF (.not.MA_POP_STACK(l_a)) CALL ERRQUIT('eomccsdt_y2_10_4_1',2,MA
     &_ERR)
      IF (.not.MA_PUSH_GET(mt_dbl,dimc,'noname',l_c,k_c)) CALL ERRQUIT('
     &eomccsdt_y2_10_4_1',3,MA_ERR)
      CALL TCE_SORT_2(dbl_mb(k_a_sort),dbl_mb(k_c),int_mb(k_range+p7b-1)
     &,int_mb(k_range+h3b-1),2,1,1.0d0)
      CALL ADD_HASH_BLOCK(d_c,dbl_mb(k_c),dimc,int_mb(k_c_offset),(p7b -
     & noab - 1 + nvab * (h3b - 1)))
      IF (.not.MA_POP_STACK(l_c)) CALL ERRQUIT('eomccsdt_y2_10_4_1',4,MA
     &_ERR)
      IF (.not.MA_POP_STACK(l_a_sort)) CALL ERRQUIT('eomccsdt_y2_10_4_1'
     &,5,MA_ERR)
      END IF
      END IF
      END IF
      END IF
      next = NXTASK(nprocs,1)
      END IF
      count = count + 1
      END DO
      END DO
      next = NXTASK(-nprocs,1)
      call GA_SYNC()
      RETURN
      END
      SUBROUTINE eomccsdt_y2_10_4_2(d_a,k_a_offset,d_b,k_b_offset,d_c,k_
     &c_offset)
C     $Id: eomccsdt_y2_all12.F 24184 2013-05-04 00:43:17Z edo $
C     This is a Fortran77 program generated by Tensor Contraction Engine v.1.0
C     Copyright (c) Battelle & Pacific Northwest National Laboratory (2002)
C     i2 ( h3 p7 )_vt + = 1 * Sum ( h10 p9 ) * t ( p9 h10 )_t * v ( h3 h10 p7 p9 )_v
      IMPLICIT NONE
#include "global.fh"
#include "mafdecls.fh"
#include "sym.fh"
#include "errquit.fh"
#include "tce.fh"
      INTEGER d_a
      INTEGER k_a_offset
      INTEGER d_b
      INTEGER k_b_offset
      INTEGER d_c
      INTEGER k_c_offset
      INTEGER NXTASK
      INTEGER next
      INTEGER nprocs
      INTEGER count
      INTEGER h3b
      INTEGER p7b
      INTEGER dimc
      INTEGER l_c_sort
      INTEGER k_c_sort
      INTEGER p9b
      INTEGER h10b
      INTEGER p9b_1
      INTEGER h10b_1
      INTEGER h3b_2
      INTEGER h10b_2
      INTEGER p7b_2
      INTEGER p9b_2
      INTEGER dim_common
      INTEGER dima_sort
      INTEGER dima
      INTEGER dimb_sort
      INTEGER dimb
      INTEGER l_a_sort
      INTEGER k_a_sort
      INTEGER l_a
      INTEGER k_a
      INTEGER l_b_sort
      INTEGER k_b_sort
      INTEGER l_b
      INTEGER k_b
      INTEGER l_c
      INTEGER k_c
      EXTERNAL NXTASK
      nprocs = GA_NNODES()
      count = 0
      next = NXTASK(nprocs,1)
      DO h3b = 1,noab
      DO p7b = noab+1,noab+nvab
      IF (next.eq.count) THEN
      IF ((.not.restricted).or.(int_mb(k_spin+h3b-1)+int_mb(k_spin+p7b-1
     &).ne.4)) THEN
      IF (int_mb(k_spin+h3b-1) .eq. int_mb(k_spin+p7b-1)) THEN
      IF (ieor(int_mb(k_sym+h3b-1),int_mb(k_sym+p7b-1)) .eq. ieor(irrep_
     &v,irrep_t)) THEN
      dimc = int_mb(k_range+h3b-1) * int_mb(k_range+p7b-1)
      IF (.not.MA_PUSH_GET(mt_dbl,dimc,'noname',l_c_sort,k_c_sort)) CALL
     & ERRQUIT('eomccsdt_y2_10_4_2',0,MA_ERR)
      CALL DFILL(dimc,0.0d0,dbl_mb(k_c_sort),1)
      DO p9b = noab+1,noab+nvab
      DO h10b = 1,noab
      IF (int_mb(k_spin+p9b-1) .eq. int_mb(k_spin+h10b-1)) THEN
      IF (ieor(int_mb(k_sym+p9b-1),int_mb(k_sym+h10b-1)) .eq. irrep_t) T
     &HEN
      CALL TCE_RESTRICTED_2(p9b,h10b,p9b_1,h10b_1)
      CALL TCE_RESTRICTED_4(h3b,h10b,p7b,p9b,h3b_2,h10b_2,p7b_2,p9b_2)
      dim_common = int_mb(k_range+p9b-1) * int_mb(k_range+h10b-1)
      dima_sort = 1
      dima = dim_common * dima_sort
      dimb_sort = int_mb(k_range+h3b-1) * int_mb(k_range+p7b-1)
      dimb = dim_common * dimb_sort
      IF ((dima .gt. 0) .and. (dimb .gt. 0)) THEN
      IF (.not.MA_PUSH_GET(mt_dbl,dima,'noname',l_a_sort,k_a_sort)) CALL
     & ERRQUIT('eomccsdt_y2_10_4_2',1,MA_ERR)
      IF (.not.MA_PUSH_GET(mt_dbl,dima,'noname',l_a,k_a)) CALL ERRQUIT('
     &eomccsdt_y2_10_4_2',2,MA_ERR)
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(h10b_
     &1 - 1 + noab * (p9b_1 - noab - 1)))
      CALL TCE_SORT_2(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+p9b-1)
     &,int_mb(k_range+h10b-1),2,1,1.0d0)
      IF (.not.MA_POP_STACK(l_a)) CALL ERRQUIT('eomccsdt_y2_10_4_2',3,MA
     &_ERR)
      IF (.not.MA_PUSH_GET(mt_dbl,dimb,'noname',l_b_sort,k_b_sort)) CALL
     & ERRQUIT('eomccsdt_y2_10_4_2',4,MA_ERR)
      IF (.not.MA_PUSH_GET(mt_dbl,dimb,'noname',l_b,k_b)) CALL ERRQUIT('
     &eomccsdt_y2_10_4_2',5,MA_ERR)
      IF ((h10b .lt. h3b) .and. (p9b .lt. p7b)) THEN
      CALL GET_HASH_BLOCK(d_b,dbl_mb(k_b),dimb,int_mb(k_b_offset),(p7b_2
     & - 1 + (noab+nvab) * (p9b_2 - 1 + (noab+nvab) * (h3b_2 - 1 + (noab
     &+nvab) * (h10b_2 - 1)))))
      CALL TCE_SORT_4(dbl_mb(k_b),dbl_mb(k_b_sort),int_mb(k_range+h10b-1
     &),int_mb(k_range+h3b-1),int_mb(k_range+p9b-1),int_mb(k_range+p7b-1
     &),4,2,1,3,1.0d0)
      END IF
      IF ((h10b .lt. h3b) .and. (p7b .le. p9b)) THEN
      CALL GET_HASH_BLOCK(d_b,dbl_mb(k_b),dimb,int_mb(k_b_offset),(p9b_2
     & - 1 + (noab+nvab) * (p7b_2 - 1 + (noab+nvab) * (h3b_2 - 1 + (noab
     &+nvab) * (h10b_2 - 1)))))
      CALL TCE_SORT_4(dbl_mb(k_b),dbl_mb(k_b_sort),int_mb(k_range+h10b-1
     &),int_mb(k_range+h3b-1),int_mb(k_range+p7b-1),int_mb(k_range+p9b-1
     &),3,2,1,4,-1.0d0)
      END IF
      IF ((h3b .le. h10b) .and. (p9b .lt. p7b)) THEN
      CALL GET_HASH_BLOCK(d_b,dbl_mb(k_b),dimb,int_mb(k_b_offset),(p7b_2
     & - 1 + (noab+nvab) * (p9b_2 - 1 + (noab+nvab) * (h10b_2 - 1 + (noa
     &b+nvab) * (h3b_2 - 1)))))
      CALL TCE_SORT_4(dbl_mb(k_b),dbl_mb(k_b_sort),int_mb(k_range+h3b-1)
     &,int_mb(k_range+h10b-1),int_mb(k_range+p9b-1),int_mb(k_range+p7b-1
     &),4,1,2,3,-1.0d0)
      END IF
      IF ((h3b .le. h10b) .and. (p7b .le. p9b)) THEN
      CALL GET_HASH_BLOCK(d_b,dbl_mb(k_b),dimb,int_mb(k_b_offset),(p9b_2
     & - 1 + (noab+nvab) * (p7b_2 - 1 + (noab+nvab) * (h10b_2 - 1 + (noa
     &b+nvab) * (h3b_2 - 1)))))
      CALL TCE_SORT_4(dbl_mb(k_b),dbl_mb(k_b_sort),int_mb(k_range+h3b-1)
     &,int_mb(k_range+h10b-1),int_mb(k_range+p7b-1),int_mb(k_range+p9b-1
     &),3,1,2,4,1.0d0)
      END IF
      IF (.not.MA_POP_STACK(l_b)) CALL ERRQUIT('eomccsdt_y2_10_4_2',6,MA
     &_ERR)
      CALL dgemm('T','N',dima_sort,dimb_sort,dim_common,1.0d0,dbl_mb(k_a
     &_sort),dim_common,dbl_mb(k_b_sort),dim_common,1.0d0,dbl_mb(k_c_sor
     &t),dima_sort)
      IF (.not.MA_POP_STACK(l_b_sort)) CALL ERRQUIT('eomccsdt_y2_10_4_2'
     &,7,MA_ERR)
      IF (.not.MA_POP_STACK(l_a_sort)) CALL ERRQUIT('eomccsdt_y2_10_4_2'
     &,8,MA_ERR)
      END IF
      END IF
      END IF
      END DO
      END DO
      IF (.not.MA_PUSH_GET(mt_dbl,dimc,'noname',l_c,k_c)) CALL ERRQUIT('
     &eomccsdt_y2_10_4_2',9,MA_ERR)
      CALL TCE_SORT_2(dbl_mb(k_c_sort),dbl_mb(k_c),int_mb(k_range+p7b-1)
     &,int_mb(k_range+h3b-1),2,1,1.0d0)
      CALL ADD_HASH_BLOCK(d_c,dbl_mb(k_c),dimc,int_mb(k_c_offset),(p7b -
     & noab - 1 + nvab * (h3b - 1)))
      IF (.not.MA_POP_STACK(l_c)) CALL ERRQUIT('eomccsdt_y2_10_4_2',10,M
     &A_ERR)
      IF (.not.MA_POP_STACK(l_c_sort)) CALL ERRQUIT('eomccsdt_y2_10_4_2'
     &,11,MA_ERR)
      END IF
      END IF
      END IF
      next = NXTASK(nprocs,1)
      END IF
      count = count + 1
      END DO
      END DO
      next = NXTASK(-nprocs,1)
      call GA_SYNC()
      RETURN
      END
      SUBROUTINE eomccsdt_y2_10_4(d_a,k_a_offset,d_b,k_b_offset,d_c,k_c_
     &offset)
C     $Id: eomccsdt_y2_all12.F 24184 2013-05-04 00:43:17Z edo $
C     This is a Fortran77 program generated by Tensor Contraction Engine v.1.0
C     Copyright (c) Battelle & Pacific Northwest National Laboratory (2002)
C     i1 ( h3 p13 h11 h14 )_ft + = -1 * Sum ( p7 ) * t ( p7 p13 h11 h14 )_t * i2 ( h3 p7 )_f
      IMPLICIT NONE
#include "global.fh"
#include "mafdecls.fh"
#include "sym.fh"
#include "errquit.fh"
#include "tce.fh"
      INTEGER d_a
      INTEGER k_a_offset
      INTEGER d_b
      INTEGER k_b_offset
      INTEGER d_c
      INTEGER k_c_offset
      INTEGER NXTASK
      INTEGER next
      INTEGER nprocs
      INTEGER count
      INTEGER h3b
      INTEGER p13b
      INTEGER h11b
      INTEGER h14b
      INTEGER dimc
      INTEGER l_c_sort
      INTEGER k_c_sort
      INTEGER p7b
      INTEGER p13b_1
      INTEGER p7b_1
      INTEGER h11b_1
      INTEGER h14b_1
      INTEGER h3b_2
      INTEGER p7b_2
      INTEGER dim_common
      INTEGER dima_sort
      INTEGER dima
      INTEGER dimb_sort
      INTEGER dimb
      INTEGER l_a_sort
      INTEGER k_a_sort
      INTEGER l_a
      INTEGER k_a
      INTEGER l_b_sort
      INTEGER k_b_sort
      INTEGER l_b
      INTEGER k_b
      INTEGER l_c
      INTEGER k_c
      EXTERNAL NXTASK
      nprocs = GA_NNODES()
      count = 0
      next = NXTASK(nprocs,1)
      DO h3b = 1,noab
      DO p13b = noab+1,noab+nvab
      DO h11b = 1,noab
      DO h14b = h11b,noab
      IF (next.eq.count) THEN
      IF ((.not.restricted).or.(int_mb(k_spin+h3b-1)+int_mb(k_spin+p13b-
     &1)+int_mb(k_spin+h11b-1)+int_mb(k_spin+h14b-1).ne.8)) THEN
      IF (int_mb(k_spin+h3b-1)+int_mb(k_spin+p13b-1) .eq. int_mb(k_spin+
     &h11b-1)+int_mb(k_spin+h14b-1)) THEN
      IF (ieor(int_mb(k_sym+h3b-1),ieor(int_mb(k_sym+p13b-1),ieor(int_mb
     &(k_sym+h11b-1),int_mb(k_sym+h14b-1)))) .eq. ieor(irrep_f,irrep_t))
     & THEN
      dimc = int_mb(k_range+h3b-1) * int_mb(k_range+p13b-1) * int_mb(k_r
     &ange+h11b-1) * int_mb(k_range+h14b-1)
      IF (.not.MA_PUSH_GET(mt_dbl,dimc,'noname',l_c_sort,k_c_sort)) CALL
     & ERRQUIT('eomccsdt_y2_10_4',0,MA_ERR)
      CALL DFILL(dimc,0.0d0,dbl_mb(k_c_sort),1)
      DO p7b = noab+1,noab+nvab
      IF (int_mb(k_spin+p13b-1)+int_mb(k_spin+p7b-1) .eq. int_mb(k_spin+
     &h11b-1)+int_mb(k_spin+h14b-1)) THEN
      IF (ieor(int_mb(k_sym+p13b-1),ieor(int_mb(k_sym+p7b-1),ieor(int_mb
     &(k_sym+h11b-1),int_mb(k_sym+h14b-1)))) .eq. irrep_t) THEN
      CALL TCE_RESTRICTED_4(p13b,p7b,h11b,h14b,p13b_1,p7b_1,h11b_1,h14b_
     &1)
      CALL TCE_RESTRICTED_2(h3b,p7b,h3b_2,p7b_2)
      dim_common = int_mb(k_range+p7b-1)
      dima_sort = int_mb(k_range+p13b-1) * int_mb(k_range+h11b-1) * int_
     &mb(k_range+h14b-1)
      dima = dim_common * dima_sort
      dimb_sort = int_mb(k_range+h3b-1)
      dimb = dim_common * dimb_sort
      IF ((dima .gt. 0) .and. (dimb .gt. 0)) THEN
      IF (.not.MA_PUSH_GET(mt_dbl,dima,'noname',l_a_sort,k_a_sort)) CALL
     & ERRQUIT('eomccsdt_y2_10_4',1,MA_ERR)
      IF (.not.MA_PUSH_GET(mt_dbl,dima,'noname',l_a,k_a)) CALL ERRQUIT('
     &eomccsdt_y2_10_4',2,MA_ERR)
      IF ((p7b .le. p13b)) THEN
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(h14b_
     &1 - 1 + noab * (h11b_1 - 1 + noab * (p13b_1 - noab - 1 + nvab * (p
     &7b_1 - noab - 1)))))
      CALL TCE_SORT_4(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+p7b-1)
     &,int_mb(k_range+p13b-1),int_mb(k_range+h11b-1),int_mb(k_range+h14b
     &-1),4,3,2,1,1.0d0)
      END IF
      IF ((p13b .lt. p7b)) THEN
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(h14b_
     &1 - 1 + noab * (h11b_1 - 1 + noab * (p7b_1 - noab - 1 + nvab * (p1
     &3b_1 - noab - 1)))))
      CALL TCE_SORT_4(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+p13b-1
     &),int_mb(k_range+p7b-1),int_mb(k_range+h11b-1),int_mb(k_range+h14b
     &-1),4,3,1,2,-1.0d0)
      END IF
      IF (.not.MA_POP_STACK(l_a)) CALL ERRQUIT('eomccsdt_y2_10_4',3,MA_E
     &RR)
      IF (.not.MA_PUSH_GET(mt_dbl,dimb,'noname',l_b_sort,k_b_sort)) CALL
     & ERRQUIT('eomccsdt_y2_10_4',4,MA_ERR)
      IF (.not.MA_PUSH_GET(mt_dbl,dimb,'noname',l_b,k_b)) CALL ERRQUIT('
     &eomccsdt_y2_10_4',5,MA_ERR)
      CALL GET_HASH_BLOCK(d_b,dbl_mb(k_b),dimb,int_mb(k_b_offset),(p7b_2
     & - noab - 1 + nvab * (h3b_2 - 1)))
      CALL TCE_SORT_2(dbl_mb(k_b),dbl_mb(k_b_sort),int_mb(k_range+h3b-1)
     &,int_mb(k_range+p7b-1),1,2,1.0d0)
      IF (.not.MA_POP_STACK(l_b)) CALL ERRQUIT('eomccsdt_y2_10_4',6,MA_E
     &RR)
      CALL dgemm('T','N',dima_sort,dimb_sort,dim_common,1.0d0,dbl_mb(k_a
     &_sort),dim_common,dbl_mb(k_b_sort),dim_common,1.0d0,dbl_mb(k_c_sor
     &t),dima_sort)
      IF (.not.MA_POP_STACK(l_b_sort)) CALL ERRQUIT('eomccsdt_y2_10_4',7
     &,MA_ERR)
      IF (.not.MA_POP_STACK(l_a_sort)) CALL ERRQUIT('eomccsdt_y2_10_4',8
     &,MA_ERR)
      END IF
      END IF
      END IF
      END DO
      IF (.not.MA_PUSH_GET(mt_dbl,dimc,'noname',l_c,k_c)) CALL ERRQUIT('
     &eomccsdt_y2_10_4',9,MA_ERR)
      CALL TCE_SORT_4(dbl_mb(k_c_sort),dbl_mb(k_c),int_mb(k_range+h3b-1)
     &,int_mb(k_range+h14b-1),int_mb(k_range+h11b-1),int_mb(k_range+p13b
     &-1),1,4,3,2,-1.0d0)
      CALL ADD_HASH_BLOCK(d_c,dbl_mb(k_c),dimc,int_mb(k_c_offset),(h14b 
     &- 1 + noab * (h11b - 1 + noab * (p13b - noab - 1 + nvab * (h3b - 1
     &)))))
      IF (.not.MA_POP_STACK(l_c)) CALL ERRQUIT('eomccsdt_y2_10_4',10,MA_
     &ERR)
      IF (.not.MA_POP_STACK(l_c_sort)) CALL ERRQUIT('eomccsdt_y2_10_4',1
     &1,MA_ERR)
      END IF
      END IF
      END IF
      next = NXTASK(nprocs,1)
      END IF
      count = count + 1
      END DO
      END DO
      END DO
      END DO
      next = NXTASK(-nprocs,1)
      call GA_SYNC()
      RETURN
      END
      SUBROUTINE eomccsdt_y2_10_5_1(d_a,k_a_offset,d_c,k_c_offset)
C     $Id: eomccsdt_y2_all12.F 24184 2013-05-04 00:43:17Z edo $
C     This is a Fortran77 program generated by Tensor Contraction Engine v.1.0
C     Copyright (c) Battelle & Pacific Northwest National Laboratory (2002)
C     i2 ( h3 h8 h11 p6 )_v + = 1 * v ( h3 h8 h11 p6 )_v
      IMPLICIT NONE
#include "global.fh"
#include "mafdecls.fh"
#include "sym.fh"
#include "errquit.fh"
#include "tce.fh"
      INTEGER d_a
      INTEGER k_a_offset
      INTEGER d_c
      INTEGER k_c_offset
      INTEGER NXTASK
      INTEGER next
      INTEGER nprocs
      INTEGER count
      INTEGER h3b
      INTEGER h8b
      INTEGER h11b
      INTEGER p6b
      INTEGER dimc
      INTEGER h3b_1
      INTEGER h8b_1
      INTEGER h11b_1
      INTEGER p6b_1
      INTEGER dim_common
      INTEGER dima_sort
      INTEGER dima
      INTEGER l_a_sort
      INTEGER k_a_sort
      INTEGER l_a
      INTEGER k_a
      INTEGER l_c
      INTEGER k_c
      EXTERNAL NXTASK
      nprocs = GA_NNODES()
      count = 0
      next = NXTASK(nprocs,1)
      DO h3b = 1,noab
      DO h8b = 1,noab
      DO h11b = 1,noab
      DO p6b = noab+1,noab+nvab
      IF (next.eq.count) THEN
      IF ((.not.restricted).or.(int_mb(k_spin+h3b-1)+int_mb(k_spin+h8b-1
     &)+int_mb(k_spin+h11b-1)+int_mb(k_spin+p6b-1).ne.8)) THEN
      IF (int_mb(k_spin+h3b-1)+int_mb(k_spin+h8b-1) .eq. int_mb(k_spin+h
     &11b-1)+int_mb(k_spin+p6b-1)) THEN
      IF (ieor(int_mb(k_sym+h3b-1),ieor(int_mb(k_sym+h8b-1),ieor(int_mb(
     &k_sym+h11b-1),int_mb(k_sym+p6b-1)))) .eq. irrep_v) THEN
      dimc = int_mb(k_range+h3b-1) * int_mb(k_range+h8b-1) * int_mb(k_ra
     &nge+h11b-1) * int_mb(k_range+p6b-1)
      CALL TCE_RESTRICTED_4(h3b,h8b,h11b,p6b,h3b_1,h8b_1,h11b_1,p6b_1)
      dim_common = 1
      dima_sort = int_mb(k_range+h3b-1) * int_mb(k_range+h8b-1) * int_mb
     &(k_range+h11b-1) * int_mb(k_range+p6b-1)
      dima = dim_common * dima_sort
      IF (dima .gt. 0) THEN
      IF (.not.MA_PUSH_GET(mt_dbl,dima,'noname',l_a_sort,k_a_sort)) CALL
     & ERRQUIT('eomccsdt_y2_10_5_1',0,MA_ERR)
      IF (.not.MA_PUSH_GET(mt_dbl,dima,'noname',l_a,k_a)) CALL ERRQUIT('
     &eomccsdt_y2_10_5_1',1,MA_ERR)
      IF ((h8b .lt. h3b)) THEN
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(p6b_1
     & - 1 + (noab+nvab) * (h11b_1 - 1 + (noab+nvab) * (h3b_1 - 1 + (noa
     &b+nvab) * (h8b_1 - 1)))))
      CALL TCE_SORT_4(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+h8b-1)
     &,int_mb(k_range+h3b-1),int_mb(k_range+h11b-1),int_mb(k_range+p6b-1
     &),4,3,1,2,-1.0d0)
      END IF
      IF ((h3b .le. h8b)) THEN
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(p6b_1
     & - 1 + (noab+nvab) * (h11b_1 - 1 + (noab+nvab) * (h8b_1 - 1 + (noa
     &b+nvab) * (h3b_1 - 1)))))
      CALL TCE_SORT_4(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+h3b-1)
     &,int_mb(k_range+h8b-1),int_mb(k_range+h11b-1),int_mb(k_range+p6b-1
     &),4,3,2,1,1.0d0)
      END IF
      IF (.not.MA_POP_STACK(l_a)) CALL ERRQUIT('eomccsdt_y2_10_5_1',2,MA
     &_ERR)
      IF (.not.MA_PUSH_GET(mt_dbl,dimc,'noname',l_c,k_c)) CALL ERRQUIT('
     &eomccsdt_y2_10_5_1',3,MA_ERR)
      CALL TCE_SORT_4(dbl_mb(k_a_sort),dbl_mb(k_c),int_mb(k_range+p6b-1)
     &,int_mb(k_range+h11b-1),int_mb(k_range+h8b-1),int_mb(k_range+h3b-1
     &),4,3,2,1,1.0d0)
      CALL ADD_HASH_BLOCK(d_c,dbl_mb(k_c),dimc,int_mb(k_c_offset),(p6b -
     & noab - 1 + nvab * (h11b - 1 + noab * (h8b - 1 + noab * (h3b - 1))
     &)))
      IF (.not.MA_POP_STACK(l_c)) CALL ERRQUIT('eomccsdt_y2_10_5_1',4,MA
     &_ERR)
      IF (.not.MA_POP_STACK(l_a_sort)) CALL ERRQUIT('eomccsdt_y2_10_5_1'
     &,5,MA_ERR)
      END IF
      END IF
      END IF
      END IF
      next = NXTASK(nprocs,1)
      END IF
      count = count + 1
      END DO
      END DO
      END DO
      END DO
      next = NXTASK(-nprocs,1)
      call GA_SYNC()
      RETURN
      END
      SUBROUTINE eomccsdt_y2_10_5_2(d_a,k_a_offset,d_b,k_b_offset,d_c,k_
     &c_offset)
C     $Id: eomccsdt_y2_all12.F 24184 2013-05-04 00:43:17Z edo $
C     This is a Fortran77 program generated by Tensor Contraction Engine v.1.0
C     Copyright (c) Battelle & Pacific Northwest National Laboratory (2002)
C     i2 ( h3 h8 h11 p6 )_vt + = -1 * Sum ( p9 ) * t ( p9 h11 )_t * v ( h3 h8 p6 p9 )_v
      IMPLICIT NONE
#include "global.fh"
#include "mafdecls.fh"
#include "sym.fh"
#include "errquit.fh"
#include "tce.fh"
      INTEGER d_a
      INTEGER k_a_offset
      INTEGER d_b
      INTEGER k_b_offset
      INTEGER d_c
      INTEGER k_c_offset
      INTEGER NXTASK
      INTEGER next
      INTEGER nprocs
      INTEGER count
      INTEGER h3b
      INTEGER h8b
      INTEGER h11b
      INTEGER p6b
      INTEGER dimc
      INTEGER l_c_sort
      INTEGER k_c_sort
      INTEGER p9b
      INTEGER p9b_1
      INTEGER h11b_1
      INTEGER h3b_2
      INTEGER h8b_2
      INTEGER p6b_2
      INTEGER p9b_2
      INTEGER dim_common
      INTEGER dima_sort
      INTEGER dima
      INTEGER dimb_sort
      INTEGER dimb
      INTEGER l_a_sort
      INTEGER k_a_sort
      INTEGER l_a
      INTEGER k_a
      INTEGER l_b_sort
      INTEGER k_b_sort
      INTEGER l_b
      INTEGER k_b
      INTEGER l_c
      INTEGER k_c
      EXTERNAL NXTASK
      nprocs = GA_NNODES()
      count = 0
      next = NXTASK(nprocs,1)
      DO h3b = 1,noab
      DO h8b = 1,noab
      DO h11b = 1,noab
      DO p6b = noab+1,noab+nvab
      IF (next.eq.count) THEN
      IF ((.not.restricted).or.(int_mb(k_spin+h3b-1)+int_mb(k_spin+h8b-1
     &)+int_mb(k_spin+h11b-1)+int_mb(k_spin+p6b-1).ne.8)) THEN
      IF (int_mb(k_spin+h3b-1)+int_mb(k_spin+h8b-1) .eq. int_mb(k_spin+h
     &11b-1)+int_mb(k_spin+p6b-1)) THEN
      IF (ieor(int_mb(k_sym+h3b-1),ieor(int_mb(k_sym+h8b-1),ieor(int_mb(
     &k_sym+h11b-1),int_mb(k_sym+p6b-1)))) .eq. ieor(irrep_v,irrep_t)) T
     &HEN
      dimc = int_mb(k_range+h3b-1) * int_mb(k_range+h8b-1) * int_mb(k_ra
     &nge+h11b-1) * int_mb(k_range+p6b-1)
      IF (.not.MA_PUSH_GET(mt_dbl,dimc,'noname',l_c_sort,k_c_sort)) CALL
     & ERRQUIT('eomccsdt_y2_10_5_2',0,MA_ERR)
      CALL DFILL(dimc,0.0d0,dbl_mb(k_c_sort),1)
      DO p9b = noab+1,noab+nvab
      IF (int_mb(k_spin+p9b-1) .eq. int_mb(k_spin+h11b-1)) THEN
      IF (ieor(int_mb(k_sym+p9b-1),int_mb(k_sym+h11b-1)) .eq. irrep_t) T
     &HEN
      CALL TCE_RESTRICTED_2(p9b,h11b,p9b_1,h11b_1)
      CALL TCE_RESTRICTED_4(h3b,h8b,p6b,p9b,h3b_2,h8b_2,p6b_2,p9b_2)
      dim_common = int_mb(k_range+p9b-1)
      dima_sort = int_mb(k_range+h11b-1)
      dima = dim_common * dima_sort
      dimb_sort = int_mb(k_range+h3b-1) * int_mb(k_range+h8b-1) * int_mb
     &(k_range+p6b-1)
      dimb = dim_common * dimb_sort
      IF ((dima .gt. 0) .and. (dimb .gt. 0)) THEN
      IF (.not.MA_PUSH_GET(mt_dbl,dima,'noname',l_a_sort,k_a_sort)) CALL
     & ERRQUIT('eomccsdt_y2_10_5_2',1,MA_ERR)
      IF (.not.MA_PUSH_GET(mt_dbl,dima,'noname',l_a,k_a)) CALL ERRQUIT('
     &eomccsdt_y2_10_5_2',2,MA_ERR)
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(h11b_
     &1 - 1 + noab * (p9b_1 - noab - 1)))
      CALL TCE_SORT_2(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+p9b-1)
     &,int_mb(k_range+h11b-1),2,1,1.0d0)
      IF (.not.MA_POP_STACK(l_a)) CALL ERRQUIT('eomccsdt_y2_10_5_2',3,MA
     &_ERR)
      IF (.not.MA_PUSH_GET(mt_dbl,dimb,'noname',l_b_sort,k_b_sort)) CALL
     & ERRQUIT('eomccsdt_y2_10_5_2',4,MA_ERR)
      IF (.not.MA_PUSH_GET(mt_dbl,dimb,'noname',l_b,k_b)) CALL ERRQUIT('
     &eomccsdt_y2_10_5_2',5,MA_ERR)
      IF ((h8b .lt. h3b) .and. (p9b .lt. p6b)) THEN
      CALL GET_HASH_BLOCK(d_b,dbl_mb(k_b),dimb,int_mb(k_b_offset),(p6b_2
     & - 1 + (noab+nvab) * (p9b_2 - 1 + (noab+nvab) * (h3b_2 - 1 + (noab
     &+nvab) * (h8b_2 - 1)))))
      CALL TCE_SORT_4(dbl_mb(k_b),dbl_mb(k_b_sort),int_mb(k_range+h8b-1)
     &,int_mb(k_range+h3b-1),int_mb(k_range+p9b-1),int_mb(k_range+p6b-1)
     &,4,1,2,3,1.0d0)
      END IF
      IF ((h8b .lt. h3b) .and. (p6b .le. p9b)) THEN
      CALL GET_HASH_BLOCK(d_b,dbl_mb(k_b),dimb,int_mb(k_b_offset),(p9b_2
     & - 1 + (noab+nvab) * (p6b_2 - 1 + (noab+nvab) * (h3b_2 - 1 + (noab
     &+nvab) * (h8b_2 - 1)))))
      CALL TCE_SORT_4(dbl_mb(k_b),dbl_mb(k_b_sort),int_mb(k_range+h8b-1)
     &,int_mb(k_range+h3b-1),int_mb(k_range+p6b-1),int_mb(k_range+p9b-1)
     &,3,1,2,4,-1.0d0)
      END IF
      IF ((h3b .le. h8b) .and. (p9b .lt. p6b)) THEN
      CALL GET_HASH_BLOCK(d_b,dbl_mb(k_b),dimb,int_mb(k_b_offset),(p6b_2
     & - 1 + (noab+nvab) * (p9b_2 - 1 + (noab+nvab) * (h8b_2 - 1 + (noab
     &+nvab) * (h3b_2 - 1)))))
      CALL TCE_SORT_4(dbl_mb(k_b),dbl_mb(k_b_sort),int_mb(k_range+h3b-1)
     &,int_mb(k_range+h8b-1),int_mb(k_range+p9b-1),int_mb(k_range+p6b-1)
     &,4,2,1,3,-1.0d0)
      END IF
      IF ((h3b .le. h8b) .and. (p6b .le. p9b)) THEN
      CALL GET_HASH_BLOCK(d_b,dbl_mb(k_b),dimb,int_mb(k_b_offset),(p9b_2
     & - 1 + (noab+nvab) * (p6b_2 - 1 + (noab+nvab) * (h8b_2 - 1 + (noab
     &+nvab) * (h3b_2 - 1)))))
      CALL TCE_SORT_4(dbl_mb(k_b),dbl_mb(k_b_sort),int_mb(k_range+h3b-1)
     &,int_mb(k_range+h8b-1),int_mb(k_range+p6b-1),int_mb(k_range+p9b-1)
     &,3,2,1,4,1.0d0)
      END IF
      IF (.not.MA_POP_STACK(l_b)) CALL ERRQUIT('eomccsdt_y2_10_5_2',6,MA
     &_ERR)
      CALL dgemm('T','N',dima_sort,dimb_sort,dim_common,1.0d0,dbl_mb(k_a
     &_sort),dim_common,dbl_mb(k_b_sort),dim_common,1.0d0,dbl_mb(k_c_sor
     &t),dima_sort)
      IF (.not.MA_POP_STACK(l_b_sort)) CALL ERRQUIT('eomccsdt_y2_10_5_2'
     &,7,MA_ERR)
      IF (.not.MA_POP_STACK(l_a_sort)) CALL ERRQUIT('eomccsdt_y2_10_5_2'
     &,8,MA_ERR)
      END IF
      END IF
      END IF
      END DO
      IF (.not.MA_PUSH_GET(mt_dbl,dimc,'noname',l_c,k_c)) CALL ERRQUIT('
     &eomccsdt_y2_10_5_2',9,MA_ERR)
      CALL TCE_SORT_4(dbl_mb(k_c_sort),dbl_mb(k_c),int_mb(k_range+p6b-1)
     &,int_mb(k_range+h8b-1),int_mb(k_range+h3b-1),int_mb(k_range+h11b-1
     &),3,2,4,1,-1.0d0)
      CALL ADD_HASH_BLOCK(d_c,dbl_mb(k_c),dimc,int_mb(k_c_offset),(p6b -
     & noab - 1 + nvab * (h11b - 1 + noab * (h8b - 1 + noab * (h3b - 1))
     &)))
      IF (.not.MA_POP_STACK(l_c)) CALL ERRQUIT('eomccsdt_y2_10_5_2',10,M
     &A_ERR)
      IF (.not.MA_POP_STACK(l_c_sort)) CALL ERRQUIT('eomccsdt_y2_10_5_2'
     &,11,MA_ERR)
      END IF
      END IF
      END IF
      next = NXTASK(nprocs,1)
      END IF
      count = count + 1
      END DO
      END DO
      END DO
      END DO
      next = NXTASK(-nprocs,1)
      call GA_SYNC()
      RETURN
      END
      SUBROUTINE eomccsdt_y2_10_5(d_a,k_a_offset,d_b,k_b_offset,d_c,k_c_
     &offset)
C     $Id: eomccsdt_y2_all12.F 24184 2013-05-04 00:43:17Z edo $
C     This is a Fortran77 program generated by Tensor Contraction Engine v.1.0
C     Copyright (c) Battelle & Pacific Northwest National Laboratory (2002)
C     i1 ( h3 p13 h11 h14 )_vt + = -2 * Sum ( h8 p6 ) * t ( p6 p13 h8 h14 )_t * i2 ( h3 h8 h11 p6 )_v
      IMPLICIT NONE
#include "global.fh"
#include "mafdecls.fh"
#include "sym.fh"
#include "errquit.fh"
#include "tce.fh"
      INTEGER d_a
      INTEGER k_a_offset
      INTEGER d_b
      INTEGER k_b_offset
      INTEGER d_c
      INTEGER k_c_offset
      INTEGER NXTASK
      INTEGER next
      INTEGER nprocs
      INTEGER count
      INTEGER h3b
      INTEGER p13b
      INTEGER h14b
      INTEGER h11b
      INTEGER dimc
      INTEGER l_c_sort
      INTEGER k_c_sort
      INTEGER p6b
      INTEGER h8b
      INTEGER p13b_1
      INTEGER p6b_1
      INTEGER h14b_1
      INTEGER h8b_1
      INTEGER h3b_2
      INTEGER h8b_2
      INTEGER h11b_2
      INTEGER p6b_2
      INTEGER dim_common
      INTEGER dima_sort
      INTEGER dima
      INTEGER dimb_sort
      INTEGER dimb
      INTEGER l_a_sort
      INTEGER k_a_sort
      INTEGER l_a
      INTEGER k_a
      INTEGER l_b_sort
      INTEGER k_b_sort
      INTEGER l_b
      INTEGER k_b
      INTEGER l_c
      INTEGER k_c
      EXTERNAL NXTASK
      nprocs = GA_NNODES()
      count = 0
      next = NXTASK(nprocs,1)
      DO h3b = 1,noab
      DO p13b = noab+1,noab+nvab
      DO h14b = 1,noab
      DO h11b = 1,noab
      IF (next.eq.count) THEN
      IF ((.not.restricted).or.(int_mb(k_spin+h3b-1)+int_mb(k_spin+p13b-
     &1)+int_mb(k_spin+h11b-1)+int_mb(k_spin+h14b-1).ne.8)) THEN
      IF (int_mb(k_spin+h3b-1)+int_mb(k_spin+p13b-1) .eq. int_mb(k_spin+
     &h11b-1)+int_mb(k_spin+h14b-1)) THEN
      IF (ieor(int_mb(k_sym+h3b-1),ieor(int_mb(k_sym+p13b-1),ieor(int_mb
     &(k_sym+h11b-1),int_mb(k_sym+h14b-1)))) .eq. ieor(irrep_v,irrep_t))
     & THEN
      dimc = int_mb(k_range+h3b-1) * int_mb(k_range+p13b-1) * int_mb(k_r
     &ange+h11b-1) * int_mb(k_range+h14b-1)
      IF (.not.MA_PUSH_GET(mt_dbl,dimc,'noname',l_c_sort,k_c_sort)) CALL
     & ERRQUIT('eomccsdt_y2_10_5',0,MA_ERR)
      CALL DFILL(dimc,0.0d0,dbl_mb(k_c_sort),1)
      DO p6b = noab+1,noab+nvab
      DO h8b = 1,noab
      IF (int_mb(k_spin+p13b-1)+int_mb(k_spin+p6b-1) .eq. int_mb(k_spin+
     &h14b-1)+int_mb(k_spin+h8b-1)) THEN
      IF (ieor(int_mb(k_sym+p13b-1),ieor(int_mb(k_sym+p6b-1),ieor(int_mb
     &(k_sym+h14b-1),int_mb(k_sym+h8b-1)))) .eq. irrep_t) THEN
      CALL TCE_RESTRICTED_4(p13b,p6b,h14b,h8b,p13b_1,p6b_1,h14b_1,h8b_1)
      CALL TCE_RESTRICTED_4(h3b,h8b,h11b,p6b,h3b_2,h8b_2,h11b_2,p6b_2)
      dim_common = int_mb(k_range+p6b-1) * int_mb(k_range+h8b-1)
      dima_sort = int_mb(k_range+p13b-1) * int_mb(k_range+h14b-1)
      dima = dim_common * dima_sort
      dimb_sort = int_mb(k_range+h3b-1) * int_mb(k_range+h11b-1)
      dimb = dim_common * dimb_sort
      IF ((dima .gt. 0) .and. (dimb .gt. 0)) THEN
      IF (.not.MA_PUSH_GET(mt_dbl,dima,'noname',l_a_sort,k_a_sort)) CALL
     & ERRQUIT('eomccsdt_y2_10_5',1,MA_ERR)
      IF (.not.MA_PUSH_GET(mt_dbl,dima,'noname',l_a,k_a)) CALL ERRQUIT('
     &eomccsdt_y2_10_5',2,MA_ERR)
      IF ((p6b .le. p13b) .and. (h8b .le. h14b)) THEN
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(h14b_
     &1 - 1 + noab * (h8b_1 - 1 + noab * (p13b_1 - noab - 1 + nvab * (p6
     &b_1 - noab - 1)))))
      CALL TCE_SORT_4(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+p6b-1)
     &,int_mb(k_range+p13b-1),int_mb(k_range+h8b-1),int_mb(k_range+h14b-
     &1),4,2,3,1,1.0d0)
      END IF
      IF ((p6b .le. p13b) .and. (h14b .lt. h8b)) THEN
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(h8b_1
     & - 1 + noab * (h14b_1 - 1 + noab * (p13b_1 - noab - 1 + nvab * (p6
     &b_1 - noab - 1)))))
      CALL TCE_SORT_4(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+p6b-1)
     &,int_mb(k_range+p13b-1),int_mb(k_range+h14b-1),int_mb(k_range+h8b-
     &1),3,2,4,1,-1.0d0)
      END IF
      IF ((p13b .lt. p6b) .and. (h8b .le. h14b)) THEN
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(h14b_
     &1 - 1 + noab * (h8b_1 - 1 + noab * (p6b_1 - noab - 1 + nvab * (p13
     &b_1 - noab - 1)))))
      CALL TCE_SORT_4(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+p13b-1
     &),int_mb(k_range+p6b-1),int_mb(k_range+h8b-1),int_mb(k_range+h14b-
     &1),4,1,3,2,-1.0d0)
      END IF
      IF ((p13b .lt. p6b) .and. (h14b .lt. h8b)) THEN
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(h8b_1
     & - 1 + noab * (h14b_1 - 1 + noab * (p6b_1 - noab - 1 + nvab * (p13
     &b_1 - noab - 1)))))
      CALL TCE_SORT_4(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+p13b-1
     &),int_mb(k_range+p6b-1),int_mb(k_range+h14b-1),int_mb(k_range+h8b-
     &1),3,1,4,2,1.0d0)
      END IF
      IF (.not.MA_POP_STACK(l_a)) CALL ERRQUIT('eomccsdt_y2_10_5',3,MA_E
     &RR)
      IF (.not.MA_PUSH_GET(mt_dbl,dimb,'noname',l_b_sort,k_b_sort)) CALL
     & ERRQUIT('eomccsdt_y2_10_5',4,MA_ERR)
      IF (.not.MA_PUSH_GET(mt_dbl,dimb,'noname',l_b,k_b)) CALL ERRQUIT('
     &eomccsdt_y2_10_5',5,MA_ERR)
      IF ((h11b .le. p6b)) THEN
      CALL GET_HASH_BLOCK(d_b,dbl_mb(k_b),dimb,int_mb(k_b_offset),(p6b_2
     & - noab - 1 + nvab * (h11b_2 - 1 + noab * (h8b_2 - 1 + noab * (h3b
     &_2 - 1)))))
      CALL TCE_SORT_4(dbl_mb(k_b),dbl_mb(k_b_sort),int_mb(k_range+h3b-1)
     &,int_mb(k_range+h8b-1),int_mb(k_range+h11b-1),int_mb(k_range+p6b-1
     &),3,1,2,4,1.0d0)
      END IF
      IF (.not.MA_POP_STACK(l_b)) CALL ERRQUIT('eomccsdt_y2_10_5',6,MA_E
     &RR)
      CALL dgemm('T','N',dima_sort,dimb_sort,dim_common,1.0d0,dbl_mb(k_a
     &_sort),dim_common,dbl_mb(k_b_sort),dim_common,1.0d0,dbl_mb(k_c_sor
     &t),dima_sort)
      IF (.not.MA_POP_STACK(l_b_sort)) CALL ERRQUIT('eomccsdt_y2_10_5',7
     &,MA_ERR)
      IF (.not.MA_POP_STACK(l_a_sort)) CALL ERRQUIT('eomccsdt_y2_10_5',8
     &,MA_ERR)
      END IF
      END IF
      END IF
      END DO
      END DO
      IF (.not.MA_PUSH_GET(mt_dbl,dimc,'noname',l_c,k_c)) CALL ERRQUIT('
     &eomccsdt_y2_10_5',9,MA_ERR)
      IF ((h11b .le. h14b)) THEN
      CALL TCE_SORT_4(dbl_mb(k_c_sort),dbl_mb(k_c),int_mb(k_range+h11b-1
     &),int_mb(k_range+h3b-1),int_mb(k_range+h14b-1),int_mb(k_range+p13b
     &-1),2,4,1,3,-1.0d0)
      CALL ADD_HASH_BLOCK(d_c,dbl_mb(k_c),dimc,int_mb(k_c_offset),(h14b 
     &- 1 + noab * (h11b - 1 + noab * (p13b - noab - 1 + nvab * (h3b - 1
     &)))))
      END IF
      IF ((h14b .le. h11b)) THEN
      CALL TCE_SORT_4(dbl_mb(k_c_sort),dbl_mb(k_c),int_mb(k_range+h11b-1
     &),int_mb(k_range+h3b-1),int_mb(k_range+h14b-1),int_mb(k_range+p13b
     &-1),2,4,3,1,1.0d0)
      CALL ADD_HASH_BLOCK(d_c,dbl_mb(k_c),dimc,int_mb(k_c_offset),(h11b 
     &- 1 + noab * (h14b - 1 + noab * (p13b - noab - 1 + nvab * (h3b - 1
     &)))))
      END IF
      IF (.not.MA_POP_STACK(l_c)) CALL ERRQUIT('eomccsdt_y2_10_5',10,MA_
     &ERR)
      IF (.not.MA_POP_STACK(l_c_sort)) CALL ERRQUIT('eomccsdt_y2_10_5',1
     &1,MA_ERR)
      END IF
      END IF
      END IF
      next = NXTASK(nprocs,1)
      END IF
      count = count + 1
      END DO
      END DO
      END DO
      END DO
      next = NXTASK(-nprocs,1)
      call GA_SYNC()
      RETURN
      END
      SUBROUTINE eomccsdt_y2_10_6(d_a,k_a_offset,d_b,k_b_offset,d_c,k_c_
     &offset)
C     $Id: eomccsdt_y2_all12.F 24184 2013-05-04 00:43:17Z edo $
C     This is a Fortran77 program generated by Tensor Contraction Engine v.1.0
C     Copyright (c) Battelle & Pacific Northwest National Laboratory (2002)
C     i1 ( h3 p13 h11 h14 )_vt + = -1/2 * Sum ( p5 p6 ) * t ( p5 p6 h11 h14 )_t * v ( h3 p13 p5 p6 )_v
      IMPLICIT NONE
#include "global.fh"
#include "mafdecls.fh"
#include "sym.fh"
#include "errquit.fh"
#include "tce.fh"
      INTEGER d_a
      INTEGER k_a_offset
      INTEGER d_b
      INTEGER k_b_offset
      INTEGER d_c
      INTEGER k_c_offset
      INTEGER NXTASK
      INTEGER next
      INTEGER nprocs
      INTEGER count
      INTEGER h3b
      INTEGER p13b
      INTEGER h11b
      INTEGER h14b
      INTEGER dimc
      INTEGER l_c_sort
      INTEGER k_c_sort
      INTEGER p5b
      INTEGER p6b
      INTEGER p5b_1
      INTEGER p6b_1
      INTEGER h11b_1
      INTEGER h14b_1
      INTEGER h3b_2
      INTEGER p13b_2
      INTEGER p5b_2
      INTEGER p6b_2
      INTEGER dim_common
      INTEGER dima_sort
      INTEGER dima
      INTEGER dimb_sort
      INTEGER dimb
      INTEGER l_a_sort
      INTEGER k_a_sort
      INTEGER l_a
      INTEGER k_a
      INTEGER l_b_sort
      INTEGER k_b_sort
      INTEGER l_b
      INTEGER k_b
      INTEGER nsuperp(2)
      INTEGER isuperp
      INTEGER l_c
      INTEGER k_c
      DOUBLE PRECISION FACTORIAL
      EXTERNAL NXTASK
      EXTERNAL FACTORIAL
      nprocs = GA_NNODES()
      count = 0
      next = NXTASK(nprocs,1)
      DO h3b = 1,noab
      DO p13b = noab+1,noab+nvab
      DO h11b = 1,noab
      DO h14b = h11b,noab
      IF (next.eq.count) THEN
      IF ((.not.restricted).or.(int_mb(k_spin+h3b-1)+int_mb(k_spin+p13b-
     &1)+int_mb(k_spin+h11b-1)+int_mb(k_spin+h14b-1).ne.8)) THEN
      IF (int_mb(k_spin+h3b-1)+int_mb(k_spin+p13b-1) .eq. int_mb(k_spin+
     &h11b-1)+int_mb(k_spin+h14b-1)) THEN
      IF (ieor(int_mb(k_sym+h3b-1),ieor(int_mb(k_sym+p13b-1),ieor(int_mb
     &(k_sym+h11b-1),int_mb(k_sym+h14b-1)))) .eq. ieor(irrep_v,irrep_t))
     & THEN
      dimc = int_mb(k_range+h3b-1) * int_mb(k_range+p13b-1) * int_mb(k_r
     &ange+h11b-1) * int_mb(k_range+h14b-1)
      IF (.not.MA_PUSH_GET(mt_dbl,dimc,'noname',l_c_sort,k_c_sort)) CALL
     & ERRQUIT('eomccsdt_y2_10_6',0,MA_ERR)
      CALL DFILL(dimc,0.0d0,dbl_mb(k_c_sort),1)
      DO p5b = noab+1,noab+nvab
      DO p6b = p5b,noab+nvab
      IF (int_mb(k_spin+p5b-1)+int_mb(k_spin+p6b-1) .eq. int_mb(k_spin+h
     &11b-1)+int_mb(k_spin+h14b-1)) THEN
      IF (ieor(int_mb(k_sym+p5b-1),ieor(int_mb(k_sym+p6b-1),ieor(int_mb(
     &k_sym+h11b-1),int_mb(k_sym+h14b-1)))) .eq. irrep_t) THEN
      CALL TCE_RESTRICTED_4(p5b,p6b,h11b,h14b,p5b_1,p6b_1,h11b_1,h14b_1)
      CALL TCE_RESTRICTED_4(h3b,p13b,p5b,p6b,h3b_2,p13b_2,p5b_2,p6b_2)
      dim_common = int_mb(k_range+p5b-1) * int_mb(k_range+p6b-1)
      dima_sort = int_mb(k_range+h11b-1) * int_mb(k_range+h14b-1)
      dima = dim_common * dima_sort
      dimb_sort = int_mb(k_range+h3b-1) * int_mb(k_range+p13b-1)
      dimb = dim_common * dimb_sort
      IF ((dima .gt. 0) .and. (dimb .gt. 0)) THEN
      IF (.not.MA_PUSH_GET(mt_dbl,dima,'noname',l_a_sort,k_a_sort)) CALL
     & ERRQUIT('eomccsdt_y2_10_6',1,MA_ERR)
      IF (.not.MA_PUSH_GET(mt_dbl,dima,'noname',l_a,k_a)) CALL ERRQUIT('
     &eomccsdt_y2_10_6',2,MA_ERR)
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(h14b_
     &1 - 1 + noab * (h11b_1 - 1 + noab * (p6b_1 - noab - 1 + nvab * (p5
     &b_1 - noab - 1)))))
      CALL TCE_SORT_4(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+p5b-1)
     &,int_mb(k_range+p6b-1),int_mb(k_range+h11b-1),int_mb(k_range+h14b-
     &1),4,3,2,1,1.0d0)
      IF (.not.MA_POP_STACK(l_a)) CALL ERRQUIT('eomccsdt_y2_10_6',3,MA_E
     &RR)
      IF (.not.MA_PUSH_GET(mt_dbl,dimb,'noname',l_b_sort,k_b_sort)) CALL
     & ERRQUIT('eomccsdt_y2_10_6',4,MA_ERR)
      IF (.not.MA_PUSH_GET(mt_dbl,dimb,'noname',l_b,k_b)) CALL ERRQUIT('
     &eomccsdt_y2_10_6',5,MA_ERR)
      IF ((h3b .le. p13b)) THEN
      CALL GET_HASH_BLOCK(d_b,dbl_mb(k_b),dimb,int_mb(k_b_offset),(p6b_2
     & - 1 + (noab+nvab) * (p5b_2 - 1 + (noab+nvab) * (p13b_2 - 1 + (noa
     &b+nvab) * (h3b_2 - 1)))))
      CALL TCE_SORT_4(dbl_mb(k_b),dbl_mb(k_b_sort),int_mb(k_range+h3b-1)
     &,int_mb(k_range+p13b-1),int_mb(k_range+p5b-1),int_mb(k_range+p6b-1
     &),2,1,4,3,1.0d0)
      END IF
      IF (.not.MA_POP_STACK(l_b)) CALL ERRQUIT('eomccsdt_y2_10_6',6,MA_E
     &RR)
      nsuperp(1) = 1
      nsuperp(2) = 1
      isuperp = 1
      IF (p5b .eq. p6b) THEN
      nsuperp(isuperp) = nsuperp(isuperp) + 1
      ELSE
      isuperp = isuperp + 1
      END IF
      CALL dgemm('T','N',dima_sort,dimb_sort,dim_common,2.0d0/FACTORIAL(
     &nsuperp(1))/FACTORIAL(nsuperp(2)),dbl_mb(k_a_sort),dim_common,dbl_
     &mb(k_b_sort),dim_common,1.0d0,dbl_mb(k_c_sort),dima_sort)
      IF (.not.MA_POP_STACK(l_b_sort)) CALL ERRQUIT('eomccsdt_y2_10_6',7
     &,MA_ERR)
      IF (.not.MA_POP_STACK(l_a_sort)) CALL ERRQUIT('eomccsdt_y2_10_6',8
     &,MA_ERR)
      END IF
      END IF
      END IF
      END DO
      END DO
      IF (.not.MA_PUSH_GET(mt_dbl,dimc,'noname',l_c,k_c)) CALL ERRQUIT('
     &eomccsdt_y2_10_6',9,MA_ERR)
      CALL TCE_SORT_4(dbl_mb(k_c_sort),dbl_mb(k_c),int_mb(k_range+p13b-1
     &),int_mb(k_range+h3b-1),int_mb(k_range+h14b-1),int_mb(k_range+h11b
     &-1),2,1,4,3,-1.0d0/2.0d0)
      CALL ADD_HASH_BLOCK(d_c,dbl_mb(k_c),dimc,int_mb(k_c_offset),(h14b 
     &- 1 + noab * (h11b - 1 + noab * (p13b - noab - 1 + nvab * (h3b - 1
     &)))))
      IF (.not.MA_POP_STACK(l_c)) CALL ERRQUIT('eomccsdt_y2_10_6',10,MA_
     &ERR)
      IF (.not.MA_POP_STACK(l_c_sort)) CALL ERRQUIT('eomccsdt_y2_10_6',1
     &1,MA_ERR)
      END IF
      END IF
      END IF
      next = NXTASK(nprocs,1)
      END IF
      count = count + 1
      END DO
      END DO
      END DO
      END DO
      next = NXTASK(-nprocs,1)
      call GA_SYNC()
      RETURN
      END
      SUBROUTINE eomccsdt_y2_10_7(d_a,k_a_offset,d_b,k_b_offset,d_c,k_c_
     &offset)
C     $Id: eomccsdt_y2_all12.F 24184 2013-05-04 00:43:17Z edo $
C     This is a Fortran77 program generated by Tensor Contraction Engine v.1.0
C     Copyright (c) Battelle & Pacific Northwest National Laboratory (2002)
C     i1 ( h3 p13 h11 h14 )_vt + = 1/2 * Sum ( h10 p6 p7 ) * t ( p6 p7 p13 h10 h11 h14 )_t * v ( h3 h10 p6 p7 )_v
      IMPLICIT NONE
#include "global.fh"
#include "mafdecls.fh"
#include "sym.fh"
#include "errquit.fh"
#include "tce.fh"
      INTEGER d_a
      INTEGER k_a_offset
      INTEGER d_b
      INTEGER k_b_offset
      INTEGER d_c
      INTEGER k_c_offset
      INTEGER NXTASK
      INTEGER next
      INTEGER nprocs
      INTEGER count
      INTEGER h3b
      INTEGER p13b
      INTEGER h11b
      INTEGER h14b
      INTEGER dimc
      INTEGER l_c_sort
      INTEGER k_c_sort
      INTEGER p6b
      INTEGER p7b
      INTEGER h10b
      INTEGER p13b_1
      INTEGER p6b_1
      INTEGER p7b_1
      INTEGER h11b_1
      INTEGER h14b_1
      INTEGER h10b_1
      INTEGER h3b_2
      INTEGER h10b_2
      INTEGER p6b_2
      INTEGER p7b_2
      INTEGER dim_common
      INTEGER dima_sort
      INTEGER dima
      INTEGER dimb_sort
      INTEGER dimb
      INTEGER l_a_sort
      INTEGER k_a_sort
      INTEGER l_a
      INTEGER k_a
      INTEGER l_b_sort
      INTEGER k_b_sort
      INTEGER l_b
      INTEGER k_b
      INTEGER nsuperp(2)
      INTEGER isuperp
      INTEGER l_c
      INTEGER k_c
      DOUBLE PRECISION FACTORIAL
      EXTERNAL NXTASK
      EXTERNAL FACTORIAL
      nprocs = GA_NNODES()
      count = 0
      next = NXTASK(nprocs,1)
      DO h3b = 1,noab
      DO p13b = noab+1,noab+nvab
      DO h11b = 1,noab
      DO h14b = h11b,noab
      IF (next.eq.count) THEN
      IF ((.not.restricted).or.(int_mb(k_spin+h3b-1)+int_mb(k_spin+p13b-
     &1)+int_mb(k_spin+h11b-1)+int_mb(k_spin+h14b-1).ne.8)) THEN
      IF (int_mb(k_spin+h3b-1)+int_mb(k_spin+p13b-1) .eq. int_mb(k_spin+
     &h11b-1)+int_mb(k_spin+h14b-1)) THEN
      IF (ieor(int_mb(k_sym+h3b-1),ieor(int_mb(k_sym+p13b-1),ieor(int_mb
     &(k_sym+h11b-1),int_mb(k_sym+h14b-1)))) .eq. ieor(irrep_v,irrep_t))
     & THEN
      dimc = int_mb(k_range+h3b-1) * int_mb(k_range+p13b-1) * int_mb(k_r
     &ange+h11b-1) * int_mb(k_range+h14b-1)
      IF (.not.MA_PUSH_GET(mt_dbl,dimc,'noname',l_c_sort,k_c_sort)) CALL
     & ERRQUIT('eomccsdt_y2_10_7',0,MA_ERR)
      CALL DFILL(dimc,0.0d0,dbl_mb(k_c_sort),1)
      DO p6b = noab+1,noab+nvab
      DO p7b = p6b,noab+nvab
      DO h10b = 1,noab
      IF (int_mb(k_spin+p13b-1)+int_mb(k_spin+p6b-1)+int_mb(k_spin+p7b-1
     &) .eq. int_mb(k_spin+h11b-1)+int_mb(k_spin+h14b-1)+int_mb(k_spin+h
     &10b-1)) THEN
      IF (ieor(int_mb(k_sym+p13b-1),ieor(int_mb(k_sym+p6b-1),ieor(int_mb
     &(k_sym+p7b-1),ieor(int_mb(k_sym+h11b-1),ieor(int_mb(k_sym+h14b-1),
     &int_mb(k_sym+h10b-1)))))) .eq. irrep_t) THEN
      CALL TCE_RESTRICTED_6(p13b,p6b,p7b,h11b,h14b,h10b,p13b_1,p6b_1,p7b
     &_1,h11b_1,h14b_1,h10b_1)
      CALL TCE_RESTRICTED_4(h3b,h10b,p6b,p7b,h3b_2,h10b_2,p6b_2,p7b_2)
      dim_common = int_mb(k_range+p6b-1) * int_mb(k_range+p7b-1) * int_m
     &b(k_range+h10b-1)
      dima_sort = int_mb(k_range+p13b-1) * int_mb(k_range+h11b-1) * int_
     &mb(k_range+h14b-1)
      dima = dim_common * dima_sort
      dimb_sort = int_mb(k_range+h3b-1)
      dimb = dim_common * dimb_sort
      IF ((dima .gt. 0) .and. (dimb .gt. 0)) THEN
      IF (.not.MA_PUSH_GET(mt_dbl,dima,'noname',l_a_sort,k_a_sort)) CALL
     & ERRQUIT('eomccsdt_y2_10_7',1,MA_ERR)
      IF (.not.MA_PUSH_GET(mt_dbl,dima,'noname',l_a,k_a)) CALL ERRQUIT('
     &eomccsdt_y2_10_7',2,MA_ERR)
      IF ((p7b .le. p13b) .and. (h10b .le. h11b)) THEN
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(h14b_
     &1 - 1 + noab * (h11b_1 - 1 + noab * (h10b_1 - 1 + noab * (p13b_1 -
     & noab - 1 + nvab * (p7b_1 - noab - 1 + nvab * (p6b_1 - noab - 1)))
     &))))
      CALL TCE_SORT_6(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+p6b-1)
     &,int_mb(k_range+p7b-1),int_mb(k_range+p13b-1),int_mb(k_range+h10b-
     &1),int_mb(k_range+h11b-1),int_mb(k_range+h14b-1),6,5,3,4,2,1,1.0d0
     &)
      END IF
      IF ((p7b .le. p13b) .and. (h11b .lt. h10b) .and. (h10b .le. h14b))
     & THEN
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(h14b_
     &1 - 1 + noab * (h10b_1 - 1 + noab * (h11b_1 - 1 + noab * (p13b_1 -
     & noab - 1 + nvab * (p7b_1 - noab - 1 + nvab * (p6b_1 - noab - 1)))
     &))))
      CALL TCE_SORT_6(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+p6b-1)
     &,int_mb(k_range+p7b-1),int_mb(k_range+p13b-1),int_mb(k_range+h11b-
     &1),int_mb(k_range+h10b-1),int_mb(k_range+h14b-1),6,4,3,5,2,1,-1.0d
     &0)
      END IF
      IF ((p7b .le. p13b) .and. (h14b .lt. h10b)) THEN
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(h10b_
     &1 - 1 + noab * (h14b_1 - 1 + noab * (h11b_1 - 1 + noab * (p13b_1 -
     & noab - 1 + nvab * (p7b_1 - noab - 1 + nvab * (p6b_1 - noab - 1)))
     &))))
      CALL TCE_SORT_6(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+p6b-1)
     &,int_mb(k_range+p7b-1),int_mb(k_range+p13b-1),int_mb(k_range+h11b-
     &1),int_mb(k_range+h14b-1),int_mb(k_range+h10b-1),5,4,3,6,2,1,1.0d0
     &)
      END IF
      IF ((p6b .le. p13b) .and. (p13b .lt. p7b) .and. (h10b .le. h11b)) 
     &THEN
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(h14b_
     &1 - 1 + noab * (h11b_1 - 1 + noab * (h10b_1 - 1 + noab * (p7b_1 - 
     &noab - 1 + nvab * (p13b_1 - noab - 1 + nvab * (p6b_1 - noab - 1)))
     &))))
      CALL TCE_SORT_6(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+p6b-1)
     &,int_mb(k_range+p13b-1),int_mb(k_range+p7b-1),int_mb(k_range+h10b-
     &1),int_mb(k_range+h11b-1),int_mb(k_range+h14b-1),6,5,2,4,3,1,-1.0d
     &0)
      END IF
      IF ((p6b .le. p13b) .and. (p13b .lt. p7b) .and. (h11b .lt. h10b) .
     &and. (h10b .le. h14b)) THEN
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(h14b_
     &1 - 1 + noab * (h10b_1 - 1 + noab * (h11b_1 - 1 + noab * (p7b_1 - 
     &noab - 1 + nvab * (p13b_1 - noab - 1 + nvab * (p6b_1 - noab - 1)))
     &))))
      CALL TCE_SORT_6(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+p6b-1)
     &,int_mb(k_range+p13b-1),int_mb(k_range+p7b-1),int_mb(k_range+h11b-
     &1),int_mb(k_range+h10b-1),int_mb(k_range+h14b-1),6,4,2,5,3,1,1.0d0
     &)
      END IF
      IF ((p6b .le. p13b) .and. (p13b .lt. p7b) .and. (h14b .lt. h10b)) 
     &THEN
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(h10b_
     &1 - 1 + noab * (h14b_1 - 1 + noab * (h11b_1 - 1 + noab * (p7b_1 - 
     &noab - 1 + nvab * (p13b_1 - noab - 1 + nvab * (p6b_1 - noab - 1)))
     &))))
      CALL TCE_SORT_6(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+p6b-1)
     &,int_mb(k_range+p13b-1),int_mb(k_range+p7b-1),int_mb(k_range+h11b-
     &1),int_mb(k_range+h14b-1),int_mb(k_range+h10b-1),5,4,2,6,3,1,-1.0d
     &0)
      END IF
      IF ((p13b .lt. p6b) .and. (h10b .le. h11b)) THEN
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(h14b_
     &1 - 1 + noab * (h11b_1 - 1 + noab * (h10b_1 - 1 + noab * (p7b_1 - 
     &noab - 1 + nvab * (p6b_1 - noab - 1 + nvab * (p13b_1 - noab - 1)))
     &))))
      CALL TCE_SORT_6(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+p13b-1
     &),int_mb(k_range+p6b-1),int_mb(k_range+p7b-1),int_mb(k_range+h10b-
     &1),int_mb(k_range+h11b-1),int_mb(k_range+h14b-1),6,5,1,4,3,2,1.0d0
     &)
      END IF
      IF ((p13b .lt. p6b) .and. (h11b .lt. h10b) .and. (h10b .le. h14b))
     & THEN
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(h14b_
     &1 - 1 + noab * (h10b_1 - 1 + noab * (h11b_1 - 1 + noab * (p7b_1 - 
     &noab - 1 + nvab * (p6b_1 - noab - 1 + nvab * (p13b_1 - noab - 1)))
     &))))
      CALL TCE_SORT_6(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+p13b-1
     &),int_mb(k_range+p6b-1),int_mb(k_range+p7b-1),int_mb(k_range+h11b-
     &1),int_mb(k_range+h10b-1),int_mb(k_range+h14b-1),6,4,1,5,3,2,-1.0d
     &0)
      END IF
      IF ((p13b .lt. p6b) .and. (h14b .lt. h10b)) THEN
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(h10b_
     &1 - 1 + noab * (h14b_1 - 1 + noab * (h11b_1 - 1 + noab * (p7b_1 - 
     &noab - 1 + nvab * (p6b_1 - noab - 1 + nvab * (p13b_1 - noab - 1)))
     &))))
      CALL TCE_SORT_6(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+p13b-1
     &),int_mb(k_range+p6b-1),int_mb(k_range+p7b-1),int_mb(k_range+h11b-
     &1),int_mb(k_range+h14b-1),int_mb(k_range+h10b-1),5,4,1,6,3,2,1.0d0
     &)
      END IF
      IF (.not.MA_POP_STACK(l_a)) CALL ERRQUIT('eomccsdt_y2_10_7',3,MA_E
     &RR)
      IF (.not.MA_PUSH_GET(mt_dbl,dimb,'noname',l_b_sort,k_b_sort)) CALL
     & ERRQUIT('eomccsdt_y2_10_7',4,MA_ERR)
      IF (.not.MA_PUSH_GET(mt_dbl,dimb,'noname',l_b,k_b)) CALL ERRQUIT('
     &eomccsdt_y2_10_7',5,MA_ERR)
      IF ((h10b .lt. h3b)) THEN
      CALL GET_HASH_BLOCK(d_b,dbl_mb(k_b),dimb,int_mb(k_b_offset),(p7b_2
     & - 1 + (noab+nvab) * (p6b_2 - 1 + (noab+nvab) * (h3b_2 - 1 + (noab
     &+nvab) * (h10b_2 - 1)))))
      CALL TCE_SORT_4(dbl_mb(k_b),dbl_mb(k_b_sort),int_mb(k_range+h10b-1
     &),int_mb(k_range+h3b-1),int_mb(k_range+p6b-1),int_mb(k_range+p7b-1
     &),2,1,4,3,-1.0d0)
      END IF
      IF ((h3b .le. h10b)) THEN
      CALL GET_HASH_BLOCK(d_b,dbl_mb(k_b),dimb,int_mb(k_b_offset),(p7b_2
     & - 1 + (noab+nvab) * (p6b_2 - 1 + (noab+nvab) * (h10b_2 - 1 + (noa
     &b+nvab) * (h3b_2 - 1)))))
      CALL TCE_SORT_4(dbl_mb(k_b),dbl_mb(k_b_sort),int_mb(k_range+h3b-1)
     &,int_mb(k_range+h10b-1),int_mb(k_range+p6b-1),int_mb(k_range+p7b-1
     &),1,2,4,3,1.0d0)
      END IF
      IF (.not.MA_POP_STACK(l_b)) CALL ERRQUIT('eomccsdt_y2_10_7',6,MA_E
     &RR)
      nsuperp(1) = 1
      nsuperp(2) = 1
      isuperp = 1
      IF (p6b .eq. p7b) THEN
      nsuperp(isuperp) = nsuperp(isuperp) + 1
      ELSE
      isuperp = isuperp + 1
      END IF
      CALL dgemm('T','N',dima_sort,dimb_sort,dim_common,2.0d0/FACTORIAL(
     &nsuperp(1))/FACTORIAL(nsuperp(2)),dbl_mb(k_a_sort),dim_common,dbl_
     &mb(k_b_sort),dim_common,1.0d0,dbl_mb(k_c_sort),dima_sort)
      IF (.not.MA_POP_STACK(l_b_sort)) CALL ERRQUIT('eomccsdt_y2_10_7',7
     &,MA_ERR)
      IF (.not.MA_POP_STACK(l_a_sort)) CALL ERRQUIT('eomccsdt_y2_10_7',8
     &,MA_ERR)
      END IF
      END IF
      END IF
      END DO
      END DO
      END DO
      IF (.not.MA_PUSH_GET(mt_dbl,dimc,'noname',l_c,k_c)) CALL ERRQUIT('
     &eomccsdt_y2_10_7',9,MA_ERR)
      CALL TCE_SORT_4(dbl_mb(k_c_sort),dbl_mb(k_c),int_mb(k_range+h3b-1)
     &,int_mb(k_range+h14b-1),int_mb(k_range+h11b-1),int_mb(k_range+p13b
     &-1),1,4,3,2,1.0d0/2.0d0)
      CALL ADD_HASH_BLOCK(d_c,dbl_mb(k_c),dimc,int_mb(k_c_offset),(h14b 
     &- 1 + noab * (h11b - 1 + noab * (p13b - noab - 1 + nvab * (h3b - 1
     &)))))
      IF (.not.MA_POP_STACK(l_c)) CALL ERRQUIT('eomccsdt_y2_10_7',10,MA_
     &ERR)
      IF (.not.MA_POP_STACK(l_c_sort)) CALL ERRQUIT('eomccsdt_y2_10_7',1
     &1,MA_ERR)
      END IF
      END IF
      END IF
      next = NXTASK(nprocs,1)
      END IF
      count = count + 1
      END DO
      END DO
      END DO
      END DO
      next = NXTASK(-nprocs,1)
      call GA_SYNC()
      RETURN
      END
      SUBROUTINE eomccsdt_y2_10(d_a,k_a_offset,d_b,k_b_offset,d_c,k_c_of
     &fset)
C     $Id: eomccsdt_y2_all12.F 24184 2013-05-04 00:43:17Z edo $
C     This is a Fortran77 program generated by Tensor Contraction Engine v.1.0
C     Copyright (c) Battelle & Pacific Northwest National Laboratory (2002)
C     i0 ( h3 h4 p1 p2 )_yv + = 1/2 * P( 2 ) * Sum ( h11 h14 p13 ) * y ( h3 h11 h14 p1 p2 p13 )_y * i1 ( h4 p13 h11 h14 )_v
      IMPLICIT NONE
#include "global.fh"
#include "mafdecls.fh"
#include "sym.fh"
#include "errquit.fh"
#include "tce.fh"
      INTEGER d_a
      INTEGER k_a_offset
      INTEGER d_b
      INTEGER k_b_offset
      INTEGER d_c
      INTEGER k_c_offset
      INTEGER NXTASK
      INTEGER next
      INTEGER nprocs
      INTEGER count
      INTEGER h3b
      INTEGER h4b
      INTEGER p1b
      INTEGER p2b
      INTEGER dimc
      INTEGER l_c_sort
      INTEGER k_c_sort
      INTEGER h11b
      INTEGER h14b
      INTEGER p13b
      INTEGER h3b_1
      INTEGER h11b_1
      INTEGER h14b_1
      INTEGER p1b_1
      INTEGER p2b_1
      INTEGER p13b_1
      INTEGER h4b_2
      INTEGER p13b_2
      INTEGER h11b_2
      INTEGER h14b_2
      INTEGER dim_common
      INTEGER dima_sort
      INTEGER dima
      INTEGER dimb_sort
      INTEGER dimb
      INTEGER l_a_sort
      INTEGER k_a_sort
      INTEGER l_a
      INTEGER k_a
      INTEGER l_b_sort
      INTEGER k_b_sort
      INTEGER l_b
      INTEGER k_b
      INTEGER nsuperh(2)
      INTEGER isuperh
      INTEGER l_c
      INTEGER k_c
      DOUBLE PRECISION FACTORIAL
      EXTERNAL NXTASK
      EXTERNAL FACTORIAL
      nprocs = GA_NNODES()
      count = 0
      next = NXTASK(nprocs,1)
      DO h3b = 1,noab
      DO h4b = 1,noab
      DO p1b = noab+1,noab+nvab
      DO p2b = p1b,noab+nvab
      IF (next.eq.count) THEN
      IF ((.not.restricted).or.(int_mb(k_spin+h3b-1)+int_mb(k_spin+h4b-1
     &)+int_mb(k_spin+p1b-1)+int_mb(k_spin+p2b-1).ne.8)) THEN
      IF (int_mb(k_spin+h3b-1)+int_mb(k_spin+h4b-1) .eq. int_mb(k_spin+p
     &1b-1)+int_mb(k_spin+p2b-1)) THEN
      IF (ieor(int_mb(k_sym+h3b-1),ieor(int_mb(k_sym+h4b-1),ieor(int_mb(
     &k_sym+p1b-1),int_mb(k_sym+p2b-1)))) .eq. ieor(irrep_y,irrep_v)) TH
     &EN
      dimc = int_mb(k_range+h3b-1) * int_mb(k_range+h4b-1) * int_mb(k_ra
     &nge+p1b-1) * int_mb(k_range+p2b-1)
      IF (.not.MA_PUSH_GET(mt_dbl,dimc,'noname',l_c_sort,k_c_sort)) CALL
     & ERRQUIT('eomccsdt_y2_10',0,MA_ERR)
      CALL DFILL(dimc,0.0d0,dbl_mb(k_c_sort),1)
      DO h11b = 1,noab
      DO h14b = h11b,noab
      DO p13b = noab+1,noab+nvab
      IF (int_mb(k_spin+h3b-1)+int_mb(k_spin+h11b-1)+int_mb(k_spin+h14b-
     &1) .eq. int_mb(k_spin+p1b-1)+int_mb(k_spin+p2b-1)+int_mb(k_spin+p1
     &3b-1)) THEN
      IF (ieor(int_mb(k_sym+h3b-1),ieor(int_mb(k_sym+h11b-1),ieor(int_mb
     &(k_sym+h14b-1),ieor(int_mb(k_sym+p1b-1),ieor(int_mb(k_sym+p2b-1),i
     &nt_mb(k_sym+p13b-1)))))) .eq. irrep_y) THEN
      CALL TCE_RESTRICTED_6(h3b,h11b,h14b,p1b,p2b,p13b,h3b_1,h11b_1,h14b
     &_1,p1b_1,p2b_1,p13b_1)
      CALL TCE_RESTRICTED_4(h4b,p13b,h11b,h14b,h4b_2,p13b_2,h11b_2,h14b_
     &2)
      dim_common = int_mb(k_range+h11b-1) * int_mb(k_range+h14b-1) * int
     &_mb(k_range+p13b-1)
      dima_sort = int_mb(k_range+h3b-1) * int_mb(k_range+p1b-1) * int_mb
     &(k_range+p2b-1)
      dima = dim_common * dima_sort
      dimb_sort = int_mb(k_range+h4b-1)
      dimb = dim_common * dimb_sort
      IF ((dima .gt. 0) .and. (dimb .gt. 0)) THEN
      IF (.not.MA_PUSH_GET(mt_dbl,dima,'noname',l_a_sort,k_a_sort)) CALL
     & ERRQUIT('eomccsdt_y2_10',1,MA_ERR)
      IF (.not.MA_PUSH_GET(mt_dbl,dima,'noname',l_a,k_a)) CALL ERRQUIT('
     &eomccsdt_y2_10',2,MA_ERR)
      IF ((h14b .lt. h3b) .and. (p13b .lt. p1b)) THEN
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(p2b_1
     & - noab - 1 + nvab * (p1b_1 - noab - 1 + nvab * (p13b_1 - noab - 1
     & + nvab * (h3b_1 - 1 + noab * (h14b_1 - 1 + noab * (h11b_1 - 1))))
     &)))
      CALL TCE_SORT_6(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+h11b-1
     &),int_mb(k_range+h14b-1),int_mb(k_range+h3b-1),int_mb(k_range+p13b
     &-1),int_mb(k_range+p1b-1),int_mb(k_range+p2b-1),6,5,3,4,2,1,1.0d0)
      END IF
      IF ((h14b .lt. h3b) .and. (p1b .le. p13b) .and. (p13b .lt. p2b)) T
     &HEN
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(p2b_1
     & - noab - 1 + nvab * (p13b_1 - noab - 1 + nvab * (p1b_1 - noab - 1
     & + nvab * (h3b_1 - 1 + noab * (h14b_1 - 1 + noab * (h11b_1 - 1))))
     &)))
      CALL TCE_SORT_6(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+h11b-1
     &),int_mb(k_range+h14b-1),int_mb(k_range+h3b-1),int_mb(k_range+p1b-
     &1),int_mb(k_range+p13b-1),int_mb(k_range+p2b-1),6,4,3,5,2,1,-1.0d0
     &)
      END IF
      IF ((h14b .lt. h3b) .and. (p2b .le. p13b)) THEN
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(p13b_
     &1 - noab - 1 + nvab * (p2b_1 - noab - 1 + nvab * (p1b_1 - noab - 1
     & + nvab * (h3b_1 - 1 + noab * (h14b_1 - 1 + noab * (h11b_1 - 1))))
     &)))
      CALL TCE_SORT_6(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+h11b-1
     &),int_mb(k_range+h14b-1),int_mb(k_range+h3b-1),int_mb(k_range+p1b-
     &1),int_mb(k_range+p2b-1),int_mb(k_range+p13b-1),5,4,3,6,2,1,1.0d0)
      END IF
      IF ((h11b .lt. h3b) .and. (h3b .le. h14b) .and. (p13b .lt. p1b)) T
     &HEN
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(p2b_1
     & - noab - 1 + nvab * (p1b_1 - noab - 1 + nvab * (p13b_1 - noab - 1
     & + nvab * (h14b_1 - 1 + noab * (h3b_1 - 1 + noab * (h11b_1 - 1))))
     &)))
      CALL TCE_SORT_6(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+h11b-1
     &),int_mb(k_range+h3b-1),int_mb(k_range+h14b-1),int_mb(k_range+p13b
     &-1),int_mb(k_range+p1b-1),int_mb(k_range+p2b-1),6,5,2,4,3,1,-1.0d0
     &)
      END IF
      IF ((h11b .lt. h3b) .and. (h3b .le. h14b) .and. (p1b .le. p13b) .a
     &nd. (p13b .lt. p2b)) THEN
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(p2b_1
     & - noab - 1 + nvab * (p13b_1 - noab - 1 + nvab * (p1b_1 - noab - 1
     & + nvab * (h14b_1 - 1 + noab * (h3b_1 - 1 + noab * (h11b_1 - 1))))
     &)))
      CALL TCE_SORT_6(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+h11b-1
     &),int_mb(k_range+h3b-1),int_mb(k_range+h14b-1),int_mb(k_range+p1b-
     &1),int_mb(k_range+p13b-1),int_mb(k_range+p2b-1),6,4,2,5,3,1,1.0d0)
      END IF
      IF ((h11b .lt. h3b) .and. (h3b .le. h14b) .and. (p2b .le. p13b)) T
     &HEN
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(p13b_
     &1 - noab - 1 + nvab * (p2b_1 - noab - 1 + nvab * (p1b_1 - noab - 1
     & + nvab * (h14b_1 - 1 + noab * (h3b_1 - 1 + noab * (h11b_1 - 1))))
     &)))
      CALL TCE_SORT_6(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+h11b-1
     &),int_mb(k_range+h3b-1),int_mb(k_range+h14b-1),int_mb(k_range+p1b-
     &1),int_mb(k_range+p2b-1),int_mb(k_range+p13b-1),5,4,2,6,3,1,-1.0d0
     &)
      END IF
      IF ((h3b .le. h11b) .and. (p13b .lt. p1b)) THEN
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(p2b_1
     & - noab - 1 + nvab * (p1b_1 - noab - 1 + nvab * (p13b_1 - noab - 1
     & + nvab * (h14b_1 - 1 + noab * (h11b_1 - 1 + noab * (h3b_1 - 1))))
     &)))
      CALL TCE_SORT_6(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+h3b-1)
     &,int_mb(k_range+h11b-1),int_mb(k_range+h14b-1),int_mb(k_range+p13b
     &-1),int_mb(k_range+p1b-1),int_mb(k_range+p2b-1),6,5,1,4,3,2,1.0d0)
      END IF
      IF ((h3b .le. h11b) .and. (p1b .le. p13b) .and. (p13b .lt. p2b)) T
     &HEN
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(p2b_1
     & - noab - 1 + nvab * (p13b_1 - noab - 1 + nvab * (p1b_1 - noab - 1
     & + nvab * (h14b_1 - 1 + noab * (h11b_1 - 1 + noab * (h3b_1 - 1))))
     &)))
      CALL TCE_SORT_6(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+h3b-1)
     &,int_mb(k_range+h11b-1),int_mb(k_range+h14b-1),int_mb(k_range+p1b-
     &1),int_mb(k_range+p13b-1),int_mb(k_range+p2b-1),6,4,1,5,3,2,-1.0d0
     &)
      END IF
      IF ((h3b .le. h11b) .and. (p2b .le. p13b)) THEN
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(p13b_
     &1 - noab - 1 + nvab * (p2b_1 - noab - 1 + nvab * (p1b_1 - noab - 1
     & + nvab * (h14b_1 - 1 + noab * (h11b_1 - 1 + noab * (h3b_1 - 1))))
     &)))
      CALL TCE_SORT_6(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+h3b-1)
     &,int_mb(k_range+h11b-1),int_mb(k_range+h14b-1),int_mb(k_range+p1b-
     &1),int_mb(k_range+p2b-1),int_mb(k_range+p13b-1),5,4,1,6,3,2,1.0d0)
      END IF
      IF (.not.MA_POP_STACK(l_a)) CALL ERRQUIT('eomccsdt_y2_10',3,MA_ERR
     &)
      IF (.not.MA_PUSH_GET(mt_dbl,dimb,'noname',l_b_sort,k_b_sort)) CALL
     & ERRQUIT('eomccsdt_y2_10',4,MA_ERR)
      IF (.not.MA_PUSH_GET(mt_dbl,dimb,'noname',l_b,k_b)) CALL ERRQUIT('
     &eomccsdt_y2_10',5,MA_ERR)
      CALL GET_HASH_BLOCK(d_b,dbl_mb(k_b),dimb,int_mb(k_b_offset),(h14b_
     &2 - 1 + noab * (h11b_2 - 1 + noab * (p13b_2 - noab - 1 + nvab * (h
     &4b_2 - 1)))))
      CALL TCE_SORT_4(dbl_mb(k_b),dbl_mb(k_b_sort),int_mb(k_range+h4b-1)
     &,int_mb(k_range+p13b-1),int_mb(k_range+h11b-1),int_mb(k_range+h14b
     &-1),1,2,4,3,1.0d0)
      IF (.not.MA_POP_STACK(l_b)) CALL ERRQUIT('eomccsdt_y2_10',6,MA_ERR
     &)
      nsuperh(1) = 1
      nsuperh(2) = 1
      isuperh = 1
      IF (h11b .eq. h14b) THEN
      nsuperh(isuperh) = nsuperh(isuperh) + 1
      ELSE
      isuperh = isuperh + 1
      END IF
      CALL dgemm('T','N',dima_sort,dimb_sort,dim_common,2.0d0/FACTORIAL(
     &nsuperh(1))/FACTORIAL(nsuperh(2)),dbl_mb(k_a_sort),dim_common,dbl_
     &mb(k_b_sort),dim_common,1.0d0,dbl_mb(k_c_sort),dima_sort)
      IF (.not.MA_POP_STACK(l_b_sort)) CALL ERRQUIT('eomccsdt_y2_10',7,M
     &A_ERR)
      IF (.not.MA_POP_STACK(l_a_sort)) CALL ERRQUIT('eomccsdt_y2_10',8,M
     &A_ERR)
      END IF
      END IF
      END IF
      END DO
      END DO
      END DO
      IF (.not.MA_PUSH_GET(mt_dbl,dimc,'noname',l_c,k_c)) CALL ERRQUIT('
     &eomccsdt_y2_10',9,MA_ERR)
      IF ((h3b .le. h4b)) THEN
      CALL TCE_SORT_4(dbl_mb(k_c_sort),dbl_mb(k_c),int_mb(k_range+h4b-1)
     &,int_mb(k_range+p2b-1),int_mb(k_range+p1b-1),int_mb(k_range+h3b-1)
     &,4,1,3,2,1.0d0/2.0d0)
      CALL ADD_HASH_BLOCK(d_c,dbl_mb(k_c),dimc,int_mb(k_c_offset),(p2b -
     & noab - 1 + nvab * (p1b - noab - 1 + nvab * (h4b - 1 + noab * (h3b
     & - 1)))))
      END IF
      IF ((h4b .le. h3b)) THEN
      CALL TCE_SORT_4(dbl_mb(k_c_sort),dbl_mb(k_c),int_mb(k_range+h4b-1)
     &,int_mb(k_range+p2b-1),int_mb(k_range+p1b-1),int_mb(k_range+h3b-1)
     &,1,4,3,2,-1.0d0/2.0d0)
      CALL ADD_HASH_BLOCK(d_c,dbl_mb(k_c),dimc,int_mb(k_c_offset),(p2b -
     & noab - 1 + nvab * (p1b - noab - 1 + nvab * (h3b - 1 + noab * (h4b
     & - 1)))))
      END IF
      IF (.not.MA_POP_STACK(l_c)) CALL ERRQUIT('eomccsdt_y2_10',10,MA_ER
     &R)
      IF (.not.MA_POP_STACK(l_c_sort)) CALL ERRQUIT('eomccsdt_y2_10',11,
     &MA_ERR)
      END IF
      END IF
      END IF
      next = NXTASK(nprocs,1)
      END IF
      count = count + 1
      END DO
      END DO
      END DO
      END DO
      next = NXTASK(-nprocs,1)
      call GA_SYNC()
      RETURN
      END
      SUBROUTINE eomccsdt_y2_11_1(d_a,k_a_offset,d_c,k_c_offset)
C     $Id: eomccsdt_y2_all12.F 24184 2013-05-04 00:43:17Z edo $
C     This is a Fortran77 program generated by Tensor Contraction Engine v.1.0
C     Copyright (c) Battelle & Pacific Northwest National Laboratory (2002)
C     i1 ( p11 p13 h12 p1 )_v + = -1 * v ( p11 p13 h12 p1 )_v
      IMPLICIT NONE
#include "global.fh"
#include "mafdecls.fh"
#include "sym.fh"
#include "errquit.fh"
#include "tce.fh"
      INTEGER d_a
      INTEGER k_a_offset
      INTEGER d_c
      INTEGER k_c_offset
      INTEGER NXTASK
      INTEGER next
      INTEGER nprocs
      INTEGER count
      INTEGER p11b
      INTEGER p13b
      INTEGER p1b
      INTEGER h12b
      INTEGER dimc
      INTEGER p11b_1
      INTEGER p13b_1
      INTEGER p1b_1
      INTEGER h12b_1
      INTEGER dim_common
      INTEGER dima_sort
      INTEGER dima
      INTEGER l_a_sort
      INTEGER k_a_sort
      INTEGER l_a
      INTEGER k_a
      INTEGER l_c
      INTEGER k_c
      EXTERNAL NXTASK
      nprocs = GA_NNODES()
      count = 0
      next = NXTASK(nprocs,1)
      DO p11b = noab+1,noab+nvab
      DO p13b = p11b,noab+nvab
      DO p1b = noab+1,noab+nvab
      DO h12b = 1,noab
      IF (next.eq.count) THEN
      IF ((.not.restricted).or.(int_mb(k_spin+p11b-1)+int_mb(k_spin+p13b
     &-1)+int_mb(k_spin+p1b-1)+int_mb(k_spin+h12b-1).ne.8)) THEN
      IF (int_mb(k_spin+p11b-1)+int_mb(k_spin+p13b-1) .eq. int_mb(k_spin
     &+p1b-1)+int_mb(k_spin+h12b-1)) THEN
      IF (ieor(int_mb(k_sym+p11b-1),ieor(int_mb(k_sym+p13b-1),ieor(int_m
     &b(k_sym+p1b-1),int_mb(k_sym+h12b-1)))) .eq. irrep_v) THEN
      dimc = int_mb(k_range+p11b-1) * int_mb(k_range+p13b-1) * int_mb(k_
     &range+p1b-1) * int_mb(k_range+h12b-1)
      CALL TCE_RESTRICTED_4(p11b,p13b,p1b,h12b,p11b_1,p13b_1,p1b_1,h12b_
     &1)
      dim_common = 1
      dima_sort = int_mb(k_range+p11b-1) * int_mb(k_range+p13b-1) * int_
     &mb(k_range+p1b-1) * int_mb(k_range+h12b-1)
      dima = dim_common * dima_sort
      IF (dima .gt. 0) THEN
      IF (.not.MA_PUSH_GET(mt_dbl,dima,'noname',l_a_sort,k_a_sort)) CALL
     & ERRQUIT('eomccsdt_y2_11_1',0,MA_ERR)
      IF (.not.MA_PUSH_GET(mt_dbl,dima,'noname',l_a,k_a)) CALL ERRQUIT('
     &eomccsdt_y2_11_1',1,MA_ERR)
      IF ((h12b .le. p1b)) THEN
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(p1b_1
     & - 1 + (noab+nvab) * (h12b_1 - 1 + (noab+nvab) * (p13b_1 - 1 + (no
     &ab+nvab) * (p11b_1 - 1)))))
      CALL TCE_SORT_4(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+p11b-1
     &),int_mb(k_range+p13b-1),int_mb(k_range+h12b-1),int_mb(k_range+p1b
     &-1),3,4,2,1,1.0d0)
      END IF
      IF (.not.MA_POP_STACK(l_a)) CALL ERRQUIT('eomccsdt_y2_11_1',2,MA_E
     &RR)
      IF (.not.MA_PUSH_GET(mt_dbl,dimc,'noname',l_c,k_c)) CALL ERRQUIT('
     &eomccsdt_y2_11_1',3,MA_ERR)
      CALL TCE_SORT_4(dbl_mb(k_a_sort),dbl_mb(k_c),int_mb(k_range+h12b-1
     &),int_mb(k_range+p1b-1),int_mb(k_range+p13b-1),int_mb(k_range+p11b
     &-1),4,3,2,1,-1.0d0)
      CALL ADD_HASH_BLOCK(d_c,dbl_mb(k_c),dimc,int_mb(k_c_offset),(h12b 
     &- 1 + noab * (p1b - noab - 1 + nvab * (p13b - noab - 1 + nvab * (p
     &11b - noab - 1)))))
      IF (.not.MA_POP_STACK(l_c)) CALL ERRQUIT('eomccsdt_y2_11_1',4,MA_E
     &RR)
      IF (.not.MA_POP_STACK(l_a_sort)) CALL ERRQUIT('eomccsdt_y2_11_1',5
     &,MA_ERR)
      END IF
      END IF
      END IF
      END IF
      next = NXTASK(nprocs,1)
      END IF
      count = count + 1
      END DO
      END DO
      END DO
      END DO
      next = NXTASK(-nprocs,1)
      call GA_SYNC()
      RETURN
      END
      SUBROUTINE eomccsdt_y2_11_2(d_a,k_a_offset,d_b,k_b_offset,d_c,k_c_
     &offset)
C     $Id: eomccsdt_y2_all12.F 24184 2013-05-04 00:43:17Z edo $
C     This is a Fortran77 program generated by Tensor Contraction Engine v.1.0
C     Copyright (c) Battelle & Pacific Northwest National Laboratory (2002)
C     i1 ( p11 p13 h12 p1 )_vt + = 1 * Sum ( p5 ) * t ( p5 h12 )_t * v ( p11 p13 p1 p5 )_v
      IMPLICIT NONE
#include "global.fh"
#include "mafdecls.fh"
#include "sym.fh"
#include "errquit.fh"
#include "tce.fh"
      INTEGER d_a
      INTEGER k_a_offset
      INTEGER d_b
      INTEGER k_b_offset
      INTEGER d_c
      INTEGER k_c_offset
      INTEGER NXTASK
      INTEGER next
      INTEGER nprocs
      INTEGER count
      INTEGER p11b
      INTEGER p13b
      INTEGER p1b
      INTEGER h12b
      INTEGER dimc
      INTEGER l_c_sort
      INTEGER k_c_sort
      INTEGER p5b
      INTEGER p5b_1
      INTEGER h12b_1
      INTEGER p11b_2
      INTEGER p13b_2
      INTEGER p1b_2
      INTEGER p5b_2
      INTEGER dim_common
      INTEGER dima_sort
      INTEGER dima
      INTEGER dimb_sort
      INTEGER dimb
      INTEGER l_a_sort
      INTEGER k_a_sort
      INTEGER l_a
      INTEGER k_a
      INTEGER l_b_sort
      INTEGER k_b_sort
      INTEGER l_b
      INTEGER k_b
      INTEGER l_c
      INTEGER k_c
      EXTERNAL NXTASK
      nprocs = GA_NNODES()
      count = 0
      next = NXTASK(nprocs,1)
      DO p11b = noab+1,noab+nvab
      DO p13b = p11b,noab+nvab
      DO p1b = noab+1,noab+nvab
      DO h12b = 1,noab
      IF (next.eq.count) THEN
      IF ((.not.restricted).or.(int_mb(k_spin+p11b-1)+int_mb(k_spin+p13b
     &-1)+int_mb(k_spin+p1b-1)+int_mb(k_spin+h12b-1).ne.8)) THEN
      IF (int_mb(k_spin+p11b-1)+int_mb(k_spin+p13b-1) .eq. int_mb(k_spin
     &+p1b-1)+int_mb(k_spin+h12b-1)) THEN
      IF (ieor(int_mb(k_sym+p11b-1),ieor(int_mb(k_sym+p13b-1),ieor(int_m
     &b(k_sym+p1b-1),int_mb(k_sym+h12b-1)))) .eq. ieor(irrep_v,irrep_t))
     & THEN
      dimc = int_mb(k_range+p11b-1) * int_mb(k_range+p13b-1) * int_mb(k_
     &range+p1b-1) * int_mb(k_range+h12b-1)
      IF (.not.MA_PUSH_GET(mt_dbl,dimc,'noname',l_c_sort,k_c_sort)) CALL
     & ERRQUIT('eomccsdt_y2_11_2',0,MA_ERR)
      CALL DFILL(dimc,0.0d0,dbl_mb(k_c_sort),1)
      DO p5b = noab+1,noab+nvab
      IF (int_mb(k_spin+p5b-1) .eq. int_mb(k_spin+h12b-1)) THEN
      IF (ieor(int_mb(k_sym+p5b-1),int_mb(k_sym+h12b-1)) .eq. irrep_t) T
     &HEN
      CALL TCE_RESTRICTED_2(p5b,h12b,p5b_1,h12b_1)
      CALL TCE_RESTRICTED_4(p11b,p13b,p1b,p5b,p11b_2,p13b_2,p1b_2,p5b_2)
      dim_common = int_mb(k_range+p5b-1)
      dima_sort = int_mb(k_range+h12b-1)
      dima = dim_common * dima_sort
      dimb_sort = int_mb(k_range+p11b-1) * int_mb(k_range+p13b-1) * int_
     &mb(k_range+p1b-1)
      dimb = dim_common * dimb_sort
      IF ((dima .gt. 0) .and. (dimb .gt. 0)) THEN
      IF (.not.MA_PUSH_GET(mt_dbl,dima,'noname',l_a_sort,k_a_sort)) CALL
     & ERRQUIT('eomccsdt_y2_11_2',1,MA_ERR)
      IF (.not.MA_PUSH_GET(mt_dbl,dima,'noname',l_a,k_a)) CALL ERRQUIT('
     &eomccsdt_y2_11_2',2,MA_ERR)
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(h12b_
     &1 - 1 + noab * (p5b_1 - noab - 1)))
      CALL TCE_SORT_2(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+p5b-1)
     &,int_mb(k_range+h12b-1),2,1,1.0d0)
      IF (.not.MA_POP_STACK(l_a)) CALL ERRQUIT('eomccsdt_y2_11_2',3,MA_E
     &RR)
      IF (.not.MA_PUSH_GET(mt_dbl,dimb,'noname',l_b_sort,k_b_sort)) CALL
     & ERRQUIT('eomccsdt_y2_11_2',4,MA_ERR)
      IF (.not.MA_PUSH_GET(mt_dbl,dimb,'noname',l_b,k_b)) CALL ERRQUIT('
     &eomccsdt_y2_11_2',5,MA_ERR)
      IF ((p5b .lt. p1b)) THEN
      CALL GET_HASH_BLOCK(d_b,dbl_mb(k_b),dimb,int_mb(k_b_offset),(p1b_2
     & - 1 + (noab+nvab) * (p5b_2 - 1 + (noab+nvab) * (p13b_2 - 1 + (noa
     &b+nvab) * (p11b_2 - 1)))))
      CALL TCE_SORT_4(dbl_mb(k_b),dbl_mb(k_b_sort),int_mb(k_range+p11b-1
     &),int_mb(k_range+p13b-1),int_mb(k_range+p5b-1),int_mb(k_range+p1b-
     &1),4,2,1,3,-1.0d0)
      END IF
      IF ((p1b .le. p5b)) THEN
      CALL GET_HASH_BLOCK(d_b,dbl_mb(k_b),dimb,int_mb(k_b_offset),(p5b_2
     & - 1 + (noab+nvab) * (p1b_2 - 1 + (noab+nvab) * (p13b_2 - 1 + (noa
     &b+nvab) * (p11b_2 - 1)))))
      CALL TCE_SORT_4(dbl_mb(k_b),dbl_mb(k_b_sort),int_mb(k_range+p11b-1
     &),int_mb(k_range+p13b-1),int_mb(k_range+p1b-1),int_mb(k_range+p5b-
     &1),3,2,1,4,1.0d0)
      END IF
      IF (.not.MA_POP_STACK(l_b)) CALL ERRQUIT('eomccsdt_y2_11_2',6,MA_E
     &RR)
      CALL dgemm('T','N',dima_sort,dimb_sort,dim_common,1.0d0,dbl_mb(k_a
     &_sort),dim_common,dbl_mb(k_b_sort),dim_common,1.0d0,dbl_mb(k_c_sor
     &t),dima_sort)
      IF (.not.MA_POP_STACK(l_b_sort)) CALL ERRQUIT('eomccsdt_y2_11_2',7
     &,MA_ERR)
      IF (.not.MA_POP_STACK(l_a_sort)) CALL ERRQUIT('eomccsdt_y2_11_2',8
     &,MA_ERR)
      END IF
      END IF
      END IF
      END DO
      IF (.not.MA_PUSH_GET(mt_dbl,dimc,'noname',l_c,k_c)) CALL ERRQUIT('
     &eomccsdt_y2_11_2',9,MA_ERR)
      CALL TCE_SORT_4(dbl_mb(k_c_sort),dbl_mb(k_c),int_mb(k_range+p1b-1)
     &,int_mb(k_range+p13b-1),int_mb(k_range+p11b-1),int_mb(k_range+h12b
     &-1),3,2,1,4,1.0d0)
      CALL ADD_HASH_BLOCK(d_c,dbl_mb(k_c),dimc,int_mb(k_c_offset),(h12b 
     &- 1 + noab * (p1b - noab - 1 + nvab * (p13b - noab - 1 + nvab * (p
     &11b - noab - 1)))))
      IF (.not.MA_POP_STACK(l_c)) CALL ERRQUIT('eomccsdt_y2_11_2',10,MA_
     &ERR)
      IF (.not.MA_POP_STACK(l_c_sort)) CALL ERRQUIT('eomccsdt_y2_11_2',1
     &1,MA_ERR)
      END IF
      END IF
      END IF
      next = NXTASK(nprocs,1)
      END IF
      count = count + 1
      END DO
      END DO
      END DO
      END DO
      next = NXTASK(-nprocs,1)
      call GA_SYNC()
      RETURN
      END
      SUBROUTINE eomccsdt_y2_11_3_1(d_a,k_a_offset,d_c,k_c_offset)
C     $Id: eomccsdt_y2_all12.F 24184 2013-05-04 00:43:17Z edo $
C     This is a Fortran77 program generated by Tensor Contraction Engine v.1.0
C     Copyright (c) Battelle & Pacific Northwest National Laboratory (2002)
C     i2 ( h7 h8 h12 p1 )_v + = 1 * v ( h7 h8 h12 p1 )_v
      IMPLICIT NONE
#include "global.fh"
#include "mafdecls.fh"
#include "sym.fh"
#include "errquit.fh"
#include "tce.fh"
      INTEGER d_a
      INTEGER k_a_offset
      INTEGER d_c
      INTEGER k_c_offset
      INTEGER NXTASK
      INTEGER next
      INTEGER nprocs
      INTEGER count
      INTEGER h7b
      INTEGER h8b
      INTEGER p1b
      INTEGER h12b
      INTEGER dimc
      INTEGER h7b_1
      INTEGER h8b_1
      INTEGER p1b_1
      INTEGER h12b_1
      INTEGER dim_common
      INTEGER dima_sort
      INTEGER dima
      INTEGER l_a_sort
      INTEGER k_a_sort
      INTEGER l_a
      INTEGER k_a
      INTEGER l_c
      INTEGER k_c
      EXTERNAL NXTASK
      nprocs = GA_NNODES()
      count = 0
      next = NXTASK(nprocs,1)
      DO h7b = 1,noab
      DO h8b = h7b,noab
      DO p1b = noab+1,noab+nvab
      DO h12b = 1,noab
      IF (next.eq.count) THEN
      IF ((.not.restricted).or.(int_mb(k_spin+h7b-1)+int_mb(k_spin+h8b-1
     &)+int_mb(k_spin+p1b-1)+int_mb(k_spin+h12b-1).ne.8)) THEN
      IF (int_mb(k_spin+h7b-1)+int_mb(k_spin+h8b-1) .eq. int_mb(k_spin+p
     &1b-1)+int_mb(k_spin+h12b-1)) THEN
      IF (ieor(int_mb(k_sym+h7b-1),ieor(int_mb(k_sym+h8b-1),ieor(int_mb(
     &k_sym+p1b-1),int_mb(k_sym+h12b-1)))) .eq. irrep_v) THEN
      dimc = int_mb(k_range+h7b-1) * int_mb(k_range+h8b-1) * int_mb(k_ra
     &nge+p1b-1) * int_mb(k_range+h12b-1)
      CALL TCE_RESTRICTED_4(h7b,h8b,p1b,h12b,h7b_1,h8b_1,p1b_1,h12b_1)
      dim_common = 1
      dima_sort = int_mb(k_range+h7b-1) * int_mb(k_range+h8b-1) * int_mb
     &(k_range+p1b-1) * int_mb(k_range+h12b-1)
      dima = dim_common * dima_sort
      IF (dima .gt. 0) THEN
      IF (.not.MA_PUSH_GET(mt_dbl,dima,'noname',l_a_sort,k_a_sort)) CALL
     & ERRQUIT('eomccsdt_y2_11_3_1',0,MA_ERR)
      IF (.not.MA_PUSH_GET(mt_dbl,dima,'noname',l_a,k_a)) CALL ERRQUIT('
     &eomccsdt_y2_11_3_1',1,MA_ERR)
      IF ((h12b .le. p1b)) THEN
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(p1b_1
     & - 1 + (noab+nvab) * (h12b_1 - 1 + (noab+nvab) * (h8b_1 - 1 + (noa
     &b+nvab) * (h7b_1 - 1)))))
      CALL TCE_SORT_4(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+h7b-1)
     &,int_mb(k_range+h8b-1),int_mb(k_range+h12b-1),int_mb(k_range+p1b-1
     &),3,4,2,1,1.0d0)
      END IF
      IF (.not.MA_POP_STACK(l_a)) CALL ERRQUIT('eomccsdt_y2_11_3_1',2,MA
     &_ERR)
      IF (.not.MA_PUSH_GET(mt_dbl,dimc,'noname',l_c,k_c)) CALL ERRQUIT('
     &eomccsdt_y2_11_3_1',3,MA_ERR)
      CALL TCE_SORT_4(dbl_mb(k_a_sort),dbl_mb(k_c),int_mb(k_range+h12b-1
     &),int_mb(k_range+p1b-1),int_mb(k_range+h8b-1),int_mb(k_range+h7b-1
     &),4,3,2,1,1.0d0)
      CALL ADD_HASH_BLOCK(d_c,dbl_mb(k_c),dimc,int_mb(k_c_offset),(h12b 
     &- 1 + noab * (p1b - noab - 1 + nvab * (h8b - 1 + noab * (h7b - 1))
     &)))
      IF (.not.MA_POP_STACK(l_c)) CALL ERRQUIT('eomccsdt_y2_11_3_1',4,MA
     &_ERR)
      IF (.not.MA_POP_STACK(l_a_sort)) CALL ERRQUIT('eomccsdt_y2_11_3_1'
     &,5,MA_ERR)
      END IF
      END IF
      END IF
      END IF
      next = NXTASK(nprocs,1)
      END IF
      count = count + 1
      END DO
      END DO
      END DO
      END DO
      next = NXTASK(-nprocs,1)
      call GA_SYNC()
      RETURN
      END
      SUBROUTINE eomccsdt_y2_11_3_2(d_a,k_a_offset,d_b,k_b_offset,d_c,k_
     &c_offset)
C     $Id: eomccsdt_y2_all12.F 24184 2013-05-04 00:43:17Z edo $
C     This is a Fortran77 program generated by Tensor Contraction Engine v.1.0
C     Copyright (c) Battelle & Pacific Northwest National Laboratory (2002)
C     i2 ( h7 h8 h12 p1 )_vt + = -1 * Sum ( p9 ) * t ( p9 h12 )_t * v ( h7 h8 p1 p9 )_v
      IMPLICIT NONE
#include "global.fh"
#include "mafdecls.fh"
#include "sym.fh"
#include "errquit.fh"
#include "tce.fh"
      INTEGER d_a
      INTEGER k_a_offset
      INTEGER d_b
      INTEGER k_b_offset
      INTEGER d_c
      INTEGER k_c_offset
      INTEGER NXTASK
      INTEGER next
      INTEGER nprocs
      INTEGER count
      INTEGER h7b
      INTEGER h8b
      INTEGER p1b
      INTEGER h12b
      INTEGER dimc
      INTEGER l_c_sort
      INTEGER k_c_sort
      INTEGER p9b
      INTEGER p9b_1
      INTEGER h12b_1
      INTEGER h7b_2
      INTEGER h8b_2
      INTEGER p1b_2
      INTEGER p9b_2
      INTEGER dim_common
      INTEGER dima_sort
      INTEGER dima
      INTEGER dimb_sort
      INTEGER dimb
      INTEGER l_a_sort
      INTEGER k_a_sort
      INTEGER l_a
      INTEGER k_a
      INTEGER l_b_sort
      INTEGER k_b_sort
      INTEGER l_b
      INTEGER k_b
      INTEGER l_c
      INTEGER k_c
      EXTERNAL NXTASK
      nprocs = GA_NNODES()
      count = 0
      next = NXTASK(nprocs,1)
      DO h7b = 1,noab
      DO h8b = h7b,noab
      DO p1b = noab+1,noab+nvab
      DO h12b = 1,noab
      IF (next.eq.count) THEN
      IF ((.not.restricted).or.(int_mb(k_spin+h7b-1)+int_mb(k_spin+h8b-1
     &)+int_mb(k_spin+p1b-1)+int_mb(k_spin+h12b-1).ne.8)) THEN
      IF (int_mb(k_spin+h7b-1)+int_mb(k_spin+h8b-1) .eq. int_mb(k_spin+p
     &1b-1)+int_mb(k_spin+h12b-1)) THEN
      IF (ieor(int_mb(k_sym+h7b-1),ieor(int_mb(k_sym+h8b-1),ieor(int_mb(
     &k_sym+p1b-1),int_mb(k_sym+h12b-1)))) .eq. ieor(irrep_v,irrep_t)) T
     &HEN
      dimc = int_mb(k_range+h7b-1) * int_mb(k_range+h8b-1) * int_mb(k_ra
     &nge+p1b-1) * int_mb(k_range+h12b-1)
      IF (.not.MA_PUSH_GET(mt_dbl,dimc,'noname',l_c_sort,k_c_sort)) CALL
     & ERRQUIT('eomccsdt_y2_11_3_2',0,MA_ERR)
      CALL DFILL(dimc,0.0d0,dbl_mb(k_c_sort),1)
      DO p9b = noab+1,noab+nvab
      IF (int_mb(k_spin+p9b-1) .eq. int_mb(k_spin+h12b-1)) THEN
      IF (ieor(int_mb(k_sym+p9b-1),int_mb(k_sym+h12b-1)) .eq. irrep_t) T
     &HEN
      CALL TCE_RESTRICTED_2(p9b,h12b,p9b_1,h12b_1)
      CALL TCE_RESTRICTED_4(h7b,h8b,p1b,p9b,h7b_2,h8b_2,p1b_2,p9b_2)
      dim_common = int_mb(k_range+p9b-1)
      dima_sort = int_mb(k_range+h12b-1)
      dima = dim_common * dima_sort
      dimb_sort = int_mb(k_range+h7b-1) * int_mb(k_range+h8b-1) * int_mb
     &(k_range+p1b-1)
      dimb = dim_common * dimb_sort
      IF ((dima .gt. 0) .and. (dimb .gt. 0)) THEN
      IF (.not.MA_PUSH_GET(mt_dbl,dima,'noname',l_a_sort,k_a_sort)) CALL
     & ERRQUIT('eomccsdt_y2_11_3_2',1,MA_ERR)
      IF (.not.MA_PUSH_GET(mt_dbl,dima,'noname',l_a,k_a)) CALL ERRQUIT('
     &eomccsdt_y2_11_3_2',2,MA_ERR)
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(h12b_
     &1 - 1 + noab * (p9b_1 - noab - 1)))
      CALL TCE_SORT_2(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+p9b-1)
     &,int_mb(k_range+h12b-1),2,1,1.0d0)
      IF (.not.MA_POP_STACK(l_a)) CALL ERRQUIT('eomccsdt_y2_11_3_2',3,MA
     &_ERR)
      IF (.not.MA_PUSH_GET(mt_dbl,dimb,'noname',l_b_sort,k_b_sort)) CALL
     & ERRQUIT('eomccsdt_y2_11_3_2',4,MA_ERR)
      IF (.not.MA_PUSH_GET(mt_dbl,dimb,'noname',l_b,k_b)) CALL ERRQUIT('
     &eomccsdt_y2_11_3_2',5,MA_ERR)
      IF ((p9b .lt. p1b)) THEN
      CALL GET_HASH_BLOCK(d_b,dbl_mb(k_b),dimb,int_mb(k_b_offset),(p1b_2
     & - 1 + (noab+nvab) * (p9b_2 - 1 + (noab+nvab) * (h8b_2 - 1 + (noab
     &+nvab) * (h7b_2 - 1)))))
      CALL TCE_SORT_4(dbl_mb(k_b),dbl_mb(k_b_sort),int_mb(k_range+h7b-1)
     &,int_mb(k_range+h8b-1),int_mb(k_range+p9b-1),int_mb(k_range+p1b-1)
     &,4,2,1,3,-1.0d0)
      END IF
      IF ((p1b .le. p9b)) THEN
      CALL GET_HASH_BLOCK(d_b,dbl_mb(k_b),dimb,int_mb(k_b_offset),(p9b_2
     & - 1 + (noab+nvab) * (p1b_2 - 1 + (noab+nvab) * (h8b_2 - 1 + (noab
     &+nvab) * (h7b_2 - 1)))))
      CALL TCE_SORT_4(dbl_mb(k_b),dbl_mb(k_b_sort),int_mb(k_range+h7b-1)
     &,int_mb(k_range+h8b-1),int_mb(k_range+p1b-1),int_mb(k_range+p9b-1)
     &,3,2,1,4,1.0d0)
      END IF
      IF (.not.MA_POP_STACK(l_b)) CALL ERRQUIT('eomccsdt_y2_11_3_2',6,MA
     &_ERR)
      CALL dgemm('T','N',dima_sort,dimb_sort,dim_common,1.0d0,dbl_mb(k_a
     &_sort),dim_common,dbl_mb(k_b_sort),dim_common,1.0d0,dbl_mb(k_c_sor
     &t),dima_sort)
      IF (.not.MA_POP_STACK(l_b_sort)) CALL ERRQUIT('eomccsdt_y2_11_3_2'
     &,7,MA_ERR)
      IF (.not.MA_POP_STACK(l_a_sort)) CALL ERRQUIT('eomccsdt_y2_11_3_2'
     &,8,MA_ERR)
      END IF
      END IF
      END IF
      END DO
      IF (.not.MA_PUSH_GET(mt_dbl,dimc,'noname',l_c,k_c)) CALL ERRQUIT('
     &eomccsdt_y2_11_3_2',9,MA_ERR)
      CALL TCE_SORT_4(dbl_mb(k_c_sort),dbl_mb(k_c),int_mb(k_range+p1b-1)
     &,int_mb(k_range+h8b-1),int_mb(k_range+h7b-1),int_mb(k_range+h12b-1
     &),3,2,1,4,-1.0d0)
      CALL ADD_HASH_BLOCK(d_c,dbl_mb(k_c),dimc,int_mb(k_c_offset),(h12b 
     &- 1 + noab * (p1b - noab - 1 + nvab * (h8b - 1 + noab * (h7b - 1))
     &)))
      IF (.not.MA_POP_STACK(l_c)) CALL ERRQUIT('eomccsdt_y2_11_3_2',10,M
     &A_ERR)
      IF (.not.MA_POP_STACK(l_c_sort)) CALL ERRQUIT('eomccsdt_y2_11_3_2'
     &,11,MA_ERR)
      END IF
      END IF
      END IF
      next = NXTASK(nprocs,1)
      END IF
      count = count + 1
      END DO
      END DO
      END DO
      END DO
      next = NXTASK(-nprocs,1)
      call GA_SYNC()
      RETURN
      END
      SUBROUTINE eomccsdt_y2_11_3(d_a,k_a_offset,d_b,k_b_offset,d_c,k_c_
     &offset)
C     $Id: eomccsdt_y2_all12.F 24184 2013-05-04 00:43:17Z edo $
C     This is a Fortran77 program generated by Tensor Contraction Engine v.1.0
C     Copyright (c) Battelle & Pacific Northwest National Laboratory (2002)
C     i1 ( p11 p13 h12 p1 )_vt + = -1/2 * Sum ( h7 h8 ) * t ( p11 p13 h7 h8 )_t * i2 ( h7 h8 h12 p1 )_v
      IMPLICIT NONE
#include "global.fh"
#include "mafdecls.fh"
#include "sym.fh"
#include "errquit.fh"
#include "tce.fh"
      INTEGER d_a
      INTEGER k_a_offset
      INTEGER d_b
      INTEGER k_b_offset
      INTEGER d_c
      INTEGER k_c_offset
      INTEGER NXTASK
      INTEGER next
      INTEGER nprocs
      INTEGER count
      INTEGER p11b
      INTEGER p13b
      INTEGER p1b
      INTEGER h12b
      INTEGER dimc
      INTEGER l_c_sort
      INTEGER k_c_sort
      INTEGER h7b
      INTEGER h8b
      INTEGER p11b_1
      INTEGER p13b_1
      INTEGER h7b_1
      INTEGER h8b_1
      INTEGER h7b_2
      INTEGER h8b_2
      INTEGER p1b_2
      INTEGER h12b_2
      INTEGER dim_common
      INTEGER dima_sort
      INTEGER dima
      INTEGER dimb_sort
      INTEGER dimb
      INTEGER l_a_sort
      INTEGER k_a_sort
      INTEGER l_a
      INTEGER k_a
      INTEGER l_b_sort
      INTEGER k_b_sort
      INTEGER l_b
      INTEGER k_b
      INTEGER nsubh(2)
      INTEGER isubh
      INTEGER l_c
      INTEGER k_c
      DOUBLE PRECISION FACTORIAL
      EXTERNAL NXTASK
      EXTERNAL FACTORIAL
      nprocs = GA_NNODES()
      count = 0
      next = NXTASK(nprocs,1)
      DO p11b = noab+1,noab+nvab
      DO p13b = p11b,noab+nvab
      DO p1b = noab+1,noab+nvab
      DO h12b = 1,noab
      IF (next.eq.count) THEN
      IF ((.not.restricted).or.(int_mb(k_spin+p11b-1)+int_mb(k_spin+p13b
     &-1)+int_mb(k_spin+p1b-1)+int_mb(k_spin+h12b-1).ne.8)) THEN
      IF (int_mb(k_spin+p11b-1)+int_mb(k_spin+p13b-1) .eq. int_mb(k_spin
     &+p1b-1)+int_mb(k_spin+h12b-1)) THEN
      IF (ieor(int_mb(k_sym+p11b-1),ieor(int_mb(k_sym+p13b-1),ieor(int_m
     &b(k_sym+p1b-1),int_mb(k_sym+h12b-1)))) .eq. ieor(irrep_v,irrep_t))
     & THEN
      dimc = int_mb(k_range+p11b-1) * int_mb(k_range+p13b-1) * int_mb(k_
     &range+p1b-1) * int_mb(k_range+h12b-1)
      IF (.not.MA_PUSH_GET(mt_dbl,dimc,'noname',l_c_sort,k_c_sort)) CALL
     & ERRQUIT('eomccsdt_y2_11_3',0,MA_ERR)
      CALL DFILL(dimc,0.0d0,dbl_mb(k_c_sort),1)
      DO h7b = 1,noab
      DO h8b = h7b,noab
      IF (int_mb(k_spin+p11b-1)+int_mb(k_spin+p13b-1) .eq. int_mb(k_spin
     &+h7b-1)+int_mb(k_spin+h8b-1)) THEN
      IF (ieor(int_mb(k_sym+p11b-1),ieor(int_mb(k_sym+p13b-1),ieor(int_m
     &b(k_sym+h7b-1),int_mb(k_sym+h8b-1)))) .eq. irrep_t) THEN
      CALL TCE_RESTRICTED_4(p11b,p13b,h7b,h8b,p11b_1,p13b_1,h7b_1,h8b_1)
      CALL TCE_RESTRICTED_4(h7b,h8b,p1b,h12b,h7b_2,h8b_2,p1b_2,h12b_2)
      dim_common = int_mb(k_range+h7b-1) * int_mb(k_range+h8b-1)
      dima_sort = int_mb(k_range+p11b-1) * int_mb(k_range+p13b-1)
      dima = dim_common * dima_sort
      dimb_sort = int_mb(k_range+p1b-1) * int_mb(k_range+h12b-1)
      dimb = dim_common * dimb_sort
      IF ((dima .gt. 0) .and. (dimb .gt. 0)) THEN
      IF (.not.MA_PUSH_GET(mt_dbl,dima,'noname',l_a_sort,k_a_sort)) CALL
     & ERRQUIT('eomccsdt_y2_11_3',1,MA_ERR)
      IF (.not.MA_PUSH_GET(mt_dbl,dima,'noname',l_a,k_a)) CALL ERRQUIT('
     &eomccsdt_y2_11_3',2,MA_ERR)
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(h8b_1
     & - 1 + noab * (h7b_1 - 1 + noab * (p13b_1 - noab - 1 + nvab * (p11
     &b_1 - noab - 1)))))
      CALL TCE_SORT_4(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+p11b-1
     &),int_mb(k_range+p13b-1),int_mb(k_range+h7b-1),int_mb(k_range+h8b-
     &1),2,1,4,3,1.0d0)
      IF (.not.MA_POP_STACK(l_a)) CALL ERRQUIT('eomccsdt_y2_11_3',3,MA_E
     &RR)
      IF (.not.MA_PUSH_GET(mt_dbl,dimb,'noname',l_b_sort,k_b_sort)) CALL
     & ERRQUIT('eomccsdt_y2_11_3',4,MA_ERR)
      IF (.not.MA_PUSH_GET(mt_dbl,dimb,'noname',l_b,k_b)) CALL ERRQUIT('
     &eomccsdt_y2_11_3',5,MA_ERR)
      CALL GET_HASH_BLOCK(d_b,dbl_mb(k_b),dimb,int_mb(k_b_offset),(h12b_
     &2 - 1 + noab * (p1b_2 - noab - 1 + nvab * (h8b_2 - 1 + noab * (h7b
     &_2 - 1)))))
      CALL TCE_SORT_4(dbl_mb(k_b),dbl_mb(k_b_sort),int_mb(k_range+h7b-1)
     &,int_mb(k_range+h8b-1),int_mb(k_range+p1b-1),int_mb(k_range+h12b-1
     &),4,3,2,1,1.0d0)
      IF (.not.MA_POP_STACK(l_b)) CALL ERRQUIT('eomccsdt_y2_11_3',6,MA_E
     &RR)
      nsubh(1) = 1
      nsubh(2) = 1
      isubh = 1
      IF (h7b .eq. h8b) THEN
      nsubh(isubh) = nsubh(isubh) + 1
      ELSE
      isubh = isubh + 1
      END IF
      CALL dgemm('T','N',dima_sort,dimb_sort,dim_common,2.0d0/FACTORIAL(
     &nsubh(1))/FACTORIAL(nsubh(2)),dbl_mb(k_a_sort),dim_common,dbl_mb(k
     &_b_sort),dim_common,1.0d0,dbl_mb(k_c_sort),dima_sort)
      IF (.not.MA_POP_STACK(l_b_sort)) CALL ERRQUIT('eomccsdt_y2_11_3',7
     &,MA_ERR)
      IF (.not.MA_POP_STACK(l_a_sort)) CALL ERRQUIT('eomccsdt_y2_11_3',8
     &,MA_ERR)
      END IF
      END IF
      END IF
      END DO
      END DO
      IF (.not.MA_PUSH_GET(mt_dbl,dimc,'noname',l_c,k_c)) CALL ERRQUIT('
     &eomccsdt_y2_11_3',9,MA_ERR)
      CALL TCE_SORT_4(dbl_mb(k_c_sort),dbl_mb(k_c),int_mb(k_range+h12b-1
     &),int_mb(k_range+p1b-1),int_mb(k_range+p13b-1),int_mb(k_range+p11b
     &-1),4,3,2,1,-1.0d0/2.0d0)
      CALL ADD_HASH_BLOCK(d_c,dbl_mb(k_c),dimc,int_mb(k_c_offset),(h12b 
     &- 1 + noab * (p1b - noab - 1 + nvab * (p13b - noab - 1 + nvab * (p
     &11b - noab - 1)))))
      IF (.not.MA_POP_STACK(l_c)) CALL ERRQUIT('eomccsdt_y2_11_3',10,MA_
     &ERR)
      IF (.not.MA_POP_STACK(l_c_sort)) CALL ERRQUIT('eomccsdt_y2_11_3',1
     &1,MA_ERR)
      END IF
      END IF
      END IF
      next = NXTASK(nprocs,1)
      END IF
      count = count + 1
      END DO
      END DO
      END DO
      END DO
      next = NXTASK(-nprocs,1)
      call GA_SYNC()
      RETURN
      END
      SUBROUTINE eomccsdt_y2_11_4(d_a,k_a_offset,d_b,k_b_offset,d_c,k_c_
     &offset)
C     $Id: eomccsdt_y2_all12.F 24184 2013-05-04 00:43:17Z edo $
C     This is a Fortran77 program generated by Tensor Contraction Engine v.1.0
C     Copyright (c) Battelle & Pacific Northwest National Laboratory (2002)
C     i1 ( p11 p13 h12 p1 )_vt + = -2 * Sum ( h8 p6 ) * t ( p6 p13 h8 h12 )_t * v ( h8 p11 p1 p6 )_v
      IMPLICIT NONE
#include "global.fh"
#include "mafdecls.fh"
#include "sym.fh"
#include "errquit.fh"
#include "tce.fh"
      INTEGER d_a
      INTEGER k_a_offset
      INTEGER d_b
      INTEGER k_b_offset
      INTEGER d_c
      INTEGER k_c_offset
      INTEGER NXTASK
      INTEGER next
      INTEGER nprocs
      INTEGER count
      INTEGER p13b
      INTEGER p11b
      INTEGER p1b
      INTEGER h12b
      INTEGER dimc
      INTEGER l_c_sort
      INTEGER k_c_sort
      INTEGER p6b
      INTEGER h8b
      INTEGER p13b_1
      INTEGER p6b_1
      INTEGER h12b_1
      INTEGER h8b_1
      INTEGER p11b_2
      INTEGER h8b_2
      INTEGER p1b_2
      INTEGER p6b_2
      INTEGER dim_common
      INTEGER dima_sort
      INTEGER dima
      INTEGER dimb_sort
      INTEGER dimb
      INTEGER l_a_sort
      INTEGER k_a_sort
      INTEGER l_a
      INTEGER k_a
      INTEGER l_b_sort
      INTEGER k_b_sort
      INTEGER l_b
      INTEGER k_b
      INTEGER l_c
      INTEGER k_c
      EXTERNAL NXTASK
      nprocs = GA_NNODES()
      count = 0
      next = NXTASK(nprocs,1)
      DO p13b = noab+1,noab+nvab
      DO p11b = noab+1,noab+nvab
      DO p1b = noab+1,noab+nvab
      DO h12b = 1,noab
      IF (next.eq.count) THEN
      IF ((.not.restricted).or.(int_mb(k_spin+p11b-1)+int_mb(k_spin+p13b
     &-1)+int_mb(k_spin+p1b-1)+int_mb(k_spin+h12b-1).ne.8)) THEN
      IF (int_mb(k_spin+p11b-1)+int_mb(k_spin+p13b-1) .eq. int_mb(k_spin
     &+p1b-1)+int_mb(k_spin+h12b-1)) THEN
      IF (ieor(int_mb(k_sym+p11b-1),ieor(int_mb(k_sym+p13b-1),ieor(int_m
     &b(k_sym+p1b-1),int_mb(k_sym+h12b-1)))) .eq. ieor(irrep_v,irrep_t))
     & THEN
      dimc = int_mb(k_range+p11b-1) * int_mb(k_range+p13b-1) * int_mb(k_
     &range+p1b-1) * int_mb(k_range+h12b-1)
      IF (.not.MA_PUSH_GET(mt_dbl,dimc,'noname',l_c_sort,k_c_sort)) CALL
     & ERRQUIT('eomccsdt_y2_11_4',0,MA_ERR)
      CALL DFILL(dimc,0.0d0,dbl_mb(k_c_sort),1)
      DO p6b = noab+1,noab+nvab
      DO h8b = 1,noab
      IF (int_mb(k_spin+p13b-1)+int_mb(k_spin+p6b-1) .eq. int_mb(k_spin+
     &h12b-1)+int_mb(k_spin+h8b-1)) THEN
      IF (ieor(int_mb(k_sym+p13b-1),ieor(int_mb(k_sym+p6b-1),ieor(int_mb
     &(k_sym+h12b-1),int_mb(k_sym+h8b-1)))) .eq. irrep_t) THEN
      CALL TCE_RESTRICTED_4(p13b,p6b,h12b,h8b,p13b_1,p6b_1,h12b_1,h8b_1)
      CALL TCE_RESTRICTED_4(p11b,h8b,p1b,p6b,p11b_2,h8b_2,p1b_2,p6b_2)
      dim_common = int_mb(k_range+p6b-1) * int_mb(k_range+h8b-1)
      dima_sort = int_mb(k_range+p13b-1) * int_mb(k_range+h12b-1)
      dima = dim_common * dima_sort
      dimb_sort = int_mb(k_range+p11b-1) * int_mb(k_range+p1b-1)
      dimb = dim_common * dimb_sort
      IF ((dima .gt. 0) .and. (dimb .gt. 0)) THEN
      IF (.not.MA_PUSH_GET(mt_dbl,dima,'noname',l_a_sort,k_a_sort)) CALL
     & ERRQUIT('eomccsdt_y2_11_4',1,MA_ERR)
      IF (.not.MA_PUSH_GET(mt_dbl,dima,'noname',l_a,k_a)) CALL ERRQUIT('
     &eomccsdt_y2_11_4',2,MA_ERR)
      IF ((p6b .le. p13b) .and. (h8b .le. h12b)) THEN
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(h12b_
     &1 - 1 + noab * (h8b_1 - 1 + noab * (p13b_1 - noab - 1 + nvab * (p6
     &b_1 - noab - 1)))))
      CALL TCE_SORT_4(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+p6b-1)
     &,int_mb(k_range+p13b-1),int_mb(k_range+h8b-1),int_mb(k_range+h12b-
     &1),4,2,3,1,1.0d0)
      END IF
      IF ((p6b .le. p13b) .and. (h12b .lt. h8b)) THEN
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(h8b_1
     & - 1 + noab * (h12b_1 - 1 + noab * (p13b_1 - noab - 1 + nvab * (p6
     &b_1 - noab - 1)))))
      CALL TCE_SORT_4(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+p6b-1)
     &,int_mb(k_range+p13b-1),int_mb(k_range+h12b-1),int_mb(k_range+h8b-
     &1),3,2,4,1,-1.0d0)
      END IF
      IF ((p13b .lt. p6b) .and. (h8b .le. h12b)) THEN
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(h12b_
     &1 - 1 + noab * (h8b_1 - 1 + noab * (p6b_1 - noab - 1 + nvab * (p13
     &b_1 - noab - 1)))))
      CALL TCE_SORT_4(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+p13b-1
     &),int_mb(k_range+p6b-1),int_mb(k_range+h8b-1),int_mb(k_range+h12b-
     &1),4,1,3,2,-1.0d0)
      END IF
      IF ((p13b .lt. p6b) .and. (h12b .lt. h8b)) THEN
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(h8b_1
     & - 1 + noab * (h12b_1 - 1 + noab * (p6b_1 - noab - 1 + nvab * (p13
     &b_1 - noab - 1)))))
      CALL TCE_SORT_4(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+p13b-1
     &),int_mb(k_range+p6b-1),int_mb(k_range+h12b-1),int_mb(k_range+h8b-
     &1),3,1,4,2,1.0d0)
      END IF
      IF (.not.MA_POP_STACK(l_a)) CALL ERRQUIT('eomccsdt_y2_11_4',3,MA_E
     &RR)
      IF (.not.MA_PUSH_GET(mt_dbl,dimb,'noname',l_b_sort,k_b_sort)) CALL
     & ERRQUIT('eomccsdt_y2_11_4',4,MA_ERR)
      IF (.not.MA_PUSH_GET(mt_dbl,dimb,'noname',l_b,k_b)) CALL ERRQUIT('
     &eomccsdt_y2_11_4',5,MA_ERR)
      IF ((h8b .le. p11b) .and. (p6b .lt. p1b)) THEN
      CALL GET_HASH_BLOCK(d_b,dbl_mb(k_b),dimb,int_mb(k_b_offset),(p1b_2
     & - 1 + (noab+nvab) * (p6b_2 - 1 + (noab+nvab) * (p11b_2 - 1 + (noa
     &b+nvab) * (h8b_2 - 1)))))
      CALL TCE_SORT_4(dbl_mb(k_b),dbl_mb(k_b_sort),int_mb(k_range+h8b-1)
     &,int_mb(k_range+p11b-1),int_mb(k_range+p6b-1),int_mb(k_range+p1b-1
     &),4,2,1,3,-1.0d0)
      END IF
      IF ((h8b .le. p11b) .and. (p1b .le. p6b)) THEN
      CALL GET_HASH_BLOCK(d_b,dbl_mb(k_b),dimb,int_mb(k_b_offset),(p6b_2
     & - 1 + (noab+nvab) * (p1b_2 - 1 + (noab+nvab) * (p11b_2 - 1 + (noa
     &b+nvab) * (h8b_2 - 1)))))
      CALL TCE_SORT_4(dbl_mb(k_b),dbl_mb(k_b_sort),int_mb(k_range+h8b-1)
     &,int_mb(k_range+p11b-1),int_mb(k_range+p1b-1),int_mb(k_range+p6b-1
     &),3,2,1,4,1.0d0)
      END IF
      IF (.not.MA_POP_STACK(l_b)) CALL ERRQUIT('eomccsdt_y2_11_4',6,MA_E
     &RR)
      CALL dgemm('T','N',dima_sort,dimb_sort,dim_common,1.0d0,dbl_mb(k_a
     &_sort),dim_common,dbl_mb(k_b_sort),dim_common,1.0d0,dbl_mb(k_c_sor
     &t),dima_sort)
      IF (.not.MA_POP_STACK(l_b_sort)) CALL ERRQUIT('eomccsdt_y2_11_4',7
     &,MA_ERR)
      IF (.not.MA_POP_STACK(l_a_sort)) CALL ERRQUIT('eomccsdt_y2_11_4',8
     &,MA_ERR)
      END IF
      END IF
      END IF
      END DO
      END DO
      IF (.not.MA_PUSH_GET(mt_dbl,dimc,'noname',l_c,k_c)) CALL ERRQUIT('
     &eomccsdt_y2_11_4',9,MA_ERR)
      IF ((p11b .le. p13b)) THEN
      CALL TCE_SORT_4(dbl_mb(k_c_sort),dbl_mb(k_c),int_mb(k_range+p1b-1)
     &,int_mb(k_range+p11b-1),int_mb(k_range+h12b-1),int_mb(k_range+p13b
     &-1),2,4,1,3,-1.0d0)
      CALL ADD_HASH_BLOCK(d_c,dbl_mb(k_c),dimc,int_mb(k_c_offset),(h12b 
     &- 1 + noab * (p1b - noab - 1 + nvab * (p13b - noab - 1 + nvab * (p
     &11b - noab - 1)))))
      END IF
      IF ((p13b .le. p11b)) THEN
      CALL TCE_SORT_4(dbl_mb(k_c_sort),dbl_mb(k_c),int_mb(k_range+p1b-1)
     &,int_mb(k_range+p11b-1),int_mb(k_range+h12b-1),int_mb(k_range+p13b
     &-1),4,2,1,3,1.0d0)
      CALL ADD_HASH_BLOCK(d_c,dbl_mb(k_c),dimc,int_mb(k_c_offset),(h12b 
     &- 1 + noab * (p1b - noab - 1 + nvab * (p11b - noab - 1 + nvab * (p
     &13b - noab - 1)))))
      END IF
      IF (.not.MA_POP_STACK(l_c)) CALL ERRQUIT('eomccsdt_y2_11_4',10,MA_
     &ERR)
      IF (.not.MA_POP_STACK(l_c_sort)) CALL ERRQUIT('eomccsdt_y2_11_4',1
     &1,MA_ERR)
      END IF
      END IF
      END IF
      next = NXTASK(nprocs,1)
      END IF
      count = count + 1
      END DO
      END DO
      END DO
      END DO
      next = NXTASK(-nprocs,1)
      call GA_SYNC()
      RETURN
      END
      SUBROUTINE eomccsdt_y2_11_5(d_a,k_a_offset,d_b,k_b_offset,d_c,k_c_
     &offset)
C     $Id: eomccsdt_y2_all12.F 24184 2013-05-04 00:43:17Z edo $
C     This is a Fortran77 program generated by Tensor Contraction Engine v.1.0
C     Copyright (c) Battelle & Pacific Northwest National Laboratory (2002)
C     i1 ( p11 p13 h12 p1 )_vt + = 1/2 * Sum ( h9 h10 p7 ) * t ( p7 p11 p13 h9 h10 h12 )_t * v ( h9 h10 p1 p7 )_v
      IMPLICIT NONE
#include "global.fh"
#include "mafdecls.fh"
#include "sym.fh"
#include "errquit.fh"
#include "tce.fh"
      INTEGER d_a
      INTEGER k_a_offset
      INTEGER d_b
      INTEGER k_b_offset
      INTEGER d_c
      INTEGER k_c_offset
      INTEGER NXTASK
      INTEGER next
      INTEGER nprocs
      INTEGER count
      INTEGER p11b
      INTEGER p13b
      INTEGER p1b
      INTEGER h12b
      INTEGER dimc
      INTEGER l_c_sort
      INTEGER k_c_sort
      INTEGER p7b
      INTEGER h9b
      INTEGER h10b
      INTEGER p11b_1
      INTEGER p13b_1
      INTEGER p7b_1
      INTEGER h12b_1
      INTEGER h9b_1
      INTEGER h10b_1
      INTEGER h9b_2
      INTEGER h10b_2
      INTEGER p1b_2
      INTEGER p7b_2
      INTEGER dim_common
      INTEGER dima_sort
      INTEGER dima
      INTEGER dimb_sort
      INTEGER dimb
      INTEGER l_a_sort
      INTEGER k_a_sort
      INTEGER l_a
      INTEGER k_a
      INTEGER l_b_sort
      INTEGER k_b_sort
      INTEGER l_b
      INTEGER k_b
      INTEGER nsubh(2)
      INTEGER isubh
      INTEGER l_c
      INTEGER k_c
      DOUBLE PRECISION FACTORIAL
      EXTERNAL NXTASK
      EXTERNAL FACTORIAL
      nprocs = GA_NNODES()
      count = 0
      next = NXTASK(nprocs,1)
      DO p11b = noab+1,noab+nvab
      DO p13b = p11b,noab+nvab
      DO p1b = noab+1,noab+nvab
      DO h12b = 1,noab
      IF (next.eq.count) THEN
      IF ((.not.restricted).or.(int_mb(k_spin+p11b-1)+int_mb(k_spin+p13b
     &-1)+int_mb(k_spin+p1b-1)+int_mb(k_spin+h12b-1).ne.8)) THEN
      IF (int_mb(k_spin+p11b-1)+int_mb(k_spin+p13b-1) .eq. int_mb(k_spin
     &+p1b-1)+int_mb(k_spin+h12b-1)) THEN
      IF (ieor(int_mb(k_sym+p11b-1),ieor(int_mb(k_sym+p13b-1),ieor(int_m
     &b(k_sym+p1b-1),int_mb(k_sym+h12b-1)))) .eq. ieor(irrep_v,irrep_t))
     & THEN
      dimc = int_mb(k_range+p11b-1) * int_mb(k_range+p13b-1) * int_mb(k_
     &range+p1b-1) * int_mb(k_range+h12b-1)
      IF (.not.MA_PUSH_GET(mt_dbl,dimc,'noname',l_c_sort,k_c_sort)) CALL
     & ERRQUIT('eomccsdt_y2_11_5',0,MA_ERR)
      CALL DFILL(dimc,0.0d0,dbl_mb(k_c_sort),1)
      DO p7b = noab+1,noab+nvab
      DO h9b = 1,noab
      DO h10b = h9b,noab
      IF (int_mb(k_spin+p11b-1)+int_mb(k_spin+p13b-1)+int_mb(k_spin+p7b-
     &1) .eq. int_mb(k_spin+h12b-1)+int_mb(k_spin+h9b-1)+int_mb(k_spin+h
     &10b-1)) THEN
      IF (ieor(int_mb(k_sym+p11b-1),ieor(int_mb(k_sym+p13b-1),ieor(int_m
     &b(k_sym+p7b-1),ieor(int_mb(k_sym+h12b-1),ieor(int_mb(k_sym+h9b-1),
     &int_mb(k_sym+h10b-1)))))) .eq. irrep_t) THEN
      CALL TCE_RESTRICTED_6(p11b,p13b,p7b,h12b,h9b,h10b,p11b_1,p13b_1,p7
     &b_1,h12b_1,h9b_1,h10b_1)
      CALL TCE_RESTRICTED_4(h9b,h10b,p1b,p7b,h9b_2,h10b_2,p1b_2,p7b_2)
      dim_common = int_mb(k_range+p7b-1) * int_mb(k_range+h9b-1) * int_m
     &b(k_range+h10b-1)
      dima_sort = int_mb(k_range+p11b-1) * int_mb(k_range+p13b-1) * int_
     &mb(k_range+h12b-1)
      dima = dim_common * dima_sort
      dimb_sort = int_mb(k_range+p1b-1)
      dimb = dim_common * dimb_sort
      IF ((dima .gt. 0) .and. (dimb .gt. 0)) THEN
      IF (.not.MA_PUSH_GET(mt_dbl,dima,'noname',l_a_sort,k_a_sort)) CALL
     & ERRQUIT('eomccsdt_y2_11_5',1,MA_ERR)
      IF (.not.MA_PUSH_GET(mt_dbl,dima,'noname',l_a,k_a)) CALL ERRQUIT('
     &eomccsdt_y2_11_5',2,MA_ERR)
      IF ((p7b .le. p11b) .and. (h10b .le. h12b)) THEN
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(h12b_
     &1 - 1 + noab * (h10b_1 - 1 + noab * (h9b_1 - 1 + noab * (p13b_1 - 
     &noab - 1 + nvab * (p11b_1 - noab - 1 + nvab * (p7b_1 - noab - 1)))
     &))))
      CALL TCE_SORT_6(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+p7b-1)
     &,int_mb(k_range+p11b-1),int_mb(k_range+p13b-1),int_mb(k_range+h9b-
     &1),int_mb(k_range+h10b-1),int_mb(k_range+h12b-1),6,3,2,5,4,1,1.0d0
     &)
      END IF
      IF ((p7b .le. p11b) .and. (h9b .le. h12b) .and. (h12b .lt. h10b)) 
     &THEN
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(h10b_
     &1 - 1 + noab * (h12b_1 - 1 + noab * (h9b_1 - 1 + noab * (p13b_1 - 
     &noab - 1 + nvab * (p11b_1 - noab - 1 + nvab * (p7b_1 - noab - 1)))
     &))))
      CALL TCE_SORT_6(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+p7b-1)
     &,int_mb(k_range+p11b-1),int_mb(k_range+p13b-1),int_mb(k_range+h9b-
     &1),int_mb(k_range+h12b-1),int_mb(k_range+h10b-1),5,3,2,6,4,1,-1.0d
     &0)
      END IF
      IF ((p7b .le. p11b) .and. (h12b .lt. h9b)) THEN
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(h10b_
     &1 - 1 + noab * (h9b_1 - 1 + noab * (h12b_1 - 1 + noab * (p13b_1 - 
     &noab - 1 + nvab * (p11b_1 - noab - 1 + nvab * (p7b_1 - noab - 1)))
     &))))
      CALL TCE_SORT_6(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+p7b-1)
     &,int_mb(k_range+p11b-1),int_mb(k_range+p13b-1),int_mb(k_range+h12b
     &-1),int_mb(k_range+h9b-1),int_mb(k_range+h10b-1),4,3,2,6,5,1,1.0d0
     &)
      END IF
      IF ((p11b .lt. p7b) .and. (p7b .le. p13b) .and. (h10b .le. h12b)) 
     &THEN
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(h12b_
     &1 - 1 + noab * (h10b_1 - 1 + noab * (h9b_1 - 1 + noab * (p13b_1 - 
     &noab - 1 + nvab * (p7b_1 - noab - 1 + nvab * (p11b_1 - noab - 1)))
     &))))
      CALL TCE_SORT_6(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+p11b-1
     &),int_mb(k_range+p7b-1),int_mb(k_range+p13b-1),int_mb(k_range+h9b-
     &1),int_mb(k_range+h10b-1),int_mb(k_range+h12b-1),6,3,1,5,4,2,-1.0d
     &0)
      END IF
      IF ((p11b .lt. p7b) .and. (p7b .le. p13b) .and. (h9b .le. h12b) .a
     &nd. (h12b .lt. h10b)) THEN
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(h10b_
     &1 - 1 + noab * (h12b_1 - 1 + noab * (h9b_1 - 1 + noab * (p13b_1 - 
     &noab - 1 + nvab * (p7b_1 - noab - 1 + nvab * (p11b_1 - noab - 1)))
     &))))
      CALL TCE_SORT_6(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+p11b-1
     &),int_mb(k_range+p7b-1),int_mb(k_range+p13b-1),int_mb(k_range+h9b-
     &1),int_mb(k_range+h12b-1),int_mb(k_range+h10b-1),5,3,1,6,4,2,1.0d0
     &)
      END IF
      IF ((p11b .lt. p7b) .and. (p7b .le. p13b) .and. (h12b .lt. h9b)) T
     &HEN
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(h10b_
     &1 - 1 + noab * (h9b_1 - 1 + noab * (h12b_1 - 1 + noab * (p13b_1 - 
     &noab - 1 + nvab * (p7b_1 - noab - 1 + nvab * (p11b_1 - noab - 1)))
     &))))
      CALL TCE_SORT_6(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+p11b-1
     &),int_mb(k_range+p7b-1),int_mb(k_range+p13b-1),int_mb(k_range+h12b
     &-1),int_mb(k_range+h9b-1),int_mb(k_range+h10b-1),4,3,1,6,5,2,-1.0d
     &0)
      END IF
      IF ((p13b .lt. p7b) .and. (h10b .le. h12b)) THEN
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(h12b_
     &1 - 1 + noab * (h10b_1 - 1 + noab * (h9b_1 - 1 + noab * (p7b_1 - n
     &oab - 1 + nvab * (p13b_1 - noab - 1 + nvab * (p11b_1 - noab - 1)))
     &))))
      CALL TCE_SORT_6(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+p11b-1
     &),int_mb(k_range+p13b-1),int_mb(k_range+p7b-1),int_mb(k_range+h9b-
     &1),int_mb(k_range+h10b-1),int_mb(k_range+h12b-1),6,2,1,5,4,3,1.0d0
     &)
      END IF
      IF ((p13b .lt. p7b) .and. (h9b .le. h12b) .and. (h12b .lt. h10b)) 
     &THEN
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(h10b_
     &1 - 1 + noab * (h12b_1 - 1 + noab * (h9b_1 - 1 + noab * (p7b_1 - n
     &oab - 1 + nvab * (p13b_1 - noab - 1 + nvab * (p11b_1 - noab - 1)))
     &))))
      CALL TCE_SORT_6(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+p11b-1
     &),int_mb(k_range+p13b-1),int_mb(k_range+p7b-1),int_mb(k_range+h9b-
     &1),int_mb(k_range+h12b-1),int_mb(k_range+h10b-1),5,2,1,6,4,3,-1.0d
     &0)
      END IF
      IF ((p13b .lt. p7b) .and. (h12b .lt. h9b)) THEN
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(h10b_
     &1 - 1 + noab * (h9b_1 - 1 + noab * (h12b_1 - 1 + noab * (p7b_1 - n
     &oab - 1 + nvab * (p13b_1 - noab - 1 + nvab * (p11b_1 - noab - 1)))
     &))))
      CALL TCE_SORT_6(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+p11b-1
     &),int_mb(k_range+p13b-1),int_mb(k_range+p7b-1),int_mb(k_range+h12b
     &-1),int_mb(k_range+h9b-1),int_mb(k_range+h10b-1),4,2,1,6,5,3,1.0d0
     &)
      END IF
      IF (.not.MA_POP_STACK(l_a)) CALL ERRQUIT('eomccsdt_y2_11_5',3,MA_E
     &RR)
      IF (.not.MA_PUSH_GET(mt_dbl,dimb,'noname',l_b_sort,k_b_sort)) CALL
     & ERRQUIT('eomccsdt_y2_11_5',4,MA_ERR)
      IF (.not.MA_PUSH_GET(mt_dbl,dimb,'noname',l_b,k_b)) CALL ERRQUIT('
     &eomccsdt_y2_11_5',5,MA_ERR)
      IF ((p7b .lt. p1b)) THEN
      CALL GET_HASH_BLOCK(d_b,dbl_mb(k_b),dimb,int_mb(k_b_offset),(p1b_2
     & - 1 + (noab+nvab) * (p7b_2 - 1 + (noab+nvab) * (h10b_2 - 1 + (noa
     &b+nvab) * (h9b_2 - 1)))))
      CALL TCE_SORT_4(dbl_mb(k_b),dbl_mb(k_b_sort),int_mb(k_range+h9b-1)
     &,int_mb(k_range+h10b-1),int_mb(k_range+p7b-1),int_mb(k_range+p1b-1
     &),4,2,1,3,-1.0d0)
      END IF
      IF ((p1b .le. p7b)) THEN
      CALL GET_HASH_BLOCK(d_b,dbl_mb(k_b),dimb,int_mb(k_b_offset),(p7b_2
     & - 1 + (noab+nvab) * (p1b_2 - 1 + (noab+nvab) * (h10b_2 - 1 + (noa
     &b+nvab) * (h9b_2 - 1)))))
      CALL TCE_SORT_4(dbl_mb(k_b),dbl_mb(k_b_sort),int_mb(k_range+h9b-1)
     &,int_mb(k_range+h10b-1),int_mb(k_range+p1b-1),int_mb(k_range+p7b-1
     &),3,2,1,4,1.0d0)
      END IF
      IF (.not.MA_POP_STACK(l_b)) CALL ERRQUIT('eomccsdt_y2_11_5',6,MA_E
     &RR)
      nsubh(1) = 1
      nsubh(2) = 1
      isubh = 1
      IF (h9b .eq. h10b) THEN
      nsubh(isubh) = nsubh(isubh) + 1
      ELSE
      isubh = isubh + 1
      END IF
      CALL dgemm('T','N',dima_sort,dimb_sort,dim_common,2.0d0/FACTORIAL(
     &nsubh(1))/FACTORIAL(nsubh(2)),dbl_mb(k_a_sort),dim_common,dbl_mb(k
     &_b_sort),dim_common,1.0d0,dbl_mb(k_c_sort),dima_sort)
      IF (.not.MA_POP_STACK(l_b_sort)) CALL ERRQUIT('eomccsdt_y2_11_5',7
     &,MA_ERR)
      IF (.not.MA_POP_STACK(l_a_sort)) CALL ERRQUIT('eomccsdt_y2_11_5',8
     &,MA_ERR)
      END IF
      END IF
      END IF
      END DO
      END DO
      END DO
      IF (.not.MA_PUSH_GET(mt_dbl,dimc,'noname',l_c,k_c)) CALL ERRQUIT('
     &eomccsdt_y2_11_5',9,MA_ERR)
      CALL TCE_SORT_4(dbl_mb(k_c_sort),dbl_mb(k_c),int_mb(k_range+p1b-1)
     &,int_mb(k_range+h12b-1),int_mb(k_range+p13b-1),int_mb(k_range+p11b
     &-1),4,3,1,2,1.0d0/2.0d0)
      CALL ADD_HASH_BLOCK(d_c,dbl_mb(k_c),dimc,int_mb(k_c_offset),(h12b 
     &- 1 + noab * (p1b - noab - 1 + nvab * (p13b - noab - 1 + nvab * (p
     &11b - noab - 1)))))
      IF (.not.MA_POP_STACK(l_c)) CALL ERRQUIT('eomccsdt_y2_11_5',10,MA_
     &ERR)
      IF (.not.MA_POP_STACK(l_c_sort)) CALL ERRQUIT('eomccsdt_y2_11_5',1
     &1,MA_ERR)
      END IF
      END IF
      END IF
      next = NXTASK(nprocs,1)
      END IF
      count = count + 1
      END DO
      END DO
      END DO
      END DO
      next = NXTASK(-nprocs,1)
      call GA_SYNC()
      RETURN
      END
      SUBROUTINE eomccsdt_y2_11_6_1(d_a,k_a_offset,d_b,k_b_offset,d_c,k_
     &c_offset)
C     $Id: eomccsdt_y2_all12.F 24184 2013-05-04 00:43:17Z edo $
C     This is a Fortran77 program generated by Tensor Contraction Engine v.1.0
C     Copyright (c) Battelle & Pacific Northwest National Laboratory (2002)
C     i2 ( h8 p11 h12 p1 )_vt + = -1 * Sum ( p5 ) * t ( p5 h12 )_t * v ( h8 p11 p1 p5 )_v
      IMPLICIT NONE
#include "global.fh"
#include "mafdecls.fh"
#include "sym.fh"
#include "errquit.fh"
#include "tce.fh"
      INTEGER d_a
      INTEGER k_a_offset
      INTEGER d_b
      INTEGER k_b_offset
      INTEGER d_c
      INTEGER k_c_offset
      INTEGER NXTASK
      INTEGER next
      INTEGER nprocs
      INTEGER count
      INTEGER h8b
      INTEGER p11b
      INTEGER p1b
      INTEGER h12b
      INTEGER dimc
      INTEGER l_c_sort
      INTEGER k_c_sort
      INTEGER p5b
      INTEGER p5b_1
      INTEGER h12b_1
      INTEGER h8b_2
      INTEGER p11b_2
      INTEGER p1b_2
      INTEGER p5b_2
      INTEGER dim_common
      INTEGER dima_sort
      INTEGER dima
      INTEGER dimb_sort
      INTEGER dimb
      INTEGER l_a_sort
      INTEGER k_a_sort
      INTEGER l_a
      INTEGER k_a
      INTEGER l_b_sort
      INTEGER k_b_sort
      INTEGER l_b
      INTEGER k_b
      INTEGER l_c
      INTEGER k_c
      EXTERNAL NXTASK
      nprocs = GA_NNODES()
      count = 0
      next = NXTASK(nprocs,1)
      DO h8b = 1,noab
      DO p11b = noab+1,noab+nvab
      DO p1b = noab+1,noab+nvab
      DO h12b = 1,noab
      IF (next.eq.count) THEN
      IF ((.not.restricted).or.(int_mb(k_spin+h8b-1)+int_mb(k_spin+p11b-
     &1)+int_mb(k_spin+p1b-1)+int_mb(k_spin+h12b-1).ne.8)) THEN
      IF (int_mb(k_spin+h8b-1)+int_mb(k_spin+p11b-1) .eq. int_mb(k_spin+
     &p1b-1)+int_mb(k_spin+h12b-1)) THEN
      IF (ieor(int_mb(k_sym+h8b-1),ieor(int_mb(k_sym+p11b-1),ieor(int_mb
     &(k_sym+p1b-1),int_mb(k_sym+h12b-1)))) .eq. ieor(irrep_v,irrep_t)) 
     &THEN
      dimc = int_mb(k_range+h8b-1) * int_mb(k_range+p11b-1) * int_mb(k_r
     &ange+p1b-1) * int_mb(k_range+h12b-1)
      IF (.not.MA_PUSH_GET(mt_dbl,dimc,'noname',l_c_sort,k_c_sort)) CALL
     & ERRQUIT('eomccsdt_y2_11_6_1',0,MA_ERR)
      CALL DFILL(dimc,0.0d0,dbl_mb(k_c_sort),1)
      DO p5b = noab+1,noab+nvab
      IF (int_mb(k_spin+p5b-1) .eq. int_mb(k_spin+h12b-1)) THEN
      IF (ieor(int_mb(k_sym+p5b-1),int_mb(k_sym+h12b-1)) .eq. irrep_t) T
     &HEN
      CALL TCE_RESTRICTED_2(p5b,h12b,p5b_1,h12b_1)
      CALL TCE_RESTRICTED_4(h8b,p11b,p1b,p5b,h8b_2,p11b_2,p1b_2,p5b_2)
      dim_common = int_mb(k_range+p5b-1)
      dima_sort = int_mb(k_range+h12b-1)
      dima = dim_common * dima_sort
      dimb_sort = int_mb(k_range+h8b-1) * int_mb(k_range+p11b-1) * int_m
     &b(k_range+p1b-1)
      dimb = dim_common * dimb_sort
      IF ((dima .gt. 0) .and. (dimb .gt. 0)) THEN
      IF (.not.MA_PUSH_GET(mt_dbl,dima,'noname',l_a_sort,k_a_sort)) CALL
     & ERRQUIT('eomccsdt_y2_11_6_1',1,MA_ERR)
      IF (.not.MA_PUSH_GET(mt_dbl,dima,'noname',l_a,k_a)) CALL ERRQUIT('
     &eomccsdt_y2_11_6_1',2,MA_ERR)
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(h12b_
     &1 - 1 + noab * (p5b_1 - noab - 1)))
      CALL TCE_SORT_2(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+p5b-1)
     &,int_mb(k_range+h12b-1),2,1,1.0d0)
      IF (.not.MA_POP_STACK(l_a)) CALL ERRQUIT('eomccsdt_y2_11_6_1',3,MA
     &_ERR)
      IF (.not.MA_PUSH_GET(mt_dbl,dimb,'noname',l_b_sort,k_b_sort)) CALL
     & ERRQUIT('eomccsdt_y2_11_6_1',4,MA_ERR)
      IF (.not.MA_PUSH_GET(mt_dbl,dimb,'noname',l_b,k_b)) CALL ERRQUIT('
     &eomccsdt_y2_11_6_1',5,MA_ERR)
      IF ((p5b .lt. p1b)) THEN
      CALL GET_HASH_BLOCK(d_b,dbl_mb(k_b),dimb,int_mb(k_b_offset),(p1b_2
     & - 1 + (noab+nvab) * (p5b_2 - 1 + (noab+nvab) * (p11b_2 - 1 + (noa
     &b+nvab) * (h8b_2 - 1)))))
      CALL TCE_SORT_4(dbl_mb(k_b),dbl_mb(k_b_sort),int_mb(k_range+h8b-1)
     &,int_mb(k_range+p11b-1),int_mb(k_range+p5b-1),int_mb(k_range+p1b-1
     &),4,2,1,3,-1.0d0)
      END IF
      IF ((p1b .le. p5b)) THEN
      CALL GET_HASH_BLOCK(d_b,dbl_mb(k_b),dimb,int_mb(k_b_offset),(p5b_2
     & - 1 + (noab+nvab) * (p1b_2 - 1 + (noab+nvab) * (p11b_2 - 1 + (noa
     &b+nvab) * (h8b_2 - 1)))))
      CALL TCE_SORT_4(dbl_mb(k_b),dbl_mb(k_b_sort),int_mb(k_range+h8b-1)
     &,int_mb(k_range+p11b-1),int_mb(k_range+p1b-1),int_mb(k_range+p5b-1
     &),3,2,1,4,1.0d0)
      END IF
      IF (.not.MA_POP_STACK(l_b)) CALL ERRQUIT('eomccsdt_y2_11_6_1',6,MA
     &_ERR)
      CALL dgemm('T','N',dima_sort,dimb_sort,dim_common,1.0d0,dbl_mb(k_a
     &_sort),dim_common,dbl_mb(k_b_sort),dim_common,1.0d0,dbl_mb(k_c_sor
     &t),dima_sort)
      IF (.not.MA_POP_STACK(l_b_sort)) CALL ERRQUIT('eomccsdt_y2_11_6_1'
     &,7,MA_ERR)
      IF (.not.MA_POP_STACK(l_a_sort)) CALL ERRQUIT('eomccsdt_y2_11_6_1'
     &,8,MA_ERR)
      END IF
      END IF
      END IF
      END DO
      IF (.not.MA_PUSH_GET(mt_dbl,dimc,'noname',l_c,k_c)) CALL ERRQUIT('
     &eomccsdt_y2_11_6_1',9,MA_ERR)
      CALL TCE_SORT_4(dbl_mb(k_c_sort),dbl_mb(k_c),int_mb(k_range+p1b-1)
     &,int_mb(k_range+p11b-1),int_mb(k_range+h8b-1),int_mb(k_range+h12b-
     &1),3,2,1,4,-1.0d0)
      CALL ADD_HASH_BLOCK(d_c,dbl_mb(k_c),dimc,int_mb(k_c_offset),(h12b 
     &- 1 + noab * (p1b - noab - 1 + nvab * (p11b - noab - 1 + nvab * (h
     &8b - 1)))))
      IF (.not.MA_POP_STACK(l_c)) CALL ERRQUIT('eomccsdt_y2_11_6_1',10,M
     &A_ERR)
      IF (.not.MA_POP_STACK(l_c_sort)) CALL ERRQUIT('eomccsdt_y2_11_6_1'
     &,11,MA_ERR)
      END IF
      END IF
      END IF
      next = NXTASK(nprocs,1)
      END IF
      count = count + 1
      END DO
      END DO
      END DO
      END DO
      next = NXTASK(-nprocs,1)
      call GA_SYNC()
      RETURN
      END
      SUBROUTINE eomccsdt_y2_11_6(d_a,k_a_offset,d_b,k_b_offset,d_c,k_c_
     &offset)
C     $Id: eomccsdt_y2_all12.F 24184 2013-05-04 00:43:17Z edo $
C     This is a Fortran77 program generated by Tensor Contraction Engine v.1.0
C     Copyright (c) Battelle & Pacific Northwest National Laboratory (2002)
C     i1 ( p11 p13 h12 p1 )_vtt + = -2 * Sum ( h8 ) * t ( p13 h8 )_t * i2 ( h8 p11 h12 p1 )_vt
      IMPLICIT NONE
#include "global.fh"
#include "mafdecls.fh"
#include "sym.fh"
#include "errquit.fh"
#include "tce.fh"
      INTEGER d_a
      INTEGER k_a_offset
      INTEGER d_b
      INTEGER k_b_offset
      INTEGER d_c
      INTEGER k_c_offset
      INTEGER NXTASK
      INTEGER next
      INTEGER nprocs
      INTEGER count
      INTEGER p13b
      INTEGER p11b
      INTEGER p1b
      INTEGER h12b
      INTEGER dimc
      INTEGER l_c_sort
      INTEGER k_c_sort
      INTEGER h8b
      INTEGER p13b_1
      INTEGER h8b_1
      INTEGER p11b_2
      INTEGER h8b_2
      INTEGER p1b_2
      INTEGER h12b_2
      INTEGER dim_common
      INTEGER dima_sort
      INTEGER dima
      INTEGER dimb_sort
      INTEGER dimb
      INTEGER l_a_sort
      INTEGER k_a_sort
      INTEGER l_a
      INTEGER k_a
      INTEGER l_b_sort
      INTEGER k_b_sort
      INTEGER l_b
      INTEGER k_b
      INTEGER l_c
      INTEGER k_c
      EXTERNAL NXTASK
      nprocs = GA_NNODES()
      count = 0
      next = NXTASK(nprocs,1)
      DO p13b = noab+1,noab+nvab
      DO p11b = noab+1,noab+nvab
      DO p1b = noab+1,noab+nvab
      DO h12b = 1,noab
      IF (next.eq.count) THEN
      IF ((.not.restricted).or.(int_mb(k_spin+p11b-1)+int_mb(k_spin+p13b
     &-1)+int_mb(k_spin+p1b-1)+int_mb(k_spin+h12b-1).ne.8)) THEN
      IF (int_mb(k_spin+p11b-1)+int_mb(k_spin+p13b-1) .eq. int_mb(k_spin
     &+p1b-1)+int_mb(k_spin+h12b-1)) THEN
      IF (ieor(int_mb(k_sym+p11b-1),ieor(int_mb(k_sym+p13b-1),ieor(int_m
     &b(k_sym+p1b-1),int_mb(k_sym+h12b-1)))) .eq. ieor(irrep_v,ieor(irre
     &p_t,irrep_t))) THEN
      dimc = int_mb(k_range+p11b-1) * int_mb(k_range+p13b-1) * int_mb(k_
     &range+p1b-1) * int_mb(k_range+h12b-1)
      IF (.not.MA_PUSH_GET(mt_dbl,dimc,'noname',l_c_sort,k_c_sort)) CALL
     & ERRQUIT('eomccsdt_y2_11_6',0,MA_ERR)
      CALL DFILL(dimc,0.0d0,dbl_mb(k_c_sort),1)
      DO h8b = 1,noab
      IF (int_mb(k_spin+p13b-1) .eq. int_mb(k_spin+h8b-1)) THEN
      IF (ieor(int_mb(k_sym+p13b-1),int_mb(k_sym+h8b-1)) .eq. irrep_t) T
     &HEN
      CALL TCE_RESTRICTED_2(p13b,h8b,p13b_1,h8b_1)
      CALL TCE_RESTRICTED_4(p11b,h8b,p1b,h12b,p11b_2,h8b_2,p1b_2,h12b_2)
      dim_common = int_mb(k_range+h8b-1)
      dima_sort = int_mb(k_range+p13b-1)
      dima = dim_common * dima_sort
      dimb_sort = int_mb(k_range+p11b-1) * int_mb(k_range+p1b-1) * int_m
     &b(k_range+h12b-1)
      dimb = dim_common * dimb_sort
      IF ((dima .gt. 0) .and. (dimb .gt. 0)) THEN
      IF (.not.MA_PUSH_GET(mt_dbl,dima,'noname',l_a_sort,k_a_sort)) CALL
     & ERRQUIT('eomccsdt_y2_11_6',1,MA_ERR)
      IF (.not.MA_PUSH_GET(mt_dbl,dima,'noname',l_a,k_a)) CALL ERRQUIT('
     &eomccsdt_y2_11_6',2,MA_ERR)
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(h8b_1
     & - 1 + noab * (p13b_1 - noab - 1)))
      CALL TCE_SORT_2(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+p13b-1
     &),int_mb(k_range+h8b-1),1,2,1.0d0)
      IF (.not.MA_POP_STACK(l_a)) CALL ERRQUIT('eomccsdt_y2_11_6',3,MA_E
     &RR)
      IF (.not.MA_PUSH_GET(mt_dbl,dimb,'noname',l_b_sort,k_b_sort)) CALL
     & ERRQUIT('eomccsdt_y2_11_6',4,MA_ERR)
      IF (.not.MA_PUSH_GET(mt_dbl,dimb,'noname',l_b,k_b)) CALL ERRQUIT('
     &eomccsdt_y2_11_6',5,MA_ERR)
      IF ((h8b .le. p11b)) THEN
      CALL GET_HASH_BLOCK(d_b,dbl_mb(k_b),dimb,int_mb(k_b_offset),(h12b_
     &2 - 1 + noab * (p1b_2 - noab - 1 + nvab * (p11b_2 - noab - 1 + nva
     &b * (h8b_2 - 1)))))
      CALL TCE_SORT_4(dbl_mb(k_b),dbl_mb(k_b_sort),int_mb(k_range+h8b-1)
     &,int_mb(k_range+p11b-1),int_mb(k_range+p1b-1),int_mb(k_range+h12b-
     &1),4,3,2,1,1.0d0)
      END IF
      IF (.not.MA_POP_STACK(l_b)) CALL ERRQUIT('eomccsdt_y2_11_6',6,MA_E
     &RR)
      CALL dgemm('T','N',dima_sort,dimb_sort,dim_common,1.0d0,dbl_mb(k_a
     &_sort),dim_common,dbl_mb(k_b_sort),dim_common,1.0d0,dbl_mb(k_c_sor
     &t),dima_sort)
      IF (.not.MA_POP_STACK(l_b_sort)) CALL ERRQUIT('eomccsdt_y2_11_6',7
     &,MA_ERR)
      IF (.not.MA_POP_STACK(l_a_sort)) CALL ERRQUIT('eomccsdt_y2_11_6',8
     &,MA_ERR)
      END IF
      END IF
      END IF
      END DO
      IF (.not.MA_PUSH_GET(mt_dbl,dimc,'noname',l_c,k_c)) CALL ERRQUIT('
     &eomccsdt_y2_11_6',9,MA_ERR)
      IF ((p11b .le. p13b)) THEN
      CALL TCE_SORT_4(dbl_mb(k_c_sort),dbl_mb(k_c),int_mb(k_range+h12b-1
     &),int_mb(k_range+p1b-1),int_mb(k_range+p11b-1),int_mb(k_range+p13b
     &-1),3,4,2,1,-1.0d0)
      CALL ADD_HASH_BLOCK(d_c,dbl_mb(k_c),dimc,int_mb(k_c_offset),(h12b 
     &- 1 + noab * (p1b - noab - 1 + nvab * (p13b - noab - 1 + nvab * (p
     &11b - noab - 1)))))
      END IF
      IF ((p13b .le. p11b)) THEN
      CALL TCE_SORT_4(dbl_mb(k_c_sort),dbl_mb(k_c),int_mb(k_range+h12b-1
     &),int_mb(k_range+p1b-1),int_mb(k_range+p11b-1),int_mb(k_range+p13b
     &-1),4,3,2,1,1.0d0)
      CALL ADD_HASH_BLOCK(d_c,dbl_mb(k_c),dimc,int_mb(k_c_offset),(h12b 
     &- 1 + noab * (p1b - noab - 1 + nvab * (p11b - noab - 1 + nvab * (p
     &13b - noab - 1)))))
      END IF
      IF (.not.MA_POP_STACK(l_c)) CALL ERRQUIT('eomccsdt_y2_11_6',10,MA_
     &ERR)
      IF (.not.MA_POP_STACK(l_c_sort)) CALL ERRQUIT('eomccsdt_y2_11_6',1
     &1,MA_ERR)
      END IF
      END IF
      END IF
      next = NXTASK(nprocs,1)
      END IF
      count = count + 1
      END DO
      END DO
      END DO
      END DO
      next = NXTASK(-nprocs,1)
      call GA_SYNC()
      RETURN
      END
      SUBROUTINE eomccsdt_y2_11_7_1(d_a,k_a_offset,d_b,k_b_offset,d_c,k_
     &c_offset)
C     $Id: eomccsdt_y2_all12.F 24184 2013-05-04 00:43:17Z edo $
C     This is a Fortran77 program generated by Tensor Contraction Engine v.1.0
C     Copyright (c) Battelle & Pacific Northwest National Laboratory (2002)
C     i2 ( h10 p13 h12 p1 )_vt + = 1 * Sum ( h8 p6 ) * t ( p6 p13 h8 h12 )_t * v ( h8 h10 p1 p6 )_v
      IMPLICIT NONE
#include "global.fh"
#include "mafdecls.fh"
#include "sym.fh"
#include "errquit.fh"
#include "tce.fh"
      INTEGER d_a
      INTEGER k_a_offset
      INTEGER d_b
      INTEGER k_b_offset
      INTEGER d_c
      INTEGER k_c_offset
      INTEGER NXTASK
      INTEGER next
      INTEGER nprocs
      INTEGER count
      INTEGER p13b
      INTEGER h10b
      INTEGER p1b
      INTEGER h12b
      INTEGER dimc
      INTEGER l_c_sort
      INTEGER k_c_sort
      INTEGER p6b
      INTEGER h8b
      INTEGER p13b_1
      INTEGER p6b_1
      INTEGER h12b_1
      INTEGER h8b_1
      INTEGER h10b_2
      INTEGER h8b_2
      INTEGER p1b_2
      INTEGER p6b_2
      INTEGER dim_common
      INTEGER dima_sort
      INTEGER dima
      INTEGER dimb_sort
      INTEGER dimb
      INTEGER l_a_sort
      INTEGER k_a_sort
      INTEGER l_a
      INTEGER k_a
      INTEGER l_b_sort
      INTEGER k_b_sort
      INTEGER l_b
      INTEGER k_b
      INTEGER l_c
      INTEGER k_c
      EXTERNAL NXTASK
      nprocs = GA_NNODES()
      count = 0
      next = NXTASK(nprocs,1)
      DO p13b = noab+1,noab+nvab
      DO h10b = 1,noab
      DO p1b = noab+1,noab+nvab
      DO h12b = 1,noab
      IF (next.eq.count) THEN
      IF ((.not.restricted).or.(int_mb(k_spin+h10b-1)+int_mb(k_spin+p13b
     &-1)+int_mb(k_spin+p1b-1)+int_mb(k_spin+h12b-1).ne.8)) THEN
      IF (int_mb(k_spin+h10b-1)+int_mb(k_spin+p13b-1) .eq. int_mb(k_spin
     &+p1b-1)+int_mb(k_spin+h12b-1)) THEN
      IF (ieor(int_mb(k_sym+h10b-1),ieor(int_mb(k_sym+p13b-1),ieor(int_m
     &b(k_sym+p1b-1),int_mb(k_sym+h12b-1)))) .eq. ieor(irrep_v,irrep_t))
     & THEN
      dimc = int_mb(k_range+h10b-1) * int_mb(k_range+p13b-1) * int_mb(k_
     &range+p1b-1) * int_mb(k_range+h12b-1)
      IF (.not.MA_PUSH_GET(mt_dbl,dimc,'noname',l_c_sort,k_c_sort)) CALL
     & ERRQUIT('eomccsdt_y2_11_7_1',0,MA_ERR)
      CALL DFILL(dimc,0.0d0,dbl_mb(k_c_sort),1)
      DO p6b = noab+1,noab+nvab
      DO h8b = 1,noab
      IF (int_mb(k_spin+p13b-1)+int_mb(k_spin+p6b-1) .eq. int_mb(k_spin+
     &h12b-1)+int_mb(k_spin+h8b-1)) THEN
      IF (ieor(int_mb(k_sym+p13b-1),ieor(int_mb(k_sym+p6b-1),ieor(int_mb
     &(k_sym+h12b-1),int_mb(k_sym+h8b-1)))) .eq. irrep_t) THEN
      CALL TCE_RESTRICTED_4(p13b,p6b,h12b,h8b,p13b_1,p6b_1,h12b_1,h8b_1)
      CALL TCE_RESTRICTED_4(h10b,h8b,p1b,p6b,h10b_2,h8b_2,p1b_2,p6b_2)
      dim_common = int_mb(k_range+p6b-1) * int_mb(k_range+h8b-1)
      dima_sort = int_mb(k_range+p13b-1) * int_mb(k_range+h12b-1)
      dima = dim_common * dima_sort
      dimb_sort = int_mb(k_range+h10b-1) * int_mb(k_range+p1b-1)
      dimb = dim_common * dimb_sort
      IF ((dima .gt. 0) .and. (dimb .gt. 0)) THEN
      IF (.not.MA_PUSH_GET(mt_dbl,dima,'noname',l_a_sort,k_a_sort)) CALL
     & ERRQUIT('eomccsdt_y2_11_7_1',1,MA_ERR)
      IF (.not.MA_PUSH_GET(mt_dbl,dima,'noname',l_a,k_a)) CALL ERRQUIT('
     &eomccsdt_y2_11_7_1',2,MA_ERR)
      IF ((p6b .le. p13b) .and. (h8b .le. h12b)) THEN
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(h12b_
     &1 - 1 + noab * (h8b_1 - 1 + noab * (p13b_1 - noab - 1 + nvab * (p6
     &b_1 - noab - 1)))))
      CALL TCE_SORT_4(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+p6b-1)
     &,int_mb(k_range+p13b-1),int_mb(k_range+h8b-1),int_mb(k_range+h12b-
     &1),4,2,3,1,1.0d0)
      END IF
      IF ((p6b .le. p13b) .and. (h12b .lt. h8b)) THEN
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(h8b_1
     & - 1 + noab * (h12b_1 - 1 + noab * (p13b_1 - noab - 1 + nvab * (p6
     &b_1 - noab - 1)))))
      CALL TCE_SORT_4(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+p6b-1)
     &,int_mb(k_range+p13b-1),int_mb(k_range+h12b-1),int_mb(k_range+h8b-
     &1),3,2,4,1,-1.0d0)
      END IF
      IF ((p13b .lt. p6b) .and. (h8b .le. h12b)) THEN
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(h12b_
     &1 - 1 + noab * (h8b_1 - 1 + noab * (p6b_1 - noab - 1 + nvab * (p13
     &b_1 - noab - 1)))))
      CALL TCE_SORT_4(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+p13b-1
     &),int_mb(k_range+p6b-1),int_mb(k_range+h8b-1),int_mb(k_range+h12b-
     &1),4,1,3,2,-1.0d0)
      END IF
      IF ((p13b .lt. p6b) .and. (h12b .lt. h8b)) THEN
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(h8b_1
     & - 1 + noab * (h12b_1 - 1 + noab * (p6b_1 - noab - 1 + nvab * (p13
     &b_1 - noab - 1)))))
      CALL TCE_SORT_4(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+p13b-1
     &),int_mb(k_range+p6b-1),int_mb(k_range+h12b-1),int_mb(k_range+h8b-
     &1),3,1,4,2,1.0d0)
      END IF
      IF (.not.MA_POP_STACK(l_a)) CALL ERRQUIT('eomccsdt_y2_11_7_1',3,MA
     &_ERR)
      IF (.not.MA_PUSH_GET(mt_dbl,dimb,'noname',l_b_sort,k_b_sort)) CALL
     & ERRQUIT('eomccsdt_y2_11_7_1',4,MA_ERR)
      IF (.not.MA_PUSH_GET(mt_dbl,dimb,'noname',l_b,k_b)) CALL ERRQUIT('
     &eomccsdt_y2_11_7_1',5,MA_ERR)
      IF ((h8b .le. h10b) .and. (p6b .lt. p1b)) THEN
      CALL GET_HASH_BLOCK(d_b,dbl_mb(k_b),dimb,int_mb(k_b_offset),(p1b_2
     & - 1 + (noab+nvab) * (p6b_2 - 1 + (noab+nvab) * (h10b_2 - 1 + (noa
     &b+nvab) * (h8b_2 - 1)))))
      CALL TCE_SORT_4(dbl_mb(k_b),dbl_mb(k_b_sort),int_mb(k_range+h8b-1)
     &,int_mb(k_range+h10b-1),int_mb(k_range+p6b-1),int_mb(k_range+p1b-1
     &),4,2,1,3,-1.0d0)
      END IF
      IF ((h8b .le. h10b) .and. (p1b .le. p6b)) THEN
      CALL GET_HASH_BLOCK(d_b,dbl_mb(k_b),dimb,int_mb(k_b_offset),(p6b_2
     & - 1 + (noab+nvab) * (p1b_2 - 1 + (noab+nvab) * (h10b_2 - 1 + (noa
     &b+nvab) * (h8b_2 - 1)))))
      CALL TCE_SORT_4(dbl_mb(k_b),dbl_mb(k_b_sort),int_mb(k_range+h8b-1)
     &,int_mb(k_range+h10b-1),int_mb(k_range+p1b-1),int_mb(k_range+p6b-1
     &),3,2,1,4,1.0d0)
      END IF
      IF ((h10b .lt. h8b) .and. (p6b .lt. p1b)) THEN
      CALL GET_HASH_BLOCK(d_b,dbl_mb(k_b),dimb,int_mb(k_b_offset),(p1b_2
     & - 1 + (noab+nvab) * (p6b_2 - 1 + (noab+nvab) * (h8b_2 - 1 + (noab
     &+nvab) * (h10b_2 - 1)))))
      CALL TCE_SORT_4(dbl_mb(k_b),dbl_mb(k_b_sort),int_mb(k_range+h10b-1
     &),int_mb(k_range+h8b-1),int_mb(k_range+p6b-1),int_mb(k_range+p1b-1
     &),4,1,2,3,1.0d0)
      END IF
      IF ((h10b .lt. h8b) .and. (p1b .le. p6b)) THEN
      CALL GET_HASH_BLOCK(d_b,dbl_mb(k_b),dimb,int_mb(k_b_offset),(p6b_2
     & - 1 + (noab+nvab) * (p1b_2 - 1 + (noab+nvab) * (h8b_2 - 1 + (noab
     &+nvab) * (h10b_2 - 1)))))
      CALL TCE_SORT_4(dbl_mb(k_b),dbl_mb(k_b_sort),int_mb(k_range+h10b-1
     &),int_mb(k_range+h8b-1),int_mb(k_range+p1b-1),int_mb(k_range+p6b-1
     &),3,1,2,4,-1.0d0)
      END IF
      IF (.not.MA_POP_STACK(l_b)) CALL ERRQUIT('eomccsdt_y2_11_7_1',6,MA
     &_ERR)
      CALL dgemm('T','N',dima_sort,dimb_sort,dim_common,1.0d0,dbl_mb(k_a
     &_sort),dim_common,dbl_mb(k_b_sort),dim_common,1.0d0,dbl_mb(k_c_sor
     &t),dima_sort)
      IF (.not.MA_POP_STACK(l_b_sort)) CALL ERRQUIT('eomccsdt_y2_11_7_1'
     &,7,MA_ERR)
      IF (.not.MA_POP_STACK(l_a_sort)) CALL ERRQUIT('eomccsdt_y2_11_7_1'
     &,8,MA_ERR)
      END IF
      END IF
      END IF
      END DO
      END DO
      IF (.not.MA_PUSH_GET(mt_dbl,dimc,'noname',l_c,k_c)) CALL ERRQUIT('
     &eomccsdt_y2_11_7_1',9,MA_ERR)
      CALL TCE_SORT_4(dbl_mb(k_c_sort),dbl_mb(k_c),int_mb(k_range+p1b-1)
     &,int_mb(k_range+h10b-1),int_mb(k_range+h12b-1),int_mb(k_range+p13b
     &-1),2,4,1,3,1.0d0)
      CALL ADD_HASH_BLOCK(d_c,dbl_mb(k_c),dimc,int_mb(k_c_offset),(h12b 
     &- 1 + noab * (p1b - noab - 1 + nvab * (p13b - noab - 1 + nvab * (h
     &10b - 1)))))
      IF (.not.MA_POP_STACK(l_c)) CALL ERRQUIT('eomccsdt_y2_11_7_1',10,M
     &A_ERR)
      IF (.not.MA_POP_STACK(l_c_sort)) CALL ERRQUIT('eomccsdt_y2_11_7_1'
     &,11,MA_ERR)
      END IF
      END IF
      END IF
      next = NXTASK(nprocs,1)
      END IF
      count = count + 1
      END DO
      END DO
      END DO
      END DO
      next = NXTASK(-nprocs,1)
      call GA_SYNC()
      RETURN
      END
      SUBROUTINE eomccsdt_y2_11_7(d_a,k_a_offset,d_b,k_b_offset,d_c,k_c_
     &offset)
C     $Id: eomccsdt_y2_all12.F 24184 2013-05-04 00:43:17Z edo $
C     This is a Fortran77 program generated by Tensor Contraction Engine v.1.0
C     Copyright (c) Battelle & Pacific Northwest National Laboratory (2002)
C     i1 ( p11 p13 h12 p1 )_vtt + = 2 * Sum ( h10 ) * t ( p11 h10 )_t * i2 ( h10 p13 h12 p1 )_vt
      IMPLICIT NONE
#include "global.fh"
#include "mafdecls.fh"
#include "sym.fh"
#include "errquit.fh"
#include "tce.fh"
      INTEGER d_a
      INTEGER k_a_offset
      INTEGER d_b
      INTEGER k_b_offset
      INTEGER d_c
      INTEGER k_c_offset
      INTEGER NXTASK
      INTEGER next
      INTEGER nprocs
      INTEGER count
      INTEGER p11b
      INTEGER p13b
      INTEGER p1b
      INTEGER h12b
      INTEGER dimc
      INTEGER l_c_sort
      INTEGER k_c_sort
      INTEGER h10b
      INTEGER p11b_1
      INTEGER h10b_1
      INTEGER p13b_2
      INTEGER h10b_2
      INTEGER p1b_2
      INTEGER h12b_2
      INTEGER dim_common
      INTEGER dima_sort
      INTEGER dima
      INTEGER dimb_sort
      INTEGER dimb
      INTEGER l_a_sort
      INTEGER k_a_sort
      INTEGER l_a
      INTEGER k_a
      INTEGER l_b_sort
      INTEGER k_b_sort
      INTEGER l_b
      INTEGER k_b
      INTEGER l_c
      INTEGER k_c
      EXTERNAL NXTASK
      nprocs = GA_NNODES()
      count = 0
      next = NXTASK(nprocs,1)
      DO p11b = noab+1,noab+nvab
      DO p13b = noab+1,noab+nvab
      DO p1b = noab+1,noab+nvab
      DO h12b = 1,noab
      IF (next.eq.count) THEN
      IF ((.not.restricted).or.(int_mb(k_spin+p11b-1)+int_mb(k_spin+p13b
     &-1)+int_mb(k_spin+p1b-1)+int_mb(k_spin+h12b-1).ne.8)) THEN
      IF (int_mb(k_spin+p11b-1)+int_mb(k_spin+p13b-1) .eq. int_mb(k_spin
     &+p1b-1)+int_mb(k_spin+h12b-1)) THEN
      IF (ieor(int_mb(k_sym+p11b-1),ieor(int_mb(k_sym+p13b-1),ieor(int_m
     &b(k_sym+p1b-1),int_mb(k_sym+h12b-1)))) .eq. ieor(irrep_v,ieor(irre
     &p_t,irrep_t))) THEN
      dimc = int_mb(k_range+p11b-1) * int_mb(k_range+p13b-1) * int_mb(k_
     &range+p1b-1) * int_mb(k_range+h12b-1)
      IF (.not.MA_PUSH_GET(mt_dbl,dimc,'noname',l_c_sort,k_c_sort)) CALL
     & ERRQUIT('eomccsdt_y2_11_7',0,MA_ERR)
      CALL DFILL(dimc,0.0d0,dbl_mb(k_c_sort),1)
      DO h10b = 1,noab
      IF (int_mb(k_spin+p11b-1) .eq. int_mb(k_spin+h10b-1)) THEN
      IF (ieor(int_mb(k_sym+p11b-1),int_mb(k_sym+h10b-1)) .eq. irrep_t) 
     &THEN
      CALL TCE_RESTRICTED_2(p11b,h10b,p11b_1,h10b_1)
      CALL TCE_RESTRICTED_4(p13b,h10b,p1b,h12b,p13b_2,h10b_2,p1b_2,h12b_
     &2)
      dim_common = int_mb(k_range+h10b-1)
      dima_sort = int_mb(k_range+p11b-1)
      dima = dim_common * dima_sort
      dimb_sort = int_mb(k_range+p13b-1) * int_mb(k_range+p1b-1) * int_m
     &b(k_range+h12b-1)
      dimb = dim_common * dimb_sort
      IF ((dima .gt. 0) .and. (dimb .gt. 0)) THEN
      IF (.not.MA_PUSH_GET(mt_dbl,dima,'noname',l_a_sort,k_a_sort)) CALL
     & ERRQUIT('eomccsdt_y2_11_7',1,MA_ERR)
      IF (.not.MA_PUSH_GET(mt_dbl,dima,'noname',l_a,k_a)) CALL ERRQUIT('
     &eomccsdt_y2_11_7',2,MA_ERR)
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(h10b_
     &1 - 1 + noab * (p11b_1 - noab - 1)))
      CALL TCE_SORT_2(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+p11b-1
     &),int_mb(k_range+h10b-1),1,2,1.0d0)
      IF (.not.MA_POP_STACK(l_a)) CALL ERRQUIT('eomccsdt_y2_11_7',3,MA_E
     &RR)
      IF (.not.MA_PUSH_GET(mt_dbl,dimb,'noname',l_b_sort,k_b_sort)) CALL
     & ERRQUIT('eomccsdt_y2_11_7',4,MA_ERR)
      IF (.not.MA_PUSH_GET(mt_dbl,dimb,'noname',l_b,k_b)) CALL ERRQUIT('
     &eomccsdt_y2_11_7',5,MA_ERR)
      IF ((h10b .le. p13b)) THEN
      CALL GET_HASH_BLOCK(d_b,dbl_mb(k_b),dimb,int_mb(k_b_offset),(h12b_
     &2 - 1 + noab * (p1b_2 - noab - 1 + nvab * (p13b_2 - noab - 1 + nva
     &b * (h10b_2 - 1)))))
      CALL TCE_SORT_4(dbl_mb(k_b),dbl_mb(k_b_sort),int_mb(k_range+h10b-1
     &),int_mb(k_range+p13b-1),int_mb(k_range+p1b-1),int_mb(k_range+h12b
     &-1),4,3,2,1,1.0d0)
      END IF
      IF (.not.MA_POP_STACK(l_b)) CALL ERRQUIT('eomccsdt_y2_11_7',6,MA_E
     &RR)
      CALL dgemm('T','N',dima_sort,dimb_sort,dim_common,1.0d0,dbl_mb(k_a
     &_sort),dim_common,dbl_mb(k_b_sort),dim_common,1.0d0,dbl_mb(k_c_sor
     &t),dima_sort)
      IF (.not.MA_POP_STACK(l_b_sort)) CALL ERRQUIT('eomccsdt_y2_11_7',7
     &,MA_ERR)
      IF (.not.MA_POP_STACK(l_a_sort)) CALL ERRQUIT('eomccsdt_y2_11_7',8
     &,MA_ERR)
      END IF
      END IF
      END IF
      END DO
      IF (.not.MA_PUSH_GET(mt_dbl,dimc,'noname',l_c,k_c)) CALL ERRQUIT('
     &eomccsdt_y2_11_7',9,MA_ERR)
      IF ((p11b .le. p13b)) THEN
      CALL TCE_SORT_4(dbl_mb(k_c_sort),dbl_mb(k_c),int_mb(k_range+h12b-1
     &),int_mb(k_range+p1b-1),int_mb(k_range+p13b-1),int_mb(k_range+p11b
     &-1),4,3,2,1,1.0d0)
      CALL ADD_HASH_BLOCK(d_c,dbl_mb(k_c),dimc,int_mb(k_c_offset),(h12b 
     &- 1 + noab * (p1b - noab - 1 + nvab * (p13b - noab - 1 + nvab * (p
     &11b - noab - 1)))))
      END IF
      IF ((p13b .le. p11b)) THEN
      CALL TCE_SORT_4(dbl_mb(k_c_sort),dbl_mb(k_c),int_mb(k_range+h12b-1
     &),int_mb(k_range+p1b-1),int_mb(k_range+p13b-1),int_mb(k_range+p11b
     &-1),3,4,2,1,-1.0d0)
      CALL ADD_HASH_BLOCK(d_c,dbl_mb(k_c),dimc,int_mb(k_c_offset),(h12b 
     &- 1 + noab * (p1b - noab - 1 + nvab * (p11b - noab - 1 + nvab * (p
     &13b - noab - 1)))))
      END IF
      IF (.not.MA_POP_STACK(l_c)) CALL ERRQUIT('eomccsdt_y2_11_7',10,MA_
     &ERR)
      IF (.not.MA_POP_STACK(l_c_sort)) CALL ERRQUIT('eomccsdt_y2_11_7',1
     &1,MA_ERR)
      END IF
      END IF
      END IF
      next = NXTASK(nprocs,1)
      END IF
      count = count + 1
      END DO
      END DO
      END DO
      END DO
      next = NXTASK(-nprocs,1)
      call GA_SYNC()
      RETURN
      END
      SUBROUTINE eomccsdt_y2_11(d_a,k_a_offset,d_b,k_b_offset,d_c,k_c_of
     &fset)
C     $Id: eomccsdt_y2_all12.F 24184 2013-05-04 00:43:17Z edo $
C     This is a Fortran77 program generated by Tensor Contraction Engine v.1.0
C     Copyright (c) Battelle & Pacific Northwest National Laboratory (2002)
C     i0 ( h3 h4 p1 p2 )_yv + = 1/2 * P( 2 ) * Sum ( h12 p11 p13 ) * y ( h3 h4 h12 p1 p11 p13 )_y * i1 ( p11 p13 h12 p2 )_v
      IMPLICIT NONE
#include "global.fh"
#include "mafdecls.fh"
#include "sym.fh"
#include "errquit.fh"
#include "tce.fh"
      INTEGER d_a
      INTEGER k_a_offset
      INTEGER d_b
      INTEGER k_b_offset
      INTEGER d_c
      INTEGER k_c_offset
      INTEGER NXTASK
      INTEGER next
      INTEGER nprocs
      INTEGER count
      INTEGER h3b
      INTEGER h4b
      INTEGER p1b
      INTEGER p2b
      INTEGER dimc
      INTEGER l_c_sort
      INTEGER k_c_sort
      INTEGER h12b
      INTEGER p11b
      INTEGER p13b
      INTEGER h3b_1
      INTEGER h4b_1
      INTEGER h12b_1
      INTEGER p1b_1
      INTEGER p11b_1
      INTEGER p13b_1
      INTEGER p11b_2
      INTEGER p13b_2
      INTEGER p2b_2
      INTEGER h12b_2
      INTEGER dim_common
      INTEGER dima_sort
      INTEGER dima
      INTEGER dimb_sort
      INTEGER dimb
      INTEGER l_a_sort
      INTEGER k_a_sort
      INTEGER l_a
      INTEGER k_a
      INTEGER l_b_sort
      INTEGER k_b_sort
      INTEGER l_b
      INTEGER k_b
      INTEGER nsubp(2)
      INTEGER isubp
      INTEGER l_c
      INTEGER k_c
      DOUBLE PRECISION FACTORIAL
      EXTERNAL NXTASK
      EXTERNAL FACTORIAL
      nprocs = GA_NNODES()
      count = 0
      next = NXTASK(nprocs,1)
      DO h3b = 1,noab
      DO h4b = h3b,noab
      DO p1b = noab+1,noab+nvab
      DO p2b = noab+1,noab+nvab
      IF (next.eq.count) THEN
      IF ((.not.restricted).or.(int_mb(k_spin+h3b-1)+int_mb(k_spin+h4b-1
     &)+int_mb(k_spin+p1b-1)+int_mb(k_spin+p2b-1).ne.8)) THEN
      IF (int_mb(k_spin+h3b-1)+int_mb(k_spin+h4b-1) .eq. int_mb(k_spin+p
     &1b-1)+int_mb(k_spin+p2b-1)) THEN
      IF (ieor(int_mb(k_sym+h3b-1),ieor(int_mb(k_sym+h4b-1),ieor(int_mb(
     &k_sym+p1b-1),int_mb(k_sym+p2b-1)))) .eq. ieor(irrep_y,irrep_v)) TH
     &EN
      dimc = int_mb(k_range+h3b-1) * int_mb(k_range+h4b-1) * int_mb(k_ra
     &nge+p1b-1) * int_mb(k_range+p2b-1)
      IF (.not.MA_PUSH_GET(mt_dbl,dimc,'noname',l_c_sort,k_c_sort)) CALL
     & ERRQUIT('eomccsdt_y2_11',0,MA_ERR)
      CALL DFILL(dimc,0.0d0,dbl_mb(k_c_sort),1)
      DO h12b = 1,noab
      DO p11b = noab+1,noab+nvab
      DO p13b = p11b,noab+nvab
      IF (int_mb(k_spin+h3b-1)+int_mb(k_spin+h4b-1)+int_mb(k_spin+h12b-1
     &) .eq. int_mb(k_spin+p1b-1)+int_mb(k_spin+p11b-1)+int_mb(k_spin+p1
     &3b-1)) THEN
      IF (ieor(int_mb(k_sym+h3b-1),ieor(int_mb(k_sym+h4b-1),ieor(int_mb(
     &k_sym+h12b-1),ieor(int_mb(k_sym+p1b-1),ieor(int_mb(k_sym+p11b-1),i
     &nt_mb(k_sym+p13b-1)))))) .eq. irrep_y) THEN
      CALL TCE_RESTRICTED_6(h3b,h4b,h12b,p1b,p11b,p13b,h3b_1,h4b_1,h12b_
     &1,p1b_1,p11b_1,p13b_1)
      CALL TCE_RESTRICTED_4(p11b,p13b,p2b,h12b,p11b_2,p13b_2,p2b_2,h12b_
     &2)
      dim_common = int_mb(k_range+h12b-1) * int_mb(k_range+p11b-1) * int
     &_mb(k_range+p13b-1)
      dima_sort = int_mb(k_range+h3b-1) * int_mb(k_range+h4b-1) * int_mb
     &(k_range+p1b-1)
      dima = dim_common * dima_sort
      dimb_sort = int_mb(k_range+p2b-1)
      dimb = dim_common * dimb_sort
      IF ((dima .gt. 0) .and. (dimb .gt. 0)) THEN
      IF (.not.MA_PUSH_GET(mt_dbl,dima,'noname',l_a_sort,k_a_sort)) CALL
     & ERRQUIT('eomccsdt_y2_11',1,MA_ERR)
      IF (.not.MA_PUSH_GET(mt_dbl,dima,'noname',l_a,k_a)) CALL ERRQUIT('
     &eomccsdt_y2_11',2,MA_ERR)
      IF ((h12b .lt. h3b) .and. (p13b .lt. p1b)) THEN
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(p1b_1
     & - noab - 1 + nvab * (p13b_1 - noab - 1 + nvab * (p11b_1 - noab - 
     &1 + nvab * (h4b_1 - 1 + noab * (h3b_1 - 1 + noab * (h12b_1 - 1))))
     &)))
      CALL TCE_SORT_6(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+h12b-1
     &),int_mb(k_range+h3b-1),int_mb(k_range+h4b-1),int_mb(k_range+p11b-
     &1),int_mb(k_range+p13b-1),int_mb(k_range+p1b-1),6,3,2,5,4,1,1.0d0)
      END IF
      IF ((h12b .lt. h3b) .and. (p11b .lt. p1b) .and. (p1b .le. p13b)) T
     &HEN
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(p13b_
     &1 - noab - 1 + nvab * (p1b_1 - noab - 1 + nvab * (p11b_1 - noab - 
     &1 + nvab * (h4b_1 - 1 + noab * (h3b_1 - 1 + noab * (h12b_1 - 1))))
     &)))
      CALL TCE_SORT_6(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+h12b-1
     &),int_mb(k_range+h3b-1),int_mb(k_range+h4b-1),int_mb(k_range+p11b-
     &1),int_mb(k_range+p1b-1),int_mb(k_range+p13b-1),5,3,2,6,4,1,-1.0d0
     &)
      END IF
      IF ((h12b .lt. h3b) .and. (p1b .le. p11b)) THEN
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(p13b_
     &1 - noab - 1 + nvab * (p11b_1 - noab - 1 + nvab * (p1b_1 - noab - 
     &1 + nvab * (h4b_1 - 1 + noab * (h3b_1 - 1 + noab * (h12b_1 - 1))))
     &)))
      CALL TCE_SORT_6(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+h12b-1
     &),int_mb(k_range+h3b-1),int_mb(k_range+h4b-1),int_mb(k_range+p1b-1
     &),int_mb(k_range+p11b-1),int_mb(k_range+p13b-1),4,3,2,6,5,1,1.0d0)
      END IF
      IF ((h3b .le. h12b) .and. (h12b .lt. h4b) .and. (p13b .lt. p1b)) T
     &HEN
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(p1b_1
     & - noab - 1 + nvab * (p13b_1 - noab - 1 + nvab * (p11b_1 - noab - 
     &1 + nvab * (h4b_1 - 1 + noab * (h12b_1 - 1 + noab * (h3b_1 - 1))))
     &)))
      CALL TCE_SORT_6(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+h3b-1)
     &,int_mb(k_range+h12b-1),int_mb(k_range+h4b-1),int_mb(k_range+p11b-
     &1),int_mb(k_range+p13b-1),int_mb(k_range+p1b-1),6,3,1,5,4,2,-1.0d0
     &)
      END IF
      IF ((h3b .le. h12b) .and. (h12b .lt. h4b) .and. (p11b .lt. p1b) .a
     &nd. (p1b .le. p13b)) THEN
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(p13b_
     &1 - noab - 1 + nvab * (p1b_1 - noab - 1 + nvab * (p11b_1 - noab - 
     &1 + nvab * (h4b_1 - 1 + noab * (h12b_1 - 1 + noab * (h3b_1 - 1))))
     &)))
      CALL TCE_SORT_6(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+h3b-1)
     &,int_mb(k_range+h12b-1),int_mb(k_range+h4b-1),int_mb(k_range+p11b-
     &1),int_mb(k_range+p1b-1),int_mb(k_range+p13b-1),5,3,1,6,4,2,1.0d0)
      END IF
      IF ((h3b .le. h12b) .and. (h12b .lt. h4b) .and. (p1b .le. p11b)) T
     &HEN
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(p13b_
     &1 - noab - 1 + nvab * (p11b_1 - noab - 1 + nvab * (p1b_1 - noab - 
     &1 + nvab * (h4b_1 - 1 + noab * (h12b_1 - 1 + noab * (h3b_1 - 1))))
     &)))
      CALL TCE_SORT_6(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+h3b-1)
     &,int_mb(k_range+h12b-1),int_mb(k_range+h4b-1),int_mb(k_range+p1b-1
     &),int_mb(k_range+p11b-1),int_mb(k_range+p13b-1),4,3,1,6,5,2,-1.0d0
     &)
      END IF
      IF ((h4b .le. h12b) .and. (p13b .lt. p1b)) THEN
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(p1b_1
     & - noab - 1 + nvab * (p13b_1 - noab - 1 + nvab * (p11b_1 - noab - 
     &1 + nvab * (h12b_1 - 1 + noab * (h4b_1 - 1 + noab * (h3b_1 - 1))))
     &)))
      CALL TCE_SORT_6(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+h3b-1)
     &,int_mb(k_range+h4b-1),int_mb(k_range+h12b-1),int_mb(k_range+p11b-
     &1),int_mb(k_range+p13b-1),int_mb(k_range+p1b-1),6,2,1,5,4,3,1.0d0)
      END IF
      IF ((h4b .le. h12b) .and. (p11b .lt. p1b) .and. (p1b .le. p13b)) T
     &HEN
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(p13b_
     &1 - noab - 1 + nvab * (p1b_1 - noab - 1 + nvab * (p11b_1 - noab - 
     &1 + nvab * (h12b_1 - 1 + noab * (h4b_1 - 1 + noab * (h3b_1 - 1))))
     &)))
      CALL TCE_SORT_6(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+h3b-1)
     &,int_mb(k_range+h4b-1),int_mb(k_range+h12b-1),int_mb(k_range+p11b-
     &1),int_mb(k_range+p1b-1),int_mb(k_range+p13b-1),5,2,1,6,4,3,-1.0d0
     &)
      END IF
      IF ((h4b .le. h12b) .and. (p1b .le. p11b)) THEN
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(p13b_
     &1 - noab - 1 + nvab * (p11b_1 - noab - 1 + nvab * (p1b_1 - noab - 
     &1 + nvab * (h12b_1 - 1 + noab * (h4b_1 - 1 + noab * (h3b_1 - 1))))
     &)))
      CALL TCE_SORT_6(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+h3b-1)
     &,int_mb(k_range+h4b-1),int_mb(k_range+h12b-1),int_mb(k_range+p1b-1
     &),int_mb(k_range+p11b-1),int_mb(k_range+p13b-1),4,2,1,6,5,3,1.0d0)
      END IF
      IF (.not.MA_POP_STACK(l_a)) CALL ERRQUIT('eomccsdt_y2_11',3,MA_ERR
     &)
      IF (.not.MA_PUSH_GET(mt_dbl,dimb,'noname',l_b_sort,k_b_sort)) CALL
     & ERRQUIT('eomccsdt_y2_11',4,MA_ERR)
      IF (.not.MA_PUSH_GET(mt_dbl,dimb,'noname',l_b,k_b)) CALL ERRQUIT('
     &eomccsdt_y2_11',5,MA_ERR)
      CALL GET_HASH_BLOCK(d_b,dbl_mb(k_b),dimb,int_mb(k_b_offset),(h12b_
     &2 - 1 + noab * (p2b_2 - noab - 1 + nvab * (p13b_2 - noab - 1 + nva
     &b * (p11b_2 - noab - 1)))))
      CALL TCE_SORT_4(dbl_mb(k_b),dbl_mb(k_b_sort),int_mb(k_range+p11b-1
     &),int_mb(k_range+p13b-1),int_mb(k_range+p2b-1),int_mb(k_range+h12b
     &-1),3,2,1,4,1.0d0)
      IF (.not.MA_POP_STACK(l_b)) CALL ERRQUIT('eomccsdt_y2_11',6,MA_ERR
     &)
      nsubp(1) = 1
      nsubp(2) = 1
      isubp = 1
      IF (p11b .eq. p13b) THEN
      nsubp(isubp) = nsubp(isubp) + 1
      ELSE
      isubp = isubp + 1
      END IF
      CALL dgemm('T','N',dima_sort,dimb_sort,dim_common,2.0d0/FACTORIAL(
     &nsubp(1))/FACTORIAL(nsubp(2)),dbl_mb(k_a_sort),dim_common,dbl_mb(k
     &_b_sort),dim_common,1.0d0,dbl_mb(k_c_sort),dima_sort)
      IF (.not.MA_POP_STACK(l_b_sort)) CALL ERRQUIT('eomccsdt_y2_11',7,M
     &A_ERR)
      IF (.not.MA_POP_STACK(l_a_sort)) CALL ERRQUIT('eomccsdt_y2_11',8,M
     &A_ERR)
      END IF
      END IF
      END IF
      END DO
      END DO
      END DO
      IF (.not.MA_PUSH_GET(mt_dbl,dimc,'noname',l_c,k_c)) CALL ERRQUIT('
     &eomccsdt_y2_11',9,MA_ERR)
      IF ((p1b .le. p2b)) THEN
      CALL TCE_SORT_4(dbl_mb(k_c_sort),dbl_mb(k_c),int_mb(k_range+p2b-1)
     &,int_mb(k_range+p1b-1),int_mb(k_range+h4b-1),int_mb(k_range+h3b-1)
     &,4,3,2,1,1.0d0/2.0d0)
      CALL ADD_HASH_BLOCK(d_c,dbl_mb(k_c),dimc,int_mb(k_c_offset),(p2b -
     & noab - 1 + nvab * (p1b - noab - 1 + nvab * (h4b - 1 + noab * (h3b
     & - 1)))))
      END IF
      IF ((p2b .le. p1b)) THEN
      CALL TCE_SORT_4(dbl_mb(k_c_sort),dbl_mb(k_c),int_mb(k_range+p2b-1)
     &,int_mb(k_range+p1b-1),int_mb(k_range+h4b-1),int_mb(k_range+h3b-1)
     &,4,3,1,2,-1.0d0/2.0d0)
      CALL ADD_HASH_BLOCK(d_c,dbl_mb(k_c),dimc,int_mb(k_c_offset),(p1b -
     & noab - 1 + nvab * (p2b - noab - 1 + nvab * (h4b - 1 + noab * (h3b
     & - 1)))))
      END IF
      IF (.not.MA_POP_STACK(l_c)) CALL ERRQUIT('eomccsdt_y2_11',10,MA_ER
     &R)
      IF (.not.MA_POP_STACK(l_c_sort)) CALL ERRQUIT('eomccsdt_y2_11',11,
     &MA_ERR)
      END IF
      END IF
      END IF
      next = NXTASK(nprocs,1)
      END IF
      count = count + 1
      END DO
      END DO
      END DO
      END DO
      next = NXTASK(-nprocs,1)
      call GA_SYNC()
      RETURN
      END
      SUBROUTINE eomccsdt_y2_12_1(d_a,k_a_offset,d_b,k_b_offset,d_c,k_c_
     &offset)
C     $Id: eomccsdt_y2_all12.F 24184 2013-05-04 00:43:17Z edo $
C     This is a Fortran77 program generated by Tensor Contraction Engine v.1.0
C     Copyright (c) Battelle & Pacific Northwest National Laboratory (2002)
C     i1 ( h3 h11 )_yt + = 1 * Sum ( p5 ) * t ( p5 h11 )_t * y ( h3 p5 )_y
      IMPLICIT NONE
#include "global.fh"
#include "mafdecls.fh"
#include "sym.fh"
#include "errquit.fh"
#include "tce.fh"
      INTEGER d_a
      INTEGER k_a_offset
      INTEGER d_b
      INTEGER k_b_offset
      INTEGER d_c
      INTEGER k_c_offset
      INTEGER NXTASK
      INTEGER next
      INTEGER nprocs
      INTEGER count
      INTEGER h3b
      INTEGER h11b
      INTEGER dimc
      INTEGER l_c_sort
      INTEGER k_c_sort
      INTEGER p5b
      INTEGER p5b_1
      INTEGER h11b_1
      INTEGER h3b_2
      INTEGER p5b_2
      INTEGER dim_common
      INTEGER dima_sort
      INTEGER dima
      INTEGER dimb_sort
      INTEGER dimb
      INTEGER l_a_sort
      INTEGER k_a_sort
      INTEGER l_a
      INTEGER k_a
      INTEGER l_b_sort
      INTEGER k_b_sort
      INTEGER l_b
      INTEGER k_b
      INTEGER l_c
      INTEGER k_c
      EXTERNAL NXTASK
      nprocs = GA_NNODES()
      count = 0
      next = NXTASK(nprocs,1)
      DO h3b = 1,noab
      DO h11b = 1,noab
      IF (next.eq.count) THEN
      IF ((.not.restricted).or.(int_mb(k_spin+h3b-1)+int_mb(k_spin+h11b-
     &1).ne.4)) THEN
      IF (int_mb(k_spin+h3b-1) .eq. int_mb(k_spin+h11b-1)) THEN
      IF (ieor(int_mb(k_sym+h3b-1),int_mb(k_sym+h11b-1)) .eq. ieor(irrep
     &_y,irrep_t)) THEN
      dimc = int_mb(k_range+h3b-1) * int_mb(k_range+h11b-1)
      IF (.not.MA_PUSH_GET(mt_dbl,dimc,'noname',l_c_sort,k_c_sort)) CALL
     & ERRQUIT('eomccsdt_y2_12_1',0,MA_ERR)
      CALL DFILL(dimc,0.0d0,dbl_mb(k_c_sort),1)
      DO p5b = noab+1,noab+nvab
      IF (int_mb(k_spin+p5b-1) .eq. int_mb(k_spin+h11b-1)) THEN
      IF (ieor(int_mb(k_sym+p5b-1),int_mb(k_sym+h11b-1)) .eq. irrep_t) T
     &HEN
      CALL TCE_RESTRICTED_2(p5b,h11b,p5b_1,h11b_1)
      CALL TCE_RESTRICTED_2(h3b,p5b,h3b_2,p5b_2)
      dim_common = int_mb(k_range+p5b-1)
      dima_sort = int_mb(k_range+h11b-1)
      dima = dim_common * dima_sort
      dimb_sort = int_mb(k_range+h3b-1)
      dimb = dim_common * dimb_sort
      IF ((dima .gt. 0) .and. (dimb .gt. 0)) THEN
      IF (.not.MA_PUSH_GET(mt_dbl,dima,'noname',l_a_sort,k_a_sort)) CALL
     & ERRQUIT('eomccsdt_y2_12_1',1,MA_ERR)
      IF (.not.MA_PUSH_GET(mt_dbl,dima,'noname',l_a,k_a)) CALL ERRQUIT('
     &eomccsdt_y2_12_1',2,MA_ERR)
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(h11b_
     &1 - 1 + noab * (p5b_1 - noab - 1)))
      CALL TCE_SORT_2(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+p5b-1)
     &,int_mb(k_range+h11b-1),2,1,1.0d0)
      IF (.not.MA_POP_STACK(l_a)) CALL ERRQUIT('eomccsdt_y2_12_1',3,MA_E
     &RR)
      IF (.not.MA_PUSH_GET(mt_dbl,dimb,'noname',l_b_sort,k_b_sort)) CALL
     & ERRQUIT('eomccsdt_y2_12_1',4,MA_ERR)
      IF (.not.MA_PUSH_GET(mt_dbl,dimb,'noname',l_b,k_b)) CALL ERRQUIT('
     &eomccsdt_y2_12_1',5,MA_ERR)
      CALL GET_HASH_BLOCK(d_b,dbl_mb(k_b),dimb,int_mb(k_b_offset),(p5b_2
     & - noab - 1 + nvab * (h3b_2 - 1)))
      CALL TCE_SORT_2(dbl_mb(k_b),dbl_mb(k_b_sort),int_mb(k_range+h3b-1)
     &,int_mb(k_range+p5b-1),1,2,1.0d0)
      IF (.not.MA_POP_STACK(l_b)) CALL ERRQUIT('eomccsdt_y2_12_1',6,MA_E
     &RR)
      CALL dgemm('T','N',dima_sort,dimb_sort,dim_common,1.0d0,dbl_mb(k_a
     &_sort),dim_common,dbl_mb(k_b_sort),dim_common,1.0d0,dbl_mb(k_c_sor
     &t),dima_sort)
      IF (.not.MA_POP_STACK(l_b_sort)) CALL ERRQUIT('eomccsdt_y2_12_1',7
     &,MA_ERR)
      IF (.not.MA_POP_STACK(l_a_sort)) CALL ERRQUIT('eomccsdt_y2_12_1',8
     &,MA_ERR)
      END IF
      END IF
      END IF
      END DO
      IF (.not.MA_PUSH_GET(mt_dbl,dimc,'noname',l_c,k_c)) CALL ERRQUIT('
     &eomccsdt_y2_12_1',9,MA_ERR)
      CALL TCE_SORT_2(dbl_mb(k_c_sort),dbl_mb(k_c),int_mb(k_range+h3b-1)
     &,int_mb(k_range+h11b-1),1,2,1.0d0)
      CALL ADD_HASH_BLOCK(d_c,dbl_mb(k_c),dimc,int_mb(k_c_offset),(h11b 
     &- 1 + noab * (h3b - 1)))
      IF (.not.MA_POP_STACK(l_c)) CALL ERRQUIT('eomccsdt_y2_12_1',10,MA_
     &ERR)
      IF (.not.MA_POP_STACK(l_c_sort)) CALL ERRQUIT('eomccsdt_y2_12_1',1
     &1,MA_ERR)
      END IF
      END IF
      END IF
      next = NXTASK(nprocs,1)
      END IF
      count = count + 1
      END DO
      END DO
      next = NXTASK(-nprocs,1)
      call GA_SYNC()
      RETURN
      END
      SUBROUTINE eomccsdt_y2_12_2(d_a,k_a_offset,d_b,k_b_offset,d_c,k_c_
     &offset)
C     $Id: eomccsdt_y2_all12.F 24184 2013-05-04 00:43:17Z edo $
C     This is a Fortran77 program generated by Tensor Contraction Engine v.1.0
C     Copyright (c) Battelle & Pacific Northwest National Laboratory (2002)
C     i1 ( h3 h11 )_yt + = -1/2 * Sum ( h7 p6 p5 ) * t ( p5 p6 h7 h11 )_t * y ( h3 h7 p5 p6 )_y
      IMPLICIT NONE
#include "global.fh"
#include "mafdecls.fh"
#include "sym.fh"
#include "errquit.fh"
#include "tce.fh"
      INTEGER d_a
      INTEGER k_a_offset
      INTEGER d_b
      INTEGER k_b_offset
      INTEGER d_c
      INTEGER k_c_offset
      INTEGER NXTASK
      INTEGER next
      INTEGER nprocs
      INTEGER count
      INTEGER h3b
      INTEGER h11b
      INTEGER dimc
      INTEGER l_c_sort
      INTEGER k_c_sort
      INTEGER p5b
      INTEGER p6b
      INTEGER h7b
      INTEGER p5b_1
      INTEGER p6b_1
      INTEGER h11b_1
      INTEGER h7b_1
      INTEGER h3b_2
      INTEGER h7b_2
      INTEGER p5b_2
      INTEGER p6b_2
      INTEGER dim_common
      INTEGER dima_sort
      INTEGER dima
      INTEGER dimb_sort
      INTEGER dimb
      INTEGER l_a_sort
      INTEGER k_a_sort
      INTEGER l_a
      INTEGER k_a
      INTEGER l_b_sort
      INTEGER k_b_sort
      INTEGER l_b
      INTEGER k_b
      INTEGER nsuperp(2)
      INTEGER isuperp
      INTEGER l_c
      INTEGER k_c
      DOUBLE PRECISION FACTORIAL
      EXTERNAL NXTASK
      EXTERNAL FACTORIAL
      nprocs = GA_NNODES()
      count = 0
      next = NXTASK(nprocs,1)
      DO h3b = 1,noab
      DO h11b = 1,noab
      IF (next.eq.count) THEN
      IF ((.not.restricted).or.(int_mb(k_spin+h3b-1)+int_mb(k_spin+h11b-
     &1).ne.4)) THEN
      IF (int_mb(k_spin+h3b-1) .eq. int_mb(k_spin+h11b-1)) THEN
      IF (ieor(int_mb(k_sym+h3b-1),int_mb(k_sym+h11b-1)) .eq. ieor(irrep
     &_y,irrep_t)) THEN
      dimc = int_mb(k_range+h3b-1) * int_mb(k_range+h11b-1)
      IF (.not.MA_PUSH_GET(mt_dbl,dimc,'noname',l_c_sort,k_c_sort)) CALL
     & ERRQUIT('eomccsdt_y2_12_2',0,MA_ERR)
      CALL DFILL(dimc,0.0d0,dbl_mb(k_c_sort),1)
      DO p5b = noab+1,noab+nvab
      DO p6b = p5b,noab+nvab
      DO h7b = 1,noab
      IF (int_mb(k_spin+p5b-1)+int_mb(k_spin+p6b-1) .eq. int_mb(k_spin+h
     &11b-1)+int_mb(k_spin+h7b-1)) THEN
      IF (ieor(int_mb(k_sym+p5b-1),ieor(int_mb(k_sym+p6b-1),ieor(int_mb(
     &k_sym+h11b-1),int_mb(k_sym+h7b-1)))) .eq. irrep_t) THEN
      CALL TCE_RESTRICTED_4(p5b,p6b,h11b,h7b,p5b_1,p6b_1,h11b_1,h7b_1)
      CALL TCE_RESTRICTED_4(h3b,h7b,p5b,p6b,h3b_2,h7b_2,p5b_2,p6b_2)
      dim_common = int_mb(k_range+p5b-1) * int_mb(k_range+p6b-1) * int_m
     &b(k_range+h7b-1)
      dima_sort = int_mb(k_range+h11b-1)
      dima = dim_common * dima_sort
      dimb_sort = int_mb(k_range+h3b-1)
      dimb = dim_common * dimb_sort
      IF ((dima .gt. 0) .and. (dimb .gt. 0)) THEN
      IF (.not.MA_PUSH_GET(mt_dbl,dima,'noname',l_a_sort,k_a_sort)) CALL
     & ERRQUIT('eomccsdt_y2_12_2',1,MA_ERR)
      IF (.not.MA_PUSH_GET(mt_dbl,dima,'noname',l_a,k_a)) CALL ERRQUIT('
     &eomccsdt_y2_12_2',2,MA_ERR)
      IF ((h7b .le. h11b)) THEN
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(h11b_
     &1 - 1 + noab * (h7b_1 - 1 + noab * (p6b_1 - noab - 1 + nvab * (p5b
     &_1 - noab - 1)))))
      CALL TCE_SORT_4(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+p5b-1)
     &,int_mb(k_range+p6b-1),int_mb(k_range+h7b-1),int_mb(k_range+h11b-1
     &),4,3,2,1,1.0d0)
      END IF
      IF ((h11b .lt. h7b)) THEN
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(h7b_1
     & - 1 + noab * (h11b_1 - 1 + noab * (p6b_1 - noab - 1 + nvab * (p5b
     &_1 - noab - 1)))))
      CALL TCE_SORT_4(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+p5b-1)
     &,int_mb(k_range+p6b-1),int_mb(k_range+h11b-1),int_mb(k_range+h7b-1
     &),3,4,2,1,-1.0d0)
      END IF
      IF (.not.MA_POP_STACK(l_a)) CALL ERRQUIT('eomccsdt_y2_12_2',3,MA_E
     &RR)
      IF (.not.MA_PUSH_GET(mt_dbl,dimb,'noname',l_b_sort,k_b_sort)) CALL
     & ERRQUIT('eomccsdt_y2_12_2',4,MA_ERR)
      IF (.not.MA_PUSH_GET(mt_dbl,dimb,'noname',l_b,k_b)) CALL ERRQUIT('
     &eomccsdt_y2_12_2',5,MA_ERR)
      IF ((h7b .lt. h3b)) THEN
      CALL GET_HASH_BLOCK(d_b,dbl_mb(k_b),dimb,int_mb(k_b_offset),(p6b_2
     & - noab - 1 + nvab * (p5b_2 - noab - 1 + nvab * (h3b_2 - 1 + noab 
     &* (h7b_2 - 1)))))
      CALL TCE_SORT_4(dbl_mb(k_b),dbl_mb(k_b_sort),int_mb(k_range+h7b-1)
     &,int_mb(k_range+h3b-1),int_mb(k_range+p5b-1),int_mb(k_range+p6b-1)
     &,2,1,4,3,-1.0d0)
      END IF
      IF ((h3b .le. h7b)) THEN
      CALL GET_HASH_BLOCK(d_b,dbl_mb(k_b),dimb,int_mb(k_b_offset),(p6b_2
     & - noab - 1 + nvab * (p5b_2 - noab - 1 + nvab * (h7b_2 - 1 + noab 
     &* (h3b_2 - 1)))))
      CALL TCE_SORT_4(dbl_mb(k_b),dbl_mb(k_b_sort),int_mb(k_range+h3b-1)
     &,int_mb(k_range+h7b-1),int_mb(k_range+p5b-1),int_mb(k_range+p6b-1)
     &,1,2,4,3,1.0d0)
      END IF
      IF (.not.MA_POP_STACK(l_b)) CALL ERRQUIT('eomccsdt_y2_12_2',6,MA_E
     &RR)
      nsuperp(1) = 1
      nsuperp(2) = 1
      isuperp = 1
      IF (p5b .eq. p6b) THEN
      nsuperp(isuperp) = nsuperp(isuperp) + 1
      ELSE
      isuperp = isuperp + 1
      END IF
      CALL dgemm('T','N',dima_sort,dimb_sort,dim_common,2.0d0/FACTORIAL(
     &nsuperp(1))/FACTORIAL(nsuperp(2)),dbl_mb(k_a_sort),dim_common,dbl_
     &mb(k_b_sort),dim_common,1.0d0,dbl_mb(k_c_sort),dima_sort)
      IF (.not.MA_POP_STACK(l_b_sort)) CALL ERRQUIT('eomccsdt_y2_12_2',7
     &,MA_ERR)
      IF (.not.MA_POP_STACK(l_a_sort)) CALL ERRQUIT('eomccsdt_y2_12_2',8
     &,MA_ERR)
      END IF
      END IF
      END IF
      END DO
      END DO
      END DO
      IF (.not.MA_PUSH_GET(mt_dbl,dimc,'noname',l_c,k_c)) CALL ERRQUIT('
     &eomccsdt_y2_12_2',9,MA_ERR)
      CALL TCE_SORT_2(dbl_mb(k_c_sort),dbl_mb(k_c),int_mb(k_range+h3b-1)
     &,int_mb(k_range+h11b-1),1,2,-1.0d0/2.0d0)
      CALL ADD_HASH_BLOCK(d_c,dbl_mb(k_c),dimc,int_mb(k_c_offset),(h11b 
     &- 1 + noab * (h3b - 1)))
      IF (.not.MA_POP_STACK(l_c)) CALL ERRQUIT('eomccsdt_y2_12_2',10,MA_
     &ERR)
      IF (.not.MA_POP_STACK(l_c_sort)) CALL ERRQUIT('eomccsdt_y2_12_2',1
     &1,MA_ERR)
      END IF
      END IF
      END IF
      next = NXTASK(nprocs,1)
      END IF
      count = count + 1
      END DO
      END DO
      next = NXTASK(-nprocs,1)
      call GA_SYNC()
      RETURN
      END
      SUBROUTINE eomccsdt_y2_12_3(d_a,k_a_offset,d_b,k_b_offset,d_c,k_c_
     &offset)
C     $Id: eomccsdt_y2_all12.F 24184 2013-05-04 00:43:17Z edo $
C     This is a Fortran77 program generated by Tensor Contraction Engine v.1.0
C     Copyright (c) Battelle & Pacific Northwest National Laboratory (2002)
C     i1 ( h3 h11 )_yt + = 1/12 * Sum ( h9 h8 p7 p6 p5 ) * t ( p5 p6 p7 h8 h9 h11 )_t * y ( h3 h8 h9 p5 p6 p7 )_y
      IMPLICIT NONE
#include "global.fh"
#include "mafdecls.fh"
#include "sym.fh"
#include "errquit.fh"
#include "tce.fh"
      INTEGER d_a
      INTEGER k_a_offset
      INTEGER d_b
      INTEGER k_b_offset
      INTEGER d_c
      INTEGER k_c_offset
      INTEGER NXTASK
      INTEGER next
      INTEGER nprocs
      INTEGER count
      INTEGER h3b
      INTEGER h11b
      INTEGER dimc
      INTEGER l_c_sort
      INTEGER k_c_sort
      INTEGER p5b
      INTEGER p6b
      INTEGER p7b
      INTEGER h8b
      INTEGER h9b
      INTEGER p5b_1
      INTEGER p6b_1
      INTEGER p7b_1
      INTEGER h11b_1
      INTEGER h8b_1
      INTEGER h9b_1
      INTEGER h3b_2
      INTEGER h8b_2
      INTEGER h9b_2
      INTEGER p5b_2
      INTEGER p6b_2
      INTEGER p7b_2
      INTEGER dim_common
      INTEGER dima_sort
      INTEGER dima
      INTEGER dimb_sort
      INTEGER dimb
      INTEGER l_a_sort
      INTEGER k_a_sort
      INTEGER l_a
      INTEGER k_a
      INTEGER l_b_sort
      INTEGER k_b_sort
      INTEGER l_b
      INTEGER k_b
      INTEGER nsuperp(3)
      INTEGER isuperp
      INTEGER nsubh(2)
      INTEGER isubh
      INTEGER l_c
      INTEGER k_c
      DOUBLE PRECISION FACTORIAL
      EXTERNAL NXTASK
      EXTERNAL FACTORIAL
      nprocs = GA_NNODES()
      count = 0
      next = NXTASK(nprocs,1)
      DO h3b = 1,noab
      DO h11b = 1,noab
      IF (next.eq.count) THEN
      IF ((.not.restricted).or.(int_mb(k_spin+h3b-1)+int_mb(k_spin+h11b-
     &1).ne.4)) THEN
      IF (int_mb(k_spin+h3b-1) .eq. int_mb(k_spin+h11b-1)) THEN
      IF (ieor(int_mb(k_sym+h3b-1),int_mb(k_sym+h11b-1)) .eq. ieor(irrep
     &_y,irrep_t)) THEN
      dimc = int_mb(k_range+h3b-1) * int_mb(k_range+h11b-1)
      IF (.not.MA_PUSH_GET(mt_dbl,dimc,'noname',l_c_sort,k_c_sort)) CALL
     & ERRQUIT('eomccsdt_y2_12_3',0,MA_ERR)
      CALL DFILL(dimc,0.0d0,dbl_mb(k_c_sort),1)
      DO p5b = noab+1,noab+nvab
      DO p6b = p5b,noab+nvab
      DO p7b = p6b,noab+nvab
      DO h8b = 1,noab
      DO h9b = h8b,noab
      IF (int_mb(k_spin+p5b-1)+int_mb(k_spin+p6b-1)+int_mb(k_spin+p7b-1)
     & .eq. int_mb(k_spin+h11b-1)+int_mb(k_spin+h8b-1)+int_mb(k_spin+h9b
     &-1)) THEN
      IF (ieor(int_mb(k_sym+p5b-1),ieor(int_mb(k_sym+p6b-1),ieor(int_mb(
     &k_sym+p7b-1),ieor(int_mb(k_sym+h11b-1),ieor(int_mb(k_sym+h8b-1),in
     &t_mb(k_sym+h9b-1)))))) .eq. irrep_t) THEN
      CALL TCE_RESTRICTED_6(p5b,p6b,p7b,h11b,h8b,h9b,p5b_1,p6b_1,p7b_1,h
     &11b_1,h8b_1,h9b_1)
      CALL TCE_RESTRICTED_6(h3b,h8b,h9b,p5b,p6b,p7b,h3b_2,h8b_2,h9b_2,p5
     &b_2,p6b_2,p7b_2)
      dim_common = int_mb(k_range+p5b-1) * int_mb(k_range+p6b-1) * int_m
     &b(k_range+p7b-1) * int_mb(k_range+h8b-1) * int_mb(k_range+h9b-1)
      dima_sort = int_mb(k_range+h11b-1)
      dima = dim_common * dima_sort
      dimb_sort = int_mb(k_range+h3b-1)
      dimb = dim_common * dimb_sort
      IF ((dima .gt. 0) .and. (dimb .gt. 0)) THEN
      IF (.not.MA_PUSH_GET(mt_dbl,dima,'noname',l_a_sort,k_a_sort)) CALL
     & ERRQUIT('eomccsdt_y2_12_3',1,MA_ERR)
      IF (.not.MA_PUSH_GET(mt_dbl,dima,'noname',l_a,k_a)) CALL ERRQUIT('
     &eomccsdt_y2_12_3',2,MA_ERR)
      IF ((h9b .le. h11b)) THEN
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(h11b_
     &1 - 1 + noab * (h9b_1 - 1 + noab * (h8b_1 - 1 + noab * (p7b_1 - no
     &ab - 1 + nvab * (p6b_1 - noab - 1 + nvab * (p5b_1 - noab - 1))))))
     &)
      CALL TCE_SORT_6(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+p5b-1)
     &,int_mb(k_range+p6b-1),int_mb(k_range+p7b-1),int_mb(k_range+h8b-1)
     &,int_mb(k_range+h9b-1),int_mb(k_range+h11b-1),6,5,4,3,2,1,1.0d0)
      END IF
      IF ((h8b .le. h11b) .and. (h11b .lt. h9b)) THEN
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(h9b_1
     & - 1 + noab * (h11b_1 - 1 + noab * (h8b_1 - 1 + noab * (p7b_1 - no
     &ab - 1 + nvab * (p6b_1 - noab - 1 + nvab * (p5b_1 - noab - 1))))))
     &)
      CALL TCE_SORT_6(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+p5b-1)
     &,int_mb(k_range+p6b-1),int_mb(k_range+p7b-1),int_mb(k_range+h8b-1)
     &,int_mb(k_range+h11b-1),int_mb(k_range+h9b-1),5,6,4,3,2,1,-1.0d0)
      END IF
      IF ((h11b .lt. h8b)) THEN
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(h9b_1
     & - 1 + noab * (h8b_1 - 1 + noab * (h11b_1 - 1 + noab * (p7b_1 - no
     &ab - 1 + nvab * (p6b_1 - noab - 1 + nvab * (p5b_1 - noab - 1))))))
     &)
      CALL TCE_SORT_6(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+p5b-1)
     &,int_mb(k_range+p6b-1),int_mb(k_range+p7b-1),int_mb(k_range+h11b-1
     &),int_mb(k_range+h8b-1),int_mb(k_range+h9b-1),4,6,5,3,2,1,1.0d0)
      END IF
      IF (.not.MA_POP_STACK(l_a)) CALL ERRQUIT('eomccsdt_y2_12_3',3,MA_E
     &RR)
      IF (.not.MA_PUSH_GET(mt_dbl,dimb,'noname',l_b_sort,k_b_sort)) CALL
     & ERRQUIT('eomccsdt_y2_12_3',4,MA_ERR)
      IF (.not.MA_PUSH_GET(mt_dbl,dimb,'noname',l_b,k_b)) CALL ERRQUIT('
     &eomccsdt_y2_12_3',5,MA_ERR)
      IF ((h9b .lt. h3b)) THEN
      CALL GET_HASH_BLOCK(d_b,dbl_mb(k_b),dimb,int_mb(k_b_offset),(p7b_2
     & - noab - 1 + nvab * (p6b_2 - noab - 1 + nvab * (p5b_2 - noab - 1 
     &+ nvab * (h3b_2 - 1 + noab * (h9b_2 - 1 + noab * (h8b_2 - 1)))))))
      CALL TCE_SORT_6(dbl_mb(k_b),dbl_mb(k_b_sort),int_mb(k_range+h8b-1)
     &,int_mb(k_range+h9b-1),int_mb(k_range+h3b-1),int_mb(k_range+p5b-1)
     &,int_mb(k_range+p6b-1),int_mb(k_range+p7b-1),3,2,1,6,5,4,1.0d0)
      END IF
      IF ((h8b .lt. h3b) .and. (h3b .le. h9b)) THEN
      CALL GET_HASH_BLOCK(d_b,dbl_mb(k_b),dimb,int_mb(k_b_offset),(p7b_2
     & - noab - 1 + nvab * (p6b_2 - noab - 1 + nvab * (p5b_2 - noab - 1 
     &+ nvab * (h9b_2 - 1 + noab * (h3b_2 - 1 + noab * (h8b_2 - 1)))))))
      CALL TCE_SORT_6(dbl_mb(k_b),dbl_mb(k_b_sort),int_mb(k_range+h8b-1)
     &,int_mb(k_range+h3b-1),int_mb(k_range+h9b-1),int_mb(k_range+p5b-1)
     &,int_mb(k_range+p6b-1),int_mb(k_range+p7b-1),2,3,1,6,5,4,-1.0d0)
      END IF
      IF ((h3b .le. h8b)) THEN
      CALL GET_HASH_BLOCK(d_b,dbl_mb(k_b),dimb,int_mb(k_b_offset),(p7b_2
     & - noab - 1 + nvab * (p6b_2 - noab - 1 + nvab * (p5b_2 - noab - 1 
     &+ nvab * (h9b_2 - 1 + noab * (h8b_2 - 1 + noab * (h3b_2 - 1)))))))
      CALL TCE_SORT_6(dbl_mb(k_b),dbl_mb(k_b_sort),int_mb(k_range+h3b-1)
     &,int_mb(k_range+h8b-1),int_mb(k_range+h9b-1),int_mb(k_range+p5b-1)
     &,int_mb(k_range+p6b-1),int_mb(k_range+p7b-1),1,3,2,6,5,4,1.0d0)
      END IF
      IF (.not.MA_POP_STACK(l_b)) CALL ERRQUIT('eomccsdt_y2_12_3',6,MA_E
     &RR)
      nsuperp(1) = 1
      nsuperp(2) = 1
      nsuperp(3) = 1
      isuperp = 1
      IF (p5b .eq. p6b) THEN
      nsuperp(isuperp) = nsuperp(isuperp) + 1
      ELSE
      isuperp = isuperp + 1
      END IF
      IF (p6b .eq. p7b) THEN
      nsuperp(isuperp) = nsuperp(isuperp) + 1
      ELSE
      isuperp = isuperp + 1
      END IF
      nsubh(1) = 1
      nsubh(2) = 1
      isubh = 1
      IF (h8b .eq. h9b) THEN
      nsubh(isubh) = nsubh(isubh) + 1
      ELSE
      isubh = isubh + 1
      END IF
      CALL dgemm('T','N',dima_sort,dimb_sort,dim_common,12.0d0/FACTORIAL
     &(nsuperp(1))/FACTORIAL(nsuperp(2))/FACTORIAL(nsuperp(3))/FACTORIAL
     &(nsubh(1))/FACTORIAL(nsubh(2)),dbl_mb(k_a_sort),dim_common,dbl_mb(
     &k_b_sort),dim_common,1.0d0,dbl_mb(k_c_sort),dima_sort)
      IF (.not.MA_POP_STACK(l_b_sort)) CALL ERRQUIT('eomccsdt_y2_12_3',7
     &,MA_ERR)
      IF (.not.MA_POP_STACK(l_a_sort)) CALL ERRQUIT('eomccsdt_y2_12_3',8
     &,MA_ERR)
      END IF
      END IF
      END IF
      END DO
      END DO
      END DO
      END DO
      END DO
      IF (.not.MA_PUSH_GET(mt_dbl,dimc,'noname',l_c,k_c)) CALL ERRQUIT('
     &eomccsdt_y2_12_3',9,MA_ERR)
      CALL TCE_SORT_2(dbl_mb(k_c_sort),dbl_mb(k_c),int_mb(k_range+h3b-1)
     &,int_mb(k_range+h11b-1),1,2,1.0d0/12.0d0)
      CALL ADD_HASH_BLOCK(d_c,dbl_mb(k_c),dimc,int_mb(k_c_offset),(h11b 
     &- 1 + noab * (h3b - 1)))
      IF (.not.MA_POP_STACK(l_c)) CALL ERRQUIT('eomccsdt_y2_12_3',10,MA_
     &ERR)
      IF (.not.MA_POP_STACK(l_c_sort)) CALL ERRQUIT('eomccsdt_y2_12_3',1
     &1,MA_ERR)
      END IF
      END IF
      END IF
      next = NXTASK(nprocs,1)
      END IF
      count = count + 1
      END DO
      END DO
      next = NXTASK(-nprocs,1)
      call GA_SYNC()
      RETURN
      END
      SUBROUTINE eomccsdt_y2_12(d_a,k_a_offset,d_b,k_b_offset,d_c,k_c_of
     &fset)
C     $Id: eomccsdt_y2_all12.F 24184 2013-05-04 00:43:17Z edo $
C     This is a Fortran77 program generated by Tensor Contraction Engine v.1.0
C     Copyright (c) Battelle & Pacific Northwest National Laboratory (2002)
C     i0 ( h3 h4 p1 p2 )_ytv + = 1 * P( 2 ) * Sum ( h11 ) * i1 ( h3 h11 )_yt * v ( h4 h11 p1 p2 )_v
      IMPLICIT NONE
#include "global.fh"
#include "mafdecls.fh"
#include "sym.fh"
#include "errquit.fh"
#include "tce.fh"
      INTEGER d_a
      INTEGER k_a_offset
      INTEGER d_b
      INTEGER k_b_offset
      INTEGER d_c
      INTEGER k_c_offset
      INTEGER NXTASK
      INTEGER next
      INTEGER nprocs
      INTEGER count
      INTEGER h3b
      INTEGER h4b
      INTEGER p1b
      INTEGER p2b
      INTEGER dimc
      INTEGER l_c_sort
      INTEGER k_c_sort
      INTEGER h11b
      INTEGER h3b_1
      INTEGER h11b_1
      INTEGER h4b_2
      INTEGER h11b_2
      INTEGER p1b_2
      INTEGER p2b_2
      INTEGER dim_common
      INTEGER dima_sort
      INTEGER dima
      INTEGER dimb_sort
      INTEGER dimb
      INTEGER l_a_sort
      INTEGER k_a_sort
      INTEGER l_a
      INTEGER k_a
      INTEGER l_b_sort
      INTEGER k_b_sort
      INTEGER l_b
      INTEGER k_b
      INTEGER l_c
      INTEGER k_c
      EXTERNAL NXTASK
      nprocs = GA_NNODES()
      count = 0
      next = NXTASK(nprocs,1)
      DO h3b = 1,noab
      DO h4b = 1,noab
      DO p1b = noab+1,noab+nvab
      DO p2b = p1b,noab+nvab
      IF (next.eq.count) THEN
      IF ((.not.restricted).or.(int_mb(k_spin+h3b-1)+int_mb(k_spin+h4b-1
     &)+int_mb(k_spin+p1b-1)+int_mb(k_spin+p2b-1).ne.8)) THEN
      IF (int_mb(k_spin+h3b-1)+int_mb(k_spin+h4b-1) .eq. int_mb(k_spin+p
     &1b-1)+int_mb(k_spin+p2b-1)) THEN
      IF (ieor(int_mb(k_sym+h3b-1),ieor(int_mb(k_sym+h4b-1),ieor(int_mb(
     &k_sym+p1b-1),int_mb(k_sym+p2b-1)))) .eq. ieor(irrep_y,ieor(irrep_t
     &,irrep_v))) THEN
      dimc = int_mb(k_range+h3b-1) * int_mb(k_range+h4b-1) * int_mb(k_ra
     &nge+p1b-1) * int_mb(k_range+p2b-1)
      IF (.not.MA_PUSH_GET(mt_dbl,dimc,'noname',l_c_sort,k_c_sort)) CALL
     & ERRQUIT('eomccsdt_y2_12',0,MA_ERR)
      CALL DFILL(dimc,0.0d0,dbl_mb(k_c_sort),1)
      DO h11b = 1,noab
      IF (int_mb(k_spin+h3b-1) .eq. int_mb(k_spin+h11b-1)) THEN
      IF (ieor(int_mb(k_sym+h3b-1),int_mb(k_sym+h11b-1)) .eq. ieor(irrep
     &_y,irrep_t)) THEN
      CALL TCE_RESTRICTED_2(h3b,h11b,h3b_1,h11b_1)
      CALL TCE_RESTRICTED_4(h4b,h11b,p1b,p2b,h4b_2,h11b_2,p1b_2,p2b_2)
      dim_common = int_mb(k_range+h11b-1)
      dima_sort = int_mb(k_range+h3b-1)
      dima = dim_common * dima_sort
      dimb_sort = int_mb(k_range+h4b-1) * int_mb(k_range+p1b-1) * int_mb
     &(k_range+p2b-1)
      dimb = dim_common * dimb_sort
      IF ((dima .gt. 0) .and. (dimb .gt. 0)) THEN
      IF (.not.MA_PUSH_GET(mt_dbl,dima,'noname',l_a_sort,k_a_sort)) CALL
     & ERRQUIT('eomccsdt_y2_12',1,MA_ERR)
      IF (.not.MA_PUSH_GET(mt_dbl,dima,'noname',l_a,k_a)) CALL ERRQUIT('
     &eomccsdt_y2_12',2,MA_ERR)
      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(h11b_
     &1 - 1 + noab * (h3b_1 - 1)))
      CALL TCE_SORT_2(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+h3b-1)
     &,int_mb(k_range+h11b-1),1,2,1.0d0)
      IF (.not.MA_POP_STACK(l_a)) CALL ERRQUIT('eomccsdt_y2_12',3,MA_ERR
     &)
      IF (.not.MA_PUSH_GET(mt_dbl,dimb,'noname',l_b_sort,k_b_sort)) CALL
     & ERRQUIT('eomccsdt_y2_12',4,MA_ERR)
      IF (.not.MA_PUSH_GET(mt_dbl,dimb,'noname',l_b,k_b)) CALL ERRQUIT('
     &eomccsdt_y2_12',5,MA_ERR)
      IF ((h11b .lt. h4b)) THEN
      CALL GET_HASH_BLOCK(d_b,dbl_mb(k_b),dimb,int_mb(k_b_offset),(p2b_2
     & - 1 + (noab+nvab) * (p1b_2 - 1 + (noab+nvab) * (h4b_2 - 1 + (noab
     &+nvab) * (h11b_2 - 1)))))
      CALL TCE_SORT_4(dbl_mb(k_b),dbl_mb(k_b_sort),int_mb(k_range+h11b-1
     &),int_mb(k_range+h4b-1),int_mb(k_range+p1b-1),int_mb(k_range+p2b-1
     &),4,3,2,1,-1.0d0)
      END IF
      IF ((h4b .le. h11b)) THEN
      CALL GET_HASH_BLOCK(d_b,dbl_mb(k_b),dimb,int_mb(k_b_offset),(p2b_2
     & - 1 + (noab+nvab) * (p1b_2 - 1 + (noab+nvab) * (h11b_2 - 1 + (noa
     &b+nvab) * (h4b_2 - 1)))))
      CALL TCE_SORT_4(dbl_mb(k_b),dbl_mb(k_b_sort),int_mb(k_range+h4b-1)
     &,int_mb(k_range+h11b-1),int_mb(k_range+p1b-1),int_mb(k_range+p2b-1
     &),4,3,1,2,1.0d0)
      END IF
      IF (.not.MA_POP_STACK(l_b)) CALL ERRQUIT('eomccsdt_y2_12',6,MA_ERR
     &)
      CALL dgemm('T','N',dima_sort,dimb_sort,dim_common,1.0d0,dbl_mb(k_a
     &_sort),dim_common,dbl_mb(k_b_sort),dim_common,1.0d0,dbl_mb(k_c_sor
     &t),dima_sort)
      IF (.not.MA_POP_STACK(l_b_sort)) CALL ERRQUIT('eomccsdt_y2_12',7,M
     &A_ERR)
      IF (.not.MA_POP_STACK(l_a_sort)) CALL ERRQUIT('eomccsdt_y2_12',8,M
     &A_ERR)
      END IF
      END IF
      END IF
      END DO
      IF (.not.MA_PUSH_GET(mt_dbl,dimc,'noname',l_c,k_c)) CALL ERRQUIT('
     &eomccsdt_y2_12',9,MA_ERR)
      IF ((h3b .le. h4b)) THEN
      CALL TCE_SORT_4(dbl_mb(k_c_sort),dbl_mb(k_c),int_mb(k_range+p2b-1)
     &,int_mb(k_range+p1b-1),int_mb(k_range+h4b-1),int_mb(k_range+h3b-1)
     &,4,3,2,1,1.0d0)
      CALL ADD_HASH_BLOCK(d_c,dbl_mb(k_c),dimc,int_mb(k_c_offset),(p2b -
     & noab - 1 + nvab * (p1b - noab - 1 + nvab * (h4b - 1 + noab * (h3b
     & - 1)))))
      END IF
      IF ((h4b .le. h3b)) THEN
      CALL TCE_SORT_4(dbl_mb(k_c_sort),dbl_mb(k_c),int_mb(k_range+p2b-1)
     &,int_mb(k_range+p1b-1),int_mb(k_range+h4b-1),int_mb(k_range+h3b-1)
     &,3,4,2,1,-1.0d0)
      CALL ADD_HASH_BLOCK(d_c,dbl_mb(k_c),dimc,int_mb(k_c_offset),(p2b -
     & noab - 1 + nvab * (p1b - noab - 1 + nvab * (h3b - 1 + noab * (h4b
     & - 1)))))
      END IF
      IF (.not.MA_POP_STACK(l_c)) CALL ERRQUIT('eomccsdt_y2_12',10,MA_ER
     &R)
      IF (.not.MA_POP_STACK(l_c_sort)) CALL ERRQUIT('eomccsdt_y2_12',11,
     &MA_ERR)
      END IF
      END IF
      END IF
      next = NXTASK(nprocs,1)
      END IF
      count = count + 1
      END DO
      END DO
      END DO
      END DO
      next = NXTASK(-nprocs,1)
      call GA_SYNC()
      RETURN
      END
