c
c
c     ###################################################
c     ##  COPYRIGHT (C)  1990  by  Jay William Ponder  ##
c     ##              All Rights Reserved              ##
c     ###################################################
c
c     #############################################################
c     ##                                                         ##
c     ##  subroutine energ  --  energy                           ##
c     ##                                                         ##
c     #############################################################
c
c
c     "analyze" computes and displays the total potential; options
c     are provided to partition the energy by atom or by potential
c     function type; parameters used in computing interactions can
c     also be displayed by atom; output of large energy interactions
c     and the total dipole moment and components are available
c
c
      subroutine energ(transx,ic12tn,atnmtn,itptn,itgtn,mcmkey,
     *                 intn,nattom,mcmatm,mcmcar,tnky,tranky,
     *                 energy)
      implicit none
      include 'sizes.i'
      include 'action.i'
      include 'analyz.i'
      include 'angang.i'
      include 'angle.i'
      include 'atmtyp.i'
      include 'atoms.i'
      include 'bond.i'
      include 'charge.i'
      include 'chgpot.i'
      include 'potent.i'
      include 'couple.i'
      include 'dipole.i'
      include 'energi.i'
      include 'improp.i'
      include 'imptor.i'
      include 'inform.i'
      include 'iounit.i'
      include 'keys.i'
      include 'kvdws.i'
      include 'moment.i'
      include 'mpole.i'
      include 'opbend.i'
      include 'polar.i'
      include 'restrn.i'
      include 'solute.i'
      include 'strbnd.i'
      include 'strtor.i'
      include 'tors.i'
      include 'units.i'
      include 'urey.i'
      include 'vdw.i'
      integer i,j,k,trimtext,mcmkey
      integer nattom,mcmatm,mcmcar
      integer ic12tn(mcmatm,mcmatm),itptn(mcmatm),itgtn(mcmatm)
      integer intn(mcmatm)
      integer tnky
      character*80 tranky(mcmkey)
      character*3 atnmtn(mcmatm)
      real*8 transx(mcmcar)
      integer ia,ib,ic,id
      integer list(20),fold(6)
      real*8 energy,rg,moment
      real*8 ampli(6),phase(6)
      character*1 letter
      character*80 record,string
      logical doenergy,doatom,dolarge
      logical doprops,doelect,doparam
      logical exist,header,active(maxatm)
c
cOTs
      use_angle=.true.
cOTe
c
c     set up the structure and mechanics calculation
c
      call initial
c     call getxyz
      n=nattom
      do i=1,nattom
         tag(i)=itgtn(i)
         type(i)=itptn(i)
         name(i)=atnmtn(i)
         do j=1,nattom
            i12(i,j)=ic12tn(i,j)
         enddo
         x(i)=transx((i-1)*3+1)
         y(i)=transx((i-1)*3+2)
         z(i)=transx((i-1)*3+3)
      enddo
      do i=1,nattom
         n12(i) = intn(i)
      enddo
      nkey=tnky
      if (nkey.gt.0) then
         do i=1,nkey
            keyline(i)=tranky(i)
         enddo
      endif
      call mechanic
c
c     now make the call to compute the potential energy
c
      call analysis (energy)
c
c     I commented the printing of the information. It is not useful.
c     TVA 01/24/02
c
c      if (abs(energy) .lt. 1.0d10) then
c            write (iout,90)  energy
c   90       format (/,' Total Potential Energy :',6x,f16.4,' Kcal/mole')
c      else
c            write (iout,100)  energy
c  100       format (/,' Total Potential Energy :',6x,d16.4,' Kcal/mole')
c      end if
c
c      close (unit=iout)
      return
      end
