c
c
c     ###################################################
c     ##  COPYRIGHT (C)  1990  by  Jay William Ponder  ##
c     ##              All Rights Reserved              ##
c     ###################################################
c
c     ###############################################################
c     ##                                                           ##
c     ##  subroutine readprm  --  input of force field parameters  ##
c     ##                                                           ##
c     ###############################################################
c
c
c     "readprm" processes the potential energy parameter file
c     in order to define the default force field parameters
c
c
      subroutine readprm (iprm)
      implicit none
CAMBP#ifdef MPI
CAMBPc     =========================== AMBER/MPI ===========================
CAMBP#     ifdef MPI_DOUBLE_PRECISION
CAMBP#       undef MPI_DOUBLE_PRECISION
CAMBP#     endif
CAMBP      include 'mpif.h'
CAMBP#     ifdef CRAY_PVP
CAMBP#       define MPI_DOUBLE_PRECISION MPI_REAL8
CAMBP#     endif
CAMBPc     ========================= END AMBER/MPI =========================
CAMBP#     include "parallel.h"
CAMBP#     include "extra.h"
CAMBPc
CAMBP      integer iend,ier
CAMBP#endif
      include 'sizes.i'
      include 'fields.i'
      include 'iounit.i'
      include 'kanang.i'
      include 'kangs.i'
      include 'katoms.i'
      include 'kbonds.i'
      include 'kchrge.i'
      include 'kdipol.i'
      include 'kiprop.i'
      include 'kitors.i'
      include 'kmulti.i'
      include 'kopbnd.i'
      include 'korbs.i'
      include 'kpolr.i'
      include 'kstbnd.i'
      include 'ksttor.i'
      include 'ktorsn.i'
      include 'kurybr.i'
      include 'kvdws.i'
      include 'kvdwpr.i'
      integer i,j,iprm,size,next
      integer length,trimtext
      integer ia,ib,ic,id
      integer cls,atn,lig,ft(6)
      integer nb,nb5,nb4,nb3
      integer na,na5,na4,na3
      integer nopb,nu,ndi,nti
      integer nt,nt5,nt4,nbt
      integer nd,nd5,nd4,nd3
      integer nvp,nmp,npi
      real*8 wght,rd,ep,rdn
      real*8 an1,an2,an3
      real*8 ba1,ba2,ba3
      real*8 aa1,aa2,aa3
      real*8 bt1,bt2,bt3
      real*8 dk,vd,dst,cg,dp,ps,fc
      real*8 bd,el,pol,iz,rp,ss,ts
      real*8 vt(6),st(6),pl(13)
c jcc
      real*8 edb
      character*3 pa,pb,pc,pd
      character*8 axt
      character*20 keyword
      character*80 record,string
      logical header
c
c
c     initialize the counters for some parameter types
c
      nvp = 0
      nb = 0
      nb5 = 0
      nb4 = 0
      nb3 = 0
      na = 0
      na5 = 0
      na4 = 0
      na3 = 0
      nopb = 0
      nu = 0
      ndi = 0
      nti = 0
      nt = 0
      nt5 = 0
      nt4 = 0
      nbt = 0
      nd = 0
      nd5 = 0
      nd4 = 0
      nd3 = 0
      nmp = 0
      npi = 0
c
c     initialize some of the force field parameters
c
      do i = 1, maxtyp
         symbol(i) = '   '
         atmcls(i) = 0
         atmnum(i) = 0
         weight(i) = 0.0d0
         ligand(i) = 0
         describe(i) = '                    '
         chg(i) = 0.0d0
         polr(i) = 0.0d0
      end do
      do i = 1, maxclass
         rad(i) = 0.0d0
         eps(i) = 0.0d0
         reduct(i) = 0.0d0
         do j = 1, 3
            stbn(j,i) = 0.0d0
            anan(j,i) = 0.0d0
         end do
         electron(i) = 0.0d0
         ionize(i) = 0.0d0
         repulse(i) = 0.0d0
      end do
      do i = 1, maxbio
         biotyp(i) = 0
      end do
c
c     number of characters in an atom number text string
c
      size = 3
c
c     set blank line header before echoed comment lines
c
      header = .true.
c
c     process each line of the parameter file, first
c     extract the keyword at the start of each line
c
      dowhile (.true.)
CAMBP#ifdef MPI
CAMBP         if(master) read (iprm,10,end=430)  record
CAMBP         iend=0
CAMBP         call mpi_bcast(iend, 1, mpi_integer, 0, commsander, ier) 
CAMBP         if(iend.eq.1) goto 430
CAMBP         call mpi_bcast(record, 80, mpi_character, 0, commsander, ier) 
CAMBP#else
         read (iprm,10,end=430)  record
CAMBP#endif
   10    format (a80)
         next = 1
         call gettext (record,keyword,next)
         call upcase (keyword)
c
c     check for a force field modification keyword
c
         call prmkey (record)
c
c     comment line to be echoed to the output
c
         if (keyword(1:5) .eq. 'ECHO ') then
            string = record(next:80)
            length = trimtext (string)
            if (header) then
               header = .false.
               write (iout,20)
   20          format ()
            end if
            if (length .eq. 0) then
               write (iout,30)
   30          format ()
            else
               write (iout,40)  string(1:length)
   40          format (a)
            end if
c
c     atom type definitions and parameters
c
         else if (keyword(1:5) .eq. 'ATOM ') then
            ia = 0
            cls = 0
            atn = 0
            wght = 0.0d0
            lig = 0
            call getnumb (record,ia,next)
            call getnumb (record,cls,next)
            if (cls .eq. 0)  cls = ia
            atmcls(ia) = cls
            if (ia .ge. maxtyp) then
               write (iout,50)
   50          format (/,' READPRM  --  Too many Atom Types;',
     &                    ' Increase MAXTYP')
               call fatal
            else if (cls .ge. maxclass) then
               write (iout,60)
   60          format (/,' READPRM  --  Too many Atom Classes;',
     &                    ' Increase MAXCLASS')
               call fatal
            end if
            call getword (record,symbol(ia),next)
            call getstring (record,describe(ia),next)
            string = record(next:80)
            read (string,*,err=70,end=70)  atn,wght,lig
   70       continue
            atmnum(ia) = atn
            weight(ia) = wght
            ligand(ia) = lig
c
c     van der Waals parameters for individual atom types
c
         else if (keyword(1:4) .eq. 'VDW ') then
            ia = 0
            rd = 0.0d0
            ep = 0.0d0
            rdn = 0.0d0
            string = record(next:80)
            read (string,*,err=80,end=80)  ia,rd,ep,rdn
   80       continue
            rad(ia) = rd
            eps(ia) = ep
            reduct(ia) = rdn
C hailin
c     van der Waals 1-4 parameters for individual atom types
c
         else if (keyword(1:6) .eq. 'VDW14 ') then
            ia = 0  
            rd = 0.0d0
            ep = 0.0d0
c            string = record(next:120)                                  0305MH08
            string = record(next:80)                                    0305MH08
            read (string,*,err=9990,end=9990)  ia,rd,ep
 9990       continue
            if (ia .ne. 0) then
               rad4(ia) = rd
               eps4(ia) = ep
            end if
c
C hailinend
c
c     van der Waals parameters for specific atom pairs
c
         else if (keyword(1:6) .eq. 'VDWPR ') then
            ia = 0
            ib = 0
            rd = 0.0d0
            ep = 0.0d0
            string = record(next:80)
            read (string,*,err=90,end=90)  ia,ib,rd,ep
   90       continue
            call numeral (ia,pa,size)
            call numeral (ib,pb,size)
            nvp = nvp + 1
            if (ia .le. ib) then
               kvpr(nvp) = pa//pb
            else
               kvpr(nvp) = pb//pa
            end if
            radpr(nvp) = rd
            epspr(nvp) = ep
c
c     bond stretching parameters
c
         else if (keyword(1:5) .eq. 'BOND ') then
            ia = 0
            ib = 0
            fc = 0.0d0
            bd = 0.0d0
            edb = -1.d0
            string = record(next:80)
c jcc       read (string,*,err=100,end=100)  ia,ib,fc,bd
            read (string,*,err=100,end=100)  ia,ib,fc,bd,edb
  100       continue
            call numeral (ia,pa,size)
            call numeral (ib,pb,size)
            nb = nb + 1
            if (ia .le. ib) then
               kb(nb) = pa//pb
            else
               kb(nb) = pb//pa
            end if
            fcon(nb) = fc
            blen(nb) = bd
            ebd(nb) = edb
c
c     bond stretching parameters for 5-membered rings
c
         else if (keyword(1:6) .eq. 'BOND5 ') then
            ia = 0
            ib = 0
            fc = 0.0d0
            bd = 0.0d0
            edb = 0.d0
            string = record(next:80)
c jcc       read (string,*,err=110,end=110)  ia,ib,fc,bd
            read (string,*,err=110,end=110)  ia,ib,fc,bd,edb
  110       continue
            call numeral (ia,pa,size)
            call numeral (ib,pb,size)
            nb5 = nb5 + 1
            if (ia .le. ib) then
               kb5(nb5) = pa//pb
            else
               kb5(nb5) = pb//pa
            end if
            fcon5(nb5) = fc
            blen5(nb5) = bd
            ebd5(nb) = edb
c
c     bond stretching parameters for 4-membered rings
c
         else if (keyword(1:6) .eq. 'BOND4 ') then
            ia = 0
            ib = 0
            fc = 0.0d0
            bd = 0.0d0
            edb = 0.d0
            string = record(next:80)
c jcc       read (string,*,err=120,end=120)  ia,ib,fc,bd
            read (string,*,err=120,end=120)  ia,ib,fc,bd,edb
  120       continue
            call numeral (ia,pa,size)
            call numeral (ib,pb,size)
            nb4 = nb4 + 1
            if (ia .le. ib) then
               kb4(nb4) = pa//pb
            else
               kb4(nb4) = pb//pa
            end if
            fcon4(nb4) = fc
            blen4(nb4) = bd
            ebd4(nb) = edb
c
c     bond stretching parameters for 3-membered rings
c
         else if (keyword(1:6) .eq. 'BOND3 ') then
            ia = 0
            ib = 0
            fc = 0.0d0
            bd = 0.0d0
            edb = 0.d0
            string = record(next:80)
c jcc       read (string,*,err=130,end=130)  ia,ib,fc,bd
            read (string,*,err=130,end=130)  ia,ib,fc,bd,edb
  130       continue
            call numeral (ia,pa,size)
            call numeral (ib,pb,size)
            nb3 = nb3 + 1
            if (ia .le. ib) then
               kb3(nb3) = pa//pb
            else
               kb3(nb3) = pb//pa
            end if
            fcon3(nb3) = fc
            blen3(nb3) = bd
            ebd3(nb) = edb
c
c     bond angle bending parameters
c
         else if (keyword(1:6) .eq. 'ANGLE ') then
            ia = 0
            ib = 0
            ic = 0
            fc = 0.0d0
            an1 = 0.0d0
            an2 = 0.0d0
            an3 = 0.0d0
            string = record(next:80)
            read (string,*,err=140,end=140)  ia,ib,ic,fc,an1,an2,an3
  140       continue
            call numeral (ia,pa,size)
            call numeral (ib,pb,size)
            call numeral (ic,pc,size)
            na = na + 1
            if (ia .le. ic) then
               ka(na) = pa//pb//pc
            else
               ka(na) = pc//pb//pa
            end if
            con(na) = fc
            ang(1,na) = an1
            ang(2,na) = an2
            ang(3,na) = an3
c
c     angle bending parameters for 5-membered rings
c
         else if (keyword(1:7) .eq. 'ANGLE5 ') then
            ia = 0
            ib = 0
            ic = 0
            fc = 0.0d0
            an1 = 0.0d0
            an2 = 0.0d0
            an3 = 0.0d0
            string = record(next:80)
            read (string,*,err=150,end=150)  ia,ib,ic,fc,an1,an2,an3
  150       continue
            call numeral (ia,pa,size)
            call numeral (ib,pb,size)
            call numeral (ic,pc,size)
            na5 = na5 + 1
            if (ia .le. ic) then
               ka5(na5) = pa//pb//pc
            else
               ka5(na5) = pc//pb//pa
            end if
            con5(na5) = fc
            ang5(1,na5) = an1
            ang5(2,na5) = an2
            ang5(3,na5) = an3
c
c     angle bending parameters for 4-membered rings
c
         else if (keyword(1:7) .eq. 'ANGLE4 ') then
            ia = 0
            ib = 0
            ic = 0
            fc = 0.0d0
            an1 = 0.0d0
            an2 = 0.0d0
            an3 = 0.0d0
            string = record(next:80)
            read (string,*,err=160,end=160)  ia,ib,ic,fc,an1,an2,an3
  160       continue
            call numeral (ia,pa,size)
            call numeral (ib,pb,size)
            call numeral (ic,pc,size)
            na4 = na4 + 1
            if (ia .le. ic) then
               ka4(na4) = pa//pb//pc
            else
               ka4(na4) = pc//pb//pa
            end if
            con4(na4) = fc
            ang4(1,na4) = an1
            ang4(2,na4) = an2
            ang4(3,na4) = an3
c
c     angle bending parameters for 3-membered rings
c
         else if (keyword(1:7) .eq. 'ANGLE3 ') then
            ia = 0
            ib = 0
            ic = 0
            fc = 0.0d0
            an1 = 0.0d0
            an2 = 0.0d0
            an3 = 0.0d0
            string = record(next:80)
            read (string,*,err=170,end=170)  ia,ib,ic,fc,an1,an2,an3
  170       continue
            call numeral (ia,pa,size)
            call numeral (ib,pb,size)
            call numeral (ic,pc,size)
            na3 = na3 + 1
            if (ia .le. ic) then
               ka3(na3) = pa//pb//pc
            else
               ka3(na3) = pc//pb//pa
            end if
            con3(na3) = fc
            ang3(1,na3) = an1
            ang3(2,na3) = an2
            ang3(3,na3) = an3
c
c     stretch-bend parameters
c
         else if (keyword(1:7) .eq. 'STRBND ') then
            ia = 0
            ba1 = 0.0d0
            ba2 = 0.0d0
            ba3 = 0.0d0
            string = record(next:80)
            read (string,*,err=180,end=180)  ia,ba1,ba2,ba3
  180       continue
            stbn(1,ia) = ba1
            stbn(2,ia) = ba2
            stbn(3,ia) = ba3
c
c     out-of-plane bend parameters
c
         else if (keyword(1:7) .eq. 'OPBEND ') then
            ia = 0
            ib = 0
            fc = 0.0d0
            string = record(next:80)
            read (string,*,err=190,end=190)  ia,ib,fc
  190       continue
            call numeral (ia,pa,size)
            call numeral (ib,pb,size)
            nopb = nopb + 1
            kaopb(nopb) = pa//pb
            copb(nopb) = fc
c
c     Urey-Bradley parameters
c
         else if (keyword(1:9) .eq. 'UREYBRAD ') then
            ia = 0
            ib = 0
            ic = 0
            fc = 0.0d0
            dst = 0.0d0
            string = record(next:80)
            read (string,*,err=200,end=200)  ia,ib,ic,fc,dst
  200       continue
            call numeral (ia,pa,size)
            call numeral (ib,pb,size)
            call numeral (ic,pc,size)
            nu = nu + 1
            if (ia .le. ic) then
               ku(nu) = pa//pb//pc
            else
               ku(nu) = pc//pb//pa
            end if
            ucon(nu) = fc
            dst13(nu) = dst
c
c     angle-angle parameters
c
         else if (keyword(1:7) .eq. 'ANGANG ') then
            ia = 0
            aa1 = 0.0d0
            aa2 = 0.0d0
            aa3 = 0.0d0
            string = record(next:80)
            read (string,*,err=210,end=210)  ia,aa1,aa2,aa3
  210       continue
            anan(1,ia) = aa1
            anan(2,ia) = aa2
            anan(3,ia) = aa3
c
c     improper dihedral parameters
c
         else if (keyword(1:9) .eq. 'IMPROPER ') then
            ia = 0
            ib = 0
            ic = 0
            id = 0
            dk = 0.0d0
            vd = 0.0d0
            string = record(next:80)
            read (string,*,err=220,end=220)  ia,ib,ic,id,dk,vd
  220       continue
            call numeral (ia,pa,size)
            call numeral (ib,pb,size)
            call numeral (ic,pc,size)
            call numeral (id,pd,size)
            ndi = ndi + 1
            kdi(ndi) = pa//pb//pc//pd
            dcon(ndi) = dk
            tdi(ndi) = vd
c
c     improper torsional parameters
c
         else if (keyword(1:8) .eq. 'IMPTORS ') then
            ia = 0
            ib = 0
            ic = 0
            id = 0
            do i = 1, 6
               vt(i) = 0.0d0
               st(i) = 0.0d0
               ft(i) = 0
            end do
            string = record(next:80)
            read (string,*,err=230,end=230)  ia,ib,ic,id,
     &                                       (vt(j),st(j),ft(j),j=1,6)
  230       continue
            call numeral (ia,pa,size)
            call numeral (ib,pb,size)
            call numeral (ic,pc,size)
            call numeral (id,pd,size)
            nti = nti + 1
            kti(nti) = pa//pb//pc//pd
            call torphase (ft,vt,st)
            ti1(1,nti) = vt(1)
            ti1(2,nti) = st(1)
            ti2(1,nti) = vt(2)
            ti2(2,nti) = st(2)
            ti3(1,nti) = vt(3)
            ti3(2,nti) = st(3)
c
c     torsional parameters
c
         else if (keyword(1:8) .eq. 'TORSION ') then
            ia = 0
            ib = 0
            ic = 0
            id = 0
            do i = 1, 6
               vt(i) = 0.0d0
               st(i) = 0.0d0
               ft(i) = 0
            end do
            string = record(next:80)
            read (string,*,err=240,end=240)  ia,ib,ic,id,
     &                                       (vt(j),st(j),ft(j),j=1,6)
  240       continue
            call numeral (ia,pa,size)
            call numeral (ib,pb,size)
            call numeral (ic,pc,size)
            call numeral (id,pd,size)
            nt = nt + 1
            if (ib .lt. ic) then
               kt(nt) = pa//pb//pc//pd
            else if (ic .lt. ib) then
               kt(nt) = pd//pc//pb//pa
            else if (ia .le. id) then
               kt(nt) = pa//pb//pc//pd
            else if (id .lt. ia) then
               kt(nt) = pd//pc//pb//pa
            end if
            call torphase (ft,vt,st)
            t1(1,nt) = vt(1)
            t1(2,nt) = st(1)
            t2(1,nt) = vt(2)
            t2(2,nt) = st(2)
            t3(1,nt) = vt(3)
            t3(2,nt) = st(3)
            t4(1,nt) = vt(4)
            t4(2,nt) = st(4)
            t5(1,nt) = vt(5)
            t5(2,nt) = st(5)
            t6(1,nt) = vt(6)
            t6(2,nt) = st(6)
c
c     torsional parameters for 5-membered rings
c
         else if (keyword(1:9) .eq. 'TORSION5 ') then
            ia = 0
            ib = 0
            ic = 0
            id = 0
            do i = 1, 6
               vt(i) = 0.0d0
               st(i) = 0.0d0
               ft(i) = 0
            end do
            string = record(next:80)
            read (string,*,err=250,end=250)  ia,ib,ic,id,
     &                                       (vt(j),st(j),ft(j),j=1,6)
  250       continue
            call numeral (ia,pa,size)
            call numeral (ib,pb,size)
            call numeral (ic,pc,size)
            call numeral (id,pd,size)
            nt5 = nt5 + 1
            if (ib .lt. ic) then
               kt5(nt5) = pa//pb//pc//pd
            else if (ic .lt. ib) then
               kt5(nt5) = pd//pc//pb//pa
            else if (ia .le. id) then
               kt5(nt5) = pa//pb//pc//pd
            else if (id .lt. ia) then
               kt5(nt5) = pd//pc//pb//pa
            end if
            call torphase (ft,vt,st)
            t15(1,nt5) = vt(1)
            t15(2,nt5) = st(1)
            t25(1,nt5) = vt(2)
            t25(2,nt5) = st(2)
            t35(1,nt5) = vt(3)
            t35(2,nt5) = st(3)
            t45(1,nt5) = vt(4)
            t45(2,nt5) = st(4)
            t55(1,nt5) = vt(5)
            t55(2,nt5) = st(5)
            t65(1,nt5) = vt(6)
            t65(2,nt5) = st(6)
c
c     torsional parameters for 4-membered rings
c
         else if (keyword(1:9) .eq. 'TORSION4 ') then
            ia = 0
            ib = 0
            ic = 0
            id = 0
            do i = 1, 6
               vt(i) = 0.0d0
               st(i) = 0.0d0
               ft(i) = 0
            end do
            string = record(next:80)
            read (string,*,err=260,end=260)  ia,ib,ic,id,
     &                                       (vt(i),st(i),ft(i),i=1,6)
  260       continue
            call numeral (ia,pa,size)
            call numeral (ib,pb,size)
            call numeral (ic,pc,size)
            call numeral (id,pd,size)
            nt4 = nt4 + 1
            if (ib .lt. ic) then
               kt4(nt4) = pa//pb//pc//pd
            else if (ic .lt. ib) then
               kt4(nt4) = pd//pc//pb//pa
            else if (ia .le. id) then
               kt4(nt4) = pa//pb//pc//pd
            else if (id .lt. ia) then
               kt4(nt4) = pd//pc//pb//pa
            end if
            call torphase (ft,vt,st)
            t14(1,nt4) = vt(1)
            t14(2,nt4) = st(1)
            t24(1,nt4) = vt(2)
            t24(2,nt4) = st(2)
            t34(1,nt4) = vt(3)
            t34(2,nt4) = st(3)
            t44(1,nt4) = vt(4)
            t44(2,nt4) = st(4)
            t54(1,nt4) = vt(5)
            t54(2,nt4) = st(5)
            t64(1,nt4) = vt(6)
            t64(2,nt4) = st(6)
c
c     stretch-torsion parameters
c
         else if (keyword(1:8) .eq. 'STRTORS ') then
            ia = 0
            ib = 0
            bt1 = 0.0d0
            bt2 = 0.0d0
            bt3 = 0.0d0
            string = record(next:80)
            read (string,*,err=270,end=270)  ia,ib,bt1,bt2,bt3
  270       continue
            call numeral (ia,pa,size)
            call numeral (ib,pb,size)
            nbt = nbt + 1
            if (ia .le. ib) then
               kbt(nbt) = pa//pb
            else
               kbt(nbt) = pb//pa
            end if
            btcon(1,nbt) = bt1
            btcon(2,nbt) = bt2
            btcon(3,nbt) = bt3
c
c     atomic partial charge parameters
c
         else if (keyword(1:7) .eq. 'CHARGE ') then
            ia = 0
            cg = 0.0d0
            string = record(next:80)
            read (string,*,err=280,end=280)  ia,cg
  280       continue
            chg(ia) = cg
c
c     bond dipole moment parameters
c
         else if (keyword(1:7) .eq. 'DIPOLE ') then
            ia = 0
            ib = 0
            dp = 0.0d0
            ps = 0.5d0
            string = record(next:80)
            read (string,*,err=290,end=290)  ia,ib,dp,ps
  290       continue
            call numeral (ia,pa,size)
            call numeral (ib,pb,size)
            nd = nd + 1
            if (ia .le. ib) then
               kd(nd) = pa//pb
            else
               kd(nd) = pb//pa
            end if
            dpl(nd) = dp
            pos(nd) = ps
c
c     bond dipole moment parameters for 5-membered rings
c
         else if (keyword(1:8) .eq. 'DIPOLE5 ') then
            ia = 0
            ib = 0
            dp = 0.0d0
            ps = 0.5d0
            string = record(next:80)
            read (string,*,err=300,end=300)  ia,ib,dp,ps
  300       continue
            call numeral (ia,pa,size)
            call numeral (ib,pb,size)
            nd5 = nd5 + 1
            if (ia .le. ib) then
               kd5(nd5) = pa//pb
            else
               kd5(nd5) = pb//pa
            end if
            dpl5(nd5) = dp
            pos5(nd5) = ps
c
c     bond dipole moment parameters for 4-membered rings
c
         else if (keyword(1:8) .eq. 'DIPOLE4 ') then
            ia = 0
            ib = 0
            dp = 0.0d0
            ps = 0.5d0
            string = record(next:80)
            read (string,*,err=310,end=310)  ia,ib,dp,ps
  310       continue
            call numeral (ia,pa,size)
            call numeral (ib,pb,size)
            nd4 = nd4 + 1
            if (ia .le. ib) then
               kd4(nd4) = pa//pb
            else
               kd4(nd4) = pb//pa
            end if
            dpl4(nd4) = dp
            pos4(nd4) = ps
c
c     bond dipole moment parameters for 3-membered rings
c
         else if (keyword(1:8) .eq. 'DIPOLE3 ') then
            ia = 0
            ib = 0
            dp = 0.0d0
            ps = 0.5d0
            string = record(next:80)
            read (string,*,err=320,end=320)  ia,ib,dp,ps
  320       continue
            call numeral (ia,pa,size)
            call numeral (ib,pb,size)
            nd3 = nd3 + 1
            if (ia .le. ib) then
               kd3(nd3) = pa//pb
            else
               kd3(nd3) = pb//pa
            end if
            dpl3(nd3) = dp
            pos3(nd3) = ps
c
c     atomic multipole moment parameters
c
         else if (keyword(1:10) .eq. 'MULTIPOLE ') then
            ia = 0
            ib = 0
            ic = 0
            axt = 'Z-then-X'
            do i = 1, 13
               pl(i) = 0.0d0
            end do
            string = record(next:80)
            read (string,*,err=370,end=370)  ia,ib,ic,pl(1)
            read (iprm,330,end=430)  record
  330       format (a80)
            read (record,*,err=370,end=370)  pl(2),pl(3),pl(4)
            read (iprm,340,end=430)  record
  340       format (a80)
            read (record,*,err=370,end=370)  pl(5)
            read (iprm,350,end=430)  record
  350       format (a80)
            read (record,*,err=370,end=370)  pl(8),pl(9)
            read (iprm,360,end=430)  record
  360       format (a80)
            read (record,*,err=370,end=370)  pl(11),pl(12),pl(13)
  370       continue
            if (ic .lt. 0) then
               ic = -ic
               axt = 'Bisector'
            end if
            call numeral (ia,pa,size)
            call numeral (ib,pb,size)
            call numeral (ic,pc,size)
            nmp = nmp + 1
            kmp(nmp) = pa//pb//pc
            mpaxis(nmp) = axt
            multip(1,nmp) = pl(1)
            multip(2,nmp) = pl(2)
            multip(3,nmp) = pl(3)
            multip(4,nmp) = pl(4)
            multip(5,nmp) = pl(5)
            multip(6,nmp) = pl(8)
            multip(7,nmp) = pl(11)
            multip(8,nmp) = pl(8)
            multip(9,nmp) = pl(9)
            multip(10,nmp) = pl(12)
            multip(11,nmp) = pl(11)
            multip(12,nmp) = pl(12)
            multip(13,nmp) = pl(13)
c
c     atomic dipole polarizability parameters
c
         else if (keyword(1:9) .eq. 'POLARIZE ') then
            ia = 0
            pol = 0.0d0
            string = record(next:80)
            read (string,*,err=380,end=380)  ia,pol
  380       continue
            polr(ia) = pol
c
c     conjugated pisystem atom parameters
c
         else if (keyword(1:7) .eq. 'PIATOM ') then
            ia = 0
            el = 0.0d0
            iz = 0.0d0
            rp = 0.0d0
            string = record(next:80)
            read (string,*,err=390,end=390)  ia,el,iz,rp
  390       continue
            electron(ia) = el
            ionize(ia) = iz
            repulse(ia) = rp
c
c     conjugated pisystem bond parameters
c
         else if (keyword(1:7) .eq. 'PIBOND ') then
            ia = 0
            ib = 0
            ss = 0.0d0
            ts = 0.0d0
            string = record(next:80)
            read (string,*,err=400,end=400)  ia,ib,ss,ts
  400       continue
            call numeral (ia,pa,size)
            call numeral (ib,pb,size)
            npi = npi + 1
            if (ia .le. ib) then
               kpi(npi) = pa//pb
            else
               kpi(npi) = pb//pa
            end if
            sslope(npi) = ss
            tslope(npi) = ts
c
c     biopolymer atom type conversion definitions
c
         else if (keyword(1:8) .eq. 'BIOTYPE ') then
            string = record(next:80)
            read (string,*,err=410,end=410)  ia
            call getword (record,string,next)
            call getstring (record,string,next)
            string = record(next:80)
            read (string,*,err=410,end=410)  ib
            biotyp(ia) = ib
  410       continue
         end if
  420    continue
      end do
  430 continue
c
CAMBP#ifdef MPI
CAMBP      if(master) then
CAMBP         iend=1
CAMBP         call mpi_bcast(iend, 1, mpi_integer, 0, commsander, ier) 
CAMBP      end if
CAMBP#endif      
c
c     zero out unused values for parameter atom types
c
      do i = nvp+1, maxnvp
         kvpr(i) = '      '
      end do
      do i = nb+1, maxnb
         kb(i) = '      '
      end do
      do i = nb5+1, maxnb5
         kb5(i) = '      '
      end do
      do i = nb4+1, maxnb4
         kb4(i) = '      '
      end do
      do i = nb3+1, maxnb3
         kb3(i) = '      '
      end do
      do i = na+1, maxna
         ka(i) = '         '
      end do
      do i = na5+1, maxna5
         ka5(i) = '         '
      end do
      do i = na4+1, maxna4
         ka4(i) = '         '
      end do
      do i = na3+1, maxna3
         ka3(i) = '         '
      end do
      do i = nopb+1, maxnopb
         kaopb(i) = '      '
      end do
      do i = nu+1, maxnu
         ku(i) = '         '
      end do
      do i = ndi+1, maxndi
         kdi(i) = '            '
      end do
      do i = nti+1, maxnti
         kti(i) = '            '
      end do
      do i = nt+1, maxnt
         kt(i) = '            '
      end do
      do i = nt5+1, maxnt5
         kt5(i) = '            '
      end do
      do i = nt4+1, maxnt4
         kt4(i) = '            '
      end do
      do i = nbt+1, maxnbt
         kbt(i) = '      '
      end do
      do i = nd+1, maxnd
         kd(i) = '      '
      end do
      do i = nd5+1, maxnd5
         kd5(i) = '      '
      end do
      do i = nd4+1, maxnd4
         kd4(i) = '      '
      end do
      do i = nd3+1, maxnd3
         kd3(i) = '      '
      end do
      do i = nmp+1, maxnmp
         kmp(i) = '         '
      end do
      do i = npi+1, maxnpi
         kpi(i) = '      '
      end do
      return
      end
