      subroutine chnbrk (mcaaat, atomin, seqbcd, brksym, chnsz,  chnct, CHNB001
     &                   chnend, caonly, seqlen, chstop, chstrt, chnlt) CHNB002
c     search through looking for distant peptide bonds. if any over     CHNB003
c     the limit are found or if a c or n atom doesn't exist then a      CHNB004
c     chain break is deemed to occur                                    CHNB005
c                                                                       CHNB006
      include 'brkcln.par'                                              CHNB007
c                                                                       CHNB008
      real      mcaaat(ncoord,mnchna,maxres)                            CHNB009
c                                                                       CHNB010
      logical   atomin(mnchna,maxres), caonly                           CHNB011
c                                                                       CHNB012
      integer   chnsz(maxchn), chnct, seqlen, chnend(maxchn), chnlt     CHNB013
c                                                                       CHNB014
      character seqbcd(maxres)*6, brksym(maxres)*1, chstop(maxres)*1,   CHNB015
     &          chstrt(maxres)*1                                        CHNB016
c                                                                       CHNB017
      real      atdist                                                  CHNB018
c                                                                       CHNB019
      integer   nxres, ninchn, i                                        CHNB020
c                                                                       CHNB021
  500 format (' Chain letter change but no chain break between ', i4,   CHNB022
     & 2x, a6, ' and ', i4, 2x, a6)                                     CHNB023
c                                                                       CHNB024
      do 100 i = 1, maxchn                                              CHNB025
      chnsz(i) = 0                                                      CHNB026
  100 continue                                                          CHNB027
      do 200 nxres = 1, seqlen                                          CHNB028
      brksym(nxres) = space                                             CHNB029
      chstop(nxres) = space                                             CHNB030
      chstrt(nxres) = space                                             CHNB031
  200 continue                                                          CHNB032
c                                                                       CHNB033
      ninchn = 1                                                        CHNB034
      chnct  = 1                                                        CHNB035
      chnlt  = 1                                                        CHNB036
      do 1000 nxres = 2, seqlen                                         CHNB037
      if (caonly) then                                                  CHNB038
         if (atdist(mcaaat(1,calph,nxres-1),mcaaat(1,calph,nxres))      CHNB039
     &      .gt. cadbnd) then                                           CHNB040
            call chnset (brksym, chnsz,  chnct,  chnend, ninchn, seqbcd,CHNB041
     &                   nxres,  seqlen, chstop, chstrt, chnlt)         CHNB042
         else                                                           CHNB043
            ninchn = ninchn + 1                                         CHNB044
            if (seqbcd(nxres-1)(1:1) .ne. seqbcd(nxres)(1:1)) then      CHNB045
CHECK v.2.1.3-->                                                        CHNB046
C               write (logfi, 500) nxres-1, seqbcd(nxres-1),            CHNB047
C     +                            nxres,   seqbcd(nxres)               CHNB048
               write (*, 500) nxres-1, seqbcd(nxres-1),                 CHNB049
     &                            nxres,   seqbcd(nxres)                CHNB050
CHECK v.2.1.3<--                                                        CHNB051
CHECK v.1.0-->                                                          CHNB052
C               write (*,     500) nxres-1, seqbcd(nxres-1),            CHNB053
C     +                            nxres,   seqbcd(nxres)               CHNB054
CHECK v.1.0<--                                                          CHNB055
            end if                                                      CHNB056
         end if                                                         CHNB057
      else                                                              CHNB058
         if (atomin(carb,nxres-1) .and. atomin(nmain,nxres)) then       CHNB059
            if (atdist(mcaaat(1,carb,nxres-1),                          CHNB060
     &                 mcaaat(1,nmain,nxres)) .gt. pepbnd) then         CHNB061
               call chnset (brksym, chnsz, chnct,  chnend, ninchn,      CHNB062
     &                      seqbcd, nxres, seqlen, chstop, chstrt,      CHNB063
     &                      chnlt)                                      CHNB064
            else                                                        CHNB065
               ninchn = ninchn + 1                                      CHNB066
               if (seqbcd(nxres-1)(1:1) .ne. seqbcd(nxres)(1:1)) then   CHNB067
CHECK v.2.1.3-->                                                        CHNB068
C                  write (logfi, 500) nxres-1, seqbcd(nxres-1),         CHNB069
C     +                               nxres,   seqbcd(nxres)            CHNB070
                  write (*, 500) nxres-1, seqbcd(nxres-1),              CHNB071
     &                               nxres,   seqbcd(nxres)             CHNB072
CHECK v.2.1.3<--                                                        CHNB073
CHECK v.1.0-->                                                          CHNB074
C                  write (*,     500) nxres-1, seqbcd(nxres-1),         CHNB075
C     +                               nxres,   seqbcd(nxres)            CHNB076
CHECK v.1.0<--                                                          CHNB077
                  chstop(nxres-1) = '>'                                 CHNB078
                  chstrt(nxres)   = '<'                                 CHNB079
               end if                                                   CHNB080
            end if                                                      CHNB081
         else                                                           CHNB082
            call chnset (brksym, chnsz,  chnct,  chnend, ninchn, seqbcd,CHNB083
     &                   nxres,  seqlen, chstop, chstrt, chnlt)         CHNB084
         end if                                                         CHNB085
      end if                                                            CHNB086
 1000 continue                                                          CHNB087
      call chnset (brksym,   chnsz,  chnct,  chnend, ninchn, seqbcd,    CHNB088
     &             seqlen+1, seqlen, chstop, chstrt, chnlt)             CHNB089
      end                                                               CHNB090
