1      Subroutine hf3OIs(Axyz,Aprims,Acoef,NPA,La,
2     &                  Bxyz,Bprims,Bcoef,NPB,Lb,
3     &                  Cxyz,Cprims,Ccoef,NPC,Lc,
4     &                  b3OI,Nint,TriDiag,
5     &                  DryRun,W0,maxW0)
6c $Id$
7
8      Implicit real*8 (a-h,o-z)
9      Implicit integer (i-n)
10
11      Logical TriDiag,DryRun
12
13c--> Cartesian Coordinates, Primitives & Contraction Coefficients
14
15      Dimension Axyz(3),Aprims(NPA),Acoef(NPA)
16      Dimension Bxyz(3),Bprims(NPB),Bcoef(NPB)
17      Dimension Cxyz(3),Cprims(NPC),Ccoef(NPC)
18
19c--> Block of 3-Center Overlap Integrals
20
21      Dimension b3OI(Nint)
22
23c--> Scratch Space.
24
25      Dimension W0(maxW0)
26c
27c Compute 3-ctr overlap integrals (3OIs) for three shells of contracted
28c Gaussians functions.
29c
30c******************************************************************************
31
32c Define the prefactor of the charge distribution.
33
34c Assign pointers to scratch space.
35
36      i_alpha = 1
37      i_top   = i_alpha + (NPA*NPB*NPC)*4 - 1
38
39      if((i_top.gt.maxW0).and.(.not.Dryrun))then
40
41       write(*,*) 'HF3CTR:  Insufficient scratch space.'
42       write(*,*) '         needed    ',i_top
43       write(*,*) '         allocated ',maxW0
44
45       write(*,*) 'alpha   :  ',i_alpha
46
47       write(*,*) 'if you get this error doing higher multipoles with',
48     & 'a small basis set, try modifying NWints/api/exact_mem.F:279' ! Jeff
49
50       stop
51
52      end if
53
54      MaxMem = i_top    ! take care of compiler warnings
55
56      if( DryRun )then
57
58       MaxMem = i_top
59       NABC = NPA*NPB*NPC
60
61      else
62
63       call hf1set3(Axyz,Aprims,Acoef,NPA,
64     &              Bxyz,Bprims,Bcoef,NPB,
65     &              Cxyz,Cprims,Ccoef,NPC,
66     &              W0(i_alpha),NABC)
67
68      end if
69
70c Define the center of the charge distribution.
71
72c Assign pointers to scratch space.
73
74      i_E   = i_alpha + NABC*4
75      i_G   = i_E     + NABC*3*(La+Lb+Lc+1)*(La+1)*(Lb+1)*(Lc+1)
76      i_top = i_G     + NABC*3 - 1
77
78      if((i_top.gt.maxW0).and.(.not.Dryrun)) then
79
80       write(*,*) 'HF3CTR:  Insufficient scratch space.'
81       write(*,*) '         needed    ',i_top
82       write(*,*) '         allocated ',maxW0
83
84       write(*,*) 'alpha   :  ',i_alpha
85       write(*,*) 'E       :  ',i_E
86       write(*,*) 'G       :  ',i_G
87
88       write(*,*) 'if you get this error doing higher multipoles with',
89     & 'a small basis set, try modifying NWints/api/exact_mem.F:279' ! Jeff
90
91       stop
92
93      end if
94
95      if( DryRun )then
96
97       MaxMem = max( MaxMem, i_top )
98
99      else
100
101       call hfctr3(Axyz,Bxyz,Cxyz,W0(i_alpha),W0(i_G),NABC)
102
103      end if
104
105c Define the Hermite linear expansion coefficients.
106
107c Assign pointers to scratch space.
108
109      i_GT    = i_G     + NABC*3
110      i_ABC2I = i_GT    + NABC*3
111      i_top   = i_ABC2I + NABC*3 - 1
112
113      if( i_top .gt. maxW0 .and. .not.Dryrun)then
114
115       write(*,*) 'HF3CTR:  Insufficient scratch space.'
116       write(*,*) '         needed    ',i_top
117       write(*,*) '         allocated ',maxW0
118
119       write(*,*) 'alpha   :  ',i_alpha
120       write(*,*) 'E       :  ',i_E
121       write(*,*) 'G       :  ',i_G
122       write(*,*) 'GT      :  ',i_GT
123       write(*,*) 'ABC2I   :  ',i_ABC2I
124
125       write(*,*) 'if you get this error doing higher multipoles with',
126     & 'a small basis set, try modifying NWints/api/exact_mem.F:279' ! Jeff
127
128       stop
129
130      end if
131
132      if( DryRun )then
133
134       MaxMem = max( MaxMem, i_top )
135
136      else
137
138       call hf1mke3(Axyz,Bxyz,Cxyz,W0(i_alpha),W0(i_G),W0(i_GT),
139     &              W0(i_ABC2I),W0(i_E),NABC,La,Lb,Lc)
140
141      end if
142
143c Return the maximum amount of scratch space required by a "dry run".
144
145      if( DryRun )then
146       maxW0 = MaxMem
147       return
148      end if
149
150c Compute the 3-ctr OIs.
151
152      call hfabc(W0(i_E),b3OI,NABC,La,Lb,Lc,TriDiag)
153
154      end
155