c
c
c     ###################################################
c     ##  COPYRIGHT (C)  1990  by  Jay William Ponder  ##
c     ##              All Rights Reserved              ##
c     ###################################################
c
c     #############################################################
c     ##                                                         ##
c     ##  subroutine pialter  --  modify constants for pisystem  ##
c     ##                                                         ##
c     #############################################################
c
c
c     "pialter" first modifies bond lengths and force constants
c     according to the standard bond slope parameters and the
c     bond order values stored in "pnpl"; also alters some 2-fold
c     torsional parameters based on the bond-order * beta matrix
c
c
      subroutine pialter
      implicit none
      include 'sizes.i'
      include 'bond.i'
      include 'inform.i'
      include 'iounit.i'
      include 'pibond.i'
      include 'pistuf.i'
      include 'piterm.i'
      include 'tors.i'
      integer i,j,k
c
c
c     modify the stretching constants and natural bond lengths
c
      if (debug) then
         write (iout,10)
   10    format ()
      end if
      do i = 1, npibond
         k = pibond(1,i)
         bk(k) = bkpi(i) - kslope(i) * (1.0d0-pnpl(i))
         bl(k) = blpi(i) + lslope(i) * (1.0d0-pnpl(i))
         if (debug) then
            write (iout,20)  ibnd(1,k),ibnd(2,k),bkpi(i),
     &                       blpi(i),bk(k),bl(k)
   20       format (' PIALTER  --  Bond',3x,2i6,5x,
     &                f7.3,f8.4,' -->',f7.3,f8.4)
         end if
      end do
c
c     modify the 2-fold torsional constants across pibonds
c
      if (debug) then
         write (iout,30)
   30    format ()
      end if
      do i = 1, npitors
         j = pitors(1,i)
         k = pitors(2,i)
         tors2(1,j) = pbpl(k) * torspi(i)
         if (debug) then
            write (iout,40)  (itors(k,j),k=1,4),torspi(i),tors2(1,j)
   40       format (' PIALTER  --  Torsion',4i6,3x,f10.3,' -->',f10.3)
         end if
      end do
      if (debug) then
         write (iout,50)
   50    format ()
      end if
      return
      end
