1      Subroutine a_dist(xyz, Rij, nctrs,dopts)
2c
3C$Id$
4c
5      implicit none
6c
7#include "cdft.fh"
8c
9      integer nctrs
10c
11c     Cartesian Coordinates
12c
13      double precision xyz(3,nctrs)
14c
15c     Internuclear Distances
16c
17      double precision Rij((nctrs*(nctrs+1))/2)
18c
19      integer i, j, ij
20      logical dopts
21c
22c     Evaluate the distance between each pair of centers.
23c
24c     pt charges are "tagged" with -1
25c
26      rij(1)=0d0
27      if(nctrs.eq.1) return
28      if (dopts.and.iatype_pt_chg(1)) rij(1) = -1.0d0
29      ij = 1
30      if(dopts) then
31         do i = 2, nctrs
32            do  j = 1, i-1
33                ij = ij + 1
34               if (iatype_pt_chg(i).or.iatype_pt_chg(j))then
35                  Rij(ij) = -1.0d0
36               else
37                  Rij(ij) = 1.0d0/sqrt(  (xyz(1,i) - xyz(1,j))**2 +
38     &                 (xyz(2,i) - xyz(2,j))**2 +
39     &                                (xyz(3,i) - xyz(3,j))**2   )
40               endif
41            enddo
42            ij=ij+1
43            Rij(ij) = 0.0d0
44         enddo
45      else
46         do i = 2, nctrs
47!DEC$ LOOP COUNT(100)
48            do  j = 1, i-1
49               ij = ij + 1
50               Rij(ij) = 1.0d0/sqrt(
51     &              (xyz(1,i) - xyz(1,j))*(xyz(1,i) - xyz(1,j)) +
52     &              (xyz(2,i) - xyz(2,j))*(xyz(2,i) - xyz(2,j)) +
53     &              (xyz(3,i) - xyz(3,j))*(xyz(3,i) - xyz(3,j)))
54            enddo
55            ij=ij+1
56            Rij(ij) = 0.0d0
57         enddo
58      endif
59c
60      return
61      end
62