c
c
c     ###################################################
c     ##  COPYRIGHT (C)  1990  by  Jay William Ponder  ##
c     ##              All Rights Reserved              ##
c     ###################################################
c
c     ################################################################
c     ##                                                            ##
c     ##  subroutine field  --  get the potential energy functions  ##
c     ##                                                            ##
c     ################################################################
c
c
c     "field" sets the force field potential energy functions from
c     a parameter file and modifications specified in a keyfile
c
c
      subroutine field
      implicit none
      include 'sizes.i'
      include 'angpot.i'
      include 'bndpot.i'
      include 'chgpot.i'
      include 'keys.i'
      include 'math.i'
      include 'polpot.i'
      include 'potent.i'
      include 'rxnpot.i'
      include 'torpot.i'
      include 'urypot.i'
      include 'vdwpot.i'
      integer i, ihereb
      character*80 record
      save ihereb
      if (ihereb.ne.1) then
c
c
c     set the default values for the active potentials
c
      use_bond = .true.
      use_angle = .true.
      use_strbnd = .true.
      use_urey = .true.
      use_angang = .true.
      use_opbend = .true.
      use_improp = .true.
      use_imptor = .true.
      use_tors = .true.
      use_strtor = .true.
      use_tortor = .false.
      use_vdw = .true.
      use_lj = .true.
      use_buck = .false.
      use_hal = .false.
      use_gauss = .false.
      use_charge = .true.
      use_chgdpl = .true.
      use_dipole = .true.
      use_mpole = .true.
      use_polar = .true.
      use_rxnfld = .false.
      use_solv = .true.
      use_geom = .true.
      use_extra = .true.
c
c     set default values for force field control parameters
c
      bndtyp = 'TAYLOR'
      bndunit = 1.0d0
c jcc
      bdeunit = 1.0d0
c jcc
      cbnd = 0.0d0
      qbnd = 0.0d0
      angtyp = 'HARMONIC'
      angunit = 1.0d0 / radian**2
      cang = 0.0d0
      qang = 0.0d0
      pang = 0.0d0
      sang = 0.0d0
      aaunit = 1.0d0 / radian**2
      stbnunit = 1.0d0
      ureyunit = 1.0d0
      torsunit = 1.0d0
      storunit = 1.0d0
      vdwtyp = 'LENNARD-JONES'
      aterm = 0.0d0
      bterm = 0.0d0
      cterm = 0.0d0
      ngauss = 0
      vdw12use = 1
      vdw13use = 1
      vdw14use = -1
      vdwscale = 1.0d0
      radrule = 'ARITHMETIC'
      radtyp = 'R-MIN'
      radsiz = 'RADIUS'
      epsrule = 'GEOMETRIC'
      dielec = 1.0d0
      chgscale = 1.0d0
      chg12use = 1
      chg13use = 1
      chg14use = -1
      neutnbr = .false.
      neutcut = .false.
      poltyp = 'MUTUAL'
      poleps = 0.000001d0
      pgamma = 1.0d0
      pradius = 1.662d0
      rfsize = 1000000.0d0
      rfbulkd = 80.0d0
      rfterms = 1
c
c     read the potential energy force field parameter file
c
      call getprm
      ihereb=1
      endif
c
c     check keywords for potential function control parameters
c
      do i = 1, nkey
         record = keyline(i)
         call prmkey (record)
      end do
c
c     if vdw is not used, turn off each vdw function type
c
      if (.not. use_vdw) then
         use_buck = .false.
         use_lj = .false.
         use_hal = .false.
         use_gauss = .false.
      end if
      return
      end
