      subroutine enegdd(energy,coo,forces,potscl,
     &                  nac,iac,nad,iad,
     &                  nbnd,ibnd,bl,bk,
     &                  nang,iang,ango,ak,
     &                  nt,it,trs1,trs2,trs3,trs4,
     &                  nti,iti,trsi1,trsi2,
     &                  q,iconn,ityp)
      implicit double precision (a-h,o-z), integer (i-n)
      parameter (mxcon=10)
      parameter (mxac=3*mxcon)
      parameter (mxad=9*mxcon)
      common /athlp/  iatoms, mxnat
      integer*2 ityp
      dimension forces(3,*),potscl(*)
      dimension nac(*),nad(*),iac(mxac,*),iad(mxad,*)
      dimension ibnd(2,*), bl(*), bk(*)
      dimension iang(3,*),ango(*),ak(*)
      dimension it(4,*),trs1(4,*),trs2(4,*),trs3(4,*),trs4(4,*)
      dimension iti(4,*),trsi1(4,*),trsi2(4,*)
      dimension coo(3,*),q(*),iconn(mxcon+1,*),ityp(*)

      eb  = 0.0d0
      ea  = 0.0d0
      eit = 0.0d0
      et  = 0.0d0
      ev  = 0.0d0
      ec  = 0.0d0

      do i=1,iatoms
         do j=1,3
            forces(j,i) = 0.0d0
         end do
      end do

      call bond (eb,nbnd,ibnd,bl,bk,coo,forces)

      call angle(ea,nang,iang,ango,ak,coo,forces)
      call tors (eit,1,
     &                nt,it,trs1,trs2,trs3,trs4,
     &                nti,iti,trsi1,trsi2,
     &                coo,forces)
      call tors (et,0,
     &                nt,it,trs1,trs2,trs3,trs4,
     &                nti,iti,trsi1,trsi2,
     &                coo,forces)

      call vdwlj(ev,nac,iac,nad,iad,coo,iconn,ityp,forces,potscl)
      call charge(ec,nac,iac,nad,iad,
     &            coo,iconn,q,forces,potscl)

      energy = eb + ea + eit + et + ev + ec

c      print*,'eb=',eb,'ea=',ea,'eit=',eit,'et=',et,'ev=',ev,'ec=',ec
      do i=1,iatoms
         do j=1,3
            forces(j,i) = -forces(j,i)
         end do
      end do

      return
      end
