1      SUBROUTINE alpha_2_7(d_a,k_a_offset,d_b,k_b_offset,d_c,k_c_offset)
2C     $Id$
3C     This is a Fortran77 program generated by Tensor Contraction Engine v.1.0
4C     Copyright (c) Battelle & Pacific Northwest National Laboratory (2002)
5C     i0 ( )_ytratrbv + = 1/4 * Sum ( h7 p10 h9 h11 ) * i1 ( h7 p10 h9 h11 )_ytratrb * v ( h9 h11 h7 p10 )_v
6      IMPLICIT NONE
7#include "global.fh"
8#include "mafdecls.fh"
9#include "sym.fh"
10#include "errquit.fh"
11#include "tce.fh"
12      INTEGER d_a
13      INTEGER k_a_offset
14      INTEGER d_b
15      INTEGER k_b_offset
16      INTEGER d_c
17      INTEGER k_c_offset
18      INTEGER NXTASK
19      INTEGER next
20      INTEGER nprocs
21      INTEGER count
22      INTEGER dimc
23      INTEGER l_c_sort
24      INTEGER k_c_sort
25      INTEGER h7b
26      INTEGER p10b
27      INTEGER h9b
28      INTEGER h11b
29      INTEGER h7b_1
30      INTEGER p10b_1
31      INTEGER h9b_1
32      INTEGER h11b_1
33      INTEGER h9b_2
34      INTEGER h11b_2
35      INTEGER h7b_2
36      INTEGER p10b_2
37      INTEGER dim_common
38      INTEGER dima_sort
39      INTEGER dima
40      INTEGER dimb_sort
41      INTEGER dimb
42      INTEGER l_a_sort
43      INTEGER k_a_sort
44      INTEGER l_a
45      INTEGER k_a
46      INTEGER l_b_sort
47      INTEGER k_b_sort
48      INTEGER l_b
49      INTEGER k_b
50      INTEGER nsubh(2)
51      INTEGER isubh
52      INTEGER l_c
53      INTEGER k_c
54      DOUBLE PRECISION FACTORIAL
55      EXTERNAL NXTASK
56      EXTERNAL FACTORIAL
57      nprocs = GA_NNODES()
58      count = 0
59      next = NXTASK(nprocs,1)
60      IF (next.eq.count) THEN
61      IF (0 .eq. ieor(irrep_y,ieor(irrep_tra,ieor(irrep_trb,irrep_v))))
62     &THEN
63      dimc = 1
64      IF (.not.MA_PUSH_GET(mt_dbl,dimc,'noname',l_c_sort,k_c_sort)) CALL
65     & ERRQUIT('alpha_2_7',0,MA_ERR)
66      CALL DFILL(dimc,0.0d0,dbl_mb(k_c_sort),1)
67      DO h7b = 1,noab
68      DO p10b = noab+1,noab+nvab
69      DO h9b = 1,noab
70      DO h11b = h9b,noab
71      IF (int_mb(k_spin+h7b-1)+int_mb(k_spin+p10b-1) .eq. int_mb(k_spin+
72     &h9b-1)+int_mb(k_spin+h11b-1)) THEN
73      IF (ieor(int_mb(k_sym+h7b-1),ieor(int_mb(k_sym+p10b-1),ieor(int_mb
74     &(k_sym+h9b-1),int_mb(k_sym+h11b-1)))) .eq. ieor(irrep_y,ieor(irrep
75     &_tra,irrep_trb))) THEN
76      CALL TCE_RESTRICTED_4(h7b,p10b,h9b,h11b,h7b_1,p10b_1,h9b_1,h11b_1)
77      CALL TCE_RESTRICTED_4(h9b,h11b,h7b,p10b,h9b_2,h11b_2,h7b_2,p10b_2)
78      dim_common = int_mb(k_range+h7b-1) * int_mb(k_range+p10b-1) * int_
79     &mb(k_range+h9b-1) * int_mb(k_range+h11b-1)
80      dima_sort = 1
81      dima = dim_common * dima_sort
82      dimb_sort = 1
83      dimb = dim_common * dimb_sort
84      IF ((dima .gt. 0) .and. (dimb .gt. 0)) THEN
85      IF (.not.MA_PUSH_GET(mt_dbl,dima,'noname',l_a_sort,k_a_sort)) CALL
86     & ERRQUIT('alpha_2_7',1,MA_ERR)
87      IF (.not.MA_PUSH_GET(mt_dbl,dima,'noname',l_a,k_a)) CALL ERRQUIT('
88     &alpha_2_7',2,MA_ERR)
89      CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(h11b_
90     &1 - 1 + noab * (h9b_1 - 1 + noab * (p10b_1 - noab - 1 + nvab * (h7
91     &b_1 - 1)))))
92      CALL TCE_SORT_4(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+h7b-1)
93     &,int_mb(k_range+p10b-1),int_mb(k_range+h9b-1),int_mb(k_range+h11b-
94     &1),4,3,2,1,1.0d0)
95      IF (.not.MA_POP_STACK(l_a)) CALL ERRQUIT('alpha_2_7',3,MA_ERR)
96      IF (.not.MA_PUSH_GET(mt_dbl,dimb,'noname',l_b_sort,k_b_sort)) CALL
97     & ERRQUIT('alpha_2_7',4,MA_ERR)
98      IF (.not.MA_PUSH_GET(mt_dbl,dimb,'noname',l_b,k_b)) CALL ERRQUIT('
99     &alpha_2_7',5,MA_ERR)
100      if(.not.intorb) then
101      CALL GET_HASH_BLOCK(d_b,dbl_mb(k_b),dimb,int_mb(k_b_offset),(p10b_
102     &2 - 1 + (noab+nvab) * (h7b_2 - 1 + (noab+nvab) * (h11b_2 - 1 + (no
103     &ab+nvab) * (h9b_2 - 1)))))
104      else
105      CALL GET_HASH_BLOCK_I(d_b,dbl_mb(k_b),dimb,int_mb(k_b_offset),
106     &(p10b_
107     &2 - 1 + (noab+nvab) * (h7b_2 - 1 + (noab+nvab) * (h11b_2 - 1 + (no
108     &ab+nvab) * (h9b_2 - 1)))),p10b_2,h7b_2,h11b_2,h9b_2)
109      end if
110      CALL TCE_SORT_4(dbl_mb(k_b),dbl_mb(k_b_sort),int_mb(k_range+h9b-1)
111     &,int_mb(k_range+h11b-1),int_mb(k_range+h7b-1),int_mb(k_range+p10b-
112     &1),2,1,4,3,1.0d0)
113      IF (.not.MA_POP_STACK(l_b)) CALL ERRQUIT('alpha_2_7',6,MA_ERR)
114      nsubh(1) = 1
115      nsubh(2) = 1
116      isubh = 1
117      IF (h9b .eq. h11b) THEN
118      nsubh(isubh) = nsubh(isubh) + 1
119      ELSE
120      isubh = isubh + 1
121      END IF
122      CALL DGEMM('T','N',dima_sort,dimb_sort,dim_common,2.0d0/FACTORIAL(
123     &nsubh(1))/FACTORIAL(nsubh(2)),dbl_mb(k_a_sort),dim_common,dbl_mb(k
124     &_b_sort),dim_common,1.0d0,dbl_mb(k_c_sort),dima_sort)
125      IF (.not.MA_POP_STACK(l_b_sort)) CALL ERRQUIT('alpha_2_7',7,MA_ERR
126     &)
127      IF (.not.MA_POP_STACK(l_a_sort)) CALL ERRQUIT('alpha_2_7',8,MA_ERR
128     &)
129      END IF
130      END IF
131      END IF
132      END DO
133      END DO
134      END DO
135      END DO
136      IF (.not.MA_PUSH_GET(mt_dbl,dimc,'noname',l_c,k_c)) CALL ERRQUIT('
137     &alpha_2_7',9,MA_ERR)
138      CALL TCE_SORT_0(dbl_mb(k_c_sort),dbl_mb(k_c),1.0d0/4.0d0)
139      CALL ADD_HASH_BLOCK(d_c,dbl_mb(k_c),dimc,int_mb(k_c_offset),0)
140      IF (.not.MA_POP_STACK(l_c)) CALL ERRQUIT('alpha_2_7',10,MA_ERR)
141      IF (.not.MA_POP_STACK(l_c_sort)) CALL ERRQUIT('alpha_2_7',11,MA_ER
142     &R)
143      END IF
144      next = NXTASK(nprocs,1)
145      END IF
146      count = count + 1
147      next = NXTASK(-nprocs,1)
148      call GA_SYNC()
149      RETURN
150      END
151