      subroutine normd(nconts,ncontp,ncontd,nshels,nshelp,nsheld,mtloca,
     &                 wkvec)

c  this subroutine written by alain st-amant and sor koon goh of the
c  department of chemistry, university of ottawa, ottawa, canada.
c  all rights reserved.  this is part of the DeFT project.

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

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

      dimension wkvec(*)

      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

      wkvec(i4)=wkvec(i4)/sqrt3
      wkvec(i4+i1*3+3)=wkvec(i4+i1*3+3)/sqrt3
      wkvec(i4+i1*5+10)=wkvec(i4+i1*5+10)/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

      wkvec(i4)=wkvec(i4)/sqrt3
      wkvec(i4+1)=wkvec(i4+1)/sqrt3
      wkvec(i4+2)=wkvec(i4+2)/sqrt3

      wkvec(i4+i1*3+3)=wkvec(i4+i1*3+3)/sqrt3
      wkvec(i4+i1*3+4)=wkvec(i4+i1*3+4)/sqrt3
      wkvec(i4+i1*3+5)=wkvec(i4+i1*3+5)/sqrt3

      wkvec(i4+i1*5+10)=wkvec(i4+i1*5+10)/sqrt3
      wkvec(i4+i1*5+11)=wkvec(i4+i1*5+11)/sqrt3
      wkvec(i4+i1*5+12)=wkvec(i4+i1*5+12)/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

      wkvec(i4)=wkvec(i4)/three
      if(i.ne.j) wkvec(i4+1)=wkvec(i4+1)/sqrt3
      if(i.ne.j) wkvec(i4+2)=wkvec(i4+2)/sqrt3
      if(i.ne.j) wkvec(i4+3)=wkvec(i4+3)/three
      if(i.ne.j) wkvec(i4+4)=wkvec(i4+4)/sqrt3
      if(i.ne.j) wkvec(i4+5)=wkvec(i4+5)/three

      wkvec(i4+i1)=wkvec(i4+i1)/sqrt3
      if(i.ne.j) wkvec(i4+i1+3)=wkvec(i4+i1+3)/sqrt3
      if(i.ne.j) wkvec(i4+i1+5)=wkvec(i4+i1+5)/sqrt3

      wkvec(i4+i1*2+1)=wkvec(i4+i1*2+1)/sqrt3
      if(i.ne.j) wkvec(i4+i1*2+4)=wkvec(i4+i1*2+4)/sqrt3
      if(i.ne.j) wkvec(i4+i1*2+6)=wkvec(i4+i1*2+6)/sqrt3

      wkvec(i4+i1*3+3)=wkvec(i4+i1*3+3)/three
      wkvec(i4+i1*3+4)=wkvec(i4+i1*3+4)/sqrt3
      wkvec(i4+i1*3+5)=wkvec(i4+i1*3+5)/sqrt3
      wkvec(i4+i1*3+6)=wkvec(i4+i1*3+6)/three
      if(i.ne.j) wkvec(i4+i1*3+7)=wkvec(i4+i1*3+7)/sqrt3
      if(i.ne.j) wkvec(i4+i1*3+8)=wkvec(i4+i1*3+8)/three

      wkvec(i4+i1*4+6)=wkvec(i4+i1*4+6)/sqrt3
      wkvec(i4+i1*4+9)=wkvec(i4+i1*4+9)/sqrt3
      if(i.ne.j) wkvec(i4+i1*4+11)=wkvec(i4+i1*4+11)/sqrt3

      wkvec(i4+i1*5+10)=wkvec(i4+i1*5+10)/three
      wkvec(i4+i1*5+11)=wkvec(i4+i1*5+11)/sqrt3
      wkvec(i4+i1*5+12)=wkvec(i4+i1*5+12)/sqrt3
      wkvec(i4+i1*5+13)=wkvec(i4+i1*5+13)/three
      wkvec(i4+i1*5+14)=wkvec(i4+i1*5+14)/sqrt3
      wkvec(i4+i1*5+15)=wkvec(i4+i1*5+15)/three

 1003 continue

      return
      end
