      SUBROUTINE beta_4(d_d1,d_i0,d_t1,d_t2,d_tr1,d_tr2,d_y1,d_y2,k_d1_o
     &ffset,k_i0_offset,k_t1_offset,k_t2_offset,k_tr1_offset,k_tr2_offse
     &t,k_y1_offset,k_y2_offset)
C     $Id: beta_4.F 19698 2010-10-29 17:03:09Z d3y133 $
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 ( )_ytrd + = -1 * Sum ( h2 h1 ) * d ( h1 h2 )_d * i1 ( h2 h1 )_ytr
C         i1 ( h2 h1 )_ytr + = 1 * Sum ( p3 ) * tr ( p3 h1 )_tr * y ( h2 p3 )_y
C         i1 ( h2 h1 )_ytr + = 1/2 * Sum ( h5 p3 p4 ) * tr ( p3 p4 h1 h5 )_tr * y ( h2 h5 p3 p4 )_y
C     i0 ( )_dtry + = 1 * Sum ( p1 h3 ) * y ( h3 p1 )_y * i1 ( p1 h3 )_dtr
C         i1 ( p1 h3 )_dtr + = 1 * Sum ( p2 ) * d ( p1 p2 )_d * tr ( p2 h3 )_tr
C     i0 ( )_ytrd + = 1 * Sum ( p2 h1 ) * d ( h1 p2 )_d * i1 ( p2 h1 )_ytr
C         i1 ( p2 h1 )_ytr + = 1 * Sum ( h4 p3 ) * tr ( p2 p3 h1 h4 )_tr * y ( h4 p3 )_y
C         i1 ( p2 h1 )_ytrt + = -1 * Sum ( h3 ) * t ( p2 h3 )_t * i2 ( h3 h1 )_ytr
C             i2 ( h3 h1 )_ytr + = 1 * Sum ( p4 ) * tr ( p4 h1 )_tr * y ( h3 p4 )_y
C             i2 ( h3 h1 )_ytr + = 1/2 * Sum ( h6 p4 p5 ) * tr ( p4 p5 h1 h6 )_tr * y ( h3 h6 p4 p5 )_y
C         i1 ( p2 h1 )_yttr + = -1 * Sum ( h7 ) * tr ( p2 h7 )_tr * i2 ( h7 h1 )_yt
C             i2 ( h7 h1 )_yt + = 1 * Sum ( p3 ) * t ( p3 h1 )_t * y ( h7 p3 )_y
C             i2 ( h7 h1 )_yt + = -1/2 * Sum ( h5 p3 p4 ) * t ( p3 p4 h1 h5 )_t * y ( h5 h7 p3 p4 )_y
C         i1 ( p2 h1 )_yttr + = 1/2 * Sum ( h5 h6 p4 ) * tr ( p2 p4 h5 h6 )_tr * i2 ( h5 h6 h1 p4 )_yt
C             i2 ( h5 h6 h1 p4 )_yt + = -1 * Sum ( p3 ) * t ( p3 h1 )_t * y ( h5 h6 p3 p4 )_y
C         i1 ( p2 h1 )_ytrt + = -1/2 * Sum ( h4 h5 p3 ) * t ( p2 p3 h4 h5 )_t * i2 ( h4 h5 h1 p3 )_ytr
C             i2 ( h4 h5 h1 p3 )_ytr + = -1 * Sum ( p6 ) * tr ( p6 h1 )_tr * y ( h4 h5 p3 p6 )_y
C     i0 ( )_ytrd + = 1/2 * Sum ( p2 p1 ) * d ( p1 p2 )_d * i1 ( p2 p1 )_ytr
C         i1 ( p2 p1 )_ytr + = 1 * Sum ( h4 h5 p3 ) * tr ( p2 p3 h4 h5 )_tr * y ( h4 h5 p1 p3 )_y
      IMPLICIT NONE
#include "global.fh"
#include "mafdecls.fh"
#include "util.fh"
#include "errquit.fh"
#include "tce.fh"
      INTEGER d_i0
      INTEGER k_i0_offset
      INTEGER d_d1
      INTEGER k_d1_offset
      INTEGER d_i1
      INTEGER k_i1_offset
      INTEGER d_y1
      INTEGER k_y1_offset
      INTEGER l_i1_offset
      INTEGER d_tr1
      INTEGER k_tr1_offset
      INTEGER size_i1
      INTEGER d_tr2
      INTEGER k_tr2_offset
      INTEGER d_y2
      INTEGER k_y2_offset
      INTEGER d_t1
      INTEGER k_t1_offset
      INTEGER d_i2
      INTEGER k_i2_offset
      INTEGER d_t2
      INTEGER k_t2_offset
      INTEGER l_i2_offset
      INTEGER size_i2
      CHARACTER*255 filename
      CALL OFFSET_beta_4_1_1(l_i1_offset,k_i1_offset,size_i1)
      CALL TCE_FILENAME('beta_4_1_1_i1',filename)
      CALL CREATEFILE(filename,d_i1,size_i1)
      CALL beta_4_1_1(d_tr1,k_tr1_offset,d_y1,k_y1_offset,d_i1,k_i1_offs
     &et)
      CALL beta_4_1_2(d_tr2,k_tr2_offset,d_y2,k_y2_offset,d_i1,k_i1_offs
     &et)
      CALL RECONCILEFILE(d_i1,size_i1)
      CALL beta_4_1(d_d1,k_d1_offset,d_i1,k_i1_offset,d_i0,k_i0_offset)
      CALL DELETEFILE(d_i1)
      IF (.not.MA_POP_STACK(l_i1_offset)) CALL ERRQUIT('beta_4',-1,MA_ER
     &R)
      CALL OFFSET_beta_4_2_1(l_i1_offset,k_i1_offset,size_i1)
      CALL TCE_FILENAME('beta_4_2_1_i1',filename)
      CALL CREATEFILE(filename,d_i1,size_i1)
      CALL beta_4_2_1(d_d1,k_d1_offset,d_tr1,k_tr1_offset,d_i1,k_i1_offs
     &et)
      CALL RECONCILEFILE(d_i1,size_i1)
      CALL beta_4_2(d_y1,k_y1_offset,d_i1,k_i1_offset,d_i0,k_i0_offset)
      CALL DELETEFILE(d_i1)
      IF (.not.MA_POP_STACK(l_i1_offset)) CALL ERRQUIT('beta_4',-1,MA_ER
     &R)
      CALL OFFSET_beta_4_3_1(l_i1_offset,k_i1_offset,size_i1)
      CALL TCE_FILENAME('beta_4_3_1_i1',filename)
      CALL CREATEFILE(filename,d_i1,size_i1)
      CALL beta_4_3_1(d_tr2,k_tr2_offset,d_y1,k_y1_offset,d_i1,k_i1_offs
     &et)
      CALL OFFSET_beta_4_3_2_1(l_i2_offset,k_i2_offset,size_i2)
      CALL TCE_FILENAME('beta_4_3_2_1_i2',filename)
      CALL CREATEFILE(filename,d_i2,size_i2)
      CALL beta_4_3_2_1(d_tr1,k_tr1_offset,d_y1,k_y1_offset,d_i2,k_i2_of
     &fset)
      CALL beta_4_3_2_2(d_tr2,k_tr2_offset,d_y2,k_y2_offset,d_i2,k_i2_of
     &fset)
      CALL RECONCILEFILE(d_i2,size_i2)
      CALL beta_4_3_2(d_t1,k_t1_offset,d_i2,k_i2_offset,d_i1,k_i1_offset
     &)
      CALL DELETEFILE(d_i2)
      IF (.not.MA_POP_STACK(l_i2_offset)) CALL ERRQUIT('beta_4',-1,MA_ER
     &R)
      CALL OFFSET_beta_4_3_3_1(l_i2_offset,k_i2_offset,size_i2)
      CALL TCE_FILENAME('beta_4_3_3_1_i2',filename)
      CALL CREATEFILE(filename,d_i2,size_i2)
      CALL beta_4_3_3_1(d_t1,k_t1_offset,d_y1,k_y1_offset,d_i2,k_i2_offs
     &et)
      CALL beta_4_3_3_2(d_t2,k_t2_offset,d_y2,k_y2_offset,d_i2,k_i2_offs
     &et)
      CALL RECONCILEFILE(d_i2,size_i2)
      CALL beta_4_3_3(d_tr1,k_tr1_offset,d_i2,k_i2_offset,d_i1,k_i1_offs
     &et)
      CALL DELETEFILE(d_i2)
      IF (.not.MA_POP_STACK(l_i2_offset)) CALL ERRQUIT('beta_4',-1,MA_ER
     &R)
      CALL OFFSET_beta_4_3_4_1(l_i2_offset,k_i2_offset,size_i2)
      CALL TCE_FILENAME('beta_4_3_4_1_i2',filename)
      CALL CREATEFILE(filename,d_i2,size_i2)
      CALL beta_4_3_4_1(d_t1,k_t1_offset,d_y2,k_y2_offset,d_i2,k_i2_offs
     &et)
      CALL RECONCILEFILE(d_i2,size_i2)
      CALL beta_4_3_4(d_tr2,k_tr2_offset,d_i2,k_i2_offset,d_i1,k_i1_offs
     &et)
      CALL DELETEFILE(d_i2)
      IF (.not.MA_POP_STACK(l_i2_offset)) CALL ERRQUIT('beta_4',-1,MA_ER
     &R)
      CALL OFFSET_beta_4_3_5_1(l_i2_offset,k_i2_offset,size_i2)
      CALL TCE_FILENAME('beta_4_3_5_1_i2',filename)
      CALL CREATEFILE(filename,d_i2,size_i2)
      CALL beta_4_3_5_1(d_tr1,k_tr1_offset,d_y2,k_y2_offset,d_i2,k_i2_of
     &fset)
      CALL RECONCILEFILE(d_i2,size_i2)
      CALL beta_4_3_5(d_t2,k_t2_offset,d_i2,k_i2_offset,d_i1,k_i1_offset
     &)
      CALL DELETEFILE(d_i2)
      IF (.not.MA_POP_STACK(l_i2_offset)) CALL ERRQUIT('beta_4',-1,MA_ER
     &R)
      CALL RECONCILEFILE(d_i1,size_i1)
      CALL beta_4_3(d_d1,k_d1_offset,d_i1,k_i1_offset,d_i0,k_i0_offset)
      CALL DELETEFILE(d_i1)
      IF (.not.MA_POP_STACK(l_i1_offset)) CALL ERRQUIT('beta_4',-1,MA_ER
     &R)
      CALL OFFSET_beta_4_4_1(l_i1_offset,k_i1_offset,size_i1)
      CALL TCE_FILENAME('beta_4_4_1_i1',filename)
      CALL CREATEFILE(filename,d_i1,size_i1)
      CALL beta_4_4_1(d_tr2,k_tr2_offset,d_y2,k_y2_offset,d_i1,k_i1_offs
     &et)
      CALL RECONCILEFILE(d_i1,size_i1)
      CALL beta_4_4(d_d1,k_d1_offset,d_i1,k_i1_offset,d_i0,k_i0_offset)
      CALL DELETEFILE(d_i1)
      IF (.not.MA_POP_STACK(l_i1_offset)) CALL ERRQUIT('beta_4',-1,MA_ER
     &R)
      RETURN
      END
