      Subroutine Chnbrk(mcaaat, atomin, seqbcd, brksym, chnsz, chnct,   CHNB001
     &                  chnend, caonly, seqlen)                         CHNB002
c                                                                       CHNB003
c     search through looking for distant peptide bonds. If any over     CHNB004
c     the limit are found or if a c or n atom does not exist then a     CHNB005
c     chain break is deemed to occur                                    CHNB006
c                                                                       CHNB007
      include 'sstruc.par'                                              CHNB008
      real      mcaaat(ncoord,mnchna,maxres)                            CHNB009
      logical   atomin(mnchna,maxres), caonly                           CHNB010
      Integer   chnsz(maxchn), chnct, seqlen, chnend(maxchn)            CHNB011
      character seqbcd(maxres)*6, brksym(maxres)*1                      CHNB012
      Real      atdist                                                  CHNB013
                                                                        CHNB014
      Integer   nxres, ninchn                                           CHNB015
                                                                        CHNB016
      do 200 nxres = 1, seqlen                                          CHNB017
      brksym(nxres) = space                                             CHNB018
  200 continue                                                          CHNB019
      ninchn = 1                                                        CHNB020
      chnct = 1                                                         CHNB021
      do 1000, nxres = 2, seqlen                                        CHNB022
      if (caonly) then                                                  CHNB023
         if (atdist(mcaaat(1,calph,nxres-1),mcaaat(1,calph,nxres))      CHNB024
     &      .gt. cadbnd) then                                           CHNB025
            call chnset(brksym, chnsz, chnct, chnend, ninchn, seqbcd,   CHNB026
     &                  nxres, seqlen)                                  CHNB027
         else                                                           CHNB028
            ninchn = ninchn + 1                                         CHNB029
            if (seqbcd(nxres-1)(1:1) .ne. seqbcd(nxres)(1:1))           CHNB030
     &         Write(errfi,500) nxres-1, seqbcd(nxres-1),               CHNB031
     &                          nxres, seqbcd(nxres)                    CHNB032
  500       format('chain letter change but no chain break between ',   CHNB033
     &             i4,2x,a6,' and',i4,2x,a6)                            CHNB034
         end if                                                         CHNB035
      else                                                              CHNB036
         If (atomin(carb,nxres-1) .and. atomin(nmain,nxres)) then       CHNB037
            if (atdist(mcaaat(1,carb,nxres-1),mcaaat(1,nmain,nxres))    CHNB038
     &          .gt. pepbnd) then                                       CHNB039
               call chnset(brksym, chnsz, chnct, chnend, ninchn, seqbcd,CHNB040
     &                     nxres, seqlen)                               CHNB041
            else                                                        CHNB042
               ninchn = ninchn + 1                                      CHNB043
               if (seqbcd(nxres-1)(1:1) .ne. seqbcd(nxres)(1:1))        CHNB044
     &            Write(errfi,500) nxres-1, seqbcd(nxres-1),            CHNB045
     &                  nxres, seqbcd(nxres)                            CHNB046
            end if                                                      CHNB047
         else                                                           CHNB048
            call chnset(brksym, chnsz, chnct, chnend, ninchn, seqbcd,   CHNB049
     &                  nxres, seqlen)                                  CHNB050
         end if                                                         CHNB051
      end if                                                            CHNB052
 1000 continue                                                          CHNB053
      call chnset(brksym, chnsz, chnct, chnend, ninchn, seqbcd,         CHNB054
     &            seqlen+1, seqlen)                                     CHNB055
      END                                                               CHNB056
