      subroutine normo(ndim,nconts,ncontp,ncontd,nshels,nshelp,nsheld,
     &                 mtloca,overlap)

      implicit real*8 (a-h,o-z)

      dimension nshels(*),nshelp(*),nsheld(*),mtloca(*)

      dimension overlap(ndim,*)

      data three/3.0d0/

      sqrt3=sqrt(three)

      do 1001 i=1,ncontd
      do 1001 j=1,nconts

      i1=mtloca(nsheld(i))
      i2=(i1*(i1-1))/2
      i3=mtloca(nshels(j))
      i4=i2+i3

      overlap(i4,1)=overlap(i4,1)/sqrt3
      overlap(i4,2)=overlap(i4,2)/sqrt3
      overlap(i4,3)=overlap(i4,3)/sqrt3

      overlap(i4+i1*3+3,1)=overlap(i4+i1*3+3,1)/sqrt3
      overlap(i4+i1*3+3,2)=overlap(i4+i1*3+3,2)/sqrt3
      overlap(i4+i1*3+3,3)=overlap(i4+i1*3+3,3)/sqrt3

      overlap(i4+i1*5+10,1)=overlap(i4+i1*5+10,1)/sqrt3
      overlap(i4+i1*5+10,2)=overlap(i4+i1*5+10,2)/sqrt3
      overlap(i4+i1*5+10,3)=overlap(i4+i1*5+10,3)/sqrt3

 1001 continue

      do 1002 i=1,ncontd
      do 1002 j=1,ncontp

      i1=mtloca(nsheld(i))
      i2=(i1*(i1-1))/2
      i3=mtloca(nshelp(j))
      i4=i2+i3

      overlap(i4,1)=overlap(i4,1)/sqrt3
      overlap(i4,2)=overlap(i4,2)/sqrt3
      overlap(i4,3)=overlap(i4,3)/sqrt3

      overlap(i4+1,1)=overlap(i4+1,1)/sqrt3
      overlap(i4+1,2)=overlap(i4+1,2)/sqrt3
      overlap(i4+1,3)=overlap(i4+1,3)/sqrt3

      overlap(i4+2,1)=overlap(i4+2,1)/sqrt3
      overlap(i4+2,2)=overlap(i4+2,2)/sqrt3
      overlap(i4+2,3)=overlap(i4+2,3)/sqrt3

      overlap(i4+i1*3+3,1)=overlap(i4+i1*3+3,1)/sqrt3
      overlap(i4+i1*3+3,2)=overlap(i4+i1*3+3,2)/sqrt3
      overlap(i4+i1*3+3,3)=overlap(i4+i1*3+3,3)/sqrt3

      overlap(i4+i1*3+4,1)=overlap(i4+i1*3+4,1)/sqrt3
      overlap(i4+i1*3+4,2)=overlap(i4+i1*3+4,2)/sqrt3
      overlap(i4+i1*3+4,3)=overlap(i4+i1*3+4,3)/sqrt3

      overlap(i4+i1*3+5,1)=overlap(i4+i1*3+5,1)/sqrt3
      overlap(i4+i1*3+5,2)=overlap(i4+i1*3+5,2)/sqrt3
      overlap(i4+i1*3+5,3)=overlap(i4+i1*3+5,3)/sqrt3

      overlap(i4+i1*5+10,1)=overlap(i4+i1*5+10,1)/sqrt3
      overlap(i4+i1*5+10,2)=overlap(i4+i1*5+10,2)/sqrt3
      overlap(i4+i1*5+10,3)=overlap(i4+i1*5+10,3)/sqrt3

      overlap(i4+i1*5+11,1)=overlap(i4+i1*5+11,1)/sqrt3
      overlap(i4+i1*5+11,2)=overlap(i4+i1*5+11,2)/sqrt3
      overlap(i4+i1*5+11,3)=overlap(i4+i1*5+11,3)/sqrt3

      overlap(i4+i1*5+12,1)=overlap(i4+i1*5+12,1)/sqrt3
      overlap(i4+i1*5+12,2)=overlap(i4+i1*5+12,2)/sqrt3
      overlap(i4+i1*5+12,3)=overlap(i4+i1*5+12,3)/sqrt3

 1002 continue

      do 1003 i=1,ncontd
      do 1003 j=1,i

      i1=mtloca(nsheld(i))
      i2=(i1*(i1-1))/2
      i3=mtloca(nsheld(j))
      i4=i2+i3

      overlap(i4,1)=overlap(i4,1)/three
      overlap(i4,2)=overlap(i4,2)/three
      overlap(i4,3)=overlap(i4,3)/three

      if(i.ne.j) overlap(i4+1,1)=overlap(i4+1,1)/sqrt3
      if(i.ne.j) overlap(i4+1,2)=overlap(i4+1,2)/sqrt3
      if(i.ne.j) overlap(i4+1,3)=overlap(i4+1,3)/sqrt3

      if(i.ne.j) overlap(i4+2,1)=overlap(i4+2,1)/sqrt3
      if(i.ne.j) overlap(i4+2,2)=overlap(i4+2,2)/sqrt3
      if(i.ne.j) overlap(i4+2,3)=overlap(i4+2,3)/sqrt3

      if(i.ne.j) overlap(i4+3,1)=overlap(i4+3,1)/three
      if(i.ne.j) overlap(i4+3,2)=overlap(i4+3,2)/three
      if(i.ne.j) overlap(i4+3,3)=overlap(i4+3,3)/three

      if(i.ne.j) overlap(i4+4,1)=overlap(i4+4,1)/sqrt3
      if(i.ne.j) overlap(i4+4,2)=overlap(i4+4,2)/sqrt3
      if(i.ne.j) overlap(i4+4,3)=overlap(i4+4,3)/sqrt3

      if(i.ne.j) overlap(i4+5,1)=overlap(i4+5,1)/three
      if(i.ne.j) overlap(i4+5,2)=overlap(i4+5,2)/three
      if(i.ne.j) overlap(i4+5,3)=overlap(i4+5,3)/three

      overlap(i4+i1,1)=overlap(i4+i1,1)/sqrt3
      overlap(i4+i1,2)=overlap(i4+i1,2)/sqrt3
      overlap(i4+i1,3)=overlap(i4+i1,3)/sqrt3

      if(i.ne.j) overlap(i4+i1+3,1)=overlap(i4+i1+3,1)/sqrt3
      if(i.ne.j) overlap(i4+i1+3,2)=overlap(i4+i1+3,2)/sqrt3
      if(i.ne.j) overlap(i4+i1+3,3)=overlap(i4+i1+3,3)/sqrt3

      if(i.ne.j) overlap(i4+i1+5,1)=overlap(i4+i1+5,1)/sqrt3
      if(i.ne.j) overlap(i4+i1+5,2)=overlap(i4+i1+5,2)/sqrt3
      if(i.ne.j) overlap(i4+i1+5,3)=overlap(i4+i1+5,3)/sqrt3

      overlap(i4+i1*2+1,1)=overlap(i4+i1*2+1,1)/sqrt3
      overlap(i4+i1*2+1,2)=overlap(i4+i1*2+1,2)/sqrt3
      overlap(i4+i1*2+1,3)=overlap(i4+i1*2+1,3)/sqrt3

      if(i.ne.j) overlap(i4+i1*2+4,1)=overlap(i4+i1*2+4,1)/sqrt3
      if(i.ne.j) overlap(i4+i1*2+4,2)=overlap(i4+i1*2+4,2)/sqrt3
      if(i.ne.j) overlap(i4+i1*2+4,3)=overlap(i4+i1*2+4,3)/sqrt3

      if(i.ne.j) overlap(i4+i1*2+6,1)=overlap(i4+i1*2+6,1)/sqrt3
      if(i.ne.j) overlap(i4+i1*2+6,2)=overlap(i4+i1*2+6,2)/sqrt3
      if(i.ne.j) overlap(i4+i1*2+6,3)=overlap(i4+i1*2+6,3)/sqrt3

      overlap(i4+i1*3+3,1)=overlap(i4+i1*3+3,1)/three
      overlap(i4+i1*3+3,2)=overlap(i4+i1*3+3,2)/three
      overlap(i4+i1*3+3,3)=overlap(i4+i1*3+3,3)/three

      overlap(i4+i1*3+4,1)=overlap(i4+i1*3+4,1)/sqrt3
      overlap(i4+i1*3+4,2)=overlap(i4+i1*3+4,2)/sqrt3
      overlap(i4+i1*3+4,3)=overlap(i4+i1*3+4,3)/sqrt3

      overlap(i4+i1*3+5,1)=overlap(i4+i1*3+5,1)/sqrt3
      overlap(i4+i1*3+5,2)=overlap(i4+i1*3+5,2)/sqrt3
      overlap(i4+i1*3+5,3)=overlap(i4+i1*3+5,3)/sqrt3

      overlap(i4+i1*3+6,1)=overlap(i4+i1*3+6,1)/three
      overlap(i4+i1*3+6,2)=overlap(i4+i1*3+6,2)/three
      overlap(i4+i1*3+6,3)=overlap(i4+i1*3+6,3)/three

      if(i.ne.j) overlap(i4+i1*3+7,1)=overlap(i4+i1*3+7,1)/sqrt3
      if(i.ne.j) overlap(i4+i1*3+7,2)=overlap(i4+i1*3+7,2)/sqrt3
      if(i.ne.j) overlap(i4+i1*3+7,3)=overlap(i4+i1*3+7,3)/sqrt3

      if(i.ne.j) overlap(i4+i1*3+8,1)=overlap(i4+i1*3+8,1)/three
      if(i.ne.j) overlap(i4+i1*3+8,2)=overlap(i4+i1*3+8,2)/three
      if(i.ne.j) overlap(i4+i1*3+8,3)=overlap(i4+i1*3+8,3)/three

      overlap(i4+i1*4+6,1)=overlap(i4+i1*4+6,1)/sqrt3
      overlap(i4+i1*4+6,2)=overlap(i4+i1*4+6,2)/sqrt3
      overlap(i4+i1*4+6,3)=overlap(i4+i1*4+6,3)/sqrt3

      overlap(i4+i1*4+9,1)=overlap(i4+i1*4+9,1)/sqrt3
      overlap(i4+i1*4+9,2)=overlap(i4+i1*4+9,2)/sqrt3
      overlap(i4+i1*4+9,3)=overlap(i4+i1*4+9,3)/sqrt3

      if(i.ne.j) overlap(i4+i1*4+11,1)=overlap(i4+i1*4+11,1)/sqrt3
      if(i.ne.j) overlap(i4+i1*4+11,2)=overlap(i4+i1*4+11,2)/sqrt3
      if(i.ne.j) overlap(i4+i1*4+11,3)=overlap(i4+i1*4+11,3)/sqrt3

      overlap(i4+i1*5+10,1)=overlap(i4+i1*5+10,1)/three
      overlap(i4+i1*5+10,2)=overlap(i4+i1*5+10,2)/three
      overlap(i4+i1*5+10,3)=overlap(i4+i1*5+10,3)/three

      overlap(i4+i1*5+11,1)=overlap(i4+i1*5+11,1)/sqrt3
      overlap(i4+i1*5+11,2)=overlap(i4+i1*5+11,2)/sqrt3
      overlap(i4+i1*5+11,3)=overlap(i4+i1*5+11,3)/sqrt3

      overlap(i4+i1*5+12,1)=overlap(i4+i1*5+12,1)/sqrt3
      overlap(i4+i1*5+12,2)=overlap(i4+i1*5+12,2)/sqrt3
      overlap(i4+i1*5+12,3)=overlap(i4+i1*5+12,3)/sqrt3

      overlap(i4+i1*5+13,1)=overlap(i4+i1*5+13,1)/three
      overlap(i4+i1*5+13,2)=overlap(i4+i1*5+13,2)/three
      overlap(i4+i1*5+13,3)=overlap(i4+i1*5+13,3)/three

      overlap(i4+i1*5+14,1)=overlap(i4+i1*5+14,1)/sqrt3
      overlap(i4+i1*5+14,2)=overlap(i4+i1*5+14,2)/sqrt3
      overlap(i4+i1*5+14,3)=overlap(i4+i1*5+14,3)/sqrt3

      overlap(i4+i1*5+15,1)=overlap(i4+i1*5+15,1)/three
      overlap(i4+i1*5+15,2)=overlap(i4+i1*5+15,2)/three
      overlap(i4+i1*5+15,3)=overlap(i4+i1*5+15,3)/three

 1003 continue

      return
      end
