      SUBROUTINE dip_r(d_i0,d_o1,d_t1,d_tr1,d_tr2,d_v2,k_i0_offset,k_o1_
     &offset,k_t1_offset,k_tr1_offset,k_tr2_offset,k_v2_offset)
C     $Id: dip_r.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 ( )_to + = 1 * Sum ( p5 h6 ) * t ( p5 h6 )_t * i1 ( h6 p5 )_o
C         i1 ( h6 p5 )_o + = 1 * o ( h6 p5 )_o
C         i1 ( h6 p5 )_vtr + = 1 * Sum ( h4 p3 ) * tr ( p3 h4 )_tr * v ( h4 h6 p3 p5 )_v
C     i0 ( )_vtr + = 1/4 * Sum ( h3 h4 p1 p2 ) * tr ( p1 p2 h3 h4 )_tr * v ( h3 h4 p1 p2 )_v
      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_t1
      INTEGER k_t1_offset
      INTEGER d_i1
      INTEGER k_i1_offset
      INTEGER d_tr2
      INTEGER k_tr2_offset
      INTEGER d_v2
      INTEGER k_v2_offset
      INTEGER l_i1_offset
      INTEGER d_o1
      INTEGER k_o1_offset
      INTEGER size_i1
      INTEGER d_tr1
      INTEGER k_tr1_offset
      CHARACTER*255 filename
      CALL OFFSET_dip_r_1_1(l_i1_offset,k_i1_offset,size_i1)
      CALL TCE_FILENAME('dip_r_1_1_i1',filename)
      CALL CREATEFILE(filename,d_i1,size_i1)
      CALL dip_r_1_1(d_o1,k_o1_offset,d_i1,k_i1_offset)
      CALL dip_r_1_2(d_tr1,k_tr1_offset,d_v2,k_v2_offset,d_i1,k_i1_offse
     &t)
      CALL RECONCILEFILE(d_i1,size_i1)
      CALL dip_r_1(d_t1,k_t1_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('dip_r',-1,MA_ERR
     &)
      CALL dip_r_2(d_tr2,k_tr2_offset,d_v2,k_v2_offset,d_i0,k_i0_offset)
      RETURN
      END
